drivers/hid/bpf/progs/Huion__KeydialK20.bpf.c
Source file repositories/reference/linux-study-clean/drivers/hid/bpf/progs/Huion__KeydialK20.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/bpf/progs/Huion__KeydialK20.bpf.c- Extension
.c- Size
- 22824 bytes
- Lines
- 533
- Domain
- Driver Families
- Bucket
- drivers/hid
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hhid_bpf.hhid_bpf_helpers.hhid_report_helpers.hbpf/bpf_tracing.h
Detected Declarations
struct pad_reportstruct pad_reportfunction BPF_PROGfunction propertyfunction BPF_PROGfunction probe
Annotated Snippet
struct pad_report {
__u8 report_id;
__u8 btn_stylus:1;
__u8 pad:7;
__u8 x;
__u8 y;
__u32 buttons;
__u8 wheel;
} __attribute__((packed)) *pad_report;
__u8 wheel = 0;
/* Wheel report */
if (data[1] == 0xf1) {
if (data[5] == 2)
wheel = 0xff;
else
wheel = data[5];
} else {
/* data[4..6] are the buttons, mapped correctly */
last_button_state = data[4] | (data[5] << 8) | (data[6] << 16);
wheel = 0; // wheel
}
pad_report = (struct pad_report *)data;
pad_report->report_id = VENDOR_REPORT_ID;
pad_report->btn_stylus = 0;
pad_report->x = 0;
pad_report->y = 0;
pad_report->buttons = last_button_state;
pad_report->wheel = wheel;
return sizeof(struct pad_report);
}
if (data[0] == PAD_KBD_REPORT_ID) {
const __u8 button_mapping[] = {
0x0e, /* Button 1: K */
0x0a, /* Button 2: G */
0x0f, /* Button 3: L */
0x4c, /* Button 4: Delete */
0x0c, /* Button 5: I */
0x07, /* Button 6: D */
0x05, /* Button 7: B */
0x08, /* Button 8: E */
0x16, /* Button 9: S */
0x1d, /* Button 10: Z */
0x06, /* Button 11: C */
0x19, /* Button 12: V */
0xff, /* Button 13: LeftControl */
0xff, /* Button 14: LeftAlt */
0xff, /* Button 15: LeftShift */
0x28, /* Button 16: Return Enter */
0x2c, /* Button 17: Spacebar */
0x11, /* Button 18: N */
};
/* See fixed_rdesc_pad */
struct pad_report {
__u8 report_id;
__u8 btn_stylus:1;
__u8 pad:7;
__u8 x;
__u8 y;
__u32 buttons;
__u8 wheel;
} __attribute__((packed)) *pad_report;
int i;
size_t b;
__u8 modifiers = data[1];
__u32 buttons = 0;
if (modifiers & 0x01) { /* Control */
buttons |= BIT(12);
}
if (modifiers & 0x02) { /* Shift */
buttons |= BIT(14);
}
if (modifiers & 0x04) { /* Alt */
buttons |= BIT(13);
}
for (i = 2; i < PAD_KBD_REPORT_LENGTH; i++) {
if (!data[i])
break;
for (b = 0; b < ARRAY_SIZE(button_mapping); b++) {
if (data[i] == button_mapping[b]) {
buttons |= BIT(b);
break;
}
Annotation
- Immediate include surface: `vmlinux.h`, `hid_bpf.h`, `hid_bpf_helpers.h`, `hid_report_helpers.h`, `bpf/bpf_tracing.h`.
- Detected declarations: `struct pad_report`, `struct pad_report`, `function BPF_PROG`, `function property`, `function BPF_PROG`, `function probe`.
- Atlas domain: Driver Families / drivers/hid.
- 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.