linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] add support for PANJIT TouchSet USB Touchscreen Device
@ 2006-03-08 22:46 Daniel Ritz
  2006-03-09  0:43 ` [linux-usb-devel] " Greg KH
  2006-03-09  9:25 ` Re: [PATCH] add support for " lanslott.gish
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Ritz @ 2006-03-08 22:46 UTC (permalink / raw)
  To: Lanslott Gish, Greg KH, Dmitry Torokhov
  Cc: linux-kernel, linux-usb, Daniel Ritz

> And what about merging with the existing driver?

something like this? it's compile tested only. not even tested
on an egalax screen since i don't have it around...
if this is ok, we could also merge itmtouch and mtouchusb into a
single driver.

rgds
-daniel

---

diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 5246b35..e1caeb5 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -224,12 +224,13 @@ config USB_ITMTOUCH
 	  To compile this driver as a module, choose M here: the
 	  module will be called itmtouch.
 
-config USB_EGALAX
-	tristate "eGalax TouchKit USB Touchscreen Driver"
+config USB_TOUCHKIT
+	tristate "TouchKit USB Touchscreen Driver"
 	depends on USB && INPUT
 	---help---
-	  Say Y here if you want to use a eGalax TouchKit USB
-	  Touchscreen controller.
+	  USB Touchscreen driver for:
+	  - eGalax Touchkit USB
+	  - PanJit TouchSet USB
 
 	  The driver has been tested on a Xenarc 700TSV monitor
 	  with eGalax touchscreen.
@@ -240,6 +241,16 @@ config USB_EGALAX
 	  To compile this driver as a module, choose M here: the
 	  module will be called touchkitusb.
 
+config USB_TOUCHKIT_EGALAX
+	default y
+	bool "eGalax device support" if EMBEDDED
+	depends on USB_TOUCHKIT
+
+config USB_TOUCHKIT_PANJIT
+	default y
+	bool "PanJit device support" if EMBEDDED
+	depends on USB_TOUCHKIT
+
 config USB_YEALINK
 	tristate "Yealink usb-p1k voip phone"
 	depends on USB && INPUT && EXPERIMENTAL
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index d512d9f..c630ac9 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -36,7 +36,7 @@ obj-$(CONFIG_USB_KEYSPAN_REMOTE)	+= keys
 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_TOUCHKIT)	+= touchkitusb.o
 obj-$(CONFIG_USB_POWERMATE)	+= powermate.o
 obj-$(CONFIG_USB_WACOM)		+= wacom.o
 obj-$(CONFIG_USB_ACECAD)	+= acecad.o
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 697c5e5..523cf1e 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -33,23 +33,8 @@
 #include <linux/usb.h>
 #include <linux/usb_input.h>
 
-#define TOUCHKIT_MIN_XC			0x0
-#define TOUCHKIT_MAX_XC			0x07ff
-#define TOUCHKIT_XC_FUZZ		0x0
-#define TOUCHKIT_XC_FLAT		0x0
-#define TOUCHKIT_MIN_YC			0x0
-#define TOUCHKIT_MAX_YC			0x07ff
-#define TOUCHKIT_YC_FUZZ		0x0
-#define TOUCHKIT_YC_FLAT		0x0
-#define TOUCHKIT_REPORT_DATA_SIZE	16
-
-#define TOUCHKIT_DOWN			0x01
-
-#define TOUCHKIT_PKT_TYPE_MASK		0xFE
-#define TOUCHKIT_PKT_TYPE_REPT		0x80
-#define TOUCHKIT_PKT_TYPE_DIAG		0x0A
 
-#define DRIVER_VERSION			"v0.1"
+#define DRIVER_VERSION			"v0.3"
 #define DRIVER_AUTHOR			"Daniel Ritz <daniel.ritz@gmx.ch>"
 #define DRIVER_DESC			"eGalax TouchKit USB HID Touchscreen Driver"
 
@@ -57,6 +42,29 @@ static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
 
+
+struct touchkit_usb;
+struct touchkit_device_info {
+	int min_xc, max_xc;
+	int min_yc, max_yc;
+
+	void (*process_pkt) (struct touchkit_usb *touchkit, struct pt_regs *regs, char *pkt, int len);
+	int  (*read_data)   (char *pkt, int *x, int *y, int *touch);
+
+};
+
+/* eGalax specific part */
+#define EGALAX_DOWN			0x01
+#define EGALAX_PKT_TYPE_MASK		0xFE
+#define EGALAX_PKT_TYPE_REPT		0x80
+#define EGALAX_PKT_TYPE_DIAG		0x0A
+
+/* PanJit specific part */
+#define PANJIT_DOWN			0x01
+
+
+/* a touchkit device */
+#define TOUCHKIT_REPORT_DATA_SIZE	16
 struct touchkit_usb {
 	unsigned char *data;
 	dma_addr_t data_dma;
@@ -65,76 +73,106 @@ struct touchkit_usb {
 	struct urb *irq;
 	struct usb_device *udev;
 	struct input_dev *input;
+	struct touchkit_device_info *type;
 	char name[128];
 	char phys[64];
 };
 
+
+enum {
+	DEVTPYE_DUMMY = -1,
+	DEVTYPE_EGALAX,
+	DEVTYPE_PANJIT,
+};
+
 static struct usb_device_id touchkit_devices[] = {
-	{USB_DEVICE(0x3823, 0x0001)},
-	{USB_DEVICE(0x0123, 0x0001)},
-	{USB_DEVICE(0x0eef, 0x0001)},
-	{USB_DEVICE(0x0eef, 0x0002)},
+#ifdef CONFIG_USB_TOUCHKIT_EGALAX
+	/* eGalax devices */
+	{USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX},
+	{USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX},
+	{USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX},
+	{USB_DEVICE(0x0eef, 0x0002), .driver_info = DEVTYPE_EGALAX},
+#endif
+
+#ifdef CONFIG_USB_TOUCHKIT_PANJIT
+	/* PanJit devices */
+	{USB_DEVICE(0x134c, 0x0001), .driver_info = DEVTYPE_PANJIT},
+	{USB_DEVICE(0x134c, 0x0002), .driver_info = DEVTYPE_PANJIT},
+	{USB_DEVICE(0x134c, 0x0003), .driver_info = DEVTYPE_PANJIT},
+	{USB_DEVICE(0x134c, 0x0004), .driver_info = DEVTYPE_PANJIT},
+#endif
+
 	{}
 };
 
-/* helpers to read the data */
-static inline int touchkit_get_touched(char *data)
-{
-	return (data[0] & TOUCHKIT_DOWN) ? 1 : 0;
-}
+/* data readers */
 
-static inline int touchkit_get_x(char *data)
+#ifdef CONFIG_USB_TOUCHKIT_EGALAX
+static int egalax_read_data(char *pkt, int *x, int *y, int *touch)
 {
-	return ((data[3] & 0x0F) << 7) | (data[4] & 0x7F);
+	if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
+		return 0;
+
+	*x = ((pkt[3] & 0x0F) << 7) | (pkt[4] & 0x7F);
+	*y = ((pkt[1] & 0x0F) << 7) | (pkt[2] & 0x7F);
+	*touch = (pkt[0] & EGALAX_DOWN) ? 1 : 0;
+
+	return 1;
+
 }
+#endif
 
-static inline int touchkit_get_y(char *data)
+#ifdef CONFIG_USB_TOUCHKIT_PANJIT
+static int panjit_read_data(char *pkt, int *x, int *y, int *touch)
 {
-	return ((data[1] & 0x0F) << 7) | (data[2] & 0x7F);
-}
+	*x = pkt[1] | (pkt[2] << 8);
+	*y = pkt[3] | (pkt[4] << 8);
+	*touch = (pkt[0] & EGALAX_DOWN) ? 1 : 0;
 
+	return 1;
+}
+#endif
 
-/* processes one input packet. */
+/* processes one input packet. generic */
 static void touchkit_process_pkt(struct touchkit_usb *touchkit,
-                                 struct pt_regs *regs, char *pkt)
+                                 struct pt_regs *regs, char *pkt, int len)
 {
-	int x, y;
+	int x, y, touch;
 
-	/* only process report packets */
-	if ((pkt[0] & TOUCHKIT_PKT_TYPE_MASK) != TOUCHKIT_PKT_TYPE_REPT)
-		return;
+	if (!touchkit->type->read_data(pkt, &x, &y, &touch))
+			return;
+
+	input_regs(touchkit->input, regs);
+	input_report_key(touchkit->input, BTN_TOUCH, touch);
 
 	if (swap_xy) {
-		y = touchkit_get_x(pkt);
-		x = touchkit_get_y(pkt);
+		input_report_abs(touchkit->input, ABS_X, y);
+		input_report_abs(touchkit->input, ABS_Y, x);
 	} else {
-		x = touchkit_get_x(pkt);
-		y = touchkit_get_y(pkt);
+		input_report_abs(touchkit->input, ABS_X, x);
+		input_report_abs(touchkit->input, ABS_Y, y);
 	}
-
-	input_regs(touchkit->input, regs);
-	input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt));
-	input_report_abs(touchkit->input, ABS_X, x);
-	input_report_abs(touchkit->input, ABS_Y, y);
 	input_sync(touchkit->input);
 }
 
 
-static int touchkit_get_pkt_len(char *buf)
+#ifdef CONFIG_USB_TOUCHKIT_EGALAX
+/* eGalax specific packet processing */
+static int egalax_get_pkt_len(char *buf)
 {
-	switch (buf[0] & TOUCHKIT_PKT_TYPE_MASK) {
-	case TOUCHKIT_PKT_TYPE_REPT:
+	switch (buf[0] & EGALAX_PKT_TYPE_MASK) {
+	case EGALAX_PKT_TYPE_REPT:
 		return 5;
 
-	case TOUCHKIT_PKT_TYPE_DIAG:
+	case EGALAX_PKT_TYPE_DIAG:
 		return buf[1] + 2;
 	}
 
 	return 0;
 }
 
-static void touchkit_process(struct touchkit_usb *touchkit, int len,
-                             struct pt_regs *regs)
+static void egalax_process(struct touchkit_usb *touchkit,
+                           struct pt_regs *regs, char *pkt, int len)
 {
 	char *buffer;
 	int pkt_len, buf_len, pos;
@@ -145,9 +183,9 @@ static void touchkit_process(struct touc
 
 		/* if only 1 byte in buffer, add another one to get length */
 		if (touchkit->buf_len == 1)
-			touchkit->buffer[1] = touchkit->data[0];
+			touchkit->buffer[1] = pkt[0];
 
-		pkt_len = touchkit_get_pkt_len(touchkit->buffer);
+		pkt_len = egalax_get_pkt_len(touchkit->buffer);
 
 		/* unknown packet: drop everything */
 		if (!pkt_len)
@@ -155,13 +193,13 @@ static void touchkit_process(struct touc
 
 		/* append, process */
 		tmp = pkt_len - touchkit->buf_len;
-		memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp);
-		touchkit_process_pkt(touchkit, regs, touchkit->buffer);
+		memcpy(touchkit->buffer + touchkit->buf_len, pkt, tmp);
+		touchkit_process_pkt(touchkit, regs, touchkit->buffer, pkt_len);
 
-		buffer = touchkit->data + tmp;
+		buffer = pkt + tmp;
 		buf_len = len - tmp;
 	} else {
-		buffer = touchkit->data;
+		buffer = pkt;
 		buf_len = len;
 	}
 
@@ -176,7 +214,7 @@ static void touchkit_process(struct touc
 	pos = 0;
 	while (pos < buf_len) {
 		/* get packet len */
-		pkt_len = touchkit_get_pkt_len(buffer + pos);
+		pkt_len = egalax_get_pkt_len(buffer + pos);
 
 		/* unknown packet: drop everything */
 		if (unlikely(!pkt_len))
@@ -184,7 +222,7 @@ static void touchkit_process(struct touc
 
 		/* full packet: process */
 		if (likely(pkt_len <= buf_len)) {
-			touchkit_process_pkt(touchkit, regs, buffer + pos);
+			touchkit_process_pkt(touchkit, regs, buffer + pos, pkt_len);
 		} else {
 			/* incomplete packet: save in buffer */
 			memcpy(touchkit->buffer, buffer + pos, buf_len - pos);
@@ -193,6 +231,7 @@ static void touchkit_process(struct touc
 		pos += pkt_len;
 	}
 }
+#endif
 
 
 static void touchkit_irq(struct urb *urb, struct pt_regs *regs)
@@ -222,7 +261,7 @@ static void touchkit_irq(struct urb *urb
 		goto exit;
 	}
 
-	touchkit_process(touchkit, urb->actual_length, regs);
+	touchkit->type->process_pkt(touchkit, regs, touchkit->data, urb->actual_length);
 
 exit:
 	retval = usb_submit_urb(urb, GFP_ATOMIC);
@@ -237,7 +276,7 @@ static int touchkit_open(struct input_de
 
 	touchkit->irq->dev = touchkit->udev;
 
-	if (usb_submit_urb(touchkit->irq, GFP_ATOMIC))
+	if (usb_submit_urb(touchkit->irq, GFP_KERNEL))
 		return -EIO;
 
 	return 0;
@@ -254,7 +293,7 @@ static int touchkit_alloc_buffers(struct
 				  struct touchkit_usb *touchkit)
 {
 	touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
-	                                  SLAB_ATOMIC, &touchkit->data_dma);
+	                                  SLAB_KERNEL, &touchkit->data_dma);
 
 	if (!touchkit->data)
 		return -1;
@@ -270,6 +309,35 @@ static void touchkit_free_buffers(struct
 		                touchkit->data, touchkit->data_dma);
 }
 
+
+/* the different device descriptors */
+static struct touchkit_device_info touchkit_dev_info[] = {
+#ifdef CONFIG_USB_TOUCHKIT_EGALAX
+	[DEVTYPE_EGALAX] = {
+		.min_xc	= 0x0,
+		.max_xc = 0x07ff,
+		.min_yc = 0x0,
+		.max_yc = 0x07ff,
+
+		.process_pkt = egalax_process,
+		.read_data   = egalax_read_data,
+	},
+#endif
+
+#ifdef CONFIG_USB_TOUCHKIT_PANJIT
+	[DEVTYPE_PANJIT] = {
+		.min_xc	= 0x0,
+		.max_xc = 0x0fff,
+		.min_yc = 0x0,
+		.max_yc = 0x0fff,
+
+		.process_pkt = touchkit_process_pkt,
+		.read_data   = panjit_read_data,
+	},
+#endif
+};
+
+
 static int touchkit_probe(struct usb_interface *intf,
 			  const struct usb_device_id *id)
 {
@@ -298,6 +366,7 @@ static int touchkit_probe(struct usb_int
 
 	touchkit->udev = udev;
 	touchkit->input = input_dev;
+	touchkit->type = &touchkit_dev_info[id->driver_info];
 
 	if (udev->manufacturer)
 		strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name));
@@ -327,10 +396,8 @@ static int touchkit_probe(struct usb_int
 
 	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, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC,
-				TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT);
-	input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC,
-				TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT);
+	input_set_abs_params(input_dev, ABS_X, touchkit->type->min_xc, touchkit->type->max_xc, 0, 0);
+	input_set_abs_params(input_dev, ABS_Y, touchkit->type->min_yc, touchkit->type->max_yc, 0, 0);
 
 	usb_fill_int_urb(touchkit->irq, touchkit->udev,
 			 usb_rcvintpipe(touchkit->udev, 0x81),
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 07a012f..2155513 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1460,6 +1460,12 @@ 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_TOUCHSET		0x134c
+#define USB_DEVICE_ID_TOUCHSET_INITIAL	0x0001
+#define USB_DEVICE_ID_TOUCHSET_JUNIOR	0x0002
+#define USB_DEVICE_ID_TOUCHSET_TRIAD	0x0003
+#define USB_DEVICE_ID_TOUCHSET_QUATA	0x0004
+
 /*
  * Alphabetically sorted blacklist by quirk type.
  */
@@ -1605,6 +1611,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_TOUCHSET, USB_DEVICE_ID_TOUCHSET_INITIAL, HID_QUIRK_BADPAD },
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET_JUNIOR, HID_QUIRK_BADPAD },
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET_TRIAD, HID_QUIRK_BADPAD },
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET_QUATA, HID_QUIRK_BADPAD },
+
 	{ 0, 0 }
 };
 


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

* Re: [linux-usb-devel] Re: [PATCH] add support for PANJIT TouchSet USB Touchscreen Device
  2006-03-08 22:46 [PATCH] add support for PANJIT TouchSet USB Touchscreen Device Daniel Ritz
@ 2006-03-09  0:43 ` Greg KH
  2006-03-10  1:15   ` Lanslott Gish
  2006-03-09  9:25 ` Re: [PATCH] add support for " lanslott.gish
  1 sibling, 1 reply; 8+ messages in thread
From: Greg KH @ 2006-03-09  0:43 UTC (permalink / raw)
  To: Daniel Ritz
  Cc: Lanslott Gish, Dmitry Torokhov, linux-kernel, linux-usb, Daniel Ritz

On Wed, Mar 08, 2006 at 11:46:36PM +0100, Daniel Ritz wrote:
> > And what about merging with the existing driver?
> 
> something like this? it's compile tested only. not even tested
> on an egalax screen since i don't have it around...
> if this is ok, we could also merge itmtouch and mtouchusb into a
> single driver.

Looks ok to me.  Would be nice to get a verification from someone who
has the device :)

thanks,

greg k-h

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

* Re: Re: [PATCH] add support for TouchSet USB Touchscreen Device
  2006-03-08 22:46 [PATCH] add support for PANJIT TouchSet USB Touchscreen Device Daniel Ritz
  2006-03-09  0:43 ` [linux-usb-devel] " Greg KH
@ 2006-03-09  9:25 ` lanslott.gish
  1 sibling, 0 replies; 8+ messages in thread
From: lanslott.gish @ 2006-03-09  9:25 UTC (permalink / raw)
  To: linux-kernel

Hi, 

repost the patch.

thx for all.


Lanslot Gish


=====================================================================
diff -u -N linux-2.6.16-rc5/drivers/usb/input/hid-core.c linux-2.6.16-rc5.modi/drivers/usb/input/hid-core.c
--- linux-2.6.16-rc5/drivers/usb/input/hid-core.c	2006-02-27 13:09:35.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/input/hid-core.c	2006-03-02 10:20:36.000000000 +0800
@@ -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.
  */
@@ -1603,6 +1609,11 @@
 	{ 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 }
 };
 
diff -u -N linux-2.6.16-rc5/drivers/usb/input/Kconfig linux-2.6.16-rc5.modi/drivers/usb/input/Kconfig
--- linux-2.6.16-rc5/drivers/usb/input/Kconfig	2006-02-27 13:09:35.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/input/Kconfig	2006-03-08 10:28:33.686019096 +0800
@@ -330,3 +330,16 @@
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called appletouch.
+
+config USB_TOUCHSET
+	tristate "TouchSet USB Device Driver"
+	depends on USB && INPUT
+	---help---
+	  Say Y here if you want to use a TouchSet 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.
diff -u -N linux-2.6.16-rc5/drivers/usb/input/Makefile linux-2.6.16-rc5.modi/drivers/usb/input/Makefile
--- linux-2.6.16-rc5/drivers/usb/input/Makefile	2006-02-27 13:09:35.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/input/Makefile	2006-03-08 10:27:29.188824160 +0800
@@ -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_TOUCHSET)	+= usbtouchset.o
 
 ifeq ($(CONFIG_USB_DEBUG),y)
 EXTRA_CFLAGS += -DDEBUG
diff -u -N linux-2.6.16-rc5/drivers/usb/input/usbtouchset.c linux-2.6.16-rc5.modi/drivers/usb/input/usbtouchset.c
--- linux-2.6.16-rc5/drivers/usb/input/usbtouchset.c	1970-01-01 08:00:00.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/input/usbtouchset.c	2006-03-07 11:43:18.000000000 +0800
@@ -0,0 +1,303 @@
+/******************************************************************************
+ * usbtouchset.c  --  Driver for TouchSet USB Device
+ *
+ * Copyright (C) 2004 by Daniel Ritz
+ * Copyright (C) 2006 by Lanslott Gish
+ * Copyright (C) by Todd E. Johnson (mtouchusb.c)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Based upon mtouchusb.c
+ *
+ *****************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+#include <linux/usb_input.h>
+
+#define TOUCHSET_MIN_XC			0x0
+#define TOUCHSET_MAX_XC			0x0fff
+#define TOUCHSET_XC_FUZZ		0x0
+#define TOUCHSET_XC_FLAT		0x0
+#define TOUCHSET_MIN_YC			0x0
+#define TOUCHSET_MAX_YC			0x0fff
+#define TOUCHSET_YC_FUZZ		0x0
+#define TOUCHSET_YC_FLAT		0x0
+#define TOUCHSET_REPORT_DATA_SIZE	8
+
+#define TOUCHSET_DOWN			0x01
+#define TOUCHSET_POINT_TOUCH		0x81
+#define TOUCHSET_POINT_NOTOUCH		0x80
+
+#define DRIVER_VERSION			"0.2"
+#define DRIVER_AUTHOR			"Lanslott Gish <lanslott.gish@gmail.com>"
+#define DRIVER_DESC			"TouchSet USB Device"
+
+static int swap_xy;
+module_param(swap_xy, bool, 0644);
+MODULE_PARM_DESC(swap_xy, "Swap X and Y axes.");
+
+
+struct usb_touchset {
+	unsigned char *data;
+	dma_addr_t data_dma;
+	struct urb *irq;
+	struct usb_device *udev;
+	struct input_dev *input;
+	char name[128];
+	char phys[64];
+};
+
+static struct usb_device_id usbtouchset_devices[] = {
+	{USB_DEVICE(0x134c, 0x0001)},
+	{USB_DEVICE(0x134c, 0x0002)},
+	{USB_DEVICE(0x134c, 0x0003)},
+	{USB_DEVICE(0x134c, 0x0004)},
+	{}
+};
+
+static inline int usbtouchset_get_touched(char *data)
+{
+	return ((((data)[0]) & TOUCHSET_DOWN) ? 1 : 0);
+}
+
+static inline int usbtouchset_get_x(char *data)
+{
+	return ((data)[1] | ((data)[2] << 8));
+}
+
+static inline int usbtouchset_get_y(char *data)
+{
+	return ((data)[3] | ((data)[4] << 8));
+}
+
+static void usbtouchset_irq(struct urb *urb, struct pt_regs *regs)
+{
+	struct usb_touchset *touchset = urb->context;
+	int retval;
+	int x, y;
+
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ETIMEDOUT:
+		/* this urb is timing out */
+		dbg("%s - urb timed out - was the device unplugged?",
+		    __FUNCTION__);
+		return;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		/* this urb is terminated, clean up */
+		dbg("%s - urb shutting down with status: %d",
+		    __FUNCTION__, urb->status);
+		return;
+	default:
+		dbg("%s - nonzero urb status received: %d",
+		    __FUNCTION__, urb->status);
+		goto exit;
+	}
+
+	if (swap_xy) {
+		y = usbtouchset_get_x(touchset->data);
+		x = usbtouchset_get_y(touchset->data);
+	} else {
+		x = usbtouchset_get_x(touchset->data);
+		y = usbtouchset_get_y(touchset->data);
+	}
+
+	input_regs(touchset->input, regs);
+	input_report_key(touchset->input, BTN_TOUCH,
+	                 usbtouchset_get_touched(touchset->data));
+	input_report_abs(touchset->input, ABS_X, x);
+	input_report_abs(touchset->input, ABS_Y, y);
+	input_sync(touchset->input);
+
+exit:
+	retval = usb_submit_urb(urb, GFP_ATOMIC);
+	if (retval)
+		err("%s - usb_submit_urb failed with result: %d",
+		    __FUNCTION__, retval);
+}
+
+static int usbtouchset_open(struct input_dev *input)
+{
+	struct usb_touchset *touchset = input->private;
+
+	touchset->irq->dev = touchset->udev;
+
+	if (usb_submit_urb(touchset->irq, GFP_KERNEL))
+		return -EIO;
+
+	return 0;
+}
+
+static void usbtouchset_close(struct input_dev *input)
+{
+	struct usb_touchset *touchset = input->private;
+
+	usb_kill_urb(touchset->irq);
+}
+
+static int usbtouchset_alloc_buffers(struct usb_device *udev,
+				  struct usb_touchset *touchset)
+{
+	touchset->data = usb_buffer_alloc(udev, TOUCHSET_REPORT_DATA_SIZE,
+	                                  SLAB_KERNEL, &touchset->data_dma);
+
+	if (!touchset->data)
+		return -1;
+
+	return 0;
+}
+
+static void usbtouchset_free_buffers(struct usb_device *udev,
+				  struct usb_touchset *touchset)
+{
+	if (touchset->data)
+		usb_buffer_free(udev, TOUCHSET_REPORT_DATA_SIZE,
+		                touchset->data, touchset->data_dma);
+}
+
+static int usbtouchset_probe(struct usb_interface *intf,
+			  const struct usb_device_id *id)
+{
+	struct usb_touchset *touchset;
+	struct input_dev *input_dev;
+	struct usb_host_interface *interface;
+	struct usb_endpoint_descriptor *endpoint;
+	struct usb_device *udev = interface_to_usbdev(intf);
+
+	interface = intf->cur_altsetting;
+	endpoint = &interface->endpoint[0].desc;
+
+	touchset = kzalloc(sizeof(struct usb_touchset), GFP_KERNEL);
+	input_dev = input_allocate_device();
+	if (!touchset || !input_dev)
+		goto out_free;
+
+	if (usbtouchset_alloc_buffers(udev, touchset))
+		goto out_free;
+
+	touchset->irq = usb_alloc_urb(0, GFP_KERNEL);
+	if (!touchset->irq) {
+		dbg("%s - usb_alloc_urb failed: touchset->irq", __FUNCTION__);
+		goto out_free_buffers;
+	}
+
+	touchset->udev = udev;
+	touchset->input = input_dev;
+
+	if (udev->manufacturer)
+		strlcpy(touchset->name, udev->manufacturer, sizeof(touchset->name));
+
+	if (udev->product) {
+		if (udev->manufacturer)
+			strlcat(touchset->name, " ", sizeof(touchset->name));
+		strlcat(touchset->name, udev->product, sizeof(touchset->name));
+	}
+
+	if (!strlen(touchset->name))
+		snprintf(touchset->name, sizeof(touchset->name),
+			"USB Device %04x:%04x",
+			 le16_to_cpu(udev->descriptor.idVendor),
+			 le16_to_cpu(udev->descriptor.idProduct));
+
+	usb_make_path(udev, touchset->phys, sizeof(touchset->phys));
+	strlcpy(touchset->phys, "/input0", sizeof(touchset->phys));
+
+	input_dev->name = touchset->name;
+	input_dev->phys = touchset->phys;
+	usb_to_input_id(udev, &input_dev->id);
+	input_dev->cdev.dev = &intf->dev;
+	input_dev->private = touchset;
+	input_dev->open = usbtouchset_open;
+	input_dev->close = usbtouchset_close;
+
+	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, TOUCHSET_MIN_XC, TOUCHSET_MAX_XC,
+				TOUCHSET_XC_FUZZ, TOUCHSET_XC_FLAT);
+	input_set_abs_params(input_dev, ABS_Y, TOUCHSET_MIN_YC, TOUCHSET_MAX_YC,
+				TOUCHSET_YC_FUZZ, TOUCHSET_YC_FLAT);
+
+	usb_fill_int_urb(touchset->irq, touchset->udev,
+			 usb_rcvintpipe(touchset->udev, 0x81),
+			 touchset->data, TOUCHSET_REPORT_DATA_SIZE,
+			 usbtouchset_irq, touchset, endpoint->bInterval);
+
+	input_register_device(touchset->input);
+
+	usb_set_intfdata(intf, touchset);
+	return 0;
+
+out_free_buffers:
+	usbtouchset_free_buffers(udev, touchset);
+out_free:
+	input_free_device(input_dev);
+	kfree(touchset);
+	return -ENOMEM;
+}
+
+static void usbtouchset_disconnect(struct usb_interface *intf)
+{
+	struct usb_touchset *touchset = usb_get_intfdata(intf);
+
+	dbg("%s - called", __FUNCTION__);
+
+	if (!touchset)
+		return;
+
+	dbg("%s - touchset is initialized, cleaning up", __FUNCTION__);
+	usb_set_intfdata(intf, NULL);
+	usb_kill_urb(touchset->irq);
+	input_unregister_device(touchset->input);
+	usb_free_urb(touchset->irq);
+	usbtouchset_free_buffers(interface_to_usbdev(intf), touchset);
+	kfree(touchset);
+}
+
+MODULE_DEVICE_TABLE(usb, usbtouchset_devices);
+
+static struct usb_driver usbtouchset_driver = {
+	.name		= "usbtouchset",
+	.probe		= usbtouchset_probe,
+	.disconnect	= usbtouchset_disconnect,
+	.id_table	= usbtouchset_devices,
+};
+
+static int __init usbtouchset_init(void)
+{
+	return usb_register(&usbtouchset_driver);
+}
+
+static void __exit usbtouchset_cleanup(void)
+{
+	usb_deregister(&usbtouchset_driver);
+}
+
+module_init(usbtouchset_init);
+module_exit(usbtouchset_cleanup);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");

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

--
This message was sent on behalf of lanslott.gish@gmail.com at openSubscriber.com
http://www.opensubscriber.com/message/linux-kernel@vger.kernel.org/3535239.html

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

* Re: [linux-usb-devel] Re: [PATCH] add support for PANJIT TouchSet USB Touchscreen Device
  2006-03-09  0:43 ` [linux-usb-devel] " Greg KH
@ 2006-03-10  1:15   ` Lanslott Gish
  2006-03-10  1:30     ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Lanslott Gish @ 2006-03-10  1:15 UTC (permalink / raw)
  To: Greg KH
  Cc: Daniel Ritz, Dmitry Torokhov, linux-kernel, linux-usb, Daniel Ritz

Hi,

merging is the wonderful way. i love all in one :))

but, every vendor has their own USB Vendor ID.
How to overcome the issue?

Lanslott Gish



On 3/9/06, Greg KH <greg@kroah.com> wrote:
> On Wed, Mar 08, 2006 at 11:46:36PM +0100, Daniel Ritz wrote:
> > > And what about merging with the existing driver?
> >
> > something like this? it's compile tested only. not even tested
> > on an egalax screen since i don't have it around...
> > if this is ok, we could also merge itmtouch and mtouchusb into a
> > single driver.
>
> Looks ok to me.  Would be nice to get a verification from someone who
> has the device :)
>
> thanks,
>
> greg k-h
>



--
L.G, Life's Good~

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

* Re: [linux-usb-devel] Re: [PATCH] add support for PANJIT TouchSet USB Touchscreen Device
  2006-03-10  1:15   ` Lanslott Gish
@ 2006-03-10  1:30     ` Greg KH
  2006-03-10  2:26       ` Lanslott Gish
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2006-03-10  1:30 UTC (permalink / raw)
  To: Lanslott Gish
  Cc: Daniel Ritz, Dmitry Torokhov, linux-kernel, linux-usb, Daniel Ritz

On Fri, Mar 10, 2006 at 09:15:28AM +0800, Lanslott Gish wrote:
> Hi,
> 
> merging is the wonderful way. i love all in one :))
> 
> but, every vendor has their own USB Vendor ID.
> How to overcome the issue?

Keep adding them to the device table?  Just like other drivers that
support more than one type of device :)

thanks,

greg k-h

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

* Re: [linux-usb-devel] Re: [PATCH] add support for PANJIT TouchSet USB Touchscreen Device
  2006-03-10  1:30     ` Greg KH
@ 2006-03-10  2:26       ` Lanslott Gish
  0 siblings, 0 replies; 8+ messages in thread
From: Lanslott Gish @ 2006-03-10  2:26 UTC (permalink / raw)
  To: Greg KH
  Cc: Daniel Ritz, Dmitry Torokhov, linux-kernel, linux-usb, Daniel Ritz

look great!
i got the TouchSet usb hardware and could help to test about this.

Lanslott Gish

On 3/10/06, Greg KH <greg@kroah.com> wrote:
> On Fri, Mar 10, 2006 at 09:15:28AM +0800, Lanslott Gish wrote:
> > Hi,
> >
> > merging is the wonderful way. i love all in one :))
> >
> > but, every vendor has their own USB Vendor ID.
> > How to overcome the issue?
>
> Keep adding them to the device table?  Just like other drivers that
> support more than one type of device :)
>
> thanks,
>
> greg k-h
>


--
L.G, Life's Good~

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

* Re: [PATCH] add support for PANJIT TouchSet USB Touchscreen Device
  2006-03-06  9:14 [PATCH] add support for PANJIT " Lanslott Gish
@ 2006-03-07  3:08 ` Dmitry Torokhov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2006-03-07  3:08 UTC (permalink / raw)
  To: Lanslott Gish
  Cc: linux-kernel, linux-usb-devel, Greg KH, Linus Torvalds, Alan Cox

On Monday 06 March 2006 04:14, Lanslott Gish wrote:
> hi,
> 
> this is the first version of the patch from a newbie :)
> add support for PANJIT TouchSet USB touchscreen device.
>

Hi,

I am reading this and it looks like twin brother of touchkitusb.c
Is there any chance we can combine these together?

-- 
Dmitry

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

* [PATCH] add support for PANJIT TouchSet USB Touchscreen Device
@ 2006-03-06  9:14 Lanslott Gish
  2006-03-07  3:08 ` Dmitry Torokhov
  0 siblings, 1 reply; 8+ messages in thread
From: Lanslott Gish @ 2006-03-06  9:14 UTC (permalink / raw)
  To: linux-kernel, linux-usb-devel, Greg KH; +Cc: Linus Torvalds, Alan Cox

hi,

this is the first version of the patch from a newbie :)
add support for PANJIT TouchSet USB touchscreen device.

patch for kernel 2.6.16-rc5.
thx for anyone see this, and feel free to apply it :)

Best Regards,

victima


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


diff -u -r -N linux-2.6.16-rc5/drivers/usb/input/hid-core.c
linux-2.6.16-rc5.modi/drivers/usb/input/hid-core.c
--- linux-2.6.16-rc5/drivers/usb/input/hid-core.c	2006-02-27
13:09:35.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/input/hid-core.c	2006-03-02
10:20:36.000000000 +0800
@@ -1459,6 +1459,12 @@
 #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_INITIAL	0x0001
+#define USB_DEVICE_ID_TOUCHSET_JUNIOR	0x0002
+#define USB_DEVICE_ID_TOUCHSET_TRIAD	0x0003
+#define USB_DEVICE_ID_TOUCHSET_QUATA	0x0004
+
 /*
  * Alphabetically sorted blacklist by quirk type.
  */
@@ -1603,6 +1609,11 @@
 	{ 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_INITIAL, HID_QUIRK_BADPAD },
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET_JUNIOR, HID_QUIRK_BADPAD },
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET_TRIAD, HID_QUIRK_BADPAD },
+	{ USB_VENDOR_ID_TOUCHSET, USB_DEVICE_ID_TOUCHSET_QUATA, HID_QUIRK_BADPAD },
+
 	{ 0, 0 }
 };

diff -u -r -N linux-2.6.16-rc5/drivers/usb/input/Kconfig
linux-2.6.16-rc5.modi/drivers/usb/input/Kconfig
--- linux-2.6.16-rc5/drivers/usb/input/Kconfig	2006-02-27
13:09:35.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/input/Kconfig	2006-03-02
09:48:38.000000000 +0800
@@ -224,6 +224,19 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called itmtouch.

+config USB_TOUCHSET
+	tristate "TouchSet USB Device Driver"
+	depends on USB && INPUT
+	---help---
+	  Say Y here if you want to use a TouchSet 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 touchsetusb.
+
 config USB_EGALAX
 	tristate "eGalax TouchKit USB Touchscreen Driver"
 	depends on USB && INPUT
diff -u -r -N linux-2.6.16-rc5/drivers/usb/input/Makefile
linux-2.6.16-rc5.modi/drivers/usb/input/Makefile
--- linux-2.6.16-rc5/drivers/usb/input/Makefile	2006-02-27
13:09:35.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/input/Makefile	2006-03-02
10:20:36.000000000 +0800
@@ -36,6 +36,7 @@
 obj-$(CONFIG_USB_MOUSE)		+= usbmouse.o
 obj-$(CONFIG_USB_MTOUCH)	+= mtouchusb.o
 obj-$(CONFIG_USB_ITMTOUCH)	+= itmtouch.o
+obj-$(CONFIG_USB_TOUCHSET)	+= touchsetusb.o
 obj-$(CONFIG_USB_EGALAX)	+= touchkitusb.o
 obj-$(CONFIG_USB_POWERMATE)	+= powermate.o
 obj-$(CONFIG_USB_WACOM)		+= wacom.o
diff -u -r -N linux-2.6.16-rc5/drivers/usb/input/touchsetusb.c
linux-2.6.16-rc5.modi/drivers/usb/input/touchsetusb.c
--- linux-2.6.16-rc5/drivers/usb/input/touchsetusb.c	1970-01-01
08:00:00.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/input/touchsetusb.c	2006-03-02
10:20:36.000000000 +0800
@@ -0,0 +1,294 @@
+/******************************************************************************
+ * touchsetusb.c  --  Driver for TouchSet USB Device
+ *
+ * Copyright (C) 2006 by Victima Gish
+ * Copyright (C) by Todd E. Johnson (mtouchusb.c)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Based upon mtouchusb.c
+ *
+ *****************************************************************************/
+
+//#define DEBUG
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/usb.h>
+#include <linux/usb_input.h>
+
+#define TOUCHSET_MIN_XC			0x0
+#define TOUCHSET_MAX_XC			0x0fff
+#define TOUCHSET_XC_FUZZ		0x0
+#define TOUCHSET_XC_FLAT		0x0
+#define TOUCHSET_MIN_YC			0x0
+#define TOUCHSET_MAX_YC			0x0fff
+#define TOUCHSET_YC_FUZZ		0x0
+#define TOUCHSET_YC_FLAT		0x0
+#define TOUCHSET_REPORT_DATA_SIZE	8
+
+#define TOUCHSET_DOWN			0x01
+#define TOUCHSET_POINT_TOUCH		0x81
+#define TOUCHSET_POINT_NOTOUCH		0x80
+
+#define TOUCHSET_GET_TOUCHED(dat)	((((dat)[0]) & TOUCHSET_DOWN) ? 1 : 0)
+#define TOUCHSET_GET_X(dat)		((dat)[1] | ((dat)[2] << 8))
+#define TOUCHSET_GET_Y(dat)		((dat)[3] | ((dat)[4] << 8))
+
+#define DRIVER_VERSION			"0.1"
+#define DRIVER_AUTHOR			"Victima Gish <victima.gish@gmail.com>"
+#define DRIVER_DESC			"TouchSet USB Device"
+
+static int swap_xy;
+static int _x;
+static int _y;
+module_param(swap_xy, bool, 0644);
+MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
+
+struct touchset_usb {
+	unsigned char *data;
+	dma_addr_t data_dma;
+	struct urb *irq;
+	struct usb_device *udev;
+	struct input_dev *input;
+	char name[128];
+	char phys[64];
+};
+
+static struct usb_device_id touchset_devices[] = {
+	{USB_DEVICE(0x134c, 0x0001)},
+	{USB_DEVICE(0x134c, 0x0002)},
+	{USB_DEVICE(0x134c, 0x0003)},
+	{USB_DEVICE(0x134c, 0x0004)},
+	{}
+};
+
+static void touchset_irq(struct urb *urb, struct pt_regs *regs)
+{
+	struct touchset_usb *touchset = urb->context;
+	int retval;
+	int x, y;
+
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ETIMEDOUT:
+		/* this urb is timing out */
+		dbg("%s - urb timed out - was the device unplugged?",
+		    __FUNCTION__);
+		return;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		/* this urb is terminated, clean up */
+		dbg("%s - urb shutting down with status: %d",
+		    __FUNCTION__, urb->status);
+		return;
+	default:
+		dbg("%s - nonzero urb status received: %d",
+		    __FUNCTION__, urb->status);
+		goto exit;
+	}
+
+	if (swap_xy) {
+		y = TOUCHSET_GET_X(touchset->data);
+		x = TOUCHSET_GET_Y(touchset->data);
+	} else {
+		x = TOUCHSET_GET_X(touchset->data);
+		y = TOUCHSET_GET_Y(touchset->data);
+	}
+
+	input_regs(touchset->input, regs);
+	input_report_key(touchset->input, BTN_TOUCH,
+	                 TOUCHSET_GET_TOUCHED(touchset->data));
+	input_report_abs(touchset->input, ABS_X, x);
+	input_report_abs(touchset->input, ABS_Y, y);
+	input_sync(touchset->input);
+
+exit:
+	retval = usb_submit_urb(urb, GFP_ATOMIC);
+	if (retval)
+		err("%s - usb_submit_urb failed with result: %d",
+		    __FUNCTION__, retval);
+}
+
+static int touchset_open(struct input_dev *input)
+{
+	struct touchset_usb *touchset = input->private;
+
+	touchset->irq->dev = touchset->udev;
+
+	if (usb_submit_urb(touchset->irq, GFP_ATOMIC))
+		return -EIO;
+
+	return 0;
+}
+
+static void touchset_close(struct input_dev *input)
+{
+	struct touchset_usb *touchset = input->private;
+
+	usb_kill_urb(touchset->irq);
+}
+
+static int touchset_alloc_buffers(struct usb_device *udev,
+				  struct touchset_usb *touchset)
+{
+	touchset->data = usb_buffer_alloc(udev, TOUCHSET_REPORT_DATA_SIZE,
+	                                  SLAB_ATOMIC, &touchset->data_dma);
+
+	if (!touchset->data)
+		return -1;
+
+	return 0;
+}
+
+static void touchset_free_buffers(struct usb_device *udev,
+				  struct touchset_usb *touchset)
+{
+	if (touchset->data)
+		usb_buffer_free(udev, TOUCHSET_REPORT_DATA_SIZE,
+		                touchset->data, touchset->data_dma);
+}
+
+static int touchset_probe(struct usb_interface *intf,
+			  const struct usb_device_id *id)
+{
+	struct touchset_usb *touchset;
+	struct input_dev *input_dev;
+	struct usb_host_interface *interface;
+	struct usb_endpoint_descriptor *endpoint;
+	struct usb_device *udev = interface_to_usbdev(intf);
+
+	interface = intf->cur_altsetting;
+	endpoint = &interface->endpoint[0].desc;
+
+	touchset = kzalloc(sizeof(struct touchset_usb), GFP_KERNEL);
+	input_dev = input_allocate_device();
+	if (!touchset || !input_dev)
+		goto out_free;
+
+	if (touchset_alloc_buffers(udev, touchset))
+		goto out_free;
+
+	touchset->irq = usb_alloc_urb(0, GFP_KERNEL);
+	if (!touchset->irq) {
+		dbg("%s - usb_alloc_urb failed: touchset->irq", __FUNCTION__);
+		goto out_free_buffers;
+	}
+
+	touchset->udev = udev;
+	touchset->input = input_dev;
+
+	if (udev->manufacturer)
+		strlcpy(touchset->name, udev->manufacturer, sizeof(touchset->name));
+
+	if (udev->product) {
+		if (udev->manufacturer)
+			strlcat(touchset->name, " ", sizeof(touchset->name));
+		strlcat(touchset->name, udev->product, sizeof(touchset->name));
+	}
+
+	if (!strlen(touchset->name))
+		snprintf(touchset->name, sizeof(touchset->name),
+			"USB Device %04x:%04x",
+			 le16_to_cpu(udev->descriptor.idVendor),
+			 le16_to_cpu(udev->descriptor.idProduct));
+
+	usb_make_path(udev, touchset->phys, sizeof(touchset->phys));
+	strlcpy(touchset->phys, "/input0", sizeof(touchset->phys));
+
+	input_dev->name = touchset->name;
+	input_dev->phys = touchset->phys;
+	usb_to_input_id(udev, &input_dev->id);
+	input_dev->cdev.dev = &intf->dev;
+	input_dev->private = touchset;
+	input_dev->open = touchset_open;
+	input_dev->close = touchset_close;
+
+	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, TOUCHSET_MIN_XC, TOUCHSET_MAX_XC,
+				TOUCHSET_XC_FUZZ, TOUCHSET_XC_FLAT);
+	input_set_abs_params(input_dev, ABS_Y, TOUCHSET_MIN_YC, TOUCHSET_MAX_YC,
+				TOUCHSET_YC_FUZZ, TOUCHSET_YC_FLAT);
+
+	usb_fill_int_urb(touchset->irq, touchset->udev,
+			 usb_rcvintpipe(touchset->udev, 0x81),
+			 touchset->data, TOUCHSET_REPORT_DATA_SIZE,
+			 touchset_irq, touchset, endpoint->bInterval);
+
+	touchset->irq->transfer_dma = touchset->data_dma;
+	touchset->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+
+	input_register_device(touchset->input);
+
+	usb_set_intfdata(intf, touchset);
+	return 0;
+
+out_free_buffers:
+	touchset_free_buffers(udev, touchset);
+out_free:
+	input_free_device(input_dev);
+	kfree(touchset);
+	return -ENOMEM;
+}
+
+static void touchset_disconnect(struct usb_interface *intf)
+{
+	struct touchset_usb *touchset = usb_get_intfdata(intf);
+
+	dbg("%s - called", __FUNCTION__);
+
+	if (!touchset)
+		return;
+
+	dbg("%s - touchset is initialized, cleaning up", __FUNCTION__);
+	usb_set_intfdata(intf, NULL);
+	usb_kill_urb(touchset->irq);
+	input_unregister_device(touchset->input);
+	usb_free_urb(touchset->irq);
+	touchset_free_buffers(interface_to_usbdev(intf), touchset);
+	kfree(touchset);
+}
+
+MODULE_DEVICE_TABLE(usb, touchset_devices);
+
+static struct usb_driver touchset_driver = {
+	.name		= "touchsetusb",
+	.probe		= touchset_probe,
+	.disconnect	= touchset_disconnect,
+	.id_table	= touchset_devices,
+};
+
+static int __init touchset_init(void)
+{
+	return usb_register(&touchset_driver);
+}
+
+static void __exit touchset_cleanup(void)
+{
+	usb_deregister(&touchset_driver);
+}
+
+module_init(touchset_init);
+module_exit(touchset_cleanup);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
diff -u -r -N linux-2.6.16-rc5/drivers/usb/Makefile
linux-2.6.16-rc5.modi/drivers/usb/Makefile
--- linux-2.6.16-rc5/drivers/usb/Makefile	2006-02-27 13:09:35.000000000 +0800
+++ linux-2.6.16-rc5.modi/drivers/usb/Makefile	2006-03-02
10:11:39.000000000 +0800
@@ -31,6 +31,7 @@
 obj-$(CONFIG_USB_KBTAB)		+= input/
 obj-$(CONFIG_USB_MOUSE)		+= input/
 obj-$(CONFIG_USB_MTOUCH)	+= input/
+obj-$(CONFIG_USB_TOUCHSET)	+= input/
 obj-$(CONFIG_USB_POWERMATE)	+= input/
 obj-$(CONFIG_USB_WACOM)		+= input/
 obj-$(CONFIG_USB_ACECAD)	+= input/





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





--
~

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

end of thread, other threads:[~2006-03-10  2:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-08 22:46 [PATCH] add support for PANJIT TouchSet USB Touchscreen Device Daniel Ritz
2006-03-09  0:43 ` [linux-usb-devel] " Greg KH
2006-03-10  1:15   ` Lanslott Gish
2006-03-10  1:30     ` Greg KH
2006-03-10  2:26       ` Lanslott Gish
2006-03-09  9:25 ` Re: [PATCH] add support for " lanslott.gish
  -- strict thread matches above, loose matches on Subject: below --
2006-03-06  9:14 [PATCH] add support for PANJIT " Lanslott Gish
2006-03-07  3:08 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).