drivers/input/touchscreen/zet6223.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/zet6223.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/zet6223.c- Extension
.c- Size
- 5792 bytes
- Lines
- 257
- 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/delay.hlinux/i2c.hlinux/input.hlinux/input/mt.hlinux/input/touchscreen.hlinux/interrupt.hlinux/module.hlinux/regulator/consumer.hlinux/unaligned.h
Detected Declarations
struct zet6223_tsfunction zet6223_startfunction zet6223_stopfunction zet6223_irqfunction zet6223_power_offfunction zet6223_power_onfunction zet6223_query_devicefunction zet6223_probe
Annotated Snippet
struct zet6223_ts {
struct i2c_client *client;
struct input_dev *input;
struct touchscreen_properties prop;
struct regulator_bulk_data supplies[2];
u16 max_x;
u16 max_y;
u8 fingernum;
};
static int zet6223_start(struct input_dev *dev)
{
struct zet6223_ts *ts = input_get_drvdata(dev);
enable_irq(ts->client->irq);
return 0;
}
static void zet6223_stop(struct input_dev *dev)
{
struct zet6223_ts *ts = input_get_drvdata(dev);
disable_irq(ts->client->irq);
}
static irqreturn_t zet6223_irq(int irq, void *dev_id)
{
struct zet6223_ts *ts = dev_id;
u16 finger_bits;
/*
* First 3 bytes are an identifier, two bytes of finger data.
* X, Y data per finger is 4 bytes.
*/
u8 bufsize = 3 + 4 * ts->fingernum;
u8 buf[ZET6223_MAX_PKT_SIZE];
int i;
int ret;
int error;
ret = i2c_master_recv(ts->client, buf, bufsize);
if (ret != bufsize) {
error = ret < 0 ? ret : -EIO;
dev_err_ratelimited(&ts->client->dev,
"Error reading input data: %d\n", error);
return IRQ_HANDLED;
}
if (buf[0] != ZET6223_VALID_PACKET)
return IRQ_HANDLED;
finger_bits = get_unaligned_be16(buf + 1);
for (i = 0; i < ts->fingernum; i++) {
if (!(finger_bits & BIT(15 - i)))
continue;
input_mt_slot(ts->input, i);
input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true);
input_event(ts->input, EV_ABS, ABS_MT_POSITION_X,
((buf[i + 3] >> 4) << 8) + buf[i + 4]);
input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y,
((buf[i + 3] & 0xF) << 8) + buf[i + 5]);
}
input_mt_sync_frame(ts->input);
input_sync(ts->input);
return IRQ_HANDLED;
}
static void zet6223_power_off(void *_ts)
{
struct zet6223_ts *ts = _ts;
regulator_bulk_disable(ARRAY_SIZE(ts->supplies), ts->supplies);
}
static int zet6223_power_on(struct zet6223_ts *ts)
{
struct device *dev = &ts->client->dev;
int error;
ts->supplies[0].supply = "vio";
ts->supplies[1].supply = "vcc";
error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->supplies),
ts->supplies);
if (error)
return error;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/mt.h`, `linux/input/touchscreen.h`, `linux/interrupt.h`, `linux/module.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct zet6223_ts`, `function zet6223_start`, `function zet6223_stop`, `function zet6223_irq`, `function zet6223_power_off`, `function zet6223_power_on`, `function zet6223_query_device`, `function zet6223_probe`.
- 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.