Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp305177lqj; Wed, 10 Apr 2024 10:54:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWazSZLNCfzAdjIIREDEHhZV5Kiu8Dk47BvMXUcq8UzoRtJklTsiGnDg0wgICxHvytgmBcqxn0ZaWxDo0V7aObMwvplAsdgUmlqn/eqxg== X-Google-Smtp-Source: AGHT+IFJb0BxAuc1zuC9gA3lj25JecYyga5v+7TGJhvnPdbayxQjB6nMU/LB+1bnQf+oZ9CI5uMj X-Received: by 2002:a05:6871:3230:b0:221:bd93:2940 with SMTP id mo48-20020a056871323000b00221bd932940mr2195684oac.27.1712771688328; Wed, 10 Apr 2024 10:54:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712771688; cv=pass; d=google.com; s=arc-20160816; b=G7PvPtTdNZXCprf048kZYUDfkIrMUYWKLkC0qLfnGGcD9n8eL7pyPF+yNMA9yrFtyK Kk4CeTU/dT+kv6Q3HpU+3Rdah9PfE3Iy0ASsCeoEpEEO9/9Xs9+Doxtd5zP7DFHsvfB8 DDoY2Kjlp+BX35UeZqUhxALy7lGVll87tAT0yzxM8qSE61sES/e7nX7cuSE6dvG1QFk8 6E+s+KvSQs61UmEnv497M0VcQO8fbdwxorRFqKlCm5evja93Gq6Vjn8hazwQeXv8suQ8 EEuiOSn5k8iiBiA7sb/D21PkTT7HMOJzF99dItrEpV6/pyGI+qjY3CR0dkgvpM1uXYr2 ye8w== 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=EyfIO6KahLfo9fIQ0wYFjmgiEexMpqFF1pWN4R11S7s=; fh=ho438NhVBtcioQVDrg3lHWbSMg2+osFD2590tU+Apuc=; b=zxSey9ZQecOrB/hB+Wn+4FrSVEP5WHhjJo9eLbfux8HiMtMXWeuwJwprrwnyZ+CYOD pNq+VdlgdurwcKXCHRGJtM8fr3WBlqFG9Elzm2xW2RQOcjIsx8eYBBjtyeTtqppNdudb c8W2TZU1Q1kDE7GFkAjCviRTBr+YZO/IOJAuY92m8ZMskaIK5xsxyHBfPVBpeKfKp3sP smE9D8NRNUkijBmAgd7cqBbwp2UNtI7f44DgR28z+Xs+PVz1UzujXS59cT37IPO0UKUy TwbKB2tQDr2WMEIZrQZ9nURAiBI0DEWpA5A/7u4anlReLgbcdmSnXXERyAdnLtKASUJi hmEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UFxkdC1z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139074-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u132-20020a63798a000000b005f3fe76ea9esi9161642pgc.649.2024.04.10.10.54.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:54:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UFxkdC1z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139074-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 CDEABB2BA0D for ; Wed, 10 Apr 2024 17:21:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AAAD17BB2C; Wed, 10 Apr 2024 17:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UFxkdC1z" 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 84BDA1802CF; Wed, 10 Apr 2024 17:20:01 +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=1712769602; cv=none; b=QfeeRc+UrdrjjKrGVwBGBa2VruYOXWxNsa45UQI8hkc3F/vC6GR0bTkEcfHY60jfSQfHMaExYY7chNK3y1M8eLmAu/wMAZWrRDMRYD83pT5ToBUb5lmilhKiKxjAj2/X0n7ARM+H4GefI9Z21taWYCan1WsU0BDukea2phA3GXY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712769602; c=relaxed/simple; bh=3thyF8TXi2zqo/LMZKFE+HSC98gQ0GfLX2rEdsYzQSA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=es2o613xR/XUe4PDd2yXtwZN8rwknqhb0RQGo10jsVC2IpOmjwNwEO+Jc79dGia6ZQUQm1GFlaeAlC0rrBD+Q65a7SXAicnM6B5nFT/PYi7PHiAtRRUqcgyOvX/uE4l+b0j6hQrteJ7sUrMLVk5jRzcbzeCWfBVkLaW4M6Fs2jg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UFxkdC1z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47940C433A6; Wed, 10 Apr 2024 17:20:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712769601; bh=3thyF8TXi2zqo/LMZKFE+HSC98gQ0GfLX2rEdsYzQSA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UFxkdC1z/1kzNDFHk/lL9Acl/OWASq+lO3vjVB3EzB5Ae0cx45LgvXiOMccVQtl1g Tb19YvxSbUMzCllxAozmZ6oIyfgOYulnX72u/WiqVadRdNytf6zaS6BXCkHXrgroOe NAs8MSYBwct3e7FYN80+PGP9eBfBURg7C0wr/F7DdT+cn95frKtIz6yww0VKy0/vPx 0ok64eLaZ5x1MPHrxeCvgiPgJwRxw/xvq7YkFsir5K6ZP/An66dsWnlJ3WDGUJ19Ic GT8TafZAeQsEbXXJkgSF1elA/k+amsu3smKMJEpUglwecnclSx3Sm6VAqpyx2Uj+XP mhUoHFHXOdOFQ== From: Benjamin Tissoires Date: Wed, 10 Apr 2024 19:19:25 +0200 Subject: [PATCH 05/18] HID: bpf: add in-tree HID-BPF fix for the IOGear Kaliber Gaming MMOmentum 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-5-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=2107; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=3thyF8TXi2zqo/LMZKFE+HSC98gQ0GfLX2rEdsYzQSA=; b=jhTpFpQs9b6BoaUe/jvmEzLqj2oCWq84Eg42H5tmhv1rdYa6AH3HhdHhdeZUxrxURtkSl3Z/D ZsgdHI0Mwr5CcUUp+rPiabsXUHmNlFIerl5uiE74pUhh1Llm9Qr2rAw X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= Allows to export more than 5 buttons on this 12 buttons mouse. Signed-off-by: Benjamin Tissoires --- .../hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.c | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.c b/drivers/hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.c new file mode 100644 index 000000000000..225cbefdbf0e --- /dev/null +++ b/drivers/hid/bpf/progs/IOGEAR__Kaliber-MMOmentum.bpf.c @@ -0,0 +1,59 @@ +// 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_IOGEAR 0x258A /* VID is shared with SinoWealth and Glorious and prob others */ +#define PID_MOMENTUM 0x0027 + +HID_BPF_CONFIG( + HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, VID_IOGEAR, PID_MOMENTUM) +); + +/* + * The IOGear Kaliber Gaming MMOmentum Pro mouse has multiple buttons (12) + * but only 5 are accessible out of the box because the report descriptor + * marks the other buttons as constants. + * We just fix the report descriptor to enable those missing 7 buttons. + */ + +SEC("fmod_ret/hid_bpf_rdesc_fixup") +int BPF_PROG(hid_fix_rdesc, struct hid_bpf_ctx *hctx) +{ + const u8 offsets[] = {84, 112, 140}; + __u8 *data = hid_bpf_get_data(hctx, 0 /* offset */, 4096 /* size */); + + if (!data) + return 0; /* EPERM check */ + + /* if not Keyboard */ + if (data[3] != 0x06) + return 0; + + for (int idx = 0; idx < ARRAY_SIZE(offsets); idx++) { + u8 offset = offsets[idx]; + + /* if Input (Cnst,Var,Abs) , make it Input (Data,Var,Abs) */ + if (data[offset] == 0x81 && data[offset + 1] == 0x03) + data[offset + 1] = 0x02; + } + + return 0; +} + +SEC("syscall") +int probe(struct hid_bpf_probe_args *ctx) +{ + /* only bind to the keyboard interface */ + ctx->retval = ctx->rdesc_size != 213; + if (ctx->retval) + ctx->retval = -EINVAL; + + return 0; +} + +char _license[] SEC("license") = "GPL"; -- 2.44.0