[PATCH 1/2] media: rockchip: rkcif: Filter enumerated formats by media bus code
Mehdi Djait
mehdi.djait at linux.intel.com
Mon Nov 9 04:27:34 PST 2026
Hello,
On Thu, Nov 05, 2026 at 04:23:09PM -0700, Faizel K B wrote:
> VIDIOC_ENUM_FMT ignores the mbus_code field and returns all formats,
> although the video devices set V4L2_CAP_IO_MC. Return only the formats
> that match the requested media bus code.
>
> Otherwise userspace can pick a pixel format that doesn't match the
> media bus format, and then interprets the captured data in the wrong
> format.
>
> Signed-off-by: Faizel K B <faizel.kb at gmail.com>
> ---
> .../media/platform/rockchip/rkcif/rkcif-stream.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
> index 3130d420ad55..f2a24832a8cf 100644
> --- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
> +++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c
> @@ -395,13 +395,20 @@ static int rkcif_stream_enum_formats(struct file *file, void *priv,
> struct v4l2_fmtdesc *f)
> {
> struct rkcif_stream *stream = video_drvdata(file);
> + unsigned int i, n = 0;
>
> - if (f->index >= stream->out_fmts_num)
> - return -EINVAL;
> + for (i = 0; i < stream->out_fmts_num; i++) {
> + if (f->mbus_code &&
> + stream->out_fmts[i].mbus_code != f->mbus_code)
what about dvp capture. The dvp_out_fmts[] does not have the mbus_code
set.
> + continue;
--
Kind Regards
Mehdi Djait
More information about the Linux-rockchip
mailing list