Linux-Media Archive mirror
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: laurent.pinchart+renesas@ideasonboard.com,
	niklas.soderlund+renesas@ragnatech.se,
	kieran.bingham+renesas@ideasonboard.com
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	linux-media@vger.kernel.org
Subject: [PATCH] media: i2c: max9271: Ignore read error in s_stream
Date: Mon,  6 May 2024 16:49:46 +0200	[thread overview]
Message-ID: <20240506144947.85253-1-jacopo.mondi@ideasonboard.com> (raw)

In order to start streaming, the serializer's SEREN bit has to
be asserted and the video link enabled. In order for the video
link to be enabled correctly a valid pixel clock has to be
detected between the serializer and the connected image sensor.

The pixel clock detection is performed by reading register 0x15 but the
first attempt to read the register value sporadically fails resulting in
a error in the stream start procedure.

As the error is not fatal, and the pixel detection procedure will abort
anyway after 10 msec if no valid pixel clock is detected, continue
instead of failing immediately if the register read fails.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

---
When running 4 cameras at a time, the first register read on the first started
camera fails pretty often. I here decided to ignore the error and go for another
read attempt, but issuing a simple "i2c_smbus_read_reg()" (as we do in the wakup
function) before the actual register read resolves the issue in the same way.

I've not been able to find in the datasheet any mention of a "ping to wakeup"
requirement before enabling the video channel, but this change make capturing
from 4 RDACM20 camera pretty reliable.
---

 drivers/media/i2c/max9271.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/max9271.c b/drivers/media/i2c/max9271.c
index ff86c8c4ea61..e339dff3986d 100644
--- a/drivers/media/i2c/max9271.c
+++ b/drivers/media/i2c/max9271.c
@@ -66,8 +66,10 @@ static int max9271_pclk_detect(struct max9271_device *dev)

 	for (i = 0; i < 100; i++) {
 		ret = max9271_read(dev, 0x15);
-		if (ret < 0)
-			return ret;
+		if (ret < 0) {
+			usleep_range(50, 100);
+			continue;
+		}

 		if (ret & MAX9271_PCLKDET)
 			return 0;
--
2.44.0


             reply	other threads:[~2024-05-06 14:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 14:49 Jacopo Mondi [this message]
2024-05-06 18:50 ` [PATCH] media: i2c: max9271: Ignore read error in s_stream Laurent Pinchart

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=20240506144947.85253-1-jacopo.mondi@ideasonboard.com \
    --to=jacopo.mondi@ideasonboard.com \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    /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 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 read-only IMAP folder(s) and NNTP newsgroup(s).