From patchwork Sun Jun 14 16:22:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: linuxsea@163.com X-Patchwork-Id: 6605031 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1BD399F399 for ; Sun, 14 Jun 2015 16:22:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 00291206FE for ; Sun, 14 Jun 2015 16:22:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0CE0206E1 for ; Sun, 14 Jun 2015 16:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751795AbbFNQWL (ORCPT ); Sun, 14 Jun 2015 12:22:11 -0400 Received: from m12-13.163.com ([220.181.12.13]:43208 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751476AbbFNQWJ (ORCPT ); Sun, 14 Jun 2015 12:22:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=NKVXZw/D1Lbhtcspxv 4td6qlO3iS2I65ivpEJhhQoJo=; b=pSX7cYpvsZlVr1sX9Jhl/F3HsWeW6bRouD liTDV6s17k0NYrM+apoM8kcJsgJPPjNI96J5IgAtZoVz8pBqjXHMQaayxgxhi6Ev fyTWEFZ3o7zxH1b9MzO6Bao23ejkVuzxvJHOgWgt63POAXvcalSw1XdxgXLFR0+z S+YRMiYxk= Received: from localhost (unknown [110.52.135.27]) by smtp9 (Coremail) with SMTP id DcCowADHlo7LqX1VWeTsBQ--.16294S2; Mon, 15 Jun 2015 00:20:28 +0800 (CST) 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 Message-Id: <1434298943-4961-1-git-send-email-linuxsea@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: DcCowADHlo7LqX1VWeTsBQ--.16294S2 X-Coremail-Antispam: 1Uf129KBjvJXoW3Ar1xWF4kGFWUXw4rCw4rZrb_yoW7ZF47pF WrJ3s0yws5KF1Fqryjyw4q9Fn8tF4kGF98KF9rtF1Igw1UCw18Ar97XFnrJr15Kr17tFsx trn5urW3WanxAr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UUb1OUUUUU= X-Originating-IP: [110.52.135.27] X-CM-SenderInfo: polq35xvhdqiywtou0bp/xtbBZA4ZgFQGzifIWwAAsb Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: linuxsea Signed-off-by: linuxsea --- 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 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 * 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 };