Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp479985pxb; Thu, 19 Aug 2021 04:22:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys5UcBcT7prrV585bap1O3WjKd9TDNBpY8WcgztzpZKaObzwS3IdGGc/kA4RMuC84rbHel X-Received: by 2002:a02:c6c3:: with SMTP id r3mr12680690jan.7.1629372163885; Thu, 19 Aug 2021 04:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629372163; cv=none; d=google.com; s=arc-20160816; b=Y55hjofaDqv9lW/kMygQu3AfomosGkfKTtzpLM0CxGGrQZoRzAlHZ3h7GyQEcvC0H8 t/LWeYt841Z2NiQEMegvDCg/D2yX5K4VmlU3VpvXnFqc3O03CwK0pYkF+SbemfaHe7eB 9lR1iI2O6n3HES04adJHq2KVhSDLM+4YMkmX/k5fppI4l5040jXdpsoUd0XKoptarhv3 rKxoQWIsUAgoGGSsKPNxxZFjSg09sxtUkqeOy5qopUxr7ir00ExMq6raUYYI265ihwP1 veMwpgVmtqB/l28T9qGZOs+UWr6ghbiJlHGlx+wGbQgQoPuFqgMFJcosPAQgPRtl6W/O t+qg== 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:dkim-signature; bh=FKbcG/SSuUeVVrDhhMj/yHt2PNjV6DYHgylyNKHb+uM=; b=RTHpkmpdGR6efTORF48OyQdwCtHPxLpClnbUIw9jxcLB0FQcrblie/oKf9Mufalq0C rfqgcEnaxeksU9wWZNLUbrbKeDTDSrE5jxaSYgGfFA6/Je/ZvrWTPy0H/fDW0xCtHk48 PhGC53zfM45KuMEvf5aL9Psu/18g+x3biMY2hpjv9zKXSpctO2ecxWJkxkGpZVv9GUWr PKtg6mQ4horsUA3qWmLuuONfSwHep85vz43M801e8ArfqLrLqWh2Crnctw+xHIjm8WI9 1ReZSWSCG9ly70SZNT7Fe2l4sOuQ1I0KKOdSS/2hdpQrQ4qqmkvw3MUJcHABdO6dfUM8 P7/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alistair23.me header.s=fm1 header.b=aFrVOdzM; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="HTcDC1o/"; 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 i13si3713869ilm.90.2021.08.19.04.22.32; Thu, 19 Aug 2021 04:22:43 -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=fm1 header.b=aFrVOdzM; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="HTcDC1o/"; 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 S239086AbhHSLWC (ORCPT + 99 others); Thu, 19 Aug 2021 07:22:02 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:53079 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238896AbhHSLVx (ORCPT ); Thu, 19 Aug 2021 07:21:53 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id CCEC4580BC3; Thu, 19 Aug 2021 07:21:16 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 19 Aug 2021 07:21:16 -0400 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=fm1; bh=FKbcG/SSuUeVV rDhhMj/yHt2PNjV6DYHgylyNKHb+uM=; b=aFrVOdzMM31ojGj0nTaWi8DHFW8ur 7Qlm9TAwJcEelIU4YsaK0LCqgA8bXmxDHJ2+jYFl7+IuS/QZ0SfYITDrlOXhS2Gg DPBxlnkNIOaQrYXBATHm49uUN+EBfBQE7n68y5QrN9x4wYQ2lNXsKIGujCVHFpYH uHOUuvG5s0yYWvWuhr+Tk1ZC6am5P/zOdJ0ACpdsZoCL5ci+wOh77fN8Idi7inD3 PPZyyBdAUcAesVy2xiXrlHjE6RP+32ItbT5P3rNRIour85W+ufU8aMpB25HXb4yG 5VKqKA06hmJcZGmRT1QofHf04xBAngdQcrx/1jyE8E9CuDlZyqzq7LKfg== 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= fm3; bh=FKbcG/SSuUeVVrDhhMj/yHt2PNjV6DYHgylyNKHb+uM=; b=HTcDC1o/ VMdFYJJH5khZT/fwJBT1Iml4jEmLmehKQLFrlBkGkib9oS1+t9kkwExvwx4DDWTb zykngBuJgEEvmDFnsFKj9svLTtUBKRs5CpsR7KxMp9rQoRFPN/dD0a4FWU28GMgZ 31aRmpRZviDd7/D7b04V780ZcfS6iQIPO8qaxgIp6z8RmWbzw7TJLLV+ZsOT9EGy PeomLcedLL4T51iK9kp2GcnY+Pp2hEzIcBiOCpftnyKH2jQTVpZV10CcLuNVE2t3 AXX6P63m6BGeG0ijgc4ETCXrCQGSUjLamNWKcv5POOEkuvs0obuSCMc2qm7Ncbu5 6/yAllgPL50iOQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrleejgdefjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeetlhhishhtrghirhcuhfhrrghntghishcuoegrlhhishhtrghi rhesrghlihhsthgrihhrvdefrdhmvgeqnecuggftrfgrthhtvghrnhepgeegtdetjeekge eguefgheeuvedugedvteejveeiudegvddtkeffkeehtdetudfhnecuvehluhhsthgvrhfu ihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomheprghlihhsthgrihhrsegrlhhish htrghirhdvfedrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Aug 2021 07:21:12 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, pinglinux@gmail.com, tatsunosuke.tobita@wacom.com, junkpainting@gmail.com, ping.cheng@wacom.com Cc: linux-kernel@vger.kernel.org, alistair23@gmail.com, robh+dt@kernel.org, devicetree@vger.kernel.org, Alistair Francis Subject: [PATCH v9 09/11] Input: wacom_i2c - Allow flipping the values from the DT Date: Thu, 19 Aug 2021 01:49:33 +1000 Message-Id: <20210818154935.1154-10-alistair@alistair23.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210818154935.1154-1-alistair@alistair23.me> References: <20210818154935.1154-1-alistair@alistair23.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow the device tree properties to flip the tilx, position or distance values. This is required for the stylus to work correctly on the reMarkable 2. Signed-off-by: Alistair Francis --- .../input/touchscreen/wacom,generic.yaml | 18 ++++++++++ drivers/input/touchscreen/wacom_i2c.c | 33 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml index a8a7f362b0ce..0da63fd92ea1 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/wacom,generic.yaml @@ -25,6 +25,24 @@ properties: vdd-supply: description: Power Supply + flip-tilt-x: + type: boolean + + flip-tilt-y: + type: boolean + + flip-pos-x: + type: boolean + + flip-pos-y: + type: boolean + + flip-distance: + type: boolean + + flip-pressure: + type: boolean + required: - compatible - reg diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index c6579a1a8d04..82b62a768451 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -72,6 +72,13 @@ struct wacom_i2c { u8 data[WACOM_QUERY_SIZE]; bool prox; int tool; + + bool flip_tilt_x; + bool flip_tilt_y; + bool flip_pos_x; + bool flip_pos_y; + bool flip_distance; + bool flip_pressure; }; static int wacom_query_device(struct i2c_client *client, @@ -140,6 +147,20 @@ static int wacom_query_device(struct i2c_client *client, return 0; } +#ifdef CONFIG_OF +static void wacom_of_read(struct wacom_i2c *wac_i2c) +{ + struct i2c_client *client = wac_i2c->client; + + wac_i2c->flip_tilt_x = of_property_read_bool(client->dev.of_node, "flip-tilt-x"); + wac_i2c->flip_tilt_y = of_property_read_bool(client->dev.of_node, "flip-tilt-y"); + wac_i2c->flip_pos_x = of_property_read_bool(client->dev.of_node, "flip-pos-x"); + wac_i2c->flip_pos_y = of_property_read_bool(client->dev.of_node, "flip-pos-y"); + wac_i2c->flip_distance = of_property_read_bool(client->dev.of_node, "flip-distance"); + wac_i2c->flip_pressure = of_property_read_bool(client->dev.of_node, "flip-pressure"); +} +#endif + static irqreturn_t wacom_i2c_irq(int irq, void *dev_id) { struct wacom_i2c *wac_i2c = dev_id; @@ -176,6 +197,14 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id) wac_i2c->prox = data[3] & 0x20; + // Flip the values based on properties from the device tree + pressure = wac_i2c->flip_pressure ? (features->pressure_max - pressure) : pressure; + distance = wac_i2c->flip_distance ? -distance : distance; + x = wac_i2c->flip_pos_x ? (features->x_max - x) : x; + y = wac_i2c->flip_pos_y ? (features->y_max - y) : y; + tilt_x = wac_i2c->flip_tilt_x ? -tilt_x : tilt_x; + tilt_y = wac_i2c->flip_tilt_y ? -tilt_y : tilt_y; + touchscreen_report_pos(input, &wac_i2c->props, features->x_max, features->y_max, true); input_report_key(input, BTN_TOUCH, tsw || ers); @@ -303,6 +332,10 @@ static int wacom_i2c_probe(struct i2c_client *client, return error; } +#ifdef CONFIG_OF + wacom_of_read(wac_i2c); +#endif + return 0; } -- 2.31.1