From patchwork Tue Dec 15 11:24:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QsO2c3rDtnJtw6lueWkgWm9sdMOhbg==?= X-Patchwork-Id: 7854091 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 486D8BEEE1 for ; Tue, 15 Dec 2015 12:10:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BA212022A for ; Tue, 15 Dec 2015 12:09:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8094520265 for ; Tue, 15 Dec 2015 12:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965034AbbLOMJy (ORCPT ); Tue, 15 Dec 2015 07:09:54 -0500 Received: from mail9.pr.hu ([87.242.0.9]:55517 "EHLO mail9.pr.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965052AbbLOMJx (ORCPT ); Tue, 15 Dec 2015 07:09:53 -0500 Received: from [2a02:808:3:101::5] (helo=mail.pr.hu) by frontdoor.pr.hu with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1a8nij-0000YE-9w; Tue, 15 Dec 2015 12:24:41 +0100 Received: from host-87-242-63-18.prtelecom.hu ([87.242.63.18] helo=s002.sicom.com) by mail.pr.hu with esmtpa (Exim 4.80) (envelope-from ) id 1a8nif-0002t5-8i; Tue, 15 Dec 2015 12:24:39 +0100 From: =?UTF-8?q?B=C3=B6sz=C3=B6rm=C3=A9nyi=20Zolt=C3=A1n?= To: Vojtech Pavlik Cc: linux-input@vger.kernel.org, linuxconsole-dev@lists.sourceforge.net, =?UTF-8?q?B=C3=B6sz=C3=B6rm=C3=A9nyi=20Zolt=C3=A1n?= Subject: [PATCH] Add support for the egalax serial touchscreen driver Date: Tue, 15 Dec 2015 12:24:32 +0100 Message-Id: <1450178672-26885-1-git-send-email-zboszormenyi@sicom.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 X-Spam-Score: 0.9 (/) X-Scan-Signature: eaf96b0a630ef3550f2a52c34f009b95 X-Spam-Tracer: backend.mail.pr.hu 0.9 20151215112439Z Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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: Böszörményi Zoltán Add inputattach support for the egalax serial touchscreen driver. Signed-off-by: Böszörményi Zoltán --- utils/inputattach.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/utils/inputattach.c b/utils/inputattach.c index bdaafa3..720a0b5 100644 --- a/utils/inputattach.c +++ b/utils/inputattach.c @@ -615,20 +615,82 @@ static int wacom_iv_init(int fd, unsigned long *id, unsigned long *extra) if (write(fd, WACOM_IV_RESET, WACOM_IV_RESET_LEN) != WACOM_IV_RESET_LEN) return -1; usleep(75 * 1000); if (write(fd, WACOM_IV_STOP, WACOM_IV_STOP_LEN) != WACOM_IV_STOP_LEN) return -1; usleep(30 * 1000); return 0; } +static int check_egalax_response(int fd, unsigned char *command, int sz, unsigned char *response) { + int pos = 0; + int error = 0; + int rest_length; + + if (write(fd, command, sz) != sz) + return -1; + + for (pos = 0; pos < 3; pos++) { + if (readchar(fd, &response[pos], 100)) { + error = 1; + break; + } + } + + if (error) + return -1; + + rest_length = response[1] - 1; + + for (; rest_length; rest_length--, pos++) { + if (readchar(fd, &response[pos], 100)) { + error = 1; + break; + } + } + + if (error) + return -1; + + if (response[1] >= command[1] && + response[0] == command[0] && + response[2] == command[2]) + return 0; + + return -1; +} + +static int egalax_init(int fd, unsigned long *id, unsigned long *extra) { + unsigned char packet_alive_query[3] = { 0x0a, 0x01, 'A' }; + unsigned char packet_fw_ver[3] = { 0x0a, 0x01, 'D' }; + unsigned char packet_ctrl_type[3] = { 0x0a, 0x01, 'E' }; + unsigned char response[128]; + + if (check_egalax_response(fd, packet_alive_query, sizeof(packet_alive_query), response)) + return -1; + + if (check_egalax_response(fd, packet_fw_ver, sizeof(packet_fw_ver), response)) + return -1; + + response[(unsigned char)response[1] + 2] = '\0'; + printf("EETI eGalaxTouch firmware: %s\n", &response[3]); + + if (check_egalax_response(fd, packet_ctrl_type, sizeof(packet_ctrl_type), response)) + return -1; + + response[(unsigned char)response[1] + 2] = '\0'; + printf("EETI eGalaxTouch controller type: %s\n", &response[3]); + + return 0; +} + struct input_types { const char *name; const char *name2; const char *desc; int speed; int flags; unsigned long type; unsigned long id; unsigned long extra; int flush; @@ -700,32 +762,42 @@ static struct input_types input_types[] = { SERIO_STOWAWAY, 0x00, 0x00, 1, NULL }, { "--ps2serkbd", "-ps2ser", "PS/2 via serial keyboard", B1200, CS8, SERIO_PS2SER, 0x00, 0x00, 1, NULL }, { "--twiddler", "-twid", "Handykey Twiddler chording keyboard", B2400, CS8, SERIO_TWIDKBD, 0x00, 0x00, 0, twiddler_init }, { "--twiddler-joy", "-twidjoy", "Handykey Twiddler used as a joystick", B2400, CS8, SERIO_TWIDJOY, 0x00, 0x00, 0, twiddler_init }, +#ifdef SERIO_EGALAX +{ "--eetiegalax", "-eeti", "EETI eGalaxTouch", + B9600, CS8, + SERIO_EGALAX, 0x00, 0x00, 0, egalax_init }, +#endif { "--elotouch", "-elo", "ELO touchscreen, 10-byte mode", B9600, CS8, SERIO_ELO, 0x00, 0x00, 0, NULL }, { "--elo4002", "-elo6b", "ELO touchscreen, 6-byte mode", B9600, CS8 | CRTSCTS, SERIO_ELO, 0x01, 0x00, 0, NULL }, { "--elo271-140", "-elo4b", "ELO touchscreen, 4-byte mode", B9600, CS8 | CRTSCTS, SERIO_ELO, 0x02, 0x00, 0, NULL }, { "--elo261-280", "-elo3b", "ELO Touchscreen, 3-byte mode", B9600, CS8 | CRTSCTS, SERIO_ELO, 0x03, 0x00, 0, NULL }, +#ifdef SERIO_HAMPSHIRE +{ "--hampshire", "-ham", "Hampshire touchscreen", + B9600, CS8, + SERIO_HAMPSHIRE, 0x00, 0x00, 0, NULL }, +#endif { "--mtouch", "-mtouch", "MicroTouch (3M) touchscreen", B9600, CS8 | CRTSCTS, SERIO_MICROTOUCH, 0x00, 0x00, 0, NULL }, #ifdef SERIO_TSC40 { "--tsc", "-tsc", "TSC-10/25/40 serial touchscreen", B9600, CS8, SERIO_TSC40, 0x00, 0x00, 0, tsc40_init }, #endif { "--touchit213", "-t213", "Sahara Touch-iT213 Tablet PC", B9600, CS8,