drivers/hid/bpf/progs/Huion__Inspiroy-2-S.bpf.c
Source file repositories/reference/linux-study-clean/drivers/hid/bpf/progs/Huion__Inspiroy-2-S.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/bpf/progs/Huion__Inspiroy-2-S.bpf.c- Extension
.c- Size
- 19690 bytes
- Lines
- 580
- 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 propertyfunction BPF_PROGfunction probe
Annotated Snippet
struct pad_report {
__u8 report_id;
__u8 btn_stylus;
__u8 x;
__u8 y;
__u8 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] are the buttons, mapped correctly */
last_button_state = data[4];
wheel = 0; // wheel
}
pad_report = (struct pad_report *)data;
pad_report->report_id = PAD_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);
} else if (data[1] & 0x80) { /* Pen reports with InRange 1 */
__u8 tip_state = data[1] & 0x1;
__u8 sec_barrel_state = data[1] & 0x4;
if (force_tip_down_count > 0) {
data[1] |= 0x1;
--force_tip_down_count;
if (tip_state)
force_tip_down_count = 0;
}
/* Tip was down and we just pressed or released the
* secondary barrel switch (the physical eraser
* button). The device will send up to 4
* reports with Tip Switch 0 and sometimes
* this report has Tip Switch 0.
*/
if (last_tip_state &&
last_sec_barrel_state != sec_barrel_state) {
force_tip_down_count = 4;
data[1] |= 0x1;
}
last_tip_state = tip_state;
last_sec_barrel_state = sec_barrel_state;
}
}
return 0;
}
HID_BPF_OPS(inspiroy_2) = {
.hid_device_event = (void *)inspiroy_2_fix_events,
.hid_rdesc_fixup = (void *)hid_fix_rdesc,
};
SEC("syscall")
int probe(struct hid_bpf_probe_args *ctx)
{
switch (ctx->rdesc_size) {
case PAD_REPORT_DESCRIPTOR_LENGTH:
case PEN_REPORT_DESCRIPTOR_LENGTH:
case VENDOR_REPORT_DESCRIPTOR_LENGTH:
ctx->retval = 0;
break;
default:
ctx->retval = -EINVAL;
}
return 0;
}
char _license[] SEC("license") = "GPL";
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 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.