media: platform: video-mux: propagate format from sink to source
Propagate the v4l2_mbus_framefmt to the source pad when either a sink pad is activated or when the format of the active sink pad changes. Signed-off-by: Chris Lesiak <chris.lesiak@licor.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
65dc760bb4
commit
fd32d53496
|
@ -45,6 +45,7 @@ static int video_mux_link_setup(struct media_entity *entity,
|
||||||
{
|
{
|
||||||
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
|
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
|
||||||
struct video_mux *vmux = v4l2_subdev_to_video_mux(sd);
|
struct video_mux *vmux = v4l2_subdev_to_video_mux(sd);
|
||||||
|
u16 source_pad = entity->num_pads - 1;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -74,6 +75,9 @@ static int video_mux_link_setup(struct media_entity *entity,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
vmux->active = local->index;
|
vmux->active = local->index;
|
||||||
|
|
||||||
|
/* Propagate the active format to the source */
|
||||||
|
vmux->format_mbus[source_pad] = vmux->format_mbus[vmux->active];
|
||||||
} else {
|
} else {
|
||||||
if (vmux->active != local->index)
|
if (vmux->active != local->index)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -162,14 +166,20 @@ static int video_mux_set_format(struct v4l2_subdev *sd,
|
||||||
struct v4l2_subdev_format *sdformat)
|
struct v4l2_subdev_format *sdformat)
|
||||||
{
|
{
|
||||||
struct video_mux *vmux = v4l2_subdev_to_video_mux(sd);
|
struct video_mux *vmux = v4l2_subdev_to_video_mux(sd);
|
||||||
struct v4l2_mbus_framefmt *mbusformat;
|
struct v4l2_mbus_framefmt *mbusformat, *source_mbusformat;
|
||||||
struct media_pad *pad = &vmux->pads[sdformat->pad];
|
struct media_pad *pad = &vmux->pads[sdformat->pad];
|
||||||
|
u16 source_pad = sd->entity.num_pads - 1;
|
||||||
|
|
||||||
mbusformat = __video_mux_get_pad_format(sd, cfg, sdformat->pad,
|
mbusformat = __video_mux_get_pad_format(sd, cfg, sdformat->pad,
|
||||||
sdformat->which);
|
sdformat->which);
|
||||||
if (!mbusformat)
|
if (!mbusformat)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
source_mbusformat = __video_mux_get_pad_format(sd, cfg, source_pad,
|
||||||
|
sdformat->which);
|
||||||
|
if (!source_mbusformat)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&vmux->lock);
|
mutex_lock(&vmux->lock);
|
||||||
|
|
||||||
/* Source pad mirrors active sink pad, no limitations on sink pads */
|
/* Source pad mirrors active sink pad, no limitations on sink pads */
|
||||||
|
@ -178,6 +188,10 @@ static int video_mux_set_format(struct v4l2_subdev *sd,
|
||||||
|
|
||||||
*mbusformat = sdformat->format;
|
*mbusformat = sdformat->format;
|
||||||
|
|
||||||
|
/* Propagate the format from an active sink to source */
|
||||||
|
if ((pad->flags & MEDIA_PAD_FL_SINK) && (pad->index == vmux->active))
|
||||||
|
*source_mbusformat = sdformat->format;
|
||||||
|
|
||||||
mutex_unlock(&vmux->lock);
|
mutex_unlock(&vmux->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue