diff options
author | David Härdeman <david@hardeman.nu> | 2014-04-03 19:31:51 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-23 20:26:08 -0400 |
commit | af3a4a9bbeb00df3e42e77240b4cdac5479812f9 (patch) | |
tree | c58da3eef556c0122365bd3d0b37243fcf988842 /drivers/media | |
parent | 4dd9bb91bb5dc44e3f8c23c60a0ba432e50d7488 (diff) |
[media] dib0700: NEC scancode cleanup
the RC RX packet is defined as:
struct dib0700_rc_response {
...
u8 not_system;
u8 system;
...
u8 data;
u8 not_data;
The NEC protocol transmits in the order:
system
not_system
data
not_data
Note that the code defines the NEC extended scancode as:
scancode = be16_to_cpu(poll_reply->system16) << 8 | poll_reply->data;
i.e.
scancode = poll_reply->not_system << 16 |
poll_reply->system << 8 |
poll_reply->data;
Which, if the order *is* reversed, would mean that the scancode that
gets defined is in reality:
scancode = poll_reply->system << 16 |
poll_reply->not_system << 8 |
poll_reply->data;
Which is the same as the order used in drivers/media/rc/ir-nec-decoder.c.
This patch changes the code to match my assumption (the generated scancode
should, however, not change).
[m.chehab@samsung.com: rebased and fixed the decoding error message]
Signed-off-by: David Härdeman <david@hardeman.nu>
CC: Patrick Boettcher <pboettcher@kernellabs.com>
Tested-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/usb/dvb-usb/dib0700_core.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c index c14285fa8271..38b151f7ceac 100644 --- a/drivers/media/usb/dvb-usb/dib0700_core.c +++ b/drivers/media/usb/dvb-usb/dib0700_core.c | |||
@@ -658,13 +658,8 @@ out: | |||
658 | struct dib0700_rc_response { | 658 | struct dib0700_rc_response { |
659 | u8 report_id; | 659 | u8 report_id; |
660 | u8 data_state; | 660 | u8 data_state; |
661 | union { | 661 | u8 system; |
662 | u16 system16; | 662 | u8 not_system; |
663 | struct { | ||
664 | u8 not_system; | ||
665 | u8 system; | ||
666 | }; | ||
667 | }; | ||
668 | u8 data; | 663 | u8 data; |
669 | u8 not_data; | 664 | u8 not_data; |
670 | }; | 665 | }; |
@@ -710,20 +705,29 @@ static void dib0700_rc_urb_completion(struct urb *purb) | |||
710 | toggle = 0; | 705 | toggle = 0; |
711 | 706 | ||
712 | /* NEC protocol sends repeat code as 0 0 0 FF */ | 707 | /* NEC protocol sends repeat code as 0 0 0 FF */ |
713 | if ((poll_reply->system == 0x00) && (poll_reply->data == 0x00) | 708 | if (poll_reply->system == 0x00 && |
714 | && (poll_reply->not_data == 0xff)) { | 709 | poll_reply->not_system == 0x00 && |
710 | poll_reply->data == 0x00 && | ||
711 | poll_reply->not_data == 0xff) { | ||
715 | poll_reply->data_state = 2; | 712 | poll_reply->data_state = 2; |
716 | break; | 713 | break; |
717 | } | 714 | } |
718 | 715 | ||
719 | if ((poll_reply->system ^ poll_reply->not_system) != 0xff) { | 716 | if ((poll_reply->data ^ poll_reply->not_data) != 0xff) { |
717 | deb_data("NEC32 protocol\n"); | ||
718 | keycode = RC_SCANCODE_NEC32(poll_reply->system << 24 | | ||
719 | poll_reply->not_system << 16 | | ||
720 | poll_reply->data << 8 | | ||
721 | poll_reply->not_data); | ||
722 | } else if ((poll_reply->system ^ poll_reply->not_system) != 0xff) { | ||
720 | deb_data("NEC extended protocol\n"); | 723 | deb_data("NEC extended protocol\n"); |
721 | /* NEC extended code - 24 bits */ | 724 | keycode = RC_SCANCODE_NECX(poll_reply->system << 8 | |
722 | keycode = be16_to_cpu(poll_reply->system16) << 8 | poll_reply->data; | 725 | poll_reply->not_system, |
726 | poll_reply->data); | ||
723 | } else { | 727 | } else { |
724 | deb_data("NEC normal protocol\n"); | 728 | deb_data("NEC normal protocol\n"); |
725 | /* normal NEC code - 16 bits */ | 729 | keycode = RC_SCANCODE_NEC(poll_reply->system, |
726 | keycode = poll_reply->system << 8 | poll_reply->data; | 730 | poll_reply->data); |
727 | } | 731 | } |
728 | 732 | ||
729 | break; | 733 | break; |
@@ -738,8 +742,8 @@ static void dib0700_rc_urb_completion(struct urb *purb) | |||
738 | 742 | ||
739 | if ((poll_reply->data + poll_reply->not_data) != 0xff) { | 743 | if ((poll_reply->data + poll_reply->not_data) != 0xff) { |
740 | /* Key failed integrity check */ | 744 | /* Key failed integrity check */ |
741 | err("key failed integrity check: %04x %02x %02x", | 745 | err("key failed integrity check: %02x %02x %02x %02x", |
742 | poll_reply->system, | 746 | poll_reply->system, poll_reply->not_system, |
743 | poll_reply->data, poll_reply->not_data); | 747 | poll_reply->data, poll_reply->not_data); |
744 | goto resubmit; | 748 | goto resubmit; |
745 | } | 749 | } |