[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250714-support-forcepads-v1-7-71c7c05748c9@google.com>
Date: Mon, 14 Jul 2025 15:09:40 +0000
From: Jonathan Denose <jdenose@...gle.com>
To: Jiri Kosina <jikos@...nel.org>, Benjamin Tissoires <bentiss@...nel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>, Jonathan Corbet <corbet@....net>,
Henrik Rydberg <rydberg@...math.org>
Cc: linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, Angela Czubak <aczubak@...gle.com>,
"Sean O'Brien" <seobrien@...gle.com>, Jonathan Denose <jdenose@...gle.com>
Subject: [PATCH 07/11] HID: input: calculate resolution for pressure
From: Angela Czubak <aczubak@...gle.com>
Assume that if the pressure is given in newtons it should be normalized
to grams. If the pressure has no unit do not calculate resolution.
Signed-off-by: Angela Czubak <aczubak@...gle.com>
Co-developed-by: Jonathan Denose <jdenose@...gle.com>
Signed-off-by: Jonathan Denose <jdenose@...gle.com>
---
drivers/hid/hid-input.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index d42c1fbd20a1cc01c04f93cf10f1d1c18043929c..1d59787bd0c0e251698e2a2944dae1c4a96adefe 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -303,6 +303,19 @@ __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
}
break;
+ case ABS_PRESSURE:
+ case ABS_MT_PRESSURE:
+ if (field->unit == HID_UNIT_NEWTON) {
+ /* Convert to grams, 1 newton is 101.97 grams */
+ prev = physical_extents;
+ physical_extents *= 10197;
+ if (physical_extents < prev)
+ return 0;
+ unit_exponent -= 2;
+ } else if (field->unit != HID_UNIT_GRAM) {
+ return 0;
+ }
+ break;
default:
return 0;
}
--
2.50.0.727.gbf7dc18ff4-goog
Powered by blists - more mailing lists