Path: blob/master/drivers/hid/bpf/progs/Trust__Philips-SPK6327.bpf.c
170956 views
// SPDX-License-Identifier: GPL-2.0-only1/* Fix for Trust Philips SPK6327 (145f:024b)2* Modifier keys report as Array (0x00) instead of Variable (0x02)3* causing LCtrl, LAlt, Super etc. to all act as LShift4*/5#include "vmlinux.h"6#include "hid_bpf.h"7#include "hid_bpf_helpers.h"8#include <bpf/bpf_tracing.h>910#define VID_TRUST 0x145F11#define PID_SPK6327 0x024B1213HID_BPF_CONFIG(14HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, VID_TRUST, PID_SPK6327)15);1617SEC(HID_BPF_RDESC_FIXUP)18int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)19{20__u8 *data = hid_bpf_get_data(hctx, 0, 4096);2122if (!data)23return 0;2425/* Fix modifier keys: Input Array (0x00) -> Input Variable (0x02) */26if (data[101] == 0x00)27data[101] = 0x02;2829return 0;30}3132HID_BPF_OPS(trust_spk6327) = {33.hid_rdesc_fixup = (void *)hid_fix_rdesc,34};3536SEC("syscall")37int probe(struct hid_bpf_probe_args *ctx)38{39/* Only apply to interface 1 (169 bytes) not interface 0 (62 bytes) */40if (ctx->rdesc_size == 169)41ctx->retval = 0;42else43ctx->retval = -EINVAL;4445return 0;46}4748char _license[] SEC("license") = "GPL";495051