From patchwork Tue Jul 30 15:51:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 13747556 X-Patchwork-Delegate: jikos@jikos.cz Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 D60541BA869; Tue, 30 Jul 2024 15:52:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354728; cv=none; b=OGnqgSqZfiI7mAX7t8b2dn5csmxtsbJrIdp//JddFND5V9QLzM+4w83SKOag1eG2kO4Y0KF6saxdYozxn+VGFtbeY+K0eacEYMygG7TdkNqSrxYHkZW0GLqNHUF+s/XY+Z2KvVUnTy+NaA0N1fjotTazDORumTD3lqfy39GOrLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354728; c=relaxed/simple; bh=FL/qY9kZgeoZ8OVYj74nz1JqSGuDuc00dgkKFESUfNA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KdFkp7z++J95/A5eJk24ZHJfVYrhLY1AjJLJo67X8U+HQ1VG+pBXNq9HC6qraKE3dZbzxXgavqk3BN0ubu1V15fWNqrrDktj5t0I8eL0sA9sJDyHiPT8eTUuGTTl7+VuKM1rVvV1g6cn+fJAKEEqX/fbRb9CcrKanJ0uVXRDSOo= 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=TzjMdKM1; arc=none smtp.client-ip=209.85.216.45 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="TzjMdKM1" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2cb55418470so2922500a91.1; Tue, 30 Jul 2024 08:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722354726; x=1722959526; 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=rGTJNgxfe9Ob3gBJFcR51TvMio1QbF0ml0yPuynT6so=; b=TzjMdKM1/W7qHt4u1G8qLFjDyXe3IlPXnpU16rgVlnCLgFJcV6JRe0MLtchvP8bYYQ RNTq2wjCtohhheoXagrkFT1R0CPXNlnUOepO42kdllJbtmdauoNnxeLk8D2ujmIA0HK3 fBfmXyOUrXjpOzB0bpjKMEh2QFFiW6I3vMtgo0xz+oWLy8Sxp+2YRBe8LwyNsvpze8Z6 Gs/NFlB33eZohnykS8uTUSidn/3lMviqF47/UXEYeGqvfvX7WMH2yGVWbXpDGGl/RMlQ pfQZu3T35Yr19fvHVHzuZeNKk4Dh5nF6Ambr/4O2h8HSrMMsznhfJE1Y+6CiEUUiyiZZ BdXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722354726; x=1722959526; 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=rGTJNgxfe9Ob3gBJFcR51TvMio1QbF0ml0yPuynT6so=; b=G//WKlMGnTIhEuUxxuC0KlYqMM7bATnG1eHPmHi/isebd0QWzojWhiD89w1pVt9TX9 mEtso+0M6ezR9I0nhEw0iH630xOeRoanc+eBfnSjEbA0Dj46F+Ibr/cO3FMaQw42AKBu 4dU8nLQPkT5U8KJaw8aD3KmWlXFjUUJcEAmj6kcEPeVQco8YPXkR+Pabw0TykS90XT37 Ld4FLokKlQXrKNbq+QQATbYbgESuKSG/+/QQ2ixqxI544E9CSqQnnsTtauTsHGjDuj7B VburL+uLvkA4gs0vGxfeywROCSTn5+EQbuP4Jo1ubHHkQK+KqBcbaHhVuH4jcaE4w296 8eDw== X-Forwarded-Encrypted: i=1; AJvYcCU5Lekpg/bR0/42TzNBAoPxEJCUH9M7AECQ7PRk5LdVCTZOyARA9yMrOzcDW9wPRpDk/PPe2tYM7JWOdQ1AETE/6Sqgs/6Z X-Gm-Message-State: AOJu0YwDrqoVAyw7jiDLnsFFixHzGCeRm5gd2OMoKy9I3w7ctKzWFq9A EYBUN4i+tGf4FJQvhQqCyWEgt0PSTBagozm2cP8E52fae9quN6ztXHZafg== X-Google-Smtp-Source: AGHT+IF4b6FaThdPXhzvuE3TfYcb2tkeIxqSYmJ/MJuohBSEy7VD5QcKXAD5OZFnOzhaMkjSCNbAWA== X-Received: by 2002:a17:90a:9c7:b0:2c9:6278:27c9 with SMTP id 98e67ed59e1d1-2cf7e621f45mr9461877a91.38.1722354724200; Tue, 30 Jul 2024 08:52:04 -0700 (PDT) Received: from localhost.localdomain (71-34-81-131.ptld.qwest.net. [71.34.81.131]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb7600054sm12788517a91.47.2024.07.30.08.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 08:52:03 -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 , Erin Skomra , "Tobita, Tatsunosuke" , Jason Gerecke , stable@vger.kernel.org Subject: [PATCH 1/5] HID: wacom: Defer calculation of resolution until resolution_code is known Date: Tue, 30 Jul 2024 08:51:55 -0700 Message-ID: <20240730155159.3156-1-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jason Gerecke The Wacom driver maps the HID_DG_TWIST usage to ABS_Z (rather than ABS_RZ) for historic reasons. When the code to support twist was introduced in commit 50066a042da5 ("HID: wacom: generic: Add support for height, tilt, and twist usages"), we were careful to write it in such a way that it had HID calculate the resolution of the twist axis assuming ABS_RZ instead (so that we would get correct angular behavior). This was broken with the introduction of commit 08a46b4190d3 ("HID: wacom: Set a default resolution for older tablets"), which moved the resolution calculation to occur *before* the adjustment from ABS_Z to ABS_RZ occurred. This commit moves the calculation of resolution after the point that we are finished setting things up for its proper use. Signed-off-by: Jason Gerecke Fixes: 08a46b4190d3 ("HID: wacom: Set a default resolution for older tablets") Cc: stable@vger.kernel.org --- drivers/hid/wacom_wac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 1f4564982b958..2541fa2e0fa3b 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1878,12 +1878,14 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, int fmax = field->logical_maximum; unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); int resolution_code = code; - int resolution = hidinput_calc_abs_res(field, resolution_code); + int resolution; if (equivalent_usage == HID_DG_TWIST) { resolution_code = ABS_RZ; } + resolution = hidinput_calc_abs_res(field, resolution_code); + if (equivalent_usage == HID_GD_X) { fmin += features->offset_left; fmax -= features->offset_right; From patchwork Tue Jul 30 15:51:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 13747557 X-Patchwork-Delegate: jikos@jikos.cz Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.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 83A441BA879 for ; Tue, 30 Jul 2024 15:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354729; cv=none; b=bgobis41nTzo2G/KCF0iSCYOVTWltkInkQCA1dnXIehiYO8Y+BBSNadwQHvQcTpz2DCcezOHrK2JNbk+aaonYW5rFc2qzhtvAJr69zkK78d0iKtiX+QPtJevACX9MbhB5P7gyOxBBnDmqDJk6N9wrFAkCtpvpM+YNk+5tBZahDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354729; c=relaxed/simple; bh=31n1X/9lIbf+QGA+QLw85KXMy5B3Q3zT8UEtcF4M2ss=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IdLOL37S5hXao/c53dD2wVdnECH1aZCTpWyQaBsdtzBt3YMi3/8G4HqtNoecZxNkmxjvAAZVDELaXFi+N55jH3s3WGv0TBC+xGjgpxNZKeaaD9c6X6n+TxVUK68cCUtQlxpRZvpKknYnkmFYNdFwdehjTQllzjyJPoi3Socx6Xg= 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=Bw6lumzs; arc=none smtp.client-ip=209.85.210.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="Bw6lumzs" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-70d25b5b6b0so3315273b3a.2 for ; Tue, 30 Jul 2024 08:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722354726; x=1722959526; 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=pGjWryPa+E0i9O1vtsxMqVFVLNR1dXSU3MEx8xiuJFI=; b=Bw6lumzsFlUbrTAW5YH9vNK2j0/uhaodjBBbwuHUTzrhr4Com/dknI7ei7TXOvR9zw pvarCLVHjOp+ZWi3nEEo/4J2ASO3aykajG3D7y0e2gvFcNbqyolnubuCbZkQNa84zjEH AkNAwLZzmpfvMHNtFgi0Lja1pBMpWkqACuFwqepT/ntFKXZ5g47TJGyB3mbbLgWaEads mdMQqrvrzebgJlhFfvbH4X4YBCl0cqiyyusLltpk1AyyIS+EC1BdrTPZDOwYZcvviRJ8 pOpQje0dN3kwInEHMQtnAbrh8eAHkVM+6vZ4FcXKFPvOS5MAWVze1sCct4m7cc4jPWqz BS5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722354726; x=1722959526; 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=pGjWryPa+E0i9O1vtsxMqVFVLNR1dXSU3MEx8xiuJFI=; b=LZiq3BX9uBZfnpLL/DI+ryuM2y60Zo1VB4TE/mqFA+hsY3CzeG28W3DNgpTmqpHt6X vTwwuIDtZpbpSnlg0yEPtGvTltXfcJX21kE9CI7YZ/x8wWaTair2XemTOEBXEFL2j1Dg aG8w/YB2BVjiepl0VGRVa3oYjR/xPPKpbSj0sZAp+AoG3sBoNTqYQDTQz5weIWG68wuy c1f9sgowRu8+aqYAM5yzij+RYh5j41AaMkzIVwg7QcMdVrE9URcAxHXzJXb0D0LSI3ae cjmWPnE6qSGXsMhYeiweJHnhc8j1KTw/4IXptbRsWT5d7oGpffSXtRuRS74QWDqrkMNw USnQ== X-Gm-Message-State: AOJu0YxreM4JLdmz578Boy0UOtR2CiFj1XwGx5Qv1jjPIu91Uy5kEtD5 E1bhGGaiaAPFQMWE1YDnbfI6pmxFB5bvN3Egf7TpVReXkjbAeU8oCR5gzw== X-Google-Smtp-Source: AGHT+IE2laQGcCFLh1elKBueC5G5/T/V8Jp5tDHWnpPQHaz5yt977NdWKpobk1jAXi5Z6e63X3dspw== X-Received: by 2002:a05:6a21:9994:b0:1c2:92a1:9320 with SMTP id adf61e73a8af0-1c4a1179205mr11364736637.7.1722354725803; Tue, 30 Jul 2024 08:52:05 -0700 (PDT) Received: from localhost.localdomain (71-34-81-131.ptld.qwest.net. [71.34.81.131]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb7600054sm12788517a91.47.2024.07.30.08.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 08:52:05 -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 , Erin Skomra , "Tobita, Tatsunosuke" , Jason Gerecke Subject: [PATCH 2/5] HID: wacom: Improve warning for tablets falling back to default resolution Date: Tue, 30 Jul 2024 08:51:56 -0700 Message-ID: <20240730155159.3156-2-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730155159.3156-1-jason.gerecke@wacom.com> References: <20240730155159.3156-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 When we encounter a usage mapped to ABS_X or ABS_Y which has a calculated resolution of 0, we want to warn the user of this before setting a default value. The previous language used the word "usage" but then printed out the value of a "code" instead. We can improve this. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 2541fa2e0fa3b..7e81c93d18229 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1906,8 +1906,8 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, if ((code == ABS_X || code == ABS_Y) && !resolution) { resolution = WACOM_INTUOS_RES; hid_warn(input, - "Wacom usage (%d) missing resolution \n", - code); + "Using default resolution for axis type 0x%x code 0x%x\n", + type, code); } input_abs_set_res(input, code, resolution); break; From patchwork Tue Jul 30 15:51:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 13747558 X-Patchwork-Delegate: jikos@jikos.cz Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 468ED1BA863 for ; Tue, 30 Jul 2024 15:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354730; cv=none; b=O/jF7fzGGK1QUi8OEOyawqrPXUT5vOOuCmvPV71WIATpQrvWRi5kAVI55NhE48EFc2UUu3MtJ5LoS9SXcvRIZ+jTeFW0JAY7CJAggoqrDUo/kCN3zd9NDjff1wbLakvWHpn7uNtZsjIUCnmJstt6Wxv4lcHQCmIFXGqfJF4mdk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354730; c=relaxed/simple; bh=uvBeMr+gnmVasu6Z9oy9pv6M0lMRifbwhZ5SZ5vJooo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KOY+/VaMMqEN2rAs3sNTUi/CflT3yB2DLTZynZSfk0ofdXYB7AfukqIkWg7HKjOYpShDD5+LiVnd0OaSnjVz3lEOLuhvCVfatWOGynn+pSihnKt9VjNG6hCtbhvMSDvAjdioTCO+PJowBYy7kNV8w2nRDk9vU2lANROi5v4i8lM= 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=mscyuVX/; arc=none smtp.client-ip=209.85.210.171 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="mscyuVX/" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-70d1c8d7d95so2902024b3a.2 for ; Tue, 30 Jul 2024 08:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722354728; x=1722959528; 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=+JDXmT+9NceTWH8KohoT7sAzeOEtpvwWoaxsk4ASnv0=; b=mscyuVX/P1uh+tCCKPEQGF/Cn8QOxKqEvsE6H337ATgmaMSC+ic4Nyt1eQw5ul5ucb oecpKd3dRSagCRBOJKUaCwTrIxAAIwNbLFJOBnp0iA9+qVRUmAXIy/dPGlbxuvysTKA9 OMVK/Ghz63I+5lSE1VrLTp9eCNUSNH+skn1Q67Lc0T9SyVRX9xiAd40lXX4I5lVLJypp tv6rWMZcXr+JJieFvT7eSNeN4t+YNja0aozgoLGz3BCBCY2HX5WyLSX04SFVPFSOkJ4h Dp8h0kioWbQSVc8mZqKpKYnDFwkfCss6oQorV9HzNWDEMhQI6mThUI8MW/V9NBxnCuA9 wIHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722354728; x=1722959528; 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=+JDXmT+9NceTWH8KohoT7sAzeOEtpvwWoaxsk4ASnv0=; b=CUrCI9iBzNCluX6W6shUUnBPT4ed/6z3tR8JXU8p9sC0VrXLOlTcN74odPKD1Ak0wL deLRoIybrMWXaX9Xc630li45JE/wSc2A2G+7fkhQQFrr4Bd6KNEBoPwRXXnUVgbYtsev L2v2NuEEarzPKYhT788dGD76XszM0yq2Tm0o+Rezol9UHXKDz/UKZya/afqbanFWa/AP qkfZrQwv5fjLKWVdIDADqfLFcA7pliyEhidFm4OocXCPTZUqWg908PoHWr6Q48svmRis 7+dQiskfFcVKxT8mxQlPs8dB39Kluu75vs75WSIey5YcGcSSeSxvGmN6VbQr3BEYgnC2 HqlA== X-Gm-Message-State: AOJu0YyKIz33MepI0JJ1gQVLB5rGkl6iBemt+vMasIUjMMEnhhu+xeI5 kWowLM+Xl4eIbmAbaXgAJQbzjGpeBJNOpGJojJQRYkSsi99/cioAtZpehA== X-Google-Smtp-Source: AGHT+IGoO6DQ1rtic7l3gtPx3JF2F1Dz170Fr2A7Ut5Qg0NxwSC9fA9FjvW9tkZzH0NC1QwRbnV3nA== X-Received: by 2002:a05:6a20:d707:b0:1c4:bb9f:c574 with SMTP id adf61e73a8af0-1c4bb9fdb54mr6559666637.43.1722354727775; Tue, 30 Jul 2024 08:52:07 -0700 (PDT) Received: from localhost.localdomain (71-34-81-131.ptld.qwest.net. [71.34.81.131]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb7600054sm12788517a91.47.2024.07.30.08.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 08:52:06 -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 , Erin Skomra , "Tobita, Tatsunosuke" , Jason Gerecke Subject: [PATCH 3/5] HID: wacom: Support touchrings with relative motion Date: Tue, 30 Jul 2024 08:51:57 -0700 Message-ID: <20240730155159.3156-3-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730155159.3156-1-jason.gerecke@wacom.com> References: <20240730155159.3156-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 If a touchring is configured to send relative events (e.g. +1 or -1 every time some bit of rotational distance is covered), we should similarly send relative events up to userspace. Previous non-HID tablets used REL_WHEEL to send this kind of information, so we opt to use this same axis since userspace (xf86-input-wacom and libinput) already expects this kind of behavior from the Wacom kernel driver. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 7e81c93d18229..96b158a94ef9c 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1911,6 +1911,7 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, } input_abs_set_res(input, code, resolution); break; + case EV_REL: case EV_KEY: case EV_MSC: case EV_SW: @@ -2047,7 +2048,10 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, features->device_type |= WACOM_DEVICETYPE_PAD; break; case WACOM_HID_WD_TOUCHRING: - wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); + if (field->flags & HID_MAIN_ITEM_RELATIVE) + wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL, 0); + else + wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); features->device_type |= WACOM_DEVICETYPE_PAD; break; case WACOM_HID_WD_TOUCHRINGSTATUS: @@ -2112,7 +2116,10 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field return; if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) { - if (usage->hid != WACOM_HID_WD_TOUCHRING) + bool is_abs_touchring = usage->hid == WACOM_HID_WD_TOUCHRING && + !(field->flags & HID_MAIN_ITEM_RELATIVE); + + if (!is_abs_touchring) wacom_wac->hid_data.inrange_state |= value; } @@ -2165,6 +2172,15 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field hdev->product == 0x3AA) value = wacom_offset_rotation(input, usage, value, 1, 2); } + else if (field->flags & HID_MAIN_ITEM_RELATIVE) { + /* We must invert the sign for vertical + * relative scrolling. Clockwise rotation + * produces positive values from HW, but + * userspace treats positive REL_WHEEL as a + * scroll *up*! + */ + value = -value; + } else { value = wacom_offset_rotation(input, usage, value, 1, 4); } From patchwork Tue Jul 30 15:51:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 13747559 X-Patchwork-Delegate: jikos@jikos.cz Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 023CF1BA889 for ; Tue, 30 Jul 2024 15:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354732; cv=none; b=FGErfwuWmjvZJCeIl4J9Jj4jj9EQweOpLo30ioP9HP6hRsrKr/Pl0XsTOiFFyFHP+AAD0Ip9xwMtF5lbZP6idJMo5AUcsZEvs1zufxPKJTuiU8POplYxLq60Xj7QpQQCJYouOXe4NV34uF6/0d/JIoPl+NZZmVFoopttD/7ICbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354732; c=relaxed/simple; bh=pCuV0U+CE/5FzqxHlYgYkhiJZ+uemPaU/f6WxnPqLAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GkjKWurAXqC4tb3+bT++GYp0kSD9r+wObR/7jOBYh+TzJPQ3LTR6Sgo3WK11Xjm6cLA3sAxILRrqW3KL1ogiO+DQrsIPmZ7SvZG/PEDJQ/0dOEzs6lYVvwy/z2/GiyFStMqup2RN63Kv9xAYiEeW/rWW4ET3fBJzB1ipwK15YuI= 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=HHMFQIAm; arc=none smtp.client-ip=209.85.215.180 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="HHMFQIAm" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-7a1be7b7bb5so3468619a12.0 for ; Tue, 30 Jul 2024 08:52:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722354730; x=1722959530; 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=M3XSJ6eZ4QQQt8d3kl2QAxniTSgrYj7kobyAQ/bT4fs=; b=HHMFQIAmVZZGT/rBZX9GSAqmYZdr/vzn6XXM3ZoIuDQFDb+NGmkiebeHWa09lVoM8e Pa41biuSmC1VvEjdWOPr608wQWdpEmlvIe6ZoG6pZnXSms7whoSrHHtN59+N8OYS8MiF pmQd40Eo1nCYM5UqrdVfKQgth660m1rDeocIZ14kqv+u0m+4KMhV7Ww+7iGHkGEg2Wys 5wDKPNWcyql+dxXIJA5gF6CtJLZ+KYUQVrX+X42XRDVjSTR7rbe+maF6CB8JJrRHjRwL DylAKEQ3bRJrQcAqeSZvNa5AxydPPPlwCGPu18kPeAhBH+vpRIqxZnYY05VUfSVJinMC 1BaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722354730; x=1722959530; 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=M3XSJ6eZ4QQQt8d3kl2QAxniTSgrYj7kobyAQ/bT4fs=; b=HewZdCeP0fA9nNLvlL/8RUQPkr9UPDwxGpx8KyWSU9oc6T1VZkEMh339hmjaonCROL 1Qw1wto2cNXtwGSsRbSFCWrtYtcuGtNCTlo4xijRw3aLBmxVlQh9hPcr9A6thSPgCg0g YHh2mfAiYqjSKjlEHkGfOmPSOUYxNiysLkxo12LUz7ujvFtlxkdJaCRoCbQeSdljF/MI 1F38EEhfQI7LO5iWnlY6hFtt1vrZ6MpjB9fsKsieaCKVkXT3enabD1696PsXm1bn57Z+ U8MmiqQz0+Eg1xy8dlHBJX9fx+H8RhkcV9xbyASJ4VxmVtwkCKHwG61LuhFABKlqEffE ZjLg== X-Gm-Message-State: AOJu0YzIg+Oo4plGuJp+YbfQmIcW6+/lK81uZTYGCUBS3zaBTYXMtN38 nOYYCBL3A8zMZ/dhq1D5EBIVFYiJXRoZB3jXsyA2MHE+dF5Q/rLCPYZdXQ== X-Google-Smtp-Source: AGHT+IFxt6hl+/Z18mh05dVq3k5WK0q12F4Fbx8Jie7ZGWwQvTL1IsGUaCK4FncvzZNRNMksZjBfyg== X-Received: by 2002:a17:90a:cc3:b0:2cd:619:6826 with SMTP id 98e67ed59e1d1-2cf7e60bee6mr13567090a91.34.1722354729636; Tue, 30 Jul 2024 08:52:09 -0700 (PDT) Received: from localhost.localdomain (71-34-81-131.ptld.qwest.net. [71.34.81.131]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb7600054sm12788517a91.47.2024.07.30.08.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 08:52:08 -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 , Erin Skomra , "Tobita, Tatsunosuke" , Jason Gerecke Subject: [PATCH 4/5] HID: wacom: Add preliminary support for high-resolution wheel scrolling Date: Tue, 30 Jul 2024 08:51:58 -0700 Message-ID: <20240730155159.3156-4-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730155159.3156-1-jason.gerecke@wacom.com> References: <20240730155159.3156-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 Modern userspace (i.e. libinput) will make use of high-resolution scrolling if supported. Hardware does not currently set a resolution multiplier needed for effective high-res scrolling, but we can still write code to support it in the future. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 24 ++++++++++++++++++++---- drivers/hid/wacom_wac.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 96b158a94ef9c..e45abc973363a 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2048,10 +2048,12 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, features->device_type |= WACOM_DEVICETYPE_PAD; break; case WACOM_HID_WD_TOUCHRING: - if (field->flags & HID_MAIN_ITEM_RELATIVE) - wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL, 0); - else + if (field->flags & HID_MAIN_ITEM_RELATIVE) { + wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL_HI_RES, 0); + set_bit(REL_WHEEL, input->relbit); + } else { wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); + } features->device_type |= WACOM_DEVICETYPE_PAD; break; case WACOM_HID_WD_TOUCHRINGSTATUS: @@ -2179,7 +2181,21 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field * userspace treats positive REL_WHEEL as a * scroll *up*! */ - value = -value; + int hires_value = -value * 120 / usage->resolution_multiplier; + int *ring_value = &wacom_wac->hid_data.ring_value; + + value = hires_value; + *ring_value += hires_value; + + /* Emulate a legacy wheel click for every 120 + * units of hi-res travel. + */ + if (*ring_value >= 120 || *ring_value <= -120) { + int clicks = *ring_value / 120; + + input_event(input, usage->type, REL_WHEEL, clicks); + *ring_value -= clicks * 120; + } } else { value = wacom_offset_rotation(input, usage, value, 1, 4); diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 6ec499841f709..aeba2f3082f03 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -312,6 +312,7 @@ struct hid_data { int width; int height; int id; + int ring_value; int cc_report; int cc_index; int cc_value_index; From patchwork Tue Jul 30 15:51:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 13747560 X-Patchwork-Delegate: jikos@jikos.cz Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 95BA81BA882 for ; Tue, 30 Jul 2024 15:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354734; cv=none; b=CYg8Lh8824zr/qkGzJiIwlSTbEIEMTyhi5Jd1bN7XSjC6+MFs4qpJiDiXDfY9zLMVAERTpk/FIGUD2FnKCC17sos0olOtmqlcu5i0sfQ0kZWu5Jc/28C7rsC8tm7HIjkrms1m+9AXsB8Bk9NSvsdqML2wZLkw3oypj4rAmw5zSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722354734; c=relaxed/simple; bh=v5e/IuWMGYfiUxz6H+zHQ+Ep/y19tWPY1QrZkU7uVks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UCXS18j+MB2k2lBwg/8W8ARPqFQI4KLJtPiwLKLfV8GLT4xe1h9Hdm6J2vkPVt7X8GrqfyDG390MIn/x41b1mMCIJaCFnKyxIa8+2isoQ03ksaK2vitjY5sgl9UezcOdsAJ6bjy1GVwlkgoc9YFHQo3xjfKXLVG0uCH68zH1gzQ= 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=R3tM6Z+K; arc=none smtp.client-ip=209.85.216.48 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="R3tM6Z+K" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2cf11b91813so3014956a91.1 for ; Tue, 30 Jul 2024 08:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722354731; x=1722959531; 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=9QznQgl7IMPwXRn13HQau8DQv3i//tPPE+dJlmMF5Xw=; b=R3tM6Z+KIcVYeSOZyV6B99DpOBtE/zqTPl4+XBe4EhX06RzZ4V31v69SDazIiL1U1h 8EaHiO1owlZTHFR2y+/o4UDWIgYD4OqmeUycf4RgpwbXPGQHfry+1MSshCLXMtDCC7cO xts4e76ZmJeQ8pTbliLg6HtBTpd1DZ1LXcrE2LxkyC7P2t/tWcUdAV4zzJ50JBc3Zn2k zEOxQydkmfZqUOdW2a76IK4VXTJKyveqqZlWyd3E5jtGf7Wgay+I4g9NB3w9Ggyexn30 0J71XiOyR2x4JjlcsJrE7oHWxNi6ITub90ZZPxlMabcMDpacRpH91RuGVjHSwt5pj4il XXyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722354731; x=1722959531; 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=9QznQgl7IMPwXRn13HQau8DQv3i//tPPE+dJlmMF5Xw=; b=R/Wwbc2VpJHQLghOYHxs3NnmP+MOwrJQNVS3QR88i6csnuJa8ZT6qPUYreusX+I4Ni 6qhsS0eclKF2sJoRJtsBLlRQ9y/cJXRqi1OwkrgxSl+wK4JFMDyeocxiGD4GofIgnEA6 4gz3gB7DTBNo/NcjZiHBY0AgVGmVFJzw5DcVHm/DoXVwVYkb6WBMKiGHPUlsGy+hwVwD 4Gd84ZHjSXdHhcEyyy5GvJ1sryzck449404tQCqDCq2YIq1fG25O3aaUrIaXI2IFUvvv AWGyAI0wE6w1lu4ngjrPn5xWihvnScYtGd/9DvIkZIqwtu93qUEqdUJ5oH/WmB2gNUUD xpTA== X-Gm-Message-State: AOJu0YxEpyIFFqsNs4GiMdfNcLqNUw+SxRT3D7v8j34RjO8qt2DKWUwH LR7IG5des1joNG6qaY6surYT5ZjKsGaZLCFyKMvY8zlIX0MgfKXfGCoCiQ== X-Google-Smtp-Source: AGHT+IFrCxGoxE87NfNjTcc3J4UGBNaa+Wm/4b/nzFp6FzZnuQ3wSDDOSFDpIcqJdipOhAXik5hr8Q== X-Received: by 2002:a17:90b:50e:b0:2c9:6ad9:b75b with SMTP id 98e67ed59e1d1-2cf7e72beabmr8118198a91.40.1722354731186; Tue, 30 Jul 2024 08:52:11 -0700 (PDT) Received: from localhost.localdomain (71-34-81-131.ptld.qwest.net. [71.34.81.131]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb7600054sm12788517a91.47.2024.07.30.08.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 08:52:10 -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 , Erin Skomra , "Tobita, Tatsunosuke" , Jason Gerecke Subject: [PATCH 5/5] HID: wacom: Support devices with two touchrings Date: Tue, 30 Jul 2024 08:51:59 -0700 Message-ID: <20240730155159.3156-5-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730155159.3156-1-jason.gerecke@wacom.com> References: <20240730155159.3156-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 If a device has more than one touchring, we want to be sure that userspace is able to distinguish them. Following previous standards, the first absolute ring will be reported as ABS_WHEEL and the second as ABS_THROTTLE. Relative rings will use REL_WHEEL_HI_RES / REL_WHEEL for the first and REL_HWHEEL_HI_RES / REL_HWHEEL for the second. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 58 ++++++++++++++++++++++++++++++++--------- drivers/hid/wacom_wac.h | 3 +++ 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index e45abc973363a..74258a78d0408 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2049,10 +2049,21 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, break; case WACOM_HID_WD_TOUCHRING: if (field->flags & HID_MAIN_ITEM_RELATIVE) { - wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL_HI_RES, 0); - set_bit(REL_WHEEL, input->relbit); + wacom_wac->relring_count++; + if (wacom_wac->relring_count == 1) { + wacom_map_usage(input, usage, field, EV_REL, REL_WHEEL_HI_RES, 0); + set_bit(REL_WHEEL, input->relbit); + } + else if (wacom_wac->relring_count == 2) { + wacom_map_usage(input, usage, field, EV_REL, REL_HWHEEL_HI_RES, 0); + set_bit(REL_HWHEEL, input->relbit); + } } else { - wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); + wacom_wac->absring_count++; + if (wacom_wac->absring_count == 1) + wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); + else if (wacom_wac->absring_count == 2) + wacom_map_usage(input, usage, field, EV_ABS, ABS_THROTTLE, 0); } features->device_type |= WACOM_DEVICETYPE_PAD; break; @@ -2175,14 +2186,37 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field value = wacom_offset_rotation(input, usage, value, 1, 2); } else if (field->flags & HID_MAIN_ITEM_RELATIVE) { - /* We must invert the sign for vertical - * relative scrolling. Clockwise rotation - * produces positive values from HW, but - * userspace treats positive REL_WHEEL as a - * scroll *up*! - */ - int hires_value = -value * 120 / usage->resolution_multiplier; - int *ring_value = &wacom_wac->hid_data.ring_value; + int hires_value = value * 120 / usage->resolution_multiplier; + int *ring_value; + int lowres_code; + + if (usage->code == REL_WHEEL_HI_RES) { + /* We must invert the sign for vertical + * relative scrolling. Clockwise + * rotation produces positive values + * from HW, but userspace treats + * positive REL_WHEEL as a scroll *up*! + */ + hires_value = -hires_value; + ring_value = &wacom_wac->hid_data.ring_value; + lowres_code = REL_WHEEL; + } + else if (usage->code == REL_HWHEEL_HI_RES) { + /* No need to invert the sign for + * horizontal relative scrolling. + * Clockwise rotation produces positive + * values from HW and userspace treats + * positive REL_HWHEEL as a scroll + * right. + */ + ring_value = &wacom_wac->hid_data.ring2_value; + lowres_code = REL_HWHEEL; + } + else { + hid_err(wacom->hdev, "unrecognized relative wheel with code %d\n", + usage->code); + break; + } value = hires_value; *ring_value += hires_value; @@ -2193,7 +2227,7 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field if (*ring_value >= 120 || *ring_value <= -120) { int clicks = *ring_value / 120; - input_event(input, usage->type, REL_WHEEL, clicks); + input_event(input, usage->type, lowres_code, clicks); *ring_value -= clicks * 120; } } diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index aeba2f3082f03..55e0c7a9fdcb4 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -313,6 +313,7 @@ struct hid_data { int height; int id; int ring_value; + int ring2_value; int cc_report; int cc_index; int cc_value_index; @@ -356,6 +357,8 @@ struct wacom_wac { int num_contacts_left; u8 bt_features; u8 bt_high_speed; + u8 absring_count; + u8 relring_count; int mode_report; int mode_value; struct hid_data hid_data;