diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-03-21 12:00:55 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-17 23:52:58 -0400 |
commit | 9f1547829a6f39fe6b2da22653dff40502f3d568 (patch) | |
tree | 71c200ea5be13eef6b96f8e2290f0d2ba7792a09 /drivers/media/video/saa7134 | |
parent | ada39630c758c5c3098f4fc1361103ea2bc1afe0 (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')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-input.c | 43 |
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 dff33279ab33..32859e549afa 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) | |||
425 | void ir_raw_decode_timer_end(unsigned long data) | 425 | void ir_raw_decode_timer_end(unsigned long data) |
426 | { | 426 | { |
427 | struct saa7134_dev *dev = (struct saa7134_dev *)data; | 427 | struct saa7134_dev *dev = (struct saa7134_dev *)data; |
428 | struct card_ir *ir = dev->remote; | ||
428 | 429 | ||
429 | ir_raw_event_handle(dev->remote->dev); | 430 | ir_raw_event_handle(dev->remote->dev); |
431 | |||
432 | ir->active = 0; | ||
430 | } | 433 | } |
431 | 434 | ||
432 | void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) | 435 | 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) | |||
462 | init_timer(&ir->timer_end); | 465 | init_timer(&ir->timer_end); |
463 | ir->timer_end.function = ir_raw_decode_timer_end; | 466 | ir->timer_end.function = ir_raw_decode_timer_end; |
464 | ir->timer_end.data = (unsigned long)dev; | 467 | ir->timer_end.data = (unsigned long)dev; |
468 | ir->active = 0; | ||
465 | } | 469 | } |
466 | } | 470 | } |
467 | 471 | ||
@@ -477,8 +481,10 @@ void saa7134_ir_stop(struct saa7134_dev *dev) | |||
477 | del_timer_sync(&ir->timer_end); | 481 | del_timer_sync(&ir->timer_end); |
478 | else if (ir->nec_gpio) | 482 | else if (ir->nec_gpio) |
479 | tasklet_kill(&ir->tlet); | 483 | tasklet_kill(&ir->tlet); |
480 | else if (ir->raw_decode) | 484 | else if (ir->raw_decode) { |
481 | del_timer_sync(&ir->timer_end); | 485 | del_timer_sync(&ir->timer_end); |
486 | ir->active = 0; | ||
487 | } | ||
482 | 488 | ||
483 | ir->running = 0; | 489 | ir->running = 0; |
484 | } | 490 | } |
@@ -951,38 +957,23 @@ static int saa7134_raw_decode_irq(struct saa7134_dev *dev) | |||
951 | unsigned long timeout; | 957 | unsigned long timeout; |
952 | int count, pulse, oldpulse; | 958 | int count, pulse, oldpulse; |
953 | 959 | ||
954 | /* Disable IR IRQ line */ | ||
955 | saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18); | ||
956 | |||
957 | /* Generate initial event */ | 960 | /* Generate initial event */ |
958 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | 961 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
959 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | 962 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
960 | pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown; | 963 | pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown; |
961 | ir_raw_event_store(dev->remote->dev, pulse? IR_PULSE : IR_SPACE); | 964 | ir_raw_event_store(dev->remote->dev, pulse? IR_PULSE : IR_SPACE); |
962 | 965 | ||
963 | #if 1 | ||
964 | /* Wait up to 10 ms for event change */ | ||
965 | oldpulse = pulse; | ||
966 | for (count = 0; count < 1000; count++) { | ||
967 | udelay(10); | ||
968 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ | ||
969 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | ||
970 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | ||
971 | pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) | ||
972 | & ir->mask_keydown; | ||
973 | if (pulse != oldpulse) | ||
974 | break; | ||
975 | } | ||
976 | |||
977 | /* Store final event */ | ||
978 | ir_raw_event_store(dev->remote->dev, pulse? IR_PULSE : IR_SPACE); | ||
979 | #endif | ||
980 | /* Wait 15 ms before deciding to do something else */ | ||
981 | timeout = jiffies + jiffies_to_msecs(15); | ||
982 | mod_timer(&ir->timer_end, timeout); | ||
983 | 966 | ||
984 | /* Enable IR IRQ line */ | 967 | /* |
985 | saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18); | 968 | * Wait 15 ms from the start of the first IR event before processing |
969 | * the event. This time is enough for NEC protocol. May need adjustments | ||
970 | * to work with other protocols. | ||
971 | */ | ||
972 | if (!ir->active) { | ||
973 | timeout = jiffies + jiffies_to_msecs(15); | ||
974 | mod_timer(&ir->timer_end, timeout); | ||
975 | ir->active = 1; | ||
976 | } | ||
986 | 977 | ||
987 | return 1; | 978 | return 1; |
988 | } | 979 | } |