Path: blob/master/drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c
26285 views
// SPDX-License-Identifier: GPL-2.0-only1/* Copyright (c) 2023 Benjamin Tissoires2*/34#include "vmlinux.h"5#include "hid_bpf.h"6#include "hid_bpf_helpers.h"7#include <bpf/bpf_tracing.h>89#define VID_HP 0x03F010#define PID_ELITE_PRESENTER 0x464A1112HID_BPF_CONFIG(13HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_GENERIC, VID_HP, PID_ELITE_PRESENTER)14);1516/*17* Already fixed as of commit 0db117359e47 ("HID: add quirk for 03f0:464a18* HP Elite Presenter Mouse") in the kernel, but this is a slightly better19* fix.20*21* The HP Elite Presenter Mouse HID Record Descriptor shows22* two mice (Report ID 0x1 and 0x2), one keypad (Report ID 0x5),23* two Consumer Controls (Report IDs 0x6 and 0x3).24* Prior to these fixes it registers one mouse, one keypad25* and one Consumer Control, and it was usable only as a26* digital laser pointer (one of the two mouses).27* We replace the second mouse collection with a pointer collection,28* allowing to use the device both as a mouse and a digital laser29* pointer.30*/3132SEC(HID_BPF_RDESC_FIXUP)33int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx)34{35__u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */);3637if (!data)38return 0; /* EPERM check */3940/* replace application mouse by application pointer on the second collection */41if (data[79] == 0x02)42data[79] = 0x01;4344return 0;45}4647HID_BPF_OPS(hp_elite_presenter) = {48.hid_rdesc_fixup = (void *)hid_fix_rdesc,49};5051SEC("syscall")52int probe(struct hid_bpf_probe_args *ctx)53{54ctx->retval = ctx->rdesc_size != 264;55if (ctx->retval)56ctx->retval = -EINVAL;5758return 0;59}6061char _license[] SEC("license") = "GPL";626364