Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3386492pxb; Mon, 17 Jan 2022 19:18:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyhBkxIpXUE0ph+VBveUsj1fJoZIpiN7WJa3WBa3eNP5UcUzuTA5ohR07E788IkKJ3Mbov X-Received: by 2002:a17:902:8212:b0:149:af87:9f9d with SMTP id x18-20020a170902821200b00149af879f9dmr25684270pln.39.1642475890603; Mon, 17 Jan 2022 19:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475890; cv=none; d=google.com; s=arc-20160816; b=KbwrDIB/PnVrDLK07202PlAnbyDzR3y2YlIcVis+iTHAANe13R4ttIpkjfAOCIHHJT xTlcmS+PZ2MgrSo486fKAIP5vYpV3OsRGP3+SGf5kS/Te8LF+c+jK61ia4L+GEWgsgPP ECf3cBOw3z4gS7WLxFg3ehh0gJsJsz678eA9TWjFitv6ZCJR/Ei0Ay4h6bd6dy33h56q TIVGsEX2/fDN4jSxGog+bu1g54H3y+9ClZLQiZb33pek8N1T3RK5CsF+b7ioSRd3E3QY joBrFP6i2kzO2UeDWnoyTvO1lICYN1ZofWRM/lRpPUltT1HI+qCF2elHzEWmla3yHQ4N bFJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ld+jOIX4pBcawZpK/UqXuUaBNEngXKGfR91V83Nhtso=; b=L2CDVkP/Hz7RJOn+8JethLRBDZ9OV1Q7LuirgJOwD5fqzayUtzn+AlqefJUUySEHVe y4U77bU7a/m381EQxb0zI9dZ606uJdWR2SqWCk0ZEfhHzX+19dZUkHo/+2XCPSOOAVhJ mKQCkTpqwAFHzw6PiiDOQwXwTtPQ6iNH3cqCtpPnv2fLfZGHMhMOqZ1+HIU6pvMPT0Sc E1um82ggydpQFczEM9zu07xAKgbFxqn9ncz46MIfNbItddVysLbIed5TW+/oze0IG420 RWmHrwz251R6QxFWv0lr1L5k8AbdHys93dE3fh6NANfjstPxofJpdUx7/wCVYOhgM40d YaSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T1JcsEA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si2305146ply.374.2022.01.17.19.17.55; Mon, 17 Jan 2022 19:18:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T1JcsEA+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343953AbiARC2V (ORCPT + 99 others); Mon, 17 Jan 2022 21:28:21 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:43226 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245598AbiARC0K (ORCPT ); Mon, 17 Jan 2022 21:26:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 63CBC6117D; Tue, 18 Jan 2022 02:26:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C5A2C36AF4; Tue, 18 Jan 2022 02:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472769; bh=MlUY9jl1m4vtcPCGndqfSTENZVSTJXkJpHf38PMkH3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T1JcsEA+TQKVWhuCEqM/dHknW2NbcMTjFpJyA4wtfxclqflZe3OxL82zs0a5z+Kmm Nau0KC/JvE4Nw88zgzRc7YM/wSgut0hCkBzaTifhxPXymJd1vPycsckHttJ+CXcvXN h8G73WLjbeKsIWocezuLsNpYISLM3ARoGU/mb2MLvkZhTyPYsNx3LHo0+jyyXA3PYy V2MsVFWI/kimYhwmvVKwusDIBrIftnyI9fFnyK0xD117A/hRg372YPhdjFNXRUsCcI ffhsE+KYYZHgZ5XSXUMtpDXz8KfB+8lUP797dAGGANR+a44GnTUBiJa9osGlyvquBp SCPTGfPzkvCeg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alistair Francis , Benjamin Tissoires , Sasha Levin , jikos@kernel.org, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 132/217] HID: quirks: Allow inverting the absolute X/Y values Date: Mon, 17 Jan 2022 21:18:15 -0500 Message-Id: <20220118021940.1942199-132-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alistair Francis [ Upstream commit fd8d135b2c5e88662f2729e034913f183455a667 ] Add a HID_QUIRK_X_INVERT/HID_QUIRK_Y_INVERT quirk that can be used to invert the X/Y values. Signed-off-by: Alistair Francis [bentiss: silence checkpatch warning] Signed-off-by: Benjamin Tissoires Link: https://lore.kernel.org/r/20211208124045.61815-2-alistair@alistair23.me Signed-off-by: Sasha Levin --- drivers/hid/hid-input.c | 6 ++++++ include/linux/hid.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 03f994541981c..bc88de172b5c3 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1333,6 +1333,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct input = field->hidinput->input; + if (usage->type == EV_ABS && + (((*quirks & HID_QUIRK_X_INVERT) && usage->code == ABS_X) || + ((*quirks & HID_QUIRK_Y_INVERT) && usage->code == ABS_Y))) { + value = field->logical_maximum - value; + } + if (usage->hat_min < usage->hat_max || usage->hat_dir) { int hat_dir = usage->hat_dir; if (!hat_dir) diff --git a/include/linux/hid.h b/include/linux/hid.h index f453be385bd47..26742ca14609a 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -349,6 +349,8 @@ struct hid_item { /* BIT(9) reserved for backward compatibility, was NO_INIT_INPUT_REPORTS */ #define HID_QUIRK_ALWAYS_POLL BIT(10) #define HID_QUIRK_INPUT_PER_APP BIT(11) +#define HID_QUIRK_X_INVERT BIT(12) +#define HID_QUIRK_Y_INVERT BIT(13) #define HID_QUIRK_SKIP_OUTPUT_REPORTS BIT(16) #define HID_QUIRK_SKIP_OUTPUT_REPORT_ID BIT(17) #define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP BIT(18) -- 2.34.1