drivers/hid/bpf/progs/Trust__Philips-SPK6327.bpf.c
Source file repositories/reference/linux-study-clean/drivers/hid/bpf/progs/Trust__Philips-SPK6327.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/bpf/progs/Trust__Philips-SPK6327.bpf.c- Extension
.c- Size
- 1077 bytes
- Lines
- 50
- 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.hbpf/bpf_tracing.h
Detected Declarations
function BPF_PROGfunction probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/* Fix for Trust Philips SPK6327 (145f:024b)
* Modifier keys report as Array (0x00) instead of Variable (0x02)
* causing LCtrl, LAlt, Super etc. to all act as LShift
*/
#include "vmlinux.h"
#include "hid_bpf.h"
#include "hid_bpf_helpers.h"
#include <bpf/bpf_tracing.h>
#define VID_TRUST 0x145F
#define PID_SPK6327 0x024B
HID_BPF_CONFIG(
HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, VID_TRUST, PID_SPK6327)
);
SEC(HID_BPF_RDESC_FIXUP)
int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)
{
__u8 *data = hid_bpf_get_data(hctx, 0, 4096);
if (!data)
return 0;
/* Fix modifier keys: Input Array (0x00) -> Input Variable (0x02) */
if (data[101] == 0x00)
data[101] = 0x02;
return 0;
}
HID_BPF_OPS(trust_spk6327) = {
.hid_rdesc_fixup = (void *)hid_fix_rdesc,
};
SEC("syscall")
int probe(struct hid_bpf_probe_args *ctx)
{
/* Only apply to interface 1 (169 bytes) not interface 0 (62 bytes) */
if (ctx->rdesc_size == 169)
ctx->retval = 0;
else
ctx->retval = -EINVAL;
return 0;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `vmlinux.h`, `hid_bpf.h`, `hid_bpf_helpers.h`, `bpf/bpf_tracing.h`.
- Detected declarations: `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.