drivers/hid/bpf/progs/Huion__Inspiroy-2-M.bpf.c

Source file repositories/reference/linux-study-clean/drivers/hid/bpf/progs/Huion__Inspiroy-2-M.bpf.c

File Facts

System
Linux kernel
Corpus path
drivers/hid/bpf/progs/Huion__Inspiroy-2-M.bpf.c
Extension
.c
Size
19227 bytes
Lines
564
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct pad_report {
				__u8 report_id;
				__u8 btn_stylus;
				__u8 x;
				__u8 y;
				__u16 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] and data[5] are the buttons, mapped correctly */
				last_button_state = data[4] | (data[5] << 8);
				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);
		}

		/* Pen reports need nothing done */
	}

	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

Implementation Notes