Skip to contentSkip to conversation

keytable: bpf decoder and keymap for XBox DVD Remote

PATCH New Sean Young 2 participants 3 messages Oct 18, 2018

Subsystems (3)
lore
Share & tools
lore

Sean Young

author maintainer
#0 lore raw

PATCH 1/1 keytable: bpf decoder and keymap for XBox DVD Remote

This uses a modified nec protocol, where 24 bits are sent and the first 12 bits are inverted.

---
 utils/keytable/bpf_protocols/Makefile.am      |   2 +-
 utils/keytable/bpf_protocols/xbox.c           | 129 ++++++++++++++++++
 .../rc_keymaps_userspace/xbox_dvd.toml        |  31 +++++
 3 files changed, 161 insertions(+), 1 deletion(-)
 create mode 100644 utils/keytable/bpf_protocols/xbox.c
 create mode 100644 utils/keytable/rc_keymaps_userspace/xbox_dvd.toml
utils/keytable/bpf_protocols/Makefile.am +1 -1
index 8887b897..2d005b1f 100644
@@ -10,7 +10,7 @@ CLANG_SYS_INCLUDES := $(shell $(CLANG) -v -E - </dev/null 2>&1 \
 %.o: %.c bpf_helpers.h
 	$(CLANG) $(CLANG_SYS_INCLUDES) -I$(top_srcdir)/include -target bpf -O2 -c $<
 
-PROTOCOLS = grundig.o pulse_distance.o pulse_length.o rc_mm.o manchester.o
+PROTOCOLS = grundig.o pulse_distance.o pulse_length.o rc_mm.o manchester.o xbox.o
 
 all: $(PROTOCOLS)
 
utils/keytable/bpf_protocols/xbox.c new file +129 -0

129 lines not on this page · raw message

utils/keytable/rc_keymaps_userspace/xbox_dvd.toml new file +31 -0
new file mode 100644
index 00000000..4f86c73c
@@ -0,0 +1,31 @@
+[[protocols]]
+name = 'XBox DVD'
+protocol = 'xbox'
+[protocols.scancodes]
+0xad5 = 'KEY_ANGLE'
+0xae2 = 'KEY_REWIND'
+0xaea = 'KEY_PLAY'
+0xae3 = 'KEY_FORWARD'
+0xadd = 'KEY_PREVIOUSSONG'
+0xae0 = 'KEY_STOP'
+0xae6 = 'KEY_PAUSE'
+0xadf = 'KEY_NEXTSONG'
+0xae5 = 'KEY_TITLE'
+0xac3 = 'KEY_INFO'
+0xaa6 = 'KEY_UP'
+0xaa9 = 'KEY_LEFT'
+0xaa8 = 'KEY_RIGHT'
+0xaa7 = 'KEY_DOWN'
+0xa0b = 'KEY_SELECT'
+0xaf7 = 'KEY_MENU'
+0xad8 = 'KEY_BACK'
+0xace = 'KEY_1'
+0xacd = 'KEY_2'
+0xacc = 'KEY_3'
+0xacb = 'KEY_4'
+0xaca = 'KEY_5'
+0xac9 = 'KEY_6'
+0xac8 = 'KEY_7'
+0xac7 = 'KEY_8'
+0xac6 = 'KEY_9'
+0xacf = 'KEY_0'
Signature · 1 line
2.17.2
author maintainer
#1 lore raw

PATCH 1/1 media: rc: XBox DVD Remote uses 12 bits scancodes

The xbox dvd remote sends 24 bits, the first 12 bits are repeated and inverted so only 12 bits are used. The upper 4 bits can be read at offset 3. Ensure we pass this to rc-core and update the keymap accordingly.

---
 drivers/media/rc/keymaps/rc-xbox-dvd.c | 58 +++++++++++++-------------
 drivers/media/rc/xbox_remote.c         |  7 ++--
 2 files changed, 33 insertions(+), 32 deletions(-)
drivers/media/rc/keymaps/rc-xbox-dvd.c +29 -29
index 61da6706715c..af387244636b 100644
@@ -7,35 +7,35 @@
 
 /* based on lircd.conf.xbox */
 static struct rc_map_table xbox_dvd[] = {
-	{0x0b, KEY_OK},
-	{0xa6, KEY_UP},
-	{0xa7, KEY_DOWN},
-	{0xa8, KEY_RIGHT},
-	{0xa9, KEY_LEFT},
-	{0xc3, KEY_INFO},
-
-	{0xc6, KEY_9},
-	{0xc7, KEY_8},
-	{0xc8, KEY_7},
-	{0xc9, KEY_6},
-	{0xca, KEY_5},
-	{0xcb, KEY_4},
-	{0xcc, KEY_3},
-	{0xcd, KEY_2},
-	{0xce, KEY_1},
-	{0xcf, KEY_0},
-
-	{0xd5, KEY_ANGLE},
-	{0xd8, KEY_BACK},
-	{0xdd, KEY_PREVIOUSSONG},
-	{0xdf, KEY_NEXTSONG},
-	{0xe0, KEY_STOP},
-	{0xe2, KEY_REWIND},
-	{0xe3, KEY_FASTFORWARD},
-	{0xe5, KEY_TITLE},
-	{0xe6, KEY_PAUSE},
-	{0xea, KEY_PLAY},
-	{0xf7, KEY_MENU},
+	{0xa0b, KEY_OK},
+	{0xaa6, KEY_UP},
+	{0xaa7, KEY_DOWN},
+	{0xaa8, KEY_RIGHT},
+	{0xaa9, KEY_LEFT},
+	{0xac3, KEY_INFO},
+
+	{0xac6, KEY_9},
+	{0xac7, KEY_8},
+	{0xac8, KEY_7},
+	{0xac9, KEY_6},
+	{0xaca, KEY_5},
+	{0xacb, KEY_4},
+	{0xacc, KEY_3},
+	{0xacd, KEY_2},
+	{0xace, KEY_1},
+	{0xacf, KEY_0},
+
+	{0xad5, KEY_ANGLE},
+	{0xad8, KEY_BACK},
+	{0xadd, KEY_PREVIOUSSONG},
+	{0xadf, KEY_NEXTSONG},
+	{0xae0, KEY_STOP},
+	{0xae2, KEY_REWIND},
+	{0xae3, KEY_FASTFORWARD},
+	{0xae5, KEY_TITLE},
+	{0xae6, KEY_PAUSE},
+	{0xaea, KEY_PLAY},
+	{0xaf7, KEY_MENU},
 };
 
 static struct rc_map_list xbox_dvd_map = {
drivers/media/rc/xbox_remote.c +4 -3
index 141ef9253018..4d41e31369d2 100644
@@ -55,7 +55,7 @@ struct xbox_remote {
 	struct usb_interface *interface;
 
 	struct urb *irq_urb;
-	unsigned char inbuf[DATA_BUFSIZE];
+	unsigned char inbuf[DATA_BUFSIZE] __aligned(sizeof(u16));
 
 	char rc_name[NAME_BUFSIZE];
 	char rc_phys[NAME_BUFSIZE];
@@ -95,7 +95,7 @@ static void xbox_remote_input_report(struct urb *urb)
 	 * data[0] = 0x00
 	 * data[1] = length - always 0x06
 	 * data[2] = the key code
-	 * data[3] = high part of key code? - always 0x0a
+	 * data[3] = high part of key code
 	 * data[4] = last_press_ms (low)
 	 * data[5] = last_press_ms (high)
 	 */
@@ -107,7 +107,8 @@ static void xbox_remote_input_report(struct urb *urb)
 		return;
 	}
 
-	rc_keydown(xbox_remote->rdev, RC_PROTO_UNKNOWN, data[2], 0);
+	rc_keydown(xbox_remote->rdev, RC_PROTO_UNKNOWN,
+		   le16_to_cpup((__le16*)(data + 2)), 0);
 }
 
 /*
Signature · 1 line
2.17.2
maintainer Tested-by on v1 1/1
#2 lore raw

Re: [PATCH] media: rc: XBox DVD Remote uses 12 bits scancodes

Quoted 113 lines · On Thu, 18 Oct 2018 12:27:17 +0100 Sean Young <[email protected]> wrote:

The xbox dvd remote sends 24 bits, the first 12 bits are repeated and inverted so only 12 bits are used. The upper 4 bits can be read at offset 3. Ensure we pass this to rc-core and update the keymap accordingly.

---
 drivers/media/rc/keymaps/rc-xbox-dvd.c | 58

+++++++++++++------------- drivers/media/rc/xbox_remote.c |
7 ++-- 2 files changed, 33 insertions(+), 32 deletions(-)

(quoted diff) +0 -0

b/drivers/media/rc/keymaps/rc-xbox-dvd.c index 61da6706715c..af387244636b 100644 --- a/drivers/media/rc/keymaps/rc-xbox-dvd.c +++ b/drivers/media/rc/keymaps/rc-xbox-dvd.c @@ -7,35 +7,35 @@

/* based on lircd.conf.xbox */
static struct rc_map_table xbox_dvd[] = {

drivers/media/rc/keymaps/rc-xbox-dvd.c +29 -29
-	{0x0b, KEY_OK},
-	{0xa6, KEY_UP},
-	{0xa7, KEY_DOWN},
-	{0xa8, KEY_RIGHT},
-	{0xa9, KEY_LEFT},
-	{0xc3, KEY_INFO},
-
-	{0xc6, KEY_9},
-	{0xc7, KEY_8},
-	{0xc8, KEY_7},
-	{0xc9, KEY_6},
-	{0xca, KEY_5},
-	{0xcb, KEY_4},
-	{0xcc, KEY_3},
-	{0xcd, KEY_2},
-	{0xce, KEY_1},
-	{0xcf, KEY_0},
-
-	{0xd5, KEY_ANGLE},
-	{0xd8, KEY_BACK},
-	{0xdd, KEY_PREVIOUSSONG},
-	{0xdf, KEY_NEXTSONG},
-	{0xe0, KEY_STOP},
-	{0xe2, KEY_REWIND},
-	{0xe3, KEY_FASTFORWARD},
-	{0xe5, KEY_TITLE},
-	{0xe6, KEY_PAUSE},
-	{0xea, KEY_PLAY},
-	{0xf7, KEY_MENU},
+	{0xa0b, KEY_OK},
+	{0xaa6, KEY_UP},
+	{0xaa7, KEY_DOWN},
+	{0xaa8, KEY_RIGHT},
+	{0xaa9, KEY_LEFT},
+	{0xac3, KEY_INFO},
+
+	{0xac6, KEY_9},
+	{0xac7, KEY_8},
+	{0xac8, KEY_7},
+	{0xac9, KEY_6},
+	{0xaca, KEY_5},
+	{0xacb, KEY_4},
+	{0xacc, KEY_3},
+	{0xacd, KEY_2},
+	{0xace, KEY_1},
+	{0xacf, KEY_0},
+
+	{0xad5, KEY_ANGLE},
+	{0xad8, KEY_BACK},
+	{0xadd, KEY_PREVIOUSSONG},
+	{0xadf, KEY_NEXTSONG},
+	{0xae0, KEY_STOP},
+	{0xae2, KEY_REWIND},
+	{0xae3, KEY_FASTFORWARD},
+	{0xae5, KEY_TITLE},
+	{0xae6, KEY_PAUSE},
+	{0xaea, KEY_PLAY},
+	{0xaf7, KEY_MENU},
 };
 
 static struct rc_map_list xbox_dvd_map = {
(quoted diff) +0 -0

b/drivers/media/rc/xbox_remote.c index 141ef9253018..4d41e31369d2 100644 --- a/drivers/media/rc/xbox_remote.c
+++ b/drivers/media/rc/xbox_remote.c

drivers/media/rc/xbox_remote.c +2 -2
@@ -55,7 +55,7 @@ struct xbox_remote {
 	struct usb_interface *interface;
 
 	struct urb *irq_urb;
-	unsigned char inbuf[DATA_BUFSIZE];
+	unsigned char inbuf[DATA_BUFSIZE] __aligned(sizeof(u16));
 
 	char rc_name[NAME_BUFSIZE];
 	char rc_phys[NAME_BUFSIZE];
@@ -95,7 +95,7 @@ static void xbox_remote_input_report(struct urb
 *urb)
 	 * data[0] = 0x00
 	 * data[1] = length - always 0x06
 	 * data[2] = the key code
-	 * data[3] = high part of key code? - always 0x0a
+	 * data[3] = high part of key code
 	 * data[4] = last_press_ms (low)
 	 * data[5] = last_press_ms (high)
drivers/media/rc/xbox_remote.c +2 -1
 	 */
@@ -107,7 +107,8 @@ static void xbox_remote_input_report(struct urb
 *urb) return;
 	}
 
-	rc_keydown(xbox_remote->rdev, RC_PROTO_UNKNOWN, data[2], 0);
+	rc_keydown(xbox_remote->rdev, RC_PROTO_UNKNOWN,
+		   le16_to_cpup((__le16*)(data + 2)), 0);
 }
 
 /*