]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: verisilicon: Export only needed pixels formats
authorBenjamin Gaignard <benjamin.gaignard@collabora.com>
Tue, 24 Jun 2025 12:29:38 +0000 (14:29 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Mon, 4 May 2026 07:31:04 +0000 (09:31 +0200)
Some pixel formats can only be produced if the decoder outputs
reference pictures directly. In some cases, such as AV1 film-grain,
the use of the post-processor is strictly required. In this case,
only enumerate the post-processor supported formats. The exception is
when V4L2_FMTDESC_FLAG_ENUM_ALL is set, in this case, we enumerate
everything regardless of the state.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Fixes: bcd4f091cf1e ("media: verisilicon: Use V4L2_FMTDESC_FLAG_ENUM_ALL flag")
Cc: stable@vger.kernel.org
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/verisilicon/hantro_v4l2.c

index fcf3bd9bcda2d02481fa7e1f20e6b7ca54d6d786..83af9fa1ce949414bef7dd26859291226d228294 100644 (file)
@@ -222,6 +222,7 @@ static int vidioc_enum_fmt(struct file *file, void *priv,
        unsigned int num_fmts, i, j = 0;
        bool skip_mode_none, enum_all_formats;
        u32 index = f->index & ~V4L2_FMTDESC_FLAG_ENUM_ALL;
+       bool need_postproc = ctx->need_postproc;
 
        /*
         * If the V4L2_FMTDESC_FLAG_ENUM_ALL flag is set, we want to enumerate all
@@ -230,6 +231,9 @@ static int vidioc_enum_fmt(struct file *file, void *priv,
        enum_all_formats = !!(f->index & V4L2_FMTDESC_FLAG_ENUM_ALL);
        f->index = index;
 
+       if (enum_all_formats)
+               need_postproc = HANTRO_AUTO_POSTPROC;
+
        /*
         * When dealing with an encoder:
         *  - on the capture side we want to filter out all MODE_NONE formats.
@@ -242,7 +246,7 @@ static int vidioc_enum_fmt(struct file *file, void *priv,
         */
        skip_mode_none = capture == ctx->is_encoder;
 
-       formats = hantro_get_formats(ctx, &num_fmts, HANTRO_AUTO_POSTPROC);
+       formats = hantro_get_formats(ctx, &num_fmts, need_postproc);
        for (i = 0; i < num_fmts; i++) {
                bool mode_none = formats[i].codec_mode == HANTRO_MODE_NONE;
                fmt = &formats[i];