drivers/hid/usbhid/hid-pidff.c
Source file repositories/reference/linux-study-clean/drivers/hid/usbhid/hid-pidff.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/usbhid/hid-pidff.c- Extension
.c- Size
- 45898 bytes
- Lines
- 1647
- 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.
- 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
hid-pidff.hlinux/hid.hlinux/input.hlinux/math64.hlinux/minmax.hlinux/slab.hlinux/stringify.hlinux/usb.h
Detected Declarations
struct pidff_usagestruct pidff_effectstruct pidff_deviceenum pid_axesfunction pidff_is_effect_conditionalfunction pidff_is_duration_infinitefunction pidff_effect_ff_to_pidfunction pidff_get_effect_type_idfunction pidff_clampfunction pidff_rescalefunction pidff_rescale_signedfunction defaultfunction pidff_setfunction pidff_set_signedfunction pidff_set_timefunction pidff_set_durationfunction pidff_set_effect_directionfunction pidff_set_envelope_reportfunction pidff_needs_set_envelopefunction pidff_set_constant_reportfunction pidff_needs_set_constantfunction pidff_set_effect_reportfunction pidff_needs_set_effectfunction pidff_set_periodic_reportfunction pidff_needs_set_periodicfunction pidff_set_condition_reportfunction pidff_needs_set_conditionfunction pidff_set_ramp_reportfunction pidff_needs_set_rampfunction pidff_set_gain_reportfunction pidff_set_device_controlfunction pidff_resetfunction pidff_fetch_poolfunction pidff_request_effect_uploadfunction pidff_needs_playbackfunction pidff_playback_pidfunction pidff_playbackfunction pidff_erase_pidfunction pidff_erase_effectfunction pidff_upload_effectfunction set_gainfunction pidff_autocenterfunction pidff_set_autocenterfunction pidff_find_usagefunction pidff_find_field_with_usagefunction pidff_find_fieldsfunction pidff_check_usagefunction pidff_find_reports
Annotated Snippet
struct pidff_usage {
struct hid_field *field;
s32 *value;
};
struct pidff_effect {
int pid_id;
int is_infinite;
unsigned int loop_count;
};
struct pidff_device {
struct hid_device *hid;
struct hid_report *reports[ARRAY_SIZE(pidff_reports)];
struct pidff_usage set_effect[ARRAY_SIZE(pidff_set_effect)];
struct pidff_usage set_envelope[ARRAY_SIZE(pidff_set_envelope)];
struct pidff_usage set_condition[ARRAY_SIZE(pidff_set_condition)];
struct pidff_usage set_periodic[ARRAY_SIZE(pidff_set_periodic)];
struct pidff_usage set_constant[ARRAY_SIZE(pidff_set_constant)];
struct pidff_usage set_ramp[ARRAY_SIZE(pidff_set_ramp)];
struct pidff_usage device_gain[ARRAY_SIZE(pidff_device_gain)];
struct pidff_usage block_load[ARRAY_SIZE(pidff_block_load)];
struct pidff_usage pool[ARRAY_SIZE(pidff_pool)];
struct pidff_usage effect_operation[ARRAY_SIZE(pidff_effect_operation)];
struct pidff_usage block_free[ARRAY_SIZE(pidff_block_free)];
struct pidff_effect effect[PID_EFFECTS_MAX];
/*
* Special field is a field that is not composed of
* usage<->value pairs that pidff_usage values are
*/
/* Special field in create_new_effect */
struct hid_field *create_new_effect_type;
/* Special fields in set_effect */
struct hid_field *set_effect_type;
struct hid_field *effect_direction;
struct hid_field *axes_enable;
/* Special field in device_control */
struct hid_field *device_control;
/* Special field in block_load */
struct hid_field *block_load_status;
/* Special field in effect_operation */
struct hid_field *effect_operation_status;
int control_id[ARRAY_SIZE(pidff_device_control)];
int type_id[ARRAY_SIZE(pidff_effect_types)];
int status_id[ARRAY_SIZE(pidff_block_load_status)];
int operation_id[ARRAY_SIZE(pidff_effect_operation_status)];
int direction_axis_id[ARRAY_SIZE(pidff_direction_axis)];
u32 quirks;
u8 effect_count;
u8 axis_count;
};
static int pidff_is_effect_conditional(struct ff_effect *effect)
{
return effect->type == FF_SPRING ||
effect->type == FF_DAMPER ||
effect->type == FF_INERTIA ||
effect->type == FF_FRICTION;
}
static int pidff_is_duration_infinite(u16 duration)
{
return duration == FF_INFINITE || duration == PID_INFINITE;
}
/*
* Get PID effect index from FF effect type.
* Return 0 if invalid.
*/
static int pidff_effect_ff_to_pid(struct ff_effect *effect)
{
switch (effect->type) {
case FF_CONSTANT:
return PID_CONSTANT;
case FF_RAMP:
return PID_RAMP;
case FF_SPRING:
return PID_SPRING;
Annotation
- Immediate include surface: `hid-pidff.h`, `linux/hid.h`, `linux/input.h`, `linux/math64.h`, `linux/minmax.h`, `linux/slab.h`, `linux/stringify.h`, `linux/usb.h`.
- Detected declarations: `struct pidff_usage`, `struct pidff_effect`, `struct pidff_device`, `enum pid_axes`, `function pidff_is_effect_conditional`, `function pidff_is_duration_infinite`, `function pidff_effect_ff_to_pid`, `function pidff_get_effect_type_id`, `function pidff_clamp`, `function pidff_rescale`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: integration implementation candidate.
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.