From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: linux-media@vger.kernel.org, Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-renesas-soc@vger.kernel.org,
"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
"Kieran Bingham" <kieran.bingham+renesas@ideasonboard.com>,
"Jacopo Mondi" <jacopo+renesas@jmondi.org>,
"Benoit Parrot" <bparrot@ti.com>,
"Maxime Ripard" <maxime.ripard@free-electrons.com>,
"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH/RFC v2 06/15] rcar-csi2: use frame description information when propagating .s_stream()
Date: Thu, 14 Dec 2017 20:08:26 +0100 [thread overview]
Message-ID: <20171214190835.7672-7-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20171214190835.7672-1-niklas.soderlund+renesas@ragnatech.se>
Use the frame description from the remote subdevice of the rcar-csi2's
sink pad to get the remote pad and stream pad needed to propagate the
.s_stream() operation.
The CSI-2 virtual channel which should be acted upon can be determined
by looking at which of the rcar-csi2 source pad the .s_stream() was
called on. This is because the rcar-csi2 acts as a demultiplexer for the
CSI-2 link on the one sink pad and outputs each virtual channel on a
distinct and known source pad.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/media/platform/rcar-vin/rcar-csi2.c | 58 ++++++++++++++++++++---------
1 file changed, 41 insertions(+), 17 deletions(-)
diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index e0f56cc3d25179a9..6b607b2e31e26063 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -614,20 +614,31 @@ static void rcar_csi2_stop(struct rcar_csi2 *priv)
rcar_csi2_reset(priv);
}
-static int rcar_csi2_sd_info(struct rcar_csi2 *priv, struct v4l2_subdev **sd)
+static int rcar_csi2_get_source_info(struct rcar_csi2 *priv,
+ struct v4l2_subdev **subdev,
+ unsigned int *pad,
+ struct v4l2_mbus_frame_desc *fd)
{
- struct media_pad *pad;
+ struct media_pad *remote_pad;
- pad = media_entity_remote_pad(&priv->pads[RCAR_CSI2_SINK]);
- if (!pad) {
- dev_err(priv->dev, "Could not find remote pad\n");
+ /* Get source subdevice and pad */
+ remote_pad = media_entity_remote_pad(&priv->pads[RCAR_CSI2_SINK]);
+ if (!remote_pad) {
+ dev_err(priv->dev, "Could not find remote source pad\n");
return -ENODEV;
}
+ *subdev = media_entity_to_v4l2_subdev(remote_pad->entity);
+ *pad = remote_pad->index;
- *sd = media_entity_to_v4l2_subdev(pad->entity);
- if (!*sd) {
- dev_err(priv->dev, "Could not find remote subdevice\n");
- return -ENODEV;
+ /* Get frame descriptor */
+ if (v4l2_subdev_call(*subdev, pad, get_frame_desc, *pad, fd)) {
+ dev_err(priv->dev, "Could not read frame desc\n");
+ return -EINVAL;
+ }
+
+ if (fd->type != V4L2_MBUS_FRAME_DESC_TYPE_CSI2) {
+ dev_err(priv->dev, "Frame desc do not describe CSI-2 link");
+ return -EINVAL;
}
return 0;
@@ -637,9 +648,10 @@ static int rcar_csi2_s_stream(struct v4l2_subdev *sd, unsigned int pad,
unsigned int stream, int enable)
{
struct rcar_csi2 *priv = sd_to_csi2(sd);
+ struct v4l2_mbus_frame_desc fd;
struct v4l2_subdev *nextsd;
- unsigned int i, count = 0;
- int ret, vc;
+ unsigned int i, rpad, count = 0;
+ int ret, vc, rstream = -1;
/* Only allow stream control on source pads and valid vc */
vc = rcar_csi2_pad_to_vc(pad);
@@ -650,11 +662,23 @@ static int rcar_csi2_s_stream(struct v4l2_subdev *sd, unsigned int pad,
if (stream != 0)
return -EINVAL;
- mutex_lock(&priv->lock);
-
- ret = rcar_csi2_sd_info(priv, &nextsd);
+ /* Get information about multiplexed link */
+ ret = rcar_csi2_get_source_info(priv, &nextsd, &rpad, &fd);
if (ret)
- goto out;
+ return ret;
+
+ /* Get stream on multiplexed link */
+ for (i = 0; i < fd.num_entries; i++)
+ if (fd.entry[i].bus.csi2.channel == vc)
+ rstream = fd.entry[i].stream;
+
+ if (rstream < 0) {
+ dev_err(priv->dev, "Could not find stream for vc %u\n", vc);
+ return -EINVAL;
+ }
+
+ /* Start or stop the requested stream */
+ mutex_lock(&priv->lock);
for (i = 0; i < 4; i++)
count += priv->stream_count[i];
@@ -673,14 +697,14 @@ static int rcar_csi2_s_stream(struct v4l2_subdev *sd, unsigned int pad,
}
if (enable && priv->stream_count[vc] == 0) {
- ret = v4l2_subdev_call(nextsd, video, s_stream, 1);
+ ret = v4l2_subdev_call(nextsd, pad, s_stream, rpad, rstream, 1);
if (ret) {
rcar_csi2_stop(priv);
pm_runtime_put(priv->dev);
goto out;
}
} else if (!enable && priv->stream_count[vc] == 1) {
- ret = v4l2_subdev_call(nextsd, video, s_stream, 0);
+ ret = v4l2_subdev_call(nextsd, pad, s_stream, rpad, rstream, 0);
}
priv->stream_count[vc] += enable ? 1 : -1;
--
2.15.1
next prev parent reply other threads:[~2017-12-14 19:09 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 19:08 [PATCH/RFC v2 00/15] Add multiplexed pad streaming support Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 01/15] v4l2-subdev.h: add pad and stream aware s_stream Niklas Söderlund
2017-12-15 11:51 ` Sakari Ailus
2017-12-18 23:06 ` Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 02/15] rcar-vin: use pad as the starting point for a pipeline Niklas Söderlund
2017-12-15 11:54 ` Sakari Ailus
2017-12-18 23:08 ` Niklas Söderlund
2017-12-27 15:28 ` Sakari Ailus
2017-12-14 19:08 ` [PATCH/RFC v2 03/15] rcar-vin: use the pad and stream aware s_stream Niklas Söderlund
2017-12-15 12:07 ` Sakari Ailus
2017-12-18 23:24 ` Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 04/15] rcar-csi2: switch to " Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 05/15] rcar-csi2: count usage for each source pad Niklas Söderlund
2017-12-15 12:25 ` Sakari Ailus
2017-12-18 23:38 ` Niklas Söderlund
2017-12-29 11:23 ` Sakari Ailus
2017-12-14 19:08 ` Niklas Söderlund [this message]
2017-12-15 13:19 ` [PATCH/RFC v2 06/15] rcar-csi2: use frame description information when propagating .s_stream() Sakari Ailus
2017-12-18 23:59 ` Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 07/15] rcar-csi2: use frame description information to configure CSI-2 bus Niklas Söderlund
2017-12-15 14:15 ` jacopo mondi
2017-12-19 0:05 ` Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 08/15] rcar-csi2: add get_routing support Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 09/15] adv748x: csi2: add module param for virtual channel Niklas Söderlund
2017-12-14 22:19 ` Kieran Bingham
2017-12-18 22:44 ` Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 10/15] adv748x: csi2: add translation from pixelcode to CSI-2 datatype Niklas Söderlund
2017-12-14 22:25 ` Kieran Bingham
2017-12-15 14:37 ` jacopo mondi
2017-12-14 19:08 ` [PATCH/RFC v2 11/15] adv748x: csi2: implement get_frame_desc Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 12/15] adv748x: csi2: switch to pad and stream aware s_stream Niklas Söderlund
2017-12-14 23:12 ` Kieran Bingham
2017-12-14 19:08 ` [PATCH/RFC v2 13/15] adv748x: csi2: only allow formats on sink pads Niklas Söderlund
2017-12-14 23:16 ` Kieran Bingham
2017-12-18 22:25 ` Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 14/15] adv748x: csi2: add get_routing support Niklas Söderlund
2017-12-14 23:27 ` Kieran Bingham
2017-12-18 22:58 ` Niklas Söderlund
2017-12-14 19:08 ` [PATCH/RFC v2 15/15] adv748x: afe: add routing support Niklas Söderlund
2017-12-14 22:56 ` Kieran Bingham
2017-12-14 22:59 ` Kieran Bingham
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=20171214190835.7672-7-niklas.soderlund+renesas@ragnatech.se \
--to=niklas.soderlund+renesas@ragnatech.se \
--cc=bparrot@ti.com \
--cc=jacopo+renesas@jmondi.org \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox