Skip to content

Commit 549cc89

Browse files
sudipimchehab
authored andcommitted
media: rcar-csi2: Optimize the selection PHTW register
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: 769afd2 ("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> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent ebeefe2 commit 549cc89

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎drivers/media/platform/rcar-vin/rcar-csi2.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,17 @@ static int rcsi2_phtw_write_mbps(struct rcar_csi2 *priv, unsigned int mbps,
11081108
const struct rcsi2_mbps_reg *values, u16 code)
11091109
{
11101110
const struct rcsi2_mbps_reg *value;
1111+
const struct rcsi2_mbps_reg *prev_value = NULL;
11111112

1112-
for (value = values; value->mbps; value++)
1113+
for (value = values; value->mbps; value++) {
11131114
if (value->mbps >= mbps)
11141115
break;
1116+
prev_value = value;
1117+
}
1118+
1119+
if (prev_value &&
1120+
((mbps - prev_value->mbps) <= (value->mbps - mbps)))
1121+
value = prev_value;
11151122

11161123
if (!value->mbps) {
11171124
dev_err(priv->dev, "Unsupported PHY speed (%u Mbps)", mbps);

0 commit comments

Comments
 (0)