Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2104668lqb; Mon, 27 May 2024 08:02:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCMYM0TeWcuD5auqEgbSK68oTASPXZlS1W9HNEPN4gbgb6FXlHV9vlPHPJQKy9aJV9yWdtg0BPcOlrtWpvrbKHhbcgbgYAYg0qECNQZA== X-Google-Smtp-Source: AGHT+IGvosKPRSYk+1jtn/8qhtsISpMrEIVmDQP7wGtk4k+QjrDCjBGKXP2hNiiPGVcvzvfMSIXV X-Received: by 2002:a17:90b:30c9:b0:2bd:f3dc:62d0 with SMTP id 98e67ed59e1d1-2bf5f74efb3mr8042757a91.37.1716822156567; Mon, 27 May 2024 08:02:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716822156; cv=pass; d=google.com; s=arc-20160816; b=XrrZjUIiSU2Neb4aUF5z7D28nPQ70z/baD++DQB+tp2zfRwNBjnrUWfLbbqX/M5gWc Tu4BTiHBWfqL69jfZJMK6UbkeHQY3pExRoK2h7ZIvpUlJsQi20+qhdTaFMUmeCtd8GER 06dbPVZxPtFpPfgGQ2lqRI1vnNAZsH4ZQKgktqQra6TheDFEZynHr7C1vFootbesa/FB h58CiOoo2CYSpNb6EQZnDBQnqLwElryuRcKtX7v26JY4i9Vbqhd1Y0ZKwYfVjmqZsuX/ Pxde99JCArAQcDLzJ6vnvFXWHZ04rOIrhkX5LVdEPkh3m0QDNQEb+FJLJVDB+hLezZ0A 4Vew== 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=U52RL69bCP2jqmRkXhi+JIcKElOfUxZXZd0v4dCxlkKzEG4KOu0BTKjEXcuIzzZZOr 6b8m3aOwIqVGDxVKx8YHWvdiizKX1Rpn5KqZAkd/o8WHGcbw3r7D158vzBe+Qe1xbW58 dn9vjcYVoh3dEyC6WRNHSq0PSNsqHttAATVEcPFUUioN4w3D+NcYelmsgr0ecxq0nKhq YEiIJSOmfIRqNMEebmAc6HooMldU327EhgSFZhSL4gq/gPW9KVHvugHCaQgsxbEoGkoz vGZnf0BoPdX/HmkCrh9047TFpkmyOkkwG12UYmLqF/1I4g/ekpqThtTR/XJkw0DDBRf/ E5pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gCowWLh2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190946-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bf99693a3csi3800272a91.29.2024.05.27.08.02.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 08:02:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gCowWLh2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190946-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190946-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6B3F9288A7B for ; Mon, 27 May 2024 14:53:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC60517B405; Mon, 27 May 2024 14:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gCowWLh2" 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 1669F17B408; Mon, 27 May 2024 14:20:26 +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=1716819626; cv=none; b=ubZ92oPOrZKHjqOzCdtCxtOmohpEafVp8enuYIddwa5vZhytIdRvSRbgww7+3isPj602tZQTDo5+hhJKYYciYZxnpY2fPGSt93VB/xA1ndSt5r2vd5EFH2CsL8KBCPeIsSL7ZGYz6nJIaSlg7XgNF2O4/WqpnNMLe5ialVGYB90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819626; c=relaxed/simple; bh=HksO7wi2Tu4etRYRKkyII0g6QFyH1LvtCOoKVJ36MLg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gUPEMuXU+LTQOJj1SufUTLuzntPAcDdpqtg//1VAej+NfAUX4BkYzBVR1kWtxgSgd9bzhja32b2N/bvIoIWJ1wl8LUffALqB8zlAKFSLnnvl4dswVZprbEouFH3ZN9tsRTBQfq91UlrneUiBsflBsbiWpwlr6Mpiq0funBVqMoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gCowWLh2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D3D5C2BBFC; Mon, 27 May 2024 14:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819626; bh=HksO7wi2Tu4etRYRKkyII0g6QFyH1LvtCOoKVJ36MLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gCowWLh2sXP/MWEQjNYGiFN4hrc5UeFPjw73TNCi9svpFlcJvzaOH/xuo2yVwjiMM EpfVhiLzOCEOrcVyAqu2XAtdUCUSctk5QvrPcwyhofOd0bN7KJ4VAmyQb8vtRCUZbB UJuIvmV3ySdF7P0SP8F/98Eo5iwR9liznem+h39XIQ79qnbDnmbW8GtuFbbJVj5Oac /4IYro19RRQTGqZbO1v2oq/vFeEBlj6GHjdrBIT6Dn0s1rcmfEXj5Bkp5oc3RJ6I6B g1sQy/ALWl1CI47X49/n0s+RhpbHBj8Jqdyab2bJ6cD9X4TQpDc23YwAOI9UG1xJBh sw6cIuEJHB/nQ== 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 4.19 3/3] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Date: Mon, 27 May 2024 10:20:05 -0400 Message-ID: <20240527142010.3855135-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527142010.3855135-1-sashal@kernel.org> References: <20240527142010.3855135-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 4.19.315 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