[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJpcXm6O8gfDnuevjh2iEXZpt7BE0OWqVH+2YfKaOZKxatOHqQ@mail.gmail.com>
Date: Thu, 29 Aug 2024 09:32:55 +0200
From: Benjamin Bara <bbara93@...il.com>
To: Sakari Ailus <sakari.ailus@...ux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>,
Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>, Hans de Goede <hdegoede@...hat.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Alexander Stein <alexander.stein@...tq-group.com>, linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org, Benjamin Bara <benjamin.bara@...data.com>
Subject: Re: [PATCH v2 1/2] media: i2c: imx290: Check for availability in probe()
Hi Sakari,
On Thu, 29 Aug 2024 at 09:05, Sakari Ailus <sakari.ailus@...ux.intel.com> wrote:
> Hi Benjamin,
>
> On Wed, Aug 28, 2024 at 08:13:07PM +0200, Benjamin Bara wrote:
> > Currently, the V4L2 subdevice is also created when the device is not
> > available/connected. In this case, dmesg shows the following:
> >
> > [ 10.419510] imx290 7-001a: Error writing reg 0x301c: -6
> > [ 10.428981] imx290 7-001a: Error writing reg 0x3020: -6
> > [ 10.442712] imx290 7-001a: Error writing reg 0x3018: -6
> > [ 10.454018] imx290 7-001a: Error writing reg 0x3020: -6
> >
> > which seems to come from imx290_ctrl_update() after the subdev init is
> > finished. However, as the errors are ignored, the subdev is initialized
> > but simply does not work. From userspace perspective, there is no
> > visible difference between a working and not-working subdevice (except
> > when trying it out or watching for the error message).
> >
> > This commit adds a simple availability check before starting with the
> > subdev initialization to error out instead.
> >
> > Signed-off-by: Benjamin Bara <benjamin.bara@...data.com>
> > ---
> > Changes since v1:
> > - define operating/standby mode and use it
> > - read out the standby mode during probe and ensure it is standby
> > ---
> > drivers/media/i2c/imx290.c | 17 +++++++++++++++--
> > 1 file changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
> > index 4150e6e4b9a6..2a869576600c 100644
> > --- a/drivers/media/i2c/imx290.c
> > +++ b/drivers/media/i2c/imx290.c
> > @@ -29,6 +29,8 @@
> > #include <media/v4l2-subdev.h>
> >
> > #define IMX290_STANDBY CCI_REG8(0x3000)
> > +#define IMX290_STANDBY_OPERATING (0 << 0)
> > +#define IMX290_STANDBY_STANDBY (1 << 0)
> > #define IMX290_REGHOLD CCI_REG8(0x3001)
> > #define IMX290_XMSTA CCI_REG8(0x3002)
> > #define IMX290_ADBIT CCI_REG8(0x3005)
> > @@ -1016,7 +1018,7 @@ static int imx290_start_streaming(struct imx290 *imx290,
> > return ret;
> > }
> >
> > - cci_write(imx290->regmap, IMX290_STANDBY, 0x00, &ret);
> > + cci_write(imx290->regmap, IMX290_STANDBY, IMX290_STANDBY_OPERATING, &ret);
>
> Please run
>
> ./scripts/checkpatch.pl --strict --max-line-length=80
>
> the next time. I'll wrap the line this time.
Sorry. I added the strict max-line check to my .gitconfig.
"b4 prep --check" now warns me.
> >
> > msleep(30);
> >
> > @@ -1029,7 +1031,7 @@ static int imx290_stop_streaming(struct imx290 *imx290)
> > {
> > int ret = 0;
> >
> > - cci_write(imx290->regmap, IMX290_STANDBY, 0x01, &ret);
> > + cci_write(imx290->regmap, IMX290_STANDBY, IMX290_STANDBY_STANDBY, &ret);
> >
> > msleep(30);
> >
> > @@ -1520,6 +1522,7 @@ static int imx290_probe(struct i2c_client *client)
> > {
> > struct device *dev = &client->dev;
> > struct imx290 *imx290;
> > + u64 val;
> > int ret;
> >
> > imx290 = devm_kzalloc(dev, sizeof(*imx290), GFP_KERNEL);
> > @@ -1580,6 +1583,16 @@ static int imx290_probe(struct i2c_client *client)
> > pm_runtime_set_autosuspend_delay(dev, 1000);
> > pm_runtime_use_autosuspend(dev);
> >
> > + /* Make sure the sensor is available before V4L2 subdev init. */
> > + ret = cci_read(imx290->regmap, IMX290_STANDBY, &val, NULL);
> > + if (ret)
> > + goto err_pm;
> > + if (val != IMX290_STANDBY_STANDBY) {
> > + dev_err(dev, "Sensor is not in standby mode\n");
> > + ret = -ENODEV;
> > + goto err_pm;
> > + }
> > +
> > /* Initialize the V4L2 subdev. */
> > ret = imx290_subdev_init(imx290);
> > if (ret)
> >
>
> --
> Kind regards,
>
> Sakari Ailus
thx & regards
Benjamin
Powered by blists - more mailing lists