mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 07:47:50 +00:00
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>
This commit is contained in:
committed by
Benjamin Tissoires
parent
344ff35849
commit
7657bf0b7c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user