linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons
@ 2015-01-08 22:51 Andrew Duggan
  2015-01-08 22:51 ` [PATCH v2 3/3] HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop Andrew Duggan
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andrew Duggan @ 2015-01-08 22:51 UTC (permalink / raw)
  To: linux-input, linux-kernel; +Cc: Andrew Duggan, Jiri Kosina, Benjamin Tissoires

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[].

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
---
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(-)

diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 018f80f..290f8f7 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -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
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop
  2015-01-08 22:51 [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons Andrew Duggan
@ 2015-01-08 22:51 ` Andrew Duggan
  2015-01-12  9:14   ` Jiri Kosina
  2015-01-08 22:51 ` [PATCH] HID: rmi: Use hid_report_len to compute the size of reports Andrew Duggan
  2015-01-12  9:14 ` [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons Jiri Kosina
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Duggan @ 2015-01-08 22:51 UTC (permalink / raw)
  To: linux-input, linux-kernel; +Cc: Andrew Duggan, Jiri Kosina, Benjamin Tissoires

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.

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
---
 drivers/hid/hid-core.c | 1 +
 drivers/hid/hid-ids.h  | 3 +++
 drivers/hid/hid-rmi.c  | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 81665b4..ef718f9 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -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) },
 	{ }
 };
 
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 7460f34..7d0912d 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -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
 
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 290f8f7..b08774a 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -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) },
 	{ }
 };
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] HID: rmi: Use hid_report_len to compute the size of reports
  2015-01-08 22:51 [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons Andrew Duggan
  2015-01-08 22:51 ` [PATCH v2 3/3] HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop Andrew Duggan
@ 2015-01-08 22:51 ` Andrew Duggan
  2015-01-12  9:14   ` Jiri Kosina
  2015-01-12  9:14 ` [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons Jiri Kosina
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Duggan @ 2015-01-08 22:51 UTC (permalink / raw)
  To: linux-input, linux-kernel; +Cc: Andrew Duggan, Jiri Kosina, Benjamin Tissoires

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

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
---
 drivers/hid/hid-rmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index b08774a..49d4fe4 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -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;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: rmi: Use hid_report_len to compute the size of reports
  2015-01-08 22:51 ` [PATCH] HID: rmi: Use hid_report_len to compute the size of reports Andrew Duggan
@ 2015-01-12  9:14   ` Jiri Kosina
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2015-01-12  9:14 UTC (permalink / raw)
  To: Andrew Duggan; +Cc: linux-input, linux-kernel, Benjamin Tissoires

On Thu, 8 Jan 2015, Andrew Duggan wrote:

> Now that hid_report_len is in hid.h we can use this function instead of
> duplicating the code which computes it.
> 
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>

Applied to for-3.20/rmi.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons
  2015-01-08 22:51 [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons Andrew Duggan
  2015-01-08 22:51 ` [PATCH v2 3/3] HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop Andrew Duggan
  2015-01-08 22:51 ` [PATCH] HID: rmi: Use hid_report_len to compute the size of reports Andrew Duggan
@ 2015-01-12  9:14 ` Jiri Kosina
  2 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2015-01-12  9:14 UTC (permalink / raw)
  To: Andrew Duggan; +Cc: linux-input, linux-kernel, Benjamin Tissoires

On Thu, 8 Jan 2015, Andrew Duggan wrote:

> 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[].
> 
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>

Applied to for-3.20/rmi.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop
  2015-01-08 22:51 ` [PATCH v2 3/3] HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop Andrew Duggan
@ 2015-01-12  9:14   ` Jiri Kosina
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2015-01-12  9:14 UTC (permalink / raw)
  To: Andrew Duggan; +Cc: linux-input, linux-kernel, Benjamin Tissoires

On Thu, 8 Jan 2015, Andrew Duggan wrote:

> 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.
> 
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>

Applied to for-3.20/rmi, thanks.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-12  9:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 22:51 [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons Andrew Duggan
2015-01-08 22:51 ` [PATCH v2 3/3] HID: rmi: Add support for the touchpad in the Razer Blade 14 laptop Andrew Duggan
2015-01-12  9:14   ` Jiri Kosina
2015-01-08 22:51 ` [PATCH] HID: rmi: Use hid_report_len to compute the size of reports Andrew Duggan
2015-01-12  9:14   ` Jiri Kosina
2015-01-12  9:14 ` [PATCH v2 2/3] HID: rmi: Support touchpads with external buttons Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).