diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-11-15 19:14:22 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-04-13 18:52:08 -0300 |
commit | e790c3cb8d904c4bad0d4a37885bece2eb848eeb (patch) | |
tree | 2b320c3290263fa349d6a95120c28ec7d2bea5cf /drivers/media/platform/vsp1/vsp1_lif.c | |
parent | 0efdf0f5eaaff6c18d1e645a8e1fdebf73400fe1 (diff) |
[media] v4l: vsp1: Store active formats in a pad config structure
Add a pad config structure field to the vsp1_entity structure and use it
to store all active pad formats. This generalizes the code to operate on
pad config structures.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/platform/vsp1/vsp1_lif.c')
-rw-r--r-- | drivers/media/platform/vsp1/vsp1_lif.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/drivers/media/platform/vsp1/vsp1_lif.c b/drivers/media/platform/vsp1/vsp1_lif.c index 5edf6a742c5b..4090a0351263 100644 --- a/drivers/media/platform/vsp1/vsp1_lif.c +++ b/drivers/media/platform/vsp1/vsp1_lif.c @@ -48,7 +48,8 @@ static int lif_s_stream(struct v4l2_subdev *subdev, int enable) return 0; } - format = &lif->entity.formats[LIF_PAD_SOURCE]; + format = vsp1_entity_get_pad_format(&lif->entity, lif->entity.config, + LIF_PAD_SOURCE); obth = min(obth, (format->width + 1) / 2 * format->height - 4); @@ -84,6 +85,7 @@ static int lif_enum_mbus_code(struct v4l2_subdev *subdev, code->code = codes[code->index]; } else { + struct v4l2_subdev_pad_config *config; struct v4l2_mbus_framefmt *format; /* The LIF can't perform format conversion, the sink format is @@ -92,8 +94,13 @@ static int lif_enum_mbus_code(struct v4l2_subdev *subdev, if (code->index) return -EINVAL; - format = vsp1_entity_get_pad_format(&lif->entity, cfg, - LIF_PAD_SINK, code->which); + config = vsp1_entity_get_pad_config(&lif->entity, cfg, + code->which); + if (!config) + return -EINVAL; + + format = vsp1_entity_get_pad_format(&lif->entity, config, + LIF_PAD_SINK); code->code = format->code; } @@ -105,10 +112,14 @@ static int lif_enum_frame_size(struct v4l2_subdev *subdev, struct v4l2_subdev_frame_size_enum *fse) { struct vsp1_lif *lif = to_lif(subdev); + struct v4l2_subdev_pad_config *config; struct v4l2_mbus_framefmt *format; - format = vsp1_entity_get_pad_format(&lif->entity, cfg, LIF_PAD_SINK, - fse->which); + config = vsp1_entity_get_pad_config(&lif->entity, cfg, fse->which); + if (!config) + return -EINVAL; + + format = vsp1_entity_get_pad_format(&lif->entity, config, LIF_PAD_SINK); if (fse->index || fse->code != format->code) return -EINVAL; @@ -133,9 +144,14 @@ static int lif_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_format *fmt) { struct vsp1_lif *lif = to_lif(subdev); + struct v4l2_subdev_pad_config *config; - fmt->format = *vsp1_entity_get_pad_format(&lif->entity, cfg, fmt->pad, - fmt->which); + config = vsp1_entity_get_pad_config(&lif->entity, cfg, fmt->which); + if (!config) + return -EINVAL; + + fmt->format = *vsp1_entity_get_pad_format(&lif->entity, config, + fmt->pad); return 0; } @@ -145,15 +161,19 @@ static int lif_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_format *fmt) { struct vsp1_lif *lif = to_lif(subdev); + struct v4l2_subdev_pad_config *config; struct v4l2_mbus_framefmt *format; + config = vsp1_entity_get_pad_config(&lif->entity, cfg, fmt->which); + if (!config) + return -EINVAL; + /* Default to YUV if the requested format is not supported. */ if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; - format = vsp1_entity_get_pad_format(&lif->entity, cfg, fmt->pad, - fmt->which); + format = vsp1_entity_get_pad_format(&lif->entity, config, fmt->pad); if (fmt->pad == LIF_PAD_SOURCE) { /* The LIF source format is always identical to its sink @@ -174,8 +194,8 @@ static int lif_set_format(struct v4l2_subdev *subdev, fmt->format = *format; /* Propagate the format to the source pad. */ - format = vsp1_entity_get_pad_format(&lif->entity, cfg, LIF_PAD_SOURCE, - fmt->which); + format = vsp1_entity_get_pad_format(&lif->entity, config, + LIF_PAD_SOURCE); *format = fmt->format; return 0; |