drivers/input/tablet/hanwang.c
Source file repositories/reference/linux-study-clean/drivers/input/tablet/hanwang.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/tablet/hanwang.c- Extension
.c- Size
- 11517 bytes
- Lines
- 444
- 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.
- 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/types.hlinux/kernel.hlinux/slab.hlinux/module.hlinux/usb/input.h
Detected Declarations
struct hanwangstruct hanwang_featuresenum hanwang_tablet_typefunction hanwang_parse_packetfunction hanwang_irqfunction hanwang_openfunction hanwang_closefunction get_featuresfunction hanwang_probefunction hanwang_disconnect
Annotated Snippet
struct hanwang {
unsigned char *data;
dma_addr_t data_dma;
struct input_dev *dev;
struct usb_device *usbdev;
struct urb *irq;
const struct hanwang_features *features;
unsigned int current_tool;
unsigned int current_id;
char name[64];
char phys[32];
};
struct hanwang_features {
unsigned short pid;
char *name;
enum hanwang_tablet_type type;
int pkg_len;
int max_x;
int max_y;
int max_tilt_x;
int max_tilt_y;
int max_pressure;
};
static const struct hanwang_features features_array[] = {
{ 0x8528, "Hanwang Art Master III 0906", HANWANG_ART_MASTER_III,
ART_MASTER_PKGLEN_MAX, 0x5757, 0x3692, 0x3f, 0x7f, 2048 },
{ 0x8529, "Hanwang Art Master III 0604", HANWANG_ART_MASTER_III,
ART_MASTER_PKGLEN_MAX, 0x3d84, 0x2672, 0x3f, 0x7f, 2048 },
{ 0x852a, "Hanwang Art Master III 1308", HANWANG_ART_MASTER_III,
ART_MASTER_PKGLEN_MAX, 0x7f00, 0x4f60, 0x3f, 0x7f, 2048 },
{ 0x8401, "Hanwang Art Master HD 5012", HANWANG_ART_MASTER_HD,
ART_MASTER_PKGLEN_MAX, 0x678e, 0x4150, 0x3f, 0x7f, 1024 },
{ 0x8503, "Hanwang Art Master II", HANWANG_ART_MASTER_II,
ART_MASTER_PKGLEN_MAX, 0x27de, 0x1cfe, 0x3f, 0x7f, 1024 },
};
static const int hw_eventtypes[] = {
EV_KEY, EV_ABS, EV_MSC,
};
static const int hw_absevents[] = {
ABS_X, ABS_Y, ABS_TILT_X, ABS_TILT_Y, ABS_WHEEL,
ABS_RX, ABS_RY, ABS_PRESSURE, ABS_MISC,
};
static const int hw_btnevents[] = {
BTN_STYLUS, BTN_STYLUS2, BTN_TOOL_PEN, BTN_TOOL_RUBBER,
BTN_TOOL_MOUSE, BTN_TOOL_FINGER,
BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8,
};
static const int hw_mscevents[] = {
MSC_SERIAL,
};
static void hanwang_parse_packet(struct hanwang *hanwang)
{
unsigned char *data = hanwang->data;
struct input_dev *input_dev = hanwang->dev;
struct usb_device *dev = hanwang->usbdev;
enum hanwang_tablet_type type = hanwang->features->type;
int i;
u16 p;
if (type == HANWANG_ART_MASTER_II) {
hanwang->current_tool = BTN_TOOL_PEN;
hanwang->current_id = STYLUS_DEVICE_ID;
}
switch (data[0]) {
case 0x02: /* data packet */
switch (data[1]) {
case 0x80: /* tool prox out */
if (type != HANWANG_ART_MASTER_II) {
hanwang->current_id = 0;
input_report_key(input_dev,
hanwang->current_tool, 0);
}
break;
case 0x00: /* artmaster ii pen leave */
if (type == HANWANG_ART_MASTER_II) {
hanwang->current_id = 0;
input_report_key(input_dev,
hanwang->current_tool, 0);
}
break;
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/slab.h`, `linux/module.h`, `linux/usb/input.h`.
- Detected declarations: `struct hanwang`, `struct hanwang_features`, `enum hanwang_tablet_type`, `function hanwang_parse_packet`, `function hanwang_irq`, `function hanwang_open`, `function hanwang_close`, `function get_features`, `function hanwang_probe`, `function hanwang_disconnect`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
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.