Commit 4d298b85 authored by David Härdeman's avatar David Härdeman Committed by Mauro Carvalho Chehab

[media] rc-core: fix dib0700 scancode generation for RC5

commit af3a4a9b ("[media] dib0700: NEC scancode cleanup") cleaned
up the NEC scancode logic but overlooked the RC5 case.

This patch brings the RC5 case in line with the NEC code and makes
the struct self-documenting.
Signed-off-by: default avatarDavid Härdeman <david@hardeman.nu>
Reported-by: default avatarDavid Cimbůrek <david.cimburek@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 8e95dba6
...@@ -655,10 +655,20 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 *rc_type) ...@@ -655,10 +655,20 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 *rc_type)
struct dib0700_rc_response { struct dib0700_rc_response {
u8 report_id; u8 report_id;
u8 data_state; u8 data_state;
union {
struct {
u8 system; u8 system;
u8 not_system; u8 not_system;
u8 data; u8 data;
u8 not_data; u8 not_data;
} nec;
struct {
u8 not_used;
u8 system;
u8 data;
u8 not_data;
} rc5;
};
}; };
#define RC_MSG_SIZE_V1_20 6 #define RC_MSG_SIZE_V1_20 6
...@@ -694,8 +704,8 @@ static void dib0700_rc_urb_completion(struct urb *purb) ...@@ -694,8 +704,8 @@ static void dib0700_rc_urb_completion(struct urb *purb)
deb_data("IR ID = %02X state = %02X System = %02X %02X Cmd = %02X %02X (len %d)\n", deb_data("IR ID = %02X state = %02X System = %02X %02X Cmd = %02X %02X (len %d)\n",
poll_reply->report_id, poll_reply->data_state, poll_reply->report_id, poll_reply->data_state,
poll_reply->system, poll_reply->not_system, poll_reply->nec.system, poll_reply->nec.not_system,
poll_reply->data, poll_reply->not_data, poll_reply->nec.data, poll_reply->nec.not_data,
purb->actual_length); purb->actual_length);
switch (d->props.rc.core.protocol) { switch (d->props.rc.core.protocol) {
...@@ -704,30 +714,30 @@ static void dib0700_rc_urb_completion(struct urb *purb) ...@@ -704,30 +714,30 @@ static void dib0700_rc_urb_completion(struct urb *purb)
toggle = 0; toggle = 0;
/* NEC protocol sends repeat code as 0 0 0 FF */ /* NEC protocol sends repeat code as 0 0 0 FF */
if (poll_reply->system == 0x00 && if (poll_reply->nec.system == 0x00 &&
poll_reply->not_system == 0x00 && poll_reply->nec.not_system == 0x00 &&
poll_reply->data == 0x00 && poll_reply->nec.data == 0x00 &&
poll_reply->not_data == 0xff) { poll_reply->nec.not_data == 0xff) {
poll_reply->data_state = 2; poll_reply->data_state = 2;
break; break;
} }
if ((poll_reply->data ^ poll_reply->not_data) != 0xff) { if ((poll_reply->nec.data ^ poll_reply->nec.not_data) != 0xff) {
deb_data("NEC32 protocol\n"); deb_data("NEC32 protocol\n");
keycode = RC_SCANCODE_NEC32(poll_reply->system << 24 | keycode = RC_SCANCODE_NEC32(poll_reply->nec.system << 24 |
poll_reply->not_system << 16 | poll_reply->nec.not_system << 16 |
poll_reply->data << 8 | poll_reply->nec.data << 8 |
poll_reply->not_data); poll_reply->nec.not_data);
} else if ((poll_reply->system ^ poll_reply->not_system) != 0xff) { } else if ((poll_reply->nec.system ^ poll_reply->nec.not_system) != 0xff) {
deb_data("NEC extended protocol\n"); deb_data("NEC extended protocol\n");
keycode = RC_SCANCODE_NECX(poll_reply->system << 8 | keycode = RC_SCANCODE_NECX(poll_reply->nec.system << 8 |
poll_reply->not_system, poll_reply->nec.not_system,
poll_reply->data); poll_reply->nec.data);
} else { } else {
deb_data("NEC normal protocol\n"); deb_data("NEC normal protocol\n");
keycode = RC_SCANCODE_NEC(poll_reply->system, keycode = RC_SCANCODE_NEC(poll_reply->nec.system,
poll_reply->data); poll_reply->nec.data);
} }
break; break;
...@@ -735,19 +745,19 @@ static void dib0700_rc_urb_completion(struct urb *purb) ...@@ -735,19 +745,19 @@ static void dib0700_rc_urb_completion(struct urb *purb)
deb_data("RC5 protocol\n"); deb_data("RC5 protocol\n");
protocol = RC_TYPE_RC5; protocol = RC_TYPE_RC5;
toggle = poll_reply->report_id; toggle = poll_reply->report_id;
keycode = RC_SCANCODE_RC5(poll_reply->system, poll_reply->data); keycode = RC_SCANCODE_RC5(poll_reply->rc5.system, poll_reply->rc5.data);
break; if ((poll_reply->rc5.data ^ poll_reply->rc5.not_data) != 0xff) {
}
if ((poll_reply->data + poll_reply->not_data) != 0xff) {
/* Key failed integrity check */ /* Key failed integrity check */
err("key failed integrity check: %02x %02x %02x %02x", err("key failed integrity check: %02x %02x %02x %02x",
poll_reply->system, poll_reply->not_system, poll_reply->rc5.not_used, poll_reply->rc5.system,
poll_reply->data, poll_reply->not_data); poll_reply->rc5.data, poll_reply->rc5.not_data);
goto resubmit; goto resubmit;
} }
break;
}
rc_keydown(d->rc_dev, protocol, keycode, toggle); rc_keydown(d->rc_dev, protocol, keycode, toggle);
resubmit: resubmit:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment