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: 36609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp892741wrt; Mon, 26 Dec 2022 04:55:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXszY/6BqCvqlx9foS3e/Oe86+M9EWw0sqyLCjRexA6M3pIkfihJVCu7FixlTAUtvViLRwnc X-Received: by 2002:a17:90a:ba84:b0:225:df28:fecf with SMTP id t4-20020a17090aba8400b00225df28fecfmr6623341pjr.13.1672059335286; Mon, 26 Dec 2022 04:55:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672059335; cv=none; d=google.com; s=arc-20160816; b=CTsB6205mILg5Sc+M7Z61GZOyG69srOwtMw9wtUUdVN4FwK+lT1wtuOTXqkKLMV7nS YCPt73stavIh6GEOvUQ+wGrI24EO6vAqBAHhKwZq10pmcbj20Y72KpEWrxOMZ9VbB2is 0NOToG9V87QfbY89iixeXZ9/8nSIxwC9QW+6cRYvq8VocbGvO6NRHR84AUg6pt1gt8Or /jUpHWMDZdy59chVbH/NnXm4eFado+Nt43OolB3FC7aoaztHLdrCimquKh2dY/RYQNTQ melmflNnTkpWb1/mtuzyqLtpvHouM7hgOKr5naiWaq2nIkWBK6ZqJmrxjhQ/CXwc68Ip EFbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CgO7IbDqgEqOBYZvNEQA1RHViZvpw8XhwXsdAZWfOVg=; b=AbgK+btnhsTQ8x6EAJDlUzZ01vs7OovYoJ+8KtXn+/6jVhYCCUZB+SqRfSodl4zS7A Gfbh5e3ypLSgrM8Wo4wVJvggS0Ja9PwLS5gWksnLRWzE9gQ4oY8wYz8UNE6yEbLuduaf kDHeTrTQByCT0mX3BehZUfcwKnkRQ7y6IHQBMFXQ26yqMN2/rGnBNRzGhdnPexHuKwp3 lfNU6U40QSztyj1MaopxzDSSwkHGy35yTXyOmEchXgm6PkV5poOf8xtaUhi5F8Jn+Cy7 /7FUHp5YM1SnV23A6J5nX+DM+0hktoy3SzPM6MNBkkm/XiUjg25KcpgRy7zs6oOnjBEA rT5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=miMOIpfN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a17090a7c4100b00218ed5d3fc5si14536561pjl.35.2022.12.26.04.55.23; Mon, 26 Dec 2022 04:55:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=miMOIpfN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232069AbiLZMzO (ORCPT + 99 others); Mon, 26 Dec 2022 07:55:14 -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-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 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753281289897162138?= X-GMAIL-MSGID: =?utf-8?q?1753281289897162138?= 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);