Merge branch 'fix/hda' into for-linus
[cascardo/linux.git] / drivers / media / IR / nuvoton-cir.c
index 2f0f780..acc729c 100644 (file)
@@ -586,7 +586,7 @@ static void nvt_dump_rx_buf(struct nvt_dev *nvt)
  */
 static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
 {
-       struct ir_raw_event rawir = { .pulse = false, .duration = 0 };
+       DEFINE_IR_RAW_EVENT(rawir);
        unsigned int count;
        u32 carrier;
        u8 sample;
@@ -603,6 +603,8 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
        count = nvt->pkts;
        nvt_dbg_verbose("Processing buffer of len %d", count);
 
+       init_ir_raw_event(&rawir);
+
        for (i = 0; i < count; i++) {
                nvt->pkts--;
                sample = nvt->buf[i];
@@ -622,6 +624,8 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
                }
 
                rawir.duration += nvt->rawir.duration;
+
+               init_ir_raw_event(&nvt->rawir);
                nvt->rawir.duration = 0;
                nvt->rawir.pulse = rawir.pulse;
 
@@ -641,11 +645,15 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)
                 * indicates end of IR signal, but new data incoming. In both
                 * cases, it means we're ready to call ir_raw_event_handle
                 */
-               if (sample == BUF_PULSE_BIT || ((sample != BUF_LEN_MASK) &&
-                   (sample & BUF_REPEAT_MASK) == BUF_REPEAT_BYTE))
+               if ((sample == BUF_PULSE_BIT) && nvt->pkts) {
+                       nvt_dbg("Calling ir_raw_event_handle (signal end)\n");
                        ir_raw_event_handle(nvt->rdev);
+               }
        }
 
+       nvt_dbg("Calling ir_raw_event_handle (buffer empty)\n");
+       ir_raw_event_handle(nvt->rdev);
+
        if (nvt->pkts) {
                nvt_dbg("Odd, pkts should be 0 now... (its %u)", nvt->pkts);
                nvt->pkts = 0;
@@ -1016,6 +1024,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
 
        spin_lock_init(&nvt->nvt_lock);
        spin_lock_init(&nvt->tx.lock);
+       init_ir_raw_event(&nvt->rawir);
 
        ret = -EBUSY;
        /* now claim resources */