drivers/input/touchscreen/tsc40.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/tsc40.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/tsc40.c- Extension
.c- Size
- 3652 bytes
- Lines
- 173
- 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/kernel.hlinux/module.hlinux/slab.hlinux/input.hlinux/serio.h
Detected Declarations
struct tsc_serfunction tsc_process_datafunction tsc_interruptfunction tsc_connectfunction tsc_disconnect
Annotated Snippet
struct tsc_ser {
struct input_dev *dev;
struct serio *serio;
u32 idx;
unsigned char data[PACKET_LENGTH];
char phys[32];
};
static void tsc_process_data(struct tsc_ser *ptsc)
{
struct input_dev *dev = ptsc->dev;
u8 *data = ptsc->data;
u32 x;
u32 y;
x = ((data[1] & 0x03) << 8) | data[2];
y = ((data[3] & 0x03) << 8) | data[4];
input_report_abs(dev, ABS_X, x);
input_report_abs(dev, ABS_Y, y);
input_report_key(dev, BTN_TOUCH, 1);
input_sync(dev);
}
static irqreturn_t tsc_interrupt(struct serio *serio,
unsigned char data, unsigned int flags)
{
struct tsc_ser *ptsc = serio_get_drvdata(serio);
struct input_dev *dev = ptsc->dev;
ptsc->data[ptsc->idx] = data;
switch (ptsc->idx++) {
case 0:
if (unlikely((data & 0x3e) != 0x10)) {
dev_dbg(&serio->dev,
"unsynchronized packet start (0x%02x)\n", data);
ptsc->idx = 0;
} else if (!(data & 0x01)) {
input_report_key(dev, BTN_TOUCH, 0);
input_sync(dev);
ptsc->idx = 0;
}
break;
case 1:
case 3:
if (unlikely(data & 0xfc)) {
dev_dbg(&serio->dev,
"unsynchronized data 0x%02x at offset %d\n",
data, ptsc->idx - 1);
ptsc->idx = 0;
}
break;
case 4:
tsc_process_data(ptsc);
ptsc->idx = 0;
break;
}
return IRQ_HANDLED;
}
static int tsc_connect(struct serio *serio, struct serio_driver *drv)
{
struct tsc_ser *ptsc;
struct input_dev *input_dev;
int error;
ptsc = kzalloc_obj(*ptsc);
input_dev = input_allocate_device();
if (!ptsc || !input_dev) {
error = -ENOMEM;
goto fail1;
}
ptsc->serio = serio;
ptsc->dev = input_dev;
scnprintf(ptsc->phys, sizeof(ptsc->phys), "%s/input0", serio->phys);
input_dev->name = "TSC-10/25/40 Serial TouchScreen";
input_dev->phys = ptsc->phys;
input_dev->id.bustype = BUS_RS232;
input_dev->id.vendor = SERIO_TSC40;
input_dev->id.product = 40;
input_dev->id.version = 0x0001;
input_dev->dev.parent = &serio->dev;
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/input.h`, `linux/serio.h`.
- Detected declarations: `struct tsc_ser`, `function tsc_process_data`, `function tsc_interrupt`, `function tsc_connect`, `function tsc_disconnect`.
- 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.