drivers/input/touchscreen/wacom_i2c.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/wacom_i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/wacom_i2c.c- Extension
.c- Size
- 6437 bytes
- Lines
- 275
- 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/bits.hlinux/module.hlinux/input.hlinux/i2c.hlinux/slab.hlinux/irq.hlinux/interrupt.hlinux/unaligned.h
Detected Declarations
struct wacom_featuresstruct wacom_i2cfunction wacom_query_devicefunction wacom_i2c_irqfunction wacom_i2c_openfunction wacom_i2c_closefunction wacom_i2c_probefunction wacom_i2c_suspendfunction wacom_i2c_resume
Annotated Snippet
struct wacom_features {
int x_max;
int y_max;
int pressure_max;
char fw_version;
};
struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
};
static int wacom_query_device(struct i2c_client *client,
struct wacom_features *features)
{
u8 get_query_data_cmd[] = {
WACOM_COMMAND_LSB,
WACOM_COMMAND_MSB,
REPORT_FEATURE | WACOM_QUERY_REPORT,
OPCODE_GET_REPORT,
WACOM_DATA_LSB,
WACOM_DATA_MSB,
};
u8 data[WACOM_QUERY_SIZE];
int ret;
struct i2c_msg msgs[] = {
/* Request reading of feature ReportID: 3 (Pen Query Data) */
{
.addr = client->addr,
.flags = 0,
.len = sizeof(get_query_data_cmd),
.buf = get_query_data_cmd,
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = sizeof(data),
.buf = data,
},
};
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (ret < 0)
return ret;
if (ret != ARRAY_SIZE(msgs))
return -EIO;
features->x_max = get_unaligned_le16(&data[3]);
features->y_max = get_unaligned_le16(&data[5]);
features->pressure_max = get_unaligned_le16(&data[11]);
features->fw_version = get_unaligned_le16(&data[13]);
dev_dbg(&client->dev,
"x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
features->x_max, features->y_max,
features->pressure_max, features->fw_version);
return 0;
}
static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
{
struct wacom_i2c *wac_i2c = dev_id;
struct input_dev *input = wac_i2c->input;
u8 *data = wac_i2c->data;
unsigned int x, y, pressure;
unsigned char tsw, f1, f2, ers;
int error;
error = i2c_master_recv(wac_i2c->client,
wac_i2c->data, sizeof(wac_i2c->data));
if (error < 0)
goto out;
tsw = data[3] & WACOM_TIP_SWITCH;
ers = data[3] & WACOM_ERASER;
f1 = data[3] & WACOM_BARREL_SWITCH;
f2 = data[3] & WACOM_BARREL_SWITCH_2;
x = le16_to_cpup((__le16 *)&data[4]);
y = le16_to_cpup((__le16 *)&data[6]);
pressure = le16_to_cpup((__le16 *)&data[8]);
if (!wac_i2c->prox)
wac_i2c->tool = (data[3] & (WACOM_ERASER | WACOM_INVERT)) ?
BTN_TOOL_RUBBER : BTN_TOOL_PEN;
Annotation
- Immediate include surface: `linux/bits.h`, `linux/module.h`, `linux/input.h`, `linux/i2c.h`, `linux/slab.h`, `linux/irq.h`, `linux/interrupt.h`, `linux/unaligned.h`.
- Detected declarations: `struct wacom_features`, `struct wacom_i2c`, `function wacom_query_device`, `function wacom_i2c_irq`, `function wacom_i2c_open`, `function wacom_i2c_close`, `function wacom_i2c_probe`, `function wacom_i2c_suspend`, `function wacom_i2c_resume`.
- 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.