diff mbox series

[RFC,4/5] media: adv748x: Report D-PHY configuration

Message ID 20190316154801.20460-5-jacopo+renesas@jmondi.org (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series media: Implement negotiation of CSI-2 data lanes | expand

Commit Message

Jacopo Mondi March 16, 2019, 3:48 p.m. UTC
Extend the media bus frame description to report the D-PHY bus
configuration.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/adv748x/adv748x-csi2.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
index 13454af72c6e..c733c7ab8247 100644
--- a/drivers/media/i2c/adv748x/adv748x-csi2.c
+++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
@@ -231,8 +231,12 @@  static int adv748x_csi2_set_format(struct v4l2_subdev *sd,
 static int adv748x_csi2_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
 				       struct v4l2_mbus_frame_desc *fd)
 {
+	struct v4l2_mbus_frame_desc_entry_csi2_dphy *dphy;
 	struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
+	struct v4l2_mbus_frame_desc_entry_csi2 *csi2;
 	struct v4l2_mbus_framefmt *mbusformat;
+	unsigned int i;
+
 
 	memset(fd, 0, sizeof(*fd));
 
@@ -244,13 +248,20 @@  static int adv748x_csi2_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
 	if (!mbusformat)
 		return -EINVAL;
 
+	fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2_DPHY;
+	fd->num_entries = 1;
+
 	fd->entry->stream = tx->vc;
-	fd->entry->bus.csi2.channel = tx->vc;
-	fd->entry->bus.csi2.data_type =
-		adv748x_csi2_code_to_datatype(mbusformat->code);
 
-	fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
-	fd->num_entries = 1;
+	csi2 = &fd->entry->bus.csi2;
+	csi2->channel = tx->vc;
+	csi2->data_type = adv748x_csi2_code_to_datatype(mbusformat->code);
+
+	dphy = &fd->phy.csi2_dphy;
+	dphy->clock_lane = 0;
+	for (i = 0; i < tx->num_lanes; ++i)
+		dphy->data_lanes[i] = i + 1;
+	dphy->num_data_lanes = tx->num_lanes;
 
 	return 0;
 }