From patchwork Wed Aug 2 09:15:04 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: 9876429 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 30A776037D for ; Wed, 2 Aug 2017 09:27:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E6D828760 for ; Wed, 2 Aug 2017 09:27:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 226FF2879F; Wed, 2 Aug 2017 09:27:02 +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 91C9828760 for ; Wed, 2 Aug 2017 09:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752718AbdHBJ0U (ORCPT ); Wed, 2 Aug 2017 05:26:20 -0400 Received: from mail7.pr.hu ([87.242.0.7]:58875 "EHLO mail7.pr.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752713AbdHBJ0T (ORCPT ); Wed, 2 Aug 2017 05:26:19 -0400 X-Greylist: delayed 645 seconds by postgrey-1.27 at vger.kernel.org; Wed, 02 Aug 2017 05:26:19 EDT 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 1dcpka-0007fr-Lu; Wed, 02 Aug 2017 11:15:32 +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=UduTD5km9I5aTfQ5CbdiSE2I4eA8C/YjHUqsyG2LmGo=; b=VWGRI/icpz4f9ohZfqx91l49fxKwZF9jXXHpyNbleuztiYVo2+YBgR5/6cCoTD9u7HoUkBNzWMGz9WZDvXD5HWSSv29i1fzk94mMJ4THNguwxpaG7DLDooq8MkmHshF6RrMs8lobyjXR0ZPDVHZDJTytOJhuUcCqy7CBL+qptGZVha+qJw9VZ5xYNppJA19ghk6/GG+e/K2gQqHrZIMPNpA+J6xGEWPgphXB80Fa988t4v6kE21rJW/0b6a7/i4uf4+fsufnQGAmpDtXBNeQogy2RXpaHHDyocnPgm0CESEiDPbSCQl6AfjnQ6q0Vq+8zOxnpHGz8OKb4tC/U2B3Rw==; 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 1dcpkW-0002uz-Rv; Wed, 02 Aug 2017 11:15:30 +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] Input: usbtouchscreen - handle HID class 0x0eef:0x0001 device Date: Wed, 2 Aug 2017 11:15:04 +0200 Message-Id: <20170802091504.29702-1-zboszor@pr.hu> X-Mailer: git-send-email 2.13.3 In-Reply-To: <599539ea-a686-51a8-795b-6d64991cfe0f@pr.hu> References: <599539ea-a686-51a8-795b-6d64991cfe0f@pr.hu> MIME-Version: 1.0 X-Scan-Signature: fce31d005a6daa43338274ee84f84c38 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. 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 | 88 +++++++++++++++++++++++++++++- 3 files changed, 88 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..b00bd0b617d7 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,82 @@ 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; + } + + if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT) + return 0; + + dev->x = ((pkt[3] & 0x0F) << 7) | (pkt[4] & 0x7F); + dev->y = ((pkt[1] & 0x0F) << 7) | (pkt[2] & 0x7F); + dev->touch = pkt[0] & 0x01; + + return 1; +} + #endif /***************************************************************************** @@ -1100,6 +1177,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