From patchwork Mon Dec 26 12:54:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 637155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20182C3DA79 for ; Mon, 26 Dec 2022 12:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbiLZMzN (ORCPT ); Mon, 26 Dec 2022 07:55:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231766AbiLZMzL (ORCPT ); Mon, 26 Dec 2022 07:55:11 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D3F124A; Mon, 26 Dec 2022 04:55:10 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so7471859wms.2; Mon, 26 Dec 2022 04:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CgO7IbDqgEqOBYZvNEQA1RHViZvpw8XhwXsdAZWfOVg=; b=miMOIpfNfMXQ+NapwMFztK0IUXcMuYUgnlhM5D+UQ0dviaWcQn97QZl83rmrYR2tA7 4665vSANJGpxwmqIF+IMatTEmSbXFTCO3b0KNJi9Yidi0O/pTgP9nltBpreTyXWdYnNv 3U+XTlUGGZ3e50+hVXBnOtBor1Q+o+F2wqm/9O+tugBeeQ8C2CJ6JUbacluwGeHal6km T9PAQkRBu7RZvoJu0vdcRIP6jpH1r5n+mxvaj5D4F3p+6S0PE7vKAtdua9S5otAQWU0E Ce7RlZT7gXT4y+ChxzeJdzlBriDYmvpOOeg8MzibU/j33UCimeo+due1LpXP9G8yP/v8 3EiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CgO7IbDqgEqOBYZvNEQA1RHViZvpw8XhwXsdAZWfOVg=; b=ACWH+WTtI2rySybSJV4QOcncTGymVxOiBgEncNUUuK0Dk+Xk5DFEFgE6DTGzQyxo0I gjb5UyeBCf95LV8hBhi43CIb859mbvgWWRVjhlDusCdsw++eOZVFZY1H5K6qFbCNGR4/ WRGw0GzO+iGOedY6WuPLEZbo0kMQczGugToIiYJmymuyAqZKXQD1oPEbqoKa1Bi16UyW nEAA+cu1JiLaJVIcFtAVtBmB7Q0ZY81S9Oqkp2V0S9eJ/ehYvuNSWImRbzd/dNjIJpU7 4Dwjurbxdjp6R5ccWnIjdZsveVxyzYcZkWyhsrOzcmkGmO+NhKe+yNt9yXIjo3p7ev1G OwqA== X-Gm-Message-State: AFqh2kpRICa8lP6sKXTRiQKVZ0EZUgsQmsirR+3/TyZ8goUbbednaGu+ PZzpC4gCQNjB1gxzyDymyhM= X-Google-Smtp-Source: AMrXdXuk/JuoZgr04mNTTCzhq56v0bwSLJ8kOkPaHxaqW7elHjXXmN0YOijxWjm/XiPmB1HNNDvTEg== X-Received: by 2002:a05:600c:4e51:b0:3d1:e1f4:21d1 with SMTP id e17-20020a05600c4e5100b003d1e1f421d1mr15405746wmq.26.1672059309067; Mon, 26 Dec 2022 04:55:09 -0800 (PST) Received: from localhost.localdomain ([94.73.32.212]) by smtp.gmail.com with ESMTPSA id y24-20020a05600c365800b003cf894dbc4fsm13684497wmq.25.2022.12.26.04.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 04:55:08 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , Mia Kanashi , Andreas Grosse Subject: [PATCH 1/6] HID: uclogic: Add frame type quirk Date: Mon, 26 Dec 2022 13:54:49 +0100 Message-Id: <20221226125454.16106-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221226125454.16106-1-jose.exposito89@gmail.com> References: <20221226125454.16106-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The report descriptor used to get information about UGEE v2 devices is incorrect in the XP-PEN Deco Pro SW. It indicates that the device frame is of type UCLOGIC_PARAMS_FRAME_BUTTONS but the device has a frame of type UCLOGIC_PARAMS_FRAME_MOUSE. Here is the original report descriptor: 0x0e 0x03 0xc8 0xb3 0x34 0x65 0x08 0x00 0xff 0x1f 0xd8 0x13 0x00 0x00 ^ This byte should be 2 Add a quirk to be able to fix the reported frame type. Tested-by: Mia Kanashi Tested-by: Andreas Grosse Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 20 +------------------- drivers/hid/hid-uclogic-params.c | 5 +++++ drivers/hid/hid-uclogic-params.h | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 7fa6fe04f1b2..7a5480b6f046 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -22,25 +22,6 @@ #include "hid-ids.h" -/* Driver data */ -struct uclogic_drvdata { - /* 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; - /* Pen input device */ - 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; -}; - /** * uclogic_inrange_timeout - handle pen in-range state timeout. * Emulate input events normally generated when pen goes out of range for @@ -202,6 +183,7 @@ static int uclogic_probe(struct hid_device *hdev, } timer_setup(&drvdata->inrange_timer, uclogic_inrange_timeout, 0); drvdata->re_state = U8_MAX; + drvdata->quirks = id->driver_data; hid_set_drvdata(hdev, drvdata); /* Initialize the device and retrieve interface parameters */ diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index cd1233d7e253..2d46d4d50604 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1298,6 +1298,7 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, struct hid_device *hdev) { int rc = 0; + struct uclogic_drvdata *drvdata; struct usb_interface *iface; __u8 bInterfaceNumber; const int str_desc_len = 12; @@ -1316,6 +1317,7 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, goto cleanup; } + drvdata = hid_get_drvdata(hdev); iface = to_usb_interface(hdev->dev.parent); bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; @@ -1382,6 +1384,9 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, p.pen.subreport_list[0].id = UCLOGIC_RDESC_V1_FRAME_ID; /* Initialize the frame interface */ + if (drvdata->quirks & UCLOGIC_MOUSE_FRAME_QUIRK) + frame_type = UCLOGIC_PARAMS_FRAME_MOUSE; + switch (frame_type) { case UCLOGIC_PARAMS_FRAME_DIAL: case UCLOGIC_PARAMS_FRAME_MOUSE: diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index a97477c02ff8..10a05c7fd939 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -19,6 +19,8 @@ #include #include +#define UCLOGIC_MOUSE_FRAME_QUIRK BIT(0) + /* Types of pen in-range reporting */ enum uclogic_params_pen_inrange { /* Normal reports: zero - out of proximity, one - in proximity */ @@ -215,6 +217,27 @@ struct uclogic_params { struct uclogic_params_frame frame_list[3]; }; +/* Driver data */ +struct uclogic_drvdata { + /* 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; + /* Pen input device */ + 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; + /* Device quirks */ + unsigned long quirks; +}; + /* Initialize a tablet interface and discover its parameters */ extern int uclogic_params_init(struct uclogic_params *params, struct hid_device *hdev); From patchwork Mon Dec 26 12:54:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 636911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47F01C3DA7D for ; Mon, 26 Dec 2022 12:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232050AbiLZMzN (ORCPT ); Mon, 26 Dec 2022 07:55:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbiLZMzM (ORCPT ); Mon, 26 Dec 2022 07:55:12 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51580DFA; Mon, 26 Dec 2022 04:55:11 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id k26-20020a05600c1c9a00b003d972646a7dso4058203wms.5; Mon, 26 Dec 2022 04:55:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lUVWBQlXKzFP1zq6JqAFf3+HtIMfgJ5UD/Yw7gpSm3A=; b=bhVxIBlogKDWgM4hWTkPzeV3uP91M71P36NvwvlJkKq7l7+/sPm8DzimOpJW1aNtBB H88Yk/fQU8PseFGTHfHAbdZPb/kzCbYIvahtVprcQsSYwussIq9ZqhwQsePZQA9gmWa3 kyqmxV+hORFTqFLI4d9nm7+6+P0LU7qmDZyrohvRyuPANGEPkT6xPfsNF+BnSJcT3I1I kExjPc55h4oUnxf+k5ATlNhms9MHkIbkW0TY7RoralIhG62C//bN4XAfq+ZreoKxwe5K Uwthiyyb5a+diIwMAVtc1l644IXgc8YcO/h213sejsOPzrAdffSlcX4K2fEmhE9N0r62 dmSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lUVWBQlXKzFP1zq6JqAFf3+HtIMfgJ5UD/Yw7gpSm3A=; b=CBkkzbdYv3ZCiIOn/TGducJipDK6e6FQaASusxrjihJgsjwrjX41j3XsK7w9PMe1SM rAA/BxXTFof/AoJ53HkmaV+SBU8hdc/plOFg3eHtvVZ9WaYWPP2dKfz+mcTnQgGMNxkL nI0JrVqScRQR8Dq+d4mMAu7tc26780JVRUArwkHhLRTy5/4WhqM5/pZN9L/kRVEgL5iB JBj18y3f+hUX4qzSQqpco5RfGzAKdQWpHzgYp00Evcb0w6iJZ5mRN6ISiAkeDqkdjABq Ri9+gJ7m5/Y3UzrMTsQpcvWY77HAm9en1uFlmYg48UDhUZZiVOaC2dVJP7N2+b3Houve r8Sg== X-Gm-Message-State: AFqh2krxRhJacpOswbOtuH+isvoNAwehCoMj02ZJU8iICbtlSwfw2IXQ nV2PCunSN24ZHL8MgWKY4o0= X-Google-Smtp-Source: AMrXdXvLLumkNKUkTxr/yZr3WSkAP1yx8Oi82c8wjOEgDZ4hrEOomRjZR4ZDmYIlKeOTostzcQ6/Vw== X-Received: by 2002:a05:600c:3844:b0:3d2:191d:2420 with SMTP id s4-20020a05600c384400b003d2191d2420mr13109943wmr.7.1672059309824; Mon, 26 Dec 2022 04:55:09 -0800 (PST) Received: from localhost.localdomain ([94.73.32.212]) by smtp.gmail.com with ESMTPSA id y24-20020a05600c365800b003cf894dbc4fsm13684497wmq.25.2022.12.26.04.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 04:55:09 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , Mia Kanashi , Andreas Grosse Subject: [PATCH 2/6] HID: uclogic: Add battery quirk Date: Mon, 26 Dec 2022 13:54:50 +0100 Message-Id: <20221226125454.16106-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221226125454.16106-1-jose.exposito89@gmail.com> References: <20221226125454.16106-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Some UGEE v2 tablets have a wireless version with an internal battery and their firmware is able to report their battery level. However, there was not found a field on their descriptor indicating whether the tablet has battery or not, making it mandatory to classify such devices through the UCLOGIC_BATTERY_QUIRK quirk. Tested-by: Mia Kanashi Tested-by: Andreas Grosse Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 5 +++++ drivers/hid/hid-uclogic-params.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 2d46d4d50604..37cf4a93eafa 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1222,6 +1222,11 @@ static int uclogic_params_ugee_v2_init_frame_mouse(struct uclogic_params *p) */ static bool uclogic_params_ugee_v2_has_battery(struct hid_device *hdev) { + struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); + + if (drvdata->quirks & UCLOGIC_BATTERY_QUIRK) + return true; + /* The XP-PEN Deco LW vendor, product and version are identical to the * Deco L. The only difference reported by their firmware is the product * name. Add a quirk to support battery reporting on the wireless diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index 10a05c7fd939..b0e7f3807939 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -20,6 +20,7 @@ #include #define UCLOGIC_MOUSE_FRAME_QUIRK BIT(0) +#define UCLOGIC_BATTERY_QUIRK BIT(1) /* Types of pen in-range reporting */ enum uclogic_params_pen_inrange { From patchwork Mon Dec 26 12:54:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 636910 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE38CC3DA7D for ; Mon, 26 Dec 2022 12:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232095AbiLZMzY (ORCPT ); Mon, 26 Dec 2022 07:55:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbiLZMzO (ORCPT ); Mon, 26 Dec 2022 07:55:14 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4761B638A; Mon, 26 Dec 2022 04:55:12 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id ay40so7519028wmb.2; Mon, 26 Dec 2022 04:55:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yrvtidJ8xPFZfQ460af+rLN0IIOJjCAfOAN34f+mtgs=; b=i8mWrqY68XdaYSWJhe8ZGyoitTjfSNsZDeBZiEfXUkARctGNy7OSchlJI5NAmoEyMu YROHsAKlvyWYNtzb6l37n7KcN6ARWBUWunLc8yIaKgoxjr+QESRRDMiOBXY9tTRg8QFc Yfzx56iZa7qK3taqFXzMFDO1qm81kUvoLeIkFv+pP2hxYvAJl3iHUlNSUQTtoY3hr/R5 d55Upl/4wDEEeL+7xn16zRY1SQF+P/4DFaKpwI82gr+hgxH6kFgUj0nr8pnt2+HlSZ8v PRh7rN73iw6xRsQaBdiMPYi4e66SVaxWqwq2petY8i0851W4acbHiWTtuKvC/F1lLmY9 yHSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yrvtidJ8xPFZfQ460af+rLN0IIOJjCAfOAN34f+mtgs=; b=jKjAJ3+GVEQISfrBCsX+o8A9LOlbaQvcPBiiFDlWTNvXDdbgunv55iHwk1hLYOHjo9 5K2dk8ZAdGJOAf7RxqdV2nyLNRHCFsUmrIm8XR6a14Dk3d1PH1G0yeP1O7lfXg9gCMUL t9CSz42khzWdoMNR3FKpqVkzDN4xeCe4cmOLxLcGADzKVHd8FFu07seP6QXWBJZH2KRG 2CsVk2HQIgS4l7uLqAJe7hWbgGzLVMbY7vD1jXpD4dhNae/7h7j/R4Fyk+VbSsLsmjKz 27lA1I84AJtQk6+9cb5M6cNgY5TTRNYhhok+oqAEQMetWbFk/zLH1pi9VIh3ai3sZKvC Cc2A== X-Gm-Message-State: AFqh2kpzO8JRYslDq0Xq5D1YD0hcVnc/Xfz/HlWf2f1/grJpM1lIZb87 czZrOuoAMKEgQ0/v01mcQPc= X-Google-Smtp-Source: AMrXdXu/pX3Ym6ZUtRfmyjt7cLay9jEvon1AhK13Hkw97UsPvQ8GhrGyZtxg6k0izbJ731iU96HpYw== X-Received: by 2002:a1c:5442:0:b0:3cf:7385:677f with SMTP id p2-20020a1c5442000000b003cf7385677fmr12686996wmi.35.1672059310708; Mon, 26 Dec 2022 04:55:10 -0800 (PST) Received: from localhost.localdomain ([94.73.32.212]) by smtp.gmail.com with ESMTPSA id y24-20020a05600c365800b003cf894dbc4fsm13684497wmq.25.2022.12.26.04.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 04:55:10 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , Mia Kanashi , Andreas Grosse Subject: [PATCH 3/6] HID: uclogic: Refactor UGEEv2 probe magic data Date: Mon, 26 Dec 2022 13:54:51 +0100 Message-Id: <20221226125454.16106-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221226125454.16106-1-jose.exposito89@gmail.com> References: <20221226125454.16106-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org A fututure patch will need to use the array of magic data that the UGEEv2 devices expect on probe and the endpoint number. Move them to a common place. Refactor, no functional changes. Tested-by: Mia Kanashi Tested-by: Andreas Grosse Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 11 +++++------ drivers/hid/hid-uclogic-rdesc.c | 6 ++++++ drivers/hid/hid-uclogic-rdesc.h | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 37cf4a93eafa..b6a515973942 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1021,8 +1021,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params, * Returns: * Zero, if successful. A negative errno code on error. */ -static int uclogic_probe_interface(struct hid_device *hdev, u8 *magic_arr, - int magic_size, int endpoint) +static int uclogic_probe_interface(struct hid_device *hdev, const u8 *magic_arr, + size_t magic_size, int endpoint) { struct usb_device *udev; unsigned int pipe = 0; @@ -1311,9 +1311,6 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, __u8 *rdesc_pen = NULL; s32 desc_params[UCLOGIC_RDESC_PH_ID_NUM]; enum uclogic_params_frame_type frame_type; - __u8 magic_arr[] = { - 0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; /* The resulting parameters (noop) */ struct uclogic_params p = {0, }; @@ -1344,7 +1341,9 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, * The specific data was discovered by sniffing the Windows driver * traffic. */ - rc = uclogic_probe_interface(hdev, magic_arr, sizeof(magic_arr), 0x03); + rc = uclogic_probe_interface(hdev, uclogic_ugee_v2_probe_arr, + uclogic_ugee_v2_probe_size, + uclogic_ugee_v2_probe_endpoint); if (rc) { uclogic_params_init_invalid(&p); goto output; diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index fb40775f5f5b..b6dfdf6356a6 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -859,6 +859,12 @@ const __u8 uclogic_rdesc_v2_frame_dial_arr[] = { const size_t uclogic_rdesc_v2_frame_dial_size = sizeof(uclogic_rdesc_v2_frame_dial_arr); +const __u8 uclogic_ugee_v2_probe_arr[] = { + 0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const size_t uclogic_ugee_v2_probe_size = sizeof(uclogic_ugee_v2_probe_arr); +const int uclogic_ugee_v2_probe_endpoint = 0x03; + /* Fixed report descriptor template for UGEE v2 pen reports */ const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[] = { 0x05, 0x0d, /* Usage Page (Digitizers), */ diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index a1f78c07293f..906d068f50a9 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -164,6 +164,11 @@ extern const size_t uclogic_rdesc_v2_frame_dial_size; /* Report ID for tweaked UGEE v2 battery reports */ #define UCLOGIC_RDESC_UGEE_V2_BATTERY_ID 0xba +/* Magic data expected by UGEEv2 devices on probe */ +extern const __u8 uclogic_ugee_v2_probe_arr[]; +extern const size_t uclogic_ugee_v2_probe_size; +extern const int uclogic_ugee_v2_probe_endpoint; + /* Fixed report descriptor template for UGEE v2 pen reports */ extern const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[]; extern const size_t uclogic_rdesc_ugee_v2_pen_template_size; From patchwork Mon Dec 26 12:54:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 637154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9155DC3DA79 for ; Mon, 26 Dec 2022 12:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbiLZMzV (ORCPT ); Mon, 26 Dec 2022 07:55:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232062AbiLZMzO (ORCPT ); Mon, 26 Dec 2022 07:55:14 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D3B4DFA; Mon, 26 Dec 2022 04:55:13 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so10358210wma.1; Mon, 26 Dec 2022 04:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vDV3yiQCxKjyRe2BrkxUA/BaPPKeET1PmW5WU9GrEbA=; b=MykWob17+SbSKC0pAldTsUb+7xQUqC3wmR0SL+dhB7zb//Oww6JMFYF8zBkRxd61HX 6uT4NloCG4Zr0MlmFqD8Om2eG0QhPywaj9Wyjmcw36JhgQVAw7BYVivqNuDmKKXy/Vye IFYTL67Z+bIj5XucAoIEpp0K9kJr2sGUXm4RLT+CedVVQlijReIxOzmQDpzWBS/Qdhau CgR2/qIxrsKALtYQCKW/bZMGtKPDD3Ntt+3mRyPWRRhay54mF+lFmyRj0OFcsZsfrBMS NZ0Te/jMe99bii0j2rGaEs9CUSoBgBeI5RNvtBYcXy12+8Ih0ZRoV/u9zg2c3sNSe4m5 AnoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vDV3yiQCxKjyRe2BrkxUA/BaPPKeET1PmW5WU9GrEbA=; b=jeIH3VEGufV6rR+TmkHlJ0eBXQezntKj1VlDtmyBWvPCMgSEp9+mfmPYZpCOeK/mJB pJV1h5xp+Q/+e55zobdD9bcl2cdPBGXp6JidmhlBsB+/BkoWpXRAuGpLtyKpRlo64p9R rDxZomI3FUbXyucfyMk0UtMYrLViU0c2CIMD6GQ28KfnpLo37D4RGFoHjG/xk7BmL3fG cgxVMfQnXkVH9SHLKDBr6Zc/ZVhZFgLIyA/oZNdvPhEdO8B1JPltA+3953nux7IboiV7 5IuKE7Sf67IfFw9JR4s46BgeSO+RNfJ/w/8PQzHZFRuj1QNkkcAOrZkdN56nUQv/v2tH kg3Q== X-Gm-Message-State: AFqh2ko9h/5twbpReoMdiXLWipxcdyR5y/g0E232ZVw2VTTYk+mKEzNK zS4SoNzMQGr//fEOM9Q0EKg= X-Google-Smtp-Source: AMrXdXvOxRHMoY5rOCAfbA/SHhChNSZRgBF8g556h3qzWnvIWK1HgD9IwRO/VNHdQRS+04QDYFrjIg== X-Received: by 2002:a7b:cb56:0:b0:3d2:3be4:2d9a with SMTP id v22-20020a7bcb56000000b003d23be42d9amr12942179wmj.20.1672059311613; Mon, 26 Dec 2022 04:55:11 -0800 (PST) Received: from localhost.localdomain ([94.73.32.212]) by smtp.gmail.com with ESMTPSA id y24-20020a05600c365800b003cf894dbc4fsm13684497wmq.25.2022.12.26.04.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 04:55:11 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , Mia Kanashi , Andreas Grosse Subject: [PATCH 4/6] HID: uclogic: Handle wireless device reconnection Date: Mon, 26 Dec 2022 13:54:52 +0100 Message-Id: <20221226125454.16106-5-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221226125454.16106-1-jose.exposito89@gmail.com> References: <20221226125454.16106-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org UGEEv2 tablets with battery can be connected using a USB cable or a USB Bluetooth dongle. When the Bluetooth dongle is used, the connection to that tablet can be lost because the tablet is out of the range of the receiver or because it was switched off using the switch placed in the back of the tablet's frame. After losing connection, the tablet is able to reconnect automatically and its firmware sends a special packet indicating that the device was reconnected. In response to this packet, the tablet needs to receive the same array of magic data it expects on probe to enable its interfaces. This patch implements a generic mechanism to hook raw events and schedule a work to perform any custom action. Tested-by: Mia Kanashi Tested-by: Andreas Grosse Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core-test.c | 105 ++++++++++++++++++++++++++ drivers/hid/hid-uclogic-core.c | 35 +++++++++ drivers/hid/hid-uclogic-params-test.c | 16 ++++ drivers/hid/hid-uclogic-params.c | 99 ++++++++++++++++++++++++ drivers/hid/hid-uclogic-params.h | 16 ++++ 5 files changed, 271 insertions(+) create mode 100644 drivers/hid/hid-uclogic-core-test.c diff --git a/drivers/hid/hid-uclogic-core-test.c b/drivers/hid/hid-uclogic-core-test.c new file mode 100644 index 000000000000..2bb916226a38 --- /dev/null +++ b/drivers/hid/hid-uclogic-core-test.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/* + * HID driver for UC-Logic devices not fully compliant with HID standard + * + * Copyright (c) 2022 José Expósito + */ + +#include +#include "./hid-uclogic-params.h" + +#define MAX_EVENT_SIZE 12 + +struct uclogic_raw_event_hook_test { + u8 event[MAX_EVENT_SIZE]; + size_t size; + bool expected; +}; + +static struct uclogic_raw_event_hook_test hook_events[] = { + { + .event = { 0xA1, 0xB2, 0xC3, 0xD4 }, + .size = 4, + }, + { + .event = { 0x1F, 0x2E, 0x3D, 0x4C, 0x5B, 0x6A }, + .size = 6, + }, +}; + +static struct uclogic_raw_event_hook_test test_events[] = { + { + .event = { 0xA1, 0xB2, 0xC3, 0xD4 }, + .size = 4, + .expected = true, + }, + { + .event = { 0x1F, 0x2E, 0x3D, 0x4C, 0x5B, 0x6A }, + .size = 6, + .expected = true, + }, + { + .event = { 0xA1, 0xB2, 0xC3 }, + .size = 3, + .expected = false, + }, + { + .event = { 0xA1, 0xB2, 0xC3, 0xD4, 0x00 }, + .size = 5, + .expected = false, + }, + { + .event = { 0x2E, 0x3D, 0x4C, 0x5B, 0x6A, 0x1F }, + .size = 6, + .expected = false, + }, +}; + +static void hid_test_uclogic_exec_event_hook_test(struct kunit *test) +{ + struct uclogic_params p = {0, }; + struct uclogic_raw_event_hook *filter; + bool res; + int n; + + /* Initialize the list of events to hook */ + p.event_hooks = kunit_kzalloc(test, sizeof(*p.event_hooks), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, p.event_hooks); + INIT_LIST_HEAD(&p.event_hooks->list); + + for (n = 0; n < ARRAY_SIZE(hook_events); n++) { + filter = kunit_kzalloc(test, sizeof(*filter), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, filter); + + filter->size = hook_events[n].size; + filter->event = kunit_kzalloc(test, filter->size, GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, filter->event); + memcpy(filter->event, &hook_events[n].event[0], filter->size); + + list_add_tail(&filter->list, &p.event_hooks->list); + } + + /* Test uclogic_exec_event_hook() */ + for (n = 0; n < ARRAY_SIZE(test_events); n++) { + res = uclogic_exec_event_hook(&p, &test_events[n].event[0], + test_events[n].size); + KUNIT_ASSERT_EQ(test, res, test_events[n].expected); + } +} + +static struct kunit_case hid_uclogic_core_test_cases[] = { + KUNIT_CASE(hid_test_uclogic_exec_event_hook_test), + {} +}; + +static struct kunit_suite hid_uclogic_core_test_suite = { + .name = "hid_uclogic_core_test", + .test_cases = hid_uclogic_core_test_cases, +}; + +kunit_test_suite(hid_uclogic_core_test_suite); + +MODULE_DESCRIPTION("KUnit tests for the UC-Logic driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("José Expósito "); diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 7a5480b6f046..9ddb17ad0d04 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -249,6 +249,34 @@ static int uclogic_resume(struct hid_device *hdev) } #endif +/** + * uclogic_exec_event_hook - if the received event is hooked schedules the + * associated work. + * + * @p: Tablet interface report parameters. + * @event: Raw event. + * @size: The size of event. + * + * Returns: + * Whether the event was hooked or not. + */ +static bool uclogic_exec_event_hook(struct uclogic_params *p, u8 *event, int size) +{ + struct uclogic_raw_event_hook *curr; + + if (!p->event_hooks) + return false; + + list_for_each_entry(curr, &p->event_hooks->list, list) { + if (curr->size == size && memcmp(curr->event, event, size) == 0) { + schedule_work(&curr->work); + return true; + } + } + + return false; +} + /** * uclogic_raw_event_pen - handle raw pen events (pen HID reports). * @@ -407,6 +435,9 @@ static int uclogic_raw_event(struct hid_device *hdev, if (report->type != HID_INPUT_REPORT) return 0; + if (uclogic_exec_event_hook(params, data, size)) + return 0; + while (true) { /* Tweak pen reports, if necessary */ if ((report_id == params->pen.id) && (size >= 2)) { @@ -536,3 +567,7 @@ module_hid_driver(uclogic_driver); MODULE_AUTHOR("Martin Rusko"); MODULE_AUTHOR("Nikolai Kondrashov"); MODULE_LICENSE("GPL"); + +#ifdef CONFIG_HID_KUNIT_TEST +#include "hid-uclogic-core-test.c" +#endif diff --git a/drivers/hid/hid-uclogic-params-test.c b/drivers/hid/hid-uclogic-params-test.c index bfa7ccb7d1e8..678f50cbb160 100644 --- a/drivers/hid/hid-uclogic-params-test.c +++ b/drivers/hid/hid-uclogic-params-test.c @@ -174,9 +174,25 @@ static void hid_test_uclogic_parse_ugee_v2_desc(struct kunit *test) KUNIT_EXPECT_EQ(test, params->frame_type, frame_type); } +static void hid_test_uclogic_params_cleanup_event_hooks(struct kunit *test) +{ + int res, n; + struct uclogic_params p = {0, }; + + res = uclogic_params_ugee_v2_init_event_hooks(NULL, &p); + KUNIT_ASSERT_EQ(test, res, 0); + + /* Check that the function can be called repeatedly */ + for (n = 0; n < 4; n++) { + uclogic_params_cleanup_event_hooks(&p); + KUNIT_EXPECT_PTR_EQ(test, p.event_hooks, NULL); + } +} + static struct kunit_case hid_uclogic_params_test_cases[] = { KUNIT_CASE_PARAM(hid_test_uclogic_parse_ugee_v2_desc, uclogic_parse_ugee_v2_desc_gen_params), + KUNIT_CASE(hid_test_uclogic_params_cleanup_event_hooks), {} }; diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index b6a515973942..86702c994c57 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -615,6 +615,31 @@ static int uclogic_params_frame_init_v1(struct uclogic_params_frame *frame, return rc; } +/** + * uclogic_params_cleanup_event_hooks - free resources used by the list of raw + * event hooks. + * Can be called repeatedly. + * + * @params: Input parameters to cleanup. Cannot be NULL. + */ +static void uclogic_params_cleanup_event_hooks(struct uclogic_params *params) +{ + struct uclogic_raw_event_hook *curr, *n; + + if (!params || !params->event_hooks) + return; + + list_for_each_entry_safe(curr, n, ¶ms->event_hooks->list, list) { + cancel_work_sync(&curr->work); + list_del(&curr->list); + kfree(curr->event); + kfree(curr); + } + + kfree(params->event_hooks); + params->event_hooks = NULL; +} + /** * uclogic_params_cleanup - free resources used by struct uclogic_params * (tablet interface's parameters). @@ -631,6 +656,7 @@ void uclogic_params_cleanup(struct uclogic_params *params) for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) uclogic_params_frame_cleanup(¶ms->frame_list[i]); + uclogic_params_cleanup_event_hooks(params); memset(params, 0, sizeof(*params)); } } @@ -1280,6 +1306,72 @@ static int uclogic_params_ugee_v2_init_battery(struct hid_device *hdev, return rc; } +/** + * uclogic_params_ugee_v2_reconnect_work() - When a wireless tablet looses + * connection to the USB dongle and reconnects, either because of its physical + * distance or because it was switches off and on using the frame's switch, + * uclogic_probe_interface() needs to be called again to enable the tablet. + * + * @work: The work that triggered this function. + */ +static void uclogic_params_ugee_v2_reconnect_work(struct work_struct *work) +{ + struct uclogic_raw_event_hook *event_hook; + + event_hook = container_of(work, struct uclogic_raw_event_hook, work); + uclogic_probe_interface(event_hook->hdev, uclogic_ugee_v2_probe_arr, + uclogic_ugee_v2_probe_size, + uclogic_ugee_v2_probe_endpoint); +} + +/** + * uclogic_params_ugee_v2_init_event_hooks() - initialize the list of events + * to be hooked for UGEE v2 devices. + * @hdev: The HID device of the tablet interface to initialize and get + * parameters from. + * @p: Parameters to fill in, cannot be NULL. + * + * Returns: + * Zero, if successful. A negative errno code on error. + */ +static int uclogic_params_ugee_v2_init_event_hooks(struct hid_device *hdev, + struct uclogic_params *p) +{ + struct uclogic_raw_event_hook *event_hook; + __u8 reconnect_event[] = { + /* Event received on wireless tablet reconnection */ + 0x02, 0xF8, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + if (!p) + return -EINVAL; + + /* The reconnection event is only received if the tablet has battery */ + if (!uclogic_params_ugee_v2_has_battery(hdev)) + return 0; + + p->event_hooks = kzalloc(sizeof(*p->event_hooks), GFP_KERNEL); + if (!p->event_hooks) + return -ENOMEM; + + INIT_LIST_HEAD(&p->event_hooks->list); + + event_hook = kzalloc(sizeof(*event_hook), GFP_KERNEL); + if (!event_hook) + return -ENOMEM; + + INIT_WORK(&event_hook->work, uclogic_params_ugee_v2_reconnect_work); + event_hook->hdev = hdev; + event_hook->size = ARRAY_SIZE(reconnect_event); + event_hook->event = kmemdup(reconnect_event, event_hook->size, GFP_KERNEL); + if (!event_hook->event) + return -ENOMEM; + + list_add_tail(&event_hook->list, &p->event_hooks->list); + + return 0; +} + /** * uclogic_params_ugee_v2_init() - initialize a UGEE graphics tablets by * discovering their parameters. @@ -1416,6 +1508,13 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, } } + /* Create a list of raw events to be ignored */ + rc = uclogic_params_ugee_v2_init_event_hooks(hdev, &p); + if (rc) { + hid_err(hdev, "error initializing event hook list: %d\n", rc); + goto cleanup; + } + output: /* Output parameters */ memcpy(params, &p, sizeof(*params)); diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index b0e7f3807939..d6ffadb2f601 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -18,6 +18,7 @@ #include #include +#include #define UCLOGIC_MOUSE_FRAME_QUIRK BIT(0) #define UCLOGIC_BATTERY_QUIRK BIT(1) @@ -176,6 +177,17 @@ struct uclogic_params_frame { unsigned int bitmap_dial_byte; }; +/* + * List of works to be performed when a certain raw event is received. + */ +struct uclogic_raw_event_hook { + struct hid_device *hdev; + __u8 *event; + size_t size; + struct work_struct work; + struct list_head list; +}; + /* * Tablet interface report parameters. * @@ -216,6 +228,10 @@ struct uclogic_params { * parts. Only valid, if "invalid" is false. */ struct uclogic_params_frame frame_list[3]; + /* + * List of event hooks. + */ + struct uclogic_raw_event_hook *event_hooks; }; /* Driver data */ From patchwork Mon Dec 26 12:54:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 637153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE79DC3DA79 for ; Mon, 26 Dec 2022 12:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232101AbiLZMzZ (ORCPT ); Mon, 26 Dec 2022 07:55:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232070AbiLZMzO (ORCPT ); Mon, 26 Dec 2022 07:55:14 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA75E24A; Mon, 26 Dec 2022 04:55:13 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id fm16-20020a05600c0c1000b003d96fb976efso5076923wmb.3; Mon, 26 Dec 2022 04:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/UNhxDSHnBv7KasoGqlSIgR8N/+eP92s5GskeMMSIno=; b=iupi2Ql1ztT+GKijQkUDyBSSpLvh6Axuz8njlD1jaRb7n4FJ+eSA81yPYyGH+0RgAa qO2qHgRNKk+tgGjE4NgCPjrsnagIrdnHFdfEItt71pr6gQ5PWxiRrxFlxW2CUoE7GhWr EIqpu16bO4iK2lCGJSESaowdzvfscCifSFIm5zJsB+k8PP56nBG0QBodo6/0HAbwnlUV aGGfc5W8HrYUTchG9tq38Y4F5l3DbyRPMBR3O4xpTQDYrhjEF+sMYS0p5deAA4DejxAi 7rNuvdKce3AyTewI3PH8a8l117iWYh9ZdhbnvsZNkLEYpeR2fTDqR8hE/8m4iHMEhHSX uVng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/UNhxDSHnBv7KasoGqlSIgR8N/+eP92s5GskeMMSIno=; b=fmcb5COK8WGTpoghgxUmoB/rvRzCetpLghZXG2+JniGbe972sR4qp+fP4X5ACIpIuP QI5pRZk2FgezN6TpdxQON52MJzRlH5k/6GvhJtjBSSz7DVTx96MytzsAwfVIIwY8KO4r W/eG8Uh10mt5D9lJPk+Fm6JuQ5ogOH2uvXcxTPgxk399eFuLwhsM0i/6xqZBd2RGZA7S i6aLgHyyzJcHf1MDRkBbJzSRbYZDE02/uOARPBvLzRE4qe5KKRIBdzeR+rFtoCz2QTos qeMXNlNHbUswVifOyTg6h6djMkkiAmg97pj6AWzLC3P2MO5lZJmHw3oDzsVttJEpyS0c tYqA== X-Gm-Message-State: AFqh2kp8HEf6Gww5AYI7korJt6YN4QKiVXMh/UcbOaXciOC9EnE54jFd R6/0sb/dZhrsxOmo1N04XYM= X-Google-Smtp-Source: AMrXdXvaJWfXeiFUT/GZAIuSyhfEAANL0dmMiLLbQakZgfaAauFEhlxdMC7q+DzEA4RnEZMFILQ0FA== X-Received: by 2002:a05:600c:d1:b0:3d3:4d21:704d with SMTP id u17-20020a05600c00d100b003d34d21704dmr12837213wmm.14.1672059312258; Mon, 26 Dec 2022 04:55:12 -0800 (PST) Received: from localhost.localdomain ([94.73.32.212]) by smtp.gmail.com with ESMTPSA id y24-20020a05600c365800b003cf894dbc4fsm13684497wmq.25.2022.12.26.04.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 04:55:12 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= Subject: [PATCH 5/6] HID: uclogic: Add support for XP-PEN Deco Pro SW Date: Mon, 26 Dec 2022 13:54:53 +0100 Message-Id: <20221226125454.16106-6-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221226125454.16106-1-jose.exposito89@gmail.com> References: <20221226125454.16106-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The XP-PEN Deco Pro SW is a UGEE v2 device with a frame with 8 buttons, a bitmap dial and a mouse; however, the UCLOGIC_MOUSE_FRAME_QUIRK is required because it reports an incorrect frame type. Its pen has 2 buttons, supports tilt and pressure. It can be connected using a USB cable or, to use it in wireless mode, using a USB Bluetooth dongle. When it is connected in wireless mode the device battery is used to power it. All the pieces to support it are already in place. Add its ID and quirks in order to support the device. Signed-off-by: José Expósito --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-input.c | 2 ++ drivers/hid/hid-uclogic-core.c | 3 +++ drivers/hid/hid-uclogic-params.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 82713ef3aaa6..d8a8028761ed 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1297,6 +1297,7 @@ #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01 0x0042 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L 0x0935 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_S 0x0909 +#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW 0x0933 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06 0x0078 #define USB_DEVICE_ID_UGEE_TABLET_G5 0x0074 #define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071 diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 9b59e436df0a..c4d9a95774cc 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -376,6 +376,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L), HID_BATTERY_QUIRK_AVOID_QUERY }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW), + HID_BATTERY_QUIRK_AVOID_QUERY }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15), HID_BATTERY_QUIRK_IGNORE }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100), diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 9ddb17ad0d04..cfef6f9af62d 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -542,6 +542,9 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_S) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW), + .driver_data = UCLOGIC_MOUSE_FRAME_QUIRK | UCLOGIC_BATTERY_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06) }, { } diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 86702c994c57..39a9259aa447 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1767,6 +1767,8 @@ int uclogic_params_init(struct uclogic_params *params, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L): case VID_PID(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_S): + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW): rc = uclogic_params_ugee_v2_init(&p, hdev); if (rc != 0) goto cleanup; From patchwork Mon Dec 26 12:54:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 636909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C866EC3DA7D for ; Mon, 26 Dec 2022 12:55:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbiLZMz0 (ORCPT ); Mon, 26 Dec 2022 07:55:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbiLZMzP (ORCPT ); Mon, 26 Dec 2022 07:55:15 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B762B61; Mon, 26 Dec 2022 04:55:14 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id p1-20020a05600c1d8100b003d8c9b191e0so7460040wms.4; Mon, 26 Dec 2022 04:55:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Eus7P8yeikk4wwlMHasaNl/bqp6teGVXQaOvLono3cc=; b=cFkqhRsdx4Ct059TDURmokgku6aJS+e9/6oDHYqnaqpdXyrmB/CL0ae+XD+1e7+E0G 5aiBlsveIM7L8iobuciqo+YSiaguuXbBrjRoSz06yeDvj/aQX9/YFXo6Jo8SzYDkMex9 FMKWrfiDYT4Sl5iUq2y9gS8uaIp3y8J+pdVOcTPivrLLddnZS0ypMRw/vnjsOO7JCC/L GX4PjD4a8xILmW6Yw2iWmi8dXwtsebx2U7tNOWb/5JlzqiT42SYdqsXzT9xDGqrpOYJf /GNGGoHriUFbVCyqQs+P8fobOye05F/qj8gkemQc4+RMULAdinDxZjl0jFTgC+FQsSyv xmyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Eus7P8yeikk4wwlMHasaNl/bqp6teGVXQaOvLono3cc=; b=WpKDSCqfbZs+COTfWnI0ODtFgTP7Qa2XYh7ZUc4hmzB/w3fPh6WE2Civ87kdZuNznM CrHXRWPUIwuMRzqhRGQpd0voPuJBGGcKLRwhOBB2J1C+bFCabCwdv6pDsUG4Q0fz70gy E4RaP08vtJIZjuXjBEqDlZfcNy8Zf2NgkNz+zAMyDSTyJJqKzEPvlNElegtr1pZHy2lc gQq/kd1KOEOfsRlPKT76pTFHfsRXTeDt+RruGuKt3vOczRs2Zgxxizmvpf3KumHultLe 4qeyQrkR/bY9STSEv9F3oXgDaNbki1gY80sDfu89Ac/GBHdJEXvbyBouStP4N/mhaVsz zvlw== X-Gm-Message-State: AFqh2kr9DE2q817UQn15q1Dive5ovo43/4bFZ+XvxplC0f8iVOMJ4/1d dcmD2NI56pijsXl+e3zOQgg= X-Google-Smtp-Source: AMrXdXvQrkxNqV5g5d8M0FQEOciZElF8fYHwEn93imuugUf2VMe/qM6luMaAiyJTtN8DHdQOrVxEDA== X-Received: by 2002:a05:600c:4fcf:b0:3cf:68f8:790b with SMTP id o15-20020a05600c4fcf00b003cf68f8790bmr13213891wmq.11.1672059313074; Mon, 26 Dec 2022 04:55:13 -0800 (PST) Received: from localhost.localdomain ([94.73.32.212]) by smtp.gmail.com with ESMTPSA id y24-20020a05600c365800b003cf894dbc4fsm13684497wmq.25.2022.12.26.04.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 04:55:12 -0800 (PST) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= , Andreas Grosse Subject: [PATCH 6/6] HID: uclogic: Add support for XP-PEN Deco Pro MW Date: Mon, 26 Dec 2022 13:54:54 +0100 Message-Id: <20221226125454.16106-7-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221226125454.16106-1-jose.exposito89@gmail.com> References: <20221226125454.16106-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The XP-PEN Deco Pro MW is a UGEE v2 device with a frame with 8 buttons, a bitmap dial and a mouse. Its pen has 2 buttons, supports tilt and pressure. It can be connected using a USB cable or, to use it in wireless mode, using a USB Bluetooth dongle. When it is connected in wireless mode the device battery is used to power it. All the pieces to support it are already in place. Add its ID and quirks in order to support the device. Link: https://github.com/DIGImend/digimend-kernel-drivers/issues/622 Tested-by: Andreas Grosse Signed-off-by: José Expósito --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-input.c | 2 ++ drivers/hid/hid-uclogic-core.c | 3 +++ drivers/hid/hid-uclogic-params.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index d8a8028761ed..5df7f4e4d610 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1296,6 +1296,7 @@ #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640 0x0094 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01 0x0042 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L 0x0935 +#define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_MW 0x0934 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_S 0x0909 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW 0x0933 #define USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06 0x0078 diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index c4d9a95774cc..4f6596febedf 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -376,6 +376,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L), HID_BATTERY_QUIRK_AVOID_QUERY }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_MW), + HID_BATTERY_QUIRK_AVOID_QUERY }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW), HID_BATTERY_QUIRK_AVOID_QUERY }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15), diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index cfef6f9af62d..a31e06b38a67 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -540,6 +540,9 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_MW), + .driver_data = UCLOGIC_MOUSE_FRAME_QUIRK | UCLOGIC_BATTERY_QUIRK }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_S) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 39a9259aa447..7fdb87a2714b 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1765,6 +1765,8 @@ int uclogic_params_init(struct uclogic_params *params, USB_DEVICE_ID_UGEE_PARBLO_A610_PRO): case VID_PID(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L): + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_MW): case VID_PID(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_S): case VID_PID(USB_VENDOR_ID_UGEE,