Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp451179pxb; Thu, 21 Oct 2021 02:53:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQE9BMzbBncdJNHY7NLs0GNfoLutqeaNAj883959974AItdQOYMiGOj6SCwTbtT5BM0Mah X-Received: by 2002:a05:6402:4311:: with SMTP id m17mr6357775edc.368.1634810032184; Thu, 21 Oct 2021 02:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634810032; cv=none; d=google.com; s=arc-20160816; b=elIjqGUnilS9YqxuSf8YDH1m/fqWZ+WeeWwzZ/E0ckYx+J3TriPsOW/PLPPVSYV1Nz HOvtPJ/VPLPjLeMhr1QWLuDy7VXTqtc/vfvCn63kP7zlAF9h7eIL3l4Wv+R7Y7zyT9v6 jn3Oidg7Nn6X4V8NmTME8A6pNMph+MVKwdi2guInvpF84dVDpcdtCMoXs9W7hlDcLFfH YfFZ0qm0p9owENK0mR3PG6Glk4raPVsW6jUL2yBejmSGt501AFHtD7c3M+U+LAtW9pvE ZTtNd+u0pNG8sRo38zSROolFceMJoReu8TGOxQMS2U8eP5P1wvhhYBAGn2XBn4I8+WvW rS3A== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=BuA1F8mAFopGpPNg7z7rb/m4d9yu2f2rm1X1F8Kqjmo=; b=HuhFEhX0iy62QetTzttty2MJwAvqHhG8+fcHjN0DqXc2cb5wUhsFwu+2+Jyz0L2V9m AxYhgH1Oxf2uWYJlbE/upIgKVj3LJj9eq2nIlmEOOLnFowWw/9dtcYYQpTwxWy3UkWor xZn4ipnQi9HsJdzN1hzVtTR9CySvr4nxBNQGC7yxoBfDlqQ2m5YNwPBsDqpFrNVCPVIy cTCNzowqzg29GEUSkMbgn6aHikMC0X6S6tqA//5rHfApngF2mddmEAQcq37vW1A/T0He Dx/y8oTANAAUPHZHg7tvy7nqCxUvI2AJr6IHUPJatf9f+wUhj88QHcUEC3I5irFYvqXd oBLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alistair23.me header.s=fm2 header.b=ExFwvYtz; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ilAzd8Y7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b88si8411599edf.243.2021.10.21.02.53.28; Thu, 21 Oct 2021 02:53:52 -0700 (PDT) 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=@alistair23.me header.s=fm2 header.b=ExFwvYtz; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ilAzd8Y7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231495AbhJUJxx (ORCPT + 99 others); Thu, 21 Oct 2021 05:53:53 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:52379 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbhJUJxw (ORCPT ); Thu, 21 Oct 2021 05:53:52 -0400 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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) -- 2.31.1