Linux-Renesas-SoC Archive on lore.kernel.org
 help / color / Atom feed
From: Michael Rodin <mrodin@de.adit-jv.com>
To: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Michael Rodin <mrodin@de.adit-jv.com>, <michael@rodin.online>,
	<efriedrich@de.adit-jv.com>, <erosca@de.adit-jv.com>,
	Suresh Udipi <sudipi@jp.adit-jv.com>
Subject: [PATCH] rcar-vin: rcar-csi2: Select the correct PHTW register
Date: Wed, 27 May 2020 18:17:35 +0200
Message-ID: <1590596255-17470-1-git-send-email-mrodin@de.adit-jv.com> (raw)
In-Reply-To: <20200512213045.GC2542285@oden.dyn.berto.se>

From: Suresh Udipi <sudipi@jp.adit-jv.com>

PHTW register is selected based on default bit rate from Table[1].
for the bit rates less than or equal to 250. Currently first
value of default bit rate which is greater than or equal to
the caculated mbps is selected.This selection can be further
improved by selecting the default bit rate which is nearest to
the calculated value.

[1] specs r19uh0105ej0200-r-car-3rd-generation.pdf [Table 25.12]

Fixes: ADIT v4.14 commit 9e568b895ee0 ("media: rcar-csi2: add Renesas R-Car MIPI CSI-2 receiver driver")

Signed-off-by: Suresh Udipi <sudipi@jp.adit-jv.com>
Signed-off-by: Michael Rodin <mrodin@de.adit-jv.com>
---
 drivers/media/platform/rcar-vin/rcar-csi2.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index 687baee..115b0af 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -886,10 +886,18 @@ static int rcsi2_phtw_write_mbps(struct rcar_csi2 *priv, unsigned int mbps,
 				 const struct rcsi2_mbps_reg *values, u16 code)
 {
 	const struct rcsi2_mbps_reg *value;
+	const struct rcsi2_mbps_reg *prev_value = NULL;
 
-	for (value = values; value->mbps; value++)
+	for (value = values; value->mbps; value++) {
 		if (value->mbps >= mbps)
 			break;
+		prev_value = value;
+	}
+
+	if (prev_value &&
+	    ((mbps - prev_value->mbps) <= (value->mbps - mbps)))
+		value = prev_value;
+
 
 	if (!value->mbps) {
 		dev_err(priv->dev, "Unsupported PHY speed (%u Mbps)", mbps);
-- 
2.7.4


      parent reply index

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20  4:49 [PATCH] [RFC] media: rcar-csi2: Corrects the selection of hsfreqrange Suresh Udipi
2020-03-04 19:46 ` Niklas Söderlund
2020-03-16 13:02   ` Niklas Söderlund
2020-03-17  7:08     ` [PATCH v2] [RFC] rcar-vin: rcar-csi2: Correct " Suresh Udipi
2020-03-17 10:37       ` Niklas Söderlund
2020-03-18  9:00         ` Suresh Udipi
2020-03-18 10:19           ` Niklas Söderlund
2020-03-20  8:00             ` [PATCH v3] media: " Suresh Udipi
2020-03-23  4:48               ` [PATCH v4] " Suresh Udipi
2020-04-14 11:56                 ` Niklas Söderlund
2020-04-30  6:03                   ` [PATCH v5] " Suresh Udipi
2020-05-04 15:01                     ` Michael Rodin
2020-05-12 21:30                       ` Niklas Söderlund
2020-05-27 15:47                         ` Michael Rodin
2020-05-27 16:16                         ` [PATCH] rcar-vin: " Michael Rodin
2020-06-05 18:44                           ` Michael Rodin
2020-06-08  3:25                             ` [PATCH v6] media: " Suresh Udipi
2020-06-10 13:40                               ` Niklas Söderlund
2020-06-12  3:10                                 ` Suresh Udipi
2020-06-12 17:28                                   ` Michael Rodin
2020-06-15 14:11                                     ` Niklas Söderlund
2020-06-17  4:57                                       ` [PATCH v7 1/2] " Suresh Udipi
2020-06-17  4:57                                         ` [PATCH v7 2/2] media: rcar-csi2: Add warning for PHY speed less than minimum Suresh Udipi
2020-06-17 13:37                                         ` [PATCH v7 1/2] media: rcar-csi2: Correct the selection of hsfreqrange Michael Rodin
2020-06-18 10:34                                           ` [PATCH v8 1/3] " Suresh Udipi
2020-06-18 10:34                                             ` [PATCH v8 2/3] media: rcar-csi2: Add warning for PHY speed less than minimum Suresh Udipi
2020-06-30 22:05                                               ` Niklas Söderlund
2020-06-18 10:34                                             ` [PATCH v8 3/3] media: rcar-csi2: Optimize the selection PHTW register Suresh Udipi
2020-06-30 22:08                                               ` Niklas Söderlund
2020-07-01  9:52                                                 ` [PATCH v9 1/3] media: rcar-csi2: Correct the selection of hsfreqrange Suresh Udipi
2020-07-01  9:53                                                   ` [PATCH v9 2/3] media: rcar-csi2: Add warning for PHY speed less than minimum Suresh Udipi
2020-07-01  9:53                                                   ` [PATCH v9 3/3] media: rcar-csi2: Optimize the selection PHTW register Suresh Udipi
2020-06-30 22:03                                             ` [PATCH v8 1/3] media: rcar-csi2: Correct the selection of hsfreqrange Niklas Söderlund
2020-05-27 16:17                         ` Michael Rodin [this message]

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=1590596255-17470-1-git-send-email-mrodin@de.adit-jv.com \
    --to=mrodin@de.adit-jv.com \
    --cc=efriedrich@de.adit-jv.com \
    --cc=erosca@de.adit-jv.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=michael@rodin.online \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=sudipi@jp.adit-jv.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

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org
	public-inbox-index linux-renesas-soc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git