All of lore.kernel.org
 help / color / mirror / Atom feed
From: linuxsea@163.com
To: dmitry.torokhov@gmail.com, nick.dyer@itdev.co.uk, bleung@chromium.org
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxsea@163.com
Subject: [PATCH] Add driver for CJTouch touchscreen
Date: Sun, 14 Jun 2015 09:22:23 -0700	[thread overview]
Message-ID: <1434298943-4961-1-git-send-email-linuxsea@163.com> (raw)

From: linuxsea <linuxsea@163.com>

Signed-off-by: linuxsea <linuxsea@163.com>
---
 drivers/input/touchscreen/Kconfig          |   12 +++
 drivers/input/touchscreen/usbtouchscreen.c |  116 ++++++++++++++++++++++++++++
 2 files changed, 128 insertions(+)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 80f6386..958297b 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -767,6 +767,8 @@ config TOUCHSCREEN_USB_COMPOSITE
 	  - Elo TouchSystems 2700 IntelliTouch
 	  - EasyTouch USB Touch Controller from Data Modul
 	  - e2i (Mimo monitors)
+	  - CJTouch
+	  - CJMTouch
 
 	  Have a look at <http://linux.chapter7.ch/touchkit/> for
 	  a usage description and the required user-space stuff.
@@ -826,6 +828,16 @@ config TOUCHSCREEN_USB_IRTOUCH
 	bool "IRTOUCHSYSTEMS/UNITOP device support" if EXPERT
 	depends on TOUCHSCREEN_USB_COMPOSITE
 
+config TOUCHSCREEN_USB_CJTOUCH
+	default y
+	bool "CJTOUCH Single Touch Touchscreen device support" if EXPERT
+	depends on TOUCHSCREEN_USB_COMPOSITE
+
+config TOUCHSCREEN_USB_CJMTOUCH
+	default y
+	bool "CJTOUCH Multi Touch Touchscreen  device support" if EXPERT
+	depends on TOUCHSCREEN_USB_COMPOSITE
+
 config TOUCHSCREEN_USB_IDEALTEK
 	default y
 	bool "IdealTEK URTC1000 device support" if EXPERT
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index f2c6c35..e2908db 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -18,6 +18,8 @@
  *  - NEXIO/iNexio
  *  - Elo TouchSystems 2700 IntelliTouch
  *  - EasyTouch USB Dual/Multi touch controller from Data Modul
+ *  - CJTouch
+ *  - CJMTouch
  *
  * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch>
  * Copyright (C) by Todd E. Johnson (mtouchusb.c)
@@ -143,6 +145,8 @@ enum {
 	DEVTYPE_NEXIO,
 	DEVTYPE_ELO,
 	DEVTYPE_ETOUCH,
+	DEVTYPE_CJTOUCH,
+	DEVTYPE_CJMTOUCH,
 };
 
 #define USB_DEVICE_HID_CLASS(vend, prod) \
@@ -251,6 +255,15 @@ static const struct usb_device_id usbtouch_devices[] = {
 	{USB_DEVICE(0x7374, 0x0001), .driver_info = DEVTYPE_ETOUCH},
 #endif
 
+#ifdef CONFIG_TOUCHSCREEN_USB_CJTOUCH
+	{USB_DEVICE(0x24b8, 0x0001), .driver_info = DEVTYPE_CJTOUCH},
+	{USB_DEVICE(0x24b8, 0x0004), .driver_info = DEVTYPE_CJTOUCH},
+#endif
+
+#ifdef CONFIG_TOUCHSCREEN_USB_CJMTOUCH
+	{USB_DEVICE(0x24b8, 0x000f), .driver_info = DEVTYPE_CJMTOUCH},
+	{USB_DEVICE(0x24b8, 0x0010), .driver_info = DEVTYPE_CJMTOUCH},
+#endif
 	{}
 };
 
@@ -1063,6 +1076,89 @@ static int elo_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
 }
 #endif
 
+/*****************************************************************************
+ * CJTouch part
+ */
+
+#ifdef CONFIG_TOUCHSCREEN_USB_CJTOUCH
+
+static int cjtouch_touch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
+{
+	dev->x = ((pkt[2] & 0x00FF) << 8) | (pkt[1] & 0x00FF);
+	dev->y = ((pkt[4] & 0x00FF) << 8) | (pkt[3] & 0x00FF);
+	dev->press = pkt[0];
+	dev->touch = pkt[0];
+
+	return 1;
+}
+#endif
+
+/*****************************************************************************
+ * CJMTouch part
+ */
+
+#ifdef CONFIG_TOUCHSCREEN_USB_CJMTOUCH
+
+static int x = 4095;
+static int y = 4095;
+static int old2State = 4095;
+
+static void cjmtouch_touch_process_pkt(struct usbtouch_usb *usbtouch,
+				   unsigned char *pkt, int len)
+{
+	int touch1 = pkt[1] & 0x01;
+	int touch2 = pkt[7] & 0x01;
+
+	if (touch1)
+		input_report_abs(usbtouch->input, ABS_MT_TOUCH_MAJOR, 1);
+	else
+		input_report_abs(usbtouch->input, ABS_MT_TOUCH_MAJOR, 0);
+
+	{
+		x = ((pkt[4] << 8) | pkt[3]);
+		y = ((pkt[6] << 8) | pkt[5]);
+
+		/*x = (x * 800) / 0xfff;
+		  y = (y * 600) / 0xfff;*/
+
+		input_report_abs(usbtouch->input, ABS_MT_WIDTH_MAJOR, 1);
+		input_report_abs(usbtouch->input, ABS_MT_POSITION_X, x);
+		input_report_abs(usbtouch->input, ABS_MT_POSITION_Y, y);
+
+		input_mt_sync(usbtouch->input);
+	}
+
+	if (touch2) {
+		old2State = 1;
+		input_report_abs(usbtouch->input, ABS_MT_TOUCH_MAJOR, 1);
+		/*x = (x * 800) / 0xfff;
+		  y = (y * 600) / 0xfff;*/
+
+		input_report_abs(usbtouch->input, ABS_MT_WIDTH_MAJOR, 1);
+		input_report_abs(usbtouch->input, ABS_MT_POSITION_X, x);
+		input_report_abs(usbtouch->input, ABS_MT_POSITION_Y, y);
+
+		input_mt_sync(usbtouch->input);
+	} else {
+		if (old2State == 1) {
+			old2State = 0;
+			input_report_abs(usbtouch->input,
+					ABS_MT_TOUCH_MAJOR, 0);
+
+		/*	x = (x * 800) / 0xfff;
+			y = (y * 600) / 0xfff;*/
+
+			input_report_abs(usbtouch->input,
+				ABS_MT_WIDTH_MAJOR, 1);
+			input_report_abs(usbtouch->input, ABS_MT_POSITION_X, x);
+			input_report_abs(usbtouch->input, ABS_MT_POSITION_Y, y);
+
+			input_mt_sync(usbtouch->input);
+		}
+	}
+	input_sync(usbtouch->input);
+}
+#endif
 
 /*****************************************************************************
  * the different device descriptors
@@ -1293,6 +1389,26 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
 		.read_data	= etouch_read_data,
 	},
 #endif
+#ifdef CONFIG_TOUCHSCREEN_USB_CJTOUCH
+	[DEVTYPE_CJTOUCH] = {
+		.min_xc	= 0x0,
+		.max_xc = 0x0fff,
+		.min_yc = 0x0,
+		.max_yc = 0x0fff,
+		.rept_size = 7,
+		.read_data = cjtouch_touch_read_data,
+	},
+#endif
+#ifdef CONFIG_TOUCHSCREEN_USB_CJMTOUCH
+	[DEVTYPE_CJMTOUCH] = {
+		.min_xc	= 0x0,
+		.max_xc = 0x0fff,
+		.min_yc = 0x0,
+		.max_yc = 0x0fff,
+		.rept_size = 14,
+		.process_pkt = cjmtouch_touch_process_pkt,
+	},
+#endif
 };
 
 
-- 
1.7.9.5



                 reply	other threads:[~2015-06-14 16:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434298943-4961-1-git-send-email-linuxsea@163.com \
    --to=linuxsea@163.com \
    --cc=bleung@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nick.dyer@itdev.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.