drivers/hid/bpf/progs/Huion__KeydialK20-Bluetooth.bpf.c
Source file repositories/reference/linux-study-clean/drivers/hid/bpf/progs/Huion__KeydialK20-Bluetooth.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/bpf/progs/Huion__KeydialK20-Bluetooth.bpf.c- Extension
.c- Size
- 25473 bytes
- Lines
- 493
- 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_reportfunction BPF_PROGfunction 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;
} __packed * pad_report = (struct pad_report *)data;
if (!data)
return 0; /* EPERM check */
/* Report ID 1 - Keyboard events (button presses) */
if (data[0] == BT_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 */
};
__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 (int i = 4; i < BT_PAD_KBD_REPORT_LENGTH; i++) {
if (!data[i])
break;
for (size_t b = 0; b < ARRAY_SIZE(button_mapping); b++) {
if (data[i] != 0xff && data[i] == button_mapping[b]) {
buttons |= BIT(b);
break;
}
}
}
last_button_state = buttons;
pad_report->report_id = OUR_REPORT_ID;
pad_report->btn_stylus = 0;
pad_report->x = 0;
pad_report->y = 0;
pad_report->buttons = buttons;
pad_report->wheel = 0;
return sizeof(struct pad_report);
}
/* Report ID 2 - Consumer control events (the button inside the wheel) */
if (data[0] == BT_PAD_CC_REPORT_ID) {
const __u8 PlayPause = 0xcd;
if (data[1] == PlayPause)
last_button_state |= BIT(18);
else
last_button_state &= ~BIT(18);
pad_report->report_id = OUR_REPORT_ID;
pad_report->btn_stylus = 0;
pad_report->x = 0;
pad_report->y = 0;
pad_report->buttons = last_button_state;
pad_report->wheel = 0;
return sizeof(struct pad_report);
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`, `function BPF_PROG`, `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.