linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Alistair Francis <alistair@alistair23.me>
Cc: 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, linux-kernel@vger.kernel.org,
	alistair23@gmail.com, devicetree@vger.kernel.org
Subject: Re: [PATCH v9 09/11] Input: wacom_i2c - Allow flipping the values from the DT
Date: Mon, 23 Aug 2021 13:15:11 -0500	[thread overview]
Message-ID: <YSPlr0X+3B9nxHW1@robh.at.kernel.org> (raw)
In-Reply-To: <20210818154935.1154-10-alistair@alistair23.me>

On Thu, Aug 19, 2021 at 01:49:33AM +1000, Alistair Francis wrote:
> 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 <alistair@alistair23.me>
> ---
>  .../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

These all need descriptions.

> +
> +  flip-tilt-y:
> +    type: boolean
> +
> +  flip-pos-x:
> +    type: boolean
> +
> +  flip-pos-y:
> +    type: boolean
> +
> +  flip-distance:
> +    type: boolean
> +
> +  flip-pressure:
> +    type: boolean

I don't understand how you flip pressure?

> +
>  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


Use 'if (!IS_ENABLED(CONFIG_OF))' in the function and drop all the 
ifdefs.

> +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
> 
> 

  reply	other threads:[~2021-08-23 18:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18 15:49 [PATCH v9 00/11] Add Wacom I2C support to rM2 Alistair Francis
2021-08-18 15:49 ` [PATCH v9 01/11] dt-bindings: Add Wacom to vendor bindings Alistair Francis
2021-08-18 15:49 ` [PATCH v9 02/11] dt-bindings: touchscreen: Initial commit of wacom,i2c Alistair Francis
2021-08-18 15:49 ` [PATCH v9 03/11] Input: wacom_i2c - Add device tree support to wacom_i2c Alistair Francis
2021-08-18 15:49 ` [PATCH v9 04/11] Input: wacom_i2c - Add touchscren properties Alistair Francis
2021-08-18 15:49 ` [PATCH v9 05/11] Input: wacom_i2c - Add support for distance and tilt x/y Alistair Francis
2021-08-23  7:06   ` Ahmad Fatoum
2021-08-18 15:49 ` [PATCH v9 06/11] Input: wacom_i2c - Clean up the query device fields Alistair Francis
2021-08-18 15:49 ` [PATCH v9 07/11] Input: wacom_i2c - Add support for vdd regulator Alistair Francis
2021-08-18 15:49 ` [PATCH v9 08/11] Input: wacom_i2c - Use macros for the bit masks Alistair Francis
2021-08-18 15:49 ` [PATCH v9 09/11] Input: wacom_i2c - Allow flipping the values from the DT Alistair Francis
2021-08-23 18:15   ` Rob Herring [this message]
2021-08-18 15:49 ` [PATCH v9 10/11] ARM: imx_v6_v7_defconfig: Enable Wacom I2C Alistair Francis
2021-08-18 15:49 ` [PATCH v9 11/11] ARM: dts: imx7d: remarkable2: add wacom digitizer device Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YSPlr0X+3B9nxHW1@robh.at.kernel.org \
    --to=robh@kernel.org \
    --cc=alistair23@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=junkpainting@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-imx@nxp.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ping.cheng@wacom.com \
    --cc=pinglinux@gmail.com \
    --cc=tatsunosuke.tobita@wacom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).