All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Rui Miguel Silva <rmfrfs@gmail.com>,
	Daniel Scally <dan.scally@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Andy Shevchenko <andy@kernel.org>, Kate Hsuan <hpa@redhat.com>,
	Tommaso Merciai <tomm.merciai@gmail.com>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v4 3/5] media: imx290: Convert to new CCI register access helpers
Date: Tue, 15 Aug 2023 15:48:53 +0200	[thread overview]
Message-ID: <2156749.irdbgypaU6@steina-w> (raw)
In-Reply-To: <ZNt+S6dl/rTNLgId@kekkonen.localdomain>

Am Dienstag, 15. August 2023, 15:31:55 CEST schrieb Sakari Ailus:
> ********************
> Achtung externe E-Mail: Öffnen Sie Anhänge und Links nur, wenn Sie wissen,
> dass diese aus einer sicheren Quelle stammen und sicher sind. Leiten Sie
> die E-Mail im Zweifelsfall zur Prüfung an den IT-Helpdesk weiter.
> Attention external email: Open attachments and links only if you know that
> they are from a secure source and are safe. In doubt forward the email to
> the IT-Helpdesk to check it. ********************
> 
> Hi Laurent,
> 
> On Tue, Aug 15, 2023 at 04:15:39PM +0300, Laurent Pinchart wrote:
> > Hi Hans,
> > 
> > On Tue, Jun 27, 2023 at 02:51:06PM +0200, Hans de Goede wrote:
> > > Use the new comon CCI register access helpers to replace the private
> > > register access helpers in the imx290 driver.
> > > 
> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > > ---
> > > Note:
> > > 1. This is untested
> > > 2. For reviewers: all the IMX290_REG_?BIT defines in both the register
> > > address defines as well as in various reg-sequences were automatically
> > > changed using search replace.
> > > ---
> > > Changes in v3:
> > > - Fixed a couple of lines > 80 chars
> > > 
> > > Changes in v2:
> > > - New patch in v2 of this series
> > > ---
> > > 
> > >  drivers/media/i2c/Kconfig  |   1 +
> > >  drivers/media/i2c/imx290.c | 360 +++++++++++++++----------------------
> > >  2 files changed, 150 insertions(+), 211 deletions(-)
> > 
> > [snip]
> > 
> > > diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
> > > index b3f832e9d7e1..e78c7b91ae72 100644
> > > --- a/drivers/media/i2c/imx290.c
> > > +++ b/drivers/media/i2c/imx290.c
> > > @@ -21,91 +21,86 @@
> > 
> > [snip]
> > 
> > > @@ -615,63 +605,15 @@ imx290_format_info(const struct imx290 *imx290,
> > > u32 code)> > 
> > >  	return NULL;
> > >  
> > >  }
> > > 
> > > -/*
> > > -----------------------------------------------------------------------
> > > ------ - * Register access
> > > - */
> > > -
> > > -static int __always_unused imx290_read(struct imx290 *imx290, u32 addr,
> > > u32 *value) -{
> > > -	u8 data[3] = { 0, 0, 0 };
> > > -	int ret;
> > > -
> > > -	ret = regmap_raw_read(imx290->regmap, addr & IMX290_REG_ADDR_MASK,
> > > -			      data, (addr >> IMX290_REG_SIZE_SHIFT) & 
3);
> > > -	if (ret < 0) {
> > > -		dev_err(imx290->dev, "%u-bit read from 0x%04x failed: 
%d\n",
> > > -			((addr >> IMX290_REG_SIZE_SHIFT) & 3) * 8,
> > > -			 addr & IMX290_REG_ADDR_MASK, ret);
> > > -		return ret;
> > > -	}
> > > -
> > > -	*value = get_unaligned_le24(data);
> > > -	return 0;
> > > -}
> > > -
> > > -static int imx290_write(struct imx290 *imx290, u32 addr, u32 value, int
> > > *err) -{
> > > -	u8 data[3];
> > > -	int ret;
> > > -
> > > -	if (err && *err)
> > > -		return *err;
> > > -
> > > -	put_unaligned_le24(value, data);
> > 
> > We seem to be having a problem here, as the CCI helpers unconditionally
> > use big endian for the data :-(
> 
> Well spotted. This driver needs to address this.
> 
> It's a hardware issue though. It's the only sensor ever I've seen to have
> little endian registers.

It's getting even worse: There are cameras using this sensor when bulk read is 
broken (VC MIPI IMX327 C, Laurent knows about this peculiar hardware), so 
regmap_config.use_single_read has to be set to true. This is currently not 
possible anymore insode this driver.

Best regards,
Alexander

> > > -
> > > -	ret = regmap_raw_write(imx290->regmap, addr & IMX290_REG_ADDR_MASK,
> > > -			       data, (addr >> IMX290_REG_SIZE_SHIFT) & 
3);
> > > -	if (ret < 0) {
> > > -		dev_err(imx290->dev, "%u-bit write to 0x%04x failed: 
%d\n",
> > > -			((addr >> IMX290_REG_SIZE_SHIFT) & 3) * 8,
> > > -			 addr & IMX290_REG_ADDR_MASK, ret);
> > > -		if (err)
> > > -			*err = ret;
> > > -	}
> > > -
> > > -	return ret;
> > > -}
> > > -
> > 
> > [snip]


-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/



  parent reply	other threads:[~2023-08-15 13:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 12:51 [PATCH v4 0/5] media: Add MIPI CCI register access helper functions Hans de Goede
2023-06-27 12:51 ` [PATCH v4 1/5] " Hans de Goede
2023-06-27 12:51 ` [PATCH v4 2/5] media: ov5693: Convert to new CCI register access helpers Hans de Goede
2023-06-27 12:51 ` [PATCH v4 3/5] media: imx290: " Hans de Goede
2023-08-15 13:15   ` Laurent Pinchart
2023-08-15 13:31     ` Sakari Ailus
2023-08-15 13:43       ` Laurent Pinchart
2023-08-15 13:48       ` Alexander Stein [this message]
2023-08-15 13:54         ` Laurent Pinchart
2023-08-15 14:15     ` Hans de Goede
2023-08-15 14:21       ` Laurent Pinchart
2023-06-27 12:51 ` [PATCH v4 4/5] media: atomisp: ov2680: " Hans de Goede
2023-06-27 12:51 ` [PATCH v4 5/5] media: Remove ov_16bit_addr_reg_helpers.h Hans de Goede
2023-07-02 10:51 ` [PATCH v4 0/5] media: Add MIPI CCI register access helper functions Sakari Ailus

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=2156749.irdbgypaU6@steina-w \
    --to=alexander.stein@ew.tq-group.com \
    --cc=andy@kernel.org \
    --cc=dan.scally@ideasonboard.com \
    --cc=hdegoede@redhat.com \
    --cc=hpa@redhat.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=rmfrfs@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomm.merciai@gmail.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 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.