media: rc: xbox_remote: add protocol and set timeout
authorMatthias Reichl <hias@horus.com>
Sun, 24 Mar 2019 09:43:51 +0000 (05:43 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 22 Apr 2019 17:02:53 +0000 (13:02 -0400)
The timestamps in ir-keytable -t output showed that the Xbox DVD
IR dongle decodes scancodes every 64ms. The last scancode of a
longer button press is decodes 64ms after the last-but-one which
indicates the decoder doesn't use a timeout but decodes on the last
edge of the signal.

267.042629: lirc protocol(unknown): scancode = 0xace
267.042665: event type EV_MSC(0x04): scancode = 0xace
267.042665: event type EV_KEY(0x01) key_down: KEY_1(0x0002)
267.042665: event type EV_SYN(0x00).
267.106625: lirc protocol(unknown): scancode = 0xace
267.106643: event type EV_MSC(0x04): scancode = 0xace
267.106643: event type EV_SYN(0x00).
267.170623: lirc protocol(unknown): scancode = 0xace
267.170638: event type EV_MSC(0x04): scancode = 0xace
267.170638: event type EV_SYN(0x00).
267.234621: lirc protocol(unknown): scancode = 0xace
267.234636: event type EV_MSC(0x04): scancode = 0xace
267.234636: event type EV_SYN(0x00).
267.298623: lirc protocol(unknown): scancode = 0xace
267.298638: event type EV_MSC(0x04): scancode = 0xace
267.298638: event type EV_SYN(0x00).
267.543345: event type EV_KEY(0x01) key_down: KEY_1(0x0002)
267.543345: event type EV_SYN(0x00).
267.570015: event type EV_KEY(0x01) key_up: KEY_1(0x0002)
267.570015: event type EV_SYN(0x00).

Add a protocol with the repeat value and set the timeout in the
driver to 10ms (to have a bit of headroom for delays) so the Xbox
DVD remote performs more responsive.

Signed-off-by: Matthias Reichl <hias@horus.com>
Acked-by: Benjamin Valentin <benpicco@googlemail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Documentation/media/lirc.h.rst.exceptions
drivers/media/rc/keymaps/rc-xbox-dvd.c
drivers/media/rc/rc-main.c
drivers/media/rc/xbox_remote.c
include/media/rc-map.h
include/uapi/linux/lirc.h

index 7a8b8ff4f07676f81818fe38395539487e8d96a9..ac768d76911307d4e70d3e50fa286a6ca37f5e15 100644 (file)
@@ -63,6 +63,7 @@ ignore symbol RC_PROTO_IMON
 ignore symbol RC_PROTO_RCMM12
 ignore symbol RC_PROTO_RCMM24
 ignore symbol RC_PROTO_RCMM32
+ignore symbol RC_PROTO_XBOX_DVD
 
 # Undocumented macros
 
index af387244636b1354b9f6b0c2f6c9a18710ba3676..42815ab57bff5b7f6505ca530720b28d421f6a03 100644 (file)
@@ -42,7 +42,7 @@ static struct rc_map_list xbox_dvd_map = {
        .map = {
                .scan     = xbox_dvd,
                .size     = ARRAY_SIZE(xbox_dvd),
-               .rc_proto = RC_PROTO_UNKNOWN,
+               .rc_proto = RC_PROTO_XBOX_DVD,
                .name     = RC_MAP_XBOX_DVD,
        }
 };
index e8fa28e20192ac18332db866218c717f954a3867..be5fd129d7287822d510a86ec942aba0c38c94d2 100644 (file)
@@ -76,6 +76,7 @@ static const struct {
                .scancode_bits = 0x00ffffff, .repeat_period = 114 },
        [RC_PROTO_RCMM32] = { .name = "rc-mm-32",
                .scancode_bits = 0xffffffff, .repeat_period = 114 },
+       [RC_PROTO_XBOX_DVD] = { .name = "xbox-dvd", .repeat_period = 64 },
 };
 
 /* Used to keep track of known keymaps */
@@ -1027,6 +1028,7 @@ static const struct {
        { RC_PROTO_BIT_RCMM12 |
          RC_PROTO_BIT_RCMM24 |
          RC_PROTO_BIT_RCMM32,  "rc-mm",        "ir-rcmm-decoder"       },
+       { RC_PROTO_BIT_XBOX_DVD, "xbox-dvd",    NULL                    },
 };
 
 /**
index f959cbb947447d4d081bd2e3914fc422a292d2c4..4a3f2cc4ef18881d00c4f2f9022cdc3ff9bcc730 100644 (file)
@@ -107,7 +107,7 @@ static void xbox_remote_input_report(struct urb *urb)
                return;
        }
 
-       rc_keydown(xbox_remote->rdev, RC_PROTO_UNKNOWN,
+       rc_keydown(xbox_remote->rdev, RC_PROTO_XBOX_DVD,
                   le16_to_cpup((__le16 *)(data + 2)), 0);
 }
 
@@ -148,7 +148,7 @@ static void xbox_remote_rc_init(struct xbox_remote *xbox_remote)
        struct rc_dev *rdev = xbox_remote->rdev;
 
        rdev->priv = xbox_remote;
-       rdev->allowed_protocols = RC_PROTO_BIT_UNKNOWN;
+       rdev->allowed_protocols = RC_PROTO_BIT_XBOX_DVD;
        rdev->driver_name = "xbox_remote";
 
        rdev->open = xbox_remote_rc_open;
@@ -157,6 +157,8 @@ static void xbox_remote_rc_init(struct xbox_remote *xbox_remote)
        rdev->device_name = xbox_remote->rc_name;
        rdev->input_phys = xbox_remote->rc_phys;
 
+       rdev->timeout = MS_TO_NS(10);
+
        usb_to_input_id(xbox_remote->udev, &rdev->input_id);
        rdev->dev.parent = &xbox_remote->interface->dev;
 }
index 5e684bb0d64c4043b9c626c30eaad8f938f618cf..367d983188f7d72624a333a6225bcff578c4c842 100644 (file)
@@ -40,6 +40,7 @@
 #define RC_PROTO_BIT_RCMM12            BIT_ULL(RC_PROTO_RCMM12)
 #define RC_PROTO_BIT_RCMM24            BIT_ULL(RC_PROTO_RCMM24)
 #define RC_PROTO_BIT_RCMM32            BIT_ULL(RC_PROTO_RCMM32)
+#define RC_PROTO_BIT_XBOX_DVD          BIT_ULL(RC_PROTO_XBOX_DVD)
 
 #define RC_PROTO_BIT_ALL \
                        (RC_PROTO_BIT_UNKNOWN | RC_PROTO_BIT_OTHER | \
@@ -55,7 +56,8 @@
                         RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_SHARP | \
                         RC_PROTO_BIT_XMP | RC_PROTO_BIT_CEC | \
                         RC_PROTO_BIT_IMON | RC_PROTO_BIT_RCMM12 | \
-                        RC_PROTO_BIT_RCMM24 | RC_PROTO_BIT_RCMM32)
+                        RC_PROTO_BIT_RCMM24 | RC_PROTO_BIT_RCMM32 | \
+                        RC_PROTO_BIT_XBOX_DVD)
 /* All rc protocols for which we have decoders */
 #define RC_PROTO_BIT_ALL_IR_DECODER \
                        (RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
index 45fcbf99d72ec49fdf5efd0030876819e6b3de27..f99d9dcae66763ef564b926a77da3311f9ae13b5 100644 (file)
@@ -195,6 +195,7 @@ struct lirc_scancode {
  * @RC_PROTO_RCMM12: RC-MM protocol 12 bits
  * @RC_PROTO_RCMM24: RC-MM protocol 24 bits
  * @RC_PROTO_RCMM32: RC-MM protocol 32 bits
+ * @RC_PROTO_XBOX_DVD: Xbox DVD Movie Playback Kit protocol
  */
 enum rc_proto {
        RC_PROTO_UNKNOWN        = 0,
@@ -224,6 +225,7 @@ enum rc_proto {
        RC_PROTO_RCMM12         = 24,
        RC_PROTO_RCMM24         = 25,
        RC_PROTO_RCMM32         = 26,
+       RC_PROTO_XBOX_DVD       = 27,
 };
 
 #endif