All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
Subject: [PATCH v3 18/35] v4l: vsp1: Extract link creation to separate function
Date: Mon,  8 Feb 2016 13:43:48 +0200	[thread overview]
Message-ID: <1454931845-23864-19-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <1454931845-23864-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

Link creation will be handled differently for the DU pipeline.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_drv.c | 95 ++++++++++++++++++++--------------
 1 file changed, 56 insertions(+), 39 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index 0fb654e72633..81c49bfdc8dd 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -67,7 +67,7 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
  */
 
 /*
- * vsp1_create_links - Create links from all sources to the given sink
+ * vsp1_create_sink_links - Create links from all sources to the given sink
  *
  * This function creates media links from all valid sources to the given sink
  * pad. Links that would be invalid according to the VSP1 hardware capabilities
@@ -76,26 +76,14 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
  * - from a UDS to a UDS (UDS entities can't be chained)
  * - from an entity to itself (no loops are allowed)
  */
-static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
+static int vsp1_create_sink_links(struct vsp1_device *vsp1,
+				  struct vsp1_entity *sink)
 {
 	struct media_entity *entity = &sink->subdev.entity;
 	struct vsp1_entity *source;
 	unsigned int pad;
 	int ret;
 
-	if (sink->type == VSP1_ENTITY_RPF) {
-		struct vsp1_rwpf *rpf = to_rwpf(&sink->subdev);
-
-		/* RPFs have no source entities, just connect their source pad
-		 * to their video device.
-		 */
-		return media_create_pad_link(&rpf->video->video.entity, 0,
-					     &rpf->entity.subdev.entity,
-					     RWPF_PAD_SINK,
-					     MEDIA_LNK_FL_ENABLED |
-					     MEDIA_LNK_FL_IMMUTABLE);
-	}
-
 	list_for_each_entry(source, &vsp1->entities, list_dev) {
 		u32 flags;
 
@@ -126,21 +114,63 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
 		}
 	}
 
-	if (sink->type == VSP1_ENTITY_WPF) {
-		struct vsp1_rwpf *wpf = to_rwpf(&sink->subdev);
-		unsigned int flags = MEDIA_LNK_FL_ENABLED;
+	return 0;
+}
 
+static int vsp1_create_links(struct vsp1_device *vsp1)
+{
+	struct vsp1_entity *entity;
+	unsigned int i;
+	int ret;
+
+	list_for_each_entry(entity, &vsp1->entities, list_dev) {
+		if (entity->type == VSP1_ENTITY_LIF ||
+		    entity->type == VSP1_ENTITY_RPF)
+			continue;
+
+		ret = vsp1_create_sink_links(vsp1, entity);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (vsp1->pdata.features & VSP1_HAS_LIF) {
+		ret = media_create_pad_link(&vsp1->wpf[0]->entity.subdev.entity,
+					    RWPF_PAD_SOURCE,
+					    &vsp1->lif->entity.subdev.entity,
+					    LIF_PAD_SINK, 0);
+		if (ret < 0)
+			return ret;
+	}
+
+	for (i = 0; i < vsp1->pdata.rpf_count; ++i) {
+		struct vsp1_rwpf *rpf = vsp1->rpf[i];
+
+		ret = media_create_pad_link(&rpf->video->video.entity, 0,
+					    &rpf->entity.subdev.entity,
+					    RWPF_PAD_SINK,
+					    MEDIA_LNK_FL_ENABLED |
+					    MEDIA_LNK_FL_IMMUTABLE);
+		if (ret < 0)
+			return ret;
+	}
+
+	for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
 		/* Connect the video device to the WPF. All connections are
 		 * immutable except for the WPF0 source link if a LIF is
 		 * present.
 		 */
-		if (!(vsp1->pdata.features & VSP1_HAS_LIF) || sink->index != 0)
+		struct vsp1_rwpf *wpf = vsp1->wpf[i];
+		unsigned int flags = MEDIA_LNK_FL_ENABLED;
+
+		if (!(vsp1->pdata.features & VSP1_HAS_LIF) || i != 0)
 			flags |= MEDIA_LNK_FL_IMMUTABLE;
 
-		return media_create_pad_link(&wpf->entity.subdev.entity,
-					     RWPF_PAD_SOURCE,
-					     &wpf->video->video.entity,
-					     0, flags);
+		ret = media_create_pad_link(&wpf->entity.subdev.entity,
+					    RWPF_PAD_SOURCE,
+					    &wpf->video->video.entity, 0,
+					    flags);
+		if (ret < 0)
+			return ret;
 	}
 
 	return 0;
@@ -310,22 +340,9 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
 	}
 
 	/* Create links. */
-	list_for_each_entry(entity, &vsp1->entities, list_dev) {
-		if (entity->type == VSP1_ENTITY_LIF)
-			continue;
-
-		ret = vsp1_create_links(vsp1, entity);
-		if (ret < 0)
-			goto done;
-	}
-
-	if (vsp1->pdata.features & VSP1_HAS_LIF) {
-		ret = media_create_pad_link(
-			&vsp1->wpf[0]->entity.subdev.entity, RWPF_PAD_SOURCE,
-			&vsp1->lif->entity.subdev.entity, LIF_PAD_SINK, 0);
-		if (ret < 0)
-			return ret;
-	}
+	ret = vsp1_create_links(vsp1);
+	if (ret < 0)
+		goto done;
 
 	ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev);
 	if (ret < 0)
-- 
2.4.10


  parent reply	other threads:[~2016-02-08 11:44 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 11:43 [PATCH v3 00/35] VSP: Add R-Car Gen3 support Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 01/35] v4l: Add YUV 4:2:2 and YUV 4:4:4 tri-planar non-contiguous formats Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 02/35] v4l: vsp1: Add tri-planar memory formats support Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 03/35] v4l: vsp1: Group all link creation code in a single file Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 04/35] v4l: vsp1: Change the type of the rwpf field in struct vsp1_video Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 05/35] v4l: vsp1: Store the memory format in struct vsp1_rwpf Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 06/35] v4l: vsp1: Move video operations to vsp1_rwpf Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 07/35] v4l: vsp1: Rename vsp1_video_buffer to vsp1_vb2_buffer Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 08/35] v4l: vsp1: Move video device out of struct vsp1_rwpf Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 09/35] v4l: vsp1: Make rwpf operations independent of video device Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 10/35] v4l: vsp1: Support VSP1 instances without any UDS Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 11/35] v4l: vsp1: Move vsp1_video pointer from vsp1_entity to vsp1_rwpf Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 12/35] v4l: vsp1: Remove struct vsp1_pipeline num_video field Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 13/35] v4l: vsp1: Decouple pipeline end of frame processing from vsp1_video Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 14/35] v4l: vsp1: Split pipeline management code from vsp1_video.c Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 15/35] v4l: vsp1: Rename video pipeline functions to use vsp1_video prefix Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 16/35] v4l: vsp1: Extract pipeline initialization code into a function Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 17/35] v4l: vsp1: Reuse local variable instead of recomputing it Laurent Pinchart
2016-02-08 11:43 ` Laurent Pinchart [this message]
2016-02-08 11:43 ` [PATCH v3 19/35] v4l: vsp1: Document the vsp1_pipeline structure Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 20/35] v4l: vsp1: Fix typo in VI6_DISP_IRQ_STA_DST register bit name Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 21/35] v4l: vsp1: Set the SRU CTRL0 register when starting the stream Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 22/35] v4l: vsp1: Remove unused module read functions Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 23/35] v4l: vsp1: Move entity route setup function to vsp1_entity.c Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 24/35] v4l: vsp1: Make number of BRU inputs configurable Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 25/35] v4l: vsp1: Make the BRU optional Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 26/35] v4l: vsp1: Move format info to vsp1_pipe.c Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 27/35] v4l: vsp1: Make the userspace API optional Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 28/35] v4l: vsp1: Make pipeline inputs array index by RPF index Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 29/35] v4l: vsp1: Set the alpha value manually in RPF and WPF s_stream handlers Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 30/35] v4l: vsp1: Don't validate links when the userspace API is disabled Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 31/35] v4l: vsp1: Add VSP+DU support Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 32/35] v4l: vsp1: Disconnect unused RPFs from the DRM pipeline Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 33/35] v4l: vsp1: Implement atomic update for the DRM driver Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 34/35] v4l: vsp1: Add support for the R-Car Gen3 VSP2 Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 35/35] v4l: vsp1: Add display list support Laurent Pinchart

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=1454931845-23864-19-git-send-email-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    /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.