From patchwork Thu Mar 3 07:47:31 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: 548409 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 D63ADC433F5 for ; Thu, 3 Mar 2022 07:47:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230340AbiCCHs3 (ORCPT ); Thu, 3 Mar 2022 02:48:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbiCCHs2 (ORCPT ); Thu, 3 Mar 2022 02:48:28 -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 96C5938BD3; Wed, 2 Mar 2022 23:47:41 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id l2-20020a7bc342000000b0037fa585de26so3428484wmj.1; Wed, 02 Mar 2022 23:47:41 -0800 (PST) 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=AATWb0QJcK0U+z3f0zjpgkV38rUnep/CDv97l/dLl40=; b=lYCu/SblUcjMJSBeWLAkwX3BFoxG28Hb9STScFacGXpx7j4zqRGZxHIIPHHN/AAZ7c iH8qvePTl1qIcZ9p4UXrE57bXw/kNMwSRBSTZJEzIRDySP0HuMIciPDGqxpaTwyiV24B n1L2W5WV90freGAspr699xnfK281iOy6umAl7m6qZu3JHt5KzlizM0ZyXFwA10ctHKdj mlYl3AD+Ky6/kPr65z0tbTcmjl9sYENh3+ta+b1SYKlPjU+mDi2Bffv7H8kqrgQqkwJT 6+YrhnDCF0VPb90L1UkkDwct0J5YOjaD1ethOCOV2KIrliCUGRcrkeWxVPYjlAdOHFeW RIRQ== 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=AATWb0QJcK0U+z3f0zjpgkV38rUnep/CDv97l/dLl40=; b=LNTsw9M2h6K/B6lwOKIfWnerKRzHZB9p/jIHX44NV6onq/mmynkV+oToUCKAGJVtVl 5t/Mv9bCK8RI6bfFlBdQ6rBBpr2zvsI33HSnYyx+0qELYe2L42uMp7HN+ez9bq4cy4uC POSFYNxfccvFV3sCkstoGQ0oG2SPyWngclqKA31zGQ5V6s1t767HeODsvd5xmTCo9b8L SwLXgIVDRGgUs9t30BROfhD6iUraxCmlr+glU864Ze3pP/YN+i0PxdWStQ4PD0eNGzc3 LvVrb3d15w1wYhC28Nagoj8hQwSoTT1ksYVVA4uPLdbNQOvRzfAANBhLRgxfcTbbPspA otpw== X-Gm-Message-State: AOAM533YZ4I0fUiijeRkUzPPDyISt/AkJolRDxj9lEGMItYx0Qx1XXOZ 7h2GOhe/+KgIsXN/hrvMG1E= X-Google-Smtp-Source: ABdhPJzPT5VhNjWM1XSE6JjuRPxqclxdxX85OzY1akbC6yYk87iVnl2f7HGNayM4eHCWdziKWA3h5g== X-Received: by 2002:a05:600c:4e08:b0:381:9094:6b3c with SMTP id b8-20020a05600c4e0800b0038190946b3cmr2699028wmq.103.1646293659970; Wed, 02 Mar 2022 23:47:39 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id d3-20020a05600c34c300b003884e826642sm841169wmq.12.2022.03.02.23.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 23:47:39 -0800 (PST) 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, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH for-5.18/uclogic 1/4] HID: uclogic: Add support for touch ring reports Date: Thu, 3 Mar 2022 08:47:31 +0100 Message-Id: <20220303074734.7235-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303074734.7235-1-jose.exposito89@gmail.com> References: <20220303074734.7235-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Add support for touch ring to UC-Logic driver. The touch ring reports can be flipped around a specific point to match the orientation and direction reported by the Wacom drivers. The proximity will also be reported similar to the Wacom drivers. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 39 +++++++++++++++++++++++++++++++- drivers/hid/hid-uclogic-params.h | 36 +++++++++++++++++++++++++---- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 05147f2d7564..b448616dacb9 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -90,6 +90,8 @@ static int uclogic_input_configured(struct hid_device *hdev, const char *suffix = NULL; struct hid_field *field; size_t len; + size_t i; + const struct uclogic_params_frame *frame; /* no report associated (HID_QUIRK_MULTI_INPUT not set) */ if (!hi->report) @@ -104,6 +106,19 @@ static int uclogic_input_configured(struct hid_device *hdev, drvdata->pen_input = hi->input; } + /* If it's one of the frame devices */ + for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) { + frame = ¶ms->frame_list[i]; + if (hi->report->id == frame->id) { + /* + * Disable EV_MSC reports for touch ring interfaces to + * make the Wacom driver pickup touch ring extents + */ + if (frame->touch_ring_byte > 0) + __clear_bit(EV_MSC, hi->input->evbit); + } + } + field = hi->report->field[0]; switch (field->application) { @@ -313,8 +328,16 @@ 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) { - data[frame->dev_id_byte] = 0xf; + /* 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) { + data[frame->dev_id_byte] = 0; + } else { + data[frame->dev_id_byte] = 0xf; + } } + /* If need to, and can, read rotary encoder state change */ if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) { unsigned int byte = frame->re_lsb / 8; @@ -341,6 +364,20 @@ static int uclogic_raw_event_frame( drvdata->re_state = state; } + /* 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 (value != 0) { + value = frame->touch_ring_flip_at - value; + if (value < 0) + value = frame->touch_ring_max + value; + + data[frame->touch_ring_byte] = value; + } + } + return 0; } diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index 86f616dfbb53..fe13bc36983b 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -123,10 +123,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. Only valid if "id" is - * not 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 + * 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. + * 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; + + /* + * The value to anchor the reversed reports at. + * I.e. one, if the reports should be flipped without offset. + * Zero if no reversal should be done. + */ + __s8 touch_ring_flip_at; }; /* @@ -191,7 +213,10 @@ extern int uclogic_params_init(struct uclogic_params *params, ".frame_list[0].desc_size = %u\n" \ ".frame_list[0].id = %u\n" \ ".frame_list[0].re_lsb = %u\n" \ - ".frame_list[0].dev_id_byte = %u\n" + ".frame_list[0].dev_id_byte = %u\n" \ + ".frame_list[0].touch_ring_byte = %u\n" \ + ".frame_list[0].touch_ring_max = %hhd\n" \ + ".frame_list[0].touch_ring_flip_at = %hhd\n" /* Tablet interface parameters *printf format arguments */ #define UCLOGIC_PARAMS_FMT_ARGS(_params) \ @@ -210,7 +235,10 @@ extern int uclogic_params_init(struct uclogic_params *params, (_params)->frame_list[0].desc_size, \ (_params)->frame_list[0].id, \ (_params)->frame_list[0].re_lsb, \ - (_params)->frame_list[0].dev_id_byte + (_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 /* Get a replacement report descriptor for a tablet's interface. */ extern int uclogic_params_get_desc(const struct uclogic_params *params, From patchwork Thu Mar 3 07:47:32 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: 547980 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 C29B9C433FE for ; Thu, 3 Mar 2022 07:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbiCCHs3 (ORCPT ); Thu, 3 Mar 2022 02:48:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbiCCHs2 (ORCPT ); Thu, 3 Mar 2022 02:48:28 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53CD285BE9; Wed, 2 Mar 2022 23:47:42 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id bg31-20020a05600c3c9f00b00381590dbb33so2680050wmb.3; Wed, 02 Mar 2022 23:47:42 -0800 (PST) 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=L0NKVzasrTrGwBZq2ioODs/A3zUcClXcRrJ9wLnu5QE=; b=M0h1vDhzoitu2Gcu9k2BkLCbs915ZC+A6XQDsmne4dOMPr111GtDhUesUGw+Akift2 7Mo19ZvCa5shn4gC8o8NsyoH1zG1YW5f+Cg8mgTZ4uWWRCe63mm86pvpMoY29/8NR3N+ rv/5LJxrdMQPvvH+PU6jumfCflxco2PoGikMsLiutbevug2oE/HKrVxp036v73bBt76H wk95VZRNx5+XrmMK7xbK6BwBQVcCCQ0l3AOD85xTbKEbnPpN1cSz//4/iXDpSjCInj6O d4kIfV6k0E740ykuGicnWVyiGxX+aA7YResiaBUn6rW4nEqn76IbNed6awW4BKKZXID7 4mUA== 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=L0NKVzasrTrGwBZq2ioODs/A3zUcClXcRrJ9wLnu5QE=; b=f2eGGkaoTvxPnewTDT73KBl1VMcZZYD5/itjacN36bOoy+0ElNmP4r8sj+9XpgFPxS /CCQe8F+gm2gXd3I2PzaZOmfchq2gUE6nduQv+CpsgFez53l9s2rDX+E+hsGzBAHLOKg iDu0hEHNcZUhsHz+aV2nv8SYBL7lh6M5TUrY+BpkPdgrmmmw/J1fTJG83AS5uSoA+4WP 2QwqGjv22uTEmIfdNlc2U7CK0tv+Bfbmq2Alwq4s3JI8EVoWx2ciVDwVaUKhf0OT2NDs AV7tA+Oz+5eEnosn+YmqrtpKPqJiij8uHEYV8j2o7k+kia2OlCDqVhxv84Z7qlmreSzq GdvQ== X-Gm-Message-State: AOAM533Uq70uZwBOf1vPm++OOBj4gK9aSbf+juAat0gDVywnO0AkPoBV m+/OnkafDwv561Ushx7kGl4= X-Google-Smtp-Source: ABdhPJx4gkOdLGlBHG92q1Jkpjo77fKPceNyhre3f51+8YnfT+fY4RJ58hoN7BidSoiKQIuMIADiZw== X-Received: by 2002:a05:600c:3596:b0:381:751a:f0a6 with SMTP id p22-20020a05600c359600b00381751af0a6mr2723282wmq.168.1646293660874; Wed, 02 Mar 2022 23:47:40 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id d3-20020a05600c34c300b003884e826642sm841169wmq.12.2022.03.02.23.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 23:47:40 -0800 (PST) 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, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH for-5.18/uclogic 2/4] HID: uclogic: Support custom device suffix for frames Date: Thu, 3 Mar 2022 08:47:32 +0100 Message-Id: <20220303074734.7235-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303074734.7235-1-jose.exposito89@gmail.com> References: <20220303074734.7235-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Support assigning custom device name suffixes to frame input devices instead of just "Pad". This allows distinguishing multiple frame input devices, e.g. for Huion HS610. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 46 +++++++++++++++++--------------- drivers/hid/hid-uclogic-params.h | 6 +++++ 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index b448616dacb9..96f3fb8c492c 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -110,6 +110,8 @@ static int uclogic_input_configured(struct hid_device *hdev, for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) { frame = ¶ms->frame_list[i]; if (hi->report->id == frame->id) { + /* Assign custom suffix, if any */ + suffix = frame->suffix; /* * Disable EV_MSC reports for touch ring interfaces to * make the Wacom driver pickup touch ring extents @@ -119,27 +121,29 @@ static int uclogic_input_configured(struct hid_device *hdev, } } - field = hi->report->field[0]; - - switch (field->application) { - case HID_GD_KEYBOARD: - suffix = "Keyboard"; - break; - case HID_GD_MOUSE: - suffix = "Mouse"; - break; - case HID_GD_KEYPAD: - suffix = "Pad"; - break; - case HID_DG_PEN: - suffix = "Pen"; - break; - case HID_CP_CONSUMER_CONTROL: - suffix = "Consumer Control"; - break; - case HID_GD_SYSTEM_CONTROL: - suffix = "System Control"; - break; + if (!suffix) { + field = hi->report->field[0]; + + switch (field->application) { + case HID_GD_KEYBOARD: + suffix = "Keyboard"; + break; + case HID_GD_MOUSE: + suffix = "Mouse"; + break; + case HID_GD_KEYPAD: + suffix = "Pad"; + break; + case HID_DG_PEN: + suffix = "Pen"; + break; + case HID_CP_CONSUMER_CONTROL: + suffix = "Consumer Control"; + break; + case HID_GD_SYSTEM_CONTROL: + suffix = "System Control"; + break; + } } if (suffix) { diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index fe13bc36983b..8042820e78b1 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -114,6 +114,10 @@ struct uclogic_params_frame { * Report ID, if reports should be tweaked, zero if not. */ unsigned int id; + /* + * The suffix to add to the input device name, if not NULL. + */ + const char *suffix; /* * Number of the least-significant bit of the 2-bit state of a rotary * encoder, in the report. Cannot point to a 2-bit field crossing a @@ -212,6 +216,7 @@ extern int uclogic_params_init(struct uclogic_params *params, ".frame_list[0].desc_ptr = %p\n" \ ".frame_list[0].desc_size = %u\n" \ ".frame_list[0].id = %u\n" \ + ".frame_list[0].suffix = %s\n" \ ".frame_list[0].re_lsb = %u\n" \ ".frame_list[0].dev_id_byte = %u\n" \ ".frame_list[0].touch_ring_byte = %u\n" \ @@ -234,6 +239,7 @@ extern int uclogic_params_init(struct uclogic_params *params, (_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, \ From patchwork Thu Mar 3 07:47:33 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: 547979 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 8FE3DC433FE for ; Thu, 3 Mar 2022 07:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbiCCHsd (ORCPT ); Thu, 3 Mar 2022 02:48:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230353AbiCCHs3 (ORCPT ); Thu, 3 Mar 2022 02:48:29 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50EB635242; Wed, 2 Mar 2022 23:47:43 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id y5so2627952wmi.0; Wed, 02 Mar 2022 23:47:43 -0800 (PST) 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=DLwnShhOGzDJRPDrMuARp5HnoES190FJM3KiBVtCeYQ=; b=T57L1WWKK6HHcKrxCPQ4A8dcb7lCYMWZpDF3b6MnTpgrmh0kjsUX7gzAf8305XPtxh Us1D88TL1n5kg3vpMvIaPLXMN54Wcr7CPlDeDGe5azqIWH92KgvA3LPqjc4utwiKkk4Y AYLXkPlX5CXMv9RVehK+W2yBBMJmwKTG1ZXtXL/Q0QjkAv5iWaa2US07B1s0W99JMnhN WSnpWw+TgFMjialPcshbIHo5hcsga8qHaRoE+eWqxEaCrzeBYs2Kr7ef2H21AZ1XfgUy 5ieGxSuKt+K4NLTubPMPADiSaqb0E1PjwL9UN+cOJQvilmxHR310kN9GvHGIOBvsVHZ9 nnQQ== 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=DLwnShhOGzDJRPDrMuARp5HnoES190FJM3KiBVtCeYQ=; b=aDGAowGyQ1a6NOwrmeZR8iZoYJ1wu2Ie7qZv6DIzzrdkLPePs+qUGKHQECYoC5D8ON I2vvBnOcMUaehVtbIt/mKtykE2v6GxuPcA41UW5iMaesTj1DKQNiNv2AK0fFONwqJXer hYyFU4+QU3X/Q7zil+YIi2SFMhyXR6YWtFTpNgQCg/Iqh+pi71pTedtPAMjJhz88StKl BVKzTzMQMsqimHI54zo2ukAGwi4wk4NLle0+GxTUBrfB8J47MZkSuoj2JcVuuwBNkEBw wfXFGOf3ehhOA2vAt7+IVfcJG9fmUKs+YwRASD6R8FoMmyJlVwszg93og/gmUvOqleeC BEcw== X-Gm-Message-State: AOAM533A2xVoC+ViDDB4yiG63vY/z19wdUNKijchBfF4U33rp2r9z8qL f5JwLttidqDh9qckCpjwxXs= X-Google-Smtp-Source: ABdhPJwobsLcgHBkl7FS/U3xZDGFU2ScOH6+8J9oX0ut67KX7hy9C/groYAsqnbga+Vr9jZxn3+EJg== X-Received: by 2002:a05:600c:4f83:b0:37c:d057:3efe with SMTP id n3-20020a05600c4f8300b0037cd0573efemr2685205wmq.143.1646293661633; Wed, 02 Mar 2022 23:47:41 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id d3-20020a05600c34c300b003884e826642sm841169wmq.12.2022.03.02.23.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 23:47:41 -0800 (PST) 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, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH for-5.18/uclogic 3/4] HID: uclogic: Allow three frame parameter sets Date: Thu, 3 Mar 2022 08:47:33 +0100 Message-Id: <20220303074734.7235-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303074734.7235-1-jose.exposito89@gmail.com> References: <20220303074734.7235-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Allow three frame parameter sets per each UC-Logic tablet interface. Bump the number of supported subreports to three as well to accommodate ID routing. This allows supporting the dial on Huion Q620M. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.h | 52 +++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index 8042820e78b1..f2649e8f959d 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -73,8 +73,8 @@ struct uclogic_params_pen { unsigned int desc_size; /* Report ID, if reports should be tweaked, zero if not */ unsigned int id; - /* The list of subreports */ - struct uclogic_params_pen_subreport subreport_list[1]; + /* The list of subreports, only valid if "id" is not zero */ + struct uclogic_params_pen_subreport subreport_list[3]; /* Type of in-range reporting, only valid if "id" is not zero */ enum uclogic_params_pen_inrange inrange; /* @@ -194,7 +194,7 @@ struct uclogic_params { * The list of frame control parameters and optional report descriptor * parts. Only valid, if "invalid" is false. */ - struct uclogic_params_frame frame_list[1]; + struct uclogic_params_frame frame_list[3]; }; /* Initialize a tablet interface and discover its parameters */ @@ -210,6 +210,8 @@ extern int uclogic_params_init(struct uclogic_params *params, ".pen.desc_size = %u\n" \ ".pen.id = %u\n" \ ".pen.subreport_list[0] = {0x%02hhx, %hhu}\n" \ + ".pen.subreport_list[1] = {0x%02hhx, %hhu}\n" \ + ".pen.subreport_list[2] = {0x%02hhx, %hhu}\n" \ ".pen.inrange = %s\n" \ ".pen.fragmented_hires = %s\n" \ ".pen.tilt_y_flipped = %s\n" \ @@ -221,7 +223,25 @@ extern int uclogic_params_init(struct uclogic_params *params, ".frame_list[0].dev_id_byte = %u\n" \ ".frame_list[0].touch_ring_byte = %u\n" \ ".frame_list[0].touch_ring_max = %hhd\n" \ - ".frame_list[0].touch_ring_flip_at = %hhd\n" + ".frame_list[0].touch_ring_flip_at = %hhd\n" \ + ".frame_list[1].desc_ptr = %p\n" \ + ".frame_list[1].desc_size = %u\n" \ + ".frame_list[1].id = %u\n" \ + ".frame_list[1].suffix = %s\n" \ + ".frame_list[1].re_lsb = %u\n" \ + ".frame_list[1].dev_id_byte = %u\n" \ + ".frame_list[1].touch_ring_byte = %u\n" \ + ".frame_list[1].touch_ring_max = %hhd\n" \ + ".frame_list[1].touch_ring_flip_at = %hhd\n" \ + ".frame_list[2].desc_ptr = %p\n" \ + ".frame_list[2].desc_size = %u\n" \ + ".frame_list[2].id = %u\n" \ + ".frame_list[2].suffix = %s\n" \ + ".frame_list[2].re_lsb = %u\n" \ + ".frame_list[2].dev_id_byte = %u\n" \ + ".frame_list[2].touch_ring_byte = %u\n" \ + ".frame_list[2].touch_ring_max = %hhd\n" \ + ".frame_list[2].touch_ring_flip_at = %hhd\n" /* Tablet interface parameters *printf format arguments */ #define UCLOGIC_PARAMS_FMT_ARGS(_params) \ @@ -233,6 +253,10 @@ extern int uclogic_params_init(struct uclogic_params *params, (_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"), \ @@ -244,7 +268,25 @@ extern int uclogic_params_init(struct uclogic_params *params, (_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].touch_ring_flip_at, \ + (_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[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 /* Get a replacement report descriptor for a tablet's interface. */ extern int uclogic_params_get_desc(const struct uclogic_params *params, From patchwork Thu Mar 3 07:47:34 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: 548408 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 80678C433F5 for ; Thu, 3 Mar 2022 07:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbiCCHsc (ORCPT ); Thu, 3 Mar 2022 02:48:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbiCCHsa (ORCPT ); Thu, 3 Mar 2022 02:48:30 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40B26DD94B; Wed, 2 Mar 2022 23:47:44 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id ay10so6399199wrb.6; Wed, 02 Mar 2022 23:47:44 -0800 (PST) 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=NiVepjW1JG6/Q6RmFnrhcxgSObNvC7PpGqjXdCAH81c=; b=UDrnu6G5FwpQdLlep9WTdwHnGvM1DdpGeNR30Bk5ZxXyT6UbnLnYKz5aRprnq+LKRk 17xpuSL1UDGm7QQryMdJt8NPcvNvH78esl7A8BG5AltilRBmKPWNg/6yepJYy5i6EhD8 Q2w3BCDRNMsI8w2/XA9+QFWv3JuTuFkWiL7V5W+jphBJpB0hTShqvR/gdKdrN05LYsry kpSqX+jDrr9Cm3vXSava8P88qh8S90J09kul9yvvnjzSMaRIdGL2BECYsaaq1syjLgr0 5du/QRvecPvR//hs2TWH4NA6fcs+i+mKxYtvy7c8pdDahX/b4NvOtNdvpMtgls+JzFoQ FPLA== 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=NiVepjW1JG6/Q6RmFnrhcxgSObNvC7PpGqjXdCAH81c=; b=h8nMysbOOPnlVcn7NmA0+pHv+qtT7plLl+01uqsqAVpq5s+uyxrB8j2cbo9OxOREjQ ml61w1Sz92BMz7hyJOZ/iiA+AoFbZbiY7nXyARVEvaIUAAH60scSZclil6U9SHiTCuVW GKFeRPWZ1SP4bH40oiNC7uKjV1gDBMRyCIMncYcfiZWoHjR07KO0H1nZvB00fb8m36LZ sACMc6+PC21Y2kWpE7ekYPKvSWlkcff/TMS76fEgcZzMvwLhFWuvG74ri1H+MgnLJuCZ hYmh4kBOX7cKEKH6ASfvGAOGs2V+mpb5xw6YD+coaLCjr40TyqwVabUAu6cQ75hZ/97J snjg== X-Gm-Message-State: AOAM533lbxqZlZoCYNZwNEGhgM6LUOSX1SGYb3sYdnMSVD5TVAwRXYOf OYt/3yBeRUJ3eYz7PTreZNg= X-Google-Smtp-Source: ABdhPJxIF8HJj5xNTIrqyqRyCjVyNySLh8FRUyaczlx5bkoabT4yzfQNSttEjAswey3etsTgQet/hQ== X-Received: by 2002:a5d:64a8:0:b0:1f0:5556:6d3a with SMTP id m8-20020a5d64a8000000b001f055566d3amr1206137wrp.72.1646293662705; Wed, 02 Mar 2022 23:47:42 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id d3-20020a05600c34c300b003884e826642sm841169wmq.12.2022.03.02.23.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 23:47:42 -0800 (PST) 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, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH for-5.18/uclogic 4/4] HID: uclogic: Add support for Huion touch ring reports Date: Thu, 3 Mar 2022 08:47:34 +0100 Message-Id: <20220303074734.7235-5-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303074734.7235-1-jose.exposito89@gmail.com> References: <20220303074734.7235-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Support touch ring reports found in Huion HS610 to the UC-Logic driver. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 40 ++++++++++++++++---- drivers/hid/hid-uclogic-rdesc.c | 65 ++++++++++++++++++++++++++++---- drivers/hid/hid-uclogic-rdesc.h | 20 +++++++--- 3 files changed, 105 insertions(+), 20 deletions(-) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 5f50ceb875d6..3ac45e7572a0 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -745,22 +745,48 @@ static int uclogic_params_huion_init(struct uclogic_params *params, goto cleanup; } else if (found) { hid_dbg(hdev, "pen v2 parameters found\n"); - /* Create v2 frame parameters */ + /* Create v2 frame button parameters */ rc = uclogic_params_frame_init_with_desc( &p.frame_list[0], - uclogic_rdesc_v2_frame_arr, - uclogic_rdesc_v2_frame_size, - UCLOGIC_RDESC_V2_FRAME_ID); + uclogic_rdesc_v2_frame_buttons_arr, + uclogic_rdesc_v2_frame_buttons_size, + UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID); if (rc != 0) { hid_err(hdev, - "failed creating v2 frame parameters: %d\n", + "failed creating v2 frame button parameters: %d\n", rc); goto cleanup; } - /* Link frame button subreports from pen reports */ + + /* Create v2 frame 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_RING_ID); + 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_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; + + /* + * 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_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_RING_ID; goto output; } hid_dbg(hdev, "pen v2 parameters not found\n"); diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index 04644d93bd11..d64b607dce5d 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -652,12 +652,12 @@ const size_t uclogic_rdesc_v2_pen_template_size = sizeof(uclogic_rdesc_v2_pen_template_arr); /* - * Expand to the contents of a generic frame report descriptor. + * Expand to the contents of a generic frame buttons report descriptor. * * @_id: The report ID to use. * @_size: Size of the report to pad to, including report ID, bytes. */ -#define UCLOGIC_RDESC_FRAME_BYTES(_id, _size) \ +#define UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(_id, _size) \ 0x05, 0x01, /* Usage Page (Desktop), */ \ 0x09, 0x07, /* Usage (Keypad), */ \ 0xA1, 0x01, /* Collection (Application), */ \ @@ -700,17 +700,66 @@ const size_t uclogic_rdesc_v2_pen_template_size = /* Fixed report descriptor for (tweaked) v1 frame reports */ const __u8 uclogic_rdesc_v1_frame_arr[] = { - UCLOGIC_RDESC_FRAME_BYTES(UCLOGIC_RDESC_V1_FRAME_ID, 8) + UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(UCLOGIC_RDESC_V1_FRAME_ID, 8) }; const size_t uclogic_rdesc_v1_frame_size = sizeof(uclogic_rdesc_v1_frame_arr); -/* Fixed report descriptor for (tweaked) v2 frame reports */ -const __u8 uclogic_rdesc_v2_frame_arr[] = { - UCLOGIC_RDESC_FRAME_BYTES(UCLOGIC_RDESC_V2_FRAME_ID, 12) +/* Fixed report descriptor for (tweaked) v2 frame button reports */ +const __u8 uclogic_rdesc_v2_frame_buttons_arr[] = { + UCLOGIC_RDESC_FRAME_BUTTONS_BYTES(UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID, + 12) }; -const size_t uclogic_rdesc_v2_frame_size = - sizeof(uclogic_rdesc_v2_frame_arr); +const size_t uclogic_rdesc_v2_frame_buttons_size = + sizeof(uclogic_rdesc_v2_frame_buttons_arr); + +/* Fixed report descriptor for (tweaked) v2 frame touch ring reports */ +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), */ + 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, 0x0B, /* Logical Maximum (11), */ + 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_ring_size = + sizeof(uclogic_rdesc_v2_frame_touch_ring_arr); /* Fixed report descriptor for Ugee EX07 frame */ const __u8 uclogic_rdesc_ugee_ex07_frame_arr[] = { diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index 3d904c27b86a..f15a9d8a946b 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -124,12 +124,22 @@ extern const size_t uclogic_rdesc_v2_pen_template_size; extern const __u8 uclogic_rdesc_v1_frame_arr[]; extern const size_t uclogic_rdesc_v1_frame_size; -/* Report ID for tweaked v2 frame reports */ -#define UCLOGIC_RDESC_V2_FRAME_ID 0xf7 +/* Report ID for tweaked v2 frame button reports */ +#define UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID 0xf7 -/* Fixed report descriptor for (tweaked) v2 frame reports */ -extern const __u8 uclogic_rdesc_v2_frame_arr[]; -extern const size_t uclogic_rdesc_v2_frame_size; +/* Fixed report descriptor for (tweaked) v2 frame button reports */ +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 + +/* 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 /* Fixed report descriptor for Ugee EX07 frame */ extern const __u8 uclogic_rdesc_ugee_ex07_frame_arr[];