[PATCH 17/17] smiapp: Decrease link frequency if media bus pixel format BPP requires

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Decrease the link frequency to the next lower if the user chooses a media
bus code (BPP) cannot be achieved using the selected link frequency.

Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
---
 drivers/media/i2c/smiapp/smiapp-core.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 537ca92..ce2c34d 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -286,11 +286,27 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor)
 
 	pll->binning_horizontal = sensor->binning_horizontal;
 	pll->binning_vertical = sensor->binning_vertical;
-	pll->link_freq =
-		sensor->link_freq->qmenu_int[sensor->link_freq->val];
 	pll->scale_m = sensor->scale_m;
 	pll->bits_per_pixel = sensor->csi_format->compressed;
 
+	if (!test_bit(sensor->link_freq->val,
+		      &sensor->valid_link_freqs[
+			      sensor->csi_format->compressed
+			      - SMIAPP_COMPRESSED_BASE])) {
+		/*
+		 * Setting the link frequency will perform PLL
+		 * re-calculation already, so skip that.
+		 */
+		return __v4l2_ctrl_s_ctrl(
+			sensor->link_freq,
+			__ffs(sensor->valid_link_freqs[
+				      sensor->csi_format->compressed
+				      - SMIAPP_COMPRESSED_BASE]));
+	}
+
+	pll->link_freq =
+		sensor->link_freq->qmenu_int[sensor->link_freq->val];
+
 	rval = smiapp_pll_try(sensor, pll);
 	if (rval < 0)
 		return rval;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux