Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp304787lqj; Wed, 10 Apr 2024 10:53:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDyEON48nC5cKEd9RxeHrwAeekLEQh4uJP5QaYFy7dFjKLiWP244vYDi9KgRLpE2hVUo62kQ8If3CntYWDOjflasQ3WOzBnn6oJ0FrLg== X-Google-Smtp-Source: AGHT+IHv2bGhxOfhshO6RxFsIard84BlUx1cE5Qot4KcnOqdB07fz8+QHXnZx43Ra/LVpkGiU2No X-Received: by 2002:a17:90a:ce14:b0:2a2:da08:67db with SMTP id f20-20020a17090ace1400b002a2da0867dbmr507829pju.6.1712771636607; Wed, 10 Apr 2024 10:53:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712771636; cv=pass; d=google.com; s=arc-20160816; b=aWCJpr+0wXgPkHheNUtpEjbjuPAFxPK/I8ZQLGso1Z+6EdjXzH69TyapFFiFtGRobZ Vn2XDvGpJ5jCY15Icn3MS789eD07cyCz4scXMV54wp1igK3YGCg7N8nCp0mBDHgljIxy DGD8PZ8pyHUEiOSf7fWrbhdUw1W3lC9L0QYQfkG41EG4srxR/LrwtasH6Bu4rCpYxO3e dJRR/8c1q9MGXdjSwDl+0tcaKHXSNitgVZgtfBfK6T0hbU+EsQ390T/OkBZmLuazdH4h UNFpqmjGKDK22um7ejNzn2uqlj5n1JDKliAmrW+Pqs2qMe582PTL9U8bI0IB5syonXV6 RstQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=FXB4jPWt44qhjBClgz3hgHwX8HrJdRb4eCOL8qDe3gc=; fh=ho438NhVBtcioQVDrg3lHWbSMg2+osFD2590tU+Apuc=; b=IKLJDdQcnaQrwc3cNUAeRnOfHJlwLjwxD2ia4iU/0XwVrgBWCFxERE43AHhiFTZ/yN 6MHbQxnn22IabiMBbA8mwNulk25dDQcdCrJl2645fTh3o6UjQ7O0UvorgxjSLv7tACmA ULnfO4z/uLgjnn+fAhQP9xNkSe206ToGdUdGQ2SIge+0njQE5PyOarXJsHCdr4Kzy23x tec+SPQGXksLmi0dhiuYSLonxcS99MlVqScyqbe/AUHmQ4IB8IlNgqYduDv0TZf3W42I vtKgGuVYqvzjIs8sxZQYDfpippN9VdgQ2VpuDwqo9QBbm5bpoiaAipX+gyA4vwzPgWQH xbHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NHR97PJx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g8-20020a63e608000000b005ce021f4418si10892141pgh.524.2024.04.10.10.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:53:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NHR97PJx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139073-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139073-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 58721B28E13 for ; Wed, 10 Apr 2024 17:20:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EA171802BC; Wed, 10 Apr 2024 17:20:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NHR97PJx" 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 5A74417BB21; Wed, 10 Apr 2024 17:19:59 +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=1712769600; cv=none; b=JUEv/MytsM93Xx7xY6CJawH1ZAU7EFwWlb1sYSQ+zs7yjiOq+ym59fhcRGx3+ZXR18iMu+E0YwHQJ5KO07ruev3R92gKJEzyTc2QxZ5pCu3ZxWXRPZ4Eu1HKFjNci3MbM+6ESpAtpbOfVXAWw2RElct5UsZIFlJB47222EmV2AA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712769600; c=relaxed/simple; bh=GdMP7KB2AP5WOlPh77qAilvcjUotd4SP3HgqhOGhk04=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S1GMvMyDiteHUyPckPN017acz0JaJ29WFkySN5l8y2jM+4PAu3Kqp+fqnDnh0mGnuIXcuC7aLG6a3DQQtSehEvYR48VYsTAzGxghCEKDGowo0oVu22YcacpPKs1KerQQo7lehPMYo47qy1cI9ApV/iGzWkHD8VYKuLI5ayU+q0M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NHR97PJx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E8DEC43390; Wed, 10 Apr 2024 17:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712769599; bh=GdMP7KB2AP5WOlPh77qAilvcjUotd4SP3HgqhOGhk04=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NHR97PJxcAUhKLa24bnkHaq9qFFf66TUNo4ryU6RD3p/YGwsSZSrmj7NYOG4LYum8 gm++usv0IBK9fr5YwiaQTAueOo1AJKBmPj3FTxHz98CSpMkPlWfwngsT5r4ZgbVdw/ dAmODS0CdD+zURD5IIrc0pxkeHWs10UR6iYnvFfhU+8YGOGY8QWXdrp8rdg6RoW1xI D+gBsCbyrRJ6JeVKlKyQxxIxtV8g8vqK9YmTqJm9MYwQgp7RRZRMc7stzcM+uaeOqz 2uv3Vx8UDHUqcMZW+XxcGDqKtPPYXtKzkvnIuFHKbopgzyjwne5HZ5p01ljdX3sWn6 Z+rg/ZdMuMh9A== From: Benjamin Tissoires Date: Wed, 10 Apr 2024 19:19:24 +0200 Subject: [PATCH 04/18] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240410-bpf_sources-v1-4-a8bf16033ef8@kernel.org> References: <20240410-bpf_sources-v1-0-a8bf16033ef8@kernel.org> In-Reply-To: <20240410-bpf_sources-v1-0-a8bf16033ef8@kernel.org> To: Jiri Kosina , Benjamin Tissoires , Shuah Khan , Peter Hutterer Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712769589; l=2434; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=GdMP7KB2AP5WOlPh77qAilvcjUotd4SP3HgqhOGhk04=; b=U/T1pI9MI/OMzR6XqGImiU2o7PCQWHxiVg0f0fMFIJPPTJzQdpLslwe4K71CMB075k1U5KXvI Vcr8GX07I1XD5IA1iHr6e6Um0NoRwpaUsoFfStpsPRijfUHT6bhGb3S X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= 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. Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) 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 000000000000..3d14bbb6f276 --- /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.44.0