linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
	linux-input@vger.kernel.org, stable@vger.kernel.org,
	"Zdeněk Rampas" <zdenda.rampas@gmail.com>
Subject: [PATCH] HID: ite: Only bind to keyboard USB interface on Acer SW5-012 keyboard dock
Date: Fri, 31 Jan 2020 13:45:53 +0100	[thread overview]
Message-ID: <20200131124553.27796-1-hdegoede@redhat.com> (raw)

Commit 8f18eca9ebc5 ("HID: ite: Add USB id match for Acer SW5-012 keyboard
dock") added the USB id for the Acer SW5-012's keyboard dock to the
hid-ite driver to fix the rfkill driver not working.

Most keyboard docks with an ITE 8595 keyboard/touchpad controller have the
"Wireless Radio Control" bits which need the special hid-ite driver on the
second USB interface (the mouse interface) and their touchpad only supports
mouse emulation, so using generic hid-input handling for anything but
the "Wireless Radio Control" bits is fine. On these devices we simply bind
to all USB interfaces.

But unlike other ITE8595 using keyboard docks, the Acer Aspire Switch 10
(SW5-012)'s touchpad not only does mouse emulation it also supports
HID-multitouch and all the keys including the "Wireless Radio Control"
bits have been moved to the first USB interface (the keyboard intf).

So we need hid-ite to handle the first (keyboard) USB interface and have
it NOT bind to the second (mouse) USB interface so that that can be
handled by hid-multitouch.c and we get proper multi-touch support.

This commit adds a match callback to hid-ite which makes it only
match the first USB interface when running on the Acer SW5-012,
fixing the regression to mouse-emulation mode introduced by adding the
keyboard dock USB id.

Note the match function only does the special only bind to the first
USB interface on the Acer SW5-012, on other devices the hid-ite driver
actually must bind to the second interface as that is where the
"Wireless Radio Control" bits are.

Cc: stable@vger.kernel.org
Fixes: 8f18eca9ebc5 ("HID: ite: Add USB id match for Acer SW5-012 keyboard dock")
Reported-by: Zdeněk Rampas <zdenda.rampas@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/hid/hid-ite.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/hid/hid-ite.c b/drivers/hid/hid-ite.c
index c436e12feb23..69a4ddfd033d 100644
--- a/drivers/hid/hid-ite.c
+++ b/drivers/hid/hid-ite.c
@@ -8,9 +8,12 @@
 #include <linux/input.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/usb.h>
 
 #include "hid-ids.h"
 
+#define ITE8595_KBD_USB_INTF		0
+
 static int ite_event(struct hid_device *hdev, struct hid_field *field,
 		     struct hid_usage *usage, __s32 value)
 {
@@ -37,6 +40,36 @@ static int ite_event(struct hid_device *hdev, struct hid_field *field,
 	return 0;
 }
 
+static bool ite_match(struct hid_device *hdev, bool ignore_special_driver)
+{
+	struct usb_interface *intf;
+
+	if (ignore_special_driver)
+		return false;
+
+	/*
+	 * Most keyboard docks with an ITE 8595 keyboard/touchpad controller
+	 * have the "Wireless Radio Control" bits which need this special
+	 * driver on the second USB interface (the mouse interface). On
+	 * these devices we simply bind to all USB interfaces.
+	 *
+	 * The Acer Aspire Switch 10 (SW5-012) is special, its touchpad
+	 * not only does mouse emulation it also supports HID-multitouch
+	 * and all the keys including the "Wireless Radio Control" bits
+	 * have been moved to the first USB interface (the keyboard intf).
+	 *
+	 * We want the hid-multitouch driver to bind to the touchpad, so on
+	 * the Acer SW5-012 we should only bind to the keyboard USB intf.
+	 */
+	if (hdev->bus != BUS_USB || hdev->vendor != USB_VENDOR_ID_SYNAPTICS ||
+		     hdev->product != USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012)
+		return true;
+
+	intf = to_usb_interface(hdev->dev.parent);
+
+	return intf->altsetting->desc.bInterfaceNumber == ITE8595_KBD_USB_INTF;
+}
+
 static const struct hid_device_id ite_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE8595) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_258A, USB_DEVICE_ID_258A_6A88) },
@@ -50,6 +83,7 @@ MODULE_DEVICE_TABLE(hid, ite_devices);
 static struct hid_driver ite_driver = {
 	.name = "itetech",
 	.id_table = ite_devices,
+	.match = ite_match,
 	.event = ite_event,
 };
 module_hid_driver(ite_driver);
-- 
2.23.0


             reply	other threads:[~2020-01-31 12:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 12:45 Hans de Goede [this message]
2020-01-31 13:10 ` [PATCH] HID: ite: Only bind to keyboard USB interface on Acer SW5-012 keyboard dock Benjamin Tissoires
2020-01-31 13:41   ` Hans de Goede
2020-01-31 13:54     ` Benjamin Tissoires
2020-01-31 14:04       ` Hans de Goede
2020-01-31 14:11         ` Benjamin Tissoires
     [not found]           ` <CABHH5-LmC3JOWyDoxC5hizZe6RZ6RuO=-gk8WDXvU9Z2usihXg@mail.gmail.com>
2020-01-31 15:45             ` Hans de Goede
     [not found]               ` <CABHH5-KNv7TU6=fiMk3JDxEX2mx7y9qr0Qx9sjOL9-=Rd5jsMw@mail.gmail.com>
2020-01-31 16:59                 ` Benjamin Tissoires
     [not found]                   ` <CABHH5-+MQZgj+Wz-BdHLJbK7X2dyyAES6KJspR=gK0TO0Dk73A@mail.gmail.com>
2020-01-31 17:31                     ` Benjamin Tissoires
     [not found]                       ` <CABHH5-LQ_Y-LGeKQHyyp0Nbz6Gmxr2TOmTPBeZqeKYTD9t3ELQ@mail.gmail.com>
2020-01-31 19:20                         ` Benjamin Tissoires
2020-02-01 10:22                     ` Hans de Goede
     [not found]                       ` <CABHH5-L0Ywc7nirnChy4YnGNeqhKa=_rXq9O5QUWtzWs1C6-_w@mail.gmail.com>
2020-02-01 11:44                         ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200131124553.27796-1-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=zdenda.rampas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).