drivers/hid/hid-haptic.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-haptic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-haptic.c- Extension
.c- Size
- 15569 bytes
- Lines
- 580
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/input/mt.hlinux/module.hhid-haptic.h
Detected Declarations
function Copyrightfunction hid_haptic_check_pressure_unitfunction hid_haptic_input_mappingfunction hid_haptic_input_configuredfunction parse_auto_trigger_fieldfunction fill_effect_buffunction switch_modefunction hid_haptic_upload_effectfunction play_effectfunction haptic_work_handlerfunction hid_haptic_playbackfunction effect_set_defaultfunction hid_haptic_erasefunction hid_haptic_destroyfunction hid_haptic_initfunction list_for_each_entryfunction hid_haptic_pressure_resetfunction hid_haptic_pressure_increaseexport hid_haptic_feature_mappingexport hid_haptic_check_pressure_unitexport hid_haptic_input_mappingexport hid_haptic_input_configuredexport hid_haptic_initexport hid_haptic_pressure_resetexport hid_haptic_pressure_increase
Annotated Snippet
if (usage->usage_index >= field->report_count) {
dev_err(&hdev->dev,
"HID_HP_AUTOTRIGGER out of range\n");
return;
}
hid_device_io_start(hdev);
hid_hw_request(hdev, field->report, HID_REQ_GET_REPORT);
hid_hw_wait(hdev);
hid_device_io_stop(hdev);
haptic->default_auto_trigger =
field->value[usage->usage_index];
haptic->auto_trigger_report = field->report;
} else if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ORDINAL) {
usage_hid = usage->hid & HID_USAGE;
switch (field->logical) {
case HID_HP_WAVEFORMLIST:
if (usage_hid > haptic->max_waveform_id)
haptic->max_waveform_id = usage_hid;
break;
case HID_HP_DURATIONLIST:
if (usage_hid > haptic->max_duration_id)
haptic->max_duration_id = usage_hid;
break;
default:
break;
}
}
}
EXPORT_SYMBOL_GPL(hid_haptic_feature_mapping);
bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
struct hid_input *hi, struct hid_field *field)
{
if (field->unit == HID_UNIT_GRAM || field->unit == HID_UNIT_NEWTON) {
haptic->force_logical_minimum = field->logical_minimum;
haptic->force_physical_minimum = field->physical_minimum;
haptic->force_resolution = input_abs_get_res(hi->input,
ABS_MT_PRESSURE);
return true;
}
return false;
}
EXPORT_SYMBOL_GPL(hid_haptic_check_pressure_unit);
int hid_haptic_input_mapping(struct hid_device *hdev,
struct hid_haptic_device *haptic,
struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
if (usage->hid == HID_HP_MANUALTRIGGER) {
haptic->manual_trigger_report = field->report;
/* we don't really want to map these fields */
return -1;
}
return 0;
}
EXPORT_SYMBOL_GPL(hid_haptic_input_mapping);
int hid_haptic_input_configured(struct hid_device *hdev,
struct hid_haptic_device *haptic,
struct hid_input *hi)
{
if (hi->application == HID_DG_TOUCHPAD) {
if (haptic->auto_trigger_report &&
haptic->manual_trigger_report) {
__set_bit(INPUT_PROP_PRESSUREPAD, hi->input->propbit);
return 1;
}
return 0;
}
return -1;
}
EXPORT_SYMBOL_GPL(hid_haptic_input_configured);
static void parse_auto_trigger_field(struct hid_haptic_device *haptic,
struct hid_field *field)
{
int count = field->report_count;
int n;
u16 usage_hid;
for (n = 0; n < count; n++) {
switch (field->usage[n].hid & HID_USAGE_PAGE) {
case HID_UP_ORDINAL:
usage_hid = field->usage[n].hid & HID_USAGE;
switch (field->logical) {
Annotation
- Immediate include surface: `linux/input/mt.h`, `linux/module.h`, `hid-haptic.h`.
- Detected declarations: `function Copyright`, `function hid_haptic_check_pressure_unit`, `function hid_haptic_input_mapping`, `function hid_haptic_input_configured`, `function parse_auto_trigger_field`, `function fill_effect_buf`, `function switch_mode`, `function hid_haptic_upload_effect`, `function play_effect`, `function haptic_work_handler`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.