aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video/saa7134/saa7134-input.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-03-21 13:00:55 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-18 00:52:58 -0300
commit9f1547829a6f39fe6b2da22653dff40502f3d568 (patch)
tree71c200ea5be13eef6b96f8e2290f0d2ba7792a09 /drivers/media/video/saa7134/saa7134-input.c
parentada39630c758c5c3098f4fc1361103ea2bc1afe0 (diff)
V4L/DVB: saa7134: don't wait too much to generate an IR event on raw_decode
At raw_decode mode, the key is processed after the end of a timer. The previous code resets the timer every time something is received at the IR port. While this works fine with IR's that don't implement repeat, like Avermedia RM-JX IR, it keeps waiting until keydown, on IR's that implement NEC repeat command, like the Terratec yellow. The solution is to change the behaviour to do the timeout after the first received data. The timeout is currently set to 15 ms, as it works fine with NEC protcocol. It may need some adjustments to support other protocols and to better handle spurious detections that may happen with some IR sensors. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-input.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index dff33279ab3..32859e549af 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -425,8 +425,11 @@ static void saa7134_input_timer(unsigned long data)
void ir_raw_decode_timer_end(unsigned long data)
{
struct saa7134_dev *dev = (struct saa7134_dev *)data;
+ struct card_ir *ir = dev->remote;
ir_raw_event_handle(dev->remote->dev);
+
+ ir->active = 0;
}
void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
@@ -462,6 +465,7 @@ void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
init_timer(&ir->timer_end);
ir->timer_end.function = ir_raw_decode_timer_end;
ir->timer_end.data = (unsigned long)dev;
+ ir->active = 0;
}
}
@@ -477,8 +481,10 @@ void saa7134_ir_stop(struct saa7134_dev *dev)
del_timer_sync(&ir->timer_end);
else if (ir->nec_gpio)
tasklet_kill(&ir->tlet);
- else if (ir->raw_decode)
+ else if (ir->raw_decode) {
del_timer_sync(&ir->timer_end);
+ ir->active = 0;
+ }
ir->running = 0;
}
@@ -951,38 +957,23 @@ static int saa7134_raw_decode_irq(struct saa7134_dev *dev)
unsigned long timeout;
int count, pulse, oldpulse;
- /* Disable IR IRQ line */
- saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18);
-
/* Generate initial event */
saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown;
ir_raw_event_store(dev->remote->dev, pulse? IR_PULSE : IR_SPACE);
-#if 1
- /* Wait up to 10 ms for event change */
- oldpulse = pulse;
- for (count = 0; count < 1000; count++) {
- udelay(10);
- /* rising SAA7134_GPIO_GPRESCAN reads the status */
- saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
- saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
- pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2)
- & ir->mask_keydown;
- if (pulse != oldpulse)
- break;
- }
-
- /* Store final event */
- ir_raw_event_store(dev->remote->dev, pulse? IR_PULSE : IR_SPACE);
-#endif
- /* Wait 15 ms before deciding to do something else */
- timeout = jiffies + jiffies_to_msecs(15);
- mod_timer(&ir->timer_end, timeout);
- /* Enable IR IRQ line */
- saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18);
+ /*
+ * Wait 15 ms from the start of the first IR event before processing
+ * the event. This time is enough for NEC protocol. May need adjustments
+ * to work with other protocols.
+ */
+ if (!ir->active) {
+ timeout = jiffies + jiffies_to_msecs(15);
+ mod_timer(&ir->timer_end, timeout);
+ ir->active = 1;
+ }
return 1;
}