Input: usbtouchscreen - initialize eGalax devices
Subsystems (2)
PATCH 1/1 Input: usbtouchscreen - initialize eGalax devices
From: Forest Bond <[email protected]>
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.
--- drivers/input/touchscreen/usbtouchscreen.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)
drivers/input/touchscreen/usbtouchscreen.c +25 -0
@@ -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
Signature · 1 line
1.7.0.4
Quoted 17 lines · Forest Bond
From: Forest Bond <[email protected]>
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.
Quoted 4 lines
I have the distinct pleasure of needing to support devices of both types and have tested accordingly.
Signed-off-by Forest Bond <[email protected]>
Applied, thanks Forest.
Quoted 49 lines
--- drivers/input/touchscreen/usbtouchscreen.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)drivers/input/touchscreen/usbtouchscreen.c +25
-0@@ -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 Signature · 1 line
1.7.0.4
Signature · 1 line
Dmitry
Hello.
Quoted 11 lines · Forest Bond
From: Forest Bond <[email protected]>
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,
Please also specify that commit's summary ion parens.
Quoted 19 lines
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 <[email protected]>--- drivers/input/touchscreen/usbtouchscreen.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)drivers/input/touchscreen/usbtouchscreen.c +0
-0
drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 313
Quoted 10 lines
drivers/input/touchscreen/usbtouchscreen.c +7
-0@@ -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. */
The preferred multi-line comment style is:
/*
* bla
* bla
*/
drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 320
Quoted 7 lines
drivers/input/touchscreen/usbtouchscreen.c +7
-0+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,
You probably can't send data from the .const section (as well as off the
stack) -- they can be DMA'ed and there'll be issues with cache consistency on non-x86 arches. You should allocate the data with kmalloc().
Although, on the second thought, maybe I'm wrong in this case... not really
sure about sending -- receiving (to the .data section) could certainly be harmful...
WBR, Sergei
Dmitry Torokhov
maintainerQuoted 55 lines · Sergei Shtylyov
Hello.
Quoted 11 lines · Forest Bond
From: Forest Bond <[email protected]>
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,Please also specify that commit's summary ion parens.
Quoted 19 lines
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 <[email protected]>--- drivers/input/touchscreen/usbtouchscreen.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)drivers/input/touchscreen/usbtouchscreen.c +0
-0drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 313
Quoted 10 lines
drivers/input/touchscreen/usbtouchscreen.c +7
-0@@ -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. */ The preferred multi-line comment style is:
/*
* bla
* bla
*/
Quoted 13 lines
drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 320
Quoted 7 lines
drivers/input/touchscreen/usbtouchscreen.c +7
-0+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,You probably can't send data from the .const section (as well as off the
stack) -- they can be DMA'ed and there'll be issues with cache consistency on non-x86 arches. You should allocate the data withkmalloc().
Although, on the second thought, maybe I'm wrong in this case... not really
sure about sending -- receiving (to the .data section) could certainly be harmful...
Hmm, do we actually send anything here? The "size" passed to usb_control_msg() is 0 so I don't think we use that data at all...
Thanks.
Signature · 1 line
Dmitry
A message that is not in the archive (sent off-list or not yet received): 20120831192632.GA30202-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org
Quoted 13 lines · Dmitry Torokhov
Quoted 4 lines
Quoted 4 lines
drivers/input/touchscreen/usbtouchscreen.c +4
-0+/* Send a "check active" packet. The response will be read +* later and ignored. */ + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + 0,Quoted 8 lines
drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 320
Quoted 2 lines
drivers/input/touchscreen/usbtouchscreen.c +2
-0+USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , + 0, 0, "\x0A\x01A", 0,You probably can't send data from the .const section (as well as off the
stack) -- they can be DMA'ed and there'll be issues with cache consistency on non-x86 arches. You should allocate the data withkmalloc().
Although, on the second thought, maybe I'm wrong in this case... not really
sure about sending -- receiving (to the .data section) could certainly be harmful...
Quoted 2 lines
Hmm, do we actually send anything here? The "size" passed to
usb_control_msg()is 0 so I don't think we use that data at all...
Good point. Perhaps the 0 is a typo, in which case data does get sent and the buffer must be kmalloc'ed. If the 0 is correct then the buffer should be NULL, not "\x0A\x01A" (and what's the purpose of the leading '0' in the second byte?).
In addition, although the bRequestType specifies USB_DIR_OUT, the pipe value is usb_rcvctrlpipe. Is this transfer meant to be IN or OUT?
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): Pine.LNX.4.44L0.1208311555140.1328-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org
Hi,
Quoted 18 lines · Alan Stern
Quoted 13 lines · Dmitry Torokhov
Quoted 4 lines
Quoted 4 lines
drivers/input/touchscreen/usbtouchscreen.c +4
-0+/* Send a "check active" packet. The response will be read +* later and ignored. */ + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + 0,Quoted 8 lines
drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 320
Quoted 2 lines
drivers/input/touchscreen/usbtouchscreen.c +2
-0+USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , + 0, 0, "\x0A\x01A", 0,You probably can't send data from the .const section (as well as off the
stack) -- they can be DMA'ed and there'll be issues with cache consistency on non-x86 arches. You should allocate the data withkmalloc().
Although, on the second thought, maybe I'm wrong in this case... not really
sure about sending -- receiving (to the .data section) could certainly be harmful...Quoted 2 lines
Hmm, do we actually send anything here? The "size" passed to
usb_control_msg()is 0 so I don't think we use that data at all...
Quoted 7 lines
Good point. Perhaps the 0 is a typo, in which case data does get sent and the buffer must be kmalloc'ed. If the 0 is correct then the buffer should be NULL, not "\x0A\x01A" (and what's the purpose of the leading '0' in the second byte?).
In addition, although the bRequestType specifies
USB_DIR_OUT, the pipe value isusb_rcvctrlpipe. Is this transfer meant to be IN or OUT?
The primary issue is that I'm a USB newb working on a deadline. ;)
My intention with this call was to send those three bytes out to the device. I tested this in Python using a libusb binding. Oddly enough, the code as written does in fact work in the sense that the device talks to the driver correctly after initialization (and without it it doesn't).
Anyway, thanks for the review and sorry for being a bonehead. I'll resend.
Thanks,
Forest
Signature · 3 lines
Forest Bond http://www.alittletooquiet.net http://www.rapidrollout.com
Hi,
Quoted 18 lines · Alan Stern
Quoted 13 lines · Dmitry Torokhov
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4
-0+ /* Send a "check active" packet. The response will be read + * later and ignored. */ + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + 0,Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0, 0, "\x0A\x01A", 0,You probably can't send data from the .const section (as well as off the
stack) -- they can be DMA'ed and there'll be issues with cache consistency on non-x86 arches. You should allocate the data withkmalloc().
Although, on the second thought, maybe I'm wrong in this case... not really
sure about sending -- receiving (to the .data section) could certainly be harmful...Quoted 2 lines
Hmm, do we actually send anything here? The "size" passed to
usb_control_msg()is 0 so I don't think we use that data at all...
Quoted 7 lines
Good point. Perhaps the 0 is a typo, in which case data does get sent and the buffer must be kmalloc'ed. If the 0 is correct then the buffer should be NULL, not "\x0A\x01A" (and what's the purpose of the leading '0' in the second byte?).
In addition, although the bRequestType specifies
USB_DIR_OUT, the pipe value isusb_rcvctrlpipe. Is this transfer meant to be IN or OUT?
Thanks again to all for the review. My theory for why the previous patch worked in spite of its wrongness is that the device actually switches modes when it receives a control message with USB_TYPE_VENDOR even though the documentation suggests an actual diagnostic packet must be received.
Does this (untested) patch look more reasonable?
drivers/input/touchscreen/usbtouchscreen.c +36 -0
@@ -304,6 +304,41 @@ 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; +unsigned char *buf; +struct usb_device *udev =interface_to_usbdev (usbtouch->interface); + +/* An eGalax diagnostic packet kicks the device into using the right +* protocol. We send a "check active" packet. The response will be +* read later and ignored. +*/ + + buf =kmalloc (3 ,GFP_KERNEL ); + buf[0 ] =EGALAX_PKT_TYPE_DIAG ; + buf[1 ] =1 ;/* length */ + buf[2 ] ='A' ;/* command - check active */ + +for (i =0 ; i <3 ; i++) { + ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ), +0 , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , +0 ,0 , buf,3 , +USB_CTRL_SET_TIMEOUT ); +if (ret >=0 ) { + ret =0 ; +break ; + } +if (ret != -EPIPE ) +break ; + } + +kfree (buf); + +return ret; +} +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 +1091,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
Thanks,
Forest
Signature · 3 lines
Forest Bond http://www.alittletooquiet.net http://www.rapidrollout.com
A message that is not in the archive (sent off-list or not yet received): 20120831225353.GE24820-B/[email protected]
Quoted 29 lines · Forest Bond
Hi,
Quoted 18 lines · Alan Stern
Quoted 13 lines · Dmitry Torokhov
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4
-0+ /* Send a "check active" packet. The response will be read + * later and ignored. */ + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + 0,Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0, 0, "\x0A\x01A", 0,You probably can't send data from the .const section (as well as off the
stack) -- they can be DMA'ed and there'll be issues with cache consistency on non-x86 arches. You should allocate the data withkmalloc().
Although, on the second thought, maybe I'm wrong in this case... not really
sure about sending -- receiving (to the .data section) could certainly be harmful...Quoted 2 lines
Hmm, do we actually send anything here? The "size" passed to
usb_control_msg()is 0 so I don't think we use that data at all...Quoted 7 lines
Good point. Perhaps the 0 is a typo, in which case data does get sent and the buffer must be kmalloc'ed. If the 0 is correct then the buffer should be NULL, not "\x0A\x01A" (and what's the purpose of the leading '0' in the second byte?).
In addition, although the bRequestType specifies
USB_DIR_OUT, the pipe value isusb_rcvctrlpipe. Is this transfer meant to be IN or OUT?
Quoted 6 lines
Thanks again to all for the review. My theory for why the previous patch worked in spite of its wrongness is that the device actually switches modes when it receives a control message with
USB_TYPE_VENDOReven though the documentation suggests an actual diagnostic packet must be received.Does this (untested) patch look more reasonable?
Yes, but we still need it tested, please.
Quoted 63 lines
drivers/input/touchscreen/usbtouchscreen.c +36
-0@@ -304,6 +304,41 @@ 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; +unsigned char *buf; +struct usb_device *udev =interface_to_usbdev (usbtouch->interface); + +/* An eGalax diagnostic packet kicks the device into using the right +* protocol. We send a "check active" packet. The response will be +* read later and ignored. +*/ + + buf =kmalloc (3 ,GFP_KERNEL ); + buf[0 ] =EGALAX_PKT_TYPE_DIAG ; + buf[1 ] =1 ;/* length */ + buf[2 ] ='A' ;/* command - check active */ + +for (i =0 ; i <3 ; i++) { + ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ), +0 , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , +0 ,0 , buf,3 , +USB_CTRL_SET_TIMEOUT ); +if (ret >=0 ) { + ret =0 ; +break ; + } +if (ret != -EPIPE ) +break ; + } + +kfree (buf); + +return ret; +} +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 +1091,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 Thanks,
ForestSignature · 3 lines
Forest Bond http://www.alittletooquiet.net http://www.rapidrollout.com
Signature · 5 lines
Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20120831231047.GA22142-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org
Hi Dmitry,
Quoted 30 lines · Dmitry Torokhov
Quoted 29 lines · Forest Bond
Hi,
Quoted 25 lines · Alan Stern
Quoted 13 lines · Dmitry Torokhov
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4
-0+ /* Send a "check active" packet. The response will be read + * later and ignored. */ + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + 0,Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0, 0, "\x0A\x01A", 0,You probably can't send data from the .const section (as well as off the
stack) -- they can be DMA'ed and there'll be issues with cache consistency on non-x86 arches. You should allocate the data withkmalloc().
Although, on the second thought, maybe I'm wrong in this case... not really
sure about sending -- receiving (to the .data section) could certainly be harmful...Quoted 2 lines
Hmm, do we actually send anything here? The "size" passed to
usb_control_msg()is 0 so I don't think we use that data at all...Good point. Perhaps the 0 is a typo, in which case data does get sent and the buffer must be kmalloc'ed. If the 0 is correct then the buffer should be NULL, not "\x0A\x01A" (and what's the purpose of the leading '0' in the second byte?).
In addition, although the bRequestType specifies
USB_DIR_OUT, the pipe value isusb_rcvctrlpipe. Is this transfer meant to be IN or OUT?
Quoted 8 lines
Quoted 6 lines
Thanks again to all for the review. My theory for why the previous patch worked in spite of its wrongness is that the device actually switches modes when it receives a control message with
USB_TYPE_VENDOReven though the documentation suggests an actual diagnostic packet must be received.Does this (untested) patch look more reasonable?
Yes, but we still need it tested, please.
Great, I'll test it later this evening when I am back in front of the hardware and follow up with a properly submitted patch.
Thanks again,
Forest
Signature · 3 lines
Forest Bond http://www.alittletooquiet.net http://www.rapidrollout.com
PATCH RESEND 1/1 Input: usbtouchscreen - initialize eGalax devices
From: Forest Bond <[email protected]>
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 ("Input: usbtouchscreen - fix eGalax HID ignoring"), 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.
--- drivers/input/touchscreen/usbtouchscreen.c | 36 ++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-)
drivers/input/touchscreen/usbtouchscreen.c +36 -0
@@ -304,6 +304,41 @@ 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; +unsigned char *buf; +struct usb_device *udev =interface_to_usbdev (usbtouch->interface); + +/* An eGalax diagnostic packet kicks the device into using the right +* protocol. We send a "check active" packet. The response will be +* read later and ignored. +*/ + + buf =kmalloc (3 ,GFP_KERNEL ); + buf[0 ] =EGALAX_PKT_TYPE_DIAG ; + buf[1 ] =1 ;/* length */ + buf[2 ] ='A' ;/* command - check active */ + +for (i =0 ; i <3 ; i++) { + ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ), +0 , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , +0 ,0 , buf,3 , +USB_CTRL_SET_TIMEOUT ); +if (ret >=0 ) { + ret =0 ; +break ; + } +if (ret != -EPIPE ) +break ; + } + +kfree (buf); + +return ret; +} +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 +1091,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
Signature · 1 line
1.7.0.4
Quoted 36 lines · Forest Bond
From: Forest Bond <[email protected]>
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("Input: usbtouchscreen - fix eGalax HID ignoring"), 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 <[email protected]>--- drivers/input/touchscreen/usbtouchscreen.c | 36 ++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-)drivers/input/touchscreen/usbtouchscreen.c +2
-0@@ -304,6 +304,41 @@ 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) +{
drivers/input/touchscreen/usbtouchscreen.c static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt) · line 318
Quoted 10 lines
drivers/input/touchscreen/usbtouchscreen.c +10
-0+int ret, i; +unsigned char *buf; +struct usb_device *udev =interface_to_usbdev (usbtouch->interface); + +/* An eGalax diagnostic packet kicks the device into using the right +* protocol. We send a "check active" packet. The response will be +* read later and ignored. +*/ + + buf =kmalloc (3 ,GFP_KERNEL );
if (!buf) return -ENOMEM;
Quoted 22 lines
drivers/input/touchscreen/usbtouchscreen.c +22
-0+ buf[0 ] =EGALAX_PKT_TYPE_DIAG ; + buf[1 ] =1 ;/* length */ + buf[2 ] ='A' ;/* command - check active */ + +for (i =0 ; i <3 ; i++) { + ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ), +0 , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , +0 ,0 , buf,3 , +USB_CTRL_SET_TIMEOUT ); +if (ret >=0 ) { + ret =0 ; +break ; + } +if (ret != -EPIPE ) +break ; + } + +kfree (buf); + +return ret; +}
A message that is not in the archive (sent off-list or not yet received): 20120903132648.GC11919-TEYkr/UGJhVKdHEj4xO92LjjLBE8jN/[email protected]
PATCH 1/1 Input: usbtouchscreen - initialize eGalax devices
From: Forest Bond <[email protected]>
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 ("Input: usbtouchscreen - fix eGalax HID ignoring"), 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.
--- drivers/input/touchscreen/usbtouchscreen.c | 39 ++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)
drivers/input/touchscreen/usbtouchscreen.c +39 -0
@@ -304,6 +304,44 @@ 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; +unsigned char *buf; +struct usb_device *udev =interface_to_usbdev (usbtouch->interface); + +/* An eGalax diagnostic packet kicks the device into using the right +* protocol. We send a "check active" packet. The response will be +* read later and ignored. +*/ + + buf =kmalloc (3 ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + buf[0 ] =EGALAX_PKT_TYPE_DIAG ; + buf[1 ] =1 ;/* length */ + buf[2 ] ='A' ;/* command - check active */ + +for (i =0 ; i <3 ; i++) { + ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ), +0 , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , +0 ,0 , buf,3 , +USB_CTRL_SET_TIMEOUT ); +if (ret >=0 ) { + ret =0 ; +break ; + } +if (ret != -EPIPE ) +break ; + } + +kfree (buf); + +return ret; +} +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 +1094,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
Signature · 5 lines
1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20120903173349.GA18666-B/[email protected]
Dmitry Torokhov
AppliedQuoted 18 lines · Forest Bond
From: Forest Bond <[email protected]>
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("Input: usbtouchscreen - fix eGalax HID ignoring"), 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.
Quoted 4 lines
I have the distinct pleasure of needing to support devices of both types and have tested accordingly.
Signed-off-by Forest Bond <[email protected]>
Applied, thank you Forest.
Quoted 63 lines
--- drivers/input/touchscreen/usbtouchscreen.c | 39 ++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)drivers/input/touchscreen/usbtouchscreen.c +39
-0@@ -304,6 +304,44 @@ 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; +unsigned char *buf; +struct usb_device *udev =interface_to_usbdev (usbtouch->interface); + +/* An eGalax diagnostic packet kicks the device into using the right +* protocol. We send a "check active" packet. The response will be +* read later and ignored. +*/ + + buf =kmalloc (3 ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + + buf[0 ] =EGALAX_PKT_TYPE_DIAG ; + buf[1 ] =1 ;/* length */ + buf[2 ] ='A' ;/* command - check active */ + +for (i =0 ; i <3 ; i++) { + ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ), +0 , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , +0 ,0 , buf,3 , +USB_CTRL_SET_TIMEOUT ); +if (ret >=0 ) { + ret =0 ; +break ; + } +if (ret != -EPIPE ) +break ; + } + +kfree (buf); + +return ret; +} +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 +1094,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 Signature · 1 line
1.7.0.4
Signature · 5 lines
Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20120905060704.GC25962-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org
Hi Dmitry,
Quoted 19 lines · Dmitry Torokhov
Quoted 18 lines · Forest Bond
From: Forest Bond <[email protected]>
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("Input: usbtouchscreen - fix eGalax HID ignoring"), 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.
Quoted 6 lines
Quoted 4 lines
I have the distinct pleasure of needing to support devices of both types and have tested accordingly.
Signed-off-by Forest Bond <[email protected]>Applied, thank you Forest.
Great, thanks a lot.
The other piece to this puzzle is that usbhid should blacklist these devices to avoid binding if it happens to be loaded before usbtouchscreen. To do this, usbhid needs to be able to blacklist devices based on interface protocol (right now it only supports blacklist on VID + PID).
Would you accept a patch set that implements this?
Thanks,
Forest
Signature · 3 lines
Forest Bond http://www.alittletooquiet.net http://www.rapidrollout.com
Dmitry Torokhov
maintainerQuoted 29 lines · Forest Bond
Hi Dmitry,
Quoted 19 lines · Dmitry Torokhov
Quoted 18 lines · Forest Bond
From: Forest Bond <[email protected]>
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("Input: usbtouchscreen - fix eGalax HID ignoring"), 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.Quoted 6 lines
Quoted 4 lines
I have the distinct pleasure of needing to support devices of both types and have tested accordingly.
Signed-off-by Forest Bond <[email protected]>Applied, thank you Forest.
Quoted 8 lines
Great, thanks a lot.
The other piece to this puzzle is that usbhid should blacklist these devices to avoid binding if it happens to be loaded before usbtouchscreen. To do this, usbhid needs to be able to blacklist devices based on interface protocol (right now it only supports blacklist on VID + PID).
Would you accept a patch set that implements this?
Juri, this question is really for you...
Thanks!
Signature · 1 line
Dmitry
Quoted 8 lines · Dmitry Torokhov
Quoted 6 lines
The other piece to this puzzle is that usbhid should blacklist these devices to avoid binding if it happens to be loaded before usbtouchscreen. To do this, usbhid needs to be able to blacklist devices based on interface protocol (right now it only supports blacklist on VID + PID).
Would you accept a patch set that implements this?
Juri, this question is really for you...
Generally, I am not objecting to this idea in general.
What is the particular use case here, so that it's needed?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Hi Jiri,
Thanks for your message. Pretty good timing, actually, as I was just about to pick this back up. ;)
Quoted 7 lines · Jiri Kosina
Quoted 5 lines · Dmitry Torokhov
Quoted 5 lines
The other piece to this puzzle is that usbhid should blacklist these devices to avoid binding if it happens to be loaded before usbtouchscreen. To do this, usbhid needs to be able to blacklist devices based on interface protocol (right now it only supports blacklist on VID + PID).
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Would you accept a patch set that implements this?
Juri, this question is really for you...
Generally, I am not objecting to this idea in general.
What is the particular use case here, so that it's needed?
We have some eGalax devices with class HID and protocol None that both usbhid and usbtouchscreen will bind to, but we only want them bound to usbtouchscreen. Some do in fact work with usbhid, but not all of them do. OTOH they all work with usbtouchscreen as of commit 037a833ed05a86d01ea27a2c32043b86c549be1b.
We want to blacklist these devices in usbhid to avoid binding to it if it is loaded first. But usbhid should continue to handle eGalax devices with class HID and protocol other than None (e.g. Mouse). They all have the same vendor and product IDs, so we need to be able to blacklist on (VID, PID, protocol) instead of just (VID, PID).
Does that make sense?
Thanks,
Forest
Signature · 3 lines
Forest Bond http://www.alittletooquiet.net http://www.rapidrollout.com
Quoted 11 lines · Forest Bond
We have some eGalax devices with class HID and protocol None that both usbhid and usbtouchscreen will bind to, but we only want them bound to usbtouchscreen. Some do in fact work with usbhid, but not all of them do. OTOH they all work with usbtouchscreen as of commit
037a833ed05a86d01ea27a2c32043b86c549be1b.We want to blacklist these devices in usbhid to avoid binding to it if it is loaded first. But usbhid should continue to handle eGalax devices with class HID and protocol other than None (e.g. Mouse). They all have the same vendor and product IDs, so we need to be able to blacklist on (VID, PID, protocol) instead of just (VID, PID).
I see, thanks for the explanation.
As this is the first time we are having this problem, I'd just propose to put just another switch into hid_ignore() for USB_VENDOR_ID_DWAV, and looking at hdev->type there to see whether we should ignore the device or not.
If it turns, over time, to be a more general problem for multiple devices, we'll just introduce the more general blacklist matching then.
How does that sound?
Signature · 2 lines
Jiri Kosina SUSE Labs
Hi Jiri,
Quoted 21 lines · Jiri Kosina
Quoted 11 lines · Forest Bond
We have some eGalax devices with class HID and protocol None that both usbhid and usbtouchscreen will bind to, but we only want them bound to usbtouchscreen. Some do in fact work with usbhid, but not all of them do. OTOH they all work with usbtouchscreen as of commit
037a833ed05a86d01ea27a2c32043b86c549be1b.We want to blacklist these devices in usbhid to avoid binding to it if it is loaded first. But usbhid should continue to handle eGalax devices with class HID and protocol other than None (e.g. Mouse). They all have the same vendor and product IDs, so we need to be able to blacklist on (VID, PID, protocol) instead of just (VID, PID).
I see, thanks for the explanation.
As this is the first time we are having this problem, I'd just propose to put just another switch into
hid_ignore()forUSB_VENDOR_ID_DWAV, and looking athdev->typethere to see whether we should ignore the device or not.
Quoted 4 lines
If it turns, over time, to be a more general problem for multiple devices, we'll just introduce the more general blacklist matching then.
How does that sound?
Makes sense to me. I didn't notice the checks in hid_ignore until now.
I'll send a patch in shortly.
Thanks,
Forest
Signature · 3 lines
Forest Bond http://www.alittletooquiet.net http://www.rapidrollout.com