v4l2: add interlaced field support in try_fmt [1/1]
authorSong Zhao <song.zhao@amlogic.com>
Mon, 6 Jul 2020 15:51:26 +0000 (08:51 -0700)
committerSong Zhao <song.zhao@amlogic.com>
Thu, 9 Jul 2020 08:19:29 +0000 (01:19 -0700)
PD#SWPL-29144

Problem:
try_fmt only return V4L2_FIELD_ANY. But gstreamer v4l2 plugin want to
check whether V4L2_FIELD_INTERLACED is supported or not.

Solution:
For H264/Mpeg2, add V4L2_FIELD_INTERLACED support.

Verify:
U212 + gst-launch

Change-Id: I8516840b2d8e13e6795a9749c36153c7e77dc9b4
Signed-off-by: Song Zhao <song.zhao@amlogic.com>
drivers/amvdec_ports/aml_vcodec_dec.c

index 681eb059aaa57ef89debde585d38e6efd32fbcce..c8445d2557878b683eba5810b17ad3bcf19990d6 100644 (file)
@@ -1487,14 +1487,20 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct aml_video_fmt *fmt)
        struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
        int i;
 
-       pix_fmt_mp->field = V4L2_FIELD_NONE;
-
        if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
                pix_fmt_mp->num_planes = 1;
                pix_fmt_mp->plane_fmt[0].bytesperline = 0;
+               if (pix_fmt_mp->pixelformat != V4L2_PIX_FMT_MPEG2  &&
+                   pix_fmt_mp->pixelformat != V4L2_PIX_FMT_H264)
+                       pix_fmt_mp->field = V4L2_FIELD_NONE;
+               else if (pix_fmt_mp->field != V4L2_FIELD_NONE)
+                       pr_info("%s, field: %u, fmt: %u\n",
+                               __func__, pix_fmt_mp->field,
+                               pix_fmt_mp->pixelformat);
        } else if (!V4L2_TYPE_IS_OUTPUT(f->type)) {
                int tmp_w, tmp_h;
 
+               pix_fmt_mp->field = V4L2_FIELD_NONE;
                pix_fmt_mp->height = clamp(pix_fmt_mp->height,
                                        AML_VDEC_MIN_H,
                                        AML_VDEC_MAX_H);