From patchwork Sun Feb 10 10:13:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804665 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCA7C13B4 for ; Sun, 10 Feb 2019 10:14:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB9FB29F45 for ; Sun, 10 Feb 2019 10:14:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C9F229F4A; Sun, 10 Feb 2019 10:14:42 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 7867A29F45 for ; Sun, 10 Feb 2019 10:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725988AbfBJKOk (ORCPT ); Sun, 10 Feb 2019 05:14:40 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40919 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbfBJKOk (ORCPT ); Sun, 10 Feb 2019 05:14:40 -0500 Received: by mail-lj1-f194.google.com with SMTP id z25-v6so6418215ljk.7 for ; Sun, 10 Feb 2019 02:14:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P5Z9Fkl99S2CE5jhv9sJ1Mo9fNjKxcZGkCDifKaTY0g=; b=nfNUUYGP9l+8bczwBQaz0Z1JPTnWQVNDhSleqRrIqgT1T8YURJhCiodZVKBazDdoWy UgjVt93D7uFGSlqMkN7YrLvQuw+U5NnieOYVhG8czdcr6PrO9EBImtWZkZEPAQmNkS2S 3/Rc4IoHZIhhVSEaK+rbLc+qV2BYc7WTuuBAHLVwldKW/v+uSbaxaN805rs6hAQuooUj 9JNiWgzXOkis+6+X8lWXO1zNvSOsm6fPPMAcbIA83uAzVYLoC+ajm8fYhtf/G7lqpTof czrsF3Olo2hZ+TDzimTHFxiuRQu+N8iDhsJ/GCAjMPobz4gQg2dAmufK+nMeS6sO55RQ 3Odw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P5Z9Fkl99S2CE5jhv9sJ1Mo9fNjKxcZGkCDifKaTY0g=; b=W1VMYLIJJcvRIXq2goJSCVP9YqazRjjudb1prWQDr8copfnFzXy1/NWQX7dYoLWKiJ Qvcb/8bRnK/eJCKE1ffhewNQeikdI3VA1/3F+fmCHwPkFjfu19mMz5sjOiIYhahs2Sj9 8cz0Pzj5GFuCo9N06Y5vvDfANKg7ZXZ4ZMbRqFRGdB/e8nTs9lS/fBK+z0GgilsB8XNh 3dsNM6TGhALwf+xGgTlBxtdpNO3hguOIBuzMtyxSVWgIpMsViEy+DOJUHFIP13yhxnfy 2ZzWd24qYCfqgd8zhdTvkeu/P8xb4J+jJsSyTsDing1GI+GtAm37z7x3zHUh8VlQffWd DlRg== X-Gm-Message-State: AHQUAubHRi72pAziloM+zDErIEBqJ3El1IYkh7qdt7pGEKQSIkQ4BJHi YgdFEFf0U87Kbbv4aU900PA= X-Google-Smtp-Source: AHgI3IZo+07/RFM8Y5qMcgJZWpI6R8VNn3El8XhUcEa0pbibQ1iQwsl7TbUZ0K2FznVZkAzb8wdiYg== X-Received: by 2002:a2e:8ec8:: with SMTP id e8-v6mr18921570ljl.162.1549793677692; Sun, 10 Feb 2019 02:14:37 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:36 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov , Andrey Alekseenko Subject: [PATCH v2 01/23] HID: kye: Add support for EasyPen M406XE Date: Sun, 10 Feb 2019 12:13:47 +0200 Message-Id: <20190210101409.3511-2-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Originally contributed by Andrey Alekseenko . Signed-off-by: Andrey Alekseenko Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-kye.c | 83 ++++++++++++++++++++++++++++++++++++++++ drivers/hid/hid-quirks.c | 1 + 3 files changed, 85 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 24f846d67478..2bef2fd07360 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -661,6 +661,7 @@ #define USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2 0x501a #define USB_DEVICE_ID_KYE_EASYPEN_M610X 0x5013 #define USB_DEVICE_ID_KYE_PENSKETCH_M912 0x5015 +#define USB_DEVICE_ID_KYE_EASYPEN_M406XE 0x5019 #define USB_VENDOR_ID_LABTEC 0x1020 #define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006 diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c index 9c113f62472d..679d422b885a 100644 --- a/drivers/hid/hid-kye.c +++ b/drivers/hid/hid-kye.c @@ -483,6 +483,80 @@ static __u8 pensketch_m912_rdesc_fixed[] = { 0xC0 /* End Collection */ }; +/* Original EasyPen M406XE report descriptor size */ +#define EASYPEN_M406XE_RDESC_ORIG_SIZE 476 + +/* Fixed EasyPen M406XE report descriptor */ +static __u8 easypen_m406xe_rdesc_fixed[] = { + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x01, /* Usage (01h), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x05, /* Report ID (5), */ + 0x09, 0x01, /* Usage (01h), */ + 0x15, 0x80, /* Logical Minimum (-128), */ + 0x25, 0x7F, /* Logical Maximum (127), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x07, /* Report Count (7), */ + 0xB1, 0x02, /* Feature (Variable), */ + 0xC0, /* End Collection, */ + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x02, /* Usage (Pen), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x10, /* Report ID (16), */ + 0x09, 0x20, /* Usage (Stylus), */ + 0xA0, /* Collection (Physical), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x09, 0x42, /* Usage (Tip Switch), */ + 0x09, 0x44, /* Usage (Barrel Switch), */ + 0x09, 0x46, /* Usage (Tablet Pick), */ + 0x95, 0x03, /* Report Count (3), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x04, /* Report Count (4), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x09, 0x32, /* Usage (In Range), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x02, /* Input (Variable), */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x01, /* Report Count (1), */ + 0xA4, /* Push, */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x55, 0xFD, /* Unit Exponent (-3), */ + 0x65, 0x13, /* Unit (Inch), */ + 0x34, /* Physical Minimum (0), */ + 0x09, 0x30, /* Usage (X), */ + 0x46, 0x70, 0x17, /* Physical Maximum (6000), */ + 0x26, 0x00, 0x3C, /* Logical Maximum (15360), */ + 0x81, 0x02, /* Input (Variable), */ + 0x09, 0x31, /* Usage (Y), */ + 0x46, 0xA0, 0x0F, /* Physical Maximum (4000), */ + 0x26, 0x00, 0x28, /* Logical Maximum (10240), */ + 0x81, 0x02, /* Input (Variable), */ + 0xB4, /* Pop, */ + 0x09, 0x30, /* Usage (Tip Pressure), */ + 0x26, 0xFF, 0x03, /* Logical Maximum (1023), */ + 0x81, 0x02, /* Input (Variable), */ + 0xC0, /* End Collection, */ + 0xC0, /* End Collection */ + 0x05, 0x0C, /* Usage Page (Consumer), */ + 0x09, 0x01, /* Usage (Consumer Control), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x12, /* Report ID (18), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x04, /* Report Count (4), */ + 0x0A, 0x79, 0x02, /* Usage (AC Redo Or Repeat), */ + 0x0A, 0x1A, 0x02, /* Usage (AC Undo), */ + 0x0A, 0x2D, 0x02, /* Usage (AC Zoom In), */ + 0x0A, 0x2E, 0x02, /* Usage (AC Zoom Out), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x34, /* Report Count (52), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0xC0 /* End Collection */ +}; + static __u8 *kye_consumer_control_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize, int offset, const char *device_name) { /* @@ -555,6 +629,12 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc, *rsize = sizeof(easypen_m610x_rdesc_fixed); } break; + case USB_DEVICE_ID_KYE_EASYPEN_M406XE: + if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) { + rdesc = easypen_m406xe_rdesc_fixed; + *rsize = sizeof(easypen_m406xe_rdesc_fixed); + } + break; case USB_DEVICE_ID_KYE_PENSKETCH_M912: if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) { rdesc = pensketch_m912_rdesc_fixed; @@ -644,6 +724,7 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id) case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2: case USB_DEVICE_ID_KYE_EASYPEN_M610X: + case USB_DEVICE_ID_KYE_EASYPEN_M406XE: case USB_DEVICE_ID_KYE_PENSKETCH_M912: ret = kye_tablet_enable(hdev); if (ret) { @@ -678,6 +759,8 @@ static const struct hid_device_id kye_devices[] = { USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) }, + { HID_USB_DEVICE(USB_VENDOR_ID_KYE, + USB_DEVICE_ID_KYE_EASYPEN_M406XE) }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 94088c0ed68a..0f4a777b17a8 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -99,6 +99,7 @@ static const struct hid_device_id hid_quirks[] = { { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912), HID_QUIRK_MULTI_INPUT }, + { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406XE), HID_QUIRK_MULTI_INPUT }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C007), HID_QUIRK_ALWAYS_POLL }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C077), HID_QUIRK_ALWAYS_POLL }, From patchwork Sun Feb 10 10:13:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804667 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60CB013B4 for ; Sun, 10 Feb 2019 10:14:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E9B929F45 for ; Sun, 10 Feb 2019 10:14:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42AD529F4A; Sun, 10 Feb 2019 10:14:49 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 AC16A29F45 for ; Sun, 10 Feb 2019 10:14:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725999AbfBJKOs (ORCPT ); Sun, 10 Feb 2019 05:14:48 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:35486 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbfBJKOs (ORCPT ); Sun, 10 Feb 2019 05:14:48 -0500 Received: by mail-lf1-f68.google.com with SMTP id v7so1300176lfd.2 for ; Sun, 10 Feb 2019 02:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6d7ReFzBavrTwiuN4OIu+zT6U1PUT07F03H2e4fgOJg=; b=o5F5eyKMbIKxo+mLcvaMRalPX52mHy5JoOUxeFypLiRPHmVh5BTcuZmSqJFNA9Jymr +P6UfAx3C6JNeMVjfCkYYqOQcjUYD+74s6X/l9DftcGKxKTXFbn8K6tDhhYgcMGYiTQq vyn1CKKOdlwxVtK781a4AQlX/6iTUAoO/sLDYosXHVp6c+doffN5mGL8tiIp9YG3BAre ynIdjY0oOyWO7RhcGbJFeHB7VUp+6C3xfpdbfdaAE27gnj8dwc9ljrYub8g/ktAypnbj vT0tzEP/uQXo9QcEic8cSS+EW6eZdJgxUx5MqE2lVuJ07t9zw3yLM6sMBte8tU9pLvIC iZVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6d7ReFzBavrTwiuN4OIu+zT6U1PUT07F03H2e4fgOJg=; b=rzi+cJsSrWZDCtDSwE9Bt7LnmAVLAPADx1zOtmz0QUny1YMB1Y/YvV2F76QMnid4nw Sh8V8vf/3mCwENJm4HcecdnebceT0G60rGBeKCtzs/nqgmJ5UTwMlkRXe2FJ9gFZtvHo MJo0nb915p/gssu3GKbqWq6oeaL5MHx4or17xnxWBJOWmADnBP+MZZLxCL1YIV5SQpex 6bJZHO5X38k0ZsN+UAJlas2F+FBi1ljIE708Z/cL3Ep4/hpdmsAgT30cTD96w3S/mGNT FMEHjZtS4j4r1r63TNeA5eLMLlyIDE10/1s7JlomPM1Eaf2hnY+4lVLTIi+q+XrluTUC rvaA== X-Gm-Message-State: AHQUAuZ8etqz7Vuk/MTUD9VFCO/aZJyHFhponmhqwFqcoli6sffN89D3 ixWrrxkbvpVPvybfrLqshV0= X-Google-Smtp-Source: AHgI3IaX56kb+avEy5dvS/vQ/FvMubdvMH+QPkKRjMjgurDRvGNyoPGRDMo3bFwvixCOlXGyZ+eQ7w== X-Received: by 2002:a19:4bd3:: with SMTP id y202mr3856072lfa.126.1549793684937; Sun, 10 Feb 2019 02:14:44 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:44 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 02/23] HID: viewsonic: Support PD1011 signature pad Date: Sun, 10 Feb 2019 12:13:48 +0200 Message-Id: <20190210101409.3511-3-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for ViewSonic PD1011 signature (display) pad, which is also sold by Signotec under a different name. Signed-off-by: Nikolai Kondrashov --- drivers/hid/Kconfig | 6 +++ drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 6 +++ drivers/hid/hid-viewsonic.c | 105 ++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 drivers/hid/hid-viewsonic.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 41e9935fc584..4e4cacf85cbd 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -412,6 +412,12 @@ config HID_WALTOP ---help--- Support for Waltop tablets. +config HID_VIEWSONIC + tristate "ViewSonic/Signotec" + depends on HID + help + Support for ViewSonic/Signotec PD1011 signature pad. + config HID_GYRATION tristate "Gyration remote control" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 896a51ce7ce0..a57e1088133a 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -114,6 +114,7 @@ obj-$(CONFIG_HID_LED) += hid-led.o obj-$(CONFIG_HID_XINMO) += hid-xinmo.o obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o +obj-$(CONFIG_HID_VIEWSONIC) += hid-viewsonic.o wacom-objs := wacom_wac.o wacom_sys.o obj-$(CONFIG_HID_WACOM) += wacom.o diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 2bef2fd07360..e23ec8fb2213 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1241,4 +1241,10 @@ #define USB_VENDOR_ID_UGTIZER 0x2179 #define USB_DEVICE_ID_UGTIZER_TABLET_GP0610 0x0053 +#define USB_VENDOR_ID_VIEWSONIC 0x0543 +#define USB_DEVICE_ID_VIEWSONIC_PD1011 0xe621 + +#define USB_VENDOR_ID_SIGNOTEC 0x2133 +#define USB_DEVICE_ID_SIGNOTEC_VIEWSONIC_PD1011 0x0018 + #endif diff --git a/drivers/hid/hid-viewsonic.c b/drivers/hid/hid-viewsonic.c new file mode 100644 index 000000000000..df60c8fc2efd --- /dev/null +++ b/drivers/hid/hid-viewsonic.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * HID driver for ViewSonic devices not fully compliant with HID standard + * + * Copyright (c) 2017 Nikolai Kondrashov + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include +#include +#include + +#include "hid-ids.h" + +/* Size of the original descriptor of PD1011 signature pad */ +#define PD1011_RDESC_ORIG_SIZE 408 + +/* Fixed report descriptor of PD1011 signature pad */ +static __u8 pd1011_rdesc_fixed[] = { + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x02, /* Usage (Pen), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x02, /* Report ID (2), */ + 0x09, 0x20, /* Usage (Stylus), */ + 0xA0, /* Collection (Physical), */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x01, /* Report Count (1), */ + 0xA4, /* Push, */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x65, 0x13, /* Unit (Inch), */ + 0x55, 0xFD, /* Unit Exponent (-3), */ + 0x34, /* Physical Minimum (0), */ + 0x09, 0x30, /* Usage (X), */ + 0x46, 0x5D, 0x21, /* Physical Maximum (8541), */ + 0x27, 0x80, 0xA9, + 0x00, 0x00, /* Logical Maximum (43392), */ + 0x81, 0x02, /* Input (Variable), */ + 0x09, 0x31, /* Usage (Y), */ + 0x46, 0xDA, 0x14, /* Physical Maximum (5338), */ + 0x26, 0xF0, 0x69, /* Logical Maximum (27120), */ + 0x81, 0x02, /* Input (Variable), */ + 0xB4, /* Pop, */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x09, 0x32, /* Usage (In Range), */ + 0x09, 0x42, /* Usage (Tip Switch), */ + 0x95, 0x02, /* Report Count (2), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x05, /* Report Count (5), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x01, /* Report Count (1), */ + 0x09, 0x30, /* Usage (Tip Pressure), */ + 0x15, 0x05, /* Logical Minimum (5), */ + 0x26, 0xFF, 0x07, /* Logical Maximum (2047), */ + 0x81, 0x02, /* Input (Variable), */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0xC0, /* End Collection, */ + 0xC0 /* End Collection */ +}; + +static __u8 *viewsonic_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int *rsize) +{ + switch (hdev->product) { + case USB_DEVICE_ID_VIEWSONIC_PD1011: + case USB_DEVICE_ID_SIGNOTEC_VIEWSONIC_PD1011: + if (*rsize == PD1011_RDESC_ORIG_SIZE) { + rdesc = pd1011_rdesc_fixed; + *rsize = sizeof(pd1011_rdesc_fixed); + } + break; + } + + return rdesc; +} + +static const struct hid_device_id viewsonic_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_VIEWSONIC, + USB_DEVICE_ID_VIEWSONIC_PD1011) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SIGNOTEC, + USB_DEVICE_ID_SIGNOTEC_VIEWSONIC_PD1011) }, + { } +}; +MODULE_DEVICE_TABLE(hid, viewsonic_devices); + +static struct hid_driver viewsonic_driver = { + .name = "viewsonic", + .id_table = viewsonic_devices, + .report_fixup = viewsonic_report_fixup, +}; +module_hid_driver(viewsonic_driver); + +MODULE_LICENSE("GPL"); From patchwork Sun Feb 10 10:13:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804669 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0953B17E6 for ; Sun, 10 Feb 2019 10:14:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EECCE29F45 for ; Sun, 10 Feb 2019 10:14:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E35EF29F4A; Sun, 10 Feb 2019 10:14:49 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UPPERCASE_50_75 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 81E8229F45 for ; Sun, 10 Feb 2019 10:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725945AbfBJKOt (ORCPT ); Sun, 10 Feb 2019 05:14:49 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45643 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKOs (ORCPT ); Sun, 10 Feb 2019 05:14:48 -0500 Received: by mail-lf1-f66.google.com with SMTP id b20so5563401lfa.12 for ; Sun, 10 Feb 2019 02:14:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Io96tyC37ajWIaR0yGorIJ3PjIHntpc2q/n5FmPL9/k=; b=KJhK7SLvB6cwqpp0W0E59r1Fsi1gfKGWzBcHRya6TZxGxSdU4N5twWDi2Nr/wjK8bN Ze090HaQ2eFI5qOzwJfm74pHGQFe08B6bd/2iKb1oB2hPieZtqsmvP6ibF3XROoaWM2B YL2rf1utLB2UjB1dect1q0ntWMtaF6iISYaIecGHFtzc+4nlDGeeBUnwr8f8rIsVNDV+ Di9QUf8InnHCYk+b8mHyFTkVPLyrU60FGA9xN9ntLAHJO2mbMSY7Z5jnWS/lB54SOYFn sR991bxdNKa26UIJ9e8lxHq8he35XyEIabWE0QEXbwiPhpGpEJlsC2SMoreJH9l/1Y5L WxBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Io96tyC37ajWIaR0yGorIJ3PjIHntpc2q/n5FmPL9/k=; b=hY1xMNkeh+yvKIlNWEVbAFPb0/7AhGw7mdYBN6ijJKgs34JYMwAlsAQG5XpV9jAEGU FJGvxzc12515YP8H+Ih8rrrgXIiavboWuU+r/oZ3h8hpmjNn8WsYuX0c01rwtFymS39F QKgSsk8z+DNSzG498OysjSkXJ4IiZJs/nKtyDFvdn6W6cr6jrl5zB+62PCa8eGuTFQRJ cO8s1sh6fPXWLQwfQ6I2y15AuLAiWoyNvaLzsOVKZiImL55Vj8nf+1kCHnHQAMZrpKFo UWr1S2qQICQArDi8tGPqWMI+AdNosr3lvE73fT4teRk9XXS1xY4FTZdDQAMFFt5GE1ff RDLA== X-Gm-Message-State: AHQUAuZDo5SI9DyEYPuVvvd6EGYhBoc2tr2nbcG3sdVw7R9zaYfv5dTt GiyKoWB8SDH4NXUfWKVTEK5RpTIdGQk= X-Google-Smtp-Source: AHgI3Ib/BvZsSkb4qLgMW5Uw4bH5cj8fmC0XuyEsCztsVevbE7bntjCNWP6vR434ff/dV5pPBNAEOg== X-Received: by 2002:a19:105:: with SMTP id 5mr3762276lfb.163.1549793686571; Sun, 10 Feb 2019 02:14:46 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:45 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 03/23] HID: Clarify vendor ID reuse by Ugee tablets Date: Sun, 10 Feb 2019 12:13:49 +0200 Message-Id: <20190210101409.3511-4-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add "_UCLOGIC" to Ugee tablet device ID macros so it's clear they come with UC-Logic vendor ID. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-ids.h | 4 ++-- drivers/hid/hid-quirks.c | 4 ++-- drivers/hid/hid-uclogic.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index e23ec8fb2213..f66553157be5 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1135,8 +1135,8 @@ #define USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850 0x0522 #define USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60 0x0781 #define USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3 0x3031 -#define USB_DEVICE_ID_UGEE_TABLET_81 0x0081 -#define USB_DEVICE_ID_UGEE_TABLET_45 0x0045 +#define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81 0x0081 +#define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45 0x0045 #define USB_DEVICE_ID_YIYNOVA_TABLET 0x004d #define USB_VENDOR_ID_UGEE 0x28bd diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 0f4a777b17a8..78c836e5ce51 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -685,8 +685,8 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_81) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, diff --git a/drivers/hid/hid-uclogic.c b/drivers/hid/hid-uclogic.c index 56b196d60041..fdc4d1ea7049 100644 --- a/drivers/hid/hid-uclogic.c +++ b/drivers/hid/hid-uclogic.c @@ -957,9 +957,9 @@ static int uclogic_probe(struct hid_device *hdev, switch (id->product) { case USB_DEVICE_ID_HUION_TABLET: case USB_DEVICE_ID_YIYNOVA_TABLET: - case USB_DEVICE_ID_UGEE_TABLET_81: + case USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81: case USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3: - case USB_DEVICE_ID_UGEE_TABLET_45: + case USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45: /* If this is the pen interface */ if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { rc = uclogic_tablet_enable(hdev); @@ -1065,8 +1065,8 @@ static const struct hid_device_id uclogic_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_HUION_TABLET) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_81) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, From patchwork Sun Feb 10 10:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804675 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81D8113B4 for ; Sun, 10 Feb 2019 10:14:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B2F229F4B for ; Sun, 10 Feb 2019 10:14:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FA4929F51; Sun, 10 Feb 2019 10:14:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 95F2729F4F for ; Sun, 10 Feb 2019 10:14:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726002AbfBJKOy (ORCPT ); Sun, 10 Feb 2019 05:14:54 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41532 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKOy (ORCPT ); Sun, 10 Feb 2019 05:14:54 -0500 Received: by mail-lf1-f67.google.com with SMTP id e27so5564653lfj.8 for ; Sun, 10 Feb 2019 02:14:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MfgzRySszATdedDxKzIR0eF4Jc+/b4snrbynKtmrvsA=; b=EVVbQnfvhg1R+SEWudqeEvaERR0rd6md4eYUhlJugG6Epm/qHlTkemMFZc6940zhm6 seMrbraFZ+882uZnvoJHUZ3wULGnYApYEH6EZStcwwxjv5KaU54OzanCDC5isAlKF11A cZWL+hgJGi7rXHq9k7Vnblk6O0wQ8hKDOog0OqsSD1/ieUtr3mdRav6lIGs3yinRd2cs ZWZRQCJet2U3u7A2fNmK8S+GD/iQvbfG9GriC2U1I9JOaprl+VQB1sRVsKWAJ0YceNjF JOuXFlGi/iQYZwVc2Y9uqYOw8Dx+iNlwGQlKODnyzci6pd37pXZVSd9/sE3RPFYtLo0Y X3ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MfgzRySszATdedDxKzIR0eF4Jc+/b4snrbynKtmrvsA=; b=HOHV17RcxwHg/SYDoiRP/x5vQBetBuz8+QwVPTX6uTDg0BBDgXN+RvQGBylVYgjSij D5WXuCVEhi7up31V8xNzgwcpfp1lFdm+Gv20gAKTJ8YzHwQiXTDcIHpTlL7/7UwBoQJz 8P1C4qnWSDwp+ONA1duSHcbG8ZtGbB8WpCuMqUU5MGTH4JtXqv5L0vrGt1gMOj2VXABP o1BkpOqigtyhB8+VA7FaOPxmIZfgSxb+mEHZ0YLzWIvDQI7oojC9I6joQX4xoSO4Cc+Y Gj3kvE9ju76wGU8xi7egfDjctFMqhHolvAAn+CXRS0RqOpz5nwd4hDXS9OjxfsxDzAh6 dt/Q== X-Gm-Message-State: AHQUAuYUgrqC7C4/xjCoOdf16EYV6sUxNiMUHk94iVpQCaPFs4+69ZA0 7QgYhnY78s68f95PD0D7fUw= X-Google-Smtp-Source: AHgI3IYBDwoNzMjr7q7D1doZY34W/bOV5qXlnqFiEswirwv6MqMmkmGlJc2OBZ5roJB07yAbLGDIvw== X-Received: by 2002:a19:c949:: with SMTP id z70mr8416222lff.9.1549793688033; Sun, 10 Feb 2019 02:14:48 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:47 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 04/23] HID: uclogic: Extract report descriptors to a module Date: Sun, 10 Feb 2019 12:13:50 +0200 Message-Id: <20190210101409.3511-5-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 As hid-uclogic has a lot of report descriptors already and there's going to be more, move them out of the driver code and into a separate module. Signed-off-by: Nikolai Kondrashov --- drivers/hid/Makefile | 2 + drivers/hid/hid-uclogic-core.c | 493 +++++++++++++ .../{hid-uclogic.c => hid-uclogic-rdesc.c} | 673 ++++-------------- drivers/hid/hid-uclogic-rdesc.h | 117 +++ 4 files changed, 745 insertions(+), 540 deletions(-) create mode 100644 drivers/hid/hid-uclogic-core.c rename drivers/hid/{hid-uclogic.c => hid-uclogic-rdesc.c} (66%) create mode 100644 drivers/hid/hid-uclogic-rdesc.h diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index a57e1088133a..fb75366ea776 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -108,6 +108,8 @@ obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o obj-$(CONFIG_HID_TIVO) += hid-tivo.o obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o +hid-uclogic-objs := hid-uclogic-core.o \ + hid-uclogic-rdesc.o obj-$(CONFIG_HID_UCLOGIC) += hid-uclogic.o obj-$(CONFIG_HID_UDRAW_PS3) += hid-udraw-ps3.o obj-$(CONFIG_HID_LED) += hid-led.o diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c new file mode 100644 index 000000000000..4042183ee9a3 --- /dev/null +++ b/drivers/hid/hid-uclogic-core.c @@ -0,0 +1,493 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * HID driver for UC-Logic devices not fully compliant with HID standard + * + * Copyright (c) 2010-2014 Nikolai Kondrashov + * Copyright (c) 2013 Martin Rusko + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include +#include +#include +#include +#include "usbhid/usbhid.h" +#include "hid-uclogic-rdesc.h" + +#include "hid-ids.h" + +/* Parameter indices */ +enum uclogic_prm { + UCLOGIC_PRM_X_LM = 1, + UCLOGIC_PRM_Y_LM = 2, + UCLOGIC_PRM_PRESSURE_LM = 4, + UCLOGIC_PRM_RESOLUTION = 5, + UCLOGIC_PRM_NUM +}; + +/* Driver data */ +struct uclogic_drvdata { + __u8 *rdesc; + unsigned int rsize; + bool invert_pen_inrange; + bool ignore_pen_usage; + bool has_virtual_pad_interface; +}; + +static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int *rsize) +{ + struct usb_interface *iface = to_usb_interface(hdev->dev.parent); + __u8 iface_num = iface->cur_altsetting->desc.bInterfaceNumber; + struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + + if (drvdata->rdesc != NULL) { + rdesc = drvdata->rdesc; + *rsize = drvdata->rsize; + return rdesc; + } + + switch (hdev->product) { + case USB_DEVICE_ID_UCLOGIC_TABLET_PF1209: + if (*rsize == UCLOGIC_RDESC_PF1209_ORIG_SIZE) { + rdesc = uclogic_rdesc_pf1209_fixed_arr; + *rsize = uclogic_rdesc_pf1209_fixed_size; + } + break; + case USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U: + if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) { + rdesc = uclogic_rdesc_wp4030u_fixed_arr; + *rsize = uclogic_rdesc_wp4030u_fixed_size; + } + break; + case USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U: + if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) { + rdesc = uclogic_rdesc_wp5540u_fixed_arr; + *rsize = uclogic_rdesc_wp5540u_fixed_size; + } + break; + case USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U: + if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) { + rdesc = uclogic_rdesc_wp8060u_fixed_arr; + *rsize = uclogic_rdesc_wp8060u_fixed_size; + } + break; + case USB_DEVICE_ID_UCLOGIC_TABLET_WP1062: + if (*rsize == UCLOGIC_RDESC_WP1062_ORIG_SIZE) { + rdesc = uclogic_rdesc_wp1062_fixed_arr; + *rsize = uclogic_rdesc_wp1062_fixed_size; + } + break; + case USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850: + switch (iface_num) { + case 0: + if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG0_SIZE) { + rdesc = uclogic_rdesc_twhl850_fixed0_arr; + *rsize = uclogic_rdesc_twhl850_fixed0_size; + } + break; + case 1: + if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG1_SIZE) { + rdesc = uclogic_rdesc_twhl850_fixed1_arr; + *rsize = uclogic_rdesc_twhl850_fixed1_size; + } + break; + case 2: + if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG2_SIZE) { + rdesc = uclogic_rdesc_twhl850_fixed2_arr; + *rsize = uclogic_rdesc_twhl850_fixed2_size; + } + break; + } + break; + case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60: + switch (iface_num) { + case 0: + if (*rsize == UCLOGIC_RDESC_TWHA60_ORIG0_SIZE) { + rdesc = uclogic_rdesc_twha60_fixed0_arr; + *rsize = uclogic_rdesc_twha60_fixed0_size; + } + break; + case 1: + if (*rsize == UCLOGIC_RDESC_TWHA60_ORIG1_SIZE) { + rdesc = uclogic_rdesc_twha60_fixed1_arr; + *rsize = uclogic_rdesc_twha60_fixed1_size; + } + break; + } + break; + } + + return rdesc; +} + +static int uclogic_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + + /* discard the unused pen interface */ + if ((drvdata->ignore_pen_usage) && + (field->application == HID_DG_PEN)) + return -1; + + /* let hid-core decide what to do */ + return 0; +} + +static int uclogic_input_configured(struct hid_device *hdev, + struct hid_input *hi) +{ + char *name; + const char *suffix = NULL; + struct hid_field *field; + size_t len; + + /* no report associated (HID_QUIRK_MULTI_INPUT not set) */ + if (!hi->report) + return 0; + + field = hi->report->field[0]; + + switch (field->application) { + case HID_GD_KEYBOARD: + suffix = "Keyboard"; + break; + case HID_GD_MOUSE: + suffix = "Mouse"; + break; + case HID_GD_KEYPAD: + suffix = "Pad"; + break; + case HID_DG_PEN: + suffix = "Pen"; + break; + case HID_CP_CONSUMER_CONTROL: + suffix = "Consumer Control"; + break; + case HID_GD_SYSTEM_CONTROL: + suffix = "System Control"; + break; + } + + if (suffix) { + len = strlen(hdev->name) + 2 + strlen(suffix); + name = devm_kzalloc(&hi->input->dev, len, GFP_KERNEL); + if (name) { + snprintf(name, len, "%s %s", hdev->name, suffix); + hi->input->name = name; + } + } + + return 0; +} + +/** + * Enable fully-functional tablet mode and determine device parameters. + * + * @hdev: HID device + */ +static int uclogic_tablet_enable(struct hid_device *hdev) +{ + int rc; + struct usb_device *usb_dev = hid_to_usb_dev(hdev); + struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + __le16 *buf = NULL; + size_t len; + s32 params[UCLOGIC_RDESC_PEN_PH_ID_NUM]; + s32 resolution; + + /* + * Read string descriptor containing tablet parameters. The specific + * string descriptor and data were discovered by sniffing the Windows + * driver traffic. + * NOTE: This enables fully-functional tablet mode. + */ + len = UCLOGIC_PRM_NUM * sizeof(*buf); + buf = kmalloc(len, GFP_KERNEL); + if (buf == NULL) { + rc = -ENOMEM; + goto cleanup; + } + rc = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), + USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, + (USB_DT_STRING << 8) + 0x64, + 0x0409, buf, len, + USB_CTRL_GET_TIMEOUT); + if (rc == -EPIPE) { + hid_err(hdev, "device parameters not found\n"); + rc = -ENODEV; + goto cleanup; + } else if (rc < 0) { + hid_err(hdev, "failed to get device parameters: %d\n", rc); + rc = -ENODEV; + goto cleanup; + } else if (rc != len) { + hid_err(hdev, "invalid device parameters\n"); + rc = -ENODEV; + goto cleanup; + } + + /* Extract device parameters */ + params[UCLOGIC_RDESC_PEN_PH_ID_X_LM] = + le16_to_cpu(buf[UCLOGIC_PRM_X_LM]); + params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] = + le16_to_cpu(buf[UCLOGIC_PRM_Y_LM]); + params[UCLOGIC_RDESC_PEN_PH_ID_PRESSURE_LM] = + le16_to_cpu(buf[UCLOGIC_PRM_PRESSURE_LM]); + resolution = le16_to_cpu(buf[UCLOGIC_PRM_RESOLUTION]); + if (resolution == 0) { + params[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = 0; + params[UCLOGIC_RDESC_PEN_PH_ID_Y_PM] = 0; + } else { + params[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = + params[UCLOGIC_RDESC_PEN_PH_ID_X_LM] * + 1000 / resolution; + params[UCLOGIC_RDESC_PEN_PH_ID_Y_PM] = + params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] * + 1000 / resolution; + } + + /* Format fixed report descriptor */ + drvdata->rdesc = uclogic_rdesc_template_apply( + uclogic_rdesc_pen_template_arr, + uclogic_rdesc_pen_template_size, + params, ARRAY_SIZE(params)); + if (drvdata->rdesc == NULL) { + rc = -ENOMEM; + goto cleanup; + } + drvdata->rsize = uclogic_rdesc_pen_template_size; + + rc = 0; + +cleanup: + kfree(buf); + return rc; +} + +/** + * Enable actual button mode. + * + * @hdev: HID device + */ +static int uclogic_button_enable(struct hid_device *hdev) +{ + int rc; + struct usb_device *usb_dev = hid_to_usb_dev(hdev); + struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + char *str_buf; + size_t str_len = 16; + unsigned char *rdesc; + size_t rdesc_len; + + str_buf = kzalloc(str_len, GFP_KERNEL); + if (str_buf == NULL) { + rc = -ENOMEM; + goto cleanup; + } + + /* Enable abstract keyboard mode */ + rc = usb_string(usb_dev, 0x7b, str_buf, str_len); + if (rc == -EPIPE) { + hid_info(hdev, "button mode setting not found\n"); + rc = 0; + goto cleanup; + } else if (rc < 0) { + hid_err(hdev, "failed to enable abstract keyboard\n"); + goto cleanup; + } else if (strncmp(str_buf, "HK On", rc)) { + hid_info(hdev, "invalid answer when requesting buttons: '%s'\n", + str_buf); + rc = -EINVAL; + goto cleanup; + } + + /* Re-allocate fixed report descriptor */ + rdesc_len = drvdata->rsize + uclogic_rdesc_buttonpad_size; + rdesc = devm_kzalloc(&hdev->dev, rdesc_len, GFP_KERNEL); + if (!rdesc) { + rc = -ENOMEM; + goto cleanup; + } + + memcpy(rdesc, drvdata->rdesc, drvdata->rsize); + + /* Append the buttonpad descriptor */ + memcpy(rdesc + drvdata->rsize, uclogic_rdesc_buttonpad_arr, + uclogic_rdesc_buttonpad_size); + + /* clean up old rdesc and use the new one */ + drvdata->rsize = rdesc_len; + devm_kfree(&hdev->dev, drvdata->rdesc); + drvdata->rdesc = rdesc; + + rc = 0; + +cleanup: + kfree(str_buf); + return rc; +} + +static int uclogic_probe(struct hid_device *hdev, + const struct hid_device_id *id) +{ + int rc; + struct usb_interface *intf = to_usb_interface(hdev->dev.parent); + struct usb_device *udev = hid_to_usb_dev(hdev); + struct uclogic_drvdata *drvdata; + + /* + * libinput requires the pad interface to be on a different node + * than the pen, so use QUIRK_MULTI_INPUT for all tablets. + */ + hdev->quirks |= HID_QUIRK_MULTI_INPUT; + + /* Allocate and assign driver data */ + drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL); + if (drvdata == NULL) + return -ENOMEM; + + hid_set_drvdata(hdev, drvdata); + + switch (id->product) { + case USB_DEVICE_ID_HUION_TABLET: + case USB_DEVICE_ID_YIYNOVA_TABLET: + case USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81: + case USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3: + case USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45: + /* If this is the pen interface */ + if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { + rc = uclogic_tablet_enable(hdev); + if (rc) { + hid_err(hdev, "tablet enabling failed\n"); + return rc; + } + drvdata->invert_pen_inrange = true; + + rc = uclogic_button_enable(hdev); + drvdata->has_virtual_pad_interface = !rc; + } else { + drvdata->ignore_pen_usage = true; + } + break; + case USB_DEVICE_ID_UGTIZER_TABLET_GP0610: + case USB_DEVICE_ID_UGEE_TABLET_EX07S: + /* If this is the pen interface */ + if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { + rc = uclogic_tablet_enable(hdev); + if (rc) { + hid_err(hdev, "tablet enabling failed\n"); + return rc; + } + drvdata->invert_pen_inrange = true; + } else { + drvdata->ignore_pen_usage = true; + } + break; + case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60: + /* + * If it is the three-interface version, which is known to + * respond to initialization. + */ + if (udev->config->desc.bNumInterfaces == 3) { + /* If it is the pen interface */ + if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { + rc = uclogic_tablet_enable(hdev); + if (rc) { + hid_err(hdev, "tablet enabling failed\n"); + return rc; + } + drvdata->invert_pen_inrange = true; + + rc = uclogic_button_enable(hdev); + drvdata->has_virtual_pad_interface = !rc; + } else { + drvdata->ignore_pen_usage = true; + } + } + break; + } + + rc = hid_parse(hdev); + if (rc) { + hid_err(hdev, "parse failed\n"); + return rc; + } + + rc = hid_hw_start(hdev, HID_CONNECT_DEFAULT); + if (rc) { + hid_err(hdev, "hw start failed\n"); + return rc; + } + + return 0; +} + +static int uclogic_raw_event(struct hid_device *hdev, struct hid_report *report, + u8 *data, int size) +{ + struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + + if ((report->type == HID_INPUT_REPORT) && + (report->id == UCLOGIC_RDESC_PEN_ID) && + (size >= 2)) { + if (drvdata->has_virtual_pad_interface && (data[1] & 0x20)) + /* Change to virtual frame button report ID */ + data[0] = 0xf7; + else if (drvdata->invert_pen_inrange) + /* Invert the in-range bit */ + data[1] ^= 0x40; + } + + return 0; +} + +static const struct hid_device_id uclogic_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) }, + { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_HUION_TABLET) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, + { } +}; +MODULE_DEVICE_TABLE(hid, uclogic_devices); + +static struct hid_driver uclogic_driver = { + .name = "uclogic", + .id_table = uclogic_devices, + .probe = uclogic_probe, + .report_fixup = uclogic_report_fixup, + .raw_event = uclogic_raw_event, + .input_mapping = uclogic_input_mapping, + .input_configured = uclogic_input_configured, +}; +module_hid_driver(uclogic_driver); + +MODULE_AUTHOR("Martin Rusko"); +MODULE_AUTHOR("Nikolai Kondrashov"); +MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-uclogic.c b/drivers/hid/hid-uclogic-rdesc.c similarity index 66% rename from drivers/hid/hid-uclogic.c rename to drivers/hid/hid-uclogic-rdesc.c index fdc4d1ea7049..e9053d28f4e0 100644 --- a/drivers/hid/hid-uclogic.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -1,7 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * HID driver for UC-Logic devices not fully compliant with HID standard + * - original and fixed report descriptors * - * Copyright (c) 2010-2014 Nikolai Kondrashov + * Copyright (c) 2010-2017 Nikolai Kondrashov * Copyright (c) 2013 Martin Rusko */ @@ -12,20 +14,12 @@ * any later version. */ -#include -#include -#include -#include +#include "hid-uclogic-rdesc.h" +#include #include -#include "usbhid/usbhid.h" - -#include "hid-ids.h" - -/* Size of the original descriptor of WPXXXXU tablets */ -#define WPXXXXU_RDESC_ORIG_SIZE 212 /* Fixed WP4030U report descriptor */ -static __u8 wp4030u_rdesc_fixed[] = { +__u8 uclogic_rdesc_wp4030u_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -66,8 +60,11 @@ static __u8 wp4030u_rdesc_fixed[] = { 0xC0 /* End Collection */ }; +const size_t uclogic_rdesc_wp4030u_fixed_size = + sizeof(uclogic_rdesc_wp4030u_fixed_arr); + /* Fixed WP5540U report descriptor */ -static __u8 wp5540u_rdesc_fixed[] = { +__u8 uclogic_rdesc_wp5540u_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -140,8 +137,11 @@ static __u8 wp5540u_rdesc_fixed[] = { 0xC0 /* End Collection */ }; +const size_t uclogic_rdesc_wp5540u_fixed_size = + sizeof(uclogic_rdesc_wp5540u_fixed_arr); + /* Fixed WP8060U report descriptor */ -static __u8 wp8060u_rdesc_fixed[] = { +__u8 uclogic_rdesc_wp8060u_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -214,11 +214,11 @@ static __u8 wp8060u_rdesc_fixed[] = { 0xC0 /* End Collection */ }; -/* Size of the original descriptor of WP1062 tablet */ -#define WP1062_RDESC_ORIG_SIZE 254 +const size_t uclogic_rdesc_wp8060u_fixed_size = + sizeof(uclogic_rdesc_wp8060u_fixed_arr); /* Fixed WP1062 report descriptor */ -static __u8 wp1062_rdesc_fixed[] = { +__u8 uclogic_rdesc_wp1062_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -262,11 +262,11 @@ static __u8 wp1062_rdesc_fixed[] = { 0xC0 /* End Collection */ }; -/* Size of the original descriptor of PF1209 tablet */ -#define PF1209_RDESC_ORIG_SIZE 234 +const size_t uclogic_rdesc_wp1062_fixed_size = + sizeof(uclogic_rdesc_wp1062_fixed_arr); /* Fixed PF1209 report descriptor */ -static __u8 pf1209_rdesc_fixed[] = { +__u8 uclogic_rdesc_pf1209_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -339,13 +339,11 @@ static __u8 pf1209_rdesc_fixed[] = { 0xC0 /* End Collection */ }; -/* Size of the original descriptors of TWHL850 tablet */ -#define TWHL850_RDESC_ORIG_SIZE0 182 -#define TWHL850_RDESC_ORIG_SIZE1 161 -#define TWHL850_RDESC_ORIG_SIZE2 92 +const size_t uclogic_rdesc_pf1209_fixed_size = + sizeof(uclogic_rdesc_pf1209_fixed_arr); /* Fixed PID 0522 tablet report descriptor, interface 0 (stylus) */ -static __u8 twhl850_rdesc_fixed0[] = { +__u8 uclogic_rdesc_twhl850_fixed0_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -387,8 +385,11 @@ static __u8 twhl850_rdesc_fixed0[] = { 0xC0 /* End Collection */ }; +const size_t uclogic_rdesc_twhl850_fixed0_size = + sizeof(uclogic_rdesc_twhl850_fixed0_arr); + /* Fixed PID 0522 tablet report descriptor, interface 1 (mouse) */ -static __u8 twhl850_rdesc_fixed1[] = { +__u8 uclogic_rdesc_twhl850_fixed1_arr[] = { 0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x02, /* Usage (Mouse), */ 0xA1, 0x01, /* Collection (Application), */ @@ -424,8 +425,11 @@ static __u8 twhl850_rdesc_fixed1[] = { 0xC0 /* End Collection */ }; +const size_t uclogic_rdesc_twhl850_fixed1_size = + sizeof(uclogic_rdesc_twhl850_fixed1_arr); + /* Fixed PID 0522 tablet report descriptor, interface 2 (frame buttons) */ -static __u8 twhl850_rdesc_fixed2[] = { +__u8 uclogic_rdesc_twhl850_fixed2_arr[] = { 0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x06, /* Usage (Keyboard), */ 0xA1, 0x01, /* Collection (Application), */ @@ -447,12 +451,11 @@ static __u8 twhl850_rdesc_fixed2[] = { 0xC0 /* End Collection */ }; -/* Size of the original descriptors of TWHA60 tablet */ -#define TWHA60_RDESC_ORIG_SIZE0 254 -#define TWHA60_RDESC_ORIG_SIZE1 139 +const size_t uclogic_rdesc_twhl850_fixed2_size = + sizeof(uclogic_rdesc_twhl850_fixed2_arr); /* Fixed TWHA60 report descriptor, interface 0 (stylus) */ -static __u8 twha60_rdesc_fixed0[] = { +__u8 uclogic_rdesc_twha60_fixed0_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -497,8 +500,11 @@ static __u8 twha60_rdesc_fixed0[] = { 0xC0 /* End Collection */ }; +const size_t uclogic_rdesc_twha60_fixed0_size = + sizeof(uclogic_rdesc_twha60_fixed0_arr); + /* Fixed TWHA60 report descriptor, interface 1 (frame buttons) */ -static __u8 twha60_rdesc_fixed1[] = { +__u8 uclogic_rdesc_twha60_fixed1_arr[] = { 0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x06, /* Usage (Keyboard), */ 0xA1, 0x01, /* Collection (Application), */ @@ -522,25 +528,11 @@ static __u8 twha60_rdesc_fixed1[] = { 0xC0 /* End Collection */ }; -/* Report descriptor template placeholder head */ -#define UCLOGIC_PH_HEAD 0xFE, 0xED, 0x1D +const size_t uclogic_rdesc_twha60_fixed1_size = + sizeof(uclogic_rdesc_twha60_fixed1_arr); -/* Report descriptor template placeholder IDs */ -enum uclogic_ph_id { - UCLOGIC_PH_ID_X_LM, - UCLOGIC_PH_ID_X_PM, - UCLOGIC_PH_ID_Y_LM, - UCLOGIC_PH_ID_Y_PM, - UCLOGIC_PH_ID_PRESSURE_LM, - UCLOGIC_PH_ID_NUM -}; - -/* Report descriptor template placeholder */ -#define UCLOGIC_PH(_ID) UCLOGIC_PH_HEAD, UCLOGIC_PH_ID_##_ID -#define UCLOGIC_PEN_REPORT_ID 0x07 - -/* Fixed report descriptor template */ -static const __u8 uclogic_tablet_rdesc_template[] = { +/* Fixed report descriptor template for (tweaked) pen reports */ +const __u8 uclogic_rdesc_pen_template_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -570,521 +562,122 @@ static const __u8 uclogic_tablet_rdesc_template[] = { 0x55, 0xFD, /* Unit Exponent (-3), */ 0x34, /* Physical Minimum (0), */ 0x09, 0x30, /* Usage (X), */ - 0x27, UCLOGIC_PH(X_LM), /* Logical Maximum (PLACEHOLDER), */ - 0x47, UCLOGIC_PH(X_PM), /* Physical Maximum (PLACEHOLDER), */ + 0x27, UCLOGIC_RDESC_PEN_PH(X_LM), + /* Logical Maximum (PLACEHOLDER), */ + 0x47, UCLOGIC_RDESC_PEN_PH(X_PM), + /* Physical Maximum (PLACEHOLDER), */ 0x81, 0x02, /* Input (Variable), */ 0x09, 0x31, /* Usage (Y), */ - 0x27, UCLOGIC_PH(Y_LM), /* Logical Maximum (PLACEHOLDER), */ - 0x47, UCLOGIC_PH(Y_PM), /* Physical Maximum (PLACEHOLDER), */ + 0x27, UCLOGIC_RDESC_PEN_PH(Y_LM), + /* Logical Maximum (PLACEHOLDER), */ + 0x47, UCLOGIC_RDESC_PEN_PH(Y_PM), + /* Physical Maximum (PLACEHOLDER), */ 0x81, 0x02, /* Input (Variable), */ 0xB4, /* Pop, */ 0x09, 0x30, /* Usage (Tip Pressure), */ - 0x27, - UCLOGIC_PH(PRESSURE_LM),/* Logical Maximum (PLACEHOLDER), */ + 0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM), + /* Logical Maximum (PLACEHOLDER), */ 0x81, 0x02, /* Input (Variable), */ 0xC0, /* End Collection, */ 0xC0 /* End Collection */ }; -/* Fixed virtual pad report descriptor */ -static const __u8 uclogic_buttonpad_rdesc[] = { - 0x05, 0x01, /* Usage Page (Desktop), */ - 0x09, 0x07, /* Usage (Keypad), */ - 0xA1, 0x01, /* Collection (Application), */ - 0x85, 0xF7, /* Report ID (247), */ - 0x05, 0x0D, /* Usage Page (Digitizers), */ - 0x09, 0x39, /* Usage (Tablet Function Keys), */ - 0xA0, /* Collection (Physical), */ - 0x05, 0x09, /* Usage Page (Button), */ - 0x75, 0x01, /* Report Size (1), */ - 0x95, 0x18, /* Report Count (24), */ - 0x81, 0x03, /* Input (Constant, Variable), */ - 0x19, 0x01, /* Usage Minimum (01h), */ - 0x29, 0x08, /* Usage Maximum (08h), */ - 0x95, 0x08, /* Report Count (8), */ - 0x81, 0x02, /* Input (Variable), */ - 0xC0, /* End Collection */ - 0xC0 /* End Collection */ -}; - -/* Parameter indices */ -enum uclogic_prm { - UCLOGIC_PRM_X_LM = 1, - UCLOGIC_PRM_Y_LM = 2, - UCLOGIC_PRM_PRESSURE_LM = 4, - UCLOGIC_PRM_RESOLUTION = 5, - UCLOGIC_PRM_NUM -}; +const size_t uclogic_rdesc_pen_template_size = + sizeof(uclogic_rdesc_pen_template_arr); -/* Driver data */ -struct uclogic_drvdata { - __u8 *rdesc; - unsigned int rsize; - bool invert_pen_inrange; - bool ignore_pen_usage; - bool has_virtual_pad_interface; +/** + * Expand to the contents of a generic buttonpad report descriptor. + * + * @_padding: Padding from the end of button bits at bit 44, until + * the end of the report, in bits. + */ +#define UCLOGIC_RDESC_BUTTONPAD_BYTES(_padding) \ + 0x05, 0x01, /* Usage Page (Desktop), */ \ + 0x09, 0x07, /* Usage (Keypad), */ \ + 0xA1, 0x01, /* Collection (Application), */ \ + 0x85, 0xF7, /* Report ID (247), */ \ + 0x14, /* Logical Minimum (0), */ \ + 0x25, 0x01, /* Logical Maximum (1), */ \ + 0x75, 0x01, /* Report Size (1), */ \ + 0x05, 0x0D, /* Usage Page (Digitizer), */ \ + 0x09, 0x39, /* Usage (Tablet Function Keys), */ \ + 0xA0, /* Collection (Physical), */ \ + 0x09, 0x44, /* Usage (Barrel Switch), */ \ + 0x95, 0x01, /* Report Count (1), */ \ + 0x81, 0x02, /* Input (Variable), */ \ + 0x05, 0x01, /* Usage Page (Desktop), */ \ + 0x09, 0x30, /* Usage (X), */ \ + 0x09, 0x31, /* Usage (Y), */ \ + 0x95, 0x02, /* Report Count (2), */ \ + 0x81, 0x02, /* Input (Variable), */ \ + 0x95, 0x15, /* Report Count (21), */ \ + 0x81, 0x01, /* Input (Constant), */ \ + 0x05, 0x09, /* Usage Page (Button), */ \ + 0x19, 0x01, /* Usage Minimum (01h), */ \ + 0x29, 0x0A, /* Usage Maximum (0Ah), */ \ + 0x95, 0x0A, /* Report Count (10), */ \ + 0x81, 0x02, /* Input (Variable), */ \ + 0xC0, /* End Collection, */ \ + 0x05, 0x01, /* Usage Page (Desktop), */ \ + 0x09, 0x05, /* Usage (Gamepad), */ \ + 0xA0, /* Collection (Physical), */ \ + 0x05, 0x09, /* Usage Page (Button), */ \ + 0x19, 0x01, /* Usage Minimum (01h), */ \ + 0x29, 0x02, /* Usage Maximum (02h), */ \ + 0x95, 0x02, /* Report Count (2), */ \ + 0x81, 0x02, /* Input (Variable), */ \ + 0x95, _padding, /* Report Count (_padding), */ \ + 0x81, 0x01, /* Input (Constant), */ \ + 0xC0, /* End Collection, */ \ + 0xC0 /* End Collection */ + +/* Fixed report descriptor for (tweaked) buttonpad reports */ +const __u8 uclogic_rdesc_buttonpad_arr[] = { + UCLOGIC_RDESC_BUTTONPAD_BYTES(20) }; - -static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc, - unsigned int *rsize) -{ - struct usb_interface *iface = to_usb_interface(hdev->dev.parent); - __u8 iface_num = iface->cur_altsetting->desc.bInterfaceNumber; - struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); - - if (drvdata->rdesc != NULL) { - rdesc = drvdata->rdesc; - *rsize = drvdata->rsize; - return rdesc; - } - - switch (hdev->product) { - case USB_DEVICE_ID_UCLOGIC_TABLET_PF1209: - if (*rsize == PF1209_RDESC_ORIG_SIZE) { - rdesc = pf1209_rdesc_fixed; - *rsize = sizeof(pf1209_rdesc_fixed); - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U: - if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) { - rdesc = wp4030u_rdesc_fixed; - *rsize = sizeof(wp4030u_rdesc_fixed); - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U: - if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) { - rdesc = wp5540u_rdesc_fixed; - *rsize = sizeof(wp5540u_rdesc_fixed); - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U: - if (*rsize == WPXXXXU_RDESC_ORIG_SIZE) { - rdesc = wp8060u_rdesc_fixed; - *rsize = sizeof(wp8060u_rdesc_fixed); - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_WP1062: - if (*rsize == WP1062_RDESC_ORIG_SIZE) { - rdesc = wp1062_rdesc_fixed; - *rsize = sizeof(wp1062_rdesc_fixed); - } - break; - case USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850: - switch (iface_num) { - case 0: - if (*rsize == TWHL850_RDESC_ORIG_SIZE0) { - rdesc = twhl850_rdesc_fixed0; - *rsize = sizeof(twhl850_rdesc_fixed0); - } - break; - case 1: - if (*rsize == TWHL850_RDESC_ORIG_SIZE1) { - rdesc = twhl850_rdesc_fixed1; - *rsize = sizeof(twhl850_rdesc_fixed1); - } - break; - case 2: - if (*rsize == TWHL850_RDESC_ORIG_SIZE2) { - rdesc = twhl850_rdesc_fixed2; - *rsize = sizeof(twhl850_rdesc_fixed2); - } - break; - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60: - switch (iface_num) { - case 0: - if (*rsize == TWHA60_RDESC_ORIG_SIZE0) { - rdesc = twha60_rdesc_fixed0; - *rsize = sizeof(twha60_rdesc_fixed0); - } - break; - case 1: - if (*rsize == TWHA60_RDESC_ORIG_SIZE1) { - rdesc = twha60_rdesc_fixed1; - *rsize = sizeof(twha60_rdesc_fixed1); - } - break; - } - break; - } - - return rdesc; -} - -static int uclogic_input_mapping(struct hid_device *hdev, struct hid_input *hi, - struct hid_field *field, struct hid_usage *usage, - unsigned long **bit, int *max) -{ - struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); - - /* discard the unused pen interface */ - if ((drvdata->ignore_pen_usage) && - (field->application == HID_DG_PEN)) - return -1; - - /* let hid-core decide what to do */ - return 0; -} - -static int uclogic_input_configured(struct hid_device *hdev, - struct hid_input *hi) -{ - char *name; - const char *suffix = NULL; - struct hid_field *field; - size_t len; - - /* no report associated (HID_QUIRK_MULTI_INPUT not set) */ - if (!hi->report) - return 0; - - field = hi->report->field[0]; - - switch (field->application) { - case HID_GD_KEYBOARD: - suffix = "Keyboard"; - break; - case HID_GD_MOUSE: - suffix = "Mouse"; - break; - case HID_GD_KEYPAD: - suffix = "Pad"; - break; - case HID_DG_PEN: - suffix = "Pen"; - break; - case HID_CP_CONSUMER_CONTROL: - suffix = "Consumer Control"; - break; - case HID_GD_SYSTEM_CONTROL: - suffix = "System Control"; - break; - } - - if (suffix) { - len = strlen(hdev->name) + 2 + strlen(suffix); - name = devm_kzalloc(&hi->input->dev, len, GFP_KERNEL); - if (name) { - snprintf(name, len, "%s %s", hdev->name, suffix); - hi->input->name = name; - } - } - - return 0; -} +const size_t uclogic_rdesc_buttonpad_size = + sizeof(uclogic_rdesc_buttonpad_arr); /** - * Enable fully-functional tablet mode and determine device parameters. + * uclogic_rdesc_template_apply() - apply report descriptor parameters to a + * report descriptor template, creating a report descriptor. Copies the + * template over to the new report descriptor and replaces every occurrence of + * UCLOGIC_RDESC_PH_HEAD, followed by an index byte, with the value from the + * parameter list at that index. + * + * @template_ptr: Pointer to the template buffer. + * @template_size: Size of the template buffer. + * @param_list: List of template parameters. + * @param_num: Number of parameters in the list. * - * @hdev: HID device + * Returns: + * Kmalloc-allocated pointer to the created report descriptor, + * or NULL if allocation failed. */ -static int uclogic_tablet_enable(struct hid_device *hdev) +__u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr, + size_t template_size, + const s32 *param_list, + size_t param_num) { - int rc; - struct usb_device *usb_dev = hid_to_usb_dev(hdev); - struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); - __le16 *buf = NULL; - size_t len; - s32 params[UCLOGIC_PH_ID_NUM]; - s32 resolution; + static const __u8 head[] = {UCLOGIC_RDESC_PH_HEAD}; + __u8 *rdesc_ptr; __u8 *p; s32 v; - /* - * Read string descriptor containing tablet parameters. The specific - * string descriptor and data were discovered by sniffing the Windows - * driver traffic. - * NOTE: This enables fully-functional tablet mode. - */ - len = UCLOGIC_PRM_NUM * sizeof(*buf); - buf = kmalloc(len, GFP_KERNEL); - if (buf == NULL) { - rc = -ENOMEM; - goto cleanup; - } - rc = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), - USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, - (USB_DT_STRING << 8) + 0x64, - 0x0409, buf, len, - USB_CTRL_GET_TIMEOUT); - if (rc == -EPIPE) { - hid_err(hdev, "device parameters not found\n"); - rc = -ENODEV; - goto cleanup; - } else if (rc < 0) { - hid_err(hdev, "failed to get device parameters: %d\n", rc); - rc = -ENODEV; - goto cleanup; - } else if (rc != len) { - hid_err(hdev, "invalid device parameters\n"); - rc = -ENODEV; - goto cleanup; - } - - /* Extract device parameters */ - params[UCLOGIC_PH_ID_X_LM] = le16_to_cpu(buf[UCLOGIC_PRM_X_LM]); - params[UCLOGIC_PH_ID_Y_LM] = le16_to_cpu(buf[UCLOGIC_PRM_Y_LM]); - params[UCLOGIC_PH_ID_PRESSURE_LM] = - le16_to_cpu(buf[UCLOGIC_PRM_PRESSURE_LM]); - resolution = le16_to_cpu(buf[UCLOGIC_PRM_RESOLUTION]); - if (resolution == 0) { - params[UCLOGIC_PH_ID_X_PM] = 0; - params[UCLOGIC_PH_ID_Y_PM] = 0; - } else { - params[UCLOGIC_PH_ID_X_PM] = params[UCLOGIC_PH_ID_X_LM] * - 1000 / resolution; - params[UCLOGIC_PH_ID_Y_PM] = params[UCLOGIC_PH_ID_Y_LM] * - 1000 / resolution; - } + rdesc_ptr = kmemdup(template_ptr, template_size, GFP_KERNEL); + if (rdesc_ptr == NULL) + return NULL; - /* Allocate fixed report descriptor */ - drvdata->rdesc = devm_kzalloc(&hdev->dev, - sizeof(uclogic_tablet_rdesc_template), - GFP_KERNEL); - if (drvdata->rdesc == NULL) { - rc = -ENOMEM; - goto cleanup; - } - drvdata->rsize = sizeof(uclogic_tablet_rdesc_template); - - /* Format fixed report descriptor */ - memcpy(drvdata->rdesc, uclogic_tablet_rdesc_template, - drvdata->rsize); - for (p = drvdata->rdesc; - p <= drvdata->rdesc + drvdata->rsize - 4;) { - if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D && - p[3] < ARRAY_SIZE(params)) { - v = params[p[3]]; + for (p = rdesc_ptr; p + sizeof(head) < rdesc_ptr + template_size;) { + if (memcmp(p, head, sizeof(head)) == 0 && + p[sizeof(head)] < param_num) { + v = param_list[p[sizeof(head)]]; put_unaligned(cpu_to_le32(v), (s32 *)p); - p += 4; + p += sizeof(head) + 1; } else { p++; } } - rc = 0; - -cleanup: - kfree(buf); - return rc; -} - -/** - * Enable actual button mode. - * - * @hdev: HID device - */ -static int uclogic_button_enable(struct hid_device *hdev) -{ - int rc; - struct usb_device *usb_dev = hid_to_usb_dev(hdev); - struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); - char *str_buf; - size_t str_len = 16; - unsigned char *rdesc; - size_t rdesc_len; - - str_buf = kzalloc(str_len, GFP_KERNEL); - if (str_buf == NULL) { - rc = -ENOMEM; - goto cleanup; - } - - /* Enable abstract keyboard mode */ - rc = usb_string(usb_dev, 0x7b, str_buf, str_len); - if (rc == -EPIPE) { - hid_info(hdev, "button mode setting not found\n"); - rc = 0; - goto cleanup; - } else if (rc < 0) { - hid_err(hdev, "failed to enable abstract keyboard\n"); - goto cleanup; - } else if (strncmp(str_buf, "HK On", rc)) { - hid_info(hdev, "invalid answer when requesting buttons: '%s'\n", - str_buf); - rc = -EINVAL; - goto cleanup; - } - - /* Re-allocate fixed report descriptor */ - rdesc_len = drvdata->rsize + sizeof(uclogic_buttonpad_rdesc); - rdesc = devm_kzalloc(&hdev->dev, rdesc_len, GFP_KERNEL); - if (!rdesc) { - rc = -ENOMEM; - goto cleanup; - } - - memcpy(rdesc, drvdata->rdesc, drvdata->rsize); - - /* Append the buttonpad descriptor */ - memcpy(rdesc + drvdata->rsize, uclogic_buttonpad_rdesc, - sizeof(uclogic_buttonpad_rdesc)); - - /* clean up old rdesc and use the new one */ - drvdata->rsize = rdesc_len; - devm_kfree(&hdev->dev, drvdata->rdesc); - drvdata->rdesc = rdesc; - - rc = 0; - -cleanup: - kfree(str_buf); - return rc; -} - -static int uclogic_probe(struct hid_device *hdev, - const struct hid_device_id *id) -{ - int rc; - struct usb_interface *intf = to_usb_interface(hdev->dev.parent); - struct usb_device *udev = hid_to_usb_dev(hdev); - struct uclogic_drvdata *drvdata; - - /* - * libinput requires the pad interface to be on a different node - * than the pen, so use QUIRK_MULTI_INPUT for all tablets. - */ - hdev->quirks |= HID_QUIRK_MULTI_INPUT; - - /* Allocate and assign driver data */ - drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL); - if (drvdata == NULL) - return -ENOMEM; - - hid_set_drvdata(hdev, drvdata); - - switch (id->product) { - case USB_DEVICE_ID_HUION_TABLET: - case USB_DEVICE_ID_YIYNOVA_TABLET: - case USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81: - case USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3: - case USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45: - /* If this is the pen interface */ - if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { - rc = uclogic_tablet_enable(hdev); - if (rc) { - hid_err(hdev, "tablet enabling failed\n"); - return rc; - } - drvdata->invert_pen_inrange = true; - - rc = uclogic_button_enable(hdev); - drvdata->has_virtual_pad_interface = !rc; - } else { - drvdata->ignore_pen_usage = true; - } - break; - case USB_DEVICE_ID_UGTIZER_TABLET_GP0610: - case USB_DEVICE_ID_UGEE_TABLET_EX07S: - /* If this is the pen interface */ - if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { - rc = uclogic_tablet_enable(hdev); - if (rc) { - hid_err(hdev, "tablet enabling failed\n"); - return rc; - } - drvdata->invert_pen_inrange = true; - } else { - drvdata->ignore_pen_usage = true; - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60: - /* - * If it is the three-interface version, which is known to - * respond to initialization. - */ - if (udev->config->desc.bNumInterfaces == 3) { - /* If it is the pen interface */ - if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { - rc = uclogic_tablet_enable(hdev); - if (rc) { - hid_err(hdev, "tablet enabling failed\n"); - return rc; - } - drvdata->invert_pen_inrange = true; - - rc = uclogic_button_enable(hdev); - drvdata->has_virtual_pad_interface = !rc; - } else { - drvdata->ignore_pen_usage = true; - } - } - break; - } - - rc = hid_parse(hdev); - if (rc) { - hid_err(hdev, "parse failed\n"); - return rc; - } - - rc = hid_hw_start(hdev, HID_CONNECT_DEFAULT); - if (rc) { - hid_err(hdev, "hw start failed\n"); - return rc; - } - - return 0; + return rdesc_ptr; } - -static int uclogic_raw_event(struct hid_device *hdev, struct hid_report *report, - u8 *data, int size) -{ - struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); - - if ((report->type == HID_INPUT_REPORT) && - (report->id == UCLOGIC_PEN_REPORT_ID) && - (size >= 2)) { - if (drvdata->has_virtual_pad_interface && (data[1] & 0x20)) - /* Change to virtual frame button report ID */ - data[0] = 0xf7; - else if (drvdata->invert_pen_inrange) - /* Invert the in-range bit */ - data[1] ^= 0x40; - } - - return 0; -} - -static const struct hid_device_id uclogic_devices[] = { - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, - USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, - USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, - USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, - USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, - USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, - USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, - USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) }, - { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_HUION_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, - { } -}; -MODULE_DEVICE_TABLE(hid, uclogic_devices); - -static struct hid_driver uclogic_driver = { - .name = "uclogic", - .id_table = uclogic_devices, - .probe = uclogic_probe, - .report_fixup = uclogic_report_fixup, - .raw_event = uclogic_raw_event, - .input_mapping = uclogic_input_mapping, - .input_configured = uclogic_input_configured, -}; -module_hid_driver(uclogic_driver); - -MODULE_AUTHOR("Martin Rusko"); -MODULE_AUTHOR("Nikolai Kondrashov"); -MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h new file mode 100644 index 000000000000..610575879522 --- /dev/null +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -0,0 +1,117 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * HID driver for UC-Logic devices not fully compliant with HID standard + * - original and fixed report descriptors + * + * Copyright (c) 2010-2018 Nikolai Kondrashov + * Copyright (c) 2013 Martin Rusko + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#ifndef _HID_UCLOGIC_RDESC_H +#define _HID_UCLOGIC_RDESC_H + +#include + +/* Size of the original descriptor of WPXXXXU tablets */ +#define UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE 212 + +/* Fixed WP4030U report descriptor */ +extern __u8 uclogic_rdesc_wp4030u_fixed_arr[]; +extern const size_t uclogic_rdesc_wp4030u_fixed_size; + +/* Fixed WP5540U report descriptor */ +extern __u8 uclogic_rdesc_wp5540u_fixed_arr[]; +extern const size_t uclogic_rdesc_wp5540u_fixed_size; + +/* Fixed WP8060U report descriptor */ +extern __u8 uclogic_rdesc_wp8060u_fixed_arr[]; +extern const size_t uclogic_rdesc_wp8060u_fixed_size; + +/* Size of the original descriptor of WP1062 tablet */ +#define UCLOGIC_RDESC_WP1062_ORIG_SIZE 254 + +/* Fixed WP1062 report descriptor */ +extern __u8 uclogic_rdesc_wp1062_fixed_arr[]; +extern const size_t uclogic_rdesc_wp1062_fixed_size; + +/* Size of the original descriptor of PF1209 tablet */ +#define UCLOGIC_RDESC_PF1209_ORIG_SIZE 234 + +/* Fixed PF1209 report descriptor */ +extern __u8 uclogic_rdesc_pf1209_fixed_arr[]; +extern const size_t uclogic_rdesc_pf1209_fixed_size; + +/* Size of the original descriptors of TWHL850 tablet */ +#define UCLOGIC_RDESC_TWHL850_ORIG0_SIZE 182 +#define UCLOGIC_RDESC_TWHL850_ORIG1_SIZE 161 +#define UCLOGIC_RDESC_TWHL850_ORIG2_SIZE 92 + +/* Fixed PID 0522 tablet report descriptor, interface 0 (stylus) */ +extern __u8 uclogic_rdesc_twhl850_fixed0_arr[]; +extern const size_t uclogic_rdesc_twhl850_fixed0_size; + +/* Fixed PID 0522 tablet report descriptor, interface 1 (mouse) */ +extern __u8 uclogic_rdesc_twhl850_fixed1_arr[]; +extern const size_t uclogic_rdesc_twhl850_fixed1_size; + +/* Fixed PID 0522 tablet report descriptor, interface 2 (frame buttons) */ +extern __u8 uclogic_rdesc_twhl850_fixed2_arr[]; +extern const size_t uclogic_rdesc_twhl850_fixed2_size; + +/* Size of the original descriptors of TWHA60 tablet */ +#define UCLOGIC_RDESC_TWHA60_ORIG0_SIZE 254 +#define UCLOGIC_RDESC_TWHA60_ORIG1_SIZE 139 + +/* Fixed TWHA60 report descriptor, interface 0 (stylus) */ +extern __u8 uclogic_rdesc_twha60_fixed0_arr[]; +extern const size_t uclogic_rdesc_twha60_fixed0_size; + +/* Fixed TWHA60 report descriptor, interface 1 (frame buttons) */ +extern __u8 uclogic_rdesc_twha60_fixed1_arr[]; +extern const size_t uclogic_rdesc_twha60_fixed1_size; + +/* Report descriptor template placeholder head */ +#define UCLOGIC_RDESC_PH_HEAD 0xFE, 0xED, 0x1D + +/* Apply report descriptor parameters to a report descriptor template */ +extern __u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr, + size_t template_size, + const s32 *param_list, + size_t param_num); + +/* Pen report descriptor template placeholder IDs */ +enum uclogic_rdesc_pen_ph_id { + UCLOGIC_RDESC_PEN_PH_ID_X_LM, + UCLOGIC_RDESC_PEN_PH_ID_X_PM, + UCLOGIC_RDESC_PEN_PH_ID_Y_LM, + UCLOGIC_RDESC_PEN_PH_ID_Y_PM, + UCLOGIC_RDESC_PEN_PH_ID_PRESSURE_LM, + UCLOGIC_RDESC_PEN_PH_ID_NUM +}; + +/* Report descriptor pen template placeholder */ +#define UCLOGIC_RDESC_PEN_PH(_ID) \ + UCLOGIC_RDESC_PH_HEAD, UCLOGIC_RDESC_PEN_PH_ID_##_ID + +/* Report ID for pen reports */ +#define UCLOGIC_RDESC_PEN_ID 0x07 + +/* Fixed report descriptor template for (tweaked) pen reports */ +extern const __u8 uclogic_rdesc_pen_template_arr[]; +extern const size_t uclogic_rdesc_pen_template_size; + +/* Fixed report descriptor for (tweaked) buttonpad reports */ +extern const __u8 uclogic_rdesc_buttonpad_arr[]; +extern const size_t uclogic_rdesc_buttonpad_size; + +/* Report ID for tweaked buttonpad reports */ +#define UCLOGIC_RDESC_BUTTONPAD_ID 0xf7 + +#endif /* _HID_UCLOGIC_RDESC_H */ From patchwork Sun Feb 10 10:13:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804679 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B68D17FB for ; Sun, 10 Feb 2019 10:14:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0889A29F46 for ; Sun, 10 Feb 2019 10:14:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F113B29F4B; Sun, 10 Feb 2019 10:14:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 4013129F46 for ; Sun, 10 Feb 2019 10:14:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726009AbfBJKOy (ORCPT ); Sun, 10 Feb 2019 05:14:54 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34183 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbfBJKOy (ORCPT ); Sun, 10 Feb 2019 05:14:54 -0500 Received: by mail-lf1-f67.google.com with SMTP id u21so142138lfu.1 for ; Sun, 10 Feb 2019 02:14:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L1hlvyBIhEiffQQhE6mpROq5eouFI+hh1PHWTn56coE=; b=iATkmrvYLlv/6BotvPKni9Ca7IMUK+ghDksiaNEf6w6FMZRTUAwGstXR/s4g4CjUKm lG0zTITpkIsuhI5ol6+aPbcYih4sEcPF9rK9nic0FNl7fHq1irwdOg2xd5A7E6BU34e5 PhhB8BmzJj1LSO8EWma+xtUmfpssmxqIjRgrV2zYMTAQQZiEeQjVdOdioOGn+o3w0p7G VddJQBHFjPqd44NwH74OayNihfsF2+SfCXA8BECqmOIihNUujLUqTgl+cCA0om5aXjQa A1YkbIUpbqRevA9tnNKhq4zdCqiIfjAMc1MupV1Yv8ViCNV8x8HKSE6M41NNB4nK3ZAV WjRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L1hlvyBIhEiffQQhE6mpROq5eouFI+hh1PHWTn56coE=; b=cZNnM01yB3mt5O6tT9pUfHvkdpoECwlfsh7Uq8ERX13inrNWo6TWHswtDFNdj7tNY7 QCc6NjbqcGJ4IkouBOViZ/n/TIC35Wb4sNjMJmK6h18qNYLpTW3o+l3sD7/7qjLKM9/p yL78mFmCgHfV9csHkRdmGGtd6UDVvSwY/ke4JKni2mqTmNwcu2kYI/dHBfZO5SN97Yjt KFifz6umr93kj+/vMnehAojNteo2cBIpvizbHVGcIAx/9vvHMnStqnRJWkwXqbVghN/i iN76yIVVcOeWY4znIqii9LnjF5RYXcp13YPTvEAq6xZLAC9SrsjhRey9d8wokXxykXGQ P8GQ== X-Gm-Message-State: AHQUAuZPSPWtIKXRLqSupj1/vG7oshtHM1kYnZky58G+edRPXHW2ofCM 1lTDOrmodVofN+lG1GIAY/s= X-Google-Smtp-Source: AHgI3IZibqOHdezTMDtb585hCmbCil6zQeQML3viP+/uCRVU2hnFwEipEggZRKAYl88X96GGGwv7wg== X-Received: by 2002:a19:260e:: with SMTP id m14mr14678529lfm.158.1549793689358; Sun, 10 Feb 2019 02:14:49 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:48 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 05/23] HID: uclogic: Extract tablet parameter discovery into a module Date: Sun, 10 Feb 2019 12:13:51 +0200 Message-Id: <20190210101409.3511-6-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Refactor and extract UC-Logic tablet initialization and parameter discovery into a module. For these tablets, the major part of parameter discovery cannot be separated from initialization so they have to be in the same module. Define explicitly and clearly what possible quirks the tablets may have to make the driver implementation easier and simpler. Signed-off-by: Nikolai Kondrashov --- drivers/hid/Makefile | 3 +- drivers/hid/hid-uclogic-core.c | 428 ++++------------ drivers/hid/hid-uclogic-params.c | 806 +++++++++++++++++++++++++++++++ drivers/hid/hid-uclogic-params.h | 180 +++++++ 4 files changed, 1090 insertions(+), 327 deletions(-) create mode 100644 drivers/hid/hid-uclogic-params.c create mode 100644 drivers/hid/hid-uclogic-params.h diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index fb75366ea776..9b3a747af60d 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -109,7 +109,8 @@ obj-$(CONFIG_HID_TIVO) += hid-tivo.o obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o hid-uclogic-objs := hid-uclogic-core.o \ - hid-uclogic-rdesc.o + hid-uclogic-rdesc.o \ + hid-uclogic-params.o obj-$(CONFIG_HID_UCLOGIC) += hid-uclogic.o obj-$(CONFIG_HID_UDRAW_PS3) += hid-udraw-ps3.o obj-$(CONFIG_HID_LED) += hid-led.o diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 4042183ee9a3..72a3a43766cc 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -16,126 +16,48 @@ #include #include #include -#include #include "usbhid/usbhid.h" -#include "hid-uclogic-rdesc.h" +#include "hid-uclogic-params.h" #include "hid-ids.h" -/* Parameter indices */ -enum uclogic_prm { - UCLOGIC_PRM_X_LM = 1, - UCLOGIC_PRM_Y_LM = 2, - UCLOGIC_PRM_PRESSURE_LM = 4, - UCLOGIC_PRM_RESOLUTION = 5, - UCLOGIC_PRM_NUM -}; - /* Driver data */ struct uclogic_drvdata { - __u8 *rdesc; - unsigned int rsize; - bool invert_pen_inrange; - bool ignore_pen_usage; - bool has_virtual_pad_interface; + /* Interface parameters */ + struct uclogic_params params; + /* Pointer to the replacement report descriptor. NULL if none. */ + __u8 *desc_ptr; + /* + * Size of the replacement report descriptor. + * Only valid if desc_ptr is not NULL + */ + unsigned int desc_size; }; static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { - struct usb_interface *iface = to_usb_interface(hdev->dev.parent); - __u8 iface_num = iface->cur_altsetting->desc.bInterfaceNumber; struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); - if (drvdata->rdesc != NULL) { - rdesc = drvdata->rdesc; - *rsize = drvdata->rsize; - return rdesc; - } - - switch (hdev->product) { - case USB_DEVICE_ID_UCLOGIC_TABLET_PF1209: - if (*rsize == UCLOGIC_RDESC_PF1209_ORIG_SIZE) { - rdesc = uclogic_rdesc_pf1209_fixed_arr; - *rsize = uclogic_rdesc_pf1209_fixed_size; - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U: - if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) { - rdesc = uclogic_rdesc_wp4030u_fixed_arr; - *rsize = uclogic_rdesc_wp4030u_fixed_size; - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U: - if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) { - rdesc = uclogic_rdesc_wp5540u_fixed_arr; - *rsize = uclogic_rdesc_wp5540u_fixed_size; - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U: - if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) { - rdesc = uclogic_rdesc_wp8060u_fixed_arr; - *rsize = uclogic_rdesc_wp8060u_fixed_size; - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_WP1062: - if (*rsize == UCLOGIC_RDESC_WP1062_ORIG_SIZE) { - rdesc = uclogic_rdesc_wp1062_fixed_arr; - *rsize = uclogic_rdesc_wp1062_fixed_size; - } - break; - case USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850: - switch (iface_num) { - case 0: - if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG0_SIZE) { - rdesc = uclogic_rdesc_twhl850_fixed0_arr; - *rsize = uclogic_rdesc_twhl850_fixed0_size; - } - break; - case 1: - if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG1_SIZE) { - rdesc = uclogic_rdesc_twhl850_fixed1_arr; - *rsize = uclogic_rdesc_twhl850_fixed1_size; - } - break; - case 2: - if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG2_SIZE) { - rdesc = uclogic_rdesc_twhl850_fixed2_arr; - *rsize = uclogic_rdesc_twhl850_fixed2_size; - } - break; - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60: - switch (iface_num) { - case 0: - if (*rsize == UCLOGIC_RDESC_TWHA60_ORIG0_SIZE) { - rdesc = uclogic_rdesc_twha60_fixed0_arr; - *rsize = uclogic_rdesc_twha60_fixed0_size; - } - break; - case 1: - if (*rsize == UCLOGIC_RDESC_TWHA60_ORIG1_SIZE) { - rdesc = uclogic_rdesc_twha60_fixed1_arr; - *rsize = uclogic_rdesc_twha60_fixed1_size; - } - break; - } - break; + if (drvdata->desc_ptr != NULL) { + rdesc = drvdata->desc_ptr; + *rsize = drvdata->desc_size; } - return rdesc; } -static int uclogic_input_mapping(struct hid_device *hdev, struct hid_input *hi, - struct hid_field *field, struct hid_usage *usage, - unsigned long **bit, int *max) +static int uclogic_input_mapping(struct hid_device *hdev, + struct hid_input *hi, + struct hid_field *field, + struct hid_usage *usage, + unsigned long **bit, + int *max) { struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + struct uclogic_params *params = &drvdata->params; /* discard the unused pen interface */ - if ((drvdata->ignore_pen_usage) && - (field->application == HID_DG_PEN)) + if (params->pen_unused && (field->application == HID_DG_PEN)) return -1; /* let hid-core decide what to do */ @@ -189,160 +111,12 @@ static int uclogic_input_configured(struct hid_device *hdev, return 0; } -/** - * Enable fully-functional tablet mode and determine device parameters. - * - * @hdev: HID device - */ -static int uclogic_tablet_enable(struct hid_device *hdev) -{ - int rc; - struct usb_device *usb_dev = hid_to_usb_dev(hdev); - struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); - __le16 *buf = NULL; - size_t len; - s32 params[UCLOGIC_RDESC_PEN_PH_ID_NUM]; - s32 resolution; - - /* - * Read string descriptor containing tablet parameters. The specific - * string descriptor and data were discovered by sniffing the Windows - * driver traffic. - * NOTE: This enables fully-functional tablet mode. - */ - len = UCLOGIC_PRM_NUM * sizeof(*buf); - buf = kmalloc(len, GFP_KERNEL); - if (buf == NULL) { - rc = -ENOMEM; - goto cleanup; - } - rc = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), - USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, - (USB_DT_STRING << 8) + 0x64, - 0x0409, buf, len, - USB_CTRL_GET_TIMEOUT); - if (rc == -EPIPE) { - hid_err(hdev, "device parameters not found\n"); - rc = -ENODEV; - goto cleanup; - } else if (rc < 0) { - hid_err(hdev, "failed to get device parameters: %d\n", rc); - rc = -ENODEV; - goto cleanup; - } else if (rc != len) { - hid_err(hdev, "invalid device parameters\n"); - rc = -ENODEV; - goto cleanup; - } - - /* Extract device parameters */ - params[UCLOGIC_RDESC_PEN_PH_ID_X_LM] = - le16_to_cpu(buf[UCLOGIC_PRM_X_LM]); - params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] = - le16_to_cpu(buf[UCLOGIC_PRM_Y_LM]); - params[UCLOGIC_RDESC_PEN_PH_ID_PRESSURE_LM] = - le16_to_cpu(buf[UCLOGIC_PRM_PRESSURE_LM]); - resolution = le16_to_cpu(buf[UCLOGIC_PRM_RESOLUTION]); - if (resolution == 0) { - params[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = 0; - params[UCLOGIC_RDESC_PEN_PH_ID_Y_PM] = 0; - } else { - params[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = - params[UCLOGIC_RDESC_PEN_PH_ID_X_LM] * - 1000 / resolution; - params[UCLOGIC_RDESC_PEN_PH_ID_Y_PM] = - params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] * - 1000 / resolution; - } - - /* Format fixed report descriptor */ - drvdata->rdesc = uclogic_rdesc_template_apply( - uclogic_rdesc_pen_template_arr, - uclogic_rdesc_pen_template_size, - params, ARRAY_SIZE(params)); - if (drvdata->rdesc == NULL) { - rc = -ENOMEM; - goto cleanup; - } - drvdata->rsize = uclogic_rdesc_pen_template_size; - - rc = 0; - -cleanup: - kfree(buf); - return rc; -} - -/** - * Enable actual button mode. - * - * @hdev: HID device - */ -static int uclogic_button_enable(struct hid_device *hdev) -{ - int rc; - struct usb_device *usb_dev = hid_to_usb_dev(hdev); - struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); - char *str_buf; - size_t str_len = 16; - unsigned char *rdesc; - size_t rdesc_len; - - str_buf = kzalloc(str_len, GFP_KERNEL); - if (str_buf == NULL) { - rc = -ENOMEM; - goto cleanup; - } - - /* Enable abstract keyboard mode */ - rc = usb_string(usb_dev, 0x7b, str_buf, str_len); - if (rc == -EPIPE) { - hid_info(hdev, "button mode setting not found\n"); - rc = 0; - goto cleanup; - } else if (rc < 0) { - hid_err(hdev, "failed to enable abstract keyboard\n"); - goto cleanup; - } else if (strncmp(str_buf, "HK On", rc)) { - hid_info(hdev, "invalid answer when requesting buttons: '%s'\n", - str_buf); - rc = -EINVAL; - goto cleanup; - } - - /* Re-allocate fixed report descriptor */ - rdesc_len = drvdata->rsize + uclogic_rdesc_buttonpad_size; - rdesc = devm_kzalloc(&hdev->dev, rdesc_len, GFP_KERNEL); - if (!rdesc) { - rc = -ENOMEM; - goto cleanup; - } - - memcpy(rdesc, drvdata->rdesc, drvdata->rsize); - - /* Append the buttonpad descriptor */ - memcpy(rdesc + drvdata->rsize, uclogic_rdesc_buttonpad_arr, - uclogic_rdesc_buttonpad_size); - - /* clean up old rdesc and use the new one */ - drvdata->rsize = rdesc_len; - devm_kfree(&hdev->dev, drvdata->rdesc); - drvdata->rdesc = rdesc; - - rc = 0; - -cleanup: - kfree(str_buf); - return rc; -} - static int uclogic_probe(struct hid_device *hdev, const struct hid_device_id *id) { int rc; - struct usb_interface *intf = to_usb_interface(hdev->dev.parent); - struct usb_device *udev = hid_to_usb_dev(hdev); - struct uclogic_drvdata *drvdata; + struct uclogic_drvdata *drvdata = NULL; + bool params_initialized = false; /* * libinput requires the pad interface to be on a different node @@ -352,104 +126,97 @@ static int uclogic_probe(struct hid_device *hdev, /* Allocate and assign driver data */ drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL); - if (drvdata == NULL) - return -ENOMEM; - + if (drvdata == NULL) { + rc = -ENOMEM; + goto failure; + } hid_set_drvdata(hdev, drvdata); - switch (id->product) { - case USB_DEVICE_ID_HUION_TABLET: - case USB_DEVICE_ID_YIYNOVA_TABLET: - case USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81: - case USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3: - case USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45: - /* If this is the pen interface */ - if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { - rc = uclogic_tablet_enable(hdev); - if (rc) { - hid_err(hdev, "tablet enabling failed\n"); - return rc; - } - drvdata->invert_pen_inrange = true; - - rc = uclogic_button_enable(hdev); - drvdata->has_virtual_pad_interface = !rc; - } else { - drvdata->ignore_pen_usage = true; - } - break; - case USB_DEVICE_ID_UGTIZER_TABLET_GP0610: - case USB_DEVICE_ID_UGEE_TABLET_EX07S: - /* If this is the pen interface */ - if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { - rc = uclogic_tablet_enable(hdev); - if (rc) { - hid_err(hdev, "tablet enabling failed\n"); - return rc; - } - drvdata->invert_pen_inrange = true; - } else { - drvdata->ignore_pen_usage = true; - } - break; - case USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60: - /* - * If it is the three-interface version, which is known to - * respond to initialization. - */ - if (udev->config->desc.bNumInterfaces == 3) { - /* If it is the pen interface */ - if (intf->cur_altsetting->desc.bInterfaceNumber == 0) { - rc = uclogic_tablet_enable(hdev); - if (rc) { - hid_err(hdev, "tablet enabling failed\n"); - return rc; - } - drvdata->invert_pen_inrange = true; + /* Initialize the device and retrieve interface parameters */ + rc = uclogic_params_init(&drvdata->params, hdev); + if (rc != 0) { + hid_err(hdev, "failed probing parameters: %d\n", rc); + goto failure; + } + params_initialized = true; + hid_dbg(hdev, "parameters:\n" UCLOGIC_PARAMS_FMT_STR, + UCLOGIC_PARAMS_FMT_ARGS(&drvdata->params)); + if (drvdata->params.invalid) { + hid_info(hdev, "interface is invalid, ignoring\n"); + rc = -ENODEV; + goto failure; + } - rc = uclogic_button_enable(hdev); - drvdata->has_virtual_pad_interface = !rc; - } else { - drvdata->ignore_pen_usage = true; - } - } - break; + /* Generate replacement report descriptor */ + rc = uclogic_params_get_desc(&drvdata->params, + &drvdata->desc_ptr, + &drvdata->desc_size); + if (rc) { + hid_err(hdev, + "failed generating replacement report descriptor: %d\n", + rc); + goto failure; } rc = hid_parse(hdev); if (rc) { hid_err(hdev, "parse failed\n"); - return rc; + goto failure; } rc = hid_hw_start(hdev, HID_CONNECT_DEFAULT); if (rc) { hid_err(hdev, "hw start failed\n"); - return rc; + goto failure; } return 0; +failure: + /* Assume "remove" might not be called if "probe" failed */ + if (params_initialized) + uclogic_params_cleanup(&drvdata->params); + return rc; } -static int uclogic_raw_event(struct hid_device *hdev, struct hid_report *report, - u8 *data, int size) +static int uclogic_raw_event(struct hid_device *hdev, + struct hid_report *report, + u8 *data, int size) { struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + struct uclogic_params *params = &drvdata->params; - if ((report->type == HID_INPUT_REPORT) && - (report->id == UCLOGIC_RDESC_PEN_ID) && + /* Tweak pen reports, if necessary */ + if (!params->pen_unused && + (report->type == HID_INPUT_REPORT) && + (report->id == params->pen.id) && (size >= 2)) { - if (drvdata->has_virtual_pad_interface && (data[1] & 0x20)) - /* Change to virtual frame button report ID */ - data[0] = 0xf7; - else if (drvdata->invert_pen_inrange) + /* If it's the "virtual" frame controls report */ + if (params->frame.id != 0 && + data[1] & params->pen_frame_flag) { + /* Change to virtual frame controls report ID */ + data[0] = params->frame.id; + return 0; + } + /* If in-range reports are inverted */ + if (params->pen.inrange == + UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) { /* Invert the in-range bit */ data[1] ^= 0x40; + } } return 0; } +static void uclogic_remove(struct hid_device *hdev) +{ + struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + + hid_hw_stop(hdev); + kfree(drvdata->desc_ptr); + uclogic_params_cleanup(&drvdata->params); +} + static const struct hid_device_id uclogic_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, @@ -465,14 +232,22 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) }, - { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_HUION_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, + { HID_USB_DEVICE(USB_VENDOR_ID_HUION, + USB_DEVICE_ID_HUION_TABLET) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_HUION_TABLET) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_YIYNOVA_TABLET) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, + USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_TABLET_EX07S) }, { } }; MODULE_DEVICE_TABLE(hid, uclogic_devices); @@ -481,6 +256,7 @@ static struct hid_driver uclogic_driver = { .name = "uclogic", .id_table = uclogic_devices, .probe = uclogic_probe, + .remove = uclogic_remove, .report_fixup = uclogic_report_fixup, .raw_event = uclogic_raw_event, .input_mapping = uclogic_input_mapping, diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c new file mode 100644 index 000000000000..2f8870d58f9a --- /dev/null +++ b/drivers/hid/hid-uclogic-params.c @@ -0,0 +1,806 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * HID driver for UC-Logic devices not fully compliant with HID standard + * - tablet initialization and parameter retrieval + * + * Copyright (c) 2018 Nikolai Kondrashov + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include "hid-uclogic-params.h" +#include "hid-uclogic-rdesc.h" +#include "usbhid/usbhid.h" +#include "hid-ids.h" +#include +#include + +/** + * Convert a pen in-range reporting type to a string. + * + * @inrange: The in-range reporting type to convert. + * + * Returns: + * The string representing the type, or NULL if the type is unknown. + */ +const char *uclogic_params_pen_inrange_to_str( + enum uclogic_params_pen_inrange inrange) +{ + switch (inrange) { + case UCLOGIC_PARAMS_PEN_INRANGE_NORMAL: + return "normal"; + case UCLOGIC_PARAMS_PEN_INRANGE_INVERTED: + return "inverted"; + default: + return NULL; + } +} + +/** + * uclogic_params_get_str_desc - retrieve a string descriptor from a HID + * device interface, putting it into a kmalloc-allocated buffer as is, without + * character encoding conversion. + * + * @pbuf: Location for the kmalloc-allocated buffer pointer containing + * the retrieved descriptor. Not modified in case of error. + * Can be NULL to have retrieved descriptor discarded. + * @hdev: The HID device of the tablet interface to retrieve the string + * descriptor from. Cannot be NULL. + * @idx: Index of the string descriptor to request from the device. + * @len: Length of the buffer to allocate and the data to retrieve. + * + * Returns: + * number of bytes retrieved (<= len), + * -EPIPE, if the descriptor was not found, or + * another negative errno code in case of other error. + */ +static int uclogic_params_get_str_desc(__u8 **pbuf, struct hid_device *hdev, + __u8 idx, size_t len) +{ + int rc; + struct usb_device *udev = hid_to_usb_dev(hdev); + __u8 *buf = NULL; + + /* Check arguments */ + if (hdev == NULL) { + rc = -EINVAL; + goto cleanup; + } + + buf = kmalloc(len, GFP_KERNEL); + if (buf == NULL) { + rc = -ENOMEM; + goto cleanup; + } + + rc = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, + (USB_DT_STRING << 8) + idx, + 0x0409, buf, len, + USB_CTRL_GET_TIMEOUT); + if (rc == -EPIPE) { + hid_dbg(hdev, "string descriptor #%hhu not found\n", idx); + goto cleanup; + } else if (rc < 0) { + hid_err(hdev, + "failed retrieving string descriptor #%hhu: %d\n", + idx, rc); + goto cleanup; + } + + if (pbuf != NULL) { + *pbuf = buf; + buf = NULL; + } + +cleanup: + kfree(buf); + return rc; +} + +/** + * uclogic_params_pen_cleanup - free resources used by struct + * uclogic_params_pen (tablet interface's pen input parameters). + * Can be called repeatedly. + * + * @pen: Pen input parameters to cleanup. Cannot be NULL. + */ +static void uclogic_params_pen_cleanup(struct uclogic_params_pen *pen) +{ + kfree(pen->desc_ptr); + memset(pen, 0, sizeof(*pen)); +} + +/** + * uclogic_params_pen_init() - initialize tablet interface pen + * input and retrieve its parameters from the device. + * + * @pen: Pointer to the pen parameters to initialize (to be + * cleaned up with uclogic_params_pen_cleanup()). Not modified in + * case of error, or if parameters are not found. Cannot be NULL. + * @pfound: Location for a flag which is set to true if the parameters + * were found, and to false if not (e.g. device was + * incompatible). Not modified in case of error. Cannot be NULL. + * @hdev: The HID device of the tablet interface to initialize and get + * parameters from. Cannot be NULL. + * + * Returns: + * Zero, if successful. A negative errno code on error. + */ +static int uclogic_params_pen_init(struct uclogic_params_pen *pen, + bool *pfound, + struct hid_device *hdev) +{ + int rc; + bool found = false; + /* Buffer for (part of) the string descriptor */ + __u8 *buf = NULL; + /* Minimum descriptor length required, maximum seen so far is 18 */ + const int len = 12; + s32 resolution; + /* Pen report descriptor template parameters */ + s32 desc_params[UCLOGIC_RDESC_PEN_PH_ID_NUM]; + __u8 *desc_ptr = NULL; + + /* Check arguments */ + if (pen == NULL || pfound == NULL || hdev == NULL) { + rc = -EINVAL; + goto cleanup; + } + + /* + * Read string descriptor containing pen input parameters. + * The specific string descriptor and data were discovered by sniffing + * the Windows driver traffic. + * NOTE: This enables fully-functional tablet mode. + */ + rc = uclogic_params_get_str_desc(&buf, hdev, 100, len); + if (rc == -EPIPE) { + hid_dbg(hdev, + "string descriptor with pen parameters not found, assuming not compatible\n"); + goto finish; + } else if (rc < 0) { + hid_err(hdev, "failed retrieving pen parameters: %d\n", rc); + goto cleanup; + } else if (rc != len) { + hid_dbg(hdev, + "string descriptor with pen parameters has invalid length (got %d, expected %d), assuming not compatible\n", + rc, len); + goto finish; + } + + /* + * Fill report descriptor parameters from the string descriptor + */ + desc_params[UCLOGIC_RDESC_PEN_PH_ID_X_LM] = + get_unaligned_le16(buf + 2); + desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] = + get_unaligned_le16(buf + 4); + desc_params[UCLOGIC_RDESC_PEN_PH_ID_PRESSURE_LM] = + get_unaligned_le16(buf + 8); + resolution = get_unaligned_le16(buf + 10); + if (resolution == 0) { + desc_params[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = 0; + desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_PM] = 0; + } else { + desc_params[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = + desc_params[UCLOGIC_RDESC_PEN_PH_ID_X_LM] * 1000 / + resolution; + desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_PM] = + desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] * 1000 / + resolution; + } + kfree(buf); + buf = NULL; + + /* + * Generate pen report descriptor + */ + desc_ptr = uclogic_rdesc_template_apply( + uclogic_rdesc_pen_template_arr, + uclogic_rdesc_pen_template_size, + desc_params, ARRAY_SIZE(desc_params)); + if (desc_ptr == NULL) { + rc = -ENOMEM; + goto cleanup; + } + + /* + * Fill-in the parameters + */ + memset(pen, 0, sizeof(*pen)); + pen->desc_ptr = desc_ptr; + desc_ptr = NULL; + pen->desc_size = uclogic_rdesc_pen_template_size; + pen->id = UCLOGIC_RDESC_PEN_ID; + pen->inrange = UCLOGIC_PARAMS_PEN_INRANGE_INVERTED; + found = true; +finish: + *pfound = found; + rc = 0; +cleanup: + kfree(desc_ptr); + kfree(buf); + return rc; +} + +/** + * uclogic_params_frame_cleanup - free resources used by struct + * uclogic_params_frame (tablet interface's frame controls input parameters). + * Can be called repeatedly. + * + * @frame: Frame controls input parameters to cleanup. Cannot be NULL. + */ +static void uclogic_params_frame_cleanup(struct uclogic_params_frame *frame) +{ + kfree(frame->desc_ptr); + memset(frame, 0, sizeof(*frame)); +} + +/** + * uclogic_params_frame_init_with_desc() - initialize tablet's frame control + * parameters with a static report descriptor. + * + * @frame: Pointer to the frame parameters to initialize (to be cleaned + * up with uclogic_params_frame_cleanup()). Not modified in case + * of error. Cannot be NULL. + * @desc_ptr: Report descriptor pointer. Can be NULL, if desc_size is zero. + * @desc_size: Report descriptor size. + * @id: Report ID used for frame reports, if they should be tweaked, + * zero if not. + * + * Returns: + * Zero, if successful. A negative errno code on error. + */ +static int uclogic_params_frame_init_with_desc( + struct uclogic_params_frame *frame, + const __u8 *desc_ptr, + size_t desc_size, + unsigned int id) +{ + __u8 *copy_desc_ptr; + + if (frame == NULL || (desc_ptr == NULL && desc_size != 0)) + return -EINVAL; + + copy_desc_ptr = kmemdup(desc_ptr, desc_size, GFP_KERNEL); + if (copy_desc_ptr == NULL) + return -ENOMEM; + + memset(frame, 0, sizeof(*frame)); + frame->desc_ptr = copy_desc_ptr; + frame->desc_size = desc_size; + frame->id = id; + return 0; +} + +/** + * uclogic_params_frame_init_buttonpad() - initialize abstract buttonpad + * on a tablet interface. + * + * @frame: Pointer to the frame parameters to initialize (to be cleaned + * up with uclogic_params_frame_cleanup()). Not modified in case + * of error, or if parameters are not found. Cannot be NULL. + * @pfound: Location for a flag which is set to true if the parameters + * were found, and to false if not (e.g. device was + * incompatible). Not modified in case of error. Cannot be NULL. + * @hdev: The HID device of the tablet interface to initialize and get + * parameters from. Cannot be NULL. + * + * Returns: + * Zero, if successful. A negative errno code on error. + */ +static int uclogic_params_frame_init_buttonpad( + struct uclogic_params_frame *frame, + bool *pfound, + struct hid_device *hdev) +{ + int rc; + bool found = false; + struct usb_device *usb_dev = hid_to_usb_dev(hdev); + char *str_buf = NULL; + const size_t str_len = 16; + + /* Check arguments */ + if (frame == NULL || pfound == NULL || hdev == NULL) { + rc = -EINVAL; + goto cleanup; + } + + /* + * Enable generic button mode + */ + str_buf = kzalloc(str_len, GFP_KERNEL); + if (str_buf == NULL) { + rc = -ENOMEM; + goto cleanup; + } + + rc = usb_string(usb_dev, 123, str_buf, str_len); + if (rc == -EPIPE) { + hid_dbg(hdev, + "generic button -enabling string descriptor not found\n"); + } else if (rc < 0) { + goto cleanup; + } else if (strncmp(str_buf, "HK On", rc) != 0) { + hid_dbg(hdev, + "invalid response to enabling generic buttons: \"%s\"\n", + str_buf); + } else { + hid_dbg(hdev, "generic buttons enabled\n"); + rc = uclogic_params_frame_init_with_desc( + frame, + uclogic_rdesc_buttonpad_arr, + uclogic_rdesc_buttonpad_size, + UCLOGIC_RDESC_BUTTONPAD_ID); + if (rc != 0) + goto cleanup; + found = true; + } + + *pfound = found; + rc = 0; +cleanup: + kfree(str_buf); + return rc; +} + +/** + * uclogic_params_cleanup - free resources used by struct uclogic_params + * (tablet interface's parameters). + * Can be called repeatedly. + * + * @params: Input parameters to cleanup. Cannot be NULL. + */ +void uclogic_params_cleanup(struct uclogic_params *params) +{ + if (!params->invalid) { + kfree(params->desc_ptr); + if (!params->pen_unused) + uclogic_params_pen_cleanup(¶ms->pen); + uclogic_params_frame_cleanup(¶ms->frame); + memset(params, 0, sizeof(*params)); + } +} + +/** + * Get a replacement report descriptor for a tablet's interface. + * + * @params: The parameters of a tablet interface to get report + * descriptor for. Cannot be NULL. + * @pdesc: Location for the resulting, kmalloc-allocated report + * descriptor pointer, or for NULL, if there's no replacement + * report descriptor. Not modified in case of error. Cannot be + * NULL. + * @psize: Location for the resulting report descriptor size, not set if + * there's no replacement report descriptor. Not modified in case + * of error. Cannot be NULL. + * + * Returns: + * Zero, if successful. + * -EINVAL, if invalid arguments are supplied. + * -ENOMEM, if failed to allocate memory. + */ +int uclogic_params_get_desc(const struct uclogic_params *params, + __u8 **pdesc, + unsigned int *psize) +{ + bool common_present; + bool pen_present; + bool frame_present; + unsigned int size; + __u8 *desc = NULL; + + /* Check arguments */ + if (params == NULL || pdesc == NULL || psize == NULL) + return -EINVAL; + + size = 0; + + common_present = (params->desc_ptr != NULL); + pen_present = (!params->pen_unused && params->pen.desc_ptr != NULL); + frame_present = (params->frame.desc_ptr != NULL); + + if (common_present) + size += params->desc_size; + if (pen_present) + size += params->pen.desc_size; + if (frame_present) + size += params->frame.desc_size; + + if (common_present || pen_present || frame_present) { + __u8 *p; + + desc = kmalloc(size, GFP_KERNEL); + if (desc == NULL) + return -ENOMEM; + p = desc; + + if (common_present) { + memcpy(p, params->desc_ptr, + params->desc_size); + p += params->desc_size; + } + if (pen_present) { + memcpy(p, params->pen.desc_ptr, + params->pen.desc_size); + p += params->pen.desc_size; + } + if (frame_present) { + memcpy(p, params->frame.desc_ptr, + params->frame.desc_size); + p += params->frame.desc_size; + } + + WARN_ON(p != desc + size); + + *psize = size; + } + + *pdesc = desc; + return 0; +} + +/** + * uclogic_params_init_invalid() - initialize tablet interface parameters, + * specifying the interface is invalid. + * + * @params: Parameters to initialize (to be cleaned with + * uclogic_params_cleanup()). Cannot be NULL. + */ +static void uclogic_params_init_invalid(struct uclogic_params *params) +{ + params->invalid = true; +} + +/** + * uclogic_params_init_with_opt_desc() - initialize tablet interface + * parameters with an optional replacement report descriptor. Only modify + * report descriptor, if the original report descriptor matches the expected + * size. + * + * @params: Parameters to initialize (to be cleaned with + * uclogic_params_cleanup()). Not modified in case of + * error. Cannot be NULL. + * @hdev: The HID device of the tablet interface create the + * parameters for. Cannot be NULL. + * @orig_desc_size: Expected size of the original report descriptor to + * be replaced. + * @desc_ptr: Pointer to the replacement report descriptor. + * Can be NULL, if desc_size is zero. + * @desc_size: Size of the replacement report descriptor. + * + * Returns: + * Zero, if successful. -EINVAL if an invalid argument was passed. + * -ENOMEM, if failed to allocate memory. + */ +static int uclogic_params_init_with_opt_desc(struct uclogic_params *params, + struct hid_device *hdev, + unsigned int orig_desc_size, + __u8 *desc_ptr, + unsigned int desc_size) +{ + __u8 *desc_copy_ptr = NULL; + unsigned int desc_copy_size; + int rc; + + /* Check arguments */ + if (params == NULL || hdev == NULL || + (desc_ptr == NULL && desc_size != 0)) { + rc = -EINVAL; + goto cleanup; + } + + /* Replace report descriptor, if it matches */ + if (hdev->dev_rsize == orig_desc_size) { + hid_dbg(hdev, + "device report descriptor matches the expected size, replacing\n"); + desc_copy_ptr = kmemdup(desc_ptr, desc_size, GFP_KERNEL); + if (desc_copy_ptr == NULL) { + rc = -ENOMEM; + goto cleanup; + } + desc_copy_size = desc_size; + } else { + hid_dbg(hdev, + "device report descriptor doesn't match the expected size (%u != %u), preserving\n", + hdev->dev_rsize, orig_desc_size); + desc_copy_ptr = NULL; + desc_copy_size = 0; + } + + /* Output parameters */ + memset(params, 0, sizeof(*params)); + params->desc_ptr = desc_copy_ptr; + desc_copy_ptr = NULL; + params->desc_size = desc_copy_size; + + rc = 0; +cleanup: + kfree(desc_copy_ptr); + return rc; +} + +/** + * uclogic_params_init_with_pen_unused() - initialize tablet interface + * parameters preserving original reports and generic HID processing, but + * disabling pen usage. + * + * @params: Parameters to initialize (to be cleaned with + * uclogic_params_cleanup()). Not modified in case of + * error. Cannot be NULL. + */ +static void uclogic_params_init_with_pen_unused(struct uclogic_params *params) +{ + memset(params, 0, sizeof(*params)); + params->pen_unused = true; +} + +/** + * uclogic_params_init() - initialize a Huion tablet interface and discover + * its parameters. + * + * @params: Parameters to fill in (to be cleaned with + * uclogic_params_cleanup()). Not modified in case of error. + * Cannot be NULL. + * @hdev: The HID device of the tablet interface to initialize and get + * parameters from. Cannot be NULL. + * + * Returns: + * Zero, if successful. A negative errno code on error. + */ +static int uclogic_params_huion_init(struct uclogic_params *params, + struct hid_device *hdev) +{ + int rc; + struct usb_interface *iface = to_usb_interface(hdev->dev.parent); + __u8 bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; + bool found; + /* The resulting parameters (noop) */ + struct uclogic_params p = {0, }; + + /* Check arguments */ + if (params == NULL || hdev == NULL) { + rc = -EINVAL; + goto cleanup; + } + + /* If it's not a pen interface */ + if (bInterfaceNumber != 0) { + /* TODO: Consider marking the interface invalid */ + uclogic_params_init_with_pen_unused(&p); + goto output; + } + + /* Try to probe pen parameters */ + rc = uclogic_params_pen_init(&p.pen, &found, hdev); + if (rc != 0) { + hid_err(hdev, + "failed probing pen parameters: %d\n", rc); + goto cleanup; + } else if (found) { + hid_dbg(hdev, "pen parameters found\n"); + /* Try to probe buttonpad */ + rc = uclogic_params_frame_init_buttonpad( + &p.frame, + &found, hdev); + if (rc != 0) { + hid_err(hdev, "v1 buttonpad probing failed: %d\n", rc); + goto cleanup; + } + hid_dbg(hdev, "buttonpad parameters%s found\n", + (found ? "" : " not")); + if (found) { + /* Set bitmask marking frame reports */ + p.pen_frame_flag = 0x20; + } + goto output; + } + hid_dbg(hdev, "pen parameters not found\n"); + + uclogic_params_init_invalid(&p); + +output: + /* Output parameters */ + memcpy(params, &p, sizeof(*params)); + memset(&p, 0, sizeof(p)); + rc = 0; +cleanup: + uclogic_params_cleanup(&p); + return rc; +} + +/** + * uclogic_params_init() - initialize a tablet interface and discover its + * parameters. + * + * @params: Parameters to fill in (to be cleaned with + * uclogic_params_cleanup()). Not modified in case of error. + * Cannot be NULL. + * @hdev: The HID device of the tablet interface to initialize and get + * parameters from. Cannot be NULL. + * + * Returns: + * Zero, if successful. A negative errno code on error. + */ +int uclogic_params_init(struct uclogic_params *params, + struct hid_device *hdev) +{ + int rc; + struct usb_device *udev = hid_to_usb_dev(hdev); + __u8 bNumInterfaces = udev->config->desc.bNumInterfaces; + struct usb_interface *iface = to_usb_interface(hdev->dev.parent); + __u8 bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; + bool found; + /* The resulting parameters (noop) */ + struct uclogic_params p = {0, }; + + /* Check arguments */ + if (params == NULL || hdev == NULL) { + rc = -EINVAL; + goto cleanup; + } + + /* + * Set replacement report descriptor if the original matches the + * specified size. Otherwise keep interface unchanged. + */ +#define WITH_OPT_DESC(_orig_desc_token, _new_desc_token) \ + uclogic_params_init_with_opt_desc( \ + &p, hdev, \ + UCLOGIC_RDESC_##_orig_desc_token##_SIZE, \ + uclogic_rdesc_##_new_desc_token##_arr, \ + uclogic_rdesc_##_new_desc_token##_size) + +#define VID_PID(_vid, _pid) \ + (((__u32)(_vid) << 16) | ((__u32)(_pid) & U16_MAX)) + + /* + * Handle specific interfaces for specific tablets. + * + * Observe the following logic: + * + * If the interface is recognized as producing certain useful input: + * Mark interface as valid. + * Output interface parameters. + * Else, if the interface is recognized as *not* producing any useful + * input: + * Mark interface as invalid. + * Else: + * Mark interface as valid. + * Output noop parameters. + * + * Rule of thumb: it is better to disable a broken interface than let + * it spew garbage input. + */ + + switch (VID_PID(hdev->vendor, hdev->product)) { + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_PF1209): + rc = WITH_OPT_DESC(PF1209_ORIG, pf1209_fixed); + if (rc != 0) + goto cleanup; + break; + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U): + rc = WITH_OPT_DESC(WPXXXXU_ORIG, wp4030u_fixed); + if (rc != 0) + goto cleanup; + break; + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U): + rc = WITH_OPT_DESC(WPXXXXU_ORIG, wp5540u_fixed); + if (rc != 0) + goto cleanup; + break; + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U): + rc = WITH_OPT_DESC(WPXXXXU_ORIG, wp8060u_fixed); + if (rc != 0) + goto cleanup; + break; + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_WP1062): + rc = WITH_OPT_DESC(WP1062_ORIG, wp1062_fixed); + if (rc != 0) + goto cleanup; + break; + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850): + switch (bInterfaceNumber) { + case 0: + rc = WITH_OPT_DESC(TWHL850_ORIG0, twhl850_fixed0); + if (rc != 0) + goto cleanup; + break; + case 1: + rc = WITH_OPT_DESC(TWHL850_ORIG1, twhl850_fixed1); + if (rc != 0) + goto cleanup; + break; + case 2: + rc = WITH_OPT_DESC(TWHL850_ORIG2, twhl850_fixed2); + if (rc != 0) + goto cleanup; + break; + } + break; + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60): + /* + * If it is not a three-interface version, which is known to + * respond to initialization. + */ + if (bNumInterfaces != 3) { + switch (bInterfaceNumber) { + case 0: + rc = WITH_OPT_DESC(TWHA60_ORIG0, + twha60_fixed0); + if (rc != 0) + goto cleanup; + break; + case 1: + rc = WITH_OPT_DESC(TWHA60_ORIG1, + twha60_fixed1); + if (rc != 0) + goto cleanup; + break; + } + break; + } + /* FALL THROUGH */ + case VID_PID(USB_VENDOR_ID_HUION, + USB_DEVICE_ID_HUION_TABLET): + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_HUION_TABLET): + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_YIYNOVA_TABLET): + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81): + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3): + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45): + rc = uclogic_params_huion_init(&p, hdev); + if (rc != 0) + goto cleanup; + break; + case VID_PID(USB_VENDOR_ID_UGTIZER, + USB_DEVICE_ID_UGTIZER_TABLET_GP0610): + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_TABLET_EX07S): + /* If this is the pen interface */ + if (bInterfaceNumber == 1) { + /* Probe pen parameters */ + rc = uclogic_params_pen_init(&p.pen, &found, hdev); + if (rc != 0) { + hid_err(hdev, "pen probing failed: %d\n", rc); + goto cleanup; + } + if (!found) { + hid_warn(hdev, "pen parameters not found"); + uclogic_params_init_invalid(&p); + } + } else { + /* TODO: Consider marking the interface invalid */ + uclogic_params_init_with_pen_unused(&p); + } + break; + } + +#undef VID_PID +#undef WITH_OPT_DESC + + /* Output parameters */ + memcpy(params, &p, sizeof(*params)); + memset(&p, 0, sizeof(p)); + rc = 0; +cleanup: + uclogic_params_cleanup(&p); + return rc; +} diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h new file mode 100644 index 000000000000..4c78d9dd0576 --- /dev/null +++ b/drivers/hid/hid-uclogic-params.h @@ -0,0 +1,180 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * HID driver for UC-Logic devices not fully compliant with HID standard + * - tablet initialization and parameter retrieval + * + * Copyright (c) 2018 Nikolai Kondrashov + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#ifndef _HID_UCLOGIC_PARAMS_H +#define _HID_UCLOGIC_PARAMS_H + +#include +#include + +/* Types of pen in-range reporting */ +enum uclogic_params_pen_inrange { + /* Normal reports: zero - out of proximity, one - in proximity */ + UCLOGIC_PARAMS_PEN_INRANGE_NORMAL = 0, + /* Inverted reports: zero - in proximity, one - out of proximity */ + UCLOGIC_PARAMS_PEN_INRANGE_INVERTED, +}; + +/* Convert a pen in-range reporting type to a string */ +extern const char *uclogic_params_pen_inrange_to_str( + enum uclogic_params_pen_inrange inrange); + +/* + * Tablet interface's pen input parameters. + * + * Must use declarative (descriptive) language, not imperative, to simplify + * understanding and maintain consistency. + * + * Noop (preserving functionality) when filled with zeroes. + */ +struct uclogic_params_pen { + /* + * Pointer to report descriptor describing the inputs. + * Allocated with kmalloc. + */ + __u8 *desc_ptr; + /* + * Size of the report descriptor. + * Only valid, if "desc_ptr" is not NULL. + */ + unsigned int desc_size; + /* Report ID, if reports should be tweaked, zero if not */ + unsigned int id; + /* Type of in-range reporting, only valid if "id" is not zero */ + enum uclogic_params_pen_inrange inrange; +}; + +/* + * Parameters of frame control inputs of a tablet interface. + * + * Must use declarative (descriptive) language, not imperative, to simplify + * understanding and maintain consistency. + * + * Noop (preserving functionality) when filled with zeroes. + */ +struct uclogic_params_frame { + /* + * Pointer to report descriptor describing the inputs. + * Allocated with kmalloc. + */ + __u8 *desc_ptr; + /* + * Size of the report descriptor. + * Only valid, if "desc_ptr" is not NULL. + */ + unsigned int desc_size; + /* + * Report ID, if reports should be tweaked, zero if not. + */ + unsigned int id; +}; + +/* + * Tablet interface report parameters. + * + * Must use declarative (descriptive) language, not imperative, to simplify + * understanding and maintain consistency. + * + * When filled with zeros represents a "noop" configuration - passes all + * reports unchanged and lets the generic HID driver handle everything. + * + * The resulting device report descriptor is assembled from all the report + * descriptor parts referenced by the structure. No order of assembly should + * be assumed. The structure represents original device report descriptor if + * all the parts are NULL. + */ +struct uclogic_params { + /* + * True if the whole interface is invalid, false otherwise. + */ + bool invalid; + /* + * Pointer to the common part of the replacement report descriptor, + * allocated with kmalloc. NULL if no common part is needed. + * Only valid, if "invalid" is false. + */ + __u8 *desc_ptr; + /* + * Size of the common part of the replacement report descriptor. + * Only valid, if "desc_ptr" is not NULL. + */ + unsigned int desc_size; + /* + * True, if pen usage in report descriptor is invalid, when present. + * Only valid, if "invalid" is false. + */ + bool pen_unused; + /* + * Pen parameters and optional report descriptor part. + * Only valid if "pen_unused" is valid and false. + */ + struct uclogic_params_pen pen; + /* + * Frame control parameters and optional report descriptor part. + * Only valid, if "invalid" is false. + */ + struct uclogic_params_frame frame; + /* + * Bitmask matching frame controls "sub-report" flag in the second + * byte of the pen report, or zero if it's not expected. + * Only valid if both "pen" and "frame" are valid, and "frame.id" is + * not zero. + */ + __u8 pen_frame_flag; +}; + +/* Initialize a tablet interface and discover its parameters */ +extern int uclogic_params_init(struct uclogic_params *params, + struct hid_device *hdev); + +/* Tablet interface parameters *printf format string */ +#define UCLOGIC_PARAMS_FMT_STR \ + ".invalid = %s\n" \ + ".desc_ptr = %p\n" \ + ".desc_size = %u\n" \ + ".pen_unused = %s\n" \ + ".pen.desc_ptr = %p\n" \ + ".pen.desc_size = %u\n" \ + ".pen.id = %u\n" \ + ".pen.inrange = %s\n" \ + ".frame.desc_ptr = %p\n" \ + ".frame.desc_size = %u\n" \ + ".frame.id = %u\n" \ + ".pen_frame_flag = 0x%02x\n" + +/* Tablet interface parameters *printf format arguments */ +#define UCLOGIC_PARAMS_FMT_ARGS(_params) \ + ((_params)->invalid ? "true" : "false"), \ + (_params)->desc_ptr, \ + (_params)->desc_size, \ + ((_params)->pen_unused ? "true" : "false"), \ + (_params)->pen.desc_ptr, \ + (_params)->pen.desc_size, \ + (_params)->pen.id, \ + uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \ + (_params)->frame.desc_ptr, \ + (_params)->frame.desc_size, \ + (_params)->frame.id, \ + (_params)->pen_frame_flag + +/* Get a replacement report descriptor for a tablet's interface. */ +extern int uclogic_params_get_desc(const struct uclogic_params *params, + __u8 **pdesc, + unsigned int *psize); + +/* Free resources used by tablet interface's parameters */ +extern void uclogic_params_cleanup(struct uclogic_params *params); + +#endif /* _HID_UCLOGIC_PARAMS_H */ From patchwork Sun Feb 10 10:13:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804671 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CEFD1515 for ; Sun, 10 Feb 2019 10:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F15229F45 for ; Sun, 10 Feb 2019 10:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 832F529F4A; Sun, 10 Feb 2019 10:14:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 340E229F45 for ; Sun, 10 Feb 2019 10:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726032AbfBJKOw (ORCPT ); Sun, 10 Feb 2019 05:14:52 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:42534 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbfBJKOw (ORCPT ); Sun, 10 Feb 2019 05:14:52 -0500 Received: by mail-lj1-f194.google.com with SMTP id l15-v6so6415519lja.9 for ; Sun, 10 Feb 2019 02:14:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a+kuhlBS86h7JEOuYVa3VyqA3/+1D3JagKaOwfiO3ao=; b=LA7P5L6MV0lreDTqKVs45hWbjhkTeTRY6lg6sVSMcmASTReYKXna1YdUDkfN4+G0Xk cRMRG9G5Aoy4ob38e5d8ADLDR7Gjof273P9I8DoxNlqQsQGtwjAv19FsaD4ud/PfTTMJ Lp/gMS3p+QjQ2nO6y9aQ6zFiemVpZ6zEm7rYKTYk/VXV19BwS6vLc5uqi+kERHIwy4Au FLgM3gyNn7wTdWnWEWDd/Ef891FCmZIvL/NmzJuKkBhibvDfbjqAH1o5XYnj5p9crpki DtybeF/mmG9NBsJ0/HYbDre1Sv3IwcN8q8NYqC9w/rqf87zp9IS5hkKPM/DWEharhsrj Me1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a+kuhlBS86h7JEOuYVa3VyqA3/+1D3JagKaOwfiO3ao=; b=BsO0qq02IMcOnuAyXmPCLWRGsrTbQzfIw7C/JBntzgjmkUtAIxG1qstYPD5MHxSYpP 05n9eHiKXW+iuTeEi/jsDvHHeZCck2Ra6ZnC+Jn0ye24pEYrNmU0f3wkl4VuskmxTBWJ bgKCsd5moVR2co1Our3oo81YDHVihTEY0ILiMJgllI4hcc0JKw/2TNEh8wJFyyvDAPtf CsFfu9kjeGv/DWoj9ybSjSSQKRaV9oKr3neRGdQlM/eJ50wyCF33wCWMnYTeiZaF1sHf nunXTwXml5a6zbJyna8IVerN9MnzF4G3qJMy5PyollTuXx+6UN6dvWsf4bQ/0cIVYUN7 w1HA== X-Gm-Message-State: AHQUAuZAYOBxoqJaVCrNEjUJFM9/TSq8uCBD1XOOFKvdm04CoLK+SEuT iGnLbgZ55wj6Z6p93qZAaGg= X-Google-Smtp-Source: AHgI3IaCJ3iwT06AOQW9GomV7xdKtZ4Qf8hJatJB8Q4+pzeiXKH3MZdvUa1pa3Lkl+IUD4QOWVI4Hg== X-Received: by 2002:a2e:9849:: with SMTP id e9-v6mr9735648ljj.9.1549793690489; Sun, 10 Feb 2019 02:14:50 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:49 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 06/23] HID: uclogic: Re-initialize tablets on resume Date: Sun, 10 Feb 2019 12:13:52 +0200 Message-Id: <20190210101409.3511-7-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Re-initialize UC-Logic tablets on resume. UC-Logic tablet initialization and parameter retrieval cannot be separated for the large part, so simply discard the retrieved parameters after initialization. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 72a3a43766cc..8f8e445d77aa 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -178,6 +178,23 @@ static int uclogic_probe(struct hid_device *hdev, return rc; } +#ifdef CONFIG_PM +static int uclogic_resume(struct hid_device *hdev) +{ + int rc; + struct uclogic_params params; + + /* Re-initialize the device, but discard parameters */ + rc = uclogic_params_init(¶ms, hdev); + if (rc != 0) + hid_err(hdev, "failed to re-initialize the device\n"); + else + uclogic_params_cleanup(¶ms); + + return rc; +} +#endif + static int uclogic_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) @@ -261,6 +278,10 @@ static struct hid_driver uclogic_driver = { .raw_event = uclogic_raw_event, .input_mapping = uclogic_input_mapping, .input_configured = uclogic_input_configured, +#ifdef CONFIG_PM + .resume = uclogic_resume, + .reset_resume = uclogic_resume, +#endif }; module_hid_driver(uclogic_driver); From patchwork Sun Feb 10 10:13:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804673 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A07E01515 for ; Sun, 10 Feb 2019 10:14:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9268B29F45 for ; Sun, 10 Feb 2019 10:14:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86DD729F4B; Sun, 10 Feb 2019 10:14:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 D9D5D29F45 for ; Sun, 10 Feb 2019 10:14:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726035AbfBJKOy (ORCPT ); Sun, 10 Feb 2019 05:14:54 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:33417 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbfBJKOy (ORCPT ); Sun, 10 Feb 2019 05:14:54 -0500 Received: by mail-lj1-f194.google.com with SMTP id f24-v6so6475064ljk.0 for ; Sun, 10 Feb 2019 02:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l+tp8PaVOHhia7otABDP8tN4XQuR2MhQ9qQB+YksZdw=; b=XL86gpIdig5zFXYalzI29nQ2Fvo+uvNvPlDkxkhVg3YmcU/wtGsvXtSTQDTbudJHS3 TqUQXvwZZYiMr4YWgXIL6gP1JRIRZDnxeWQ6Ktf7QCKhPQc091ydFbmyTtsQt/4zGofx yXqCTdPWZBdOz6bUFvh77Q5zMzFINKtZzOfV7rHZGWqeIeOTk6X5NsxRLScC1zhXhTwF RlNIqeuU8gg4Fm4uviE+QQ32s8M+asXpHAvDXa5Rxk4ZlbBhio31cgmkG+NOBcFfdvhi 9/Ofr8xb1lwJlGBIfr8jfKcKt27gHhJxf3PggYDvv+UV5aRfozUHgWHdvMdNCMpRbkN4 vDXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l+tp8PaVOHhia7otABDP8tN4XQuR2MhQ9qQB+YksZdw=; b=TinY76lEkspQ0yaZIk7r4ZN4WPfkFg+uSSGRUKHfcKx2KiDg34/hzy8XTmiMki1QJr biE3kGoJMAHfufIsORcm7muWuC7rLCMO34kqRFdToSIFF6jWyeFFQgOTmiMV+xnhopLo CzaRXPCVYOMDQZjgZXwG0A1nVCnBymuliQW9d+KznM0hguwCAVj2hgZTG6vw7dsTYAj2 SxQltMhsXz/K9zJbVNlCI0xUUeENPv/kYzTbDgcR01U2Rm/MVQ9nWNaPsaxYpWfmWM+j 6v8NzdTb0dwMmhEb4OmjdBcyu6/rzGzH8mXXndtT61yYRsqvhbmy6ZyBXpiTrZUCJ6O+ klYg== X-Gm-Message-State: AHQUAuZw3PCM5xw/yTPE81hXVZDl6Hc/z0IelogPkfUEpk1HO3JNC9rD HA0wGR6r9tyW5s9NthI/aFI= X-Google-Smtp-Source: AHgI3IbLVPLEuiqAIWmaoTdTtD+bED2ZFG+Cv0ktCjMK9Cn6+ZYz4Te2cax8h6HGdJi8NfRJQLb8dQ== X-Received: by 2002:a2e:8006:: with SMTP id j6-v6mr18386107ljg.186.1549793691694; Sun, 10 Feb 2019 02:14:51 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:50 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 07/23] HID: uclogic: Designate current protocol v1 Date: Sun, 10 Feb 2019 12:13:53 +0200 Message-Id: <20190210101409.3511-8-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Designate the current UC-Logic tablet initialization protocol v1, in preparation for adding support for v2 protocol. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-params.c | 50 ++++++++++++++++---------------- drivers/hid/hid-uclogic-rdesc.c | 16 +++++----- drivers/hid/hid-uclogic-rdesc.h | 20 ++++++------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 2f8870d58f9a..f555db120baa 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -117,8 +117,8 @@ static void uclogic_params_pen_cleanup(struct uclogic_params_pen *pen) } /** - * uclogic_params_pen_init() - initialize tablet interface pen - * input and retrieve its parameters from the device. + * uclogic_params_pen_init_v1() - initialize tablet interface pen + * input and retrieve its parameters from the device, using v1 protocol. * * @pen: Pointer to the pen parameters to initialize (to be * cleaned up with uclogic_params_pen_cleanup()). Not modified in @@ -132,9 +132,9 @@ static void uclogic_params_pen_cleanup(struct uclogic_params_pen *pen) * Returns: * Zero, if successful. A negative errno code on error. */ -static int uclogic_params_pen_init(struct uclogic_params_pen *pen, - bool *pfound, - struct hid_device *hdev) +static int uclogic_params_pen_init_v1(struct uclogic_params_pen *pen, + bool *pfound, + struct hid_device *hdev) { int rc; bool found = false; @@ -202,8 +202,8 @@ static int uclogic_params_pen_init(struct uclogic_params_pen *pen, * Generate pen report descriptor */ desc_ptr = uclogic_rdesc_template_apply( - uclogic_rdesc_pen_template_arr, - uclogic_rdesc_pen_template_size, + uclogic_rdesc_pen_v1_template_arr, + uclogic_rdesc_pen_v1_template_size, desc_params, ARRAY_SIZE(desc_params)); if (desc_ptr == NULL) { rc = -ENOMEM; @@ -216,8 +216,8 @@ static int uclogic_params_pen_init(struct uclogic_params_pen *pen, memset(pen, 0, sizeof(*pen)); pen->desc_ptr = desc_ptr; desc_ptr = NULL; - pen->desc_size = uclogic_rdesc_pen_template_size; - pen->id = UCLOGIC_RDESC_PEN_ID; + pen->desc_size = uclogic_rdesc_pen_v1_template_size; + pen->id = UCLOGIC_RDESC_PEN_V1_ID; pen->inrange = UCLOGIC_PARAMS_PEN_INRANGE_INVERTED; found = true; finish: @@ -280,8 +280,8 @@ static int uclogic_params_frame_init_with_desc( } /** - * uclogic_params_frame_init_buttonpad() - initialize abstract buttonpad - * on a tablet interface. + * uclogic_params_frame_init_v1_buttonpad() - initialize abstract buttonpad + * on a v1 tablet interface. * * @frame: Pointer to the frame parameters to initialize (to be cleaned * up with uclogic_params_frame_cleanup()). Not modified in case @@ -295,7 +295,7 @@ static int uclogic_params_frame_init_with_desc( * Returns: * Zero, if successful. A negative errno code on error. */ -static int uclogic_params_frame_init_buttonpad( +static int uclogic_params_frame_init_v1_buttonpad( struct uclogic_params_frame *frame, bool *pfound, struct hid_device *hdev) @@ -335,9 +335,9 @@ static int uclogic_params_frame_init_buttonpad( hid_dbg(hdev, "generic buttons enabled\n"); rc = uclogic_params_frame_init_with_desc( frame, - uclogic_rdesc_buttonpad_arr, - uclogic_rdesc_buttonpad_size, - UCLOGIC_RDESC_BUTTONPAD_ID); + uclogic_rdesc_buttonpad_v1_arr, + uclogic_rdesc_buttonpad_v1_size, + UCLOGIC_RDESC_BUTTONPAD_V1_ID); if (rc != 0) goto cleanup; found = true; @@ -577,23 +577,23 @@ static int uclogic_params_huion_init(struct uclogic_params *params, goto output; } - /* Try to probe pen parameters */ - rc = uclogic_params_pen_init(&p.pen, &found, hdev); + /* Try to probe v1 pen parameters */ + rc = uclogic_params_pen_init_v1(&p.pen, &found, hdev); if (rc != 0) { hid_err(hdev, - "failed probing pen parameters: %d\n", rc); + "failed probing pen v1 parameters: %d\n", rc); goto cleanup; } else if (found) { - hid_dbg(hdev, "pen parameters found\n"); - /* Try to probe buttonpad */ - rc = uclogic_params_frame_init_buttonpad( + hid_dbg(hdev, "pen v1 parameters found\n"); + /* Try to probe v1 buttonpad */ + rc = uclogic_params_frame_init_v1_buttonpad( &p.frame, &found, hdev); if (rc != 0) { hid_err(hdev, "v1 buttonpad probing failed: %d\n", rc); goto cleanup; } - hid_dbg(hdev, "buttonpad parameters%s found\n", + hid_dbg(hdev, "buttonpad v1 parameters%s found\n", (found ? "" : " not")); if (found) { /* Set bitmask marking frame reports */ @@ -601,7 +601,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params, } goto output; } - hid_dbg(hdev, "pen parameters not found\n"); + hid_dbg(hdev, "pen v1 parameters not found\n"); uclogic_params_init_invalid(&p); @@ -776,8 +776,8 @@ int uclogic_params_init(struct uclogic_params *params, USB_DEVICE_ID_UGEE_TABLET_EX07S): /* If this is the pen interface */ if (bInterfaceNumber == 1) { - /* Probe pen parameters */ - rc = uclogic_params_pen_init(&p.pen, &found, hdev); + /* Probe v1 pen parameters */ + rc = uclogic_params_pen_init_v1(&p.pen, &found, hdev); if (rc != 0) { hid_err(hdev, "pen probing failed: %d\n", rc); goto cleanup; diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index e9053d28f4e0..359e72394d83 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -531,8 +531,8 @@ __u8 uclogic_rdesc_twha60_fixed1_arr[] = { const size_t uclogic_rdesc_twha60_fixed1_size = sizeof(uclogic_rdesc_twha60_fixed1_arr); -/* Fixed report descriptor template for (tweaked) pen reports */ -const __u8 uclogic_rdesc_pen_template_arr[] = { +/* Fixed report descriptor template for (tweaked) v1 pen reports */ +const __u8 uclogic_rdesc_pen_v1_template_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x02, /* Usage (Pen), */ 0xA1, 0x01, /* Collection (Application), */ @@ -582,8 +582,8 @@ const __u8 uclogic_rdesc_pen_template_arr[] = { 0xC0 /* End Collection */ }; -const size_t uclogic_rdesc_pen_template_size = - sizeof(uclogic_rdesc_pen_template_arr); +const size_t uclogic_rdesc_pen_v1_template_size = + sizeof(uclogic_rdesc_pen_v1_template_arr); /** * Expand to the contents of a generic buttonpad report descriptor. @@ -631,12 +631,12 @@ const size_t uclogic_rdesc_pen_template_size = 0xC0, /* End Collection, */ \ 0xC0 /* End Collection */ -/* Fixed report descriptor for (tweaked) buttonpad reports */ -const __u8 uclogic_rdesc_buttonpad_arr[] = { +/* Fixed report descriptor for (tweaked) v1 buttonpad reports */ +const __u8 uclogic_rdesc_buttonpad_v1_arr[] = { UCLOGIC_RDESC_BUTTONPAD_BYTES(20) }; -const size_t uclogic_rdesc_buttonpad_size = - sizeof(uclogic_rdesc_buttonpad_arr); +const size_t uclogic_rdesc_buttonpad_v1_size = + sizeof(uclogic_rdesc_buttonpad_v1_arr); /** * uclogic_rdesc_template_apply() - apply report descriptor parameters to a diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index 610575879522..cf03b98ae7cb 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -100,18 +100,18 @@ enum uclogic_rdesc_pen_ph_id { #define UCLOGIC_RDESC_PEN_PH(_ID) \ UCLOGIC_RDESC_PH_HEAD, UCLOGIC_RDESC_PEN_PH_ID_##_ID -/* Report ID for pen reports */ -#define UCLOGIC_RDESC_PEN_ID 0x07 +/* Report ID for v1 pen reports */ +#define UCLOGIC_RDESC_PEN_V1_ID 0x07 -/* Fixed report descriptor template for (tweaked) pen reports */ -extern const __u8 uclogic_rdesc_pen_template_arr[]; -extern const size_t uclogic_rdesc_pen_template_size; +/* Fixed report descriptor template for (tweaked) v1 pen reports */ +extern const __u8 uclogic_rdesc_pen_v1_template_arr[]; +extern const size_t uclogic_rdesc_pen_v1_template_size; -/* Fixed report descriptor for (tweaked) buttonpad reports */ -extern const __u8 uclogic_rdesc_buttonpad_arr[]; -extern const size_t uclogic_rdesc_buttonpad_size; +/* Fixed report descriptor for (tweaked) v1 buttonpad reports */ +extern const __u8 uclogic_rdesc_buttonpad_v1_arr[]; +extern const size_t uclogic_rdesc_buttonpad_v1_size; -/* Report ID for tweaked buttonpad reports */ -#define UCLOGIC_RDESC_BUTTONPAD_ID 0xf7 +/* Report ID for tweaked v1 buttonpad reports */ +#define UCLOGIC_RDESC_BUTTONPAD_V1_ID 0xf7 #endif /* _HID_UCLOGIC_RDESC_H */ From patchwork Sun Feb 10 10:13:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804681 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9550713B4 for ; Sun, 10 Feb 2019 10:14:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85DEC29F45 for ; Sun, 10 Feb 2019 10:14:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A64329F4A; Sun, 10 Feb 2019 10:14:59 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 D38C329F45 for ; Sun, 10 Feb 2019 10:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726039AbfBJKO4 (ORCPT ); Sun, 10 Feb 2019 05:14:56 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:45647 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbfBJKO4 (ORCPT ); Sun, 10 Feb 2019 05:14:56 -0500 Received: by mail-lf1-f67.google.com with SMTP id b20so5563476lfa.12 for ; Sun, 10 Feb 2019 02:14:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uY10ww5hzdghirBbKuQUXgFqVULtl4pVHo9UL7xgc9o=; b=tJaaiarmAwwikvvghzLDABlW9acBRqd4kNZTN59BPMTmsZUoZvjS3eDZxlwe0byYvj l5jPhsfZYKdFtKzGGK0lpmAhTw+y4iLEw9L+gBAZWOEY89eoQgs7sQd64VpEAuBRC0+K h2VfQE/yWLssklCNIgC3oYx9f2yIRkEV6D0nw3qty7ckCmecD65nE1tlGwYDZO/+lpin mrUSiz462O5W4ncv1sImdMHd6rxaYSU2O9jpIQBFoYOAf6daz81QHOO+WqMLaY9ie6nB fAIO1W8ryziC9IfpggRjI6EmkybnuPpIdrLJb5dMRhz403iNbfYr3tI+o8YTPqPGITJW pniQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uY10ww5hzdghirBbKuQUXgFqVULtl4pVHo9UL7xgc9o=; b=ptWx/FWrND8tZaIMTb+2k2/a0TXELOuFw2tjCYK0y0dx2GsMxYZdzj40ukpVifCLPm RtrZKcSpzwg7A6StIqEHmnYkytFq2IujjRlccnyhjXSJDbESI1BzM4SEGrfeDma4j4Ye pS8ltT877n26uFnflT54gPvAcksJFroIejOsFHLIR8vwbKRXN18NtZ08t6ZWekdINm19 mj1J36SHKGtkT5IElsBzGJrVvCShdciAcMz00X2KKpIXJUbWICIwtf63S89QZG2QJmLI 7jRvYHDrC+Rz7dAp3PjAcoC5yVMz8ntAapnxcUeKbO5d0AyiwU4oJl36PiWswOWOIErI Tbsg== X-Gm-Message-State: AHQUAuYYfuRnwiSV+qWLDEQtIgOEAyQXELt8GDlblYIXSK9OmKhsslut kIDRA2ddUxxgXDLHcfrhtho= X-Google-Smtp-Source: AHgI3IbuC72jo0RYi6aaavgqVwuT6LsFZFC1TGJOFNoqzkZgg4P6Hi7nU+gLw6UIvOuwepojXZMAxw== X-Received: by 2002:ac2:520f:: with SMTP id a15mr12930388lfl.110.1549793693114; Sun, 10 Feb 2019 02:14:53 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:52 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 08/23] HID: uclogic: Support in-range reporting emulation Date: Sun, 10 Feb 2019 12:13:54 +0200 Message-Id: <20190210101409.3511-9-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Newer UC-Logic tablets, such as ones made by Huion have stopped reporting in-range state, but they're otherwise worthy tablets. The manufacturer was notified of the problem and promised to fix this in the future. Meanwhile, detect pen coming in range, and emulate the reports to the userspace, to make the tablets useable. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-core.c | 54 ++++++++++++++++++++++++++++++++ drivers/hid/hid-uclogic-params.c | 2 ++ drivers/hid/hid-uclogic-params.h | 2 ++ 3 files changed, 58 insertions(+) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 8f8e445d77aa..206642802ca5 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "usbhid/usbhid.h" #include "hid-uclogic-params.h" @@ -32,8 +33,40 @@ struct uclogic_drvdata { * Only valid if desc_ptr is not NULL */ unsigned int desc_size; + /* Pen input device */ + struct input_dev *pen_input; + /* In-range timer */ + struct timer_list inrange_timer; }; +/** + * uclogic_inrange_timeout - handle pen in-range state timeout. + * Emulate input events normally generated when pen goes out of range for + * tablets which don't report that. + * + * @t: The timer the timeout handler is attached to, stored in a struct + * uclogic_drvdata. + */ +static void uclogic_inrange_timeout(struct timer_list *t) +{ + struct uclogic_drvdata *drvdata = from_timer(drvdata, t, + inrange_timer); + struct input_dev *input = drvdata->pen_input; + + if (input == NULL) + return; + input_report_abs(input, ABS_PRESSURE, 0); + /* If BTN_TOUCH state is changing */ + if (test_bit(BTN_TOUCH, input->key)) { + input_event(input, EV_MSC, MSC_SCAN, + /* Digitizer Tip Switch usage */ + 0xd0042); + input_report_key(input, BTN_TOUCH, 0); + } + input_report_key(input, BTN_TOOL_PEN, 0); + input_sync(input); +} + static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { @@ -67,6 +100,8 @@ static int uclogic_input_mapping(struct hid_device *hdev, static int uclogic_input_configured(struct hid_device *hdev, struct hid_input *hi) { + struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + struct uclogic_params *params = &drvdata->params; char *name; const char *suffix = NULL; struct hid_field *field; @@ -76,6 +111,15 @@ static int uclogic_input_configured(struct hid_device *hdev, if (!hi->report) return 0; + /* + * If this is the input corresponding to the pen report + * in need of tweaking. + */ + if (hi->report->id == params->pen.id) { + /* Remember the input device so we can simulate events */ + drvdata->pen_input = hi->input; + } + field = hi->report->field[0]; switch (field->application) { @@ -130,6 +174,7 @@ static int uclogic_probe(struct hid_device *hdev, rc = -ENOMEM; goto failure; } + timer_setup(&drvdata->inrange_timer, uclogic_inrange_timeout, 0); hid_set_drvdata(hdev, drvdata); /* Initialize the device and retrieve interface parameters */ @@ -220,6 +265,14 @@ static int uclogic_raw_event(struct hid_device *hdev, /* Invert the in-range bit */ data[1] ^= 0x40; } + /* If we need to emulate in-range detection */ + if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) { + /* Set in-range bit */ + data[1] |= 0x40; + /* (Re-)start in-range timeout */ + mod_timer(&drvdata->inrange_timer, + jiffies + msecs_to_jiffies(100)); + } } return 0; @@ -229,6 +282,7 @@ static void uclogic_remove(struct hid_device *hdev) { struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + del_timer_sync(&drvdata->inrange_timer); hid_hw_stop(hdev); kfree(drvdata->desc_ptr); uclogic_params_cleanup(&drvdata->params); diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index f555db120baa..b5e4d99c6771 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -36,6 +36,8 @@ const char *uclogic_params_pen_inrange_to_str( return "normal"; case UCLOGIC_PARAMS_PEN_INRANGE_INVERTED: return "inverted"; + case UCLOGIC_PARAMS_PEN_INRANGE_NONE: + return "none"; default: return NULL; } diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index 4c78d9dd0576..665954d6ba57 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -25,6 +25,8 @@ enum uclogic_params_pen_inrange { UCLOGIC_PARAMS_PEN_INRANGE_NORMAL = 0, /* Inverted reports: zero - in proximity, one - out of proximity */ UCLOGIC_PARAMS_PEN_INRANGE_INVERTED, + /* No reports */ + UCLOGIC_PARAMS_PEN_INRANGE_NONE, }; /* Convert a pen in-range reporting type to a string */ From patchwork Sun Feb 10 10:13:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804677 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D901417E6 for ; Sun, 10 Feb 2019 10:14:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7A0829F4A for ; Sun, 10 Feb 2019 10:14:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC54D29F51; Sun, 10 Feb 2019 10:14:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 DFF1B29F4A for ; Sun, 10 Feb 2019 10:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726042AbfBJKO5 (ORCPT ); Sun, 10 Feb 2019 05:14:57 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:38274 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKO5 (ORCPT ); Sun, 10 Feb 2019 05:14:57 -0500 Received: by mail-lf1-f66.google.com with SMTP id n15so1463956lfe.5 for ; Sun, 10 Feb 2019 02:14:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7B8Q3XJHYFZkX+3LUqYPNglwUSc3/w36EcJnFsGUeqc=; b=QZQkht8+Sply3tSWnB59DqNppYWhafogE8bSzejNUE7bo/UsqieF9D1u7M3sM5RMyI ZQwnu8pTVh2PfigGNX79inxQw6gaqBSwI14V2/2OEmT9iTQHUY6Km0x4KpzKaY/97U3s SB5p9sXaHkF1L/au2/mVCxUM3OSeQMNV7ygzExJpLjSkI6lrNfiCUdHnkis22bm6pHRA rW+NUO/PYbRglMbkCl2DTI4vHS/yU6vrGp0WSd0OhNXiyq3OhZFjqPCYeBr/TUR9r429 SIUf4EMMH80Dc2LOsYfROgFhPCMRCGxsYOwUOHfF4vURqb2qJYeHvq1qOibIP1N71Jdo kZjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7B8Q3XJHYFZkX+3LUqYPNglwUSc3/w36EcJnFsGUeqc=; b=cmbr7UAapMhP+zFvGLd8PUYNWRaeVGYFQpZMfdL4adhcQ3f75/jVyGAccHZCHeHQOD HTcLDtqoAd7UBDB8BR89FyK2N/PRR5oZoG237/l7mTGvMlqF7uBhe2uu5YOtWUEvimuw frOgCKekFW8HZoxC4BxBa1J228AA1eOWZuZABdyIW9HFHU+Xb++fqJhSsjzQSMVyxrZA wbEM2BvAkow3ytQNQWaDz/838odUwo07CR1ra3aAINH8epnnNBCD/O+0lnF7vDu5Vxsi awxReF6sM5H/KqNQv63FEIk4+gAJ7C+JgZt7mLN68qSbT5Y0YLLPXSWY7poMs4cjio4c nfgA== X-Gm-Message-State: AHQUAuaZbouO31AcYfckfd91n7VitqDKopwooJczNz3OPh1YXFYpwYZh nG/NAin/pZ14ghfhyBhwCOMciZy4WEY= X-Google-Smtp-Source: AHgI3IYyJktIW47cNDRMHxSabQXgoxUleHUGLwJi+w2NsphTeoRfiZyvyf84+man/AQHPg1T9l8K0g== X-Received: by 2002:a19:aa87:: with SMTP id t129mr19631744lfe.139.1549793694305; Sun, 10 Feb 2019 02:14:54 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:53 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 09/23] HID: uclogic: Support fragmented high-res reports Date: Sun, 10 Feb 2019 12:13:55 +0200 Message-Id: <20190210101409.3511-10-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Support parsing fragmented high-resolution reports in hid-uclogic to support v2 reporting protocol. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-core.c | 25 +++++++++++++++++++++++++ drivers/hid/hid-uclogic-params.h | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 206642802ca5..81693183d647 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -265,6 +265,31 @@ static int uclogic_raw_event(struct hid_device *hdev, /* Invert the in-range bit */ data[1] ^= 0x40; } + /* + * If report contains fragmented high-resolution pen + * coordinates + */ + if (size >= 10 && params->pen.fragmented_hires) { + u8 pressure_low_byte; + u8 pressure_high_byte; + + /* Lift pressure bytes */ + pressure_low_byte = data[6]; + pressure_high_byte = data[7]; + /* + * Move Y coord to make space for high-order X + * coord byte + */ + data[6] = data[5]; + data[5] = data[4]; + /* Move high-order X coord byte */ + data[4] = data[8]; + /* Move high-order Y coord byte */ + data[7] = data[9]; + /* Place pressure bytes */ + data[8] = pressure_low_byte; + data[9] = pressure_high_byte; + } /* If we need to emulate in-range detection */ if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) { /* Set in-range bit */ diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index 665954d6ba57..1060f70d647d 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -56,6 +56,12 @@ struct uclogic_params_pen { unsigned int id; /* Type of in-range reporting, only valid if "id" is not zero */ enum uclogic_params_pen_inrange inrange; + /* + * True, if reports include fragmented high resolution coords, with + * high-order X and then Y bytes following the pressure field. + * Only valid if "id" is not zero. + */ + bool fragmented_hires; }; /* @@ -151,6 +157,7 @@ extern int uclogic_params_init(struct uclogic_params *params, ".pen.desc_size = %u\n" \ ".pen.id = %u\n" \ ".pen.inrange = %s\n" \ + ".pen.fragmented_hires = %s\n" \ ".frame.desc_ptr = %p\n" \ ".frame.desc_size = %u\n" \ ".frame.id = %u\n" \ @@ -166,6 +173,7 @@ extern int uclogic_params_init(struct uclogic_params *params, (_params)->pen.desc_size, \ (_params)->pen.id, \ uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \ + ((_params)->pen.fragmented_hires ? "true" : "false"), \ (_params)->frame.desc_ptr, \ (_params)->frame.desc_size, \ (_params)->frame.id, \ From patchwork Sun Feb 10 10:13:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804685 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAA6817E6 for ; Sun, 10 Feb 2019 10:15:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B6B429F45 for ; Sun, 10 Feb 2019 10:15:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9015529F4A; Sun, 10 Feb 2019 10:15:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 9CD2129F45 for ; Sun, 10 Feb 2019 10:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726057AbfBJKO7 (ORCPT ); Sun, 10 Feb 2019 05:14:59 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45770 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbfBJKO7 (ORCPT ); Sun, 10 Feb 2019 05:14:59 -0500 Received: by mail-lj1-f194.google.com with SMTP id s5-v6so6393706ljd.12 for ; Sun, 10 Feb 2019 02:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8LI3jyyLVjAvJ8UGlLXNBKVjgTsUU9vGgQIM6PrLP+s=; b=U06AkolCr0+Nq0rx3o6wIJpl6Apo2wshe16JXrj3ndl8ZGicg4gIetK8WJb6SAnjos UL9ndU/KnpsjnftcuEnK2f/9vUJUtEwgC2azTf/RROOMksiKQg3yBDBWiM2R+KtVHosO sdMiPfhegKxUk5FeMWDX7nv7o+504jLQH/nJLVCTDT0TP1edBD6bzHGgq3pWKPB4b57/ 88a9IRywgfGcsZdFxLKdVEL3UjBXsnzUhaD5dCaUp/Zhu9+9zz8NPlHyQZZEunyOdPbP luB5akwd2aluMbo+SgYWu/8XaY/UBJISbPEqqjzXwLllvo8cjUf5yLmJk8Em45MzeKcN sCGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8LI3jyyLVjAvJ8UGlLXNBKVjgTsUU9vGgQIM6PrLP+s=; b=nXWcBc6Ony2gPYlySbKWPNkHMhjEkRKpu4vntES9Vk+pFy8HK5dWnga8/n4g2rdmOi cP0Qj7hlj6O+11wZfaJRDJ9ShE959peF+iRyj7XhQCwuOyF5MR5GEDajCPmte5EcmSPR ImkgKTr6/CBWaW7/koPWJEDAqPpRWq8LhzWFZI6nHNNCIVA985l8ZH7F1ah6e7lUg7On 1ieK3gyNdKvVv+9Y5gBNZo9IGWwx3/1cIES0Whz+Uv3E3onXUb4i66JOrN9ljqDS8Dac N8YxtlxImWxv6AiErcVEz6xjLeBRfAhJl0dwePTXSwUj/GhfNizOzwNgCnhk4LxK9+i1 AI1A== X-Gm-Message-State: AHQUAubj6uUw3K8e2TeQyfkaAC2h+iC0GisDfFY7tsZEbNv4iCzxM+X2 2R6wdtsGU7ce/xpB72se3I96MXed2bM= X-Google-Smtp-Source: AHgI3IZVXp/1JEY28oZ2w2v2z8XBI/zag49VJYdArswH6uKziYYwB8r3FQdOet5SbwzyF67a19GvHg== X-Received: by 2002:a2e:e02:: with SMTP id 2-v6mr12384148ljo.10.1549793695696; Sun, 10 Feb 2019 02:14:55 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:54 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 10/23] HID: uclogic: Support v2 protocol Date: Sun, 10 Feb 2019 12:13:56 +0200 Message-Id: <20190210101409.3511-11-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for UC-Logic v2 protocol to hid-uclogic. This adds support for a bunch of new Huion models. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-params.c | 201 +++++++++++++++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.c | 63 ++++++++++ drivers/hid/hid-uclogic-rdesc.h | 14 +++ 3 files changed, 278 insertions(+) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index b5e4d99c6771..132663a87f38 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -231,6 +231,151 @@ static int uclogic_params_pen_init_v1(struct uclogic_params_pen *pen, return rc; } +/** + * uclogic_params_get_le24() - get a 24-bit little-endian number from a + * buffer. + * + * @p: The pointer to the number buffer. + * + * Returns: + * The retrieved number + */ +static s32 uclogic_params_get_le24(const void *p) +{ + const __u8 *b = p; + return b[0] | (b[1] << 8UL) | (b[2] << 16UL); +} + +/** + * uclogic_params_pen_init_v2() - initialize tablet interface pen + * input and retrieve its parameters from the device, using v2 protocol. + * + * @pen: Pointer to the pen parameters to initialize (to be + * cleaned up with uclogic_params_pen_cleanup()). Not modified in + * case of error, or if parameters are not found. Cannot be NULL. + * @pfound: Location for a flag which is set to true if the parameters + * were found, and to false if not (e.g. device was + * incompatible). Not modified in case of error. Cannot be NULL. + * @hdev: The HID device of the tablet interface to initialize and get + * parameters from. Cannot be NULL. + * + * Returns: + * Zero, if successful. A negative errno code on error. + */ +static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen, + bool *pfound, + struct hid_device *hdev) +{ + int rc; + bool found = false; + /* Buffer for (part of) the string descriptor */ + __u8 *buf = NULL; + /* Descriptor length required */ + const int len = 18; + s32 resolution; + /* Pen report descriptor template parameters */ + s32 desc_params[UCLOGIC_RDESC_PEN_PH_ID_NUM]; + __u8 *desc_ptr = NULL; + + /* Check arguments */ + if (pen == NULL || pfound == NULL || hdev == NULL) { + rc = -EINVAL; + goto cleanup; + } + + /* + * Read string descriptor containing pen input parameters. + * The specific string descriptor and data were discovered by sniffing + * the Windows driver traffic. + * NOTE: This enables fully-functional tablet mode. + */ + rc = uclogic_params_get_str_desc(&buf, hdev, 200, len); + if (rc == -EPIPE) { + hid_dbg(hdev, + "string descriptor with pen parameters not found, assuming not compatible\n"); + goto finish; + } else if (rc < 0) { + hid_err(hdev, "failed retrieving pen parameters: %d\n", rc); + goto cleanup; + } else if (rc != len) { + hid_dbg(hdev, + "string descriptor with pen parameters has invalid length (got %d, expected %d), assuming not compatible\n", + rc, len); + goto finish; + } else { + size_t i; + /* + * Check it's not just a catch-all UTF-16LE-encoded ASCII + * string (such as the model name) some tablets put into all + * unknown string descriptors. + */ + for (i = 2; + i < len && + (buf[i] >= 0x20 && buf[i] < 0x7f && buf[i + 1] == 0); + i += 2); + if (i >= len) { + hid_dbg(hdev, + "string descriptor with pen parameters seems to contain only text, assuming not compatible\n"); + goto finish; + } + } + + /* + * Fill report descriptor parameters from the string descriptor + */ + desc_params[UCLOGIC_RDESC_PEN_PH_ID_X_LM] = + uclogic_params_get_le24(buf + 2); + desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] = + uclogic_params_get_le24(buf + 5); + desc_params[UCLOGIC_RDESC_PEN_PH_ID_PRESSURE_LM] = + get_unaligned_le16(buf + 8); + resolution = get_unaligned_le16(buf + 10); + if (resolution == 0) { + desc_params[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = 0; + desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_PM] = 0; + } else { + desc_params[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = + desc_params[UCLOGIC_RDESC_PEN_PH_ID_X_LM] * 1000 / + resolution; + desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_PM] = + desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] * 1000 / + resolution; + } + kfree(buf); + buf = NULL; + + /* + * Generate pen report descriptor + */ + desc_ptr = uclogic_rdesc_template_apply( + uclogic_rdesc_pen_v2_template_arr, + uclogic_rdesc_pen_v2_template_size, + desc_params, ARRAY_SIZE(desc_params)); + if (desc_ptr == NULL) { + rc = -ENOMEM; + goto cleanup; + } + + /* + * Fill-in the parameters + */ + memset(pen, 0, sizeof(*pen)); + pen->desc_ptr = desc_ptr; + desc_ptr = NULL; + pen->desc_size = uclogic_rdesc_pen_v2_template_size; + pen->id = UCLOGIC_RDESC_PEN_V2_ID; + pen->inrange = UCLOGIC_PARAMS_PEN_INRANGE_NONE; + pen->fragmented_hires = true; + found = true; +finish: + *pfound = found; + rc = 0; +cleanup: + kfree(desc_ptr); + kfree(buf); + return rc; +} + /** * uclogic_params_frame_cleanup - free resources used by struct * uclogic_params_frame (tablet interface's frame controls input parameters). @@ -560,11 +705,15 @@ static int uclogic_params_huion_init(struct uclogic_params *params, struct hid_device *hdev) { int rc; + struct usb_device *udev = hid_to_usb_dev(hdev); struct usb_interface *iface = to_usb_interface(hdev->dev.parent); __u8 bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; bool found; /* The resulting parameters (noop) */ struct uclogic_params p = {0, }; + static const char transition_ver[] = "HUION_T153_160607"; + char *ver_ptr = NULL; + const size_t ver_len = sizeof(transition_ver) + 1; /* Check arguments */ if (params == NULL || hdev == NULL) { @@ -579,6 +728,57 @@ static int uclogic_params_huion_init(struct uclogic_params *params, goto output; } + /* Try to get firmware version */ + ver_ptr = kzalloc(ver_len, GFP_KERNEL); + if (ver_ptr == NULL) { + rc = -ENOMEM; + goto cleanup; + } + rc = usb_string(udev, 201, ver_ptr, ver_len); + if (ver_ptr == NULL) { + rc = -ENOMEM; + goto cleanup; + } + if (rc == -EPIPE) { + *ver_ptr = '\0'; + } else if (rc < 0) { + hid_err(hdev, + "failed retrieving Huion firmware version: %d\n", rc); + goto cleanup; + } + + /* If this is a transition firmware */ + if (strcmp(ver_ptr, transition_ver) == 0) { + hid_dbg(hdev, + "transition firmware detected, not probing pen v2 parameters\n"); + } else { + /* Try to probe v2 pen parameters */ + rc = uclogic_params_pen_init_v2(&p.pen, &found, hdev); + if (rc != 0) { + hid_err(hdev, + "failed probing pen v2 parameters: %d\n", rc); + goto cleanup; + } else if (found) { + hid_dbg(hdev, "pen v2 parameters found\n"); + /* Create v2 buttonpad parameters */ + rc = uclogic_params_frame_init_with_desc( + &p.frame, + uclogic_rdesc_buttonpad_v2_arr, + uclogic_rdesc_buttonpad_v2_size, + UCLOGIC_RDESC_BUTTONPAD_V2_ID); + if (rc != 0) { + hid_err(hdev, + "failed creating v2 buttonpad parameters: %d\n", + rc); + goto cleanup; + } + /* Set bitmask marking frame reports in pen reports */ + p.pen_frame_flag = 0x20; + goto output; + } + hid_dbg(hdev, "pen v2 parameters not found\n"); + } + /* Try to probe v1 pen parameters */ rc = uclogic_params_pen_init_v1(&p.pen, &found, hdev); if (rc != 0) { @@ -613,6 +813,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params, memset(&p, 0, sizeof(p)); rc = 0; cleanup: + kfree(ver_ptr); uclogic_params_cleanup(&p); return rc; } diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index 359e72394d83..ef1d3cf918a4 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -585,6 +585,62 @@ const __u8 uclogic_rdesc_pen_v1_template_arr[] = { const size_t uclogic_rdesc_pen_v1_template_size = sizeof(uclogic_rdesc_pen_v1_template_arr); +/* Fixed report descriptor template for (tweaked) v2 pen reports */ +const __u8 uclogic_rdesc_pen_v2_template_arr[] = { + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x02, /* Usage (Pen), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x08, /* Report ID (8), */ + 0x09, 0x20, /* Usage (Stylus), */ + 0xA0, /* Collection (Physical), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x09, 0x42, /* Usage (Tip Switch), */ + 0x09, 0x44, /* Usage (Barrel Switch), */ + 0x09, 0x46, /* Usage (Tablet Pick), */ + 0x95, 0x03, /* Report Count (3), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x03, /* Report Count (3), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x09, 0x32, /* Usage (In Range), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x95, 0x01, /* Report Count (1), */ + 0xA4, /* Push, */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x65, 0x13, /* Unit (Inch), */ + 0x55, 0xFD, /* Unit Exponent (-3), */ + 0x75, 0x18, /* Report Size (24), */ + 0x34, /* Physical Minimum (0), */ + 0x09, 0x30, /* Usage (X), */ + 0x27, UCLOGIC_RDESC_PEN_PH(X_LM), + /* Logical Maximum (PLACEHOLDER), */ + 0x47, UCLOGIC_RDESC_PEN_PH(X_PM), + /* Physical Maximum (PLACEHOLDER), */ + 0x81, 0x02, /* Input (Variable), */ + 0x09, 0x31, /* Usage (Y), */ + 0x27, UCLOGIC_RDESC_PEN_PH(Y_LM), + /* Logical Maximum (PLACEHOLDER), */ + 0x47, UCLOGIC_RDESC_PEN_PH(Y_PM), + /* Physical Maximum (PLACEHOLDER), */ + 0x81, 0x02, /* Input (Variable), */ + 0xB4, /* Pop, */ + 0x09, 0x30, /* Usage (Tip Pressure), */ + 0x75, 0x10, /* Report Size (16), */ + 0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM), + /* Logical Maximum (PLACEHOLDER), */ + 0x81, 0x02, /* Input (Variable), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0xC0, /* End Collection, */ + 0xC0 /* End Collection */ +}; + +const size_t uclogic_rdesc_pen_v2_template_size = + sizeof(uclogic_rdesc_pen_v2_template_arr); + /** * Expand to the contents of a generic buttonpad report descriptor. * @@ -638,6 +694,13 @@ const __u8 uclogic_rdesc_buttonpad_v1_arr[] = { const size_t uclogic_rdesc_buttonpad_v1_size = sizeof(uclogic_rdesc_buttonpad_v1_arr); +/* Fixed report descriptor for (tweaked) v2 buttonpad reports */ +const __u8 uclogic_rdesc_buttonpad_v2_arr[] = { + UCLOGIC_RDESC_BUTTONPAD_BYTES(52) +}; +const size_t uclogic_rdesc_buttonpad_v2_size = + sizeof(uclogic_rdesc_buttonpad_v2_arr); + /** * uclogic_rdesc_template_apply() - apply report descriptor parameters to a * report descriptor template, creating a report descriptor. Copies the diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index cf03b98ae7cb..f205254a733c 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -107,6 +107,13 @@ enum uclogic_rdesc_pen_ph_id { extern const __u8 uclogic_rdesc_pen_v1_template_arr[]; extern const size_t uclogic_rdesc_pen_v1_template_size; +/* Report ID for v2 pen reports */ +#define UCLOGIC_RDESC_PEN_V2_ID 0x08 + +/* Fixed report descriptor template for (tweaked) v2 pen reports */ +extern const __u8 uclogic_rdesc_pen_v2_template_arr[]; +extern const size_t uclogic_rdesc_pen_v2_template_size; + /* Fixed report descriptor for (tweaked) v1 buttonpad reports */ extern const __u8 uclogic_rdesc_buttonpad_v1_arr[]; extern const size_t uclogic_rdesc_buttonpad_v1_size; @@ -114,4 +121,11 @@ extern const size_t uclogic_rdesc_buttonpad_v1_size; /* Report ID for tweaked v1 buttonpad reports */ #define UCLOGIC_RDESC_BUTTONPAD_V1_ID 0xf7 +/* Fixed report descriptor for (tweaked) v2 buttonpad reports */ +extern const __u8 uclogic_rdesc_buttonpad_v2_arr[]; +extern const size_t uclogic_rdesc_buttonpad_v2_size; + +/* Report ID for tweaked v2 buttonpad reports */ +#define UCLOGIC_RDESC_BUTTONPAD_V2_ID 0xf7 + #endif /* _HID_UCLOGIC_RDESC_H */ From patchwork Sun Feb 10 10:13:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804683 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78D9E13B4 for ; Sun, 10 Feb 2019 10:15:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B0EB29F46 for ; Sun, 10 Feb 2019 10:15:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EC6F29F4B; Sun, 10 Feb 2019 10:15:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 06D5529F46 for ; Sun, 10 Feb 2019 10:15:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726005AbfBJKO7 (ORCPT ); Sun, 10 Feb 2019 05:14:59 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38763 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKO7 (ORCPT ); Sun, 10 Feb 2019 05:14:59 -0500 Received: by mail-lj1-f194.google.com with SMTP id c19-v6so6431876lja.5 for ; Sun, 10 Feb 2019 02:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cty+WhSSS8R2xVu1lIL7Hd04HXzznx+i1a+mm8Ay504=; b=C7WnYWYl5ARVAnMN41z2kbLPj1DvDlqxWq1x4BMQZFHDSgQQoeW4GJ38ZrI3ZY5lCR TcTahrkoXENZwsvDEqy2iO864vcTpaHEKbiMhpfJ15LldA8vPQcmqytzG4uqoGgAIAD2 k1wKPVF7StL3dBrBccYtpdSFPdzsGzqGIIbwW2wLXTlLCKXVwiAxGc/WgCnHfUhr/LlV V6nHJ7u43+o6Pjor2GBw2WKj3FPwbIy1zM7Wh0MZCB1FDgmcVc6RqgktAW3lv1SxRfqI /URSHpRhYGYLXDi3DE2bvpq0wfuz7gDKqkNZsU9+NVaFLYv5Bb4JPjPH1UTMM0f0+7Yy gStQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cty+WhSSS8R2xVu1lIL7Hd04HXzznx+i1a+mm8Ay504=; b=bZRWXzCa4qOVpVd9AkS69JqNVEJzz3GEYAKCclGZclWZoo06QzA1628+Pz3eSwAE6r kwc47viGyv3zR3xvg0b8/hZfAAgv3JUA9JeL0lhp7CjELkMu4Hu8uLOyW/qrsdXHvYpr Sf5heStgvsTB3vQQH/0ZgFRMiO7nWism3kGHMXKT7WfpMWiLqxKuAjcuveK6PjGUQhZf Zrena3h4PDe09bXUHOskfhDbs2jZW3ZxmZ0Rk3jbGCVuLEJj9sPJfAVA8g5V8z3j7jZ2 x+oecyCHBcdZViJPznVIuBmwbKlxHFbxH7QQZIZleB6gA+sIimvLkS6CLU7Qsk9ki2D0 3lqg== X-Gm-Message-State: AHQUAuZ6jE36b+AyoGJ4psPeHHvjR9Nmpny+MdnFN2D/QjzwFL3ZoPCZ YzLGLwvOjjaxELSTiqkoR9k= X-Google-Smtp-Source: AHgI3IacONkl2p8v9xHs2fvuid0Zq+oJJ/SYnS5AA87DcTIuj8JaEDxH5YtgJotSWcCdj/sJurgDSw== X-Received: by 2002:a2e:980e:: with SMTP id a14-v6mr4306179ljj.119.1549793697240; Sun, 10 Feb 2019 02:14:57 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:56 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 11/23] HID: uclogic: Add support for Ugee 2150 Date: Sun, 10 Feb 2019 12:13:57 +0200 Message-Id: <20190210101409.3511-12-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for Ugee 2150 to hid-uclogic. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-uclogic-core.c | 2 ++ drivers/hid/hid-uclogic-params.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index f66553157be5..304476200c28 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1137,6 +1137,7 @@ #define USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3 0x3031 #define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81 0x0081 #define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45 0x0045 +#define USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_47 0x0047 #define USB_DEVICE_ID_YIYNOVA_TABLET 0x004d #define USB_VENDOR_ID_UGEE 0x28bd diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 81693183d647..33333a3e5ffe 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -338,6 +338,8 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_47) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 132663a87f38..f57bf2698374 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -969,6 +969,8 @@ int uclogic_params_init(struct uclogic_params *params, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3): case VID_PID(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45): + case VID_PID(USB_VENDOR_ID_UCLOGIC, + USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_47): rc = uclogic_params_huion_init(&p, hdev); if (rc != 0) goto cleanup; From patchwork Sun Feb 10 10:13:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804687 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DA681515 for ; Sun, 10 Feb 2019 10:15:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D0A329F45 for ; Sun, 10 Feb 2019 10:15:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C54629F4A; Sun, 10 Feb 2019 10:15: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0504B29F45 for ; Sun, 10 Feb 2019 10:15:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726088AbfBJKPB (ORCPT ); Sun, 10 Feb 2019 05:15:01 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34173 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKPB (ORCPT ); Sun, 10 Feb 2019 05:15:01 -0500 Received: by mail-lj1-f196.google.com with SMTP id v14-v6so6480629ljv.1 for ; Sun, 10 Feb 2019 02:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4mh56JFLbIWkust8+CV/wSEKZEPzwu6dYAwxjEoBgwk=; b=RpBTjzeH0EAK24HLPkALB8kLckVx6PJa/OdULqAyd3tZUNdw1GedmJauAKdssC2sut o3lRnqaIUfHTf34yT1T5OFstV079DGRrG192mejVTnT5H7t7mbqL7u+echmCl49FR7mr lyEKsX7lHpbFOjtZnS3hsm7l5+gw0Pn+/OTlClkSzRnn8A49P/h0q9D+wJM5zlmDK0Fc O9peLWjdwBAwak2xSh3m2+HrWRAwOB5ycjCdhN5prKbtik9l8jN4t1llge3v8nw02V7Z TCch81mgMkeD7t1tydM9MSHLht+2+fXgU6guNJK/phv8s6cCxnZFrXmVT79nPh6fgUNn YCsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4mh56JFLbIWkust8+CV/wSEKZEPzwu6dYAwxjEoBgwk=; b=e190GcpJkGp1eZMEHHdaGReNlnaEKN/ToqR++83gnpTzlZxpOC3UOMrYHAD4Jy3HEW JPNybKwll/BAPPKrClLwVhn/cbXV5J4mLYQnzqWSILHMrfBK68fjg4p73raOmQOUQlo7 6U3XJ5Z6xOZM82c7+Cc3N0Prz4Isyc31WxScWcdRTeqojnG+bSqKVXjdzP0xk+LvH4wb GRLjho+H1xC5bkXVmHmDMxnMhJpNmef5R44GpahHyY5gdpX2wgUoWVCeRbFB+YNXBtRm QmPWmBgKHc3ozGaYy3IdpodNWqS+MvN4am/bLDbUBj26HCiAtiNtjpkFcr6bAeJB1OnK aQ/g== X-Gm-Message-State: AHQUAuaJiJfTMY4IEDtby2JmLKnHtaZCqbN8horK0sfIU8zZHVsbsVn8 GhdQ1JbckfVPAaCoiY2W1OA= X-Google-Smtp-Source: AHgI3IalhQDCZLeBMvUbFhnqzAy6SKRG3GV3BUdZ8s8iY/HF7OiQuahUbaB8qvxRhjyh+MAqtMapfA== X-Received: by 2002:a2e:99d4:: with SMTP id l20-v6mr1384974ljj.142.1549793699135; Sun, 10 Feb 2019 02:14:59 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:58 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 12/23] HID: uclogic: Add support for Ugee M540 Date: Sun, 10 Feb 2019 12:13:58 +0200 Message-Id: <20190210101409.3511-13-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for Ugee M540 to hid-uclogic. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-params.c | 26 +++++++++++++++++++++++--- drivers/hid/hid-uclogic-rdesc.h | 3 +++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index f57bf2698374..72a073ae454c 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -897,9 +897,29 @@ int uclogic_params_init(struct uclogic_params *params, break; case VID_PID(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U): - rc = WITH_OPT_DESC(WPXXXXU_ORIG, wp5540u_fixed); - if (rc != 0) - goto cleanup; + if (hdev->dev_rsize == UCLOGIC_RDESC_WP5540U_V2_ORIG_SIZE) { + if (bInterfaceNumber == 0) { + /* Try to probe v1 pen parameters */ + rc = uclogic_params_pen_init_v1(&p.pen, + &found, hdev); + if (rc != 0) { + hid_err(hdev, + "pen probing failed: %d\n", + rc); + goto cleanup; + } + if (!found) { + hid_warn(hdev, + "pen parameters not found"); + } + } else { + uclogic_params_init_invalid(&p); + } + } else { + rc = WITH_OPT_DESC(WPXXXXU_ORIG, wp5540u_fixed); + if (rc != 0) + goto cleanup; + } break; case VID_PID(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U): diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index f205254a733c..cc5f3dd3804a 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -34,6 +34,9 @@ extern const size_t uclogic_rdesc_wp5540u_fixed_size; extern __u8 uclogic_rdesc_wp8060u_fixed_arr[]; extern const size_t uclogic_rdesc_wp8060u_fixed_size; +/* Size of the original descriptor of the new WP5540U tablet */ +#define UCLOGIC_RDESC_WP5540U_V2_ORIG_SIZE 232 + /* Size of the original descriptor of WP1062 tablet */ #define UCLOGIC_RDESC_WP1062_ORIG_SIZE 254 From patchwork Sun Feb 10 10:13:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804689 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D02021515 for ; Sun, 10 Feb 2019 10:15:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A5F29F46 for ; Sun, 10 Feb 2019 10:15:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B524A29F4B; Sun, 10 Feb 2019 10:15:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 3E3DA29F46 for ; Sun, 10 Feb 2019 10:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726093AbfBJKPC (ORCPT ); Sun, 10 Feb 2019 05:15:02 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40935 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfBJKPC (ORCPT ); Sun, 10 Feb 2019 05:15:02 -0500 Received: by mail-lj1-f196.google.com with SMTP id z25-v6so6418642ljk.7 for ; Sun, 10 Feb 2019 02:15:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p6naigFuhNcKdhKKWbyZ9CsQvLQs0OAH6plQx4jP89A=; b=Vg8AxEYtEJDWr1Kgvvm6to6cZgI1ixpgQTj0avZCdNnavZpL1JyaDQeByj9lSvERVA wuSTaWoynSsqt2WykxfMoFYdu6KJiSikXfqoCysPnNswWYtdzUD2JdcNPY37c67mdWgG UXG2Gz3LIphaiyjn6lckQr5l0O2zPP95+S2Ws8pyxAJS/NMEFoWAkLi9UDGt82/egaSx BFGhGmgwISLYftLX6ZyzbUx9mplUI88g6G3bnu1QYZwRKsYM0FeFY6OZm8JkYM5UW2WO mLayDAIPtkzVmBqUYALt+iFLAiktQWxctIUIdh84H4AFUpHA3dpgOi7slI80idu5wPSr g4dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p6naigFuhNcKdhKKWbyZ9CsQvLQs0OAH6plQx4jP89A=; b=SSYpQRPQsmgPZxfqcw6HhZg5F3M5I4zRg1mhs5CXTKn8MLc4RB+haqXp+b7Qa2Rdpw RfWMnvcu0SVinHW7mtR8UJgwjFaAXtYhYRHx/xjBvbDZ8swSBveWOI9TY2zOsRnI/c5O v16e7MzqrL4bkAPobKYYZVQsWmXxgvtgaz/g0UDfI6s/8Vg2XieHHaWpibdR8RXWmOqD 96nO9nBW4bgY4q+dyxXlWqqn7BHWgi9lZKjXwJdZr7nukgCPUQZgZgZw7y1gQNemMPvk WUvM3LUUqTUoXDsvqQxtsIkLVi7GDt9dQGiX4YRr+yIhxA8m9Gsj9rYLUKEo57lCVJ0U aJnA== X-Gm-Message-State: AHQUAuYbLuYooty0KzG0I6XFaNHt80JtHOZIXkQUGuIOW4e5VG9gldqm Ok6Bdv4TUVSC132JfkQcEv9epDHVoKM= X-Google-Smtp-Source: AHgI3Iai0P18AM0ls4MSXgN9gOOa80gdOJfXVqtcQNENkyrVLvPRnoOv0GyuXjRpYwmNXCvwhskXPg== X-Received: by 2002:a2e:7316:: with SMTP id o22-v6mr15186155ljc.82.1549793700501; Sun, 10 Feb 2019 02:15:00 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:59 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 13/23] HID: uclogic: Add support for Ugee EX07S frame controls Date: Sun, 10 Feb 2019 12:13:59 +0200 Message-Id: <20190210101409.3511-14-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add proper support for Ugee EX07(S) frame controls to hid-uclogic. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-params.c | 32 ++++++++++++++++++++++++++++++-- drivers/hid/hid-uclogic-rdesc.c | 27 +++++++++++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.h | 4 ++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 72a073ae454c..b22815cec06d 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -997,8 +997,6 @@ int uclogic_params_init(struct uclogic_params *params, break; case VID_PID(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610): - case VID_PID(USB_VENDOR_ID_UGEE, - USB_DEVICE_ID_UGEE_TABLET_EX07S): /* If this is the pen interface */ if (bInterfaceNumber == 1) { /* Probe v1 pen parameters */ @@ -1015,6 +1013,36 @@ int uclogic_params_init(struct uclogic_params *params, /* TODO: Consider marking the interface invalid */ uclogic_params_init_with_pen_unused(&p); } + break; + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_TABLET_EX07S): + /* Ignore non-pen interfaces */ + if (bInterfaceNumber != 1) { + uclogic_params_init_invalid(&p); + break; + } + + rc = uclogic_params_pen_init_v1(&p.pen, &found, hdev); + if (rc != 0) { + hid_err(hdev, "pen probing failed: %d\n", rc); + goto cleanup; + } else if (found) { + rc = uclogic_params_frame_init_with_desc( + &p.frame, + uclogic_rdesc_ugee_ex07_buttonpad_arr, + uclogic_rdesc_ugee_ex07_buttonpad_size, + 0); + if (rc != 0) { + hid_err(hdev, + "failed creating buttonpad parameters: %d\n", + rc); + goto cleanup; + } + } else { + hid_warn(hdev, "pen parameters not found"); + uclogic_params_init_invalid(&p); + } + break; } diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index ef1d3cf918a4..2ab8747e87b7 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -701,6 +701,33 @@ const __u8 uclogic_rdesc_buttonpad_v2_arr[] = { const size_t uclogic_rdesc_buttonpad_v2_size = sizeof(uclogic_rdesc_buttonpad_v2_arr); +/* Fixed report descriptor for Ugee EX07 buttonpad */ +const __u8 uclogic_rdesc_ugee_ex07_buttonpad_arr[] = { + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x07, /* Usage (Keypad), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x06, /* Report ID (6), */ + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x39, /* Usage (Tablet Function Keys), */ + 0xA0, /* Collection (Physical), */ + 0x05, 0x09, /* Usage Page (Button), */ + 0x75, 0x01, /* Report Size (1), */ + 0x19, 0x03, /* Usage Minimum (03h), */ + 0x29, 0x06, /* Usage Maximum (06h), */ + 0x95, 0x04, /* Report Count (4), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x1A, /* Report Count (26), */ + 0x81, 0x03, /* Input (Constant, Variable), */ + 0x19, 0x01, /* Usage Minimum (01h), */ + 0x29, 0x02, /* Usage Maximum (02h), */ + 0x95, 0x02, /* Report Count (2), */ + 0x81, 0x02, /* Input (Variable), */ + 0xC0, /* End Collection, */ + 0xC0 /* End Collection */ +}; +const size_t uclogic_rdesc_ugee_ex07_buttonpad_size = + sizeof(uclogic_rdesc_ugee_ex07_buttonpad_arr); + /** * uclogic_rdesc_template_apply() - apply report descriptor parameters to a * report descriptor template, creating a report descriptor. Copies the diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index cc5f3dd3804a..3cb6e1725f43 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -131,4 +131,8 @@ extern const size_t uclogic_rdesc_buttonpad_v2_size; /* Report ID for tweaked v2 buttonpad reports */ #define UCLOGIC_RDESC_BUTTONPAD_V2_ID 0xf7 +/* Fixed report descriptor for Ugee EX07 buttonpad */ +extern const __u8 uclogic_rdesc_ugee_ex07_buttonpad_arr[]; +extern const size_t uclogic_rdesc_ugee_ex07_buttonpad_size; + #endif /* _HID_UCLOGIC_RDESC_H */ From patchwork Sun Feb 10 10:14:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804691 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFCF11515 for ; Sun, 10 Feb 2019 10:15:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFEDA29F45 for ; Sun, 10 Feb 2019 10:15:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B34E729F4A; Sun, 10 Feb 2019 10:15:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 4D17C29F46 for ; Sun, 10 Feb 2019 10:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726101AbfBJKPD (ORCPT ); Sun, 10 Feb 2019 05:15:03 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35992 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKPD (ORCPT ); Sun, 10 Feb 2019 05:15:03 -0500 Received: by mail-lj1-f195.google.com with SMTP id g11-v6so6469227ljk.3 for ; Sun, 10 Feb 2019 02:15:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UZka0Ceu62doROs7JL+obx3DjqF2q9nllqsab4rHEC8=; b=ajKArLe9XNzFBSc20FFXbUUyN0MjQOZtdgxlWeksaUL0849etCEzb9U0ISdKyh+CpM UvzpoNtPQPvh8ov0JysNiONNu5u43TMoY7/mJERswhyu/er/cZiQMIWx7lH+E8mA9VTF 9JDwvLibZ1OafxbUaFuQf494gSMKSpTepAt3ZxCITH+U+aPK3dJK1i0nq//uKDTkN9VV 4vOd0Ts2eLtVzLBW0px86WhHiRHJYW1jFFKl9+tAQuLSYcZszIkNK8FA5We1dU3fwb0D m40AoNgHM1T75riisjWLF7xTNU9yqmdxGtCwLIMEyaw6KU5vFlRmHRb05xdLuGqNUfj/ S4zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UZka0Ceu62doROs7JL+obx3DjqF2q9nllqsab4rHEC8=; b=EAnygZB8j1Ii5LlKX9fofHAbFiuUPELDztdeSi3xmXSj5f5V8NzH/rBH4NKMRWFVnz +riTP1p5PCu0lkBbandGyaoUP3fdaaOy0uQGWoiCHxjHtFxRAYM4BxSWuHXmNezFi29h aheDtXiBArc41BWzhOrSI1fs3TYLj8wbRb41KnN4LBpIEZlAbAWeZOm+NR2z+Q3O5Plx 7etH33MkdJMJ2P4Bw6R5eK4eyF8kDXMo+emRbvnDdiJ2X7KClXTEwP2SFJG/h19YqStz +1LhFadX8Ydc7gkpHCEQWAQeIuliqPTegyP/NS6lkLjXMHnwzzvmeredeU3471/fbfWl WQMA== X-Gm-Message-State: AHQUAuaEBAjVV0YtC7nIWEySbEI0zR39TEQxQamuKY2dUOYvFM1mUl+S S4YMTgDYpbTLQyZTpmj+G6Y= X-Google-Smtp-Source: AHgI3IYjDuvAgkGQ87TRpy9oU9KVMu5NFfsjtzE1icjqCl9I0vy2uWS/nSEmTYYUOaTOPypDw6bnYQ== X-Received: by 2002:a2e:8e8e:: with SMTP id z14-v6mr13296175ljk.84.1549793701566; Sun, 10 Feb 2019 02:15:01 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:00 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 14/23] HID: uclogic: Add support for XP-Pen Star G540 Date: Sun, 10 Feb 2019 12:14:00 +0200 Message-Id: <20190210101409.3511-15-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for XP-Pen Star G540 to hid-uclogic. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-uclogic-core.c | 2 ++ drivers/hid/hid-uclogic-params.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 304476200c28..4da33b38606c 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1141,6 +1141,7 @@ #define USB_DEVICE_ID_YIYNOVA_TABLET 0x004d #define USB_VENDOR_ID_UGEE 0x28bd +#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540 0x0075 #define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071 #define USB_VENDOR_ID_UNITEC 0x227d diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 33333a3e5ffe..42c93e3a8f1b 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -346,6 +346,8 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540) }, { } }; MODULE_DEVICE_TABLE(hid, uclogic_devices); diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index b22815cec06d..ac42f9117431 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -997,6 +997,8 @@ int uclogic_params_init(struct uclogic_params *params, break; case VID_PID(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610): + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540): /* If this is the pen interface */ if (bInterfaceNumber == 1) { /* Probe v1 pen parameters */ From patchwork Sun Feb 10 10:14:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804693 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 057121515 for ; Sun, 10 Feb 2019 10:15:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB1FB29F46 for ; Sun, 10 Feb 2019 10:15:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEF8029F45; Sun, 10 Feb 2019 10:15:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 874CB29F45 for ; Sun, 10 Feb 2019 10:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbfBJKPF (ORCPT ); Sun, 10 Feb 2019 05:15:05 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34174 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfBJKPE (ORCPT ); Sun, 10 Feb 2019 05:15:04 -0500 Received: by mail-lj1-f195.google.com with SMTP id v14-v6so6480683ljv.1 for ; Sun, 10 Feb 2019 02:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ANcwBb9sRRjfw8xQaNfae/qhRZbQUN0VZMXk/i9XzHU=; b=PWNfGYXLcvpl270t8f2SccpkeYsRyJXzEPAT8XloOpmeCKLw4/ow+Y2L0IGlmMNmDK LSZmAR8i3LTbARFqkHjwCxxeRUEYIn+GHZ0/+s5vO5WQww3QgJFZ46mahfxEsffD7yOl zfmfplgLFZpvU4q6Qp15S0XBPzze1htUP5DjrFT8tAdQVdvHwqSUtZ1J7bXw3Y2Y38kR DPSb59QoodQ9229A5aIYuOFkbYTGiW4kEaKcr6Mld3aHef5ocZ08Vw/rsF2+0GsdPC3g x/hCp9cThqktvI5mtqZiiZTc6nUG5NmQTUWecaBvo/L0RiU5t3Xyja+VJbQ87c+q0qJu aiCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ANcwBb9sRRjfw8xQaNfae/qhRZbQUN0VZMXk/i9XzHU=; b=fVOVm9yN7dXvPFN4tck3Dwcx72Ihp9+akBo7TalfX9z2KYAIE3VylwO2HsDfeYwjPV Klv7BUtqLc/NAXN/TQEA7B3hP39avzTeI4EIjYca7q0F8T5IMF+lcikAh9c/Y9v8FmrQ H6oP3iU68CY/jK329cW/CggPFJbtkHwO8vukfJEFVm5LaCu5vMyVOyLskcmYYWmQZLzX jwPwf9tNJigZxNJVhhVf/Fi9KdCz5dw/8L5SsglwmSbP7khqoeRB9irpl8oVu20mEEtb mobX5JKxGfFBqMn2eXO7M8AvZ9Xn82vD+0QaJXhFqU2Gwsp1LVQWyJNx0IogaD2YqxrN 8DNQ== X-Gm-Message-State: AHQUAuZ+9UwU9QjFmZ/l61nFEkGZ5Myqp89BYhLQbIkBgoP9wFcT+P+0 zGDEIN3gjw5ZXQRcKr5e/D0= X-Google-Smtp-Source: AHgI3IZ5MwTg/UnA0ny0yZNVwppUI55Ka4O3kmlz9BstsMqmKhB9zMVT7WGu08qosoDCyBFoWJ0tZA== X-Received: by 2002:a2e:7310:: with SMTP id o16-v6mr7256520ljc.188.1549793702748; Sun, 10 Feb 2019 02:15:02 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:01 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 15/23] HID: uclogic: Add support for XP-Pen Star G640 Date: Sun, 10 Feb 2019 12:14:01 +0200 Message-Id: <20190210101409.3511-16-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for XP-Pen Star G640 to hid-uclogic. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-uclogic-core.c | 2 ++ drivers/hid/hid-uclogic-params.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 4da33b38606c..cadc8d4d6a4d 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1142,6 +1142,7 @@ #define USB_VENDOR_ID_UGEE 0x28bd #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540 0x0075 +#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640 0x0094 #define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071 #define USB_VENDOR_ID_UNITEC 0x227d diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 42c93e3a8f1b..5fdd8919902d 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -348,6 +348,8 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UGEE_TABLET_EX07S) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640) }, { } }; MODULE_DEVICE_TABLE(hid, uclogic_devices); diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index ac42f9117431..709eeb15e7de 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -999,6 +999,8 @@ int uclogic_params_init(struct uclogic_params *params, USB_DEVICE_ID_UGTIZER_TABLET_GP0610): case VID_PID(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540): + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640): /* If this is the pen interface */ if (bInterfaceNumber == 1) { /* Probe v1 pen parameters */ From patchwork Sun Feb 10 10:14:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804697 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 978EB17E6 for ; Sun, 10 Feb 2019 10:15:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88B2429F46 for ; Sun, 10 Feb 2019 10:15:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CDCF29F4B; Sun, 10 Feb 2019 10:15:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 F26EC29F4A for ; Sun, 10 Feb 2019 10:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726078AbfBJKPH (ORCPT ); Sun, 10 Feb 2019 05:15:07 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:35994 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKPH (ORCPT ); Sun, 10 Feb 2019 05:15:07 -0500 Received: by mail-lj1-f196.google.com with SMTP id g11-v6so6469260ljk.3 for ; Sun, 10 Feb 2019 02:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AZzZOOiefp8vpSHHB/8bJJ6hbr4UkRYzO9eMlhhsF1w=; b=aN7bk4FGFbxUbj7l6lkRvG92u7fyoiBV/WJcLthRrWD8+Hiz72vE963CHORAvCHtSB bI27T/fM6QNhjnuS1ry/zlxtQfNs1dcoHOssGPpd2Xl9MbMOCdTVLAnYfbWPkUEIEBeR TbGBalYjgXDfcrmkfENuDDizEvXKszqHeVdPfYgq0pQp7BgYHhkXOLKe+PSlf9X4vxgL iXopHXtSDzfIc2FuHz/mzl0FZEDaHG3Yl+OtR8fMMduW0dEAnNXDG4vy3JRxCUG+6HPw 8SQ9hrZN+tXEaJincxtvFln5BYucs9swgRlXoh+kmSDBT839iTe4CRFTMC8G7kgCFjBt MDKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AZzZOOiefp8vpSHHB/8bJJ6hbr4UkRYzO9eMlhhsF1w=; b=A+7sM69ztuigQ5xCEb5aYYRzIoP2LbikiTctilZ/AEksWtD0WuhLhcT/w9k97vYucC P6FInBNGNp2eDsbhj9/VyNlI70DUKSRLxmTyWgEyZKamdcZLDUfbzqFeK/lxyk3Bk3Hd vXuHgNgljv8kdwsN7jXq5CPIudahzhT+EOjNOi0HzlQWJ8Yo87xBb6zF9KmxUMRcNAjp nZM2H7SHH4xArQ8F3cjDJtdm01IHz8d1MGLf0xYrbdKQIFBVkEDxnXf241iOYOcPVesr ejxfF1CDBZfsMGxKmY8T83rVj8zgt3yx6D/pBDyIGH7qTZwyAb3kOIORdHFRgOAiceRZ gQWg== X-Gm-Message-State: AHQUAuatJlXnUS2aFKgSU8xfQzd8yDVFCUMofsyq6CRfAdQG9d8JnSz+ dnN4UYftP+DE0TsDis/fEcA= X-Google-Smtp-Source: AHgI3IZox3/WJvH2ijpQs6GyduYQ3g9zMTOq5BjAy4p2lWRjVUBmamhHGtLUNeSn5uzL7FuMELSalQ== X-Received: by 2002:a2e:9944:: with SMTP id r4-v6mr18525942ljj.185.1549793704060; Sun, 10 Feb 2019 02:15:04 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:03 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 16/23] HID: uclogic: Add support for XP-Pen Deco 01 Date: Sun, 10 Feb 2019 12:14:02 +0200 Message-Id: <20190210101409.3511-17-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for XP-Pen Deco 01 to hid-uclogic. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-uclogic-core.c | 2 ++ drivers/hid/hid-uclogic-params.c | 23 +++++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.c | 35 ++++++++++++++++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.h | 4 ++++ 5 files changed, 65 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index cadc8d4d6a4d..b38be58d61b6 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1143,6 +1143,7 @@ #define USB_VENDOR_ID_UGEE 0x28bd #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540 0x0075 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640 0x0094 +#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01 0x0042 #define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071 #define USB_VENDOR_ID_UNITEC 0x227d diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 5fdd8919902d..e4324ad86e58 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -350,6 +350,8 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01) }, { } }; MODULE_DEVICE_TABLE(hid, uclogic_devices); diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 709eeb15e7de..9b0fc4dd31af 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1018,6 +1018,29 @@ int uclogic_params_init(struct uclogic_params *params, uclogic_params_init_with_pen_unused(&p); } break; + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01): + /* If this is the pen and frame interface */ + if (bInterfaceNumber == 1) { + /* Probe v1 pen parameters */ + rc = uclogic_params_pen_init_v1(&p.pen, &found, hdev); + if (rc != 0) { + hid_err(hdev, "pen probing failed: %d\n", rc); + goto cleanup; + } + /* Initialize frame parameters */ + rc = uclogic_params_frame_init_with_desc( + &p.frame, + uclogic_rdesc_xppen_deco01_frame_arr, + uclogic_rdesc_xppen_deco01_frame_size, + 0); + if (rc != 0) + goto cleanup; + } else { + /* TODO: Consider marking the interface invalid */ + uclogic_params_init_with_pen_unused(&p); + } + break; case VID_PID(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S): /* Ignore non-pen interfaces */ diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index 2ab8747e87b7..73996586993f 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -728,6 +728,41 @@ const __u8 uclogic_rdesc_ugee_ex07_buttonpad_arr[] = { const size_t uclogic_rdesc_ugee_ex07_buttonpad_size = sizeof(uclogic_rdesc_ugee_ex07_buttonpad_arr); +/* Fixed report descriptor for XP-Pen Deco 01 frame controls */ +const __u8 uclogic_rdesc_xppen_deco01_frame_arr[] = { + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x07, /* Usage (Keypad), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x06, /* Report ID (6), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x39, /* Usage (Tablet Function Keys), */ + 0xA0, /* Collection (Physical), */ + 0x05, 0x09, /* Usage Page (Button), */ + 0x19, 0x01, /* Usage Minimum (01h), */ + 0x29, 0x08, /* Usage Maximum (08h), */ + 0x95, 0x08, /* Report Count (8), */ + 0x81, 0x02, /* Input (Variable), */ + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x44, /* Usage (Barrel Switch), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x02, /* Input (Variable), */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x30, /* Usage (X), */ + 0x09, 0x31, /* Usage (Y), */ + 0x95, 0x02, /* Report Count (2), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x15, /* Report Count (21), */ + 0x81, 0x01, /* Input (Constant), */ + 0xC0, /* End Collection, */ + 0xC0 /* End Collection */ +}; + +const size_t uclogic_rdesc_xppen_deco01_frame_size = + sizeof(uclogic_rdesc_xppen_deco01_frame_arr); + /** * uclogic_rdesc_template_apply() - apply report descriptor parameters to a * report descriptor template, creating a report descriptor. Copies the diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index 3cb6e1725f43..0c5bd027f155 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -135,4 +135,8 @@ extern const size_t uclogic_rdesc_buttonpad_v2_size; extern const __u8 uclogic_rdesc_ugee_ex07_buttonpad_arr[]; extern const size_t uclogic_rdesc_ugee_ex07_buttonpad_size; +/* Fixed report descriptor for XP-Pen Deco 01 frame controls */ +extern const __u8 uclogic_rdesc_xppen_deco01_frame_arr[]; +extern const size_t uclogic_rdesc_xppen_deco01_frame_size; + #endif /* _HID_UCLOGIC_RDESC_H */ From patchwork Sun Feb 10 10:14:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804695 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FBF31575 for ; Sun, 10 Feb 2019 10:15:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1157129F46 for ; Sun, 10 Feb 2019 10:15:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 058FF29F4F; Sun, 10 Feb 2019 10:15:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 9EB7829F46 for ; Sun, 10 Feb 2019 10:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbfBJKPH (ORCPT ); Sun, 10 Feb 2019 05:15:07 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45774 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfBJKPG (ORCPT ); Sun, 10 Feb 2019 05:15:06 -0500 Received: by mail-lj1-f193.google.com with SMTP id s5-v6so6393827ljd.12 for ; Sun, 10 Feb 2019 02:15:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j/uufF6j1jhec1j4yaI1N8gsCXqws97mbfh9D9faZiI=; b=uT6uNYCDJZ70xCkCKU33PVrYv7qLsas1XkUhEkOYoodD6ep7vgl7OFRPTMo8FX9iQs /NpERVFfs59ozXoUHEfS/EhACFEw5m5Vm69V+RCqjIGrQjMS54/8+0oxxSpQKSgf7aeO 5ft3zNGu5FeNFEB303AV30AbczezzphVb3VPtnTjgGOIZIqlLiwsWuLKY/pS1uvUCLIr NoSvKU6vV7/SbmgeXGeGVWyEhBTWng40V3sJWjOcBUNnbw6AYK8dwNN74ejEfnHO8jrU kKJN+mGFc+ECZ+CWwKsmX+mlx5b9/8eiJpdGatijwSq8D3fV3+pVSP4C6pACkl4b0jwc 9DEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j/uufF6j1jhec1j4yaI1N8gsCXqws97mbfh9D9faZiI=; b=mKIVagethPBpA7HuVEigVb4RABDwjdXpx8+DSXpAcQ8zjC80Q/UtzLgc88Lt+ThZrk mVtmg7c9BojC9zMvT0FdrxIP6BdLuQTB7gqFP6hqAT0xDNb7mAA8FqDlMj0qBMCMbhk3 ugI3H2viH6jcfN987jUKqsSMEKbNH3D8LCgHHTFKloaHaNejWIBMaNa5FM1yMRI+kSPU H1I5/C7JwOvgCHKJqdztHh36R2uqxJVj7DtMtxFkw/eBTrIFKisoOlRN9zb4nANIP6BG 6pUvCexdQqwZlUVWqI/55G5gugn4lLEuo5iUOCvuidTMUgtTIwE4g3daVrO0xghnWXj+ SZkw== X-Gm-Message-State: AHQUAuZ71R5FWUKY3y29rQAiiku+L0BeV3qBvxnc0VEhFfyMvk0gUUiF 5ku1JW/RcfzlKS2xeUnSU5I= X-Google-Smtp-Source: AHgI3IaAYjrIK65vJ3fVchzeHIh1Oqp4PhFXLgbN93V9T/384jeeHRwQgg79coVNv7TaoCjcO3RU0A== X-Received: by 2002:a2e:7f04:: with SMTP id a4-v6mr18282401ljd.156.1549793705157; Sun, 10 Feb 2019 02:15:05 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:04 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 17/23] HID: uclogic: Support faking Wacom pad device ID Date: Sun, 10 Feb 2019 12:14:03 +0200 Message-Id: <20190210101409.3511-18-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for inserting a Wacom pad device ID into hid-uclogic reports. This allows reporting dial inputs in a way compatible with the Wacom driver. Needed for Ugee G5 support in particular. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-core.c | 10 ++++++++++ drivers/hid/hid-uclogic-params.h | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index e4324ad86e58..f5fb612daa1e 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -300,6 +300,16 @@ static int uclogic_raw_event(struct hid_device *hdev, } } + /* Tweak frame control reports, if necessary */ + if ((report->type == HID_INPUT_REPORT) && + (report->id == params->frame.id)) { + /* If need to, and can, set pad device ID for Wacom drivers */ + if (params->frame.dev_id_byte > 0 && + params->frame.dev_id_byte < size) { + data[params->frame.dev_id_byte] = 0xf; + } + } + return 0; } diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index 1060f70d647d..4ba6ecc2b8b8 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -87,6 +87,13 @@ struct uclogic_params_frame { * Report ID, if reports should be tweaked, zero if not. */ unsigned int id; + /* + * Offset of the Wacom-style device ID byte in the report, to be set + * to pad device ID (0xf), for compatibility with Wacom drivers. Zero + * if no changes to the report should be made. Only valid if "id" is + * not zero. + */ + unsigned int dev_id_byte; }; /* @@ -161,6 +168,7 @@ extern int uclogic_params_init(struct uclogic_params *params, ".frame.desc_ptr = %p\n" \ ".frame.desc_size = %u\n" \ ".frame.id = %u\n" \ + ".frame.dev_id_byte = %u\n" \ ".pen_frame_flag = 0x%02x\n" /* Tablet interface parameters *printf format arguments */ @@ -177,6 +185,7 @@ extern int uclogic_params_init(struct uclogic_params *params, (_params)->frame.desc_ptr, \ (_params)->frame.desc_size, \ (_params)->frame.id, \ + (_params)->frame.dev_id_byte, \ (_params)->pen_frame_flag /* Get a replacement report descriptor for a tablet's interface. */ From patchwork Sun Feb 10 10:14:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804699 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81E321515 for ; Sun, 10 Feb 2019 10:15:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 739BB29F45 for ; Sun, 10 Feb 2019 10:15:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67FFB29F4A; Sun, 10 Feb 2019 10:15:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 0248429F45 for ; Sun, 10 Feb 2019 10:15:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726127AbfBJKPI (ORCPT ); Sun, 10 Feb 2019 05:15:08 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:33423 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbfBJKPI (ORCPT ); Sun, 10 Feb 2019 05:15:08 -0500 Received: by mail-lj1-f194.google.com with SMTP id f24-v6so6475283ljk.0 for ; Sun, 10 Feb 2019 02:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iYX7oziVmMWRZL/NrahYZjN+ATBishUKc/WP2vJni74=; b=V9H/v1SwlGfBzeoc7j5ie+4diRzywWUeyY4BPJKef4WEvQqDpCQbCKv1gp/BKbaJ0S spPePpQm8eaKB3EftJQz04aE2edcqH+1vPI5D2RBviuvR/h4QPRx0GxfT8vlKQtcRJUb JwpWiny3uKmd5b/ZPZ+YWv+S8rEKCJGcuY5fiavQVS/OAknAZyYbErinsRD9hRdUy0D0 h8wThamsnC7cZ3uSEQtmbLyG4fzJ+4/sD+9zAp6KUlFbZ2SxtpKkNm0VROL3fp1ASQTO xxD0278O6F/yXDoFPxwV0QOJLaoWpD2/sIR9xflr+/MR3++1/4yl68A0LTqtgQGx78gE +FhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iYX7oziVmMWRZL/NrahYZjN+ATBishUKc/WP2vJni74=; b=DGuDhDFndbwy2qEKGHMH9V7jrhYndrKDIN/gAJ2pZDAsS4rjA4ZXNcVYDVS6Wk+sRD odMNKxjKqq2WTTVH106czIb6uMFfNeQrV5FQBt0al7Im6eRd62QD7WeL8ZvZBFtmgYeg +fuf2KAMfguDqjjvx5E48ZfgEHiC4iQcpBGdVloD9OU7j6XFSITmZRLLBvOPORo1NE+k mxU1mt06Fbr3ptMcwMItjy47gs6IrkzvdfZB/Rqq3s1C92rlR/p0tzTiw8DQG8GmMB7J nJUjiZiUp4DRLYmGNpE2ZHPgGO7UhR52MFFOvMtErIcibjh1v4XB+bIZjAygFcb3vJ8V ybzw== X-Gm-Message-State: AHQUAuY9q7GFiamOkBBWDxbDcv39mYpG4emyXjJIYxQWO5rocAHbMzWY CWVfeuDYPgysPsIRcU5BHoA= X-Google-Smtp-Source: AHgI3IZ/RPHKRdxXyeW3hZcrYnIrxYmL68CCdG6zaFuCS7MDWbDLAnyduUADh6aErttEfUyp1rRa/Q== X-Received: by 2002:a2e:2416:: with SMTP id k22-v6mr5219572ljk.80.1549793706301; Sun, 10 Feb 2019 02:15:06 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:05 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 18/23] HID: uclogic: Support Gray-coded rotary encoders Date: Sun, 10 Feb 2019 12:14:04 +0200 Message-Id: <20190210101409.3511-19-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for converting Gray-coded rotary encoder input into dial input compatible with HID standard. Needed for Ugee G5 support. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-core.c | 29 +++++++++++++++++++++++++++++ drivers/hid/hid-uclogic-params.h | 8 ++++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index f5fb612daa1e..dfacb04308b1 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -37,6 +37,8 @@ struct uclogic_drvdata { struct input_dev *pen_input; /* In-range timer */ struct timer_list inrange_timer; + /* Last rotary encoder state, or U8_MAX for none */ + u8 re_state; }; /** @@ -175,6 +177,7 @@ static int uclogic_probe(struct hid_device *hdev, goto failure; } timer_setup(&drvdata->inrange_timer, uclogic_inrange_timeout, 0); + drvdata->re_state = U8_MAX; hid_set_drvdata(hdev, drvdata); /* Initialize the device and retrieve interface parameters */ @@ -308,6 +311,32 @@ static int uclogic_raw_event(struct hid_device *hdev, params->frame.dev_id_byte < size) { data[params->frame.dev_id_byte] = 0xf; } + /* If need to, and can, read rotary encoder state change */ + if (params->frame.re_lsb > 0 && + params->frame.re_lsb / 8 < size) { + unsigned int byte = params->frame.re_lsb / 8; + unsigned int bit = params->frame.re_lsb % 8; + + u8 change; + u8 prev_state = drvdata->re_state; + /* Read Gray-coded state */ + u8 state = (data[byte] >> bit) & 0x3; + /* Encode state change into 2-bit signed integer */ + if ((prev_state == 1 && state == 0) || + (prev_state == 2 && state == 3)) { + change = 1; + } else if ((prev_state == 2 && state == 0) || + (prev_state == 1 && state == 3)) { + change = 3; + } else { + change = 0; + } + /* Write change */ + data[byte] = (data[byte] & ~((u8)3 << bit)) | + (change << bit); + /* Remember state */ + drvdata->re_state = state; + } } return 0; diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index 4ba6ecc2b8b8..ba48b1c7a0e5 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -87,6 +87,12 @@ struct uclogic_params_frame { * Report ID, if reports should be tweaked, zero if not. */ unsigned int id; + /* + * Number of the least-significant bit of the 2-bit state of a rotary + * encoder, in the report. Cannot point to a 2-bit field crossing a + * byte boundary. Zero if not present. Only valid if "id" is not zero. + */ + unsigned int re_lsb; /* * Offset of the Wacom-style device ID byte in the report, to be set * to pad device ID (0xf), for compatibility with Wacom drivers. Zero @@ -168,6 +174,7 @@ extern int uclogic_params_init(struct uclogic_params *params, ".frame.desc_ptr = %p\n" \ ".frame.desc_size = %u\n" \ ".frame.id = %u\n" \ + ".frame.re_lsb = %u\n" \ ".frame.dev_id_byte = %u\n" \ ".pen_frame_flag = 0x%02x\n" @@ -185,6 +192,7 @@ extern int uclogic_params_init(struct uclogic_params *params, (_params)->frame.desc_ptr, \ (_params)->frame.desc_size, \ (_params)->frame.id, \ + (_params)->frame.re_lsb, \ (_params)->frame.dev_id_byte, \ (_params)->pen_frame_flag From patchwork Sun Feb 10 10:14:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804701 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D84871575 for ; Sun, 10 Feb 2019 10:15:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9AD229F45 for ; Sun, 10 Feb 2019 10:15:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD53A29F4B; Sun, 10 Feb 2019 10:15:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 26C9B29F45 for ; Sun, 10 Feb 2019 10:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726130AbfBJKPK (ORCPT ); Sun, 10 Feb 2019 05:15:10 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:43735 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKPK (ORCPT ); Sun, 10 Feb 2019 05:15:10 -0500 Received: by mail-lf1-f68.google.com with SMTP id j1so5573418lfb.10 for ; Sun, 10 Feb 2019 02:15:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TH1F5Yq5M8WUHD8m6YyWDvLY+6zmxsLYgRAMe+ArOJs=; b=kHewc12Cir1IjXaOh9N4ybcFvM08nZAh6UgVN8q2nqXJhxdlNRFKu01x3F3ooEhay8 YfWuINpFnnoba2WoiGgOG5tgbeo6uJdhyPEJn9ZoE+weqDHVbadVsVVJwVvOlyXFDrD0 elDEFoMj8gOuNG8irt5I/qjgOBd7OLth0V9RMN9PUgmp6AmQyxp1wM4DvBLJGJBLx/3X QywqNUSUDJ5obBkt7CWwwGzmGPacDubb4NFY7fqqdoLTNdLjvAPt7nxHpa9S9DDezNY6 1He1RhPw9hUmsIbNs2OZXaOb6JoLba1tbToO6jTM4h/pmY5DR50A2Xp3fqttO0R/Xp0x 3J4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TH1F5Yq5M8WUHD8m6YyWDvLY+6zmxsLYgRAMe+ArOJs=; b=o8qtW7jxE5ukbTGHSdVUWp+MiulWyvJkeJpSRIsamd1qWocrdQxiWsRL0DcEtkyO9f Ecj9C4JAgdtc36Rk2Sb+uqogXUj4ttsZgh991aMdleMR2UMC3znXSResdfC6LKNXGmbe 7O2IJs49+6KrFrPoeTaC+o2/kFDaqhFBQSUbVFdy2M9VKMPhtBb6n2i/5ev39Z222iIV NHeorp2ztAXwtWOu5CAByV6KoQkmBG7gVaDTyMSdLHmSVgvh7LCiKCDqdiYB9RZkHt8X WheXUG8CHMPWm8aUIg7adjeSQYBiojzrDg9Z6WvJoVsesUH+/d9kqpN+7UPe1UvCwSo9 EFGw== X-Gm-Message-State: AHQUAubiB5iB/O8omh0fR17w2ziluoqokO+7HlMJHHjLrvYEPM+Hsv6k bmKfx2URGv6YpzKgT390FoE= X-Google-Smtp-Source: AHgI3IaDcfFxMDqL9kARLE51YTj7CnYIKFOddNfVWsOANvaat+NaHP2gLVemn7JmSPx8UFFmK/PpoA== X-Received: by 2002:a19:5209:: with SMTP id m9mr110616lfb.51.1549793707456; Sun, 10 Feb 2019 02:15:07 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:06 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 19/23] HID: uclogic: Add support for Ugee G5 Date: Sun, 10 Feb 2019 12:14:05 +0200 Message-Id: <20190210101409.3511-20-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Add support for Ugee G5 to hid-uclogic. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-uclogic-core.c | 2 ++ drivers/hid/hid-uclogic-params.c | 34 ++++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.c | 54 ++++++++++++++++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.h | 13 ++++++++ 5 files changed, 104 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index b38be58d61b6..895b79daaf7c 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1144,6 +1144,7 @@ #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540 0x0075 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640 0x0094 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01 0x0042 +#define USB_DEVICE_ID_UGEE_TABLET_G5 0x0074 #define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071 #define USB_VENDOR_ID_UNITEC 0x227d diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index dfacb04308b1..8fe02d81265d 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -383,6 +383,8 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_TABLET_G5) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 9b0fc4dd31af..b582739a570a 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1040,6 +1040,40 @@ int uclogic_params_init(struct uclogic_params *params, /* TODO: Consider marking the interface invalid */ uclogic_params_init_with_pen_unused(&p); } + break; + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_TABLET_G5): + /* Ignore non-pen interfaces */ + if (bInterfaceNumber != 1) { + uclogic_params_init_invalid(&p); + break; + } + + rc = uclogic_params_pen_init_v1(&p.pen, &found, hdev); + if (rc != 0) { + hid_err(hdev, "pen probing failed: %d\n", rc); + goto cleanup; + } else if (found) { + rc = uclogic_params_frame_init_with_desc( + &p.frame, + uclogic_rdesc_ugee_g5_frame_arr, + uclogic_rdesc_ugee_g5_frame_size, + UCLOGIC_RDESC_UGEE_G5_FRAME_ID); + if (rc != 0) { + hid_err(hdev, + "failed creating buttonpad parameters: %d\n", + rc); + goto cleanup; + } + p.frame.re_lsb = + UCLOGIC_RDESC_UGEE_G5_FRAME_RE_LSB; + p.frame.dev_id_byte = + UCLOGIC_RDESC_UGEE_G5_FRAME_DEV_ID_BYTE; + } else { + hid_warn(hdev, "pen parameters not found"); + uclogic_params_init_invalid(&p); + } + break; case VID_PID(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S): diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index 73996586993f..bf5da6de7bba 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -728,6 +728,60 @@ const __u8 uclogic_rdesc_ugee_ex07_buttonpad_arr[] = { const size_t uclogic_rdesc_ugee_ex07_buttonpad_size = sizeof(uclogic_rdesc_ugee_ex07_buttonpad_arr); +/* Fixed report descriptor for Ugee G5 frame controls */ +const __u8 uclogic_rdesc_ugee_g5_frame_arr[] = { + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x07, /* Usage (Keypad), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x06, /* Report ID (6), */ + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x39, /* Usage (Tablet Function Keys), */ + 0xA0, /* Collection (Physical), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x05, 0x09, /* Usage Page (Button), */ + 0x19, 0x01, /* Usage Minimum (01h), */ + 0x29, 0x05, /* Usage Maximum (05h), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x05, /* Report Count (5), */ + 0x81, 0x02, /* Input (Variable), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x03, /* Report Count (3), */ + 0x81, 0x01, /* Input (Constant), */ + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */ + 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x02, /* Input (Variable), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x09, 0x44, /* Usage (Barrel Switch), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x02, /* Input (Variable), */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x30, /* Usage (X), */ + 0x09, 0x31, /* Usage (Y), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x02, /* Report Count (2), */ + 0x81, 0x02, /* Input (Variable), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x0B, /* Report Count (11), */ + 0x81, 0x01, /* Input (Constant), */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x38, /* Usage (Wheel), */ + 0x15, 0xFF, /* Logical Minimum (-1), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x02, /* Report Size (2), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x06, /* Input (Variable, Relative), */ + 0xC0, /* End Collection, */ + 0xC0 /* End Collection */ +}; +const size_t uclogic_rdesc_ugee_g5_frame_size = + sizeof(uclogic_rdesc_ugee_g5_frame_arr); + /* Fixed report descriptor for XP-Pen Deco 01 frame controls */ const __u8 uclogic_rdesc_xppen_deco01_frame_arr[] = { 0x05, 0x01, /* Usage Page (Desktop), */ diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index 0c5bd027f155..c5da51055af3 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -139,4 +139,17 @@ extern const size_t uclogic_rdesc_ugee_ex07_buttonpad_size; extern const __u8 uclogic_rdesc_xppen_deco01_frame_arr[]; extern const size_t uclogic_rdesc_xppen_deco01_frame_size; +/* Fixed report descriptor for Ugee G5 frame controls */ +extern const __u8 uclogic_rdesc_ugee_g5_frame_arr[]; +extern const size_t uclogic_rdesc_ugee_g5_frame_size; + +/* Report ID of Ugee G5 frame control reports */ +#define UCLOGIC_RDESC_UGEE_G5_FRAME_ID 0x06 + +/* Device ID byte offset in Ugee G5 frame report */ +#define UCLOGIC_RDESC_UGEE_G5_FRAME_DEV_ID_BYTE 0x2 + +/* Least-significant bit of Ugee G5 frame rotary encoder state */ +#define UCLOGIC_RDESC_UGEE_G5_FRAME_RE_LSB 38 + #endif /* _HID_UCLOGIC_RDESC_H */ From patchwork Sun Feb 10 10:14:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804703 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02F7517E6 for ; Sun, 10 Feb 2019 10:15:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E96CF29F46 for ; Sun, 10 Feb 2019 10:15:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDE5629F45; Sun, 10 Feb 2019 10:15:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 9354B29F46 for ; Sun, 10 Feb 2019 10:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726134AbfBJKPL (ORCPT ); Sun, 10 Feb 2019 05:15:11 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34176 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbfBJKPK (ORCPT ); Sun, 10 Feb 2019 05:15:10 -0500 Received: by mail-lj1-f194.google.com with SMTP id v14-v6so6480772ljv.1 for ; Sun, 10 Feb 2019 02:15:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LVE1oFlzcZeUSefYKw5QtqSf97EomnbNHWcuBBpGajI=; b=ikHvld3OvaFCUkNl7oAlUlJl9oRoSA+DvycihsqpzISBkLZ2VGfSAKTb86BjZneF2g 1+JpTU6Q6hEv39jw5a1NANzCna7n80G0hCwN4Qbpvfq1mOhWPtNu1h1wu3u5bL3dzgQU O44ElkbUyfQge1yAwOslDmDZeYZ6SNNfMXMxymhx4fN/x9WA4BJTe5IYfB98NPgeIapn blJpNTujU6o0ZxG9vFKT7tmoS584zvHVPhxlNWw0gjKDUjJPOlBTbHU4PtQb5frVMI7L wbZnpgMaStTLyFTgo+hCZHEHy9+Agh7Wqo/JAyN44e6HzgyMtP8rCcEjYMTeP12AuYmy BdtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LVE1oFlzcZeUSefYKw5QtqSf97EomnbNHWcuBBpGajI=; b=Z7E0a2oGegLdG2LXY2mCLMP/S5c7sVCC181nr/uqpCIbyAWHioVKZBT7gPiWZIqHBB xWnV25uPPngrvzOOmvdqdKRPBI0xblRjnDbxtm0oncrVs/sJS8fMhqDNJUoKoEfT6tnY qZ5Ow8N4v68VFM43yPQ6lI2wkAO4kEatnzWvTvfoXKcQ6vcly51869BrJj788L60QqFK 6C35o0baIiFG1+UuebyYG9Q8xFVDTdu3TDjyeAQA6O6fmiQy+G+H6MaiqkacksRS4csp l0wSimU4IVxsOdIn+WrHbyQL8AbkkgZqe1EGla/HZz0GJU6LCUP8h3WkyLq0iSeUkZAH ZhCg== X-Gm-Message-State: AHQUAuaXwftztfJ6otqBRDZObnRIgQ6llJ25eC7JBRS/e6m0J4vf+C3f 3x9PQQu5Aa3tdKLstfvCKbg= X-Google-Smtp-Source: AHgI3IYoQ9dVmSl8PN0b4wGUct2VvAAOs9RbgdcLnYdnzD0eqyS1nExQqbGwiPL6snQh1ppAN29rZA== X-Received: by 2002:a2e:549:: with SMTP id 70-v6mr1560236ljf.196.1549793708686; Sun, 10 Feb 2019 02:15:08 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:07 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 20/23] HID: uclogic: Do not initialize non-USB devices Date: Sun, 10 Feb 2019 12:14:06 +0200 Message-Id: <20190210101409.3511-21-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Do not try to initialize UC-Logic tablets if the underlying device is not a USB device, but e.g. a uhid device. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-params.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index b582739a570a..7710d9f957da 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -826,7 +826,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params, * uclogic_params_cleanup()). Not modified in case of error. * Cannot be NULL. * @hdev: The HID device of the tablet interface to initialize and get - * parameters from. Cannot be NULL. + * parameters from. Cannot be NULL. Must be using the USB low-level + * driver, i.e. be an actual USB tablet. * * Returns: * Zero, if successful. A negative errno code on error. @@ -844,7 +845,8 @@ int uclogic_params_init(struct uclogic_params *params, struct uclogic_params p = {0, }; /* Check arguments */ - if (params == NULL || hdev == NULL) { + if (params == NULL || hdev == NULL || + !hid_is_using_ll_driver(hdev, &usb_hid_driver)) { rc = -EINVAL; goto cleanup; } From patchwork Sun Feb 10 10:14:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804705 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15EDC1515 for ; Sun, 10 Feb 2019 10:15:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07ABC29F45 for ; Sun, 10 Feb 2019 10:15:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F042C29F4A; Sun, 10 Feb 2019 10:15:12 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UPPERCASE_50_75 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 9404E29F45 for ; Sun, 10 Feb 2019 10:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726124AbfBJKPM (ORCPT ); Sun, 10 Feb 2019 05:15:12 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:35502 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKPL (ORCPT ); Sun, 10 Feb 2019 05:15:11 -0500 Received: by mail-lf1-f68.google.com with SMTP id v7so1300525lfd.2 for ; Sun, 10 Feb 2019 02:15:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z2G1erP+5mmn4IOnGdk3LKLT4rH6vvY4cLyc4e2p8tU=; b=I2imlNnBEEBi9q4eeb0m5KIn9P8Z5kQeVQ8NOt6YVSq8sbtYmmrSqXWtNZZDywzHkU ipt2rzAU+avvf6j774PFjg7mTExvtcItQ1XPpjU5oX5P4w+m6M8KI0AEtbE5RBtqmXsT SB7baC9dqGQHwEqNO1ANWLSO161v+C+5EcOAex0SzIfUWg+5VaaspY4HWBKKNXpzRlC6 JXixK/W+7xvy5giUsAGlGZzbBPnVF9q6z8XFEBR5Qzh61DnSHS3fIsS11nCkLRbE8+Fz ofy3lnhMbSdF4qsS3PacW0YWZGesIqEcvJ2SAWxF/wImJa0gSKyaJJ00uX+k8YzdGOVt 3R0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z2G1erP+5mmn4IOnGdk3LKLT4rH6vvY4cLyc4e2p8tU=; b=WTHsELeOpqUevcjDjFkkVQSK5iRa775X8kmc+fCtgmpkm0/D35i5hsSu4f9ADuMTr2 zcfFfoyDSwx6+vxGAMg3Q+lXbpJlFdScT6IOLm6m+Vk5vX+8Qg3n+/9BW4EO87y5DZNH hAcEyRyY+rP0cAWObJ+GaHRMm4tAj4uh2G/hNRQzD/DyeWMry3twIQAHruO7G5E2YJlI wQGqmAvQp0sxGsBaOh020b6bJ/LmMoVKrOM7g7Uw4IeneVrXSv2geLygl6z4W+EXwRgU uwGhy5euoo8kOOgMQSJhNjWjgNWaPR5lBm71QcNoPpTcdrvGffTtjxx2kVvvW40ZrUg6 GCtQ== X-Gm-Message-State: AHQUAuYiFP2k+isbpR7q0ajcf/4UNXV4oYg+nGeL6cigLL04Ox2ALY0n fMmdLqMeJaCmt3HOrOSNcAk= X-Google-Smtp-Source: AHgI3IZ0dJr+V4Lg4pLtSacrnCx/oi0NNQadbp9yfT+yBaDvQW0STp/Dti0xx8xXM70CAXXnULqJHg== X-Received: by 2002:ac2:54b4:: with SMTP id w20mr5386867lfk.24.1549793710081; Sun, 10 Feb 2019 02:15:10 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:09 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 21/23] HID: Remove hid-uclogic entries from hid_have_special_driver Date: Sun, 10 Feb 2019 12:14:07 +0200 Message-Id: <20190210101409.3511-22-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Tested with a couple UC-Logic tablets and it seems to work fine. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-quirks.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 78c836e5ce51..4a6c7df9fc37 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -674,23 +674,6 @@ static const struct hid_device_id hid_have_special_driver[] = { #if IS_ENABLED(CONFIG_HID_TWINHAN) { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, #endif -#if IS_ENABLED(CONFIG_HID_UCLOGIC) - { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_HUION_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP1062) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_YIYNOVA_TABLET) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_81) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_UGEE_TABLET_45) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, - { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, -#endif #if IS_ENABLED(CONFIG_HID_UDRAW_PS3) { HID_USB_DEVICE(USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW) }, #endif From patchwork Sun Feb 10 10:14:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804707 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E62D91575 for ; Sun, 10 Feb 2019 10:15:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D895129F45 for ; Sun, 10 Feb 2019 10:15:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCE9529F4A; Sun, 10 Feb 2019 10:15:13 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UPPERCASE_50_75 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 7B3C629F45 for ; Sun, 10 Feb 2019 10:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726144AbfBJKPN (ORCPT ); Sun, 10 Feb 2019 05:15:13 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45008 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKPM (ORCPT ); Sun, 10 Feb 2019 05:15:12 -0500 Received: by mail-lj1-f196.google.com with SMTP id a16so2331031ljb.11 for ; Sun, 10 Feb 2019 02:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VFDMAuPtUDy5ljcSMyU0Tpvpe27Ov+LV0304LkFgWj4=; b=aQO7MkRlh9aGcl9HduOu8/DRVCfKEggsU9JzdSajrXb1D8h3pNAmX2AbJzPjPMS/Ol 0RUq9lC57yrRzWRUdr0AAtN0ChhMyX0S6RVuSI1H0kBWzHIJ+r2zqoXG1+klY/6GIhCh RPpYKXJjprxQAtocnNk45eBmNitpfaTFgMjZX6spxHBVVc8zDWsEWkt57SuWjliAD4K1 +2tZOhQGJBHsERknaIkBp2bRQ2bTdY9nL4tFCb09BeV9KCke6uoSgVUuqQexc2TGx4cM KYK8c3nmXYCV3DwlgElTYc839BqDDdA5O+3RK6uvKVMB7nbsSKEpCTrNCm9Ywr0i8vHg s3nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VFDMAuPtUDy5ljcSMyU0Tpvpe27Ov+LV0304LkFgWj4=; b=Td1eO17yri7togmxLh5r3AEt1o7BCLwur9KaGY2bgVB7+6M9XSzhA8ZDr3d8ziEm+V CQNc4wim+zb0apFVUeYCHVNhve+bcwZxj65W+3CkIsiD5qCHCNoKv7dsT9P6ArJNGwDg iuGJex5GCDMWUinUMoQbVothtj3rAr14TzTz6+pRBNntHKozqCoJG0s/4fjF8ZjLahoz kl8a639P15qt6PQzt1AfZqmG2J2wtAerA8aJVp8mbeJz5hU4Noe06bPP+XLyY4bHMLZ6 wY82DUmpymr0hdDWcbtNAITNuXgF6Xejpe10y+v3lOLZ3Pm8wI1P9/P7uRPYUQUqIbFt n7+w== X-Gm-Message-State: AHQUAuZC5CR23rhCyEaIKIbVKY27nI/EDTOd4qToQTWa5PJjc0EoEQzs RmH+CkVPRjJoxcjhp0SLdgY= X-Google-Smtp-Source: AHgI3IblbzvtF0xmCXJML5HFOs6WnXfv1OZ6DNlBGf+6zS349fOox3Ptq6RD/UpuQPbsFXs2wQHGcg== X-Received: by 2002:a2e:9855:: with SMTP id e21-v6mr4065258ljj.76.1549793711323; Sun, 10 Feb 2019 02:15:11 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:10 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 22/23] HID: Remove KYE tablets from hid_have_special_driver Date: Sun, 10 Feb 2019 12:14:08 +0200 Message-Id: <20190210101409.3511-23-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Tested with one KYE tablet and it seems to work fine. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-quirks.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 4a6c7df9fc37..38ad3e00d82f 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -412,11 +412,6 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_MANTICORE) }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GX_IMPERATOR) }, { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, - { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, - { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, - { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) }, - { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) }, - { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912) }, #endif #if IS_ENABLED(CONFIG_HID_LCPOWER) { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000) }, From patchwork Sun Feb 10 10:14:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804709 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E15841575 for ; Sun, 10 Feb 2019 10:15:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D374729F45 for ; Sun, 10 Feb 2019 10:15:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C80A129F4A; Sun, 10 Feb 2019 10:15:15 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UPPERCASE_50_75 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 7169C29F45 for ; Sun, 10 Feb 2019 10:15:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726152AbfBJKPP (ORCPT ); Sun, 10 Feb 2019 05:15:15 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45006 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKPO (ORCPT ); Sun, 10 Feb 2019 05:15:14 -0500 Received: by mail-lj1-f193.google.com with SMTP id a16so2331045ljb.11 for ; Sun, 10 Feb 2019 02:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=My1e6OsDcwewOyJLQ18j6V1F/F7wH9UkmxIxM16oGaU=; b=E1TS/iM4hdPvcuVauQwMrBVrDE5kBsiihs6QsT0qmKtNicb8TSm6q2LFcHJLWJqqCY Jo6YkifCbYmGS1xeZkLFEtz85cUCcVNTcQIKh3FQwF8Q+r89Wv0zLqeyuDOJWXQePQqB KzO/ng0mlQz1G60R+uAZoMND8R+Elu3/7AZXDEdSiVPzQGb2Va8CvF/Or3/4lyUarmza Fh6qT21CCSsLoB4b5k9M4NOWSCxXr8UbN+FfHJhEckG8CBU4J0En2FMpxpZX0ayKbcZx xC5GtlkQFw7eIGbz5Lr7PDm2UmLTdFTOO5JuVZraYeVvZj0aexPnkI2YVyNmoauLLcJn rrWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=My1e6OsDcwewOyJLQ18j6V1F/F7wH9UkmxIxM16oGaU=; b=hZurdzHFE0R4HgtA3Z9ml/xA7ZugtSv3WNyCM0vZ2wji5/gSiKDI63SYlDhGWQapeD oG5W01QK+o/oI5EjND9Og/UQ9jvtuzSpCKE+QGx8PuyB6umjQ65Qqi2GNzya/PL4vAtC 80AhxIa0t5S/LziZNTtVmj4/XovhNilTjJcOkw5mqelOJuJ32/Fyqnh7AxEDYHh/AGDM bvbneZ1EQ5UZko6Q1Ti9NzvBP4XMacBNfJka6Gmto3ETsxeL5BIpQPEOBFvXjllfFDda X2YPd2Q5x7V3Z0TLJFumwh8+sqQZ+geKyz/lJq6E1YKFWd6Pu2DSYP3HCdR25VbioV40 70ag== X-Gm-Message-State: AHQUAuaoZ5ka1M1XYRFgJHB6AfKyoC0gN300QVWYYllpMDkyKbJh40fV vPP5Ucaa7sCXZrfWTNLOMX0= X-Google-Smtp-Source: AHgI3IbX3014POY++rm7VvTE2e6Ej5BcTP+BSksZmDcfNR1jaihWisRD+6WcHQMBjjjGO/Hu4Q76mQ== X-Received: by 2002:a2e:750a:: with SMTP id q10-v6mr16849165ljc.39.1549793712574; Sun, 10 Feb 2019 02:15:12 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:15:11 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 23/23] HID: Remove Waltop tablets from hid_have_special_driver Date: Sun, 10 Feb 2019 12:14:09 +0200 Message-Id: <20190210101409.3511-24-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 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 Tested with a Waltop tablet and it seems to work fine. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-quirks.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 38ad3e00d82f..9579ec9f1c9f 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -672,15 +672,6 @@ static const struct hid_device_id hid_have_special_driver[] = { #if IS_ENABLED(CONFIG_HID_UDRAW_PS3) { HID_USB_DEVICE(USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW) }, #endif -#if IS_ENABLED(CONFIG_HID_WALTOP) - { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) }, - { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) }, - { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_Q_PAD) }, - { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_PID_0038) }, - { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) }, - { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, - { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, -#endif #if IS_ENABLED(CONFIG_HID_XINMO) { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) }, { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) },