drivers/input/touchscreen/novatek-nvt-ts.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/novatek-nvt-ts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/novatek-nvt-ts.c- Extension
.c- Size
- 9033 bytes
- Lines
- 350
- 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/gpio/consumer.hlinux/interrupt.hlinux/i2c.hlinux/input.hlinux/input/mt.hlinux/input/touchscreen.hlinux/module.hlinux/unaligned.h
Detected Declarations
struct nvt_ts_i2c_chip_datastruct nvt_ts_datafunction nvt_ts_read_datafunction nvt_ts_irqfunction nvt_ts_startfunction nvt_ts_stopfunction nvt_ts_suspendfunction nvt_ts_resumefunction nvt_ts_probe
Annotated Snippet
struct nvt_ts_i2c_chip_data {
u8 chip_id;
};
struct nvt_ts_data {
struct i2c_client *client;
struct input_dev *input;
struct gpio_desc *reset_gpio;
struct regulator_bulk_data regulators[2];
struct touchscreen_properties prop;
int max_touches;
u8 buf[NVT_TS_TOUCH_SIZE * NVT_TS_MAX_TOUCHES];
};
static int nvt_ts_read_data(struct i2c_client *client, u8 reg, u8 *data, int count)
{
struct i2c_msg msg[2] = {
{
.addr = client->addr,
.len = 1,
.buf = ®,
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = count,
.buf = data,
}
};
int ret;
ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
if (ret != ARRAY_SIZE(msg)) {
dev_err(&client->dev, "Error reading from 0x%02x: %d\n", reg, ret);
return (ret < 0) ? ret : -EIO;
}
return 0;
}
static irqreturn_t nvt_ts_irq(int irq, void *dev_id)
{
struct nvt_ts_data *data = dev_id;
struct device *dev = &data->client->dev;
int i, error, slot, x, y;
bool active;
u8 *touch;
error = nvt_ts_read_data(data->client, NVT_TS_TOUCH_START, data->buf,
data->max_touches * NVT_TS_TOUCH_SIZE);
if (error)
return IRQ_HANDLED;
for (i = 0; i < data->max_touches; i++) {
touch = &data->buf[i * NVT_TS_TOUCH_SIZE];
if (touch[0] == NVT_TS_TOUCH_INVALID)
continue;
slot = touch[0] >> NVT_TS_TOUCH_SLOT_SHIFT;
if (slot < 1 || slot > data->max_touches) {
dev_warn(dev, "slot %d out of range, ignoring\n", slot);
continue;
}
switch (touch[0] & NVT_TS_TOUCH_TYPE_MASK) {
case NVT_TS_TOUCH_NEW:
case NVT_TS_TOUCH_UPDATE:
active = true;
break;
case NVT_TS_TOUCH_RELEASE:
active = false;
break;
default:
dev_warn(dev, "slot %d unknown state %d\n", slot, touch[0] & 7);
continue;
}
slot--;
x = (touch[1] << 4) | (touch[3] >> 4);
y = (touch[2] << 4) | (touch[3] & 0x0f);
input_mt_slot(data->input, slot);
input_mt_report_slot_state(data->input, MT_TOOL_FINGER, active);
touchscreen_report_pos(data->input, &data->prop, x, y, true);
}
input_mt_sync_frame(data->input);
input_sync(data->input);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/mt.h`, `linux/input/touchscreen.h`, `linux/module.h`.
- Detected declarations: `struct nvt_ts_i2c_chip_data`, `struct nvt_ts_data`, `function nvt_ts_read_data`, `function nvt_ts_irq`, `function nvt_ts_start`, `function nvt_ts_stop`, `function nvt_ts_suspend`, `function nvt_ts_resume`, `function nvt_ts_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.