aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/dib0700_devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dib0700_devices.c')
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 9fd8399e5d8f..fe96f795792b 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -445,6 +445,9 @@ static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
445 445
446static u8 rc_request[] = { REQUEST_POLL_RC, 0 }; 446static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
447 447
448/* Number of keypresses to ignore before start repeating */
449#define RC_REPEAT_DELAY 2
450
448static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 451static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
449{ 452{
450 u8 key[4]; 453 u8 key[4];
@@ -458,18 +461,67 @@ static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
458 err("RC Query Failed"); 461 err("RC Query Failed");
459 return -1; 462 return -1;
460 } 463 }
464
465 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
461 if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0; 466 if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0;
462 if (key[3-1]!=st->rc_toggle) { 467
468 /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)key[3-2],(int)key[3-3],(int)key[3-1],(int)key[3]); */
469
470 dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */
471
472 switch (dvb_usb_dib0700_ir_proto) {
473 case 0: {
474 /* NEC protocol sends repeat code as 0 0 0 FF */
475 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
476 (key[3] == 0xFF)) {
477 st->rc_counter++;
478 if (st->rc_counter > RC_REPEAT_DELAY) {
479 *event = d->last_event;
480 *state = REMOTE_KEY_PRESSED;
481 st->rc_counter = RC_REPEAT_DELAY;
482 }
483 return 0;
484 }
463 for (i=0;i<d->props.rc_key_map_size; i++) { 485 for (i=0;i<d->props.rc_key_map_size; i++) {
464 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) { 486 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) {
487 st->rc_counter = 0;
488 *event = keymap[i].event;
489 *state = REMOTE_KEY_PRESSED;
490 d->last_event = keymap[i].event;
491 return 0;
492 }
493 }
494 break;
495 }
496 default: {
497 /* RC-5 protocol changes toggle bit on new keypress */
498 for (i = 0; i < d->props.rc_key_map_size; i++) {
499 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) {
500 if (d->last_event == keymap[i].event &&
501 key[3-1] == st->rc_toggle) {
502 st->rc_counter++;
503 /* prevents unwanted double hits */
504 if (st->rc_counter > RC_REPEAT_DELAY) {
505 *event = d->last_event;
506 *state = REMOTE_KEY_PRESSED;
507 st->rc_counter = RC_REPEAT_DELAY;
508 }
509
510 return 0;
511 }
512 st->rc_counter = 0;
465 *event = keymap[i].event; 513 *event = keymap[i].event;
466 *state = REMOTE_KEY_PRESSED; 514 *state = REMOTE_KEY_PRESSED;
467 st->rc_toggle=key[3-1]; 515 st->rc_toggle = key[3-1];
516 d->last_event = keymap[i].event;
468 return 0; 517 return 0;
469 } 518 }
470 } 519 }
471 err("Unknown remote controller key : %2X %2X",(int)key[3-2],(int)key[3-3]); 520 break;
521 }
472 } 522 }
523 err("Unknown remote controller key: %2X %2X %2X %2X", (int) key[3-2], (int) key[3-3], (int) key[3-1], (int) key[3]);
524 d->last_event = 0;
473 return 0; 525 return 0;
474} 526}
475 527