drivers/hid/i2c-hid/i2c-hid-core.c
Source file repositories/reference/linux-study-clean/drivers/hid/i2c-hid/i2c-hid-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/i2c-hid/i2c-hid-core.c- Extension
.c- Size
- 37063 bytes
- Lines
- 1411
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/module.hlinux/i2c.hlinux/interrupt.hlinux/input.hlinux/irq.hlinux/delay.hlinux/slab.hlinux/pm.hlinux/pm_wakeirq.hlinux/device.hlinux/wait.hlinux/err.hlinux/string.hlinux/list.hlinux/jiffies.hlinux/kernel.hlinux/hid.hlinux/mutex.hlinux/unaligned.hdrm/drm_panel.h../hid-ids.hi2c-hid.h
Detected Declarations
struct i2c_hid_descstruct i2c_hidfunction i2c_hid_lookup_quirkfunction i2c_hid_probe_addressfunction i2c_hid_xferfunction i2c_hid_read_registerfunction i2c_hid_encode_commandfunction i2c_hid_get_reportfunction i2c_hid_format_reportfunction i2c_hid_set_or_send_reportfunction i2c_hid_set_power_commandfunction i2c_hid_set_powerfunction i2c_hid_start_hwresetfunction scoped_guardfunction i2c_hid_finish_hwresetfunction msecs_to_jiffiesfunction i2c_hid_get_inputfunction i2c_hid_irqfunction i2c_hid_get_report_lengthfunction i2c_hid_find_max_reportfunction i2c_hid_free_buffersfunction i2c_hid_alloc_buffersfunction i2c_hid_get_raw_reportfunction i2c_hid_output_raw_reportfunction i2c_hid_output_reportfunction i2c_hid_raw_requestfunction i2c_hid_parsefunction i2c_hid_startfunction i2c_hid_stopfunction i2c_hid_openfunction i2c_hid_closefunction i2c_hid_init_irqfunction i2c_hid_fetch_hid_descriptorfunction i2c_hid_core_power_upfunction i2c_hid_core_power_downfunction i2c_hid_core_shutdown_tailfunction i2c_hid_core_restore_sequencefunction i2c_hid_core_suspendfunction i2c_hid_core_resumefunction __i2c_hid_core_probefunction i2c_hid_core_register_hidfunction i2c_hid_core_probe_panel_followerfunction ihid_core_panel_follower_workfunction i2c_hid_core_panel_follower_resumefunction i2c_hid_core_panel_follower_suspendfunction i2c_hid_core_register_panel_followerfunction i2c_hid_core_probefunction i2c_hid_core_remove
Annotated Snippet
struct i2c_hid_desc {
__le16 wHIDDescLength;
__le16 bcdVersion;
__le16 wReportDescLength;
__le16 wReportDescRegister;
__le16 wInputRegister;
__le16 wMaxInputLength;
__le16 wOutputRegister;
__le16 wMaxOutputLength;
__le16 wCommandRegister;
__le16 wDataRegister;
__le16 wVendorID;
__le16 wProductID;
__le16 wVersionID;
__le32 reserved;
} __packed;
/* The main device structure */
struct i2c_hid {
struct i2c_client *client; /* i2c client */
struct hid_device *hid; /* pointer to corresponding HID dev */
struct i2c_hid_desc hdesc; /* the HID Descriptor */
__le16 wHIDDescRegister; /* location of the i2c
* register of the HID
* descriptor. */
unsigned int bufsize; /* i2c buffer size */
u8 *inbuf; /* Input buffer */
u8 *rawbuf; /* Raw Input buffer */
u8 *cmdbuf; /* Command buffer */
unsigned long flags; /* device flags */
unsigned long quirks; /* Various quirks */
wait_queue_head_t wait; /* For waiting the interrupt */
struct mutex cmd_lock; /* protects cmdbuf and rawbuf */
struct mutex reset_lock;
struct i2chid_ops *ops;
struct drm_panel_follower panel_follower;
struct work_struct panel_follower_work;
bool is_panel_follower;
bool panel_follower_work_finished;
};
static const struct i2c_hid_quirks {
__u16 idVendor;
__u16 idProduct;
__u32 quirks;
} i2c_hid_quirks[] = {
{ I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
{ I2C_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15,
I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
{ I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118,
I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
{ USB_VENDOR_ID_ALPS_JP, HID_ANY_ID,
I2C_HID_QUIRK_RESET_ON_RESUME },
{ I2C_VENDOR_ID_SYNAPTICS, I2C_PRODUCT_ID_SYNAPTICS_SYNA2393,
I2C_HID_QUIRK_RESET_ON_RESUME },
{ USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720,
I2C_HID_QUIRK_BAD_INPUT_SIZE },
{ I2C_VENDOR_ID_CIRQUE, I2C_PRODUCT_ID_CIRQUE_1063,
I2C_HID_QUIRK_NO_SLEEP_ON_SUSPEND },
/*
* Without additional power on command, at least some QTEC devices send garbage
*/
{ I2C_VENDOR_ID_QTEC, HID_ANY_ID,
I2C_HID_QUIRK_RE_POWER_ON },
/*
* Sending the wakeup after reset actually break ELAN touchscreen controller
*/
{ USB_VENDOR_ID_ELAN, HID_ANY_ID,
I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET |
I2C_HID_QUIRK_BOGUS_IRQ },
{ I2C_VENDOR_ID_GOODIX, I2C_DEVICE_ID_GOODIX_0D42,
I2C_HID_QUIRK_DELAY_WAKEUP_AFTER_RESUME },
{ I2C_VENDOR_ID_BLTP, I2C_PRODUCT_ID_BLTP7853,
I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
{ 0, 0 }
};
/*
* i2c_hid_lookup_quirk: return any quirks associated with a I2C HID device
* @idVendor: the 16-bit vendor ID
* @idProduct: the 16-bit product ID
*
* Returns: a u32 quirks value.
*/
static u32 i2c_hid_lookup_quirk(const u16 idVendor, const u16 idProduct)
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/input.h`, `linux/irq.h`, `linux/delay.h`, `linux/slab.h`, `linux/pm.h`.
- Detected declarations: `struct i2c_hid_desc`, `struct i2c_hid`, `function i2c_hid_lookup_quirk`, `function i2c_hid_probe_address`, `function i2c_hid_xfer`, `function i2c_hid_read_register`, `function i2c_hid_encode_command`, `function i2c_hid_get_report`, `function i2c_hid_format_report`, `function i2c_hid_set_or_send_report`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.