drivers/input/touchscreen/wdt87xx_i2c.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/wdt87xx_i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/wdt87xx_i2c.c- Extension
.c- Size
- 28213 bytes
- Lines
- 1171
- 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/i2c.hlinux/input.hlinux/interrupt.hlinux/delay.hlinux/irq.hlinux/io.hlinux/module.hlinux/slab.hlinux/firmware.hlinux/input/mt.hlinux/acpi.hlinux/unaligned.h
Detected Declarations
struct wdt87xx_sys_paramstruct wdt87xx_datafunction wdt87xx_i2c_xferfunction wdt87xx_get_descfunction wdt87xx_get_stringfunction wdt87xx_get_featurefunction wdt87xx_set_featurefunction wdt87xx_send_commandfunction wdt87xx_sw_resetfunction wdt87xx_get_sysparamfunction wdt87xx_validate_firmwarefunction wdt87xx_validate_fw_chunkfunction wdt87xx_write_datafunction misrfunction wdt87xx_calculate_checksumfunction wdt87xx_get_checksumfunction wdt87xx_write_firmwarefunction wdt87xx_load_chunkfunction wdt87xx_do_update_firmwarefunction wdt87xx_update_firmwarefunction scoped_cond_guardfunction config_csum_showfunction fw_version_showfunction plat_id_showfunction update_config_storefunction update_fw_storefunction wdt87xx_report_contactfunction wdt87xx_ts_interruptfunction wdt87xx_ts_create_input_devicefunction wdt87xx_ts_probefunction wdt87xx_suspendfunction wdt87xx_resume
Annotated Snippet
struct wdt87xx_sys_param {
u16 fw_id;
u16 plat_id;
u16 xmls_id1;
u16 xmls_id2;
u16 phy_ch_x;
u16 phy_ch_y;
u16 phy_w;
u16 phy_h;
u16 scaling_factor;
u32 max_x;
u32 max_y;
u16 vendor_id;
u16 product_id;
};
struct wdt87xx_data {
struct i2c_client *client;
struct input_dev *input;
/* Mutex for fw update to prevent concurrent access */
struct mutex fw_mutex;
struct wdt87xx_sys_param param;
u8 phys[32];
};
static int wdt87xx_i2c_xfer(struct i2c_client *client,
void *txdata, size_t txlen,
void *rxdata, size_t rxlen)
{
struct i2c_msg msgs[] = {
{
.addr = client->addr,
.flags = 0,
.len = txlen,
.buf = txdata,
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = rxlen,
.buf = rxdata,
},
};
int error;
int ret;
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (ret != ARRAY_SIZE(msgs)) {
error = ret < 0 ? ret : -EIO;
dev_err(&client->dev, "%s: i2c transfer failed: %d\n",
__func__, error);
return error;
}
return 0;
}
static int wdt87xx_get_desc(struct i2c_client *client, u8 desc_idx,
u8 *buf, size_t len)
{
u8 tx_buf[] = { 0x22, 0x00, 0x10, 0x0E, 0x23, 0x00 };
int error;
tx_buf[2] |= desc_idx & 0xF;
error = wdt87xx_i2c_xfer(client, tx_buf, sizeof(tx_buf),
buf, len);
if (error) {
dev_err(&client->dev, "get desc failed: %d\n", error);
return error;
}
if (buf[0] != len) {
dev_err(&client->dev, "unexpected response to get desc: %d\n",
buf[0]);
return -EINVAL;
}
mdelay(WDT_COMMAND_DELAY_MS);
return 0;
}
static int wdt87xx_get_string(struct i2c_client *client, u8 str_idx,
u8 *buf, size_t len)
{
u8 tx_buf[] = { 0x22, 0x00, 0x13, 0x0E, str_idx, 0x23, 0x00 };
u8 rx_buf[PKT_WRITE_SIZE];
size_t rx_len = len + 2;
int error;
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/input.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/irq.h`, `linux/io.h`, `linux/module.h`, `linux/slab.h`.
- Detected declarations: `struct wdt87xx_sys_param`, `struct wdt87xx_data`, `function wdt87xx_i2c_xfer`, `function wdt87xx_get_desc`, `function wdt87xx_get_string`, `function wdt87xx_get_feature`, `function wdt87xx_set_feature`, `function wdt87xx_send_command`, `function wdt87xx_sw_reset`, `function wdt87xx_get_sysparam`.
- 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.