drivers/input/touchscreen/penmount.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/penmount.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/penmount.c- Extension
.c- Size
- 6894 bytes
- Lines
- 316
- 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/errno.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/input.hlinux/input/mt.hlinux/serio.h
Detected Declarations
struct mt_slotstruct pmfunction pm_mteventfunction pm_checkpacketfunction pm_parse_9000function pm_parse_6000function pm_parse_3000function pm_parse_6250function pm_interruptfunction pm_disconnectfunction pm_connect
Annotated Snippet
struct mt_slot {
unsigned short x, y;
bool active; /* is the touch valid? */
};
/*
* Per-touchscreen data.
*/
struct pm {
struct input_dev *dev;
struct serio *serio;
int idx;
unsigned char data[PM_MAX_LENGTH];
char phys[32];
unsigned char packetsize;
unsigned char maxcontacts;
struct mt_slot slots[PM_MAX_MTSLOT];
void (*parse_packet)(struct pm *);
};
/*
* pm_mtevent() sends mt events and also emulates pointer movement
*/
static void pm_mtevent(struct pm *pm, struct input_dev *input)
{
int i;
for (i = 0; i < pm->maxcontacts; ++i) {
input_mt_slot(input, i);
input_mt_report_slot_state(input, MT_TOOL_FINGER,
pm->slots[i].active);
if (pm->slots[i].active) {
input_event(input, EV_ABS, ABS_MT_POSITION_X, pm->slots[i].x);
input_event(input, EV_ABS, ABS_MT_POSITION_Y, pm->slots[i].y);
}
}
input_mt_report_pointer_emulation(input, true);
input_sync(input);
}
/*
* pm_checkpacket() checks if data packet is valid
*/
static bool pm_checkpacket(unsigned char *packet)
{
int total = 0;
int i;
for (i = 0; i < 5; i++)
total += packet[i];
return packet[5] == (unsigned char)~(total & 0xff);
}
static void pm_parse_9000(struct pm *pm)
{
struct input_dev *dev = pm->dev;
if ((pm->data[0] & 0x80) && pm->packetsize == ++pm->idx) {
input_report_abs(dev, ABS_X, pm->data[1] * 128 + pm->data[2]);
input_report_abs(dev, ABS_Y, pm->data[3] * 128 + pm->data[4]);
input_report_key(dev, BTN_TOUCH, !!(pm->data[0] & 0x40));
input_sync(dev);
pm->idx = 0;
}
}
static void pm_parse_6000(struct pm *pm)
{
struct input_dev *dev = pm->dev;
if ((pm->data[0] & 0xbf) == 0x30 && pm->packetsize == ++pm->idx) {
if (pm_checkpacket(pm->data)) {
input_report_abs(dev, ABS_X,
pm->data[2] * 256 + pm->data[1]);
input_report_abs(dev, ABS_Y,
pm->data[4] * 256 + pm->data[3]);
input_report_key(dev, BTN_TOUCH, pm->data[0] & 0x40);
input_sync(dev);
}
pm->idx = 0;
}
}
static void pm_parse_3000(struct pm *pm)
{
Annotation
- Immediate include surface: `linux/errno.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/input.h`, `linux/input/mt.h`, `linux/serio.h`.
- Detected declarations: `struct mt_slot`, `struct pm`, `function pm_mtevent`, `function pm_checkpacket`, `function pm_parse_9000`, `function pm_parse_6000`, `function pm_parse_3000`, `function pm_parse_6250`, `function pm_interrupt`, `function pm_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.