diff mbox series

[v3,2/2] media: imx: ask source subdevice for number of active data lanes

Message ID 20181205161414.29812-2-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series [v3,1/2] media: tc358743: fix connected/active CSI-2 lane reporting | expand

Commit Message

Philipp Zabel Dec. 5, 2018, 4:14 p.m. UTC
Temporarily use g_mbus_config() to determine the number of active data
lanes used by the transmitter. If g_mbus_config is not supported or
does not return the number of active lines, default to using all
connected data lines.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Steve Longerbeam <steve_longerbeam@mentor.com>
---
Changes since v2 [1]:
 - Rebased onto media/master

[1] https://patchwork.kernel.org/patch/9964151/
---
 drivers/staging/media/imx/imx6-mipi-csi2.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c
index 6a1cee55a49b..ae91f0d138f3 100644
--- a/drivers/staging/media/imx/imx6-mipi-csi2.c
+++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
@@ -135,10 +135,8 @@  static void csi2_enable(struct csi2_dev *csi2, bool enable)
 	}
 }
 
-static void csi2_set_lanes(struct csi2_dev *csi2)
+static void csi2_set_lanes(struct csi2_dev *csi2, int lanes)
 {
-	int lanes = csi2->bus.num_data_lanes;
-
 	writel(lanes - 1, csi2->base + CSI2_N_LANES);
 }
 
@@ -301,6 +299,9 @@  static void csi2ipu_gasket_init(struct csi2_dev *csi2)
 
 static int csi2_start(struct csi2_dev *csi2)
 {
+	const u32 mask = V4L2_MBUS_CSI2_LANE_MASK;
+	struct v4l2_mbus_config cfg;
+	int lanes = 0;
 	int ret;
 
 	ret = clk_prepare_enable(csi2->pix_clk);
@@ -316,7 +317,10 @@  static int csi2_start(struct csi2_dev *csi2)
 		goto err_disable_clk;
 
 	/* Step 4 */
-	csi2_set_lanes(csi2);
+	ret = v4l2_subdev_call(csi2->src_sd, video, g_mbus_config, &cfg);
+	if (ret == 0)
+		lanes = (cfg.flags & mask) >> __ffs(mask);
+	csi2_set_lanes(csi2, lanes ?: csi2->bus.num_data_lanes);
 	csi2_enable(csi2, true);
 
 	/* Step 5 */