linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: ili210x - Probe even if no resolution information
@ 2022-07-15 15:59 Marek Vasut
  2023-02-16 22:44 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2022-07-15 15:59 UTC (permalink / raw)
  To: linux-input; +Cc: Marek Vasut, Dmitry Torokhov, Joe Hung, Luca Hsu

Probe the touch controller driver even if resolution information is not
available. This can happen e.g. in case the touch controller suffered a
failed firmware update and is stuck in bootloader mode.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Joe Hung <joe_hung@ilitek.com>
Cc: Luca Hsu <luca_hsu@ilitek.com>
---
 drivers/input/touchscreen/ili210x.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index e9bd36adbe47d..ad25081e301c6 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -370,22 +370,32 @@ static int ili251x_firmware_update_resolution(struct device *dev)
 
 	/* The firmware update blob might have changed the resolution. */
 	error = priv->chip->read_reg(client, REG_PANEL_INFO, &rs, sizeof(rs));
-	if (error)
-		return error;
+	if (!error) {
+		resx = le16_to_cpup((__le16 *)rs);
+		resy = le16_to_cpup((__le16 *)(rs + 2));
 
-	resx = le16_to_cpup((__le16 *)rs);
-	resy = le16_to_cpup((__le16 *)(rs + 2));
+		/* The value reported by the firmware is invalid. */
+		if (!resx || resx == 0xffff || !resy || resy == 0xffff)
+			error = -EINVAL;
+	}
 
-	/* The value reported by the firmware is invalid. */
-	if (!resx || resx == 0xffff || !resy || resy == 0xffff)
-		return -EINVAL;
+	/*
+	 * In case of error, the firmware might be stuck in bootloader mode,
+	 * e.g. after a failed firmware update. Set maximum resolution, but
+	 * do not fail to probe, so the user can re-trigger the firmware
+	 * update and recover the touch controller.
+	 */
+	if (error) {
+		resx = 16384;
+		resy = 16384;
+	}
 
 	input_abs_set_max(priv->input, ABS_X, resx - 1);
 	input_abs_set_max(priv->input, ABS_Y, resy - 1);
 	input_abs_set_max(priv->input, ABS_MT_POSITION_X, resx - 1);
 	input_abs_set_max(priv->input, ABS_MT_POSITION_Y, resy - 1);
 
-	return 0;
+	return error;
 }
 
 static ssize_t ili251x_firmware_update_firmware_version(struct device *dev)
@@ -980,7 +990,6 @@ static int ili210x_i2c_probe(struct i2c_client *client,
 	if (error) {
 		dev_err(dev, "Unable to cache firmware information, err: %d\n",
 			error);
-		return error;
 	}
 	touchscreen_parse_properties(input, true, &priv->prop);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Input: ili210x - Probe even if no resolution information
  2022-07-15 15:59 [PATCH] Input: ili210x - Probe even if no resolution information Marek Vasut
@ 2023-02-16 22:44 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2023-02-16 22:44 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-input, Joe Hung, Luca Hsu

Hi Marek,

On Fri, Jul 15, 2022 at 05:59:05PM +0200, Marek Vasut wrote:
> Probe the touch controller driver even if resolution information is not
> available. This can happen e.g. in case the touch controller suffered a
> failed firmware update and is stuck in bootloader mode.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Joe Hung <joe_hung@ilitek.com>
> Cc: Luca Hsu <luca_hsu@ilitek.com>
> ---
>  drivers/input/touchscreen/ili210x.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index e9bd36adbe47d..ad25081e301c6 100644
> --- a/drivers/input/touchscreen/ili210x.c
> +++ b/drivers/input/touchscreen/ili210x.c
> @@ -370,22 +370,32 @@ static int ili251x_firmware_update_resolution(struct device *dev)
>  
>  	/* The firmware update blob might have changed the resolution. */
>  	error = priv->chip->read_reg(client, REG_PANEL_INFO, &rs, sizeof(rs));
> -	if (error)
> -		return error;
> +	if (!error) {
> +		resx = le16_to_cpup((__le16 *)rs);
> +		resy = le16_to_cpup((__le16 *)(rs + 2));
>  
> -	resx = le16_to_cpup((__le16 *)rs);
> -	resy = le16_to_cpup((__le16 *)(rs + 2));
> +		/* The value reported by the firmware is invalid. */
> +		if (!resx || resx == 0xffff || !resy || resy == 0xffff)
> +			error = -EINVAL;
> +	}
>  
> -	/* The value reported by the firmware is invalid. */
> -	if (!resx || resx == 0xffff || !resy || resy == 0xffff)
> -		return -EINVAL;
> +	/*
> +	 * In case of error, the firmware might be stuck in bootloader mode,
> +	 * e.g. after a failed firmware update. Set maximum resolution, but
> +	 * do not fail to probe, so the user can re-trigger the firmware
> +	 * update and recover the touch controller.
> +	 */
> +	if (error) {

Do you want to maybe dev_warn() here to explain the weird values?

> +		resx = 16384;
> +		resy = 16384;
> +	}

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-16 22:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-15 15:59 [PATCH] Input: ili210x - Probe even if no resolution information Marek Vasut
2023-02-16 22:44 ` Dmitry Torokhov

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).