drivers/input/touchscreen/wacom_w8001.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/wacom_w8001.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/wacom_w8001.c- Extension
.c- Size
- 16958 bytes
- Lines
- 705
- 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/mt.hlinux/serio.hlinux/ctype.hlinux/delay.h
Detected Declarations
struct w8001_coordstruct w8001_touch_querystruct w8001function parse_pen_datafunction parse_single_touchfunction scale_touch_coordinatesfunction parse_multi_touchfunction parse_touchqueryfunction report_pen_eventsfunction proximityfunction report_single_touchfunction w8001_interruptfunction w8001_commandfunction w8001_openfunction scoped_guardfunction w8001_closefunction w8001_detectfunction w8001_setup_penfunction w8001_setup_touchfunction w8001_set_devdatafunction w8001_disconnectfunction w8001_connect
Annotated Snippet
struct w8001_coord {
u8 rdy;
u8 tsw;
u8 f1;
u8 f2;
u16 x;
u16 y;
u16 pen_pressure;
u8 tilt_x;
u8 tilt_y;
};
/* touch query reply packet */
struct w8001_touch_query {
u16 x;
u16 y;
u8 panel_res;
u8 capacity_res;
u8 sensor_id;
};
/*
* Per-touchscreen data.
*/
struct w8001 {
struct input_dev *pen_dev;
struct input_dev *touch_dev;
struct serio *serio;
struct completion cmd_done;
int id;
int idx;
unsigned char response_type;
unsigned char response[W8001_MAX_LENGTH];
unsigned char data[W8001_MAX_LENGTH];
char phys[W8001_MAX_PHYS];
int type;
unsigned int pktlen;
u16 max_touch_x;
u16 max_touch_y;
u16 max_pen_x;
u16 max_pen_y;
char pen_name[64];
char touch_name[64];
int open_count;
struct mutex mutex;
};
static void parse_pen_data(u8 *data, struct w8001_coord *coord)
{
memset(coord, 0, sizeof(*coord));
coord->rdy = data[0] & 0x20;
coord->tsw = data[0] & 0x01;
coord->f1 = data[0] & 0x02;
coord->f2 = data[0] & 0x04;
coord->x = (data[1] & 0x7F) << 9;
coord->x |= (data[2] & 0x7F) << 2;
coord->x |= (data[6] & 0x60) >> 5;
coord->y = (data[3] & 0x7F) << 9;
coord->y |= (data[4] & 0x7F) << 2;
coord->y |= (data[6] & 0x18) >> 3;
coord->pen_pressure = data[5] & 0x7F;
coord->pen_pressure |= (data[6] & 0x07) << 7 ;
coord->tilt_x = data[7] & 0x7F;
coord->tilt_y = data[8] & 0x7F;
}
static void parse_single_touch(u8 *data, struct w8001_coord *coord)
{
coord->x = (data[1] << 7) | data[2];
coord->y = (data[3] << 7) | data[4];
coord->tsw = data[0] & 0x01;
}
static void scale_touch_coordinates(struct w8001 *w8001,
unsigned int *x, unsigned int *y)
{
if (w8001->max_pen_x && w8001->max_touch_x)
*x = *x * w8001->max_pen_x / w8001->max_touch_x;
if (w8001->max_pen_y && w8001->max_touch_y)
*y = *y * w8001->max_pen_y / w8001->max_touch_y;
}
static void parse_multi_touch(struct w8001 *w8001)
Annotation
- Immediate include surface: `linux/errno.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/input/mt.h`, `linux/serio.h`, `linux/ctype.h`, `linux/delay.h`.
- Detected declarations: `struct w8001_coord`, `struct w8001_touch_query`, `struct w8001`, `function parse_pen_data`, `function parse_single_touch`, `function scale_touch_coordinates`, `function parse_multi_touch`, `function parse_touchquery`, `function report_pen_events`, `function proximity`.
- 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.