All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Marek Vasut <marex@denx.de>
Cc: linux-input@vger.kernel.org, Joe Hung <joe_hung@ilitek.com>,
	Luca Hsu <luca_hsu@ilitek.com>
Subject: Re: [PATCH v2] Input: ili210x - Probe even if no resolution information
Date: Tue, 21 Feb 2023 13:14:21 -0800	[thread overview]
Message-ID: <Y/U0LTx2O2bVsUKY@google.com> (raw)
In-Reply-To: <bb6ad0b1-dc51-6002-a179-bbe59ff4d701@denx.de>

On Tue, Feb 21, 2023 at 09:12:29PM +0100, Marek Vasut wrote:
> On 2/21/23 20:40, Dmitry Torokhov wrote:
> > Hi Marek,
> > 
> > On Fri, Feb 17, 2023 at 03:52:00AM +0100, 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>
> > > ---
> > > V2: Add dev_warn() in case resolution is invalid
> > > ---
> > >   drivers/input/touchscreen/ili210x.c | 28 +++++++++++++++++++---------
> > >   1 file changed, 19 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> > > index 4897fafa4204d..d64b6d77d2e08 100644
> > > --- a/drivers/input/touchscreen/ili210x.c
> > > +++ b/drivers/input/touchscreen/ili210x.c
> > > @@ -370,22 +370,33 @@ 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) {
> > > +		dev_warn(dev, "Invalid resolution reported by controller.\n");
> > > +		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;
> > 
> > I think this will make ili251x_firmware_update_cached_state() continue
> > failing when it reports invalid coordinates. Was this intended?
> 
> This is actually correct, ili251x_firmware_update_cached_state() will fail,
> but ili210x_i2c_probe() won't stop there anymore, see the second hunk of
> this patch. The driver will instantiate the controller, so user can load
> correct firmware into it and recover the hardware.

I was concerned about call from ili210x_firmware_update_store() which
will continue returning error.

Thanks.

-- 
Dmitry

  reply	other threads:[~2023-02-21 21:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17  2:52 [PATCH v2] Input: ili210x - Probe even if no resolution information Marek Vasut
2023-02-21 19:40 ` Dmitry Torokhov
2023-02-21 20:12   ` Marek Vasut
2023-02-21 21:14     ` Dmitry Torokhov [this message]
2023-02-21 23:14       ` Marek Vasut
2023-05-06 15:27         ` Marek Vasut
2023-05-06 18:46 ` Dmitry Torokhov
2023-05-07  0:05   ` Marek Vasut

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=Y/U0LTx2O2bVsUKY@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=joe_hung@ilitek.com \
    --cc=linux-input@vger.kernel.org \
    --cc=luca_hsu@ilitek.com \
    --cc=marex@denx.de \
    /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.