Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

HID: haptic: add functions handling events

Implement hid_haptic_handle_press_release() which generates haptic feedback
as well as saves the pressed state of the haptic device.
Add functions to increase and reset the state of the pressure detected by
the device.

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>

authored by

Angela Czubak and committed by
Benjamin Tissoires
a77efca3 7657bf0b

+34 -1
+19 -1
drivers/hid/hid-haptic.c
··· 50 50 bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic, 51 51 struct hid_input *hi, struct hid_field *field) 52 52 { 53 - if (field->unit == HID_UNIT_GRAM || field->unit == HID_UNIT_NEWTON) 53 + if (field->unit == HID_UNIT_GRAM || field->unit == HID_UNIT_NEWTON) { 54 + haptic->force_logical_minimum = field->logical_minimum; 55 + haptic->force_physical_minimum = field->physical_minimum; 56 + haptic->force_resolution = input_abs_get_res(hi->input, 57 + ABS_MT_PRESSURE); 54 58 return true; 59 + } 55 60 return false; 56 61 } 57 62 EXPORT_SYMBOL_GPL(hid_haptic_check_pressure_unit); ··· 513 508 return ret; 514 509 } 515 510 EXPORT_SYMBOL_GPL(hid_haptic_init); 511 + 512 + void hid_haptic_pressure_reset(struct hid_haptic_device *haptic) 513 + { 514 + haptic->pressure_sum = 0; 515 + } 516 + EXPORT_SYMBOL_GPL(hid_haptic_pressure_reset); 517 + 518 + void hid_haptic_pressure_increase(struct hid_haptic_device *haptic, 519 + __s32 pressure) 520 + { 521 + haptic->pressure_sum += pressure; 522 + } 523 + EXPORT_SYMBOL_GPL(hid_haptic_pressure_increase);
+15
drivers/hid/hid-haptic.h
··· 70 70 struct hid_haptic_device *haptic, 71 71 struct hid_input *hi); 72 72 int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device **haptic_ptr); 73 + void hid_haptic_handle_press_release(struct hid_haptic_device *haptic); 74 + void hid_haptic_pressure_reset(struct hid_haptic_device *haptic); 75 + void hid_haptic_pressure_increase(struct hid_haptic_device *haptic, 76 + __s32 pressure); 73 77 #else 74 78 static inline 75 79 void hid_haptic_feature_mapping(struct hid_device *hdev, ··· 107 103 { 108 104 return 0; 109 105 } 106 + static inline 107 + void hid_haptic_handle_press_release(struct hid_haptic_device *haptic) 108 + {} 109 + static inline 110 + void hid_haptic_pressure_reset(struct hid_haptic_device *haptic) 111 + {} 112 + static inline 113 + void hid_haptic_pressure_increase(struct hid_haptic_device *haptic, 114 + __s32 pressure) 115 + {} 110 116 #endif 117 +