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.c143
1 files changed, 140 insertions, 3 deletions
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 0cfccc24b190..391732788911 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -38,6 +38,7 @@ static struct mt2060_config bristol_mt2060_config[2] = {
38 } 38 }
39}; 39};
40 40
41
41static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = { 42static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
42 .band_caps = BAND_VHF | BAND_UHF, 43 .band_caps = BAND_VHF | BAND_UHF,
43 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0), 44 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
@@ -445,14 +446,19 @@ static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
445 == NULL ? -ENODEV : 0; 446 == NULL ? -ENODEV : 0;
446} 447}
447 448
448#define DEFAULT_RC_INTERVAL 150 449#define DEFAULT_RC_INTERVAL 50
449 450
450static u8 rc_request[] = { REQUEST_POLL_RC, 0 }; 451static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
451 452
452/* Number of keypresses to ignore before start repeating */ 453/* Number of keypresses to ignore before start repeating */
453#define RC_REPEAT_DELAY 2 454#define RC_REPEAT_DELAY 6
455#define RC_REPEAT_DELAY_V1_20 10
454 456
455static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 457
458
459/* Used by firmware versions < 1.20 (deprecated) */
460static int dib0700_rc_query_legacy(struct dvb_usb_device *d, u32 *event,
461 int *state)
456{ 462{
457 u8 key[4]; 463 u8 key[4];
458 int i; 464 int i;
@@ -529,6 +535,137 @@ static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
529 return 0; 535 return 0;
530} 536}
531 537
538/* This is the structure of the RC response packet starting in firmware 1.20 */
539struct dib0700_rc_response {
540 u8 report_id;
541 u8 data_state;
542 u8 system_msb;
543 u8 system_lsb;
544 u8 data;
545 u8 not_data;
546};
547
548/* This supports the new IR response format for firmware v1.20 */
549static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
550 int *state)
551{
552 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
553 struct dib0700_state *st = d->priv;
554 struct dib0700_rc_response poll_reply;
555 u8 buf[6];
556 int i;
557 int status;
558 int actlen;
559 int found = 0;
560
561 /* Set initial results in case we exit the function early */
562 *event = 0;
563 *state = REMOTE_NO_KEY_PRESSED;
564
565 /* Firmware v1.20 provides RC data via bulk endpoint 1 */
566 status = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, 1), buf,
567 sizeof(buf), &actlen, 50);
568 if (status < 0) {
569 /* No data available (meaning no key press) */
570 return 0;
571 }
572
573 if (actlen != sizeof(buf)) {
574 /* We didn't get back the 6 byte message we expected */
575 err("Unexpected RC response size [%d]", actlen);
576 return -1;
577 }
578
579 poll_reply.report_id = buf[0];
580 poll_reply.data_state = buf[1];
581 poll_reply.system_msb = buf[2];
582 poll_reply.system_lsb = buf[3];
583 poll_reply.data = buf[4];
584 poll_reply.not_data = buf[5];
585
586 /*
587 info("rid=%02x ds=%02x sm=%02x sl=%02x d=%02x nd=%02x\n",
588 poll_reply.report_id, poll_reply.data_state,
589 poll_reply.system_msb, poll_reply.system_lsb,
590 poll_reply.data, poll_reply.not_data);
591 */
592
593 if ((poll_reply.data + poll_reply.not_data) != 0xff) {
594 /* Key failed integrity check */
595 err("key failed integrity check: %02x %02x %02x %02x",
596 poll_reply.system_msb, poll_reply.system_lsb,
597 poll_reply.data, poll_reply.not_data);
598 return -1;
599 }
600
601 /* Find the key in the map */
602 for (i = 0; i < d->props.rc_key_map_size; i++) {
603 if (keymap[i].custom == poll_reply.system_lsb &&
604 keymap[i].data == poll_reply.data) {
605 *event = keymap[i].event;
606 found = 1;
607 break;
608 }
609 }
610
611 if (found == 0) {
612 err("Unknown remote controller key: %02x %02x %02x %02x",
613 poll_reply.system_msb, poll_reply.system_lsb,
614 poll_reply.data, poll_reply.not_data);
615 d->last_event = 0;
616 return 0;
617 }
618
619 if (poll_reply.data_state == 1) {
620 /* New key hit */
621 st->rc_counter = 0;
622 *event = keymap[i].event;
623 *state = REMOTE_KEY_PRESSED;
624 d->last_event = keymap[i].event;
625 } else if (poll_reply.data_state == 2) {
626 /* Key repeated */
627 st->rc_counter++;
628
629 /* prevents unwanted double hits */
630 if (st->rc_counter > RC_REPEAT_DELAY_V1_20) {
631 *event = d->last_event;
632 *state = REMOTE_KEY_PRESSED;
633 st->rc_counter = RC_REPEAT_DELAY_V1_20;
634 }
635 } else {
636 err("Unknown data state [%d]", poll_reply.data_state);
637 }
638
639 return 0;
640}
641
642static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
643{
644 struct dib0700_state *st = d->priv;
645
646 /* Because some people may have improperly named firmware files,
647 let's figure out whether to use the new firmware call or the legacy
648 call based on the firmware version embedded in the file */
649 if (st->rc_func_version == 0) {
650 u32 hwver, romver, ramver, fwtype;
651 int ret = dib0700_get_version(d, &hwver, &romver, &ramver,
652 &fwtype);
653 if (ret < 0) {
654 err("Could not determine version info");
655 return -1;
656 }
657 if (ramver < 0x10200)
658 st->rc_func_version = 1;
659 else
660 st->rc_func_version = 2;
661 }
662
663 if (st->rc_func_version == 2)
664 return dib0700_rc_query_v1_20(d, event, state);
665 else
666 return dib0700_rc_query_legacy(d, event, state);
667}
668
532static struct dvb_usb_rc_key dib0700_rc_keys[] = { 669static struct dvb_usb_rc_key dib0700_rc_keys[] = {
533 /* Key codes for the tiny Pinnacle remote*/ 670 /* Key codes for the tiny Pinnacle remote*/
534 { 0x07, 0x00, KEY_MUTE }, 671 { 0x07, 0x00, KEY_MUTE },