2008-06-28 01:37:56

by Alastair Bridgewater

[permalink] [raw]
Subject: [PATCH] input: Add support for eGalax TouchKit USB touchscreen used on HP tx1305us

The eGalax touchscreen used in the HP tx1305us tablet PC (and presumably
the rest of the tx1000 series) uses a different format for events from
the device than the existing driver supports.

Add a new device description and interrupt packet handler for the
touchscreen used in the tx1305us, claiming the USB device ID for the
device that this patch was tested with from the older eGalax device code.

Signed-off-by: Alastair Bridgewater <[email protected]>

---

Applies clean with linux-2.6.25 and linux-2.6.26-rc6.

--- linux-2.6.26-rc6/drivers/input/touchscreen/usbtouchscreen.c
2008-06-27 20:34:34.886969800 -0400
+++ linux-2.6.25/drivers/input/touchscreen/usbtouchscreen.c
2008-06-06 12:19:16.460568440 -0400
@@ -103,6 +103,7 @@ struct usbtouch_usb {
enum {
DEVTPYE_DUMMY = -1,
DEVTYPE_EGALAX,
+ DEVTYPE_EGALAX2,
DEVTYPE_PANJIT,
DEVTYPE_3M,
DEVTYPE_ITM,
@@ -120,7 +121,7 @@ static struct usb_device_id usbtouch_dev
{USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX},
{USB_DEVICE(0x3823, 0x0002), .driver_info = DEVTYPE_EGALAX},
{USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX},
- {USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX},
+ {USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX2},
{USB_DEVICE(0x0eef, 0x0002), .driver_info = DEVTYPE_EGALAX},
{USB_DEVICE(0x1234, 0x0001), .driver_info = DEVTYPE_EGALAX},
{USB_DEVICE(0x1234, 0x0002), .driver_info = DEVTYPE_EGALAX},
@@ -217,6 +218,15 @@ static int egalax_get_pkt_len(unsigned c

return 0;
}
+
+static int egalax2_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
+{
+ dev->x = ((pkt[3] & 0x0F) << 8) | pkt[2];
+ dev->y = ((pkt[5] & 0x0F) << 8) | pkt[4];
+ dev->touch = pkt[1] & 0x01;
+
+ return 1;
+}
#endif


@@ -555,6 +565,15 @@ static struct usbtouch_device_info usbto
.get_pkt_len = egalax_get_pkt_len,
.read_data = egalax_read_data,
},
+
+ [DEVTYPE_EGALAX2] = {
+ .min_xc = 0x0,
+ .max_xc = 0x0fff,
+ .min_yc = 0x0,
+ .max_yc = 0x0fff,
+ .rept_size = 8,
+ .read_data = egalax2_read_data,
+ },
#endif

#ifdef CONFIG_TOUCHSCREEN_USB_PANJIT


2008-06-28 15:14:50

by Daniel Ritz

[permalink] [raw]
Subject: Re: [PATCH] input: Add support for eGalax TouchKit USB touchscreen used on HP tx1305us

hi

> The eGalax touchscreen used in the HP tx1305us tablet PC (and presumably
> the rest of the tx1000 series) uses a different format for events from
> the device than the existing driver supports.
>
is there more information available? datasheets? drivers?

> Add a new device description and interrupt packet handler for the
> touchscreen used in the tx1305us, claiming the USB device ID for the
> device that this patch was tested with from the older eGalax device code.
>
NAK. you cannot change device IDs currently used to some new code.
this will break most eGalax setups as the device ID 0x0eef,0x0001 is used
in most of them, including the one i have..

you'll need to find a way to distinguish the screens. as a starting point
i attached an lsusb -vvv output from my screen...

NAK-by: Daniel Ritz <[email protected]>

rgds
-daniel

Bus 001 Device 002: ID 0eef:0001 D-WAV Scientific Co., Ltd eGalax TouchScreen
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x0eef D-WAV Scientific Co., Ltd
idProduct 0x0001 eGalax TouchScreen
bcdDevice 1.00
iManufacturer 1 eGalax Inc.
iProduct 5
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 USB TouchScreen
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 5
Device Status: 0x0002
(Bus Powered)
Remote Wakeup Enabled

2008-06-28 15:53:09

by Daniel Ritz

[permalink] [raw]
Subject: Re: [PATCH] input: Add support for eGalax TouchKit USB touchscreen used on HP tx1305us

On Saturday 28 June 2008 17:19:16 Daniel Ritz wrote:
> hi
>
> > The eGalax touchscreen used in the HP tx1305us tablet PC (and presumably
> > the rest of the tx1000 series) uses a different format for events from
> > the device than the existing driver supports.
> >
> is there more information available? datasheets? drivers?
>
> > Add a new device description and interrupt packet handler for the
> > touchscreen used in the tx1305us, claiming the USB device ID for the
> > device that this patch was tested with from the older eGalax device code.
> >
> NAK. you cannot change device IDs currently used to some new code.
> this will break most eGalax setups as the device ID 0x0eef,0x0001 is used
> in most of them, including the one i have..
>
> you'll need to find a way to distinguish the screens. as a starting point
> i attached an lsusb -vvv output from my screen...
>

reading the latest driver guide and programming guide from eGalax (now EETI btw.
http://www.eeti.com.tw ) it turns out that the newer devices should support the HID
format and report with that by default. those newer screens are handled by the
'usbhid' driver. have you tried loading that one before usbtouchscreen?

can you give an lsusb -vvv output?

in case the usbhid driver does not work, it's possible to put the touchscreen
into the non-HID operating mode and have to current code work again..it's easy
to code...but please try usbhid first...

rgds
-daniel

2008-06-28 18:19:21

by Alastair Bridgewater

[permalink] [raw]
Subject: Re: [PATCH] input: Add support for eGalax TouchKit USB touchscreen used on HP tx1305us

Daniel Ritz wrote:
> On Saturday 28 June 2008 17:19:16 Daniel Ritz wrote:
>> hi
>>
>>> The eGalax touchscreen used in the HP tx1305us tablet PC (and presumably
>>> the rest of the tx1000 series) uses a different format for events from
>>> the device than the existing driver supports.
>>>
>> is there more information available? datasheets? drivers?
>>
>>> Add a new device description and interrupt packet handler for the
>>> touchscreen used in the tx1305us, claiming the USB device ID for the
>>> device that this patch was tested with from the older eGalax device code.
>>>
>> NAK. you cannot change device IDs currently used to some new code.
>> this will break most eGalax setups as the device ID 0x0eef,0x0001 is used
>> in most of them, including the one i have..
>>
>> you'll need to find a way to distinguish the screens. as a starting point
>> i attached an lsusb -vvv output from my screen...
>>
>
> reading the latest driver guide and programming guide from eGalax (now EETI btw.
> http://www.eeti.com.tw ) it turns out that the newer devices should support the HID
> format and report with that by default. those newer screens are handled by the
> 'usbhid' driver. have you tried loading that one before usbtouchscreen?

Okay, just built a kernel without the usbtouchscreen driver, and it
recognized the touchscreen as belonging to the usbhid driver, and it
works. Didn't even have to change my X configuration. Thank you.

> can you give an lsusb -vvv output?

Bus 001 Device 005: ID 0eef:0001 D-WAV Scientific Co., Ltd eGalax
TouchScreen
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0eef D-WAV Scientific Co., Ltd
idProduct 0x0001 eGalax TouchScreen
bcdDevice 1.00
iManufacturer 1 eGalax INC.
iProduct 2 USB TouchController
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 1 eGalax INC.
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Devices
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 2 Mouse
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 2.10
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 141
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 3
Device Status: 0x0002
(Bus Powered)
Remote Wakeup Enabled

> in case the usbhid driver does not work, it's possible to put the touchscreen
> into the non-HID operating mode and have to current code work again..it's easy
> to code...but please try usbhid first...

And usbhid works, so... what's the next step?

> rgds
> -daniel

-- Alastair Bridgewater

2008-06-30 15:23:50

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] input: Add support for eGalax TouchKit USB touchscreen used on HP tx1305us

Hi Alastair,

On Sat, Jun 28, 2008 at 02:18:24PM -0400, Alastair Bridgewater wrote:
> bInterfaceClass 3 Human Interface Devices
> bInterfaceSubClass 1 Boot Interface Subclass
> bInterfaceProtocol 2 Mouse

I think we can try to make usbtouchscreen ignore eGalaxes with
interface class set to HID?

--
Dmitry

2008-06-30 20:13:53

by Daniel Ritz

[permalink] [raw]
Subject: Re: [PATCH] input: Add support for eGalax TouchKit USB touchscreen used on HP tx1305us

On Monday 30 June 2008 17:23:35 Dmitry Torokhov wrote:
> Hi Alastair,
>
> On Sat, Jun 28, 2008 at 02:18:24PM -0400, Alastair Bridgewater wrote:
> > bInterfaceClass 3 Human Interface Devices
> > bInterfaceSubClass 1 Boot Interface Subclass
> > bInterfaceProtocol 2 Mouse
>
> I think we can try to make usbtouchscreen ignore eGalaxes with
> interface class set to HID?
>

yeah, i was thinking of that too...something like the attached?
it's completely untested, so no signed-off-by yet...

rgds
-daniel

diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 3a0a8ca..c5b18e6 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -49,6 +49,7 @@
#include <linux/init.h>
#include <linux/usb.h>
#include <linux/usb/input.h>
+#include <linux/hid.h>


#define DRIVER_VERSION "v0.6"
@@ -101,7 +102,7 @@ struct usbtouch_usb {

/* device types */
enum {
- DEVTPYE_DUMMY = -1,
+ DEVTYPE_IGNORE = -1,
DEVTYPE_EGALAX,
DEVTYPE_PANJIT,
DEVTYPE_3M,
@@ -115,8 +116,21 @@ enum {
DEVTYPE_GOTOP,
};

+#define USB_DEVICE_HID_CLASS(vend, prod) \
+ .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
+ | USB_DEVICE_ID_MATCH_DEVICE, \
+ .idVendor = (vend), \
+ .idProduct = (prod), \
+ .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
+ .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE
+
static struct usb_device_id usbtouch_devices[] = {
#ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
+ /* ignore the HID capable devices, handled by usbhid */
+ {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE},
+ {USB_DEVICE_HID_CLASS(0x0eef, 0x0002), .driver_info = DEVTYPE_IGNORE},
+
+ /* normal device IDs */
{USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX},
{USB_DEVICE(0x3823, 0x0002), .driver_info = DEVTYPE_EGALAX},
{USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX},
@@ -857,6 +871,10 @@ static int usbtouch_probe(struct usb_interface *intf,
struct usbtouch_device_info *type;
int err = -ENOMEM;

+ /* some devices are ignored */
+ if (id->driver_info == DEVTYPE_IGNORE)
+ return -ENODEV;
+
interface = intf->cur_altsetting;
endpoint = &interface->endpoint[0].desc;

2008-06-30 20:24:32

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] input: Add support for eGalax TouchKit USB touchscreen used on HP tx1305us

On Mon, Jun 30, 2008 at 10:18:36PM +0200, Daniel Ritz wrote:
> On Monday 30 June 2008 17:23:35 Dmitry Torokhov wrote:
> > Hi Alastair,
> >
> > On Sat, Jun 28, 2008 at 02:18:24PM -0400, Alastair Bridgewater wrote:
> > > bInterfaceClass 3 Human Interface Devices
> > > bInterfaceSubClass 1 Boot Interface Subclass
> > > bInterfaceProtocol 2 Mouse
> >
> > I think we can try to make usbtouchscreen ignore eGalaxes with
> > interface class set to HID?
> >
>
> yeah, i was thinking of that too...something like the attached?
> it's completely untested, so no signed-off-by yet...
>

Yeah, that looks nice. If both you guys could test it it'd be grand.

Thanks!

--
Dmitry

2008-07-01 19:45:15

by Daniel Ritz

[permalink] [raw]
Subject: Re: [PATCH] input: Add support for eGalax TouchKit USB touchscreen used on HP tx1305us

On Monday 30 June 2008 22:24:09 Dmitry Torokhov wrote:
> On Mon, Jun 30, 2008 at 10:18:36PM +0200, Daniel Ritz wrote:
> > On Monday 30 June 2008 17:23:35 Dmitry Torokhov wrote:
> > > Hi Alastair,
> > >
> > > On Sat, Jun 28, 2008 at 02:18:24PM -0400, Alastair Bridgewater wrote:
> > > > bInterfaceClass 3 Human Interface Devices
> > > > bInterfaceSubClass 1 Boot Interface Subclass
> > > > bInterfaceProtocol 2 Mouse
> > >
> > > I think we can try to make usbtouchscreen ignore eGalaxes with
> > > interface class set to HID?
> > >
> >
> > yeah, i was thinking of that too...something like the attached?
> > it's completely untested, so no signed-off-by yet...
> >
>
> Yeah, that looks nice. If both you guys could test it it'd be grand.
>

ok, i got around testing the patch with my non-HID screen. it still works.
so from my side it's ok...attached the patch with the signed-off-by line
for your patch queue...

rgds
-daniel
----

[PATCH] usbtouchscreen: ignore newer eGalax screens with HID protocol

The newer versions of the eGalax/EETI screen implement the HID protocol.
The device IDs are still the same, but the USB interface descriptor shows
the device being of HID class. Change usbtouchscreen to ignore the HID
models as they are handled by usbhid.

Signed-off-by: Daniel Ritz <[email protected]>

diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 3a0a8ca..4736262 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -49,6 +49,7 @@
#include <linux/init.h>
#include <linux/usb.h>
#include <linux/usb/input.h>
+#include <linux/hid.h>


#define DRIVER_VERSION "v0.6"
@@ -101,7 +102,7 @@ struct usbtouch_usb {

/* device types */
enum {
- DEVTPYE_DUMMY = -1,
+ DEVTYPE_IGNORE = -1,
DEVTYPE_EGALAX,
DEVTYPE_PANJIT,
DEVTYPE_3M,
@@ -115,8 +116,21 @@ enum {
DEVTYPE_GOTOP,
};

+#define USB_DEVICE_HID_CLASS(vend, prod) \
+ .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
+ | USB_DEVICE_ID_MATCH_DEVICE, \
+ .idVendor = (vend), \
+ .idProduct = (prod), \
+ .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
+ .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE
+
static struct usb_device_id usbtouch_devices[] = {
#ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
+ /* ignore the HID capable devices, handled by usbhid */
+ {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE},
+ {USB_DEVICE_HID_CLASS(0x0eef, 0x0002), .driver_info = DEVTYPE_IGNORE},
+
+ /* normal device IDs */
{USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX},
{USB_DEVICE(0x3823, 0x0002), .driver_info = DEVTYPE_EGALAX},
{USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX},
@@ -857,6 +871,10 @@ static int usbtouch_probe(struct usb_interface *intf,
struct usbtouch_device_info *type;
int err = -ENOMEM;

+ /* some devices are ignored */
+ if (id->driver_info == DEVTYPE_IGNORE)
+ return -ENODEV;
+
interface = intf->cur_altsetting;
endpoint = &interface->endpoint[0].desc;