diff options
author | Angela Czubak <aczubak@google.com> | 2025-08-18 23:08:48 +0000 |
---|---|---|
committer | Benjamin Tissoires <bentiss@kernel.org> | 2025-09-15 14:32:54 +0200 |
commit | 7657bf0b7cfb63ded95a6fe4e1cf106cf386b6cc (patch) | |
tree | 616f8009df856f7d471b420703b74080986d6668 | |
parent | 344ff358495706abc7aac1e0c59a5bb16b350307 (diff) |
HID: input: calculate resolution for pressure
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@google.com>
Co-developed-by: Jonathan Denose <jdenose@google.com>
Signed-off-by: Jonathan Denose <jdenose@google.com>
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
-rw-r--r-- | drivers/hid/hid-input.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index f6a920fe3102..5d7532d79d21 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; } |