[PATCH v1 2/2] media: rockchip: rkcif: Validate the pixel format against the media bus code
Michael Riesch
michael.riesch at collabora.com
Mon Nov 16 02:55:33 PST 2026
Hi Mehdi,
Thanks for the patch!
I think I had a check like this in the source code once, but kicked it
out because it broke one of my valid pipelines. Let's take the first
entry of mipi_out_fmts for instance: the capture block can write
V4L2_PIX_FMT_YUYV image data to memory. However, I *think* it can not
only accept MEDIA_BUS_FMT_YUYV8_1X16 as input format for that, but other
mbus formats too. Thus, if I am not mistaken, we need to rework that at
some point.
Cc: Gerald who might have a pipeline that will be broken by this patch...
On 11/12/26 19:32, Mehdi Djait wrote:
> The link validation only checks the frame size, so a pixel format that
> does not match the media bus code on the source pad is accepted.
>
> Reject such pipelines with -EPIPE.
>
> Signed-off-by: Mehdi Djait <mehdi.djait at linux.intel.com>
...but all the above said, the patch as such is valid, but I think the
definition of possible formats needs a rework. I'll leave my
Reviewed-by: Michael Riesch <michael.riesch at collabora.com>
here just in case.
Best regards,
Michael
> ---
> drivers/media/platform/rockchip/rkcif/rkcif-stream.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
> index 3130d420ad55..66726f654674 100644
> --- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
> +++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
> @@ -460,6 +460,7 @@ static int rkcif_stream_link_validate(struct media_link *link)
> {
> struct video_device *vdev =
> media_entity_to_video_device(link->sink->entity);
> + const struct rkcif_output_fmt *fmt;
> struct v4l2_mbus_framefmt *source_fmt;
> struct v4l2_subdev *sd;
> struct v4l2_subdev_state *state;
> @@ -489,6 +490,17 @@ static int rkcif_stream_link_validate(struct media_link *link)
> goto out;
> }
>
> + fmt = rkcif_stream_find_output_fmt(stream, false,
> + stream->pix.pixelformat);
> + if (!fmt || (fmt->mbus_code && fmt->mbus_code != source_fmt->code)) {
> + dev_dbg(stream->rkcif->dev,
> + "link '%s':%u -> '%s':%u not valid: Format mismatch\n",
> + link->source->entity->name, link->source->index,
> + link->sink->entity->name, link->sink->index);
> + ret = -EPIPE;
> + goto out;
> + }
> +
> ret = 0;
>
> out:
More information about the Linux-rockchip
mailing list