From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DD2015EFA3; Mon, 27 May 2024 14:13:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819203; cv=none; b=Q09IUyJU+7yKoFpQbUb18/Xw6ZyRAK8XY81jZyxynkCbld7BjNwdz1Rr4WS59Uu1HtG/FurHMoDiqWAzDzWwhTM6XlRGLjL41Sjj9pwVG17N6ampX5gH/dqTBrQAY4RRc3o6skwI9SqGXCg/uV47m5/hLiqid1fo46oFrWDot8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819203; c=relaxed/simple; bh=HksO7wi2Tu4etRYRKkyII0g6QFyH1LvtCOoKVJ36MLg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hlOQLIkZ3f38Ecc5BuQ7gM3NjKAX6XIb+9fMTEYUk2chrTCEsgt1n5oJCjM396l96o5RXOyRDUQh9Pt4PBmkLHeeBzF9nyyui8Vjv9J+KhdMKZAdDuKE0VCPpcFwSkAwH7LOPNFOaxe3kdIw11rtnOYVK0IrE4dxh9cNAh6KPh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=osi+wxSS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="osi+wxSS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76FFAC2BBFC; Mon, 27 May 2024 14:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819203; bh=HksO7wi2Tu4etRYRKkyII0g6QFyH1LvtCOoKVJ36MLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=osi+wxSSYXyfvMHBjmF/Y65q+erqgIo0H8rYK+g/p+CosV32DUxxjVGWOP4ltfYtM 7esqmSXJyM4fwkqLE9RfwoRyVKmW+cI6qgo/HsiFKsE1qv8sFj/KZbZDWCMg+IL9cv eSHn27uNNYH+mtC1hw9evFaY6Vk6i8kR7OO+d1Of1stTGW8R/ES0IfOYn973Lu12Fj 9fTW8UFonVXvhh29xZwxU2E+Z/yPcH+Sl6tYpP9GXYAXbZJ6FpIvDEvTOoXnkRHAzm Fymtowf1eXxKup723IWSo4XATaenSuUuHFGU2ja+GerACT3lgTWmH+kLx9Z4fyFAwq ndU8Tf+Hlacuw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Benjamin Tissoires , Peter Hutterer , Sasha Levin , jikos@kernel.org, linux-input@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 6.9 31/35] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Date: Mon, 27 May 2024 10:11:36 -0400 Message-ID: <20240527141214.3844331-31-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527141214.3844331-1-sashal@kernel.org> References: <20240527141214.3844331-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.9.2 Content-Transfer-Encoding: 8bit From: Benjamin Tissoires [ Upstream commit 4e6d2a297dd5be26ad409b7a05b20bd033d1c95e ] Duplicate of commit 0db117359e47 ("HID: add quirk for 03f0:464a HP Elite Presenter Mouse"), but in a slightly better way. This time we actually change the application collection, making clearer for userspace what the second mouse is. Note that having both hid-quirks fix and this HID-BPF fix is not a problem at all. Link: https://lore.kernel.org/r/20240410-bpf_sources-v1-4-a8bf16033ef8@kernel.org Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires Signed-off-by: Sasha Levin --- .../hid/bpf/progs/HP__Elite-Presenter.bpf.c | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c diff --git a/drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c b/drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c new file mode 100644 index 0000000000000..3d14bbb6f2762 --- /dev/null +++ b/drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (c) 2023 Benjamin Tissoires + */ + +#include "vmlinux.h" +#include "hid_bpf.h" +#include "hid_bpf_helpers.h" +#include + +#define VID_HP 0x03F0 +#define PID_ELITE_PRESENTER 0x464A + +HID_BPF_CONFIG( + HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_GENERIC, VID_HP, PID_ELITE_PRESENTER) +); + +/* + * Already fixed as of commit 0db117359e47 ("HID: add quirk for 03f0:464a + * HP Elite Presenter Mouse") in the kernel, but this is a slightly better + * fix. + * + * The HP Elite Presenter Mouse HID Record Descriptor shows + * two mice (Report ID 0x1 and 0x2), one keypad (Report ID 0x5), + * two Consumer Controls (Report IDs 0x6 and 0x3). + * Prior to these fixes it registers one mouse, one keypad + * and one Consumer Control, and it was usable only as a + * digital laser pointer (one of the two mouses). + * We replace the second mouse collection with a pointer collection, + * allowing to use the device both as a mouse and a digital laser + * pointer. + */ + +SEC("fmod_ret/hid_bpf_rdesc_fixup") +int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx) +{ + __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */); + + if (!data) + return 0; /* EPERM check */ + + /* replace application mouse by application pointer on the second collection */ + if (data[79] == 0x02) + data[79] = 0x01; + + return 0; +} + +SEC("syscall") +int probe(struct hid_bpf_probe_args *ctx) +{ + ctx->retval = ctx->rdesc_size != 264; + if (ctx->retval) + ctx->retval = -EINVAL; + + return 0; +} + +char _license[] SEC("license") = "GPL"; -- 2.43.0