drivers/input/mouse/elantech.c
Source file repositories/reference/linux-study-clean/drivers/input/mouse/elantech.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/mouse/elantech.c- Extension
.c- Size
- 61836 bytes
- Lines
- 2225
- Domain
- Driver Families
- Bucket
- drivers/input
- 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.
- 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/delay.hlinux/dmi.hlinux/slab.hlinux/module.hlinux/i2c.hlinux/input.hlinux/input/mt.hlinux/platform_device.hlinux/serio.hlinux/libps2.hlinux/unaligned.hpsmouse.helantech.helan_i2c.h
Detected Declarations
struct elantech_attr_datafunction synaptics_send_cmdfunction elantech_send_cmdfunction elantech_ps2_commandfunction elantech_read_reg_paramsfunction elantech_write_reg_paramsfunction elantech_read_regfunction elantech_write_regfunction elantech_packet_dumpfunction elantech_is_buttonpadfunction elantech_report_absolute_v1function elantech_set_slotfunction elantech_report_semi_mt_datafunction elantech_report_absolute_v2function elantech_report_trackpointfunction elantech_report_absolute_v3function elantech_input_sync_v4function process_packet_status_v4function process_packet_head_v4function process_packet_motion_v4function elantech_report_absolute_v4function elantech_packet_check_v1function elantech_debounce_check_v2function elantech_packet_check_v2function elantech_packet_check_v3function elantech_packet_check_v4function elantech_process_bytefunction elantech_set_rate_restore_reg_07function elantech_set_absolute_modefunction elantech_convert_resfunction elantech_get_resolution_v4function elantech_set_buttonpad_propfunction elantech_set_input_paramsfunction elantech_show_int_attrfunction elantech_set_int_attrfunction elantech_is_signature_validfunction elantech_detectfunction elantech_disconnectfunction elantech_reconnectfunction elantech_change_report_idfunction elantech_set_propertiesfunction elantech_query_infofunction elantech_create_smbusfunction elantech_setup_smbusfunction elantech_use_host_notifyfunction elantech_init_smbusfunction elantech_setup_ps2function elantech_init_ps2
Annotated Snippet
struct elantech_attr_data {
size_t field_offset;
unsigned char reg;
};
/*
* Display a register value by reading a sysfs entry
*/
static ssize_t elantech_show_int_attr(struct psmouse *psmouse, void *data,
char *buf)
{
struct elantech_data *etd = psmouse->private;
struct elantech_attr_data *attr = data;
unsigned char *reg = (unsigned char *) etd + attr->field_offset;
int rc = 0;
if (attr->reg)
rc = elantech_read_reg(psmouse, attr->reg, reg);
return sprintf(buf, "0x%02x\n", (attr->reg && rc) ? -1 : *reg);
}
/*
* Write a register value by writing a sysfs entry
*/
static ssize_t elantech_set_int_attr(struct psmouse *psmouse,
void *data, const char *buf, size_t count)
{
struct elantech_data *etd = psmouse->private;
struct elantech_attr_data *attr = data;
unsigned char *reg = (unsigned char *) etd + attr->field_offset;
unsigned char value;
int err;
err = kstrtou8(buf, 16, &value);
if (err)
return err;
/* Do we need to preserve some bits for version 2 hardware too? */
if (etd->info.hw_version == 1) {
if (attr->reg == 0x10)
/* Force absolute mode always on */
value |= ETP_R10_ABSOLUTE_MODE;
else if (attr->reg == 0x11)
/* Force 4 byte mode always on */
value |= ETP_R11_4_BYTE_MODE;
}
if (!attr->reg || elantech_write_reg(psmouse, attr->reg, value) == 0)
*reg = value;
return count;
}
#define ELANTECH_INT_ATTR(_name, _register) \
static struct elantech_attr_data elantech_attr_##_name = { \
.field_offset = offsetof(struct elantech_data, _name), \
.reg = _register, \
}; \
PSMOUSE_DEFINE_ATTR(_name, 0644, \
&elantech_attr_##_name, \
elantech_show_int_attr, \
elantech_set_int_attr)
#define ELANTECH_INFO_ATTR(_name) \
static struct elantech_attr_data elantech_attr_##_name = { \
.field_offset = offsetof(struct elantech_data, info) + \
offsetof(struct elantech_device_info, _name), \
.reg = 0, \
}; \
PSMOUSE_DEFINE_ATTR(_name, 0644, \
&elantech_attr_##_name, \
elantech_show_int_attr, \
elantech_set_int_attr)
ELANTECH_INT_ATTR(reg_07, 0x07);
ELANTECH_INT_ATTR(reg_10, 0x10);
ELANTECH_INT_ATTR(reg_11, 0x11);
ELANTECH_INT_ATTR(reg_20, 0x20);
ELANTECH_INT_ATTR(reg_21, 0x21);
ELANTECH_INT_ATTR(reg_22, 0x22);
ELANTECH_INT_ATTR(reg_23, 0x23);
ELANTECH_INT_ATTR(reg_24, 0x24);
ELANTECH_INT_ATTR(reg_25, 0x25);
ELANTECH_INT_ATTR(reg_26, 0x26);
ELANTECH_INFO_ATTR(debug);
ELANTECH_INFO_ATTR(paritycheck);
ELANTECH_INFO_ATTR(crc_enabled);
static struct attribute *elantech_attrs[] = {
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dmi.h`, `linux/slab.h`, `linux/module.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/mt.h`, `linux/platform_device.h`.
- Detected declarations: `struct elantech_attr_data`, `function synaptics_send_cmd`, `function elantech_send_cmd`, `function elantech_ps2_command`, `function elantech_read_reg_params`, `function elantech_write_reg_params`, `function elantech_read_reg`, `function elantech_write_reg`, `function elantech_packet_dump`, `function elantech_is_buttonpad`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source 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.