Skip to contentSkip to conversation

HID: rmi: Lenovo X1 Cover touchpad is a buttonpad

PATCH In review Daniel Martin 3 participants 3 messages Oct 19, 2017 – Oct 24, 2017 1 message not in the archive HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: rmi: Lenovo X1 Cover touchpad is a buttonpad

Atm. the touchpad is not tagged as buttonpad. Due to the lack of it, RMI F30 adds 3 buttons (BTN_LEFT, BTN_RIGHT and BTN_MIDDLE).

On the very first click after a boot one can see with evemu-record:
...
E: 0.084899 0001 0110 0001 # EV_KEY / BTN_LEFT 1
E: 0.084899 0001 0111 0001 # EV_KEY / BTN_RIGHT 1
...
Then BTN_LEFT gets released, but there's no release of BTN_RIGHT. With this stuck button further clicks don't work until you switch the VT and back (X-Server, xf86-input-synaptics). There're no occurences of BTN_RIGHT after a VT switch.

Fix this by tagging the device as buttonpad. The changed report looks like:

evemu-record-tm3203-003-fixed.log renamed from evemu-record-tm3203-003-wrong.log +3 -4
@@ -22,8 +22,6 @@
 #     Event code 14 ((null))
 #   Event type 1 (EV_KEY)
 #     Event code 272 (BTN_LEFT)
-#     Event code 273 (BTN_RIGHT)
-#     Event code 274 (BTN_MIDDLE)
 #     Event code 325 (BTN_TOOL_FINGER)
 #     Event code 330 (BTN_TOUCH)
 #     Event code 333 (BTN_TOOL_DOUBLETAP)
@@ -116,15 +114,16 @@
 #       Resolution 0
 # Properties:
 #   Property  type 0 (INPUT_PROP_POINTER)
+#   Property  type 2 (INPUT_PROP_BUTTONPAD)
 N: Synaptics TM3203-003
 I: 0003 17ef 6085 0111
-P: 01 00 00 00 00 00 00 00
+P: 05 00 00 00 00 00 00 00
 B: 00 0b 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
-B: 01 00 00 07 00 00 00 00 00
+B: 01 00 00 01 00 00 00 00 00
 B: 01 20 e4 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
---
 drivers/hid/hid-rmi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hid/hid-rmi.c +6 -1
index ef241d66562e..e4937deef723 100644
@@ -39,6 +39,7 @@
 /* device flags */
 #define RMI_DEVICE			BIT(0)
 #define RMI_DEVICE_HAS_PHYS_BUTTONS	BIT(1)
+#define RMI_DEVICE_IS_BUTTONPAD		BIT(2)
 
 /*
  * retrieve the ctrl registers
@@ -692,6 +693,9 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS)
 		rmi_hid_pdata.f30_data.disable = true;
+	else
+	if (data->device_flags & RMI_DEVICE_IS_BUTTONPAD)
+		rmi_hid_pdata.f30_data.buttonpad = true;
 
 	data->xport.dev = hdev->dev.parent;
 	data->xport.pdata = rmi_hid_pdata;
@@ -723,7 +727,8 @@ static void rmi_remove(struct hid_device *hdev)
 static const struct hid_device_id rmi_id[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14),
 		.driver_data = RMI_DEVICE_HAS_PHYS_BUTTONS },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X1_COVER) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X1_COVER),
+		.driver_data = RMI_DEVICE_IS_BUTTONPAD },
 	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_RMI, HID_ANY_ID, HID_ANY_ID) },
 	{ }
 };
Signature · 1 line
2.13.6
#1 lore raw

Hi Daniel,

Quoted 2 lines · Daniel Martin

Atm. the touchpad is not tagged as buttonpad. Due to the lack of it, RMI F30 adds 3 buttons (BTN_LEFT, BTN_RIGHT and BTN_MIDDLE).

It looks like this is a bug in F30. This touchpad has some additional GPIOs set which are unrelated to buttons. The criteria in F30 which determines what should be considered a button isn't correct. Once these GPIOs are correctly ignored F30 should correctly set the buttonpad bit. I'll put together a patch to fix F30.

Andrew

Quoted 80 lines

On the very first click after a boot one can see with evemu-record:
...
E: 0.084899 0001 0110 0001 # EV_KEY / BTN_LEFT 1
E: 0.084899 0001 0111 0001 # EV_KEY / BTN_RIGHT 1
...
Then BTN_LEFT gets released, but there's no release of BTN_RIGHT. With this stuck button further clicks don't work until you switch the VT and back (X-Server, xf86-input-synaptics). There're no occurences of BTN_RIGHT after a VT switch.

Fix this by tagging the device as buttonpad. The changed report looks like:

evemu-record-tm3203-003-fixed.log renamed from evemu-record-tm3203-003-wrong.log +3 -4
@@ -22,8 +22,6 @@
  #     Event code 14 ((null))
  #   Event type 1 (EV_KEY)
  #     Event code 272 (BTN_LEFT)
-#     Event code 273 (BTN_RIGHT)
-#     Event code 274 (BTN_MIDDLE)
  #     Event code 325 (BTN_TOOL_FINGER)
  #     Event code 330 (BTN_TOUCH)
  #     Event code 333 (BTN_TOOL_DOUBLETAP)
@@ -116,15 +114,16 @@
  #       Resolution 0
  # Properties:
  #   Property  type 0 (INPUT_PROP_POINTER)
+#   Property  type 2 (INPUT_PROP_BUTTONPAD)
  N: Synaptics TM3203-003
  I: 0003 17ef 6085 0111
-P: 01 00 00 00 00 00 00 00
+P: 05 00 00 00 00 00 00 00
  B: 00 0b 00 00 00 00 00 00 00
  B: 01 00 00 00 00 00 00 00 00
  B: 01 00 00 00 00 00 00 00 00
  B: 01 00 00 00 00 00 00 00 00
  B: 01 00 00 00 00 00 00 00 00
-B: 01 00 00 07 00 00 00 00 00
+B: 01 00 00 01 00 00 00 00 00
  B: 01 20 e4 00 00 00 00 00 00
  B: 01 00 00 00 00 00 00 00 00
  B: 01 00 00 00 00 00 00 00 00
---
  drivers/hid/hid-rmi.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hid/hid-rmi.c +6 -1
index ef241d66562e..e4937deef723 100644
@@ -39,6 +39,7 @@
  /* device flags */
  #define RMI_DEVICE			BIT(0)
  #define RMI_DEVICE_HAS_PHYS_BUTTONS	BIT(1)
+#define RMI_DEVICE_IS_BUTTONPAD		BIT(2)
 
  /*
   * retrieve the ctrl registers
@@ -692,6 +693,9 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
  	if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS)
  		rmi_hid_pdata.f30_data.disable = true;
+	else
+	if (data->device_flags & RMI_DEVICE_IS_BUTTONPAD)
+		rmi_hid_pdata.f30_data.buttonpad = true;
 
  	data->xport.dev = hdev->dev.parent;
  	data->xport.pdata = rmi_hid_pdata;
@@ -723,7 +727,8 @@ static void rmi_remove(struct hid_device *hdev)
  static const struct hid_device_id rmi_id[] = {
  	{ HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14),
  		.driver_data = RMI_DEVICE_HAS_PHYS_BUTTONS },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X1_COVER) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X1_COVER),
+		.driver_data = RMI_DEVICE_IS_BUTTONPAD },
  	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_RMI, HID_ANY_ID, HID_ANY_ID) },
  	{ }
  };

A message that is not in the archive (sent off-list or not yet received): CADscph1Cc1dZdBrWi--cgo+MgJvqcXJ=otsHvAfkdUOPOfJtCA@mail.gmail.com

Tested-by
#3 lore raw

Hey Daniel, thanks for forwarding this to me.

Quoted 13 lines · Daniel Martin

Atm. the touchpad is not tagged as buttonpad. Due to the lack of it, RMI F30 adds 3 buttons (BTN_LEFT, BTN_RIGHT and BTN_MIDDLE).

On the very first click after a boot one can see with evemu-record:
...
E: 0.084899 0001 0110 0001 # EV_KEY / BTN_LEFT 1
E: 0.084899 0001 0111 0001 # EV_KEY / BTN_RIGHT 1
...
Then BTN_LEFT gets released, but there's no release of BTN_RIGHT. With this stuck button further clicks don't work until you switch the VT and back (X-Server, xf86-input-synaptics). There're no occurences of BTN_RIGHT after a VT switch.

Quoted 1 line

Fix this by tagging the device as buttonpad.

I'm sorry, i'm not an expert on this so i can't make a statement about the code. But i tested this and i can confirm the annoying behaviour where the BTN_RIGHT gets stuck is now gone with this patch. Didn't observe any negative side effects.

evemu-record shows the same changes on my x1 tablet and the device is now tagged as buttonpad.

If this is enough you can consider this patch

Quoted 74 lines

The changed report looks
like:

evemu-record-tm3203-003-fixed.log renamed from evemu-record-tm3203-003-wrong.log +3 -4
@@ -22,8 +22,6 @@
 #     Event code 14 ((null))
 #   Event type 1 (EV_KEY)
 #     Event code 272 (BTN_LEFT)
-#     Event code 273 (BTN_RIGHT)
-#     Event code 274 (BTN_MIDDLE)
 #     Event code 325 (BTN_TOOL_FINGER)
 #     Event code 330 (BTN_TOUCH)
 #     Event code 333 (BTN_TOOL_DOUBLETAP)
@@ -116,15 +114,16 @@
 #       Resolution 0
 # Properties:
 #   Property  type 0 (INPUT_PROP_POINTER)
+#   Property  type 2 (INPUT_PROP_BUTTONPAD)
 N: Synaptics TM3203-003
 I: 0003 17ef 6085 0111
-P: 01 00 00 00 00 00 00 00
+P: 05 00 00 00 00 00 00 00
 B: 00 0b 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
-B: 01 00 00 07 00 00 00 00 00
+B: 01 00 00 01 00 00 00 00 00
 B: 01 20 e4 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
 B: 01 00 00 00 00 00 00 00 00
---
 drivers/hid/hid-rmi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hid/hid-rmi.c +4 -0
index ef241d66562e..e4937deef723 100644
@@ -39,6 +39,7 @@
 /* device flags */
 #define RMI_DEVICE                     BIT(0)
 #define RMI_DEVICE_HAS_PHYS_BUTTONS    BIT(1)
+#define RMI_DEVICE_IS_BUTTONPAD                BIT(2)
 
 /*
  * retrieve the ctrl registers
@@ -692,6 +693,9 @@ static int rmi_probe(struct hid_device *hdev,
 const struct hid_device_id *id)
 
        if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS)
                rmi_hid_pdata.f30_data.disable = true;
+       else
+       if (data->device_flags & RMI_DEVICE_IS_BUTTONPAD)
+               rmi_hid_pdata.f30_data.buttonpad = true;
 
        data->xport.dev = hdev->dev.parent;
        data->xport.pdata = rmi_hid_pdata;
drivers/hid/hid-rmi.c +2 -2
@@ -723,7 +727,8 @@ static void rmi_remove(struct hid_device *hdev)
 static const struct hid_device_id rmi_id[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14),
                .driver_data = RMI_DEVICE_HAS_PHYS_BUTTONS },
-       { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X1_COVER) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X1_COVER),
+               .driver_data = RMI_DEVICE_IS_BUTTONPAD },
        { HID_DEVICE(HID_BUS_ANY, HID_GROUP_RMI, HID_ANY_ID, HID_ANY_ID) },
        { }
 };
--

2.13.6