From patchwork Sun May 8 16:01:40 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: 12842473 X-Patchwork-Delegate: jikos@jikos.cz 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 CD452C433F5 for ; Sun, 8 May 2022 16:02:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235082AbiEHQFz (ORCPT ); Sun, 8 May 2022 12:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235100AbiEHQFx (ORCPT ); Sun, 8 May 2022 12:05:53 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA83E0AB; Sun, 8 May 2022 09:02:02 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id t6so16373049wra.4; Sun, 08 May 2022 09:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=obMuOVNFX3S99S3WxC9zwRJp/87FhNQ1mA/toWw3QGk=; b=Ki687qiWDjABIUssvbUHjJB+YIvM192T9ZnKgj9Hd6G5VhranaFPD+ewFeGb4p9G+0 OuIxuakVtEFN8LrgVkhs+gxBUwK6pTtontmdb1JCXVEzRYlEeySHMfFB37/M5rBSfumh 4blVJmwHN4U2mMamZXz8l1nFGCOLrS/YHzoz0xVzwLG3jR9k4oMQis6ALFMAEV7G+zb1 PDV8r0Vl1IyCTVqXvCWnqcCSDpQxSZiJAS8LbAuA95cO/GC9C7jihODDhioNFNQQAo34 GZDR51VEQ1fPQr50bfxe468eC6fyqHkBwL05h/TH1xeLiX9c7SQeWsB3PA8aDcskO3oH ilGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=obMuOVNFX3S99S3WxC9zwRJp/87FhNQ1mA/toWw3QGk=; b=xzbPF9Giy8uNaG0Z/LHD6KH60yXROJ/ztWOSW/Zivsq3nMuHBVQt/11/rsycVCTeCj uRC/jCZ4ysy3RiunjRZxazcqNUdmCmaBvbQNnaIT5EZQUhX+hEghTWGkL4DECGdGDDg5 6m6xPGUgyeWiY4nROIho5gllCgzPI5MCrsnlo2dRqFC/tjQHWEQRzXn7/XdXXYPqqRA1 vsxKtNwA5/SlANFaC27pfvm9KgyHyYn6KWPxyJ699CBhO04BgHuF31ngND3jv45yQqD9 XijDolBMF+36rC3aQphD8mGgB8ChtjaYweXigxmwrLPAXTooXgA4G36PbGWcbfQQ8n8G GuEg== X-Gm-Message-State: AOAM5311NZK8e/BjwXVqhgAnp3LHxA8bjUnlQprunqTiCfv9glnX9b0r PL8JMxH2t2XK5UoUN3gl1aA= X-Google-Smtp-Source: ABdhPJxqf7DBXlp4e1T5RVxciKZO91ox2R3Rwc1Z7DOmm7v8Shs2YFJPVkNmWmxKtivs1AF7pSbZXw== X-Received: by 2002:adf:f84b:0:b0:20a:ece0:905e with SMTP id d11-20020adff84b000000b0020aece0905emr10433971wrq.323.1652025721597; Sun, 08 May 2022 09:02:01 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id b15-20020a7bc24f000000b003942a244ecfsm10101925wmj.20.2022.05.08.09.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 09:02:01 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stefanberzl@gmail.com, albertofanjul@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH for-5.19/uclogic 1/7] HID: uclogic: Move param printing to a function Date: Sun, 8 May 2022 18:01:40 +0200 Message-Id: <20220508160146.13004-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508160146.13004-1-jose.exposito89@gmail.com> References: <20220508160146.13004-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Move parameter printing from a format string/argument list to a function to allow printing the full parameters, which now wouldn't fit into a single print call. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/hid/hid-uclogic-core.c | 4 +- drivers/hid/hid-uclogic-params.c | 89 +++++++++++++++++++++++- drivers/hid/hid-uclogic-params.h | 116 ++----------------------------- 3 files changed, 93 insertions(+), 116 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 8ef3d1830052..8cac5944e63f 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -209,8 +209,8 @@ static int uclogic_probe(struct hid_device *hdev, goto failure; } params_initialized = true; - hid_dbg(hdev, "parameters:\n" UCLOGIC_PARAMS_FMT_STR, - UCLOGIC_PARAMS_FMT_ARGS(&drvdata->params)); + hid_dbg(hdev, "parameters:\n"); + uclogic_params_hid_dbg(hdev, &drvdata->params); if (drvdata->params.invalid) { hid_info(hdev, "interface is invalid, ignoring\n"); rc = -ENODEV; diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 22f9c4f9da8a..1d9168cc7dc0 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -29,8 +29,8 @@ * 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) +static const char *uclogic_params_pen_inrange_to_str( + enum uclogic_params_pen_inrange inrange) { switch (inrange) { case UCLOGIC_PARAMS_PEN_INRANGE_NORMAL: @@ -44,6 +44,91 @@ const char *uclogic_params_pen_inrange_to_str( } } +/** + * Dump tablet interface pen parameters with hid_dbg(), indented with one tab. + * + * @hdev: The HID device the pen parameters describe. + * @pen: The pen parameters to dump. + */ +static void uclogic_params_pen_hid_dbg(const struct hid_device *hdev, + const struct uclogic_params_pen *pen) +{ + size_t i; + + hid_dbg(hdev, "\t.usage_invalid = %s\n", + (pen->usage_invalid ? "true" : "false")); + hid_dbg(hdev, "\t.desc_ptr = %p\n", pen->desc_ptr); + hid_dbg(hdev, "\t.desc_size = %u\n", pen->desc_size); + hid_dbg(hdev, "\t.id = %u\n", pen->id); + hid_dbg(hdev, "\t.subreport_list = {\n"); + for (i = 0; i < ARRAY_SIZE(pen->subreport_list); i++) { + hid_dbg(hdev, "\t\t{0x%02hhx, %hhu}%s\n", + pen->subreport_list[i].value, + pen->subreport_list[i].id, + i < (ARRAY_SIZE(pen->subreport_list) - 1) ? "," : ""); + } + hid_dbg(hdev, "\t}\n"); + hid_dbg(hdev, "\t.inrange = %s\n", + uclogic_params_pen_inrange_to_str(pen->inrange)); + hid_dbg(hdev, "\t.fragmented_hires = %s\n", + (pen->fragmented_hires ? "true" : "false")); + hid_dbg(hdev, "\t.tilt_y_flipped = %s\n", + (pen->tilt_y_flipped ? "true" : "false")); +} + +/** + * Dump tablet interface frame parameters with hid_dbg(), indented with two + * tabs. + * + * @hdev: The HID device the pen parameters describe. + * @frame: The frame parameters to dump. + */ +static void uclogic_params_frame_hid_dbg( + const struct hid_device *hdev, + const struct uclogic_params_frame *frame) +{ + hid_dbg(hdev, "\t\t.desc_ptr = %p\n", frame->desc_ptr); + hid_dbg(hdev, "\t\t.desc_size = %u\n", frame->desc_size); + hid_dbg(hdev, "\t\t.id = %u\n", frame->id); + hid_dbg(hdev, "\t\t.suffix = %s\n", frame->suffix); + hid_dbg(hdev, "\t\t.re_lsb = %u\n", frame->re_lsb); + hid_dbg(hdev, "\t\t.dev_id_byte = %u\n", frame->dev_id_byte); + hid_dbg(hdev, "\t\t.touch_ring_byte = %u\n", frame->touch_ring_byte); + hid_dbg(hdev, "\t\t.touch_ring_max = %hhd\n", frame->touch_ring_max); + hid_dbg(hdev, "\t\t.touch_ring_flip_at = %hhd\n", + frame->touch_ring_flip_at); + hid_dbg(hdev, "\t\t.bitmap_dial_byte = %u\n", + frame->bitmap_dial_byte); +} + +/** + * Dump tablet interface parameters with hid_dbg(). + * + * @hdev: The HID device the parameters describe. + * @params: The parameters to dump. + */ +void uclogic_params_hid_dbg(const struct hid_device *hdev, + const struct uclogic_params *params) +{ + size_t i; + + hid_dbg(hdev, ".invalid = %s\n", + params->invalid ? "true" : "false"); + hid_dbg(hdev, ".desc_ptr = %p\n", params->desc_ptr); + hid_dbg(hdev, ".desc_size = %u\n", params->desc_size); + hid_dbg(hdev, ".pen = {\n"); + uclogic_params_pen_hid_dbg(hdev, ¶ms->pen); + hid_dbg(hdev, "\t}\n"); + hid_dbg(hdev, ".frame_list = {\n"); + for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) { + hid_dbg(hdev, "\t{\n"); + uclogic_params_frame_hid_dbg(hdev, ¶ms->frame_list[i]); + hid_dbg(hdev, "\t}%s\n", + i < (ARRAY_SIZE(params->frame_list) - 1) ? "," : ""); + } + hid_dbg(hdev, "}\n"); +} + /** * uclogic_params_get_str_desc - retrieve a string descriptor from a HID * device interface, putting it into a kmalloc-allocated buffer as is, without diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index fb2001018c46..c7573f70d35c 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -29,11 +29,6 @@ enum uclogic_params_pen_inrange { UCLOGIC_PARAMS_PEN_INRANGE_NONE, }; -/* 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); - - /* * Pen report's subreport data. */ @@ -213,113 +208,6 @@ struct uclogic_params { 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 = {\n" \ - "\t.usage_invalid = %s\n" \ - "\t.desc_ptr = %p\n" \ - "\t.desc_size = %u\n" \ - "\t.id = %u\n" \ - "\t.subreport_list = {\n" \ - "\t\t{0x%02hhx, %hhu},\n" \ - "\t\t{0x%02hhx, %hhu},\n" \ - "\t\t{0x%02hhx, %hhu},\n" \ - "\t}\n" \ - "\t.inrange = %s\n" \ - "\t.fragmented_hires = %s\n" \ - "\t.tilt_y_flipped = %s\n" \ - "}\n" \ - ".frame_list = {\n" \ - "\t{\n" \ - "\t\t.desc_ptr = %p\n" \ - "\t\t.desc_size = %u\n" \ - "\t\t.id = %u\n" \ - "\t\t.suffix = %s\n" \ - "\t\t.re_lsb = %u\n" \ - "\t\t.dev_id_byte = %u\n" \ - "\t\t.touch_ring_byte = %u\n" \ - "\t\t.touch_ring_max = %hhd\n" \ - "\t\t.touch_ring_flip_at = %hhd\n" \ - "\t\t.bitmap_dial_byte = %u\n" \ - "\t},\n" \ - "\t{\n" \ - "\t\t.desc_ptr = %p\n" \ - "\t\t.desc_size = %u\n" \ - "\t\t.id = %u\n" \ - "\t\t.suffix = %s\n" \ - "\t\t.re_lsb = %u\n" \ - "\t\t.dev_id_byte = %u\n" \ - "\t\t.touch_ring_byte = %u\n" \ - "\t\t.touch_ring_max = %hhd\n" \ - "\t\t.touch_ring_flip_at = %hhd\n" \ - "\t\t.bitmap_dial_byte = %u\n" \ - "\t},\n" \ - "\t{\n" \ - "\t\t.desc_ptr = %p\n" \ - "\t\t.desc_size = %u\n" \ - "\t\t.id = %u\n" \ - "\t\t.suffix = %s\n" \ - "\t\t.re_lsb = %u\n" \ - "\t\t.dev_id_byte = %u\n" \ - "\t\t.touch_ring_byte = %u\n" \ - "\t\t.touch_ring_max = %hhd\n" \ - "\t\t.touch_ring_flip_at = %hhd\n" \ - "\t\t.bitmap_dial_byte = %u\n" \ - "\t},\n" \ - "}\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.usage_invalid ? "true" : "false"), \ - (_params)->pen.desc_ptr, \ - (_params)->pen.desc_size, \ - (_params)->pen.id, \ - (_params)->pen.subreport_list[0].value, \ - (_params)->pen.subreport_list[0].id, \ - (_params)->pen.subreport_list[1].value, \ - (_params)->pen.subreport_list[1].id, \ - (_params)->pen.subreport_list[2].value, \ - (_params)->pen.subreport_list[2].id, \ - uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \ - ((_params)->pen.fragmented_hires ? "true" : "false"), \ - ((_params)->pen.tilt_y_flipped ? "true" : "false"), \ - (_params)->frame_list[0].desc_ptr, \ - (_params)->frame_list[0].desc_size, \ - (_params)->frame_list[0].id, \ - (_params)->frame_list[0].suffix, \ - (_params)->frame_list[0].re_lsb, \ - (_params)->frame_list[0].dev_id_byte, \ - (_params)->frame_list[0].touch_ring_byte, \ - (_params)->frame_list[0].touch_ring_max, \ - (_params)->frame_list[0].touch_ring_flip_at, \ - (_params)->frame_list[0].bitmap_dial_byte, \ - (_params)->frame_list[1].desc_ptr, \ - (_params)->frame_list[1].desc_size, \ - (_params)->frame_list[1].id, \ - (_params)->frame_list[1].suffix, \ - (_params)->frame_list[1].re_lsb, \ - (_params)->frame_list[1].dev_id_byte, \ - (_params)->frame_list[1].touch_ring_byte, \ - (_params)->frame_list[1].touch_ring_max, \ - (_params)->frame_list[1].touch_ring_flip_at, \ - (_params)->frame_list[1].bitmap_dial_byte, \ - (_params)->frame_list[2].desc_ptr, \ - (_params)->frame_list[2].desc_size, \ - (_params)->frame_list[2].id, \ - (_params)->frame_list[2].suffix, \ - (_params)->frame_list[2].re_lsb, \ - (_params)->frame_list[2].dev_id_byte, \ - (_params)->frame_list[2].touch_ring_byte, \ - (_params)->frame_list[2].touch_ring_max, \ - (_params)->frame_list[2].touch_ring_flip_at, \ - (_params)->frame_list[2].bitmap_dial_byte - /* Get a replacement report descriptor for a tablet's interface. */ extern int uclogic_params_get_desc(const struct uclogic_params *params, __u8 **pdesc, @@ -328,4 +216,8 @@ extern int uclogic_params_get_desc(const struct uclogic_params *params, /* Free resources used by tablet interface's parameters */ extern void uclogic_params_cleanup(struct uclogic_params *params); +/* Dump tablet interface parameters with hid_dbg() */ +extern void uclogic_params_hid_dbg(const struct hid_device *hdev, + const struct uclogic_params *params); + #endif /* _HID_UCLOGIC_PARAMS_H */ From patchwork Sun May 8 16:01:41 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: 12842474 X-Patchwork-Delegate: jikos@jikos.cz 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 F2DE1C433EF for ; Sun, 8 May 2022 16:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235143AbiEHQGB (ORCPT ); Sun, 8 May 2022 12:06:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235125AbiEHQGA (ORCPT ); Sun, 8 May 2022 12:06:00 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67EEBE0AB; Sun, 8 May 2022 09:02:09 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id c190-20020a1c35c7000000b0038e37907b5bso9536874wma.0; Sun, 08 May 2022 09:02:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iQ5H4sLozkU3O3cWJmRiI8k+gjfx6qXpAt/d+asdCMs=; b=YPgN+yyyvt1aDQ1rBRo8bbtTkrLPifdqNe0K7GrPwL7SJCGAvRrZj2M4Ho6QBIX0rV 3gDqBoAozDvenRULyVyHgf6ZtM1yWyO3fnY+57Xv/JL+Y55xfDkFHmVOSt2sWh4vLj6Y 9NL6XukvGtJj6QrL2uPVkqY5MeO8MxHuneZCxtcWSHMgJPDo3kgzagomNqiqcoh3dtkB LjgzX0zv2ry0f+1uubt/NLyJGr54Mowc8EayRsKHhkY3U5zOjiw3h/o06lPMU0jGmZHs uOaT0v4iocZYJpKB2dmkw2aJX8OAnr7r12SY2ZCEdgrQI4uJvgUEOWyFdJsZ87ynnLyf 0QXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iQ5H4sLozkU3O3cWJmRiI8k+gjfx6qXpAt/d+asdCMs=; b=oQEObEHQgz+cZOObmH9xE6CO1UhdYLxHNMm1BaIznqd4042RWNogySsWd2HDd6OQjJ mDY3XTYmww8iTdjYjNMSgEzZoFKaS8h1JpviId8zTdxPSNms3FAp1N/ClI55Rdvanp/G m3H41Uc9cWhB9B63KrsiYbrwr0mLrYn5svVuTFGPrDQlYsWuihyZ14aK5CiGY+iUlKss +4r1XRLRJ8TpIodgM5K/ABJ28QpQ7GowP9o4KcyFZlq6IBbuoAS2tw/xttOiidRK0Wv1 PtXBp9e9rchBBdBReFtnju2IQ6YasnFHUoC5SmQN5k3l0tHlzkUDIwZ3TfXaw6PL+ZPR JSxQ== X-Gm-Message-State: AOAM531pSqMTrPV1S71lF5evi6iKmKKtsGbsspizLa9W3ssHtQax8+Jm l7SFaHbNmKQvrapyewPSGCA= X-Google-Smtp-Source: ABdhPJzuqn9ii1MAMBpKEFEj/vlmMQ3yDK7Ft6DM+GF5L697J/QP1LKolxvbUMq2wPDl3m802VddPg== X-Received: by 2002:a05:600c:3490:b0:394:5616:ac78 with SMTP id a16-20020a05600c349000b003945616ac78mr12426181wmq.80.1652025727841; Sun, 08 May 2022 09:02:07 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id b15-20020a7bc24f000000b003942a244ecfsm10101925wmj.20.2022.05.08.09.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 09:02:07 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stefanberzl@gmail.com, albertofanjul@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH for-5.19/uclogic 2/7] HID: uclogic: Return raw parameters from v2 pen init Date: Sun, 8 May 2022 18:01:41 +0200 Message-Id: <20220508160146.13004-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508160146.13004-1-jose.exposito89@gmail.com> References: <20220508160146.13004-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Return the raw parameters buffer from uclogic_params_pen_init_v2(), if requested, as a way to identify the tablet. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 92 ++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 34 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 1d9168cc7dc0..91379d7cd33e 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -338,28 +338,45 @@ static s32 uclogic_params_get_le24(const void *p) * 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. + * @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. + * @pparams_ptr: Location for a kmalloc'ed pointer to the retrieved raw + * parameters, which could be used to identify the tablet + * to some extent. Should be freed with kfree after use. + * NULL, if not needed. Not modified in case of error. + * Only set if *pfound is set to true. + * @pparams_len: Location for the length of the retrieved raw + * parameters. NULL, if not needed. Not modified in case + * of error. Only set if *pfound is set to true. + * @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, + __u8 **pparams_ptr, + size_t *pparams_len, struct hid_device *hdev) { int rc; bool found = false; - /* Buffer for (part of) the string descriptor */ + /* Buffer for (part of) the parameter string descriptor */ __u8 *buf = NULL; - /* Descriptor length required */ - const int len = 18; + /* Parameter string descriptor required length */ + const int params_len_min = 18; + /* Parameter string descriptor accepted length */ + const int params_len_max = 32; + /* Parameter string descriptor received length */ + int params_len; + size_t i; s32 resolution; /* Pen report descriptor template parameters */ s32 desc_params[UCLOGIC_RDESC_PEN_PH_ID_NUM]; @@ -377,7 +394,7 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen, * the Windows driver traffic. * NOTE: This enables fully-functional tablet mode. */ - rc = uclogic_params_get_str_desc(&buf, hdev, 200, len); + rc = uclogic_params_get_str_desc(&buf, hdev, 200, params_len_max); if (rc == -EPIPE) { hid_dbg(hdev, "string descriptor with pen parameters not found, assuming not compatible\n"); @@ -385,27 +402,28 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen, } else if (rc < 0) { hid_err(hdev, "failed retrieving pen parameters: %d\n", rc); goto cleanup; - } else if (rc != len) { + } else if (rc < params_len_min) { hid_dbg(hdev, - "string descriptor with pen parameters has invalid length (got %d, expected %d), assuming not compatible\n", - rc, len); + "string descriptor with pen parameters is too short (got %d, expected at least %d), assuming not compatible\n", + rc, params_len_min); + goto finish; + } + + params_len = rc; + + /* + * 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 < params_len && + (buf[i] >= 0x20 && buf[i] < 0x7f && buf[i + 1] == 0); + i += 2); + if (i >= params_len) { + hid_dbg(hdev, + "string descriptor with pen parameters seems to contain only text, assuming not compatible\n"); 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; - } } /* @@ -429,8 +447,6 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen, desc_params[UCLOGIC_RDESC_PEN_PH_ID_Y_LM] * 1000 / resolution; } - kfree(buf); - buf = NULL; /* * Generate pen report descriptor @@ -456,6 +472,13 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen, pen->fragmented_hires = true; pen->tilt_y_flipped = true; found = true; + if (pparams_ptr != NULL) { + *pparams_ptr = buf; + buf = NULL; + } + if (pparams_len != NULL) + *pparams_len = params_len; + finish: *pfound = found; rc = 0; @@ -828,7 +851,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params, "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); + rc = uclogic_params_pen_init_v2(&p.pen, &found, + NULL, NULL, hdev); if (rc != 0) { hid_err(hdev, "failed probing pen v2 parameters: %d\n", rc); From patchwork Sun May 8 16:01:42 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: 12842475 X-Patchwork-Delegate: jikos@jikos.cz 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 E9F78C433F5 for ; Sun, 8 May 2022 16:02:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235193AbiEHQGK (ORCPT ); Sun, 8 May 2022 12:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235125AbiEHQGG (ORCPT ); Sun, 8 May 2022 12:06:06 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 869DD11145; Sun, 8 May 2022 09:02:14 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id b19so16356008wrh.11; Sun, 08 May 2022 09:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T7s5fmBwP8rCs7pEtusXvi3U2iXj4JeLgqhsngdf67o=; b=Urc7uKiu9cfch99k9wn+hjQ7in3wJJOGDRJmr04x+bHSnlZyWnmkE5vkVlpFaJWXcQ inymFw9yJmhcjrmkufPl8xXhA9FntRt/mOZ1nBy5PD+/GQYtO4boolbdUSENjLWRG6Fo nqU4RLlNKQcQNYitlTJeENNAbtq0p8LWeoUOHQ7xu1lD6sCXvQxE/B2CdZ/aAUHT4Wf5 +TckcAw8MXdAZCPTRxaN6eX7mEAM/CTQDsmw1qCPh5bj67utr0q12KKfSXeGRzBufB3Q Axc4xY6N+bTrgZPqnBodc1E0s/G/4QUtvDfwUGx9JoHUJkG/IGNamH5Esid/toT+CkT3 HTqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T7s5fmBwP8rCs7pEtusXvi3U2iXj4JeLgqhsngdf67o=; b=5ltnVZFmOv/DELTIImRjryHAyPHetQLAmMVOpU4LkzWQw/wyhFnTmCxHwNViEgcRyG PR4d1riU9DpQOpYZg1zB3+8HhFJSNS5ETQ4QG8gJEjPHGidMwpRw+XYKhY8qj1uuD7pP fYTBoB5CGGbRTXLx0ed5zsqNiVNXbc0wKNysWWos5mbvB4o2/EG1ddLfFHzTHXNJEopL yCFKo4qeoOzEOX6mDVr7ufVNXH3Vnbs+2sGuVAGsi3GlcDXmaMOIh57iRWvZofBIkEOT 3/cqmsdG6u9rvZiXDudwpj+UreU8YQ23oI187/RtA7c1+hRGDXSKtVw8tLikwM7n0oHv o+fQ== X-Gm-Message-State: AOAM531jvaB565T7zPwz/6/m/Re7mBXj4OR5dlFMn5Rddje9nwEGUQBt Xm2uOxgA8eRfFaA0AcxWZTumCgDeL3E= X-Google-Smtp-Source: ABdhPJyNPuBqz8hfGfn1xyhVG/SvN8DkWQqkVUrnsh7MNwLb3UFLzq/xaimEyZLsvdE2IlrjR1akHA== X-Received: by 2002:a5d:598f:0:b0:20c:83c9:b05b with SMTP id n15-20020a5d598f000000b0020c83c9b05bmr10405766wri.343.1652025732899; Sun, 08 May 2022 09:02:12 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id b15-20020a7bc24f000000b003942a244ecfsm10101925wmj.20.2022.05.08.09.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 09:02:12 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stefanberzl@gmail.com, albertofanjul@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH for-5.19/uclogic 3/7] HID: uclogic: Do not focus on touch ring only Date: Sun, 8 May 2022 18:01:42 +0200 Message-Id: <20220508160146.13004-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508160146.13004-1-jose.exposito89@gmail.com> References: <20220508160146.13004-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Accommodate both touch ring and touch strip in naming throughout hid-uclogic by talking about abstract "touch" instead of "touch ring", wherever possible. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 20 +++++++++----------- drivers/hid/hid-uclogic-params.c | 20 ++++++++++---------- drivers/hid/hid-uclogic-params.h | 27 ++++++++++++++------------- drivers/hid/hid-uclogic-rdesc.c | 4 ++-- drivers/hid/hid-uclogic-rdesc.h | 8 ++++---- 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 8cac5944e63f..cc53625ed1f7 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -134,7 +134,7 @@ static int uclogic_input_configured(struct hid_device *hdev, * Disable EV_MSC reports for touch ring interfaces to * make the Wacom driver pickup touch ring extents */ - if (frame->touch_ring_byte > 0) + if (frame->touch_byte > 0) __clear_bit(EV_MSC, hi->input->evbit); } } @@ -351,9 +351,8 @@ static int uclogic_raw_event_frame( /* If need to, and can, set pad device ID for Wacom drivers */ if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) { /* If we also have a touch ring and the finger left it */ - if (frame->touch_ring_byte > 0 && - frame->touch_ring_byte < size && - data[frame->touch_ring_byte] == 0) { + if (frame->touch_byte > 0 && frame->touch_byte < size && + data[frame->touch_byte] == 0) { data[frame->dev_id_byte] = 0; } else { data[frame->dev_id_byte] = 0xf; @@ -387,16 +386,15 @@ static int uclogic_raw_event_frame( } /* If need to, and can, transform the touch ring reports */ - if (frame->touch_ring_byte > 0 && frame->touch_ring_byte < size && - frame->touch_ring_flip_at != 0) { - __s8 value = data[frame->touch_ring_byte]; - + if (frame->touch_byte > 0 && frame->touch_byte < size && + frame->touch_flip_at != 0) { + __s8 value = data[frame->touch_byte]; if (value != 0) { - value = frame->touch_ring_flip_at - value; + value = frame->touch_flip_at - value; if (value < 0) - value = frame->touch_ring_max + value; + value = frame->touch_max + value; - data[frame->touch_ring_byte] = value; + data[frame->touch_byte] = value; } } diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 91379d7cd33e..459f15288ccc 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -93,10 +93,10 @@ static void uclogic_params_frame_hid_dbg( hid_dbg(hdev, "\t\t.suffix = %s\n", frame->suffix); hid_dbg(hdev, "\t\t.re_lsb = %u\n", frame->re_lsb); hid_dbg(hdev, "\t\t.dev_id_byte = %u\n", frame->dev_id_byte); - hid_dbg(hdev, "\t\t.touch_ring_byte = %u\n", frame->touch_ring_byte); - hid_dbg(hdev, "\t\t.touch_ring_max = %hhd\n", frame->touch_ring_max); - hid_dbg(hdev, "\t\t.touch_ring_flip_at = %hhd\n", - frame->touch_ring_flip_at); + hid_dbg(hdev, "\t\t.touch_byte = %u\n", frame->touch_byte); + hid_dbg(hdev, "\t\t.touch_max = %hhd\n", frame->touch_max); + hid_dbg(hdev, "\t\t.touch_flip_at = %hhd\n", + frame->touch_flip_at); hid_dbg(hdev, "\t\t.bitmap_dial_byte = %u\n", frame->bitmap_dial_byte); } @@ -877,7 +877,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params, &p.frame_list[1], uclogic_rdesc_v2_frame_touch_ring_arr, uclogic_rdesc_v2_frame_touch_ring_size, - UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_ID); + UCLOGIC_RDESC_V2_FRAME_TOUCH_ID); if (rc != 0) { hid_err(hdev, "failed creating v2 frame touch ring parameters: %d\n", @@ -886,10 +886,10 @@ static int uclogic_params_huion_init(struct uclogic_params *params, } p.frame_list[1].suffix = "Touch Ring"; p.frame_list[1].dev_id_byte = - UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_DEV_ID_BYTE; - p.frame_list[1].touch_ring_byte = 5; - p.frame_list[1].touch_ring_max = 12; - p.frame_list[1].touch_ring_flip_at = 6; + UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE; + p.frame_list[1].touch_byte = 5; + p.frame_list[1].touch_max = 12; + p.frame_list[1].touch_flip_at = 6; /* Create v2 frame dial parameters */ rc = uclogic_params_frame_init_with_desc( @@ -917,7 +917,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params, UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID; p.pen.subreport_list[1].value = 0xf0; p.pen.subreport_list[1].id = - UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_ID; + UCLOGIC_RDESC_V2_FRAME_TOUCH_ID; p.pen.subreport_list[2].value = 0xf1; p.pen.subreport_list[2].id = UCLOGIC_RDESC_V2_FRAME_DIAL_ID; diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index c7573f70d35c..5bef8daaa607 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -128,31 +128,32 @@ struct uclogic_params_frame { * 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. The ID byte will be set - * to zero whenever the byte pointed by "touch_ring_byte" is zero, if + * to zero whenever the byte pointed by "touch_byte" is zero, if * the latter is valid. Only valid if "id" is not zero. */ unsigned int dev_id_byte; /* - * Offset of the touch ring state byte, in the report. + * Offset of the touch ring/strip state byte, in the report. * Zero if not present. If dev_id_byte is also valid and non-zero, * then the device ID byte will be cleared when the byte pointed to by * this offset is zero. Only valid if "id" is not zero. */ - unsigned int touch_ring_byte; - - /* - * Maximum value of the touch ring report. - * The minimum valid value is considered to be one, - * with zero being out-of-proximity (finger lift) value. - */ - __s8 touch_ring_max; - + unsigned int touch_byte; /* - * The value to anchor the reversed reports at. + * The value to anchor the reversed touch ring/strip reports at. * I.e. one, if the reports should be flipped without offset. * Zero if no reversal should be done. + * Only valid if "touch_byte" is valid and not zero. + */ + __s8 touch_flip_at; + /* + * Maximum value of the touch ring/strip report around which the value + * should be wrapped when flipping according to "touch_flip_at". + * The minimum valid value is considered to be one, with zero being + * out-of-proximity (finger lift) value. + * Only valid if "touch_flip_at" is valid and not zero. */ - __s8 touch_ring_flip_at; + __s8 touch_max; /* * Offset of the bitmap dial byte, in the report. Zero if not present. * Only valid if "id" is not zero. A bitmap dial sends reports with a diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index dd792160fe7e..e2bd3a91e6fd 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -718,8 +718,8 @@ const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[] = { 0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x07, /* Usage (Keypad), */ 0xA1, 0x01, /* Collection (Application), */ - 0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_ID, - /* Report ID (DIAL_ID), */ + 0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_ID, + /* Report ID (TOUCH_ID), */ 0x14, /* Logical Minimum (0), */ 0x05, 0x0D, /* Usage Page (Digitizer), */ 0x09, 0x39, /* Usage (Tablet Function Keys), */ diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index 2ab6b7d5f5af..b7bbaa70261e 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -131,15 +131,15 @@ extern const size_t uclogic_rdesc_v1_frame_size; extern const __u8 uclogic_rdesc_v2_frame_buttons_arr[]; extern const size_t uclogic_rdesc_v2_frame_buttons_size; -/* Report ID for tweaked v2 frame touch ring reports */ -#define UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_ID 0xf8 +/* Report ID for tweaked v2 frame touch ring/strip reports */ +#define UCLOGIC_RDESC_V2_FRAME_TOUCH_ID 0xf8 /* Fixed report descriptor for (tweaked) v2 frame touch ring reports */ extern const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[]; extern const size_t uclogic_rdesc_v2_frame_touch_ring_size; -/* Device ID byte offset in v2 frame touch ring reports */ -#define UCLOGIC_RDESC_V2_FRAME_TOUCH_RING_DEV_ID_BYTE 0x4 +/* Device ID byte offset in v2 frame touch ring/strip reports */ +#define UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE 0x4 /* Report ID for tweaked v2 frame dial reports */ #define UCLOGIC_RDESC_V2_FRAME_DIAL_ID 0xf9 From patchwork Sun May 8 16:01:43 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: 12842478 X-Patchwork-Delegate: jikos@jikos.cz 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 31C5CC433F5 for ; Sun, 8 May 2022 16:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235125AbiEHQGN (ORCPT ); Sun, 8 May 2022 12:06:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235171AbiEHQGJ (ORCPT ); Sun, 8 May 2022 12:06:09 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6027101CF; Sun, 8 May 2022 09:02:17 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id k2so16356514wrd.5; Sun, 08 May 2022 09:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2y3LCh0oX8KUwg7+Vl+Q7bdw1QHYwjY+0MMTIBBHFTM=; b=LLX6arJrsbU5eZTfLW24DKsL5gOBGjHbXSQa47ZJ2eCHZtlZ3LcV+e7mTt+hYlDvrx UVZFnhPov+1zPKFCKE5fIuhsPcS424o/LTg497T+2RL/w3ssd48XZmfXgQtCjXzUicUt +gGa16+GpCjNtRI0+eUEARHxSdcEzIbjNNDrtu8qaN/VdKNlfg3saaRsgGkCN/PlrHAi eeLGZ3gTW56vxBtAd6r8TOP3TUoqazhzkBSRFVttHqDiNN2MJ7v4Tdk9yV7pnKVB/bYU Y2OxEJD1Ln6/bL67ZN+mcU24YBmhvK4WUgye+BYBaflEtp6KDNPmu8Eksce6bh1u/rpl 3d+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2y3LCh0oX8KUwg7+Vl+Q7bdw1QHYwjY+0MMTIBBHFTM=; b=T4ql0tfZ//ikpO4tFd3n+YbVih01jrtPN7m0QocGEIuhvjiKHZ9kSGe6spiS+n+4Ml TYqmThqigb776RqmiDA3GFtK+toB3WhDtKE/KsKihcI7p9r4ORTwMKjvGdEybj7sf+BI 4WOgdsXc7fvUJx/XSEIdqNP2HsfRf+Z0R+k0PpY3+w45rKP4Bswo/Xw6BzNy9vTPDCwr Q1xRXyXj+myEJAm2wFbW3LUVkz8zCOxnmtkFK5ZZ/IyJI0kFIfS+PANbcjWhuYZKK14g DS/dW5jlK6Ab4bHgdvLtB07+RQzqHvUwFxjf/4qU79T5QJzJ9kmxeuy3V1ATzTPdNBjM VzHQ== X-Gm-Message-State: AOAM533UvKqGuedJwuSg6vUxhRf7l0KYeLZHmerRnaYl83ijOPBb6JOw /eENYbNj4/1JjT6eAfsqQY8= X-Google-Smtp-Source: ABdhPJy7AywzsZHP6NrH4mCLtxsynVY9tMzipWWeYqQMKXl2mW42cBlSpc7Z07DIh33SjnZo44mzGg== X-Received: by 2002:a5d:47ca:0:b0:20c:72c9:d3be with SMTP id o10-20020a5d47ca000000b0020c72c9d3bemr10300446wrc.114.1652025736200; Sun, 08 May 2022 09:02:16 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id b15-20020a7bc24f000000b003942a244ecfsm10101925wmj.20.2022.05.08.09.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 09:02:15 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stefanberzl@gmail.com, albertofanjul@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH for-5.19/uclogic 4/7] HID: uclogic: Always shift touch reports to zero Date: Sun, 8 May 2022 18:01:43 +0200 Message-Id: <20220508160146.13004-5-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508160146.13004-1-jose.exposito89@gmail.com> References: <20220508160146.13004-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Always decrement touch report values to have the range start with zero, regardless if flipped or not. This fixes the future non-flipped touch strip reports. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 15 ++++++++------- drivers/hid/hid-uclogic-params.c | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index cc53625ed1f7..c4ab94d58a0f 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -386,15 +386,16 @@ static int uclogic_raw_event_frame( } /* If need to, and can, transform the touch ring reports */ - if (frame->touch_byte > 0 && frame->touch_byte < size && - frame->touch_flip_at != 0) { + if (frame->touch_byte > 0 && frame->touch_byte < size) { __s8 value = data[frame->touch_byte]; - if (value != 0) { - value = frame->touch_flip_at - value; - if (value < 0) - value = frame->touch_max + value; - data[frame->touch_byte] = value; + if (value != 0) { + if (frame->touch_flip_at != 0) { + value = frame->touch_flip_at - value; + if (value <= 0) + value = frame->touch_max + value; + } + data[frame->touch_byte] = value - 1; } } diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 459f15288ccc..163efd026881 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -889,7 +889,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params, UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE; p.frame_list[1].touch_byte = 5; p.frame_list[1].touch_max = 12; - p.frame_list[1].touch_flip_at = 6; + p.frame_list[1].touch_flip_at = 7; /* Create v2 frame dial parameters */ rc = uclogic_params_frame_init_with_desc( From patchwork Sun May 8 16:01:44 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: 12842476 X-Patchwork-Delegate: jikos@jikos.cz 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 74899C433EF for ; Sun, 8 May 2022 16:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235176AbiEHQGL (ORCPT ); Sun, 8 May 2022 12:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235136AbiEHQGK (ORCPT ); Sun, 8 May 2022 12:06:10 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93CA7101DA; Sun, 8 May 2022 09:02:19 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id x18so16396607wrc.0; Sun, 08 May 2022 09:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BCAIUMXgOaQUy6jpGQ8Il3QqIm6Z+Gcea7ZCrGiHJkM=; b=lWiOfBzbnx08jhBiqDcYJyjOLsrMUrXL/rvkOrKqPsTq0TMXPqTl7q6lc9Qvl9Mcl2 H4pAB+DhqHggJlfPfuigFajXLyayfA+Vfa0VIhZIC/q1/DpyOgbZIoMyaZ9C5NcHS5hg LdrUFN39fdYfMICzHetCz2yxcB5Pi+OfLzmB14i4/9MV/VG+/qljUP4vowca+lulHVNi bYlYle7hsA+CHdrlgTzpA2O9IdbRRAnasYUcAX92EyAUMnKn0ozkdV9ZgOb8MrAKGZuh mwLkUdEMcLuoVxp/rXuYWY88qAClQ5iXKzzbLa/ksnQrsKiXlNu7+LLSfKBvZnq020Sc p2sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BCAIUMXgOaQUy6jpGQ8Il3QqIm6Z+Gcea7ZCrGiHJkM=; b=h1H7zLWnmC/pmg869CLBlJbBXXrhGmGYiXTUu9tUZHzUyRt4EKfzQbhFDsl2m+B1G+ LfL53RwfbRVYQj6jgp1wYdLHp1w8KQbEBM2Fn20RSG5bIOH89f7Bz4Rpz6yClc6kMeOn LH6g2aAsfI/efTLqPCK06EdhVVYAQ1G9vzQk4tAVKCd+S0vfGwk4E6goVLjkpxlPg4eR Xb4Qq7M4sCodI1XIZNOrFdxS28fWgho91ed913H60FwD1a6I6o8dEW1+g+3022McsrPH Lab6P8G0ewJDFIruKWoEijYdbgafE4fSi3IBU1ImI91niPJIbaTB4yvlwuQIHXpchEeq AI3g== X-Gm-Message-State: AOAM531p3z9ZZBXQTYR3uNwJYGnr98Q53/1XI9ODtSLWCvNqgtuyDaLR ZIDGRmPWxF9ww+SujOLg8yh61RBV+IY= X-Google-Smtp-Source: ABdhPJx32yXO38pW0xwFC677hk29JQs+e9DziGmFVecgcmPKXdIhPXuAYjQgdD+PD8s3RNwbQQGF/g== X-Received: by 2002:a05:6000:1f03:b0:20c:4d9e:7400 with SMTP id bv3-20020a0560001f0300b0020c4d9e7400mr10532054wrb.257.1652025737915; Sun, 08 May 2022 09:02:17 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id b15-20020a7bc24f000000b003942a244ecfsm10101925wmj.20.2022.05.08.09.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 09:02:17 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stefanberzl@gmail.com, albertofanjul@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH for-5.19/uclogic 5/7] HID: uclogic: Differentiate touch ring and touch strip Date: Sun, 8 May 2022 18:01:44 +0200 Message-Id: <20220508160146.13004-6-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508160146.13004-1-jose.exposito89@gmail.com> References: <20220508160146.13004-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Improve support for touch strips. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 84 +++++++++++++++++++++++--------- drivers/hid/hid-uclogic-rdesc.c | 48 ++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.h | 4 ++ 3 files changed, 112 insertions(+), 24 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 163efd026881..7db63bb77158 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -808,6 +808,14 @@ static int uclogic_params_huion_init(struct uclogic_params *params, static const char transition_ver[] = "HUION_T153_160607"; char *ver_ptr = NULL; const size_t ver_len = sizeof(transition_ver) + 1; + __u8 *params_ptr = NULL; + size_t params_len = 0; + /* Parameters string descriptor of a model with touch ring (HS610) */ + const __u8 touch_ring_model_params_buf[] = { + 0x13, 0x03, 0x70, 0xC6, 0x00, 0x06, 0x7C, 0x00, + 0xFF, 0x1F, 0xD8, 0x13, 0x03, 0x0D, 0x10, 0x01, + 0x04, 0x3C, 0x3E + }; /* Check arguments */ if (params == NULL || hdev == NULL) { @@ -852,7 +860,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params, } else { /* Try to probe v2 pen parameters */ rc = uclogic_params_pen_init_v2(&p.pen, &found, - NULL, NULL, hdev); + ¶ms_ptr, ¶ms_len, + hdev); if (rc != 0) { hid_err(hdev, "failed probing pen v2 parameters: %d\n", rc); @@ -872,24 +881,58 @@ static int uclogic_params_huion_init(struct uclogic_params *params, goto cleanup; } - /* Create v2 frame touch ring parameters */ - rc = uclogic_params_frame_init_with_desc( + /* Link from pen sub-report */ + p.pen.subreport_list[0].value = 0xe0; + p.pen.subreport_list[0].id = + UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID; + + /* If this is the model with touch ring */ + if (params_ptr != NULL && + params_len == sizeof(touch_ring_model_params_buf) && + memcmp(params_ptr, touch_ring_model_params_buf, + params_len) == 0) { + /* Create touch ring parameters */ + rc = uclogic_params_frame_init_with_desc( &p.frame_list[1], uclogic_rdesc_v2_frame_touch_ring_arr, uclogic_rdesc_v2_frame_touch_ring_size, UCLOGIC_RDESC_V2_FRAME_TOUCH_ID); - if (rc != 0) { - hid_err(hdev, - "failed creating v2 frame touch ring parameters: %d\n", - rc); - goto cleanup; + if (rc != 0) { + hid_err(hdev, + "failed creating v2 frame touch ring parameters: %d\n", + rc); + goto cleanup; + } + p.frame_list[1].suffix = "Touch Ring"; + p.frame_list[1].dev_id_byte = + UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE; + p.frame_list[1].touch_byte = 5; + p.frame_list[1].touch_max = 12; + p.frame_list[1].touch_flip_at = 7; + } else { + /* Create touch strip parameters */ + rc = uclogic_params_frame_init_with_desc( + &p.frame_list[1], + uclogic_rdesc_v2_frame_touch_strip_arr, + uclogic_rdesc_v2_frame_touch_strip_size, + UCLOGIC_RDESC_V2_FRAME_TOUCH_ID); + if (rc != 0) { + hid_err(hdev, + "failed creating v2 frame touch strip parameters: %d\n", + rc); + goto cleanup; + } + p.frame_list[1].suffix = "Touch Strip"; + p.frame_list[1].dev_id_byte = + UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE; + p.frame_list[1].touch_byte = 5; + p.frame_list[1].touch_max = 8; } - p.frame_list[1].suffix = "Touch Ring"; - p.frame_list[1].dev_id_byte = - UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE; - p.frame_list[1].touch_byte = 5; - p.frame_list[1].touch_max = 12; - p.frame_list[1].touch_flip_at = 7; + + /* Link from pen sub-report */ + p.pen.subreport_list[1].value = 0xf0; + p.pen.subreport_list[1].id = + UCLOGIC_RDESC_V2_FRAME_TOUCH_ID; /* Create v2 frame dial parameters */ rc = uclogic_params_frame_init_with_desc( @@ -908,19 +951,11 @@ static int uclogic_params_huion_init(struct uclogic_params *params, UCLOGIC_RDESC_V2_FRAME_DIAL_DEV_ID_BYTE; p.frame_list[2].bitmap_dial_byte = 5; - /* - * Link button and touch ring subreports from pen - * reports - */ - p.pen.subreport_list[0].value = 0xe0; - p.pen.subreport_list[0].id = - UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID; - p.pen.subreport_list[1].value = 0xf0; - p.pen.subreport_list[1].id = - UCLOGIC_RDESC_V2_FRAME_TOUCH_ID; + /* Link from pen sub-report */ p.pen.subreport_list[2].value = 0xf1; p.pen.subreport_list[2].id = UCLOGIC_RDESC_V2_FRAME_DIAL_ID; + goto output; } hid_dbg(hdev, "pen v2 parameters not found\n"); @@ -961,6 +996,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params, memset(&p, 0, sizeof(p)); rc = 0; cleanup: + kfree(params_ptr); 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 e2bd3a91e6fd..3c3d4e8780dc 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -761,6 +761,54 @@ const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[] = { const size_t uclogic_rdesc_v2_frame_touch_ring_size = sizeof(uclogic_rdesc_v2_frame_touch_ring_arr); +/* Fixed report descriptor for (tweaked) v2 frame touch strip reports */ +const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[] = { + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x07, /* Usage (Keypad), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_ID, + /* Report ID (TOUCH_ID), */ + 0x14, /* Logical Minimum (0), */ + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x09, 0x39, /* Usage (Tablet Function Keys), */ + 0xA0, /* Collection (Physical), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x05, 0x09, /* Usage Page (Button), */ + 0x09, 0x01, /* Usage (01h), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x07, /* Report Count (7), */ + 0x81, 0x01, /* Input (Constant), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x02, /* Report Count (2), */ + 0x81, 0x01, /* Input (Constant), */ + 0x05, 0x0D, /* Usage Page (Digitizer), */ + 0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */ + 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x02, /* Input (Variable), */ + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x38, /* Usage (Wheel), */ + 0x95, 0x01, /* Report Count (1), */ + 0x15, 0x00, /* Logical Minimum (0), */ + 0x25, 0x07, /* Logical Maximum (7), */ + 0x81, 0x02, /* Input (Variable), */ + 0x09, 0x30, /* Usage (X), */ + 0x09, 0x31, /* Usage (Y), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x02, /* Report Count (2), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x2E, /* Report Count (46), */ + 0x81, 0x01, /* Input (Constant), */ + 0xC0, /* End Collection, */ + 0xC0 /* End Collection */ +}; +const size_t uclogic_rdesc_v2_frame_touch_strip_size = + sizeof(uclogic_rdesc_v2_frame_touch_strip_arr); + /* Fixed report descriptor for (tweaked) v2 frame dial reports */ const __u8 uclogic_rdesc_v2_frame_dial_arr[] = { 0x05, 0x01, /* Usage Page (Desktop), */ diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index b7bbaa70261e..0c6e95e8bde7 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -138,6 +138,10 @@ extern const size_t uclogic_rdesc_v2_frame_buttons_size; extern const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[]; extern const size_t uclogic_rdesc_v2_frame_touch_ring_size; +/* Fixed report descriptor for (tweaked) v2 frame touch strip reports */ +extern const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[]; +extern const size_t uclogic_rdesc_v2_frame_touch_strip_size; + /* Device ID byte offset in v2 frame touch ring/strip reports */ #define UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE 0x4 From patchwork Sun May 8 16:01:45 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: 12842477 X-Patchwork-Delegate: jikos@jikos.cz 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 CB642C4332F for ; Sun, 8 May 2022 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235120AbiEHQGM (ORCPT ); Sun, 8 May 2022 12:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235168AbiEHQGK (ORCPT ); Sun, 8 May 2022 12:06:10 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB96E0EC; Sun, 8 May 2022 09:02:20 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id i5so16351282wrc.13; Sun, 08 May 2022 09:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KUjA3hxYaMj4HNAIAW1BXRoi3/8SbsyN1ZHWbZHr2UU=; b=RNz0p96FOH9tfqyHM77KVvxOj+onZhhCgCkxuvtSEfiiclcqUQqSB9DPIGKVCrG4rh yUhXWKCXZS1HwOukhoAae2/7C73/6CHoCnBF572JbSPhXUfFUk7ubZ1n0srhNjPzC7Kn 5Lp2yjiLIm3hye890xt3u3suNQnRrqUM8Ns+PJF5UfnPsX4Jy/tCC01eKTkjZlumtdb1 fW09uNQv7jGrY51aiANm4xOvF/CiMQZu2bia8xuLbl6+f49p6/rT64AxKSSCY7cVdqri d3dETLyc5C3MGVXCzPDbx+Jjv1empm4F6z4a/ZMsFEYtr10mG/is58lybtXtunxxmg1R Be3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KUjA3hxYaMj4HNAIAW1BXRoi3/8SbsyN1ZHWbZHr2UU=; b=bs8ywpizIV6W9NaTKL9gw9fmf3MrQNdjSjdxIgC6w7xEsVcys7Zjpj6J5ZGN7TD0T1 adp7h1m2rh8uYRvenMLT/LuwytEppueO0GOJoiIaL4yCk6ocOd9AGAdqwndj66LreNrG E13+v61hTSA7G6RHuvHp1j/bMrHINkPo7wyF6YqC6/5DbEle1YgiFpdVW/8nIj20dvua 31qmXONVfjNd7iD/05cXcX8xRJfCs77L7cNWmlellyjUKBHn+LLTINt15u162tYYuxfe uV5KYaJCuS4b0QVSKFIDwIEe8HHxFB4zw7J0n2Zmu+9B3A3pMiChL7iUYYBFlYQvWblN zXYA== X-Gm-Message-State: AOAM533G0w4oPqn1Ru3aL0SIHSVAe4lbMoI5kyT3jDeB0iW25V2bcMIl QIC9BjoQLOe2Y5o7jOsSRn4= X-Google-Smtp-Source: ABdhPJyE4xwqMM0Of3uC+0tpCvYpCf89LY9vcRU26ulo4CKdUsNmsift3gRmI9oicGugThdMpiilAQ== X-Received: by 2002:a5d:594c:0:b0:20a:dff1:6545 with SMTP id e12-20020a5d594c000000b0020adff16545mr10266670wri.211.1652025738799; Sun, 08 May 2022 09:02:18 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id b15-20020a7bc24f000000b003942a244ecfsm10101925wmj.20.2022.05.08.09.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 09:02:18 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stefanberzl@gmail.com, albertofanjul@gmail.com, Roman Romanenko , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= Subject: [PATCH for-5.19/uclogic 6/7] HID: uclogic: Add pen support for XP-PEN Star 06 Date: Sun, 8 May 2022 18:01:45 +0200 Message-Id: <20220508160146.13004-7-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508160146.13004-1-jose.exposito89@gmail.com> References: <20220508160146.13004-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Roman Romanenko Similar to other UGEE pens, but the IDs were missing. Signed-off-by: Roman Romanenko Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- 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 cef51e93e220..2cf09328566a 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1260,6 +1260,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_XPPEN_TABLET_STAR06 0x0078 #define USB_DEVICE_ID_UGEE_TABLET_G5 0x0074 #define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071 #define USB_DEVICE_ID_UGEE_TABLET_RAINBOW_CV720 0x0055 diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index c4ab94d58a0f..c0fe66e50c58 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -521,6 +521,8 @@ static const struct hid_device_id uclogic_devices[] = { USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640) }, { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO01) }, + { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06) }, { } }; MODULE_DEVICE_TABLE(hid, uclogic_devices); diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 7db63bb77158..db838f16282d 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1195,6 +1195,8 @@ int uclogic_params_init(struct uclogic_params *params, USB_DEVICE_ID_UGEE_XPPEN_TABLET_G540): case VID_PID(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_G640): + case VID_PID(USB_VENDOR_ID_UGEE, + USB_DEVICE_ID_UGEE_XPPEN_TABLET_STAR06): case VID_PID(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_RAINBOW_CV720): /* If this is the pen interface */ From patchwork Sun May 8 16:01:46 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: 12842479 X-Patchwork-Delegate: jikos@jikos.cz 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 AD4A0C433FE for ; Sun, 8 May 2022 16:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235225AbiEHQGO (ORCPT ); Sun, 8 May 2022 12:06:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235169AbiEHQGL (ORCPT ); Sun, 8 May 2022 12:06:11 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CB49E0AB; Sun, 8 May 2022 09:02:21 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id w4so16334178wrg.12; Sun, 08 May 2022 09:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5c/oJcY+mU8bZWq31obYM76SgdTTfJMILUS4a25EC9M=; b=Ou8tKTUjnVee5QYHsgs8fAh8DwycdNVZtbWyKG0/FponkQZLRTLyLG6N/Op+6/0ryt 8A/m3OvxJQzvqq+GD64IZXO03pMi6dThMO0/SP7alsclTFyTWCLeokZf63wjtaU4OxbT NjcpXnfOc7d6ZOyJlTbKlo5NIfPScx16AOqiq4o1MkEeYuzHm64VSh2DYnAcTsOXCQao 95p4YhyJL8KitsjCai18QDCAGug+V9P9A0PXIXs39vhQaVVb9ztoz30xnio2omicEJSI m0rN9uzKj1n4BHBBbv6RKMKtR6jrxYgZ29F+cjXEfJhht6OuwPWBIuFXTuhd+XdgZT72 YSQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5c/oJcY+mU8bZWq31obYM76SgdTTfJMILUS4a25EC9M=; b=6EqLjMt/AZixwnR617LDcCrwFj0QfYi1OWc875PD4ugG9chcCK/HKJgAXAgGZWgnjs feYjnq2LDSKt0t+9TpYV/nfAxCEee9N4YNurskF6hv3dt7vwof4MeO2u0QeTkch42OGL fNvhNyA1XjTbGyaUg4N4OiVp/OK05qcP1/7VghgFSVk/MiLiRSs5MDr2qWsjGRCXDQUm iVB6o4cNS+Pm0iT2MKTvt2jf7CX6Yg/Qa4qN3LDtR6Q/pulXUSY4ZMIRnUQcrjU2NITE PQqstUWG2vX/eIG0G5lnC23glx4AT1rH9u927pFAK+oxCekrSkhzjCxHKqS8aGCvK6hX XJgQ== X-Gm-Message-State: AOAM531tsiRtzFa3KQQfj9TPJFUQOhJ5MYDO1p5jUObmkRxJQd85ERas e+M7XivpHjzMz3Vr4vhaBBQ= X-Google-Smtp-Source: ABdhPJy9Pz120cLoC1JhaQndg+mUhhZwK2lhXv31H74w67CjktAf2sLjgGwcyXehdLyXqycRpl1wWg== X-Received: by 2002:a5d:4f08:0:b0:20a:ddfe:bd99 with SMTP id c8-20020a5d4f08000000b0020addfebd99mr10888248wru.339.1652025739637; Sun, 08 May 2022 09:02:19 -0700 (PDT) Received: from localhost.localdomain ([94.73.37.128]) by smtp.gmail.com with ESMTPSA id b15-20020a7bc24f000000b003942a244ecfsm10101925wmj.20.2022.05.08.09.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 09:02:19 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stefanberzl@gmail.com, albertofanjul@gmail.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= Subject: [PATCH for-5.19/uclogic 7/7] HID: uclogic: Switch to Digitizer usage for styluses Date: Sun, 8 May 2022 18:01:46 +0200 Message-Id: <20220508160146.13004-8-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508160146.13004-1-jose.exposito89@gmail.com> References: <20220508160146.13004-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov The (incorrect) "Pen" (0x02) application usage used in replacement report descriptors throughout the drivers leads to all tablets recognized as a "direct" input device (i.e. a tablet monitor) by recent kernels, which messes up desktop environments [1]. Replace the application usage with "Digitizer" (0x01) for each non-display graphics tablet. [1] https://lore.kernel.org/linux-input/f39ce5d5-bd5b-bd3f-3ea2-9b2a89ba1eb1@gmail.com/ Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-kye.c | 12 ++++++------ drivers/hid/hid-uclogic-rdesc.c | 18 +++++++++--------- drivers/hid/hid-viewsonic.c | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c index f46616390a98..da903138eee4 100644 --- a/drivers/hid/hid-kye.c +++ b/drivers/hid/hid-kye.c @@ -33,7 +33,7 @@ static __u8 easypen_i405x_rdesc_fixed[] = { 0xB1, 0x02, /* Feature (Variable), */ 0xC0, /* End Collection, */ 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x10, /* Report ID (16), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -91,7 +91,7 @@ static __u8 mousepen_i608x_rdesc_fixed[] = { 0xB1, 0x02, /* Feature (Variable), */ 0xC0, /* End Collection, */ 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x10, /* Report ID (16), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -190,7 +190,7 @@ static __u8 mousepen_i608x_v2_rdesc_fixed[] = { 0xB1, 0x02, /* Feature (Variable), */ 0xC0, /* End Collection, */ 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x10, /* Report ID (16), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -289,7 +289,7 @@ static __u8 easypen_m610x_rdesc_fixed[] = { 0xB1, 0x02, /* Feature (Variable), */ 0xC0, /* End Collection, */ 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x10, /* Report ID (16), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -368,7 +368,7 @@ static __u8 pensketch_m912_rdesc_fixed[] = { 0xB1, 0x02, /* Feature (Variable), */ 0xC0, /* End Collection, */ 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x10, /* Report ID (16), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -497,7 +497,7 @@ static __u8 easypen_m406xe_rdesc_fixed[] = { 0xB1, 0x02, /* Feature (Variable), */ 0xC0, /* End Collection, */ 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x10, /* Report ID (16), */ 0x09, 0x20, /* Usage (Stylus), */ diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index 3c3d4e8780dc..13f9ce73f1b1 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -21,7 +21,7 @@ /* Fixed WP4030U report descriptor */ __u8 uclogic_rdesc_wp4030u_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x09, /* Report ID (9), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -66,7 +66,7 @@ const size_t uclogic_rdesc_wp4030u_fixed_size = /* Fixed WP5540U report descriptor */ __u8 uclogic_rdesc_wp5540u_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x09, /* Report ID (9), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -143,7 +143,7 @@ const size_t uclogic_rdesc_wp5540u_fixed_size = /* Fixed WP8060U report descriptor */ __u8 uclogic_rdesc_wp8060u_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x09, /* Report ID (9), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -220,7 +220,7 @@ const size_t uclogic_rdesc_wp8060u_fixed_size = /* Fixed WP1062 report descriptor */ __u8 uclogic_rdesc_wp1062_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x09, /* Report ID (9), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -268,7 +268,7 @@ const size_t uclogic_rdesc_wp1062_fixed_size = /* Fixed PF1209 report descriptor */ __u8 uclogic_rdesc_pf1209_fixed_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x09, /* Report ID (9), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -345,7 +345,7 @@ const size_t uclogic_rdesc_pf1209_fixed_size = /* Fixed PID 0522 tablet report descriptor, interface 0 (stylus) */ __u8 uclogic_rdesc_twhl850_fixed0_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x09, /* Report ID (9), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -457,7 +457,7 @@ const size_t uclogic_rdesc_twhl850_fixed2_size = /* Fixed TWHA60 report descriptor, interface 0 (stylus) */ __u8 uclogic_rdesc_twha60_fixed0_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x09, /* Report ID (9), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -534,7 +534,7 @@ const size_t uclogic_rdesc_twha60_fixed1_size = /* Fixed report descriptor template for (tweaked) v1 pen reports */ const __u8 uclogic_rdesc_v1_pen_template_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x07, /* Report ID (7), */ 0x09, 0x20, /* Usage (Stylus), */ @@ -588,7 +588,7 @@ const size_t uclogic_rdesc_v1_pen_template_size = /* Fixed report descriptor template for (tweaked) v2 pen reports */ const __u8 uclogic_rdesc_v2_pen_template_arr[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x08, /* Report ID (8), */ 0x09, 0x20, /* Usage (Stylus), */ diff --git a/drivers/hid/hid-viewsonic.c b/drivers/hid/hid-viewsonic.c index df60c8fc2efd..8024b1d370e2 100644 --- a/drivers/hid/hid-viewsonic.c +++ b/drivers/hid/hid-viewsonic.c @@ -24,7 +24,7 @@ /* Fixed report descriptor of PD1011 signature pad */ static __u8 pd1011_rdesc_fixed[] = { 0x05, 0x0D, /* Usage Page (Digitizer), */ - 0x09, 0x02, /* Usage (Pen), */ + 0x09, 0x01, /* Usage (Digitizer), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x02, /* Report ID (2), */ 0x09, 0x20, /* Usage (Stylus), */