All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Richard Leitner <richard.leitner@skidata.com>
Cc: robh+dt@kernel.org, mark.rutland@arm.com,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 7/7] Input: sx8654 - use common of_touchscreen functions
Date: Tue, 16 Oct 2018 10:52:00 -0700	[thread overview]
Message-ID: <20181016175200.GE230131@dtor-ws> (raw)
In-Reply-To: <20181016092310.27346-1-richard.leitner@skidata.com>

On Tue, Oct 16, 2018 at 11:23:10AM +0200, Richard Leitner wrote:
> of_touchscreen.c provides a common interface for a axis invertion and
> swapping of touchscreens. Therefore use it in the sx8654 driver.
> 
> Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
> ---
>  drivers/input/touchscreen/sx8654.c | 37 +++++++++++++++++++------------------
>  1 file changed, 19 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c
> index 33f7a0be4ef8..08b064f96b4e 100644
> --- a/drivers/input/touchscreen/sx8654.c
> +++ b/drivers/input/touchscreen/sx8654.c
> @@ -36,6 +36,7 @@
>  #include <linux/gpio/consumer.h>
>  #include <linux/delay.h>
>  #include <linux/hrtimer.h>
> +#include <linux/input/touchscreen.h>
>  
>  /* register addresses */
>  #define I2C_REG_TOUCH0			0x00
> @@ -100,6 +101,7 @@ struct sx8654 {
>  	struct i2c_client *client;
>  	struct gpio_desc *gpio_reset;
>  	struct hrtimer timer;
> +	struct touchscreen_properties props;
>  
>  	const struct sx865x_data *data;
>  };
> @@ -168,8 +170,7 @@ static irqreturn_t sx8650_irq(int irq, void *handle)
>  				 chdata);
>  	}
>  
> -	input_report_abs(ts->input, ABS_X, x);
> -	input_report_abs(ts->input, ABS_Y, y);
> +	touchscreen_report_pos(ts->input, &ts->props, x, y, false);
>  	input_report_key(ts->input, BTN_TOUCH, 1);
>  	input_sync(ts->input);
>  	dev_dbg(dev, "point(%4d,%4d)\n", x, y);
> @@ -215,8 +216,8 @@ static irqreturn_t sx8654_irq(int irq, void *handle)
>  		x = ((data[0] & 0xf) << 8) | (data[1]);
>  		y = ((data[2] & 0xf) << 8) | (data[3]);
>  
> -		input_report_abs(sx8654->input, ABS_X, x);
> -		input_report_abs(sx8654->input, ABS_Y, y);
> +		touchscreen_report_pos(sx8654->input, &sx8654->props, x, y,
> +				       false);
>  		input_report_key(sx8654->input, BTN_TOUCH, 1);
>  		input_sync(sx8654->input);
>  
> @@ -355,6 +356,8 @@ static int sx8654_get_ofdata(struct sx8654 *ts)
>  	}
>  	dev_dbg(dev, "got GPIO reset pin\n");
>  

You need to mark axes used by the device before calling
touchscreen_parse_properties(), otherwise you'll get warnings if
corresponding property is present in DT.

> +	touchscreen_parse_properties(ts->input, false, &ts->props);
> +
>  	return 0;
>  }
>  #else /* CONFIG_OF */
> @@ -380,25 +383,11 @@ static int sx8654_probe(struct i2c_client *client,
>  	sx8654 = devm_kzalloc(&client->dev, sizeof(*sx8654), GFP_KERNEL);
>  	if (!sx8654)
>  		return -ENOMEM;
> -
>  	sx8654->client = client;
>  
> -	error = sx8654_get_ofdata(sx8654);
> -	if (error) {
> -		dev_err(&client->dev, "get_ofdata failed: %d\n", error);
> -		return error;
> -	}
> -
> -	if (!sx8654->data->has_irq_penrelease) {
> -		dev_dbg(&client->dev, "use timer for penrelease\n");
> -		hrtimer_init(&sx8654->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> -		sx8654->timer.function = sx865x_penrelease_timer_handler;
> -	}
> -
>  	input = devm_input_allocate_device(&client->dev);
>  	if (!input)
>  		return -ENOMEM;
> -
>  	sx8654->input = input;
>  
>  	input->name = "SX8654 I2C Touchscreen";
> @@ -414,6 +403,18 @@ static int sx8654_probe(struct i2c_client *client,
>  
>  	input_set_drvdata(sx8654->input, sx8654);
>  
> +	error = sx8654_get_ofdata(sx8654);
> +	if (error) {
> +		dev_err(&client->dev, "get_ofdata failed: %d\n", error);
> +		return error;
> +	}
> +
> +	if (!sx8654->data->has_irq_penrelease) {
> +		dev_dbg(&client->dev, "use timer for penrelease\n");
> +		hrtimer_init(&sx8654->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> +		sx8654->timer.function = sx865x_penrelease_timer_handler;
> +	}
> +
>  	error = sx8654_reset(sx8654);
>  	if (error) {
>  		dev_err(&client->dev, "reset failed");
> -- 
> 2.11.0
> 

-- 
Dmitry

      reply	other threads:[~2018-10-16 17:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16  9:16 [PATCH 0/7] Input: sx8654 - reset-gpio, sx865[056] support, etc Richard Leitner
2018-10-16  9:16 ` Richard Leitner
2018-10-16  9:16 ` [PATCH 1/7] dt-bindings: input: touchscreen: sx8654: add reset-gpio property Richard Leitner
2018-10-16  9:16   ` Richard Leitner
2018-10-16  9:16 ` [PATCH 2/7] Input: sx8654 - add reset-gpio support Richard Leitner
2018-10-16  9:16   ` Richard Leitner
2018-10-16 17:39   ` Dmitry Torokhov
2018-10-16 19:32     ` Richard Leitner
2018-10-16 19:32       ` Richard Leitner
2018-10-16  9:16 ` [PATCH 3/7] dt-bindings: input: touchscreen: sx8654: add compatible models Richard Leitner
2018-10-16  9:16   ` Richard Leitner
2018-10-16  9:16 ` [PATCH 4/7] Input: sx8654 - add sx8655 and sx8656 to compatibles Richard Leitner
2018-10-16  9:16   ` Richard Leitner
2018-10-16  9:22 ` [PATCH 5/7] dt-bindings: input: touchscreen: sx8654: add sx8650 to comatibles Richard Leitner
2018-10-16  9:22   ` Richard Leitner
2018-10-16  9:22 ` [PATCH 6/7] Input: sx8654 - add sx8650 support Richard Leitner
2018-10-16  9:22   ` Richard Leitner
2018-10-16 17:48   ` Dmitry Torokhov
2018-10-16 19:34     ` Richard Leitner
2018-10-16 19:34       ` Richard Leitner
2018-10-16 20:18       ` Dmitry Torokhov
2018-10-16  9:23 ` [PATCH 7/7] Input: sx8654 - use common of_touchscreen functions Richard Leitner
2018-10-16  9:23   ` Richard Leitner
2018-10-16 17:52   ` Dmitry Torokhov [this message]

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=20181016175200.GE230131@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=richard.leitner@skidata.com \
    --cc=robh+dt@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.