@@ -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
*/
@@ -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;
/*
@@ -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)
@@ -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 */
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(-)