All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: usbtouchscreen - initialize eGalax devices
@ 2012-08-31 13:56 Forest Bond
  2012-08-31 14:51 ` Dmitry Torokhov
  2012-08-31 18:50 ` Sergei Shtylyov
  0 siblings, 2 replies; 19+ messages in thread
From: Forest Bond @ 2012-08-31 13:56 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Daniel Ritz, linux-input, linux-usb

From: Forest Bond <forest.bond@rapidrollout.com>

Certain eGalax devices expose an interface with class HID and protocol
None.  Some work with usbhid and some work with usbtouchscreen, but
there is no easy way to differentiate.  Sending an eGalax diagnostic
packet seems to kick them all into using the right protocol for
usbtouchscreen, so we can continue to bind them all there (as opposed to
handing some off to usbhid).

This fixes a regression for devices that were claimed by (and worked
with) usbhid prior to commit 139ebe8dc80dd74cb2ac9f5603d18fbf5cff049f,
which made usbtouchscreen claim them instead.  With this patch they will
still be claimed by usbtouchscreen, but they will actually report events
usbtouchscreen can understand.  Note that these devices will be limited
to the usbtouchscreen feature set so e.g. dual touch features are not
supported.

I have the distinct pleasure of needing to support devices of both types
and have tested accordingly.

Signed-off-by: Forest Bond <forest.bond@rapidrollout.com>
---
 drivers/input/touchscreen/usbtouchscreen.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index e32709e..2ce5308 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -304,6 +304,30 @@ static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
 #define EGALAX_PKT_TYPE_REPT		0x80
 #define EGALAX_PKT_TYPE_DIAG		0x0A
 
+static int egalax_init(struct usbtouch_usb *usbtouch)
+{
+	int ret, i;
+	struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
+
+	/* An eGalax diagnostic packet kicks the device into using the right
+	 * protocol. */
+	for (i = 0; i < 3; i++) {
+		/* Send a "check active" packet. The response will be read
+		 * later and ignored. */
+		ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+				      0,
+				      USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+				      0, 0, "\x0A\x01A", 0,
+				      USB_CTRL_SET_TIMEOUT);
+		if (ret >= 0)
+			break;
+		if (ret != -EPIPE)
+			return ret;
+	}
+
+	return 0;
+}
+
 static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
 {
 	if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
@@ -1056,6 +1080,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
 		.process_pkt	= usbtouch_process_multi,
 		.get_pkt_len	= egalax_get_pkt_len,
 		.read_data	= egalax_read_data,
+		.init		= egalax_init,
 	},
 #endif
 
-- 
1.7.0.4

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

end of thread, other threads:[~2012-11-05 18:37 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-31 13:56 [PATCH] Input: usbtouchscreen - initialize eGalax devices Forest Bond
2012-08-31 14:51 ` Dmitry Torokhov
2012-08-31 18:50 ` Sergei Shtylyov
2012-08-31 19:26   ` Dmitry Torokhov
     [not found]     ` <20120831192632.GA30202-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2012-08-31 20:04       ` Alan Stern
     [not found]         ` <Pine.LNX.4.44L0.1208311555140.1328-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-08-31 20:22           ` Forest Bond
2012-08-31 22:53           ` Forest Bond
     [not found]             ` <20120831225353.GE24820-B/PTSs0AgtP3p6jHtUh95NHuzzzSOjJt@public.gmane.org>
2012-08-31 23:10               ` Dmitry Torokhov
     [not found]                 ` <20120831231047.GA22142-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2012-08-31 23:23                   ` Forest Bond
2012-09-01  0:37                     ` [PATCH resend] " Forest Bond
2012-09-03 13:26                       ` Sergey Vlasov
     [not found]                         ` <20120903132648.GC11919-TEYkr/UGJhVKdHEj4xO92LjjLBE8jN/0@public.gmane.org>
2012-09-03 17:33                           ` [PATCH resend2] " Forest Bond
     [not found]                             ` <20120903173349.GA18666-B/PTSs0AgtP3p6jHtUh95NHuzzzSOjJt@public.gmane.org>
2012-09-05  6:07                               ` Dmitry Torokhov
     [not found]                                 ` <20120905060704.GC25962-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2012-09-07 20:42                                   ` Forest Bond
2012-09-10 21:11                                     ` Dmitry Torokhov
2012-11-01 10:38                                       ` Jiri Kosina
2012-11-02 19:51                                         ` Forest Bond
2012-11-05 14:19                                           ` Jiri Kosina
2012-11-05 18:34                                             ` Forest Bond

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.