From patchwork Wed Aug 2 11:46:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Wm9sdMOhbiBCw7ZzesO2cm3DqW55aQ==?= X-Patchwork-Id: 9876649 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA92A60360 for ; Wed, 2 Aug 2017 11:46:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C74782871C for ; Wed, 2 Aug 2017 11:46:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B920828776; Wed, 2 Aug 2017 11:46:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 676522871C for ; Wed, 2 Aug 2017 11:46:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753045AbdHBLqv (ORCPT ); Wed, 2 Aug 2017 07:46:51 -0400 Received: from mail7.pr.hu ([87.242.0.7]:35112 "EHLO mail7.pr.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753078AbdHBLqu (ORCPT ); Wed, 2 Aug 2017 07:46:50 -0400 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 1dcs6y-0006ZQ-W0; Wed, 02 Aug 2017 13:46:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pr.hu; s=pr20170203; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=pg0ra+z/T/7NTHbpPzv/fBY/mDzrojQ3Ax4BVDy/Ego=; b=AlGI6orhckGaxFcttHAuKsw+YJRdobStb8loYmdg11zWUj2D/2xj/Dkw6l2N6GBHQnxNJm0aCXOcKBlWm5LsLc3gEb1aNMmRaLY/xt5f6Qociz6yQ2DwThygDlZbClC85sxCtvee9rxOuMPerotFUUEhIM5yH5YcrlJWcxiWKHXblQDmsgQPljdcVqHGmuX9QllKhRkUU2cdp2gqYQWFC4LuQ767hJhIDj89g9BKWbOVbo89EldF92U0NUQ2sIJGXPk4HF3SisiE/jWSwNQ7BWrCGfWReMVe01o1J+PtOXTN0nqON862G9fN2AWlLon27T9EXTnU+qq0GDSpv0qz5w==; Received: from host-87-242-51-16.prtelecom.hu ([87.242.51.16] helo=s002.sicom.com.com) by mail.pr.hu with esmtpa (Exim 4.80) (envelope-from ) id 1dcs6v-0005lk-4m; Wed, 02 Aug 2017 13:46:46 +0200 From: zboszor@pr.hu To: linux-input@vger.kernel.org, Dmitry Torokhov Cc: Benjamin Tissoires , Jiri Kosina , =?UTF-8?q?B=C3=B6sz=C3=B6rm=C3=A9nyi=20Zolt=C3=A1n?= Subject: [PATCH v2] Input: usbtouchscreen - handle HID class 0x0eef:0x0001 device Date: Wed, 2 Aug 2017 13:46:39 +0200 Message-Id: <20170802114639.9445-1-zboszor@pr.hu> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170802091504.29702-1-zboszor@pr.hu> References: <20170802091504.29702-1-zboszor@pr.hu> MIME-Version: 1.0 X-Scan-Signature: 92c2ac033948f69aa00333af679f204c Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Böszörményi Zoltán The device was previously handled by hid-multitouch only half way, BTN_TOUCH events were not emitted so Xorg could only detect motion. The EETI vendor magic sequence is different from what the old capacitive touchscreen documentation contains which is now used for this device. Touch events are also implemented for this device acording to the vendor device driver. usbhid and hid-multitouch now ignore this device. v2: Removed copy & paste leftovers Signed-off-by: Zoltán Böszörményi --- drivers/hid/hid-core.c | 1 + drivers/hid/usbhid/hid-quirks.c | 1 - drivers/input/touchscreen/usbtouchscreen.c | 79 +++++++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 9017dcc14502..3be59cb199dd 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2640,6 +2640,7 @@ static const struct hid_device_id hid_ignore_list[] = { { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER)}, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x0400) }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, 0x0401) }, { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index a88e7c7bea0a..3a807485a415 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c @@ -34,7 +34,6 @@ static const struct hid_blacklist { { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, - { USB_VENDOR_ID_DWAV, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER, HID_QUIRK_MULTI_INPUT | HID_QUIRK_NOGET }, { USB_VENDOR_ID_MOJO, USB_DEVICE_ID_RETRO_ADAPTER, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 2c41107240de..07a8a3a586a8 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -125,6 +125,7 @@ struct usbtouch_usb { enum { DEVTYPE_IGNORE = -1, DEVTYPE_EGALAX, + DEVTYPE_EGALAX_VENDOR_CODE, DEVTYPE_PANJIT, DEVTYPE_3M, DEVTYPE_ITM, @@ -155,7 +156,7 @@ enum { static const struct usb_device_id usbtouch_devices[] = { #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX /* ignore the HID capable devices, handled by usbhid */ - {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE}, + {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX_VENDOR_CODE}, {USB_DEVICE_HID_CLASS(0x0eef, 0x0002), .driver_info = DEVTYPE_IGNORE}, /* normal device IDs */ @@ -370,6 +371,73 @@ static int egalax_get_pkt_len(unsigned char *buf, int len) return 0; } + +/* eGalax vendor constants */ +#define EGALAX_MOUSE 0x01 +#define EGALAX_DIGITIZER 0x02 +#define EGALAX_VENDORCMD 0x03 +#define EGALAX_MT 0x04 +#define EGALAX_MTOUCH_ALLPOINT 0x06 + +static int egalax_vendor_init(struct usbtouch_usb *usbtouch) +{ + int ret, i; + unsigned char *buf; + struct usb_device *udev = interface_to_usbdev(usbtouch->interface); + + /* + * An eGalax diagnostic packet kicks the device into using the right + * protocol. We send a "check active" packet. The response will be + * read later and ignored. + */ + + buf = kmalloc(3, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + /* EETI vendor magic */ + buf[0] = 0x05; + buf[1] = 0x02; + buf[2] = 0x00; + + for (i = 0; i < 3; i++) { + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), + 0, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0, 0, buf, 3, + USB_CTRL_SET_TIMEOUT); + if (ret >= 0) { + ret = 0; + break; + } + if (ret != -EPIPE) + break; + } + + kfree(buf); + + return ret; +} + +static int egalax_vendor_read_data(struct usbtouch_usb *dev, unsigned char *pkt) +{ + switch (pkt[0]) { + case EGALAX_MOUSE: + case EGALAX_DIGITIZER: + case EGALAX_MT: + dev->x = ((pkt[3] << 8) + pkt[2]) >> 1; + dev->y = ((pkt[5] << 8) + pkt[4]) >> 1; + dev->touch = pkt[1] & 0x01; + return 1; + case EGALAX_MTOUCH_ALLPOINT: + /* ignore, TODO */ + return 0; + case EGALAX_VENDORCMD: + default: + return 0; + } +} + #endif /***************************************************************************** @@ -1100,6 +1168,15 @@ static struct usbtouch_device_info usbtouch_dev_info[] = { .read_data = egalax_read_data, .init = egalax_init, }, + [DEVTYPE_EGALAX_VENDOR_CODE] = { + .min_xc = 0x0, + .max_xc = 0x07ff, + .min_yc = 0x0, + .max_yc = 0x07ff, + .rept_size = 16, + .read_data = egalax_vendor_read_data, + .init = egalax_vendor_init, + }, #endif #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT