From patchwork Wed Dec 8 12:40:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12695333 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 09568C433EF for ; Wed, 8 Dec 2021 12:42:52 +0000 (UTC) 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:References:In-Reply-To: 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: List-Owner; bh=Y1+UkA1CthDmEbZ3C/No/rrbw+f09JMT9QFVDp429BM=; b=oTNya2dEBv2BtQ mpNgyKfVrCXMJOzGvaxMcW78ZMYROqzJq/Ygo5+wiRmKORrOqeRawSOWZ6N5MgOqUDRs5aZAwI8Qr D0KGoCIfXA50dt+8yJ6TdSqWH/QGCaAoGjHunXdESLcieoYz53K1qfe1p4L9hsBMNP80ttC1QtHEV xEo53yZieeD0P5bBHkPXAHP3TGnG7vlFBw0U1h3oNk+IKltRYwN8qDFJty8TA1RCgRebsyJpNEkUy nViIbLJj79TT5MKOOIU48+GvHu7EXzugDcCB+JtGpN9i4bmHQi5kWzkqDShIuA4hpFix4HHc0oMrW tmiZSoaWi9zoA86sr8QQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1muwG8-00CXA1-5S; Wed, 08 Dec 2021 12:41:20 +0000 Received: from new4-smtp.messagingengine.com ([66.111.4.230]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1muwFr-00CX6x-PZ for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 12:41:08 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 0C49D580269; Wed, 8 Dec 2021 07:41:01 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 08 Dec 2021 07:41:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=XXHhIZecWEbbp w/wt6LKfLxH0GHT7xbD6LEPfEWZbjk=; b=Qc4G35IAQu4qPzpj/pU5z9Z5sUQgk NbeFGUU+3398Yasf3swb190ngYr6jxa5OEhn/KpqFK85mGrLgKcjv2YYY44NXZc0 V1EzBAKwyDsMsrCosnhurdaHMX76vcxRRisuF9isMN5rhFv/vkiNI//PXHZ+12uN 6B3YcNqvzplQUz3HGjvdNIjwbGObsxAYLEjqoDwhElLWldSwv3hOkuZHY0Jie3u0 XWBJRIwHWoOn4VFt9KbDJ56v8Ls1ovAxEGnAYN9HwUMy8WJ58h1tG0X3uvTCjkig 73dzS48R8hnOrpIyKZ0OIktSwaxBSGQbAVc3bDFTv5KSaK1K+dAHkfDGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=XXHhIZecWEbbpw/wt6LKfLxH0GHT7xbD6LEPfEWZbjk=; b=dV74NZPP xjzFLMlwQ5qcqHF46vzLiBr+i0tvoe4V6G6Mo7XOHPLUc/oGI9iJIILLHABVlggh zhQlP38Hqi7BWGqSNqYDe18Q7s3GRanD7U3gkMCjDX75AC66S5L/8tluwnmdRkI0 TxFC133kE3tJ/GQqd9K/8QKXiDTtigEl+RZQ3XSko0Zs6DB8vZ8G9sWigQWn6FBo p+1zQQ2qvHz1eMQvgbSxT5t/488qO7R2Vagf+oD2SkQyk5sFcIE1OaeMBFScvunx Uq68h8M7jUgqcElMYdFdWndAtbYK/GShwOfj2ppCA3OURrOkNhBLke15zgqW15I2 VKU3QQ5bnt2RWw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrjeekgdegvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeetlhhishhtrghirhcuhfhrrghntghishcuoegrlhhishhtrghi rhesrghlihhsthgrihhrvdefrdhmvgeqnecuggftrfgrthhtvghrnhepgeegtdetjeekge eguefgheeuvedugedvteejveeiudegvddtkeffkeehtdetudfhnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlihhsthgrihhrsegrlhhish htrghirhdvfedrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Dec 2021 07:40:55 -0500 (EST) From: Alistair Francis To: s.hauer@pengutronix.de, shawnguo@kernel.org, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com Cc: jikos@kernel.org, linux-kernel@vger.kernel.org, alistair23@gmail.com, linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org, Jason.Gerecke@wacom.com, linux-imx@nxp.com, Ping.Cheng@wacom.com, devicetree@vger.kernel.org, martin.chen@wacom.com, tatsunosuke.tobita@wacom.com, Alistair Francis Subject: [PATCH v16 1/3] HID: quirks: Allow inverting the absolute X/Y values Date: Wed, 8 Dec 2021 22:40:43 +1000 Message-Id: <20211208124045.61815-2-alistair@alistair23.me> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211208124045.61815-1-alistair@alistair23.me> References: <20211208124045.61815-1-alistair@alistair23.me> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211208_044103_952587_20EAF74E X-CRM114-Status: UNSURE ( 9.75 ) X-CRM114-Notice: Please train this message. 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_X_INVERT/HID_QUIRK_Y_INVERT quirk that can be used to invert the X/Y values. Signed-off-by: Alistair Francis --- 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 217f2d1b91c5..83ee803186a1 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1331,6 +1331,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 9e067f937dbc..4959385ca588 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)