Skip to content

Commit af3a4a9

Browse files
Alphixmchehab
authored andcommitted
[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>
1 parent 4dd9bb9 commit af3a4a9

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

‎drivers/media/usb/dvb-usb/dib0700_core.c‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -658,13 +658,8 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 *rc_type)
658658
struct dib0700_rc_response {
659659
u8 report_id;
660660
u8 data_state;
661-
union {
662-
u16 system16;
663-
struct {
664-
u8 not_system;
665-
u8 system;
666-
};
667-
};
661+
u8 system;
662+
u8 not_system;
668663
u8 data;
669664
u8 not_data;
670665
};
@@ -710,20 +705,29 @@ static void dib0700_rc_urb_completion(struct urb *purb)
710705
toggle = 0;
711706

712707
/* NEC protocol sends repeat code as 0 0 0 FF */
713-
if ((poll_reply->system == 0x00) && (poll_reply->data == 0x00)
714-
&& (poll_reply->not_data == 0xff)) {
708+
if (poll_reply->system == 0x00 &&
709+
poll_reply->not_system == 0x00 &&
710+
poll_reply->data == 0x00 &&
711+
poll_reply->not_data == 0xff) {
715712
poll_reply->data_state = 2;
716713
break;
717714
}
718715

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) {
720723
deb_data("NEC extended protocol\n");
721-
/* NEC extended code - 24 bits */
722-
keycode = be16_to_cpu(poll_reply->system16) << 8 | poll_reply->data;
724+
keycode = RC_SCANCODE_NECX(poll_reply->system << 8 |
725+
poll_reply->not_system,
726+
poll_reply->data);
723727
} else {
724728
deb_data("NEC normal protocol\n");
725-
/* normal NEC code - 16 bits */
726-
keycode = poll_reply->system << 8 | poll_reply->data;
729+
keycode = RC_SCANCODE_NEC(poll_reply->system,
730+
poll_reply->data);
727731
}
728732

729733
break;
@@ -738,8 +742,8 @@ static void dib0700_rc_urb_completion(struct urb *purb)
738742

739743
if ((poll_reply->data + poll_reply->not_data) != 0xff) {
740744
/* Key failed integrity check */
741-
err("key failed integrity check: %04x %02x %02x",
742-
poll_reply->system,
745+
err("key failed integrity check: %02x %02x %02x %02x",
746+
poll_reply->system, poll_reply->not_system,
743747
poll_reply->data, poll_reply->not_data);
744748
goto resubmit;
745749
}

0 commit comments

Comments
 (0)