Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2091130lqb; Mon, 27 May 2024 07:36:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLXp+pS6Z/zmEzalZsFdNMS7KtmxBSXIsvo0LE+6kXjASx62GZqbkvxbHIrgpwEdxwWbCxq5q6gwT2Sowkb0lQbZ1Ztlof5wztIyzVMg== X-Google-Smtp-Source: AGHT+IH4yDziPbNB7J/gQNMyVMGXsLerzf0w1bH7ykHnWvu1vO3PIXSIJP4zJLZ1p62PP8SXQyQ5 X-Received: by 2002:a67:ef83:0:b0:47b:af16:39bc with SMTP id ada2fe7eead31-48a2bd3be0emr10450355137.17.1716820604465; Mon, 27 May 2024 07:36:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716820604; cv=pass; d=google.com; s=arc-20160816; b=NVzwvoyXPphnZlWCbGmLHYYfvw5Q9wDki7Pj9reGYIL6SFfkUAJoXeSKHP64ycwicv XL+xRwMz+80ypTbFHwTd5xv2A7s4zlPsepZ2RJAAWI+qsvVxOIINeptncALXuxjYzUDT PakfQRGP4Wi1rJT1i46FzGnOOR+D9TqnYSsmR2HyLWX9/H0xZ9yIklmceVct26KFhX0v FCYIIrz631X7ij/hG0Evj6sKObR6EdI2IqiOiA9+hOxG4RqWSQdEeVKiO8aDlry2cV1s v9THAGs7cQBX1VAkGOurjvDAfBXnA+7zLKcshIXJGESGtDxE8obVOqewa5BfUzDSnfiC 1EcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oR/qPL1kzxSZ2gp5atkIUwMWRIk8NB5HEU4jfgTR4DA=; fh=J+yvkFHRZLzJDRHjMyQEqw11J7BJ7Gr64Dd+/CZl+xw=; b=fv7CoBpxOlXocpW3CD2eb7+ssXRArrmHMsbr4kDoTOAEVxk74LuJ7y9Ej5vubRPlk2 SeU6SYJOPu2+O85/+0RLGI3fdrGaFkG5Encbsz9COArX+0ViJwLfPlLZRK3ibSY8jcK2 7WNzLcYz8ZdMBdzwU3ROAcIfEK+iJnVMRQBbo3Uzx4EWAO+2N2l8E1pCDJ1I9JLGEl9Y vjsudfIxG7eM/b5ZJ3NrTik/kDC4X44GdcdhqGl9NNtdELwi/cZJgPtnn5yYS41Z+27u LCQW32PcGFxM8D1pq0aCPawjWTPMWDpaHkwD5Av5nqYUL3v4xOV6GD90QHdN7J3/+ENY Z5nQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uMxbnIIB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190893-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190893-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a1e0cc1a2514c-804e8ce8476si704896241.81.2024.05.27.07.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:36:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190893-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uMxbnIIB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190893-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190893-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 31E961C21609 for ; Mon, 27 May 2024 14:36:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1A661C230A; Mon, 27 May 2024 14:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uMxbnIIB" 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 F41DD16C86B; Mon, 27 May 2024 14:16:52 +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=1716819413; cv=none; b=TBnqZby3FHjiHl03A0RZ25QnRgJrZAR6Z9XbJ/6cecAg+ICONnNFlBZRkakY6RdtkXlASWZzzcGN7Ddt1BewbbYTiTXDWY7RL7AIrI2hFWyZc2jRFBpgFzbRboBCdMkzHImsFbvgRLJJfQAWAjzo1U8ylrlOyOyXDFRGEKoUCAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819413; c=relaxed/simple; bh=HksO7wi2Tu4etRYRKkyII0g6QFyH1LvtCOoKVJ36MLg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=utwLaWlKA5kSuE86tJgJ7MlKuVWzqxIhSB60xADUvW7yyjh3wRJFFioYh6jd+2TEuLKHftmuAfAbuGaIL+DSX4Dlw4NLkeW3qnV/MWfVsP26H/9KT5KWi7x6RVh+LfqFvgNprBbSyqOBYz5IF9rBwAM+E/BusUPKJ3x0nFNXEt0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uMxbnIIB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAC2CC2BBFC; Mon, 27 May 2024 14:16:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819412; bh=HksO7wi2Tu4etRYRKkyII0g6QFyH1LvtCOoKVJ36MLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uMxbnIIBlr3xpbb+xOvDSHBMlHEwC/pkXrlJzPdOehQA+nICmbbDkOtfwGWDy/nf5 g2lFV++ok75wFFydtFS/Dk8qQb3vv3jBAYpcxyBx4E+82ii+ZKA25eP5U3BfmCkvBp /1QVaHRjrI7EblSjELxBc6lIZZYzFqTDk+WWoImhmvm6C27UANUAGsAEZz7L+d5HPr Zv/YcFRyMKEKH+y1+hNL3PQPbite2PZ6EnuSl5dlxiDmuxzxdE41n8sejpHYVnD9J7 gCLwwt5qD4LToE4DIQ2g+GZMZGlHpIuGmP+ve11pOPUTmBVhsZaINGY6h5eoF6y7Lr GK2VqD8yVZf2Q== 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.6 20/21] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Date: Mon, 27 May 2024 10:15:31 -0400 Message-ID: <20240527141551.3853516-20-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527141551.3853516-1-sashal@kernel.org> References: <20240527141551.3853516-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@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.6.32 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