linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	tomoharu.fukawa.eb@renesas.com,
	"Wolfram Sang" <wsa@the-dreams.de>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH 05/11] media: rcar-vin: add wrapper to get rvin_graph_entity
Date: Tue, 31 Jan 2017 16:40:10 +0100	[thread overview]
Message-ID: <20170131154016.15526-6-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20170131154016.15526-1-niklas.soderlund+renesas@ragnatech.se>

Update the driver to retrieve the code and mbus_cfg values from a
rvin_graph_entity retrieved from a wrapper function instead of directly
accessing the entity for the digital port. This is done to prepare for
Gen3 support where the subdeivce might change during runtime, so to
directly accesses a specific rvin_graph_entity is bad.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/platform/rcar-vin/rcar-core.c |  9 +++++++++
 drivers/media/platform/rcar-vin/rcar-dma.c  | 15 ++++++++++-----
 drivers/media/platform/rcar-vin/rcar-v4l2.c |  6 +++++-
 drivers/media/platform/rcar-vin/rcar-vin.h  |  1 +
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 098a0b1cc10a26ba..89a9280efa05aa0c 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -26,6 +26,15 @@
 #include "rcar-vin.h"
 
 /* -----------------------------------------------------------------------------
+ * Subdevice helpers
+ */
+
+struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin)
+{
+	return &vin->digital;
+}
+
+/* -----------------------------------------------------------------------------
  * Async notifier
  */
 
diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index 9ccd5ff55e192514..eac5c192b887ea45 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -131,10 +131,15 @@ static u32 rvin_read(struct rvin_dev *vin, u32 offset)
 
 static int rvin_setup(struct rvin_dev *vin)
 {
+	struct rvin_graph_entity *rent;
 	u32 vnmc, dmr, dmr2, interrupts;
 	v4l2_std_id std;
 	bool progressive = false, output_is_yuv = false, input_is_yuv = false;
 
+	rent = vin_to_entity(vin);
+	if (!rent)
+		return -ENODEV;
+
 	switch (vin->format.field) {
 	case V4L2_FIELD_TOP:
 		vnmc = VNMC_IM_ODD;
@@ -174,7 +179,7 @@ static int rvin_setup(struct rvin_dev *vin)
 	/*
 	 * Input interface
 	 */
-	switch (vin->digital.code) {
+	switch (rent->code) {
 	case MEDIA_BUS_FMT_YUYV8_1X16:
 		/* BT.601/BT.1358 16bit YCbCr422 */
 		vnmc |= VNMC_INF_YUV16;
@@ -182,7 +187,7 @@ static int rvin_setup(struct rvin_dev *vin)
 		break;
 	case MEDIA_BUS_FMT_UYVY8_2X8:
 		/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-		vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ?
+		vnmc |= rent->mbus_cfg.type == V4L2_MBUS_BT656 ?
 			VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
 		input_is_yuv = true;
 		break;
@@ -191,7 +196,7 @@ static int rvin_setup(struct rvin_dev *vin)
 		break;
 	case MEDIA_BUS_FMT_UYVY10_2X10:
 		/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-		vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ?
+		vnmc |= rent->mbus_cfg.type == V4L2_MBUS_BT656 ?
 			VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
 		input_is_yuv = true;
 		break;
@@ -203,11 +208,11 @@ static int rvin_setup(struct rvin_dev *vin)
 	dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
 
 	/* Hsync Signal Polarity Select */
-	if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
+	if (!(rent->mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
 		dmr2 |= VNDMR2_HPS;
 
 	/* Vsync Signal Polarity Select */
-	if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
+	if (!(rent->mbus_cfg.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
 		dmr2 |= VNDMR2_VPS;
 
 	/*
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index f9218f230322eb0b..370bb184e5faace7 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -164,6 +164,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
 {
 	struct v4l2_subdev *sd;
 	struct v4l2_subdev_pad_config *pad_cfg;
+	struct rvin_graph_entity *rent;
 	struct v4l2_subdev_format format = {
 		.which = which,
 	};
@@ -171,8 +172,11 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
 	int ret;
 
 	sd = vin_to_source(vin);
+	rent = vin_to_entity(vin);
+	if (!rent)
+		return -ENODEV;
 
-	v4l2_fill_mbus_format(&format.format, pix, vin->digital.code);
+	v4l2_fill_mbus_format(&format.format, pix, rent->code);
 
 	pad_cfg = v4l2_subdev_alloc_pad_config(sd);
 	if (pad_cfg == NULL)
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h
index 727e215c08718eb9..daec26a38d896b21 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -144,6 +144,7 @@ struct rvin_dev {
 	struct v4l2_rect compose;
 };
 
+struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin);
 #define vin_to_source(vin)		vin->digital.subdev
 
 /* Debug */
-- 
2.11.0


  parent reply	other threads:[~2017-01-31 15:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 15:40 [PATCH 00/11] media: rcar-vin: fix OPS and format/pad index issues Niklas Söderlund
2017-01-31 15:40 ` [PATCH 01/11] media: rcar-vin: reset bytesperline and sizeimage when resetting format Niklas Söderlund
2017-01-31 15:40 ` [PATCH 02/11] media: rcar-vin: use rvin_reset_format() in S_DV_TIMINGS Niklas Söderlund
2017-01-31 15:40 ` [PATCH 03/11] media: rcar-vin: fix how pads are handled for v4l2 subdeivce operations Niklas Söderlund
2017-01-31 15:40 ` [PATCH 04/11] media: rcar-vin: fix standard in input enumeration Niklas Söderlund
2017-01-31 15:40 ` Niklas Söderlund [this message]
2017-01-31 15:40 ` [PATCH 06/11] media: rcar-vin: move subdev source and sink pad index to rvin_graph_entity Niklas Söderlund
2017-01-31 15:40 ` [PATCH 07/11] media: rcar-vin: move pad index discovery to async complete handler Niklas Söderlund
2017-01-31 15:40 ` [PATCH 08/11] media: rcar-vin: refactor pad lookup code Niklas Söderlund
2017-01-31 15:40 ` [PATCH 09/11] media: rcar-vin: use pad information when verifying media bus format Niklas Söderlund
2017-01-31 15:40 ` [PATCH 10/11] media: rcar-vin: split rvin_s_fmt_vid_cap() Niklas Söderlund
2017-01-31 15:40 ` [PATCH 11/11] media: rcar-vin: register the video device early Niklas Söderlund
2017-02-07 11:20 ` [PATCH 00/11] media: rcar-vin: fix OPS and format/pad index issues Wolfram Sang
2017-02-13 14:19 ` Hans Verkuil
2017-02-13 15:31   ` Laurent Pinchart
2017-02-13 15:43     ` Hans Verkuil
2017-02-13 17:47   ` Niklas Söderlund
2017-02-13 20:57     ` Hans Verkuil
2017-02-14  6:40       ` Niklas Söderlund

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=20170131154016.15526-6-niklas.soderlund+renesas@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=tomoharu.fukawa.eb@renesas.com \
    --cc=wsa@the-dreams.de \
    /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;
as well as URLs for NNTP newsgroup(s).