From patchwork Thu Oct 21 09:51:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12574451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39C85C433FE for ; Thu, 21 Oct 2021 09:53:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 091B3610D0 for ; Thu, 21 Oct 2021 09:53:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 091B3610D0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=alistair23.me Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=FLdPrdQGwyoI8UIaEqiAG6VFztWZfFLWKHaSNNshJRw=; b=eZ+kEcR/QAKFPH n8i1yacSz4wP+LN1lMQvm42TJ5gu/kK/9bF6jnKp/96cz1JORVezS/A6/d3xKpfRF+qX1rg8j1i1g tWYVfaVxm8ZiXAv0h/vdMpQJrbxD1uwttRPpixTra4d1zBZZF1QDliK3ZSbvHaKW+hK5zI7FGo9/q QBLOTdPE9hEdOiegKTXFVOcSOL6h3imK3j3wh/s6GSd8uVbehdDNr0tzU2YJB6SCVuV1efCEOfrmK wveg9vBWvjDIZDJQt2UZv1LOfQ2WSOORzrxnkcxUySKx/ccuPEn/B0CFosmuVfpWOb/8uOT024nEO 6NXYsnCQR0gGM2/sTCcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdUji-0076TQ-1U; Thu, 21 Oct 2021 09:51:46 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdUje-0076SH-Hj for linux-arm-kernel@lists.infradead.org; Thu, 21 Oct 2021 09:51:43 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id D2F1E580CC1; Thu, 21 Oct 2021 05:51:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 21 Oct 2021 05:51:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=BuA1F8mAFopGpPNg7z7rb/m4d9 yu2f2rm1X1F8Kqjmo=; b=ExFwvYtzbfpBTCEh6q5ftopLWkFTBC8SOZrEX4haf+ sJ0hE4/QkQU8TLKW4nKNWoYAONa8gf5OsugrXOeuMSuSFhU5sYoiJU6VSDAlvI2u j3/gAG706Pf61KDvCOrsifbqenKXbBmyFCXIvgjM/gceKNpM85J57Q1vc0avwCJm sm1SUfq9rub274N3BO9/4BIEZIrxWUh/2hbvfU74QaI9f0eQ52nZjNkN6mrzBw7v me9t76p1KCghan7idapaxKuFBz3tA/US4iaFMP5Eg0X0x0+FRfpknsgJIw7HBw4m BjKnXay7CqWgqc7csIQlkLoqA82iNs0bS+v+994zjLOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=BuA1F8mAFopGpPNg7 z7rb/m4d9yu2f2rm1X1F8Kqjmo=; b=ilAzd8Y73dvNuv+Qyi0BjJQyZIFOXk60M CG14+Zi6VTWyyDJVVWhqWh9c9L+sC6slEdFL22U7EdZY3TbW59C2fmFEwX4mOfSA 4rTT2hRPnpPIj3ja+9baGmYPCAhePh33482IAgVyl0YaQ51NpFwQaIIHedOKjwFv mQoNEtcOcv3NRs1X5XmGmv1hcYsJjNV1CwmczS+Mtmjx+PGso2f8877tKrvAfmJL z5SLrO6fSiDCYHpD0OkovlfJXtOlxUaTtyaTQjY1yI0X3tHYPYAG8KVwopyHw7yy LH/xBqRTo77/UODPq/zCbtqPXqNvNnJ7qx3LI+K6IBeWrklQXS2wg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddviedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgrihhr segrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeejleeihfdvtefgtd ethfdtgefftdeiffefjeeiffefveeuleejheejvefhffeukeenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhishhtrghirhesrghlihhsth grihhrvdefrdhmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 05:51:32 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, shawnguo@kernel.org, s.hauer@pengutronix.de, benjamin.tissoires@redhat.com Cc: linux-imx@nxp.com, jikos@kernel.org, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alistair23@gmail.com, Alistair Francis Subject: [PATCH v12 1/3] HID: quirks: Allow inverting the absolute X/Y values Date: Thu, 21 Oct 2021 19:51:05 +1000 Message-Id: <20211021095107.116292-1-alistair@alistair23.me> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211021_025142_694872_E1165B48 X-CRM114-Status: GOOD ( 10.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a HID_QUIRK_XY_INVERT quirk that can be used to invert the X/Y values. Signed-off-by: Alistair Francis --- drivers/hid/hid-input.c | 7 +++++++ include/linux/hid.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 4b5ebeacd283..0a9634473940 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1328,6 +1328,13 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct input = field->hidinput->input; + if (*quirks & HID_QUIRK_XY_INVERT) { + if (usage->type == EV_ABS && + (usage->code == ABS_X || 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 9e067f937dbc..a6e91ee5b3de 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -349,6 +349,7 @@ 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_XY_INVERT BIT(12) #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)