drivers/hid/hid-lg4ff.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-lg4ff.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-lg4ff.c- Extension
.c- Size
- 42167 bytes
- Lines
- 1501
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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.hlinux/usb.hlinux/hid.husbhid/usbhid.hhid-lg.hhid-lg4ff.hhid-ids.h
Detected Declarations
struct lg4ff_wheel_datastruct lg4ff_device_entrystruct lg4ff_wheelstruct lg4ff_compat_mode_switchstruct lg4ff_wheel_ident_infostruct lg4ff_multimode_wheelstruct lg4ff_alternate_modefunction lg4ff_adjust_dfp_x_axisfunction lg4ff_adjust_input_eventfunction lg4ff_raw_eventfunction lg4ff_init_wheel_datafunction lg4ff_playfunction lg4ff_set_autocenter_defaultfunction lg4ff_set_autocenter_ffexfunction lg4ff_set_range_g25function lg4ff_set_range_dfpfunction lg4ff_switch_compatibility_modefunction lg4ff_alternate_modes_showfunction lg4ff_alternate_modes_storefunction lg4ff_combine_showfunction lg4ff_combine_storefunction lg4ff_range_showfunction lg4ff_range_storefunction lg4ff_real_id_showfunction lg4ff_real_id_storefunction lg4ff_set_ledsfunction lg4ff_led_set_brightnessfunction lg4ff_led_get_brightnessfunction lg4ff_identify_multimode_wheelfunction lg4ff_handle_multimode_wheelfunction lg4ff_initfunction lg4ff_deinit
Annotated Snippet
struct lg4ff_wheel_data {
const u32 product_id;
u16 combine;
u16 range;
const u16 min_range;
const u16 max_range;
#ifdef CONFIG_LEDS_CLASS
u8 led_state;
struct led_classdev *led[5];
#endif
const u32 alternate_modes;
const char * const real_tag;
const char * const real_name;
const u16 real_product_id;
void (*set_range)(struct hid_device *hid, u16 range);
};
struct lg4ff_device_entry {
spinlock_t report_lock; /* Protect output HID report */
struct hid_report *report;
struct lg4ff_wheel_data wdata;
};
static const signed short lg4ff_wheel_effects[] = {
FF_CONSTANT,
FF_AUTOCENTER,
-1
};
static const signed short no_wheel_effects[] = {
-1
};
struct lg4ff_wheel {
const u32 product_id;
const signed short *ff_effects;
const u16 min_range;
const u16 max_range;
void (*set_range)(struct hid_device *hid, u16 range);
};
struct lg4ff_compat_mode_switch {
const u8 cmd_count; /* Number of commands to send */
const u8 cmd[];
};
struct lg4ff_wheel_ident_info {
const u32 modes;
const u16 mask;
const u16 result;
const u16 real_product_id;
};
struct lg4ff_multimode_wheel {
const u16 product_id;
const u32 alternate_modes;
const char *real_tag;
const char *real_name;
};
struct lg4ff_alternate_mode {
const u16 product_id;
const char *tag;
const char *name;
};
static const struct lg4ff_wheel lg4ff_devices[] = {
{USB_DEVICE_ID_LOGITECH_WINGMAN_FG, no_wheel_effects, 40, 180, NULL},
{USB_DEVICE_ID_LOGITECH_WINGMAN_FFG, lg4ff_wheel_effects, 40, 180, NULL},
{USB_DEVICE_ID_LOGITECH_WHEEL, lg4ff_wheel_effects, 40, 270, NULL},
{USB_DEVICE_ID_LOGITECH_MOMO_WHEEL, lg4ff_wheel_effects, 40, 270, NULL},
{USB_DEVICE_ID_LOGITECH_DFP_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_dfp},
{USB_DEVICE_ID_LOGITECH_G25_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
{USB_DEVICE_ID_LOGITECH_DFGT_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
{USB_DEVICE_ID_LOGITECH_G27_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
{USB_DEVICE_ID_LOGITECH_G29_WHEEL, lg4ff_wheel_effects, 40, 900, lg4ff_set_range_g25},
{USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2, lg4ff_wheel_effects, 40, 270, NULL},
{USB_DEVICE_ID_LOGITECH_WII_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}
};
static const struct lg4ff_multimode_wheel lg4ff_multimode_wheels[] = {
{USB_DEVICE_ID_LOGITECH_DFP_WHEEL,
LG4FF_MODE_NATIVE | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
LG4FF_DFP_TAG, LG4FF_DFP_NAME},
{USB_DEVICE_ID_LOGITECH_G25_WHEEL,
LG4FF_MODE_NATIVE | LG4FF_MODE_G25 | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
LG4FF_G25_TAG, LG4FF_G25_NAME},
{USB_DEVICE_ID_LOGITECH_DFGT_WHEEL,
LG4FF_MODE_NATIVE | LG4FF_MODE_DFGT | LG4FF_MODE_DFP | LG4FF_MODE_DFEX,
Annotation
- Immediate include surface: `linux/input.h`, `linux/usb.h`, `linux/hid.h`, `usbhid/usbhid.h`, `hid-lg.h`, `hid-lg4ff.h`, `hid-ids.h`.
- Detected declarations: `struct lg4ff_wheel_data`, `struct lg4ff_device_entry`, `struct lg4ff_wheel`, `struct lg4ff_compat_mode_switch`, `struct lg4ff_wheel_ident_info`, `struct lg4ff_multimode_wheel`, `struct lg4ff_alternate_mode`, `function lg4ff_adjust_dfp_x_axis`, `function lg4ff_adjust_input_event`, `function lg4ff_raw_event`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: source 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.