Skip to contentSkip to conversation

HID: rmi: Support touchpads with external buttons

PATCH Applied Andrew Duggan 2 participants 6 messages Jan 8, 2015 – Jan 12, 2015 HID

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/3 HID: rmi: Support touchpads with external buttons

The external buttons on HID touchpads are connected as pass through devices and button events are not reported in the rmi registers. As a result on these devices we need to allow the HID generic desktop button events to be processed by hid-input. Unfortunately, there is no way to query the touchpad to determine that it has pass through buttons so the RMI_DEVICE_HAS_PHYS_BUTTONS should be set manually when adding the device to rmi_id[].

---
Here is the second version of the remaining patches in this patch series from last month. The most significant changes are setting the HAS_PHYS_BUTTONS flags in driver_data and avoiding reset being called with every button press.

 drivers/hid/hid-rmi.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/hid/hid-rmi.c +19 -1
index 018f80f..290f8f7 100644
@@ -35,6 +35,7 @@
 
 /* device flags */
 #define RMI_DEVICE			BIT(0)
+#define RMI_DEVICE_HAS_PHYS_BUTTONS	BIT(1)
 
 enum rmi_mode_type {
 	RMI_MODE_OFF			= 0,
@@ -472,6 +473,15 @@ static int rmi_event(struct hid_device *hdev, struct hid_field *field,
 	if ((data->device_flags & RMI_DEVICE) &&
 	    (field->application == HID_GD_POINTER ||
 	    field->application == HID_GD_MOUSE)) {
+		if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) {
+			if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON)
+				return 0;
+
+			if ((usage->hid == HID_GD_X || usage->hid == HID_GD_Y)
+			    && !value)
+				return 1;
+		}
+
 		rmi_schedule_reset(hdev);
 		return 1;
 	}
@@ -942,8 +952,13 @@ static int rmi_input_mapping(struct hid_device *hdev,
 	 * we want to make HID ignore the advertised HID collection
 	 * for RMI deivces
 	 */
-	if (data->device_flags & RMI_DEVICE)
+	if (data->device_flags & RMI_DEVICE) {
+		if ((data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) &&
+		    ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON))
+			return 0;
+
 		return -1;
+	}
 
 	return 0;
 }
@@ -991,6 +1006,9 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		return ret;
 	}
 
+	if (id->driver_data)
+		data->device_flags = id->driver_data;
+
 	/*
 	 * Check for the RMI specific report ids. If they are misisng
 	 * simply return and let the events be processed by hid-input
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 HID: rmi: Use hid_report_len to compute the size of reports

Now that hid_report_len is in hid.h we can use this function instead of duplicating the code which computes it.

---
 drivers/hid/hid-rmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/hid/hid-rmi.c +2 -3
index b08774a..49d4fe4 100644
@@ -1025,7 +1025,7 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		goto start;
 	}
 
-	data->input_report_size = (input_report->size >> 3) + 1 /* report id */;
+	data->input_report_size = hid_report_len(input_report);
 
 	if (!rmi_check_valid_report_id(hdev, HID_OUTPUT_REPORT,
 	    RMI_WRITE_REPORT_ID, &output_report)) {
@@ -1034,8 +1034,7 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		goto start;
 	}
 
-	data->output_report_size = (output_report->size >> 3)
-					+ 1 /* report id */;
+	data->output_report_size = hid_report_len(output_report);
 
 	data->device_flags |= RMI_DEVICE;
 	alloc_size = data->output_report_size + data->input_report_size;
Signature · 1 line
2.1.0
Applied
#2 lore raw

Re: [PATCH] HID: rmi: Use hid_report_len to compute the size of reports

Quoted 4 lines · Andrew Duggan

Now that hid_report_len is in hid.h we can use this function instead of duplicating the code which computes it.

Applied to for-3.20/rmi.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#3 lore raw

PATCH v2 3/3 HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop

In reply to Andrew Duggan

Have hid-rmi handle all of the Razer Blade HID devices that are part of the composite USB device. This will allow hid-rmi to operate the touchpad in rmi mode while passing events from the other devices to hid-input.

---
 drivers/hid/hid-core.c | 1 +
 drivers/hid/hid-ids.h  | 3 +++
 drivers/hid/hid-rmi.c  | 2 ++
 3 files changed, 6 insertions(+)
drivers/hid/hid-core.c +1 -0
index 81665b4..ef718f9 100644
@@ -1982,6 +1982,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE2) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14) },
 	{ }
 };
 
drivers/hid/hid-ids.h +3 -0
index 7460f34..7d0912d 100644
@@ -767,6 +767,9 @@
 #define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001		0x3001
 #define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008		0x3008
 
+#define USB_VENDOR_ID_RAZER            0x1532
+#define USB_DEVICE_ID_RAZER_BLADE_14   0x011D
+
 #define USB_VENDOR_ID_REALTEK		0x0bda
 #define USB_DEVICE_ID_REALTEK_READER	0x0152
 
drivers/hid/hid-rmi.c +2 -0
index 290f8f7..b08774a 100644
@@ -1083,6 +1083,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_DEVICE(HID_BUS_ANY, HID_GROUP_RMI, HID_ANY_ID, HID_ANY_ID) },
 	{ }
 };
Signature · 1 line
2.1.0
Applied
#4 lore raw

Re: [PATCH v2 3/3] HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop

Quoted 5 lines · Andrew Duggan

Have hid-rmi handle all of the Razer Blade HID devices that are part of the composite USB device. This will allow hid-rmi to operate the touchpad in rmi mode while passing events from the other devices to hid-input.

Applied to for-3.20/rmi, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs
Applied
#5 lore raw
In reply to Andrew Duggan
Quoted 8 lines · Andrew Duggan

The external buttons on HID touchpads are connected as pass through devices and button events are not reported in the rmi registers. As a result on these devices we need to allow the HID generic desktop button events to be processed by hid-input. Unfortunately, there is no way to query the touchpad to determine that it has pass through buttons so the RMI_DEVICE_HAS_PHYS_BUTTONS should be set manually when adding the device to rmi_id[].

Applied to for-3.20/rmi.

Signature · 2 lines
Jiri Kosina
SUSE Labs