From patchwork Mon Sep 9 20:32:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 827164 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C02913B2B0 for ; Mon, 9 Sep 2024 20:32:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725913934; cv=none; b=JG5UUm9FLo9vKJkThXPD9NU2YKcBXxCcE2cRf1vZAaJYCnRj0MtlTDb+rdE2mQViMjdJ6LCTWYYTxrglbp7wBDyUn2POcOkU61ycLOwEO4t0RrESfo8/pFC0NXKPTMzalzCdeltH38OPDT4jh3c5UM0cWRoiCZlrPtew4dMClsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725913934; c=relaxed/simple; bh=kbKiqmucJyArKgR3xr50CXFA7M+DUcILpDwu7OHBxF4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=o+hwA9gGGEqI2D2lxe9ChJx0N6tLztMR16hCf28T6PLmWZHhXikf7liUYBqdVhwA0PC5IOoZo7y4Ci2RdBCRZN/wrb8ymYmFJYmGb9FZeGVNSn1WA/Ic3k0cjpm9zFOruYmoE8jJaAPZ/r9VG9BdrIy/VbH/xl3Gi82zJAngWU8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kl4fSYa7; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kl4fSYa7" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-206b9455460so39377535ad.0 for ; Mon, 09 Sep 2024 13:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725913932; x=1726518732; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=O1N4xVF1ei9/Ktxsre7AID2lFh75C0GoLvtSOUs2cWQ=; b=kl4fSYa7W0lgdadwSUkneBpkfmBtFS/bGX8N2t63owupmZkyuL1qB6UdGfobhZuNF4 4uPtNt9+gOTiEEi6g8zn5ue5CeKWFug9qiuCDZpynVpYp5QoosCUQgC5/KgDgi/zRt8G U9VInXdd/HFP/eHbPoPEsIvP/pMuXHRSKW3ZVxQFtKGql0cwEEY4wiCvaCwjpL8DuFMl 6LiiyQXQcw359bOB4N1tgx+zAypHerHIZ4+hsmvaDxVFaKEQ5PZ9AvV6LcaTMFULPXNx Y0FLrd5Lwxjhd+RUgRHUZe52zLybLjtSDbHLDVovpGXQp5ptTfTg7XJk7t9bXVP6pXXd Eg/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725913932; x=1726518732; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=O1N4xVF1ei9/Ktxsre7AID2lFh75C0GoLvtSOUs2cWQ=; b=Vqizm84oGLedz0h8vCMTPH0ByL2jqgIW3FEMi5GRf0Kb/aMTprjDIL7sKC05ERqcBv qNNq9K0E1OUaXkrINESki/NmFFWflXTnSIiXfs9xUvK1TnbOQa0w/jueGLoG8Oty27RO leYg1beO7XyXRa0uykEauHdvSPplFYqqB0LvGWc2dNJZupRunPzuBravOmVBZV6M073A 1WyZN0/iVOGDHVSiJAzB7dfbdVU/BvHduF2wzCoMozW3m0kuaaIiWgy996erzFtqvhgg FV48pn5/IVHHMnU1cjLKspZen4aq7Sb8Qy/Mfd/S+l/pq4bbrEfv7LHu4EUu1e6Uo5ye SBmQ== X-Gm-Message-State: AOJu0YwQWtxn39Z8wd/Eb0eM1jVPY2CxVvDOd4hvc4Kt+n5Wtr8uHIdb 9TyYb6ca61cDvSGtOmHzRaON6/gv4SKsTXZ2Q10yN8//BQ0tCjiEfwh7YQ== X-Google-Smtp-Source: AGHT+IH0PLywJd0F8g4UsbCiQuywopeyGC5pqmhXuSTYGNaLLZoCWqMwqJyBhAQILaTwCH77nWRRjA== X-Received: by 2002:a17:902:c408:b0:1fd:8dfd:3553 with SMTP id d9443c01a7336-20743a2de20mr11250635ad.18.1725913931704; Mon, 09 Sep 2024 13:32:11 -0700 (PDT) Received: from localhost.localdomain (71-34-65-148.ptld.qwest.net. [71.34.65.148]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d823736630sm4406787a12.9.2024.09.09.13.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 13:32:11 -0700 (PDT) From: "Gerecke, Jason" X-Google-Original-From: "Gerecke, Jason" To: linux-input@vger.kernel.org, Benjamin Tissoires , Jiri Kosina Cc: Ping Cheng , Joshua Dickens , Jason Gerecke , Joshua Dickens Subject: [PATCH 1/2] HID: wacom: Support sequence numbers smaller than 16-bit Date: Mon, 9 Sep 2024 13:32:07 -0700 Message-ID: <20240909203208.47339-1-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jason Gerecke The current dropped packet reporting assumes that all sequence numbers are 16 bits in length. This results in misleading "Dropped" messages if the hardware uses fewer bits. For example, if a tablet uses only 8 bits to store its sequence number, once it rolls over from 255 -> 0, the driver will still be expecting a packet "256". This patch adjusts the logic to reset the next expected packet to logical_minimum whenever it overflows beyond logical_maximum. Signed-off-by: Jason Gerecke Tested-by: Joshua Dickens Fixes: 6d09085b38e5 ("HID: wacom: Adding Support for new usages") --- drivers/hid/wacom_wac.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 74258a78d0408..cef08737a6240 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2512,9 +2512,14 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field wacom_wac->hid_data.barrelswitch3 = value; return; case WACOM_HID_WD_SEQUENCENUMBER: - if (wacom_wac->hid_data.sequence_number != value) - hid_warn(hdev, "Dropped %hu packets", (unsigned short)(value - wacom_wac->hid_data.sequence_number)); + if (wacom_wac->hid_data.sequence_number != value) { + int sequence_size = field->logical_maximum - field->logical_minimum + 1; + int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size; + hid_warn(hdev, "Dropped %d packets", drop_count); + } wacom_wac->hid_data.sequence_number = value + 1; + if (wacom_wac->hid_data.sequence_number > field->logical_maximum) + wacom_wac->hid_data.sequence_number = field->logical_minimum; return; } From patchwork Mon Sep 9 20:32:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 826731 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3006189F57 for ; Mon, 9 Sep 2024 20:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725913936; cv=none; b=hEB+9TYeFeEPrsBoaFRaNn16fAGnLxRBOHjtMcai+sWvq/ry/sEJTXRN3OkRWUHvz8aVUtm6tVlbc/ylOIX41oRZw2ZMZ7hqs7TMbNcga7VOC8l+1ANutCTb0hnDt3oUfkXYFt8u+o1gJxEHPxlgyuJl78cBJ1XwqAvUnx/T6ng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725913936; c=relaxed/simple; bh=i+Xy7PVzbOh9JFFzQIGZ7nRYDld0P4P+Y5hcjj43uPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VSmoNfZ4zpbCc2lGsWoE42YigaOtukVZXqUopH9MJGGZYFF02ar51CAl3AVCAiveCTy3WPG5Wf037QQrZVEEfPs1Jjf6fX4qixSlqg8XUs2rVJrk0tHy0Ko+Xb3OLArjO5pRu7SRlmsDW2Wh/uaLrzsqR2NUV7F8dFFaE7gmoDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=il7UZta0; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="il7UZta0" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7d4f85766f0so3787848a12.2 for ; Mon, 09 Sep 2024 13:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725913934; x=1726518734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2vpYjGJ0ua1E6dpg64gj/fCqbz10Lnv+rQh/+Bu1a34=; b=il7UZta0ilW9tpt5GKU0X+3TlUj5X6xN/H6XBOyFPAuNoe/NkVW29YeO6kqSoNAJL7 Ya/fO/nyuyIzhSblrAcd6dL0o7eVNC1XwALH3YTS29H+KPIOUlVZ7acaWbXH/tGzhHpL khX7AwAU6Z5g5cN8udFur/GEiYEB1TUYsqefQqx3+N7WwyHRv26OfwwGnkgfsVfvoDXA 6NKathWY1zA88MuBnsEqTZ9ejMR/DTHY0NvKyYejDyxGOKX5wami8M7sFhnIScnJadoY a7AJn9NHNypMmxRUdyC6FO1YbyVXQNXdzbQILp3SsYg8a5JPUxBV5Oju1rXO/DwMnNrb pQug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725913934; x=1726518734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2vpYjGJ0ua1E6dpg64gj/fCqbz10Lnv+rQh/+Bu1a34=; b=lj57UL5hBnBHYoYwNTn1bOoHKtPoQudkiWRVIFzgfMItrj2GOsW9KGYCcg4/eKsX9q +fGAIuKl3aV0AmjUO7u27AeVgZc/IWkMLZerrDHwqfHGcp9ef832FsvmRm/OR52QJkm4 IXxsMt1hVDZ0DW8T4Szm/HG8jQApeKuDk/QrOM8PnaSLo95mZj8lweDdiG7iUJWXWq6r kXW9Ygc9rHywKmhJLL07ctHpKGEO4sI0MeTSqqjaHzXShVbo3G0vAEnrj4wbuJSJSal6 8PSdG/PDtk7ZCrmcb8p0EMkfwf7JHQ0Ia0k7Nh8N3lVpybPBq9m1O6upioXPN7j5+Vp6 fLKQ== X-Gm-Message-State: AOJu0YwTMga4ZSj4VIC4elhNnDJ7uXcLrD/K6kxat6GNBd89dpXKQHeZ RFfMI+x+hRjA6G2X20oyEzB32m+QOGQezOXSPvPJa0/6W8Ivjm+n1SRGnA== X-Google-Smtp-Source: AGHT+IE1Co5ZzvgNe2RSoq1O0EGmAYwsbT06K9fYsY+ykgO/+Tie+ZCuho1Wwy1OZv2ZsyFdB786kg== X-Received: by 2002:a17:902:b696:b0:205:709e:1949 with SMTP id d9443c01a7336-2070a817383mr89638155ad.57.1725913933671; Mon, 09 Sep 2024 13:32:13 -0700 (PDT) Received: from localhost.localdomain (71-34-65-148.ptld.qwest.net. [71.34.65.148]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d823736630sm4406787a12.9.2024.09.09.13.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 13:32:13 -0700 (PDT) From: "Gerecke, Jason" X-Google-Original-From: "Gerecke, Jason" To: linux-input@vger.kernel.org, Benjamin Tissoires , Jiri Kosina Cc: Ping Cheng , Joshua Dickens , Jason Gerecke , Joshua Dickens Subject: [PATCH 2/2] HID: wacom: Do not warn about dropped packets for first packet Date: Mon, 9 Sep 2024 13:32:08 -0700 Message-ID: <20240909203208.47339-2-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240909203208.47339-1-jason.gerecke@wacom.com> References: <20240909203208.47339-1-jason.gerecke@wacom.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jason Gerecke The driver currently assumes that the first sequence number it will see is going to be 0. This is not a realiable assumption and can break if, for example, the tablet has already been running for some time prior to the kernel driver connecting to the device. This commit initializes the expected sequence number to -1 and will only print the "Dropped" warning the it has been updated to a non-negative value. Signed-off-by: Jason Gerecke Tested-by: Joshua Dickens Fixes: 6d09085b38e5 ("HID: wacom: Adding Support for new usages") --- drivers/hid/wacom_wac.c | 6 +++++- drivers/hid/wacom_wac.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index cef08737a6240..59a13ad9371cd 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2388,6 +2388,9 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS3, 0); features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3; break; + case WACOM_HID_WD_SEQUENCENUMBER: + wacom_wac->hid_data.sequence_number = -1; + break; } } @@ -2512,7 +2515,8 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field wacom_wac->hid_data.barrelswitch3 = value; return; case WACOM_HID_WD_SEQUENCENUMBER: - if (wacom_wac->hid_data.sequence_number != value) { + if (wacom_wac->hid_data.sequence_number != value && + wacom_wac->hid_data.sequence_number >= 0) { int sequence_size = field->logical_maximum - field->logical_minimum + 1; int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size; hid_warn(hdev, "Dropped %d packets", drop_count); diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 55e0c7a9fdcb4..c8803d5c6a71e 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -326,7 +326,7 @@ struct hid_data { int bat_connected; int ps_connected; bool pad_input_event_flag; - unsigned short sequence_number; + int sequence_number; ktime_t time_delayed; };