From patchwork Thu Feb 10 19:04: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: 541599 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 8C303C433F5 for ; Thu, 10 Feb 2022 19:04:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343637AbiBJTEx (ORCPT ); Thu, 10 Feb 2022 14:04:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343633AbiBJTEw (ORCPT ); Thu, 10 Feb 2022 14:04:52 -0500 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 B665B2188; Thu, 10 Feb 2022 11:04:52 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id v12so11342856wrv.2; Thu, 10 Feb 2022 11:04:52 -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=FpmRjI0D+EUjYe3MeaVVjfaIantYzT3rLaYTj18YtDY=; b=KK8VxxYFNzGY9uQk3j+LgYTG0MruHQh7kSQKDUrSXVX5ahF1ACDOjDpuGj2e6fWuCf Ayl4KYwww5Jhex1PeSTHDpx5yP7yZ4MgFCTsCln0mov0JAsTxMmopyma6UF81/j3SLzX ACnYdFH41nCKYvdZBHVUymd5z7ZQavR+ZrBGW0SyRytPJV+PpBMdY+uw56TBUQpLBYLY e5zVROEzuAtNxaujQPeBf8JCROsVLymQz8c3L8OnLMFI6XIrAQ7vj7QnJuwG5mpUdvqr n9TncL/uQnQIVgRxnysSEnQxHjxuiPYMjijNy+TnRjDCsG2yLuU9dZXNYggkIwbS0Cwf EoaA== 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=FpmRjI0D+EUjYe3MeaVVjfaIantYzT3rLaYTj18YtDY=; b=7wWyOMMdKLeDR9lO1XBHwpst/QClieQe4Vqf48nvLE/uhC0bMOs+COfBPfQjxY7Ha8 GSjnDnOcwie5r+MAowZ3eZytmRqRzCo4U2RsTVePpmansSRth40zlZLpBlsiNU0rEhDb ipS+hiRoBOv37qjeVrEIQ0TP0wGyF1cMKNOa7f2XNVBzBh+3YwnP1XwLwitz8YXCm5J5 zJ8IzTb2Owb6KbAqaQ+oVtFU/8tiLeDC1fX3gT+/PmRRU7LMqy7zMjsxEb9gDGTAC5aK Bsvwl4IcOWOj1rjY0uDrZdTGJPDIVujB39Ef84i27TcfOgeo7+gTqYs7kf2hwoHNeNbk RPkw== X-Gm-Message-State: AOAM532RTK4JuJSoD+dBQ8vvEUaHU30R0lDFNh/1VjABU/sj+F20coYd O1DuZF0scm2PPFx5XVfAcD+oElROx/THCw== X-Google-Smtp-Source: ABdhPJx4yTAHUWHtzEXcqnx00gEFZFjP7TG1bALA0XmwAKM9UVXczPvofWdN38j83/8PdoxCGhuDGg== X-Received: by 2002:a05:6000:188:: with SMTP id p8mr7296289wrx.84.1644519891164; Thu, 10 Feb 2022 11:04:51 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id o10sm21794816wri.19.2022.02.10.11.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 11:04:50 -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 1/7] HID: uclogic: Support Huion tilt reporting Date: Thu, 10 Feb 2022 20:04:31 +0100 Message-Id: <20220210190437.50152-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210190437.50152-1-jose.exposito89@gmail.com> References: <20220210190437.50152-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 Huion v2 protocol tilt reporting. Describe reports as angles in degrees, which is not exactly true, but there doesn't seem to be a straightforward, consistent conversion possible, and what's reported would have to be enough. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 3 +++ drivers/hid/hid-uclogic-params.c | 1 + drivers/hid/hid-uclogic-params.h | 8 ++++++++ drivers/hid/hid-uclogic-rdesc.c | 12 +++++++++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index d8ab0139e5cd..823704bc02ef 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -304,6 +304,9 @@ static int uclogic_raw_event(struct hid_device *hdev, mod_timer(&drvdata->inrange_timer, jiffies + msecs_to_jiffies(100)); } + /* If we report tilt and Y direction is flipped */ + if (size >= 12 && params->pen.tilt_y_flipped) + data[11] = -data[11]; } /* Tweak frame control reports, if necessary */ diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 3e70f969fb84..30e0f69ed5af 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -369,6 +369,7 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen, pen->id = UCLOGIC_RDESC_PEN_V2_ID; pen->inrange = UCLOGIC_PARAMS_PEN_INRANGE_NONE; pen->fragmented_hires = true; + pen->tilt_y_flipped = true; found = true; finish: *pfound = found; diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index ba48b1c7a0e5..e8381bb77bd0 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -62,6 +62,12 @@ struct uclogic_params_pen { * Only valid if "id" is not zero. */ bool fragmented_hires; + /* + * True if the pen reports tilt in bytes at offset 10 (X) and 11 (Y), + * and the Y tilt direction is flipped. + * Only valid if "id" is not zero. + */ + bool tilt_y_flipped; }; /* @@ -171,6 +177,7 @@ extern int uclogic_params_init(struct uclogic_params *params, ".pen.id = %u\n" \ ".pen.inrange = %s\n" \ ".pen.fragmented_hires = %s\n" \ + ".pen.tilt_y_flipped = %s\n" \ ".frame.desc_ptr = %p\n" \ ".frame.desc_size = %u\n" \ ".frame.id = %u\n" \ @@ -189,6 +196,7 @@ extern int uclogic_params_init(struct uclogic_params *params, (_params)->pen.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.desc_ptr, \ (_params)->frame.desc_size, \ (_params)->frame.id, \ diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index 6dd6dcd09c8b..2607cbdf8ff2 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -633,7 +633,17 @@ const __u8 uclogic_rdesc_pen_v2_template_arr[] = { 0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM), /* Logical Maximum (PLACEHOLDER), */ 0x81, 0x02, /* Input (Variable), */ - 0x81, 0x03, /* Input (Constant, Variable), */ + 0x54, /* Unit Exponent (0), */ + 0x65, 0x14, /* Unit (Degrees), */ + 0x35, 0xC4, /* Physical Minimum (-60), */ + 0x45, 0x3C, /* Physical Maximum (60), */ + 0x15, 0xC4, /* Logical Minimum (-60), */ + 0x25, 0x3C, /* Logical Maximum (60), */ + 0x75, 0x08, /* Report Size (8), */ + 0x95, 0x02, /* Report Count (2), */ + 0x09, 0x3D, /* Usage (X Tilt), */ + 0x09, 0x3E, /* Usage (Y Tilt), */ + 0x81, 0x02, /* Input (Variable), */ 0xC0, /* End Collection, */ 0xC0 /* End Collection */ }; From patchwork Thu Feb 10 19:04: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: 541944 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 D7E53C433EF for ; Thu, 10 Feb 2022 19:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343596AbiBJTEx (ORCPT ); Thu, 10 Feb 2022 14:04:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343638AbiBJTEw (ORCPT ); Thu, 10 Feb 2022 14:04:52 -0500 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 589A5100C; Thu, 10 Feb 2022 11:04:53 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id w11so11301834wra.4; Thu, 10 Feb 2022 11:04:53 -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=nAA6pdXjhS4D3IAaxQTjb/m0O26X1sZm/YouSY/spQ4=; b=k4Ntv0iA4bcSn3GKu4B5DCKss5zKxFD9bXP0NXImDtZXvuHLj20oT09ZHOPNHRMdA2 cSa3ByaYh4oL6PPus9JCLqCJAH+LJ3g8o4LzY7ktZsiVOBvgFcQIllvA3/bm/uR0KOTM 9ZRiIygS8OhYuEeA9uLNhzHrMvVSR0nYdFz1TK5zpdaGyiEvnTZIb1ljCBuGzCUksmYt lmrzCF8s4+4VQbDDZEfJeCqG765alaTYqU8xIPF2Ps40G7Mv72M9R8bgMoRDd3SXvS0l p/Zqih51TrB2iY15bbf3iZygA+U6zJqin30OjhoqD1/NqDL0zV8Ppjkphc7gcX8AgpRa QfAg== 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=nAA6pdXjhS4D3IAaxQTjb/m0O26X1sZm/YouSY/spQ4=; b=Zt0BLfLQaSSZ/bSVFNgl1MEsBR5LOY9sm+rJm+ei4pb+Qnfz1W3BVZZhxuDTbReaUV vHE6WiQd9e2LIlArMYsbBxRAVHvYaETEHpc7GiPIj+5oKyCWUyh92BR+vBDy5CHD4Gms FHkIniSdfVjl2VefpiQeOL4aafNXI13XW4obizf1D/imGGk5/i5BbQyUFFspTnJAYZGc bVLQlmnP2I0NDzgfOr2Z7i6bjn0UY//goA+v0U/VoHxRa+E6X3Ciyvz3wNtpydKM3BrT xX0U5yMW8OQfI+oYMgfHAL+uZbUiGen/mAmInBKwGqP6WzROsDrytATznc+hjQsHa97j fibg== X-Gm-Message-State: AOAM530GKAMsHlDN+k4X5DRdP1ohgDtEcN18TD4k9bBUSg27pJ0RKM9V U3LeQK7st3frhGkjGtnQg3w= X-Google-Smtp-Source: ABdhPJyNtQjpApuEhj3jDG1SUuj2eAEid6s6WwsVI73LthRdOf83jyNUs0TPALyr31cuO+1JlffOmw== X-Received: by 2002:a5d:6143:: with SMTP id y3mr7567484wrt.556.1644519891963; Thu, 10 Feb 2022 11:04:51 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id o10sm21794816wri.19.2022.02.10.11.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 11:04:51 -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 2/7] HID: uclogic: Rename Huion HS64 PID to Huion Tablet 2 Date: Thu, 10 Feb 2022 20:04:32 +0100 Message-Id: <20220210190437.50152-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210190437.50152-1-jose.exposito89@gmail.com> References: <20220210190437.50152-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Since the 006d Huion PID is used by multiple tablets (at least HS64 and HS610), rename its constant to a more general "USB_DEVICE_ID_HUION_TABLET2". Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-ids.h | 2 +- drivers/hid/hid-uclogic-core.c | 2 +- drivers/hid/hid-uclogic-params.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 85975031389b..10780a076693 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -606,7 +606,7 @@ #define USB_VENDOR_ID_HUION 0x256c #define USB_DEVICE_ID_HUION_TABLET 0x006e -#define USB_DEVICE_ID_HUION_HS64 0x006d +#define USB_DEVICE_ID_HUION_TABLET2 0x006d #define USB_VENDOR_ID_IBM 0x04b3 #define USB_DEVICE_ID_IBM_SCROLLPOINT_III 0x3100 diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 823704bc02ef..850c660ec2ab 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -376,7 +376,7 @@ static const struct hid_device_id uclogic_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) }, { HID_USB_DEVICE(USB_VENDOR_ID_HUION, - USB_DEVICE_ID_HUION_HS64) }, + USB_DEVICE_ID_HUION_TABLET2) }, { HID_USB_DEVICE(USB_VENDOR_ID_TRUST, USB_DEVICE_ID_TRUST_PANORA_TABLET) }, { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 30e0f69ed5af..98910d8dae92 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -993,7 +993,7 @@ int uclogic_params_init(struct uclogic_params *params, case VID_PID(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET): case VID_PID(USB_VENDOR_ID_HUION, - USB_DEVICE_ID_HUION_HS64): + USB_DEVICE_ID_HUION_TABLET2): case VID_PID(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_HUION_TABLET): case VID_PID(USB_VENDOR_ID_UCLOGIC, From patchwork Thu Feb 10 19:04: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: 541943 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 4496BC4332F for ; Thu, 10 Feb 2022 19:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343646AbiBJTEy (ORCPT ); Thu, 10 Feb 2022 14:04:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343632AbiBJTEx (ORCPT ); Thu, 10 Feb 2022 14:04:53 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E64C100C; Thu, 10 Feb 2022 11:04:54 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id n8so4036947wmk.3; Thu, 10 Feb 2022 11:04:54 -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=ZXd3/jskGjTWmhBRtSHB5dWP3UeubOqYdsG1HEGhcGc=; b=cfYxogM1ADU/8WqEwxEoGdZv2gw+K4ObDr4bcWIUG4nvDWNsN9+KkS0/zqA3xl9VX5 KVI5DRyEAsJ4NdT3joax/BEjoQxgM4IPnToqRwUPwekQ9sZsZmNelks0Q2BhRiV5Jnvj 9hDWObpS+ZR7xYwvjK1JS67WFbN5sgjysoeamTzVLXUKzqR8wez2hM8l7GBxoPH16NNy K+syjQgsSr+pcHeW0a/NYZlxWXfAMRe+KC1nLIPTgRmmqg5+1HkZUsyYIusWJBKqg6Lh dh8ZeLupqu+e6+OVKeFiMqnAhHos9kmNtHrN+9CC+BDyIDRdOndBvCkARqWrGj+tJ5DV TYuQ== 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=ZXd3/jskGjTWmhBRtSHB5dWP3UeubOqYdsG1HEGhcGc=; b=YhHQKgYe7Ki+iRY1kG3IEF4J6pBbKgisxq92VYOAUGKRtFoxlO5PoZHmlY7UjwDiFg yvRvvK1tVHk14BGaiB628oM7ZqqVEzCz7wrutwZrPR32nV+DmeeOlpVTyfdQ5TMjyzd9 tLVLDKMnKhmGDWZ65fpfwmUtyJ7/gc9zTtuEzSTieC0m7+uf+5YP8qn+0oRNqDiAT1tI iBb1WidB5gGFYnJHJ+pl4EAKlCiAcBPq3hvO3Mf2cZ4+964TjUPgmRIuFsisn+8cB0X9 jJ9RkFJorhbL5Um0eJRTKwO2Xxi5ZG0pGZhw4AVjhtHCjYq+i1cW7kSOt/sUOZ/nQEL6 fsgA== X-Gm-Message-State: AOAM532T63eT/dqBVySO7TNVBIVds5jAQdmv0VA1f1vZFnK5CcjU3Iga fvCN4tBuHqepbsNHTrsrwsA= X-Google-Smtp-Source: ABdhPJwUqnA/XWrFtrJomP5/5yYmCObWzQszd8Tx6uhGEvVICKqtOvigtMqUfxuzXM9g95L9/quYPg== X-Received: by 2002:a7b:c350:: with SMTP id l16mr3244793wmj.146.1644519892785; Thu, 10 Feb 2022 11:04:52 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id o10sm21794816wri.19.2022.02.10.11.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 11:04:52 -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 3/7] HID: uclogic: Support Huion 13th frame button Date: Thu, 10 Feb 2022 20:04:33 +0100 Message-Id: <20220210190437.50152-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210190437.50152-1-jose.exposito89@gmail.com> References: <20220210190437.50152-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 reporting 13th frame button for Huion tablets. This supports reporting the button in the center of the dial for Huion HS610. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-rdesc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index 2607cbdf8ff2..ec16355d200b 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -689,8 +689,8 @@ const size_t uclogic_rdesc_pen_v2_template_size = 0xA0, /* Collection (Physical), */ \ 0x05, 0x09, /* Usage Page (Button), */ \ 0x19, 0x01, /* Usage Minimum (01h), */ \ - 0x29, 0x02, /* Usage Maximum (02h), */ \ - 0x95, 0x02, /* Report Count (2), */ \ + 0x29, 0x03, /* Usage Maximum (03h), */ \ + 0x95, 0x03, /* Report Count (3), */ \ 0x81, 0x02, /* Input (Variable), */ \ 0x95, _padding, /* Report Count (_padding), */ \ 0x81, 0x01, /* Input (Constant), */ \ @@ -699,14 +699,14 @@ const size_t uclogic_rdesc_pen_v2_template_size = /* Fixed report descriptor for (tweaked) v1 buttonpad reports */ const __u8 uclogic_rdesc_buttonpad_v1_arr[] = { - UCLOGIC_RDESC_BUTTONPAD_BYTES(20) + UCLOGIC_RDESC_BUTTONPAD_BYTES(19) }; const size_t uclogic_rdesc_buttonpad_v1_size = sizeof(uclogic_rdesc_buttonpad_v1_arr); /* Fixed report descriptor for (tweaked) v2 buttonpad reports */ const __u8 uclogic_rdesc_buttonpad_v2_arr[] = { - UCLOGIC_RDESC_BUTTONPAD_BYTES(52) + UCLOGIC_RDESC_BUTTONPAD_BYTES(51) }; const size_t uclogic_rdesc_buttonpad_v2_size = sizeof(uclogic_rdesc_buttonpad_v2_arr); From patchwork Thu Feb 10 19:04: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: 541598 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 78ECFC43217 for ; Thu, 10 Feb 2022 19:04:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343643AbiBJTEz (ORCPT ); Thu, 10 Feb 2022 14:04:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343649AbiBJTEz (ORCPT ); Thu, 10 Feb 2022 14:04:55 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EFDF10BA; Thu, 10 Feb 2022 11:04:55 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id x3-20020a05600c21c300b0037c01ad715bso1581736wmj.2; Thu, 10 Feb 2022 11:04:55 -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=9ldkbEk4Ot0+c2jkb2wLX+CD6aUDq3RF/PTF3GMpQmA=; b=ZsTazNhRiUDa2uCyCVxXhCKANmWAfIIWrKzWI9hrKiiYeCk5vIOgUzxNZI50mDZ00X JPMm8qEtmrXY/9eA8nuQJ/dhqjANGfYiggqQlM5/XIf+/aVd7+yzs4Ivaceep5U3pAkp 7oJsCKqvnTywszFINkJsbEa1wPHMjTI8pdipvjJRsBIpFxMtFy8LtxgZfLS34i3hMzeF 5ViM0pvLRZ7oJEDrsJgROegP+MMb6Qt/ZLNGUMhERzUK6N3LzDzdqgxTScHaYLqfWTtu lZlusHcXqy5JDQV4HAiCzv2g5Tovw+Ya2s6GK7bWE+gBnUpln1PxlnlJvBUQo67kyntH 2x5g== 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=9ldkbEk4Ot0+c2jkb2wLX+CD6aUDq3RF/PTF3GMpQmA=; b=zIDrsskgpc7pJcIRlOBqe5hntP406FS/Yzyq976EGr0xGHZpIdCx2CxXyg+8hCmFmP xa2tG0NcVrdOkVNWkHb/O9Tw1MyO7rsrK1pTitGq4g6NHUZccDI3I5D0T0wslq0fzz+a RMroHS95E+HUZ+UwHtbnlY2K+/QWbwfHdZ7NVSGf8S47zCL8nqHsKLB/dbFPtdwfcSFf XEPmAVxQla+14iXQpVwXfaUDxQZ4qNMIw1iZymq3oDbFJcemdHf1buPR23WIIWfwdnlc H+LSphTzZKbha3/XxMkUu7VP0J7ExY4JTQBILXdLk7Kjmg4+dV+68A55Wdk+YbVthGfj K2sw== X-Gm-Message-State: AOAM532oX+LOKoCy0PL20XQD7ZvxEmvfkNg5q/ilo10BlYZwwCTrQ9DR UehSB1rRUZwWTf1ggaPLRTiIM7d4e5sYKA== X-Google-Smtp-Source: ABdhPJxvcmFn3FCRhMI/RD4mHKKCrWK2L157C6o6psrEVZ95zkuyHEWR8A25hwlCMllL271+Sxfriw== X-Received: by 2002:a05:600c:4ca1:: with SMTP id g33mr3391418wmp.108.1644519893640; Thu, 10 Feb 2022 11:04:53 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id o10sm21794816wri.19.2022.02.10.11.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 11:04:53 -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 4/7] HID: uclogic: Split pen and frame raw event handling Date: Thu, 10 Feb 2022 20:04:34 +0100 Message-Id: <20220210190437.50152-5-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210190437.50152-1-jose.exposito89@gmail.com> References: <20220210190437.50152-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov In order to avoid ending up with a big uclogic_raw_event function, split it in two smaller functions: uclogic_raw_event_pen for the pen events and uclogic_raw_event_frame for the pad events. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 195 ++++++++++++++++++++------------- 1 file changed, 120 insertions(+), 75 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 850c660ec2ab..9187fd835a46 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -246,6 +246,123 @@ static int uclogic_resume(struct hid_device *hdev) } #endif +/** + * uclogic_raw_event_pen - handle raw pen events (pen HID reports). + * + * @drvdata: Driver data. + * @data: Report data buffer, can be modified. + * @size: Report data size, bytes. + * + * Returns: + * Negative value on error (stops event delivery), zero for success. + */ +static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata, + u8 *data, int size) +{ + struct uclogic_params *params = &drvdata->params; + + WARN_ON(drvdata == NULL); + WARN_ON(data == NULL && size != 0); + + /* If in-range reports are inverted */ + if (params->pen.inrange == + UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) { + /* Invert the in-range bit */ + data[1] ^= 0x40; + } + /* + * If report contains fragmented high-resolution pen + * coordinates + */ + if (size >= 10 && params->pen.fragmented_hires) { + u8 pressure_low_byte; + u8 pressure_high_byte; + + /* Lift pressure bytes */ + pressure_low_byte = data[6]; + pressure_high_byte = data[7]; + /* + * Move Y coord to make space for high-order X + * coord byte + */ + data[6] = data[5]; + data[5] = data[4]; + /* Move high-order X coord byte */ + data[4] = data[8]; + /* Move high-order Y coord byte */ + data[7] = data[9]; + /* Place pressure bytes */ + data[8] = pressure_low_byte; + data[9] = pressure_high_byte; + } + /* If we need to emulate in-range detection */ + if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) { + /* Set in-range bit */ + data[1] |= 0x40; + /* (Re-)start in-range timeout */ + mod_timer(&drvdata->inrange_timer, + jiffies + msecs_to_jiffies(100)); + } + /* If we report tilt and Y direction is flipped */ + if (size >= 12 && params->pen.tilt_y_flipped) + data[11] = -data[11]; + + return 0; +} + +/** + * uclogic_raw_event_frame - handle raw frame events (frame HID reports). + * + * @drvdata: Driver data. + * @data: Report data buffer, can be modified. + * @size: Report data size, bytes. + * + * Returns: + * Negative value on error (stops event delivery), zero for success. + */ +static int uclogic_raw_event_frame(struct uclogic_drvdata *drvdata, + u8 *data, int size) +{ + struct uclogic_params *params = &drvdata->params; + + WARN_ON(drvdata == NULL); + WARN_ON(data == NULL && size != 0); + + /* If need to, and can, set pad device ID for Wacom drivers */ + if (params->frame.dev_id_byte > 0 && + params->frame.dev_id_byte < size) { + data[params->frame.dev_id_byte] = 0xf; + } + /* If need to, and can, read rotary encoder state change */ + if (params->frame.re_lsb > 0 && + params->frame.re_lsb / 8 < size) { + unsigned int byte = params->frame.re_lsb / 8; + unsigned int bit = params->frame.re_lsb % 8; + + u8 change; + u8 prev_state = drvdata->re_state; + /* Read Gray-coded state */ + u8 state = (data[byte] >> bit) & 0x3; + /* Encode state change into 2-bit signed integer */ + if ((prev_state == 1 && state == 0) || + (prev_state == 2 && state == 3)) { + change = 1; + } else if ((prev_state == 2 && state == 0) || + (prev_state == 1 && state == 3)) { + change = 3; + } else { + change = 0; + } + /* Write change */ + data[byte] = (data[byte] & ~((u8)3 << bit)) | + (change << bit); + /* Remember state */ + drvdata->re_state = state; + } + + return 0; +} + static int uclogic_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) @@ -265,85 +382,13 @@ static int uclogic_raw_event(struct hid_device *hdev, data[0] = params->frame.id; return 0; } - /* If in-range reports are inverted */ - if (params->pen.inrange == - UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) { - /* Invert the in-range bit */ - data[1] ^= 0x40; - } - /* - * If report contains fragmented high-resolution pen - * coordinates - */ - if (size >= 10 && params->pen.fragmented_hires) { - u8 pressure_low_byte; - u8 pressure_high_byte; - - /* Lift pressure bytes */ - pressure_low_byte = data[6]; - pressure_high_byte = data[7]; - /* - * Move Y coord to make space for high-order X - * coord byte - */ - data[6] = data[5]; - data[5] = data[4]; - /* Move high-order X coord byte */ - data[4] = data[8]; - /* Move high-order Y coord byte */ - data[7] = data[9]; - /* Place pressure bytes */ - data[8] = pressure_low_byte; - data[9] = pressure_high_byte; - } - /* If we need to emulate in-range detection */ - if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) { - /* Set in-range bit */ - data[1] |= 0x40; - /* (Re-)start in-range timeout */ - mod_timer(&drvdata->inrange_timer, - jiffies + msecs_to_jiffies(100)); - } - /* If we report tilt and Y direction is flipped */ - if (size >= 12 && params->pen.tilt_y_flipped) - data[11] = -data[11]; + return uclogic_raw_event_pen(drvdata, data, size); } /* Tweak frame control reports, if necessary */ if ((report->type == HID_INPUT_REPORT) && - (report->id == params->frame.id)) { - /* If need to, and can, set pad device ID for Wacom drivers */ - if (params->frame.dev_id_byte > 0 && - params->frame.dev_id_byte < size) { - data[params->frame.dev_id_byte] = 0xf; - } - /* If need to, and can, read rotary encoder state change */ - if (params->frame.re_lsb > 0 && - params->frame.re_lsb / 8 < size) { - unsigned int byte = params->frame.re_lsb / 8; - unsigned int bit = params->frame.re_lsb % 8; - - u8 change; - u8 prev_state = drvdata->re_state; - /* Read Gray-coded state */ - u8 state = (data[byte] >> bit) & 0x3; - /* Encode state change into 2-bit signed integer */ - if ((prev_state == 1 && state == 0) || - (prev_state == 2 && state == 3)) { - change = 1; - } else if ((prev_state == 2 && state == 0) || - (prev_state == 1 && state == 3)) { - change = 3; - } else { - change = 0; - } - /* Write change */ - data[byte] = (data[byte] & ~((u8)3 << bit)) | - (change << bit); - /* Remember state */ - drvdata->re_state = state; - } - } + (report->id == params->frame.id)) + return uclogic_raw_event_frame(drvdata, data, size); return 0; } From patchwork Thu Feb 10 19:04:35 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: 541942 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 ABF66C433F5 for ; Thu, 10 Feb 2022 19:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240329AbiBJTE4 (ORCPT ); Thu, 10 Feb 2022 14:04:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343640AbiBJTEz (ORCPT ); Thu, 10 Feb 2022 14:04:55 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E48DA10B7; Thu, 10 Feb 2022 11:04:55 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id l67-20020a1c2546000000b00353951c3f62so4654278wml.5; Thu, 10 Feb 2022 11:04:55 -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=h0dKpXxaUtAsD11niFXfJyE8HvZXdWYUwT2HA9JjgyI=; b=VwrPBLS3kvrDNJso5J6IkeGM0czo59+D+dJC6JI5qtcQdximtABtnahFiEWapGe2WX aILjfkrLG9+/j+W9lDzBiSRufUZOoq/Hm9P6BMTy/YgkduEER8A+jQR81NMUvGxPk7Tf pROQCoKUEXW8WawtTv3GhJt5id/+Kp4b1+mGOeeeBUTUNEv0BAs82ggQmSy0f4oQe62A TnUiUK1J0Kq3ZuicPnQDrtJVvVqgPFI9QZytCg8Qbc4OPLPX+YNCQ6H5Ne4l2yk4npg4 usOJGk2LS6t4DttOe4W5OHy5uChojj7kOU2XQpitI4AGKReW535goe622h3dT9UoJD1Q 1Spw== 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=h0dKpXxaUtAsD11niFXfJyE8HvZXdWYUwT2HA9JjgyI=; b=2Z2AsMC16LNjZVuLeLKe2ClZ23HbVJPFxlKI+O2A4VR8brJYvzBtQRB+0EmwHafACs 0LF6XTAeFw+hS4Qws6IVBXQxaT2etS01nTAEy5CtZt6atvaHzQHdCfXT3BlOAOU6PfUl Rn+qDQ3eFArhI8AY/PwVEOl+Ua6qbzOb1oMRS0QVTsF17/q/8UpczmMtZ9JL68SfCtMM NG8/F3uNIzu2fO1uvei5kQ9IvWkpll4OVxMkxsm1A9SNuI2wtK7qjr+h+hB3tZ7sayd5 kCiLIP6ugjSr764iGLvHqXBHTA1b3yQvMtXdwh2n5zZWdsVwAZYI2WoiyUfklvjQcJXN xzbQ== X-Gm-Message-State: AOAM531Ssw/tEELCBtAFNT7cIokFsgyvIY7c7uoxPKb6ooFg3CDXNX8H i73AQd/ntsq5x/CYjxPo1XDrK8QCOG9zlA== X-Google-Smtp-Source: ABdhPJxd7cJISj2v0Z3mMR3BqsrxrGgPS9TkulmWg4EEppHoA6rt9ERKIaIuFGbtQvt7heulhYmORQ== X-Received: by 2002:a05:600c:35c8:: with SMTP id r8mr3329529wmq.142.1644519894480; Thu, 10 Feb 2022 11:04:54 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id o10sm21794816wri.19.2022.02.10.11.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 11:04:54 -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 5/7] HID: uclogic: Access pen/frame params directly in raw_event handling Date: Thu, 10 Feb 2022 20:04:35 +0100 Message-Id: <20220210190437.50152-6-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210190437.50152-1-jose.exposito89@gmail.com> References: <20220210190437.50152-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Simplify the raw event handling code by accessing the uclogic_params_pen/uclogic_params_frame structs directly. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 9187fd835a46..56b76d9b46af 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -259,13 +259,13 @@ static int uclogic_resume(struct hid_device *hdev) static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata, u8 *data, int size) { - struct uclogic_params *params = &drvdata->params; + struct uclogic_params_pen *pen = &drvdata->params.pen; WARN_ON(drvdata == NULL); WARN_ON(data == NULL && size != 0); /* If in-range reports are inverted */ - if (params->pen.inrange == + if (pen->inrange == UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) { /* Invert the in-range bit */ data[1] ^= 0x40; @@ -274,7 +274,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata, * If report contains fragmented high-resolution pen * coordinates */ - if (size >= 10 && params->pen.fragmented_hires) { + if (size >= 10 && pen->fragmented_hires) { u8 pressure_low_byte; u8 pressure_high_byte; @@ -296,7 +296,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata, data[9] = pressure_high_byte; } /* If we need to emulate in-range detection */ - if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) { + if (pen->inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) { /* Set in-range bit */ data[1] |= 0x40; /* (Re-)start in-range timeout */ @@ -304,7 +304,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata, jiffies + msecs_to_jiffies(100)); } /* If we report tilt and Y direction is flipped */ - if (size >= 12 && params->pen.tilt_y_flipped) + if (size >= 12 && pen->tilt_y_flipped) data[11] = -data[11]; return 0; @@ -323,21 +323,19 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata, static int uclogic_raw_event_frame(struct uclogic_drvdata *drvdata, u8 *data, int size) { - struct uclogic_params *params = &drvdata->params; + struct uclogic_params_frame *frame = &drvdata->params.frame; WARN_ON(drvdata == NULL); WARN_ON(data == NULL && size != 0); /* If need to, and can, set pad device ID for Wacom drivers */ - if (params->frame.dev_id_byte > 0 && - params->frame.dev_id_byte < size) { - data[params->frame.dev_id_byte] = 0xf; + if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) { + data[frame->dev_id_byte] = 0xf; } /* If need to, and can, read rotary encoder state change */ - if (params->frame.re_lsb > 0 && - params->frame.re_lsb / 8 < size) { - unsigned int byte = params->frame.re_lsb / 8; - unsigned int bit = params->frame.re_lsb % 8; + if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) { + unsigned int byte = frame->re_lsb / 8; + unsigned int bit = frame->re_lsb % 8; u8 change; u8 prev_state = drvdata->re_state; From patchwork Thu Feb 10 19:04:36 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: 541597 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 41703C433FE for ; Thu, 10 Feb 2022 19:05:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343674AbiBJTE6 (ORCPT ); Thu, 10 Feb 2022 14:04:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343653AbiBJTE4 (ORCPT ); Thu, 10 Feb 2022 14:04:56 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A123C1084; Thu, 10 Feb 2022 11:04:56 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id m14so11223708wrg.12; Thu, 10 Feb 2022 11:04:56 -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=FHzlUdZJZAbrkir44zct42ZxWDwZutaTx2Vvtix3Wsk=; b=QtyNOwJlEwfIlA1ACJIS9aSGj9/JdtURJRuW3a5+/nH41Cz9p/J6jxM8MBncRmZDks 7xFIOaPp21W8f2vAkIrivTZkSH4xGSuO8nhzWILbi0dVBUOq5QEsk7GDzVOShZzgU3oC ne+E0qV5zyuzEuawaZw8eXJGGuLFp7xFq4Zk9M8r85qVnwFwzw+2/I2daWCmsNytB/lf K46F47os3erFsHeqyEYZTg+ILLCCNgULXGgHdgTAWBc03RjzWV/1pPMKjm+9fxAsjIBr NHhFX6osrQgsdoaCJ6BjpUCrCH1LdcG5tXRXDYYZ56qOrdCC5io+GhMy9PXvNKxC1ukj gmLg== 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=FHzlUdZJZAbrkir44zct42ZxWDwZutaTx2Vvtix3Wsk=; b=GJtsyFNj0G15t3LJztKkDlLC0hjdOIMzoMyJlKwOEPLVATkv2Z6DG7IuZCGmlE7eU0 N6uliPNUn4HMY7083ps0inancWFndSBJfXRphUADmfki8u44afh/HjRaC7++gtKoHFdv VA3rsSzpHPCcIjXbpvA1+eSiTYje899bF23KpvT+GuSGtFfnKsRxierZI60yowHV7Nsq FMLu/q++cQ4DNXc/yZLg+fwazZn5sPxYx6Z7Zh38QWRoAdqZaj9jOjxGt1VtotXlB46c 9NwmnIj3WqMvN/4lbGGYLwPOC+8O9B8zxoCpuKchk6wXeQWu6DcmGhqBD/970tThA6qj bPjw== X-Gm-Message-State: AOAM533wxxlPUg8Re9o0d2otHOvU1AK1Kvt8piEtWdH4unMwgnL2NW1y C+UrMwnLjpvI0wkAygob2VhWDdjC+G+Ceg== X-Google-Smtp-Source: ABdhPJyH+Tm5WjJ41gpAy7HUaLhca8G0gg3aX+B++QVCyqE/ifCkKie+piD9OEjsP2ZY8Oym7x4aXA== X-Received: by 2002:adf:e9c8:: with SMTP id l8mr7677639wrn.415.1644519895257; Thu, 10 Feb 2022 11:04:55 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id o10sm21794816wri.19.2022.02.10.11.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 11:04:54 -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 6/7] HID: uclogic: Skip non-input raw events earlier Date: Thu, 10 Feb 2022 20:04:36 +0100 Message-Id: <20220210190437.50152-7-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210190437.50152-1-jose.exposito89@gmail.com> References: <20220210190437.50152-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Early return when a non-input raw event is received to simplify the logic present in uclogic_raw_event. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 56b76d9b46af..8aac3f7a9cda 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -368,9 +368,12 @@ static int uclogic_raw_event(struct hid_device *hdev, struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); struct uclogic_params *params = &drvdata->params; + /* Do not handle anything but input reports */ + if (report->type != HID_INPUT_REPORT) + return 0; + /* Tweak pen reports, if necessary */ if (!params->pen_unused && - (report->type == HID_INPUT_REPORT) && (report->id == params->pen.id) && (size >= 2)) { /* If it's the "virtual" frame controls report */ @@ -384,8 +387,7 @@ static int uclogic_raw_event(struct hid_device *hdev, } /* Tweak frame control reports, if necessary */ - if ((report->type == HID_INPUT_REPORT) && - (report->id == params->frame.id)) + if (report->id == params->frame.id) return uclogic_raw_event_frame(drvdata, data, size); return 0; From patchwork Thu Feb 10 19:04:37 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: 541941 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 0FF57C433F5 for ; Thu, 10 Feb 2022 19:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343680AbiBJTE7 (ORCPT ); Thu, 10 Feb 2022 14:04:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343639AbiBJTE4 (ORCPT ); Thu, 10 Feb 2022 14:04:56 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C6F101C; Thu, 10 Feb 2022 11:04:57 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id d27so11285454wrc.6; Thu, 10 Feb 2022 11:04:57 -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=/bUjkAoGmX2Zqi1ukJ2KlNTT2xXfzfE5qe09S4uZ1wY=; b=Cl5lcgI0Zg832TiBScaF9MHoC5PnobHknIGbMhcY4SqKqOxhJ47rMOA3BGAeploEge 3RubnvdFsSTc1JxAfbt5/HNnnzCzHaIIj91OeMkFgoSkURS2dNpbb4H9CR4Zb7k62dzp EQfryhLeFMPm6KM7nABOeSXWCTfeA9rR/hcfjj/+hUajqIDVZKBEuWt/8WFF67LaMyxy raW/n8eskUbGC23BQ+E+oqPbNUte16S1xgIkDFtgrAk5HJmK0crQimg5GN+tmRsVCdZ5 GeH6bNnOfAO5n2YvWyhhKJVeUx2RlIOxu9JJNVaMkTDVVxhR5dp8TXTeijQu/fciSBcu TGHA== 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=/bUjkAoGmX2Zqi1ukJ2KlNTT2xXfzfE5qe09S4uZ1wY=; b=bbyKeTAG4uZ8NBRzGFUs+SbFOBcQ5cQfyAFMWDwu9COU1Ge3s5kPp1dNYY34t9sitL oPPt17rPIOR+Ek84dH9mNAD3Ws0wPPEPCIJmtGHL5tqULY4A4LjjJaMGX4Y1r8kMLXSd mSN4AtXvBvGqw53Gj5BUcpM7yWfGHXlVyaCQEn6RAB9oJU913lfPF7LONvIE0WrjDAIC 4I6NEHNyYzVQWJ+hPWruXDm9Eki2Y5ghFN9cN/qxBJuWJHcSyYXA3nMqJZ0UVmmY0ChT mFeYApzDu8i67tFw+xn3CvHngAaruMIvcfx7XY9YaFLgiQu5ce0DmNEQcSsyLON8I4pK 89/g== X-Gm-Message-State: AOAM5300QgdhKqSj/gchTIiffylGTnMkcsQAbB8R+JDIqewBrC+X0Weu KX/72p37IS2xC1/n2AC/qzE= X-Google-Smtp-Source: ABdhPJx2S3NdfZg3QtmUIU9xyhIwzINEcHfnOGC7ZXhHAP5460Iqj1yI+Lxx0rFTj0zGp0BxW9pEZQ== X-Received: by 2002:a5d:54d0:: with SMTP id x16mr5862417wrv.280.1644519896011; Thu, 10 Feb 2022 11:04:56 -0800 (PST) Received: from localhost.localdomain ([94.73.33.246]) by smtp.gmail.com with ESMTPSA id o10sm21794816wri.19.2022.02.10.11.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 11:04:55 -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 7/7] HID: uclogic: Handle virtual frame reports Date: Thu, 10 Feb 2022 20:04:37 +0100 Message-Id: <20220210190437.50152-8-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210190437.50152-1-jose.exposito89@gmail.com> References: <20220210190437.50152-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nikolai Kondrashov Explicitly change report ID to virtual ID and handle virtual frame reports as real for consistency. Signed-off-by: Nikolai Kondrashov Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 8aac3f7a9cda..73d79d149869 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -365,6 +365,7 @@ static int uclogic_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) { + unsigned int report_id = report->id; struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev); struct uclogic_params *params = &drvdata->params; @@ -374,20 +375,20 @@ static int uclogic_raw_event(struct hid_device *hdev, /* Tweak pen reports, if necessary */ if (!params->pen_unused && - (report->id == params->pen.id) && + (report_id == params->pen.id) && (size >= 2)) { /* If it's the "virtual" frame controls report */ if (params->frame.id != 0 && data[1] & params->pen_frame_flag) { /* Change to virtual frame controls report ID */ - data[0] = params->frame.id; - return 0; + report_id = data[0] = params->frame.id; + } else { + return uclogic_raw_event_pen(drvdata, data, size); } - return uclogic_raw_event_pen(drvdata, data, size); } /* Tweak frame control reports, if necessary */ - if (report->id == params->frame.id) + if (report_id == params->frame.id) return uclogic_raw_event_frame(drvdata, data, size); return 0;