drivers/input/mouse/synaptics_i2c.c
Source file repositories/reference/linux-study-clean/drivers/input/mouse/synaptics_i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/mouse/synaptics_i2c.c- Extension
.c- Size
- 16961 bytes
- Lines
- 640
- 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.
- 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/irq.hlinux/interrupt.hlinux/input.hlinux/delay.hlinux/workqueue.hlinux/slab.hlinux/pm.h
Detected Declarations
struct synaptics_i2cfunction set_scan_ratefunction synaptics_i2c_reg_getfunction synaptics_i2c_reg_setfunction synaptics_i2c_word_getfunction synaptics_i2c_configfunction synaptics_i2c_reset_configfunction synaptics_i2c_check_errorfunction synaptics_i2c_get_inputfunction synaptics_i2c_irqfunction synaptics_i2c_check_paramsfunction synaptics_i2c_adjust_delayfunction synaptics_i2c_work_handlerfunction synaptics_i2c_openfunction synaptics_i2c_closefunction synaptics_i2c_set_input_paramsfunction synaptics_i2c_probefunction synaptics_i2c_suspendfunction synaptics_i2c_resume
Annotated Snippet
struct synaptics_i2c {
struct i2c_client *client;
struct input_dev *input;
struct delayed_work dwork;
int no_data_count;
int no_decel_param;
int reduce_report_param;
int no_filter_param;
int scan_rate_param;
int scan_ms;
};
static inline void set_scan_rate(struct synaptics_i2c *touch, int scan_rate)
{
touch->scan_ms = MSEC_PER_SEC / scan_rate;
touch->scan_rate_param = scan_rate;
}
/*
* Driver's initial design makes no race condition possible on i2c bus,
* so there is no need in any locking.
* Keep it in mind, while playing with the code.
*/
static s32 synaptics_i2c_reg_get(struct i2c_client *client, u16 reg)
{
int error;
error = i2c_smbus_write_byte_data(client, PAGE_SEL_REG, reg >> 8);
if (error)
return error;
return i2c_smbus_read_byte_data(client, reg & 0xff);
}
static s32 synaptics_i2c_reg_set(struct i2c_client *client, u16 reg, u8 val)
{
int error;
error = i2c_smbus_write_byte_data(client, PAGE_SEL_REG, reg >> 8);
if (error)
return error;
error = i2c_smbus_write_byte_data(client, reg & 0xff, val);
if (error)
return error;
return error;
}
static s32 synaptics_i2c_word_get(struct i2c_client *client, u16 reg)
{
int error;
error = i2c_smbus_write_byte_data(client, PAGE_SEL_REG, reg >> 8);
if (error)
return error;
return i2c_smbus_read_word_data(client, reg & 0xff);
}
static int synaptics_i2c_config(struct i2c_client *client)
{
int control;
int error;
u8 int_en;
/* set Report Rate to Device Highest (>=80) and Sleep to normal */
error = synaptics_i2c_reg_set(client, DEV_CONTROL_REG, 0xc1);
if (error)
return error;
/* set Interrupt Disable to Func20 / Enable to Func10) */
int_en = (polling_req) ? 0 : INT_ENA_ABS_MSK | INT_ENA_REL_MSK;
error = synaptics_i2c_reg_set(client, INTERRUPT_EN_REG, int_en);
if (error)
return error;
control = synaptics_i2c_reg_get(client, GENERAL_2D_CONTROL_REG);
/* No Deceleration */
control |= no_decel ? 1 << NO_DECELERATION : 0;
/* Reduced Reporting */
control |= reduce_report ? 1 << REDUCE_REPORTING : 0;
/* No Filter */
control |= no_filter ? 1 << NO_FILTER : 0;
error = synaptics_i2c_reg_set(client, GENERAL_2D_CONTROL_REG, control);
if (error)
return error;
return 0;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `linux/irq.h`, `linux/interrupt.h`, `linux/input.h`, `linux/delay.h`, `linux/workqueue.h`, `linux/slab.h`.
- Detected declarations: `struct synaptics_i2c`, `function set_scan_rate`, `function synaptics_i2c_reg_get`, `function synaptics_i2c_reg_set`, `function synaptics_i2c_word_get`, `function synaptics_i2c_config`, `function synaptics_i2c_reset_config`, `function synaptics_i2c_check_error`, `function synaptics_i2c_get_input`, `function synaptics_i2c_irq`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- 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.