All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo+renesas@jmondi.org>
To: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com,
	niklas.soderlund+renesas@ragnatech.se,
	kieran.bingham@ideasonboard.com
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	dave.stevenson@raspberrypi.org
Subject: [RFC 3/5] media: adv748x: Make lanes number depend on routing
Date: Sat, 16 Mar 2019 16:47:59 +0100	[thread overview]
Message-ID: <20190316154801.20460-4-jacopo+renesas@jmondi.org> (raw)
In-Reply-To: <20190316154801.20460-1-jacopo+renesas@jmondi.org>

Use the TXA routing information to configure the number of active CSI-2
data lanes. When routing AFE through TXA limit the number of data lanes
to 1, while in the canonical HDMI->TXA routing use all the physically
available ones.

The number of lanes collected from the 'data-lanes' DT property is now
used as a the number of physically available data lanes, while the
'num_lanes' variable contains the number of active ones.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/adv748x/adv748x-core.c | 19 ++++++++++++++++++-
 drivers/media/i2c/adv748x/adv748x.h      |  1 +
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index 02135741b1a6..f91c7b83f1bf 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -350,6 +350,8 @@ static int adv748x_link_setup(struct media_entity *entity,
 	struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
 	bool enable = flags & MEDIA_LNK_FL_ENABLED;
 	u8 csi4_in_sel = 0;
+	u8 num_lanes;
+	int ret;
 
 	/* Refuse to enable multiple links to the same TX at the same time. */
 	if (enable && tx->src)
@@ -373,10 +375,23 @@ static int adv748x_link_setup(struct media_entity *entity,
 			csi4_in_sel |= ADV748X_IO_10_CSI4_IN_SEL_AFE;
 		else
 			csi4_in_sel |= ADV748X_IO_10_CSI1_EN;
+
+		num_lanes = 1;
 	}
 
-	if (state->hdmi.tx)
+	if (state->hdmi.tx) {
 		csi4_in_sel |= ADV748X_IO_10_CSI4_EN;
+		num_lanes = tx->available_lanes;
+	}
+
+	/* Update the number of active lanes if it has changed. */
+	if (num_lanes != tx->num_lanes) {
+		tx->num_lanes = num_lanes;
+		ret = adv748x_write(state, tx->page, 0x00,
+				    0x80 | tx->num_lanes);
+		if (ret)
+			return ret;
+	}
 
 	state->csi4_in_sel = csi4_in_sel;
 
@@ -608,6 +623,7 @@ static int adv748x_parse_csi2_lanes(struct adv748x_state *state,
 		}
 
 		state->txa.num_lanes = num_lanes;
+		state->txa.available_lanes = num_lanes;
 		adv_dbg(state, "TXA: using %u lanes\n", state->txa.num_lanes);
 	}
 
@@ -619,6 +635,7 @@ static int adv748x_parse_csi2_lanes(struct adv748x_state *state,
 		}
 
 		state->txb.num_lanes = num_lanes;
+		state->txb.available_lanes = num_lanes;
 		adv_dbg(state, "TXB: using %u lanes\n", state->txb.num_lanes);
 	}
 
diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
index 27c116d09284..6e5c2cb421fe 100644
--- a/drivers/media/i2c/adv748x/adv748x.h
+++ b/drivers/media/i2c/adv748x/adv748x.h
@@ -80,6 +80,7 @@ struct adv748x_csi2 {
 	unsigned int page;
 	unsigned int port;
 	unsigned int num_lanes;
+	unsigned int available_lanes;
 
 	struct media_pad pads[ADV748X_CSI2_NR_PADS];
 	struct v4l2_ctrl_handler ctrl_hdl;
-- 
2.21.0


  parent reply	other threads:[~2019-03-16 15:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-16 15:47 [RFC 0/5] media: Implement negotiation of CSI-2 data lanes Jacopo Mondi
2019-03-16 15:47 ` [RFC 1/5] v4l: subdev: Add MIPI CSI-2 PHY to frame desc Jacopo Mondi
2019-03-16 16:20   ` Sergei Shtylyov
2019-03-18  8:23     ` Jacopo Mondi
2019-03-16 17:51   ` Sakari Ailus
2019-03-18  8:31     ` Jacopo Mondi
2019-03-18 15:29       ` Dave Stevenson
2019-03-20 16:45         ` Jacopo Mondi
2019-04-04  8:49         ` Sakari Ailus
2019-04-04 16:36           ` Dave Stevenson
2019-04-10 16:51   ` Jacopo Mondi
2019-03-16 15:47 ` [RFC 2/5] media: adv748x: Post-pone IO10 write to power up Jacopo Mondi
2019-04-12 14:15   ` Kieran Bingham
2019-04-12 14:45     ` Jacopo Mondi
2019-04-12 15:57       ` Kieran Bingham
2019-04-15  7:00         ` Jacopo Mondi
2020-06-10  9:50           ` Kieran Bingham
2019-03-16 15:47 ` Jacopo Mondi [this message]
2019-04-12 14:45   ` [RFC 3/5] media: adv748x: Make lanes number depend on routing Kieran Bingham
2019-03-16 15:48 ` [RFC 4/5] media: adv748x: Report D-PHY configuration Jacopo Mondi
2019-03-16 15:48 ` [RFC 5/5] media: rcar-csi2: Configure CSI-2 with frame desc Jacopo Mondi
2019-03-20 19:50   ` Niklas Söderlund
2019-03-21  0:51     ` Jacopo Mondi

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=20190316154801.20460-4-jacopo+renesas@jmondi.org \
    --to=jacopo+renesas@jmondi.org \
    --cc=dave.stevenson@raspberrypi.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=sakari.ailus@linux.intel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.