Skip to contentSkip to conversation

Try to add support for universal USB touchscreen device, and WISH for help~

PATCH New Lanslott Gish 6 participants 19 messages Mar 10, 2006 – Mar 21, 2006 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Try to add support for universal USB touchscreen device, and WISH for help~

Hi all,

i try to arrange some codes, and named "usbtouchdev", wish to help merging all USB touchscreen devices like mtouchusb.c, itmtouch.c, touchkitusb.c, usbtouchset.c, etc.

in this moment, only add my touchscreen driver here and test pass. if anyone wanna add another USB touchscreen driver, or wanna modify the codes, or any help i can do, please feel free to tell me.

wish help some.

======

drivers/usb/input/hid-core.c +12 -0
@@ -1459,6 +1459,9 @@
 #define USB_VENDOR_ID_HP		0x03f0
 #define USB_DEVICE_ID_HP_USBHUB_KB	0x020c
 
+#define USB_VENDOR_ID_TOUCHSET	0x134c
+#define USB_DEVICE_ID_TOUCHSET	0x0001
+
 /*
  * Alphabetically sorted blacklist by quirk type.
  */
@@ -1602,6 +1605,15 @@
 	{ USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN },
 	{ USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN },
 	{ USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN },
+
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET,
+		HID_QUIRK_IGNORE},
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET + 1,
+		HID_QUIRK_IGNORE},
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET + 2,
+		HID_QUIRK_IGNORE},
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET + 3,
+		HID_QUIRK_IGNORE},
 
 	{ 0, 0 }
 };
drivers/usb/input/Kconfig +12 -0
@@ -330,3 +330,15 @@
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called appletouch.
+
+config USB_TOUCHDEV
+	tristate "Touchscreen General USB Device"
+	depends on USB && INPUT
+	---help---
+	  Say Y here if you want to use a USB Touchscreen controller.
+
+	  Have a look at <http://linux.chapter7.ch/touchkit/> for
+	  a usage description and the required user-space stuff.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called usbtouchset.
drivers/usb/input/Makefile +1 -0
@@ -43,6 +43,7 @@
 obj-$(CONFIG_USB_YEALINK)	+= yealink.o
 obj-$(CONFIG_USB_XPAD)		+= xpad.o
 obj-$(CONFIG_USB_APPLETOUCH)	+= appletouch.o
++obj-$(CONFIG_USB_TOUCHDEV)	+= usbtouchdev.o
 
 ifeq ($(CONFIG_USB_DEBUG),y)
 EXTRA_CFLAGS += -DDEBUG
drivers/usb/input/usbtouchdev.c +280 -0

280 lines not on this page · raw message

drivers/usb/input/usbtouchdev.h +100 -0

100 lines not on this page · raw message

======
--
L.G, Life's Good~

#1 lore raw

RFC PATCH 1/1 USB touch screen driver, all-in-one

hi

here my merge of the USB touchscreen drivers, based on my patch from thursday for touchkitusb. this time it's a new driver...

and of course it's untested. i can test the egalax part next week...

[ also cc'ing the authors of the other drivers ]

the sizes for comparison:

   text    data     bss     dec     hex filename
   2942     724       4    3670     e56 touchkitusb.ko
   2647     660       0    3307     ceb mtouchusb.ko
   2448     628       0    3076     c04 itmtouch.ko

4097 1012 4 5113 13f9 usbtouchscreen.ko

comments?

rgds
-daniel

------------

drivers/usb/input/Kconfig +36 -0
index 5246b35..2f16657 100644
@@ -240,6 +240,42 @@ config USB_EGALAX
 	  To compile this driver as a module, choose M here: the
 	  module will be called touchkitusb.
 
+config USB_TOUCHSCREEN
+	tristate "USB Touchscreen Driver"
+	depends on USB && INPUT
+	---help---
+	  USB Touchscreen driver for:
+	  - eGalax Touchkit USB
+	  - PanJit TouchSet USB
+	  - 3M MicroTouch USB
+	  - ITM
+
+	  Have a look at <http://linux.chapter7.ch/touchkit/> for
+	  a usage description and the required user-space stuff.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called usbtouchscreen.
+
+config USB_TOUCHSCREEN_EGALAX
+	default y
+	bool "eGalax device support" if EMBEDDED
+	depends on USB_TOUCHSCREEN
+
+config USB_TOUCHSCREEN_PANJIT
+	default y
+	bool "PanJit device support" if EMBEDDED
+	depends on USB_TOUCHSCREEN
+
+config USB_TOUCHSCREEN_3M
+	default y
+	bool "3M/Microtouch device support" if EMBEDDED
+	depends on USB_TOUCHSCREEN
+
+config USB_TOUCHSCREEN_ITM
+	default y
+	bool "ITM device support" if EMBEDDED
+	depends on USB_TOUCHSCREEN
+
 config USB_YEALINK
 	tristate "Yealink usb-p1k voip phone"
 	depends on USB && INPUT && EXPERIMENTAL
drivers/usb/input/Makefile +1 -0
index d512d9f..7641145 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_USB_MOUSE)		+= usbmouse.o
 obj-$(CONFIG_USB_MTOUCH)	+= mtouchusb.o
 obj-$(CONFIG_USB_ITMTOUCH)	+= itmtouch.o
 obj-$(CONFIG_USB_EGALAX)	+= touchkitusb.o
+obj-$(CONFIG_USB_TOUCHSCREEN)	+= usbtouchscreen.o
 obj-$(CONFIG_USB_POWERMATE)	+= powermate.o
 obj-$(CONFIG_USB_WACOM)		+= wacom.o
 obj-$(CONFIG_USB_ACECAD)	+= acecad.o
drivers/usb/input/hid-core.c +7 -0
index 07a012f..103e33f 100644
@@ -1460,6 +1460,8 @@ void hid_init_reports(struct hid_device 
 #define USB_VENDOR_ID_HP		0x03f0
 #define USB_DEVICE_ID_HP_USBHUB_KB	0x020c
 
+#define USB_VENDOR_ID_PANJIT		0x134c
+
 /*
  * Alphabetically sorted blacklist by quirk type.
  */
@@ -1605,6 +1607,11 @@ static const struct hid_blacklist {
 	{ USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN },
 	{ USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN },
 
+	{ USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE },
+
 	{ 0, 0 }
 };
 
drivers/usb/input/usbtouchscreen.c new file +587 -0

587 lines not on this page · raw message

#2 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 9 lines · Daniel Ritz

hi

here my merge of the USB touchscreen drivers, based on my patch from thursday for touchkitusb. this time it's a new driver...

and of course it's untested. i can test the egalax part next week...

[ also cc'ing the authors of the other drivers ]

Quoted 9 lines

the sizes for comparison:

   text    data     bss     dec     hex filename
   2942     724       4    3670     e56 touchkitusb.ko
   2647     660       0    3307     ceb mtouchusb.ko
   2448     628       0    3076     c04 itmtouch.ko

4097 1012 4 5113 13f9 usbtouchscreen.ko

comments?

I like it.

drivers/usb/input/usbtouchscreen.c line 514

Quoted 7 lines
drivers/usb/input/usbtouchscreen.c new file +7 -0
+
+	input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+	input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+	input_set_abs_params(input_dev, ABS_X, type->min_xc, type->max_xc, 0, 0);
+	input_set_abs_params(input_dev, ABS_Y, type->min_yc, type->max_yc, 0, 0);
+	input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press, type->max_press, 0, 0);
+

Not all devices report pressure; driver should only advertise ABS_PRESSURE for devices that actually support it.

drivers/usb/input/usbtouchscreen.c line 524

Quoted 10 lines
drivers/usb/input/usbtouchscreen.c new file +10 -0
+	usb_fill_int_urb(usbtouch->irq, usbtouch->udev,
+			 usb_rcvintpipe(usbtouch->udev, 0x81),
+			 usbtouch->data, type->rept_size,
+			 usbtouch_irq, usbtouch, endpoint->bInterval);
+
+	usbtouch->irq->transfer_dma = usbtouch->data_dma;
+	usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+
+	input_register_device(usbtouch->input);
+

Please add error handling now that input_register_device() returns errors.

drivers/usb/input/usbtouchscreen.c line 530

Quoted 6 lines
drivers/usb/input/usbtouchscreen.c new file +6 -0
+	usb_set_intfdata(intf, usbtouch);
+
+	/* device specific init */
+	if (type->init)
+		type->init(usbtouch);
+

Should we do device-specific init before registering input device and also handle errors here?

Signature · 1 line
Dmitry
#3 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

In reply to Daniel Ritz

Hi, Daniel,
it's great. i will test touchset part today.

Regards,

Lanslott Gish

Quoted 21 lines · Daniel Ritz

hi

here my merge of the USB touchscreen drivers, based on my patch from thursday for touchkitusb. this time it's a new driver...

and of course it's untested. i can test the egalax part next week...

[ also cc'ing the authors of the other drivers ]

the sizes for comparison:

   text    data     bss     dec     hex filename
   2942     724       4    3670     e56 touchkitusb.ko
   2647     660       0    3307     ceb mtouchusb.ko
   2448     628       0    3076     c04 itmtouch.ko

4097 1012 4 5113 13f9 usbtouchscreen.ko

comments?

rgds
-daniel

#4 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Hi, Daniel,

i fixed some codes and add swap_x & swap_y functions. and test your patch passed for my touchset hrdware. here is the patch only for your usbtouchscreen.c could you help to apply this?
thank you.

Regards,

Lanslott Gish

==============================================================

drivers/usb/input/usbtouchscreen.c +14 -3
@@ -224,13 +224,24 @@
  * PanJit Part
  */
 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
+
+static int swap_x;
+module_param(swap_x, bool, 0644);
+MODULE_PARM_DESC(swap_x, "If set X axe is swapped before XY swapped.");
+static int swap_y;
+module_param(swap_y, bool, 0644);
+MODULE_PARM_DESC(swap_y, "If set Y axe is swapped before XY swapped.");
+
 static int panjit_read_data(char *pkt, int *x, int *y, int *touch, int *press)
 {
-       *x = pkt[1] | (pkt[2] << 8);
-       *y = pkt[3] | (pkt[4] << 8);
+       *x = (pkt[1] & 0x0F) | ((pkt[2]& 0xFF) << 8);
+       *y = (pkt[3] & 0x0F) | ((pkt[4]& 0xFF) << 8);
        *touch = (pkt[0] & 0x01) ? 1 : 0;
 
-       return 1;
+	if(swap_x) *x = *x ^ 0x0FFF;
+	if(swap_y) *y = *y ^ 0x0FFF;
+
+ 	return 1;
 }
 #endif
 

==============================================================

Quoted 30 lines · Lanslott Gish

Hi, Daniel,
it's great. i will test touchset part today.

Regards,

Lanslott Gish

Quoted 21 lines · Daniel Ritz

hi

here my merge of the USB touchscreen drivers, based on my patch from thursday for touchkitusb. this time it's a new driver...

and of course it's untested. i can test the egalax part next week...

[ also cc'ing the authors of the other drivers ]

the sizes for comparison:

   text    data     bss     dec     hex filename
   2942     724       4    3670     e56 touchkitusb.ko
   2647     660       0    3307     ceb mtouchusb.ko
   2448     628       0    3076     c04 itmtouch.ko

4097 1012 4 5113 13f9 usbtouchscreen.ko

comments?

rgds
-daniel

--
L.G, Life's Good~

#5 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 31 lines · Lanslott Gish

i fixed some codes and add swap_x & swap_y functions. and test your patch passed for my touchset hrdware. here is the patch only for your usbtouchscreen.c could you help to apply this?
thank you.

Regards,

Lanslott Gish

==============================================================

drivers/usb/input/usbtouchscreen.c +10 -2
@@ -224,13 +224,24 @@
  * PanJit Part
  */
 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
+
+static int swap_x;
+module_param(swap_x, bool, 0644);
+MODULE_PARM_DESC(swap_x, "If set X axe is swapped before XY swapped.");
+static int swap_y;
+module_param(swap_y, bool, 0644);
+MODULE_PARM_DESC(swap_y, "If set Y axe is swapped before XY swapped.");
+
 static int panjit_read_data(char *pkt, int *x, int *y, int *touch, int *press)
 {
-       *x = pkt[1] | (pkt[2] << 8);
-       *y = pkt[3] | (pkt[4] << 8);
+       *x = (pkt[1] & 0x0F) | ((pkt[2]& 0xFF) << 8);
+       *y = (pkt[3] & 0x0F) | ((pkt[4]& 0xFF) << 8);

drivers/usb/input/usbtouchscreen.c line 247

Quoted 10 lines
drivers/usb/input/usbtouchscreen.c +4 -1
        *touch = (pkt[0] & 0x01) ? 1 : 0;
 
-       return 1;
+	if(swap_x) *x = *x ^ 0x0FFF;
+	if(swap_y) *y = *y ^ 0x0FFF;
+
+ 	return 1;
 }
 #endif
 

Um, I think it's generally a good idea to allow this, but I'd say this should go into the common code part using the pre-known number range.

MfG, JBG

Signature · 4 lines
Jan-Benedict Glaw       [email protected]    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
#6 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

did you mean like that? thx.

regards,

Lanslott Gish
===================================================================

drivers/usb/input/usbtouchscreen.c +14 -3
@@ -49,6 +49,13 @@
 static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
+static int swap_x;
+module_param(swap_x, bool, 0644);
+MODULE_PARM_DESC(swap_x, "If set X axe is swapped before XY swapped.");
+static int swap_y;
+module_param(swap_y, bool, 0644);
+MODULE_PARM_DESC(swap_y, "If set Y axe is swapped before XY swapped.");
+
 
 
 /* device specifc data/functions */
@@ -224,13 +231,17 @@
  * PanJit Part
  */
 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
+
 static int panjit_read_data(char *pkt, int *x, int *y, int *touch, int *press)
 {
-       *x = pkt[1] | (pkt[2] << 8);
-       *y = pkt[3] | (pkt[4] << 8);
+       *x = (pkt[1] & 0x0F) | ((pkt[2]& 0xFF) << 8);
+       *y = (pkt[3] & 0x0F) | ((pkt[4]& 0xFF) << 8);
        *touch = (pkt[0] & 0x01) ? 1 : 0;
 
-       return 1;
+	if(swap_x) *x = *x ^ 0x0FFF;
+	if(swap_y) *y = *y ^ 0x0FFF;
+
+ 	return 1;
 }
 #endif

===================================================================

Quoted 26 lines · Jan-Benedict Glaw
Quoted 11 lines · Lanslott Gish

i fixed some codes and add swap_x & swap_y functions. and test your patch passed for my touchset hrdware. here is the patch only for your usbtouchscreen.c could you help to apply this?
thank you.

Regards,

Lanslott Gish

==============================================================

Um, I think it's generally a good idea to allow this, but I'd say this should go into the common code part using the pre-known number range.

MfG, JBG

--

Jan-Benedict Glaw       [email protected]    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O

für einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

Quoted 10 lines

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEFp0+Hb1edYOZ4bsRAhntAJ9tmcgcvR57teoeJIaJRqxBbrQpoACeNPFE HrHJmjM0mkN9ZQsvARoLx+0=
=06aU
-----END PGP SIGNATURE-----

--
L.G, Life's Good~

#7 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 1 line · Lanslott Gish

did you mean like that? thx.

That's basically the same patch as before?! What was ment is to move inverting the axes into usbtouch_process_pkt().

MfG, JBG

Signature · 4 lines
Jan-Benedict Glaw       [email protected]    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
#8 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

i'm not sure if any touch device need this.
If some need, please move any code to general part. thx.

Quoted 9 lines · Jan-Benedict Glaw
Quoted 1 line · Lanslott Gish

did you mean like that? thx.

That's basically the same patch as before?! What was ment is to move inverting the axes into usbtouch_process_pkt().

MfG, JBG

--

--
L.G, Life's Good~

#9 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

In reply to Lanslott Gish
Quoted 10 lines · Lanslott Gish

did you mean like that? thx.

regards,

Lanslott Gish
===================================================================

drivers/usb/input/usbtouchscreen.c +0 -0
@@ -49,6 +49,13 @@
 static int swap_xy;

drivers/usb/input/usbtouchscreen.c line 59

Quoted 10 lines
drivers/usb/input/usbtouchscreen.c +7 -0
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
+static int swap_x;
+module_param(swap_x, bool, 0644);
+MODULE_PARM_DESC(swap_x, "If set X axe is swapped before XY swapped.");
+static int swap_y;
+module_param(swap_y, bool, 0644);
+MODULE_PARM_DESC(swap_y, "If set Y axe is swapped before XY swapped.");
+
 

(i prefer invert_x and invert_y...)

drivers/usb/input/usbtouchscreen.c line 238

Quoted 13 lines
drivers/usb/input/usbtouchscreen.c +3 -2
 /* device specifc data/functions */
@@ -224,13 +231,17 @@
  * PanJit Part
  */
 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
+
 static int panjit_read_data(char *pkt, int *x, int *y, int *touch, int *press)
 {
-       *x = pkt[1] | (pkt[2] << 8);
-       *y = pkt[3] | (pkt[4] << 8);
+       *x = (pkt[1] & 0x0F) | ((pkt[2]& 0xFF) << 8);
+       *y = (pkt[3] & 0x0F) | ((pkt[4]& 0xFF) << 8);

that just can't be right. you probably mean
+ *y = pkt[3] | ((pkt[4] & 0x0F) << 8);

otherwise you mask out bits 4-7. but you want to limit it to 12 bits... (btw. no need for the & 0xFF mask since *pkt is char)

anyway, i updated the driver with all the comments i got so far. will send out in a minute as a new mail.

rgds
-daniel

#10 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 14 lines · Daniel Ritz
Quoted 13 lines · Lanslott Gish

did you mean like that? thx.

regards,

Lanslott Gish
===================================================================

drivers/usb/input/usbtouchscreen.c +1 -0
@@ -49,6 +49,13 @@
 static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
+static int swap_x;
Quoted 9 lines

drivers/usb/input/usbtouchscreen.c line 59

Quoted 7 lines
drivers/usb/input/usbtouchscreen.c +6 -0
+module_param(swap_x, bool, 0644);
+MODULE_PARM_DESC(swap_x, "If set X axe is swapped before XY swapped.");
+static int swap_y;
+module_param(swap_y, bool, 0644);
+MODULE_PARM_DESC(swap_y, "If set Y axe is swapped before XY swapped.");
+
 

(i prefer invert_x and invert_y...)

"invert" is great, thx.
evtouch(X11 driver) called these swap_x and swap_y

Quoted 17 lines

drivers/usb/input/usbtouchscreen.c line 238

Quoted 13 lines
drivers/usb/input/usbtouchscreen.c +3 -2
 /* device specifc data/functions */
@@ -224,13 +231,17 @@
  * PanJit Part
  */
 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
+
 static int panjit_read_data(char *pkt, int *x, int *y, int *touch, int *press)
 {
-       *x = pkt[1] | (pkt[2] << 8);
-       *y = pkt[3] | (pkt[4] << 8);
+       *x = (pkt[1] & 0x0F) | ((pkt[2]& 0xFF) << 8);
+       *y = (pkt[3] & 0x0F) | ((pkt[4]& 0xFF) << 8);

that just can't be right. you probably mean
+ *y = pkt[3] | ((pkt[4] & 0x0F) << 8);

Quoted 3 lines

otherwise you mask out bits 4-7. but you want to limit it to 12 bits... (btw. no need for the & 0xFF mask since *pkt is char)

you are right, sorry for my fault. the truely way is

+       *x = (pkt[1] & 0xFF) | ((pkt[2] & 0x0F) << 8);
+       *y = (pkt[3] & 0xFF) | ((pkt[4] & 0x0F) << 8);

still need 12 bits( 0x0FFF) and the masks to avoid get negative.

BTW, may i also suggest add more module_param to max_x, max_y, min_x, min_y ? i think these options is useful, too.

regards,

Lanslott Gish
--
L.G, Life's Good~

#11 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 24 lines · Lanslott Gish
Quoted 14 lines · Daniel Ritz
Quoted 13 lines · Lanslott Gish

did you mean like that? thx.

regards,

Lanslott Gish
===================================================================

drivers/usb/input/usbtouchscreen.c +1 -0
@@ -49,6 +49,13 @@
 static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
+static int swap_x;
Quoted 9 lines

drivers/usb/input/usbtouchscreen.c line 59

Quoted 7 lines
drivers/usb/input/usbtouchscreen.c +6 -0
+module_param(swap_x, bool, 0644);
+MODULE_PARM_DESC(swap_x, "If set X axe is swapped before XY swapped.");
+static int swap_y;
+module_param(swap_y, bool, 0644);
+MODULE_PARM_DESC(swap_y, "If set Y axe is swapped before XY swapped.");
+
 

(i prefer invert_x and invert_y...)

Quoted 3 lines

"invert" is great, thx.
evtouch(X11 driver) called these swap_x and swap_y

i think i drop it alltogether. as greg already mentioned it should be sysfs attributes. ( besides it's completely doable in userspace. and evtouch can do it. )

Quoted 26 lines
Quoted 17 lines

drivers/usb/input/usbtouchscreen.c line 238

Quoted 13 lines
drivers/usb/input/usbtouchscreen.c +3 -2
 /* device specifc data/functions */
@@ -224,13 +231,17 @@
  * PanJit Part
  */
 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
+
 static int panjit_read_data(char *pkt, int *x, int *y, int *touch, int *press)
 {
-       *x = pkt[1] | (pkt[2] << 8);
-       *y = pkt[3] | (pkt[4] << 8);
+       *x = (pkt[1] & 0x0F) | ((pkt[2]& 0xFF) << 8);
+       *y = (pkt[3] & 0x0F) | ((pkt[4]& 0xFF) << 8);

that just can't be right. you probably mean
+ *y = pkt[3] | ((pkt[4] & 0x0F) << 8);

Quoted 3 lines

otherwise you mask out bits 4-7. but you want to limit it to 12 bits... (btw. no need for the & 0xFF mask since *pkt is char)

you are right, sorry for my fault. the truely way is

(quoted diff) +2 -0
+       *x = (pkt[1] & 0xFF) | ((pkt[2] & 0x0F) << 8);
+       *y = (pkt[3] & 0xFF) | ((pkt[4] & 0x0F) << 8);
Quoted 1 line

still need 12 bits( 0x0FFF) and the masks to avoid get negative.

my latest patch has it right. and no, you don't need the mask for the lower 8 bits, only for the upper 4.

Quoted 4 lines

BTW, may i also suggest add more module_param to max_x, max_y, min_x, min_y ? i think these options is useful, too.

no chance. (and if i remember correctly it's possible via evdev ioctl)

rgds
-daniel

#12 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 12 lines · Daniel Ritz
Quoted 4 lines · Lanslott Gish

On 3/16/06, Daniel Ritz <[email protected]> wrote:
"invert" is great, thx.
evtouch(X11 driver) called these swap_x and swap_y

i think i drop it alltogether. as greg already mentioned it should be sysfs attributes. ( besides it's completely doable in userspace. and evtouch can do it. )

Quoted 2 lines
Quoted 5 lines
Quoted 2 lines

BTW, may i also suggest add more module_param to max_x, max_y, min_x, min_y ? i think these options is useful, too.

no chance. (and if i remember correctly it's possible via evdev ioctl)

i could use my device in X without evtouch.o or any X-module or any xorg.conf modified, but wrong positions to cursor.

and consider using touchscreens in console(framebuffer) mode, or without evtouch in X, or devices do not provide several functions.

suppose we can something in /etc/rc.d/rc.local or some files:

/sbin/modprobe usbtouchscreen swap_xy=1,min_x=123,max_y=456,....

we don't need any calibrate tool or guest several functions from devices, and complete this module.

Anyway, just some suggestions. thx :)

regards,

Lanslott Gish

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines

drivers/usb/input/usbtouchscreen.c line 238

Quoted 13 lines

/* device specifc data/functions */

drivers/usb/input/usbtouchscreen.c +3 -2
@@ -224,13 +231,17 @@
  * PanJit Part
  */
 #ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
+
 static int panjit_read_data(char *pkt, int *x, int *y, int *touch, int *press)
 {
-       *x = pkt[1] | (pkt[2] << 8);
-       *y = pkt[3] | (pkt[4] << 8);
+       *x = (pkt[1] & 0x0F) | ((pkt[2]& 0xFF) << 8);
+       *y = (pkt[3] & 0x0F) | ((pkt[4]& 0xFF) << 8);

that just can't be right. you probably mean
+ *y = pkt[3] | ((pkt[4] & 0x0F) << 8);

otherwise you mask out bits 4-7. but you want to limit it to 12 bits... (btw. no need for the & 0xFF mask since *pkt is char)

Quoted 9 lines
Quoted 5 lines

you are right, sorry for my fault. the truely way is

still need 12 bits( 0x0FFF) and the masks to avoid get negative.

my latest patch has it right. and no, you don't need the mask for the lower 8 bits, only for the upper 4.

--
L.G, Life's Good~

#13 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 18 lines · Lanslott Gish
Quoted 7 lines · Daniel Ritz
Quoted 3 lines · Lanslott Gish

BTW, may i also suggest add more module_param to max_x, max_y, min_x, min_y ? i think these options is useful, too.

no chance. (and if i remember correctly it's possible via evdev ioctl)

i could use my device in X without evtouch.o or any X-module or any xorg.conf modified, but wrong positions to cursor.

and consider using touchscreens in console(framebuffer) mode, or without evtouch in X, or devices do not provide several functions.

suppose we can something in /etc/rc.d/rc.local or some files:

Quoted 8 lines

/sbin/modprobe usbtouchscreen swap_xy=1,min_x=123,max_y=456,....

we don't need any calibrate tool or guest several functions from devices, and complete this module.

Anyway, just some suggestions. thx :)

well, all nice and good, but...it doesn't belong into the driver. it would belong into the input subsystem or evdev. there are other absolute devices not handled by this driver that need the same calibration...
but i still think it should be in userspace...

still, it might be worth discussing it with the input hackers.

Quoted 5 lines

regards,

Lanslott Gish

rgds
-daniel

#14 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Howdy,

This has always been a bit of a fuzzy area to me since the 3M / Microtouch controllers support calibration within the device. (i.e.: send raw output, or the devices internally calculated - calibrated - output.). After asking this question long ago, I decided to document it and move on... Is there a userland calibration mechanism for anything in the userspace besides something like QT Embedded?

Regards,

Todd E. Johnson

----- Original Message ----
From: Daniel Ritz <[email protected]>
To: Lanslott Gish <[email protected]>
Cc: Greg KH <[email protected]>; Dmitry Torokhov <[email protected]>; linux-kernel <[email protected]>; linux-usb <[email protected]>; [email protected]; [email protected]; [email protected]
Sent: Tuesday, March 21, 2006 3:22:02 PM
Subject: Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 18 lines · Lanslott Gish
Quoted 7 lines · Daniel Ritz
Quoted 3 lines · Lanslott Gish

BTW, may i also suggest add more module_param to max_x, max_y, min_x, min_y ? i think these options is useful, too.

no chance. (and if i remember correctly it's possible via evdev ioctl)

i could use my device in X without evtouch.o or any X-module or any xorg.conf modified, but wrong positions to cursor.

and consider using touchscreens in console(framebuffer) mode, or without evtouch in X, or devices do not provide several functions.

suppose we can something in /etc/rc.d/rc.local or some files:

Quoted 8 lines

/sbin/modprobe usbtouchscreen swap_xy=1,min_x=123,max_y=456,....

we don't need any calibrate tool or guest several functions from devices, and complete this module.

Anyway, just some suggestions. thx :)

well, all nice and good, but...it doesn't belong into the driver. it would belong into the input subsystem or evdev. there are other absolute devices not handled by this driver that need the same calibration...
but i still think it should be in userspace...

still, it might be worth discussing it with the input hackers.

Quoted 5 lines

regards,

Lanslott Gish

rgds
-daniel

#15 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

In reply to Lanslott Gish
Quoted 13 lines · Lanslott Gish

On 3/16/06, Daniel Ritz <[email protected]> wrote:
that just can't be right. you probably mean
+ *y = pkt[3] | ((pkt[4] & 0x0F) << 8);

otherwise you mask out bits 4-7. but you want to limit it to 12 bits... (btw. no need for the & 0xFF mask since *pkt is char)

you are right, sorry for my fault. the truely way is

(quoted diff) +2 -0
+       *x = (pkt[1] & 0xFF) | ((pkt[2] & 0x0F) << 8);
+       *y = (pkt[3] & 0xFF) | ((pkt[4] & 0x0F) << 8);
Quoted 2 lines

still need 12 bits( 0x0FFF) and the masks to avoid get negative.

OK, Here we go~
i try your patch:

+ printk("pkg_dbg,%x,%x,%x,%x\n",pkt[1],pkt[2],pkt[3],pkt[4]);

+       *x = pkt[1] | ((pkt[2] & 0x0F) << 8);
+       *y = pkt[3] | ((pkt[4] & 0x0F) << 8);
+       printk("touchset_dbg,%x,%x,%d,%d\n",*x,*y,*x,*y);

and here is parts of the /var/log/message (raw data from 4 corners of the panel):

---------------------------------------------------------------------------

Mar 21 14:33:52 localhost kernel: input: PANJIT TouchSet USB Touch
Panel as /class/input/input12
Mar 21 14:33:55 localhost input.agent[10300]:      joydev: already loaded
Mar 21 14:34:38 localhost kernel: pkg_dbg,fffffff9,1,2d,e
Mar 21 14:34:38 localhost kernel: touchset_dbg,fffffff9,e2d,-7,3629
Mar 21 14:34:38 localhost kernel: pkg_dbg,fffffff8,1,2c,e
Mar 21 14:34:38 localhost kernel: touchset_dbg,fffffff8,e2c,-8,3628
Mar 21 14:34:38 localhost kernel: pkg_dbg,fffffff4,1,2d,e
Mar 21 14:34:38 localhost kernel: touchset_dbg,fffffff4,e2d,-12,3629
Mar 21 14:34:38 localhost kernel: pkg_dbg,fffffff2,1,2d,e
Mar 21 14:34:38 localhost kernel: touchset_dbg,fffffff2,e2d,-14,3629
Mar 21 14:34:38 localhost kernel: pkg_dbg,fffffff1,1,2e,e
Mar 21 14:34:38 localhost kernel: touchset_dbg,fffffff1,e2e,-15,3630
Mar 21 14:34:39 localhost kernel: pkg_dbg,20,3,ffffffae,2
Mar 21 14:34:39 localhost kernel: touchset_dbg,320,ffffffae,800,-82
Mar 21 14:34:39 localhost kernel: pkg_dbg,20,3,ffffffae,2
Mar 21 14:34:39 localhost kernel: touchset_dbg,320,ffffffae,800,-82
Mar 21 14:34:39 localhost kernel: pkg_dbg,1d,3,ffffffb2,2
Mar 21 14:34:39 localhost kernel: touchset_dbg,31d,ffffffb2,797,-78
Mar 21 14:34:39 localhost kernel: pkg_dbg,1b,3,ffffffb4,2
Mar 21 14:34:39 localhost kernel: touchset_dbg,31b,ffffffb4,795,-76
Mar 21 14:34:41 localhost kernel: pkg_dbg,ffffffa4,c,75,d
Mar 21 14:34:41 localhost kernel: touchset_dbg,ffffffa4,d75,-92,3445
Mar 21 14:34:41 localhost kernel: pkg_dbg,ffffffa4,c,7a,d
Mar 21 14:34:41 localhost kernel: touchset_dbg,ffffffa4,d7a,-92,3450
Mar 21 14:34:41 localhost kernel: pkg_dbg,ffffffa2,c,ffffff81,d
Mar 21 14:34:41 localhost kernel: touchset_dbg,ffffffa2,ffffff81,-94,-127
Mar 21 14:34:41 localhost kernel: pkg_dbg,ffffff9d,c,ffffff87,d
Mar 21 14:34:41 localhost kernel: touchset_dbg,ffffff9d,ffffff87,-99,-121
Mar 21 14:34:42 localhost kernel: pkg_dbg,ffffff86,d,ffffffcf,1
Mar 21 14:34:42 localhost kernel: touchset_dbg,ffffff86,ffffffcf,-122,-49
Mar 21 14:34:42 localhost kernel: pkg_dbg,74,d,ffffffd7,1
Mar 21 14:34:42 localhost kernel: touchset_dbg,d74,ffffffd7,3444,-41
Mar 21 14:34:42 localhost kernel: pkg_dbg,58,d,ffffffe0,1
Mar 21 14:34:42 localhost kernel: touchset_dbg,d58,ffffffe0,3416,-32

----------------------------------------------------------------------

is anything weird?
and i try my codes:

+ printk("pkg_dbg,%x,%x,%x,%x\n",pkt[1],pkt[2],pkt[3],pkt[4]);

+       *x = (pkt[1] & 0xFF) | ((pkt[2] & 0x0F) << 8);
+       *y = (pkt[3] & 0xFF) | ((pkt[4] & 0x0F) << 8);

+ printk("touchset_dbg,%x,%x,%d,%d\n",*x,*y,*x,*y);

and here is the /var/log/message (the same, 4 coners):

---------------------------------------------------------------------

Mar 21 14:38:14 localhost kernel: usbcore: deregistering driver usbtouchscreen
Mar 21 14:38:14 localhost kernel: input: PANJIT TouchSet USB Touch
Panel as /class/input/input14
Mar 21 14:38:14 localhost kernel: usbcore: registered new driver usbtouchscreen
Mar 21 14:38:17 localhost input.agent[10688]:      joydev: already loaded
Mar 21 14:38:38 localhost kernel: pkg_dbg,5,2,6,e
Mar 21 14:38:38 localhost kernel: touchset_dbg,205,e06,517,3590
Mar 21 14:38:38 localhost kernel: pkg_dbg,fffffffe,1,13,e
Mar 21 14:38:38 localhost kernel: touchset_dbg,1fe,e13,510,3603
Mar 21 14:38:38 localhost kernel: pkg_dbg,fffffff0,1,22,e
Mar 21 14:38:38 localhost kernel: touchset_dbg,1f0,e22,496,3618
Mar 21 14:38:39 localhost kernel: pkg_dbg,ffffffd5,2,ffffff99,2
Mar 21 14:38:39 localhost kernel: touchset_dbg,2d5,299,725,665
Mar 21 14:38:39 localhost kernel: pkg_dbg,ffffffd2,2,ffffff9a,2
Mar 21 14:38:39 localhost kernel: touchset_dbg,2d2,29a,722,666
Mar 21 14:38:39 localhost kernel: pkg_dbg,ffffffce,2,ffffff9c,2
Mar 21 14:38:39 localhost kernel: touchset_dbg,2ce,29c,718,668
Mar 21 14:38:39 localhost kernel: pkg_dbg,ffffffc9,2,ffffff9e,2
Mar 21 14:38:39 localhost kernel: touchset_dbg,2c9,29e,713,670
Mar 21 14:38:41 localhost kernel: pkg_dbg,6e,d,ffffffec,d
Mar 21 14:38:41 localhost kernel: touchset_dbg,d6e,dec,3438,3564
Mar 21 14:38:41 localhost kernel: pkg_dbg,71,d,ffffffed,d
Mar 21 14:38:41 localhost kernel: touchset_dbg,d71,ded,3441,3565
Mar 21 14:38:41 localhost kernel: pkg_dbg,72,d,ffffffed,d
Mar 21 14:38:41 localhost kernel: touchset_dbg,d72,ded,3442,3565
Mar 21 14:38:41 localhost kernel: pkg_dbg,71,d,ffffffed,d
Mar 21 14:38:41 localhost kernel: touchset_dbg,d71,ded,3441,3565
Mar 21 14:38:41 localhost kernel: pkg_dbg,5f,d,ffffffec,d
Mar 21 14:38:41 localhost kernel: touchset_dbg,d5f,dec,3423,3564
Mar 21 14:38:42 localhost kernel: pkg_dbg,ffffffac,d,ffffffd0,1
Mar 21 14:38:42 localhost kernel: touchset_dbg,dac,1d0,3500,464
Mar 21 14:38:42 localhost kernel: pkg_dbg,ffffffae,d,ffffffd0,1
Mar 21 14:38:42 localhost kernel: touchset_dbg,dae,1d0,3502,464
Mar 21 14:38:42 localhost kernel: pkg_dbg,ffffffa3,d,ffffffdb,1
Mar 21 14:38:42 localhost kernel: touchset_dbg,da3,1db,3491,475
Mar 21 14:38:42 localhost kernel: pkg_dbg,ffffff92,d,ffffffe6,1
Mar 21 14:38:42 localhost kernel: touchset_dbg,d92,1e6,3474,486

---------------------------------------------------------------------
i think my codes is correct.

so, make sure that your device differ with mine. :)

regards,

Lanslott Gish
--
L.G, Life's Good~

#16 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 9 lines · Lanslott Gish
Quoted 8 lines · Lanslott Gish

On 3/16/06, Daniel Ritz <[email protected]> wrote:
that just can't be right. you probably mean
+ *y = pkt[3] | ((pkt[4] & 0x0F) << 8);

otherwise you mask out bits 4-7. but you want to limit it to 12 bits... (btw. no need for the & 0xFF mask since *pkt is char)

Quoted 7 lines
Quoted 7 lines

you are right, sorry for my fault. the truely way is

(quoted diff) +2 -0
+       *x = (pkt[1] & 0xFF) | ((pkt[2] & 0x0F) << 8);
+       *y = (pkt[3] & 0xFF) | ((pkt[4] & 0x0F) << 8);

still need 12 bits( 0x0FFF) and the masks to avoid get negative.

ok, ok, there is a bug. but the mask is still not needed. the real bug is that pkt is of type char instead of unsigned char. so a simple cast would be enough:
+ *x = (unsigned char) pkt[1] | ((pkt[2] & 0x0F) << 8);

but i changed the whole thing to unsigned char all over the place. it's better anyway.

rgds
-daniel

#17 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

In reply to Daniel Ritz

hi

here the updated version of the patch. changes since first version:
- only advertise ABS_PRESSURE when device supports it
- handle input_register_device() errors
- allow vendor specifc init to fail.
- add invert_x/invert_y modparams
- only care about 12 bits for panjit

thanks for all the inputs.

rgds
-daniel

-----

[PATCH] usb/input/usbtouchscreen: unified USB touchscreen driver

A new single driver for various USB touchscreen devices. It currently supports:
- eGalax TouchKit
- PanJit TouchSet
- 3M/Microtouch
- ITM Touchscreens

Support for the diffent devices can be enabled/disable when CONFIG_EMBEDDED is set.

It's offering the same module params for all screens:
- swap_xy: swaps X and Y axes
- invert_x/invert_y: inverts X/Y.

Sizes for comparision:

   text    data     bss     dec     hex filename
   2942     724       4    3670     e56 touchkitusb.ko
   2647     660       0    3307     ceb mtouchusb.ko
   2448     628       0    3076     c04 itmtouch.ko

4425 1012 12 5449 1549 usbtouchscreen.ko

drivers/usb/input/Kconfig +36 -0
index 5246b35..2f16657 100644
@@ -240,6 +240,42 @@ config USB_EGALAX
 	  To compile this driver as a module, choose M here: the
 	  module will be called touchkitusb.
 
+config USB_TOUCHSCREEN
+	tristate "USB Touchscreen Driver"
+	depends on USB && INPUT
+	---help---
+	  USB Touchscreen driver for:
+	  - eGalax Touchkit USB
+	  - PanJit TouchSet USB
+	  - 3M MicroTouch USB
+	  - ITM
+
+	  Have a look at <http://linux.chapter7.ch/touchkit/> for
+	  a usage description and the required user-space stuff.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called usbtouchscreen.
+
+config USB_TOUCHSCREEN_EGALAX
+	default y
+	bool "eGalax device support" if EMBEDDED
+	depends on USB_TOUCHSCREEN
+
+config USB_TOUCHSCREEN_PANJIT
+	default y
+	bool "PanJit device support" if EMBEDDED
+	depends on USB_TOUCHSCREEN
+
+config USB_TOUCHSCREEN_3M
+	default y
+	bool "3M/Microtouch device support" if EMBEDDED
+	depends on USB_TOUCHSCREEN
+
+config USB_TOUCHSCREEN_ITM
+	default y
+	bool "ITM device support" if EMBEDDED
+	depends on USB_TOUCHSCREEN
+
 config USB_YEALINK
 	tristate "Yealink usb-p1k voip phone"
 	depends on USB && INPUT && EXPERIMENTAL
drivers/usb/input/Makefile +1 -0
index d512d9f..7641145 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_USB_MOUSE)		+= usbmouse.o
 obj-$(CONFIG_USB_MTOUCH)	+= mtouchusb.o
 obj-$(CONFIG_USB_ITMTOUCH)	+= itmtouch.o
 obj-$(CONFIG_USB_EGALAX)	+= touchkitusb.o
+obj-$(CONFIG_USB_TOUCHSCREEN)	+= usbtouchscreen.o
 obj-$(CONFIG_USB_POWERMATE)	+= powermate.o
 obj-$(CONFIG_USB_WACOM)		+= wacom.o
 obj-$(CONFIG_USB_ACECAD)	+= acecad.o
drivers/usb/input/hid-core.c +7 -0
index 07a012f..103e33f 100644
@@ -1460,6 +1460,8 @@ void hid_init_reports(struct hid_device 
 #define USB_VENDOR_ID_HP		0x03f0
 #define USB_DEVICE_ID_HP_USBHUB_KB	0x020c
 
+#define USB_VENDOR_ID_PANJIT		0x134c
+
 /*
  * Alphabetically sorted blacklist by quirk type.
  */
@@ -1605,6 +1607,11 @@ static const struct hid_blacklist {
 	{ USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN },
 	{ USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN },
 
+	{ USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE },
+	{ USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE },
+
 	{ 0, 0 }
 };
 
drivers/usb/input/usbtouchscreen.c new file +616 -0

616 lines not on this page · raw message

#18 lore raw

Re: [RFC][PATCH] USB touch screen driver, all-in-one

Quoted 25 lines · Daniel Ritz

hi

here the updated version of the patch. changes since first version:
- only advertise ABS_PRESSURE when device supports it
- handle input_register_device() errors
- allow vendor specifc init to fail.
- add invert_x/invert_y modparams
- only care about 12 bits for panjit

thanks for all the inputs.

rgds
-daniel

-----

[PATCH] usb/input/usbtouchscreen: unified USB touchscreen driver

A new single driver for various USB touchscreen devices. It currently supports:
- eGalax TouchKit
- PanJit TouchSet
- 3M/Microtouch
- ITM Touchscreens

Quoted 6 lines

Support for the diffent devices can be enabled/disable when CONFIG_EMBEDDED is set.

It's offering the same module params for all screens:
- swap_xy: swaps X and Y axes
- invert_x/invert_y: inverts X/Y.

These should be sysfs attributes, on the devices, which will allow them to be set individually for the different devices. You can use the module paramater as the default to start with, so don't drop that.

thanks,

greg k-h