Re: [PATCH 0/2] media: meson: vdec: Add compliant H264 support

From: Hans Verkuil
Date: Mon Oct 07 2019 - 12:39:32 EST


On 10/7/19 6:24 PM, Maxime Jourdan wrote:
> On 07/10/2019 17:12, Hans Verkuil wrote:
>> On 10/7/19 4:59 PM, Maxime Jourdan wrote:
>>> Hello,
>>>
>>> This patch series aims to bring H.264 support as well as compliance update
>>> to the amlogic stateful video decoder driver.
>>>
>>> There is 1 issue that remains currently:
>>>
>>> Â - The following codepath had to be commented out from v4l2-compliance as
>>> it led to stalling:
>>>
>>> if (node->codec_mask & STATEFUL_DECODER) {
>>> ÂÂÂÂstruct v4l2_decoder_cmd cmd;
>>> ÂÂÂÂbuffer buf_cap(m2m_q);
>>>
>>> ÂÂÂÂmemset(&cmd, 0, sizeof(cmd));
>>> ÂÂÂÂcmd.cmd = V4L2_DEC_CMD_STOP;
>>>
>>> ÂÂÂÂ/* No buffers are queued, call STREAMON, then STOP */
>>> ÂÂÂÂfail_on_test(node->streamon(q.g_type()));
>>> ÂÂÂÂfail_on_test(node->streamon(m2m_q.g_type()));
>>> ÂÂÂÂfail_on_test(doioctl(node, VIDIOC_DECODER_CMD, &cmd));
>>>
>>> ÂÂÂÂfail_on_test(buf_cap.querybuf(node, 0));
>>> ÂÂÂÂfail_on_test(buf_cap.qbuf(node));
>>> ÂÂÂÂfail_on_test(buf_cap.dqbuf(node));
>>> ÂÂÂÂfail_on_test(!(buf_cap.g_flags() & V4L2_BUF_FLAG_LAST));
>>> ÂÂÂÂfor (unsigned p = 0; p < buf_cap.g_num_planes(); p++)
>>> ÂÂÂÂÂÂÂ fail_on_test(buf_cap.g_bytesused(p));
>>> ÂÂÂÂfail_on_test(node->streamoff(q.g_type()));
>>> ÂÂÂÂfail_on_test(node->streamoff(m2m_q.g_type()));
>>>
>>> ÂÂÂÂ/* Call STREAMON, queue one CAPTURE buffer, then STOP */
>>> ÂÂÂÂfail_on_test(node->streamon(q.g_type()));
>>> ÂÂÂÂfail_on_test(node->streamon(m2m_q.g_type()));
>>> ÂÂÂÂfail_on_test(buf_cap.querybuf(node, 0));
>>> ÂÂÂÂfail_on_test(buf_cap.qbuf(node));
>>> ÂÂÂÂfail_on_test(doioctl(node, VIDIOC_DECODER_CMD, &cmd));
>>>
>>> ÂÂÂÂfail_on_test(buf_cap.dqbuf(node));
>>> ÂÂÂÂfail_on_test(!(buf_cap.g_flags() & V4L2_BUF_FLAG_LAST));
>>> ÂÂÂÂfor (unsigned p = 0; p < buf_cap.g_num_planes(); p++)
>>> ÂÂÂÂÂÂÂ fail_on_test(buf_cap.g_bytesused(p));
>>> ÂÂÂÂfail_on_test(node->streamoff(q.g_type()));
>>> ÂÂÂÂfail_on_test(node->streamoff(m2m_q.g_type()));
>>> }
>>>
>>> The reason for this is because the driver has a limitation where all
>>> capturebuffers must be queued to the driver before STREAMON is effective.
>>> The firmware needs to know in advance what all the buffers are before
>>> starting to decode.
>>> This limitation is enforced via q->min_buffers_needed.
>>> As such, in this compliance codepath, STREAMON is never actually called
>>> driver-side and there is a stall on fail_on_test(buf_cap.dqbuf(node));
>>
>> That's interesting. I will have to look more closely at this.
>>
>>>
>>>
>>> One last detail: V4L2_FMT_FLAG_DYN_RESOLUTION is currently not recognized
>>> by v4l2-compliance, so it was left out for the test. However, it is
>>> present in the patch series.
>>
>> It is definitely recognized by v4l2-compliance.
>>
>>>
>>> The second patch has 3 "Alignment should match open parenthesis" lines
>>> where I preferred to keep them that way.
>>>
>>> Thanks Stanimir for sharing your HDR file creation tools, this was very
>>> helpful :).
>>>
>>> Maxime
>>>
>>> # v4l2-compliance --stream-from-hdr test-25fps.h264.hdr -s250
>>> v4l2-compliance SHA: a162244d47d4bb01d0692da879dce5a070f118e7, 64 bits
>>
>> But this SHA isn't in the v4l-utils repo, so this makes me wonder where you
>> got this repo from.
>>
>
> I am based off the hverkuil/vicodec branch. The SHA I am on is actually 05387265053bc6f9 ("test-media: add vicodec tests"), but it wasn't updated as I found out it requires a new bootstrap to refresh
> the SHA. Maybe some rebasing at some point got rid of a162244d.

Don't use the hverkuil/vicodec branch. Everything there has been merged into the
regular v4l-utils repo some time ago. So just clone git://linuxtv.org/v4l-utils.git
and use that.

Regards,

Hans

>
> I started fresh and ran it again. As you can see, V4L2_FMT_FLAG_DYN_RESOLUTION is still problematic (removing it makes all the checks pass):
>
> -------------------------------
> # v4l2-compliance --stream-from-hdr test-25fps.h264.hdr -s250
> v4l2-compliance SHA: 05387265053bc6f9c8c98e112543adb28ae39cfa, 64 bits
>
> Compliance test for meson-vdec device /dev/video0:
>
> Driver Info:
> ÂÂÂÂDriver nameÂÂÂÂÂ : meson-vdec
> ÂÂÂÂCard typeÂÂÂÂÂÂÂ : Amlogic Video Decoder
> ÂÂÂÂBus infoÂÂÂÂÂÂÂÂ : platform:meson-vdec
> ÂÂÂÂDriver versionÂÂ : 5.4.0
> ÂÂÂÂCapabilitiesÂÂÂÂ : 0x84204000
> ÂÂÂÂÂÂÂ Video Memory-to-Memory Multiplanar
> ÂÂÂÂÂÂÂ Streaming
> ÂÂÂÂÂÂÂ Extended Pix Format
> ÂÂÂÂÂÂÂ Device Capabilities
> ÂÂÂÂDevice CapsÂÂÂÂÂ : 0x04204000
> ÂÂÂÂÂÂÂ Video Memory-to-Memory Multiplanar
> ÂÂÂÂÂÂÂ Streaming
> ÂÂÂÂÂÂÂ Extended Pix Format
> ÂÂÂÂDetected Stateful Decoder
>
> Required ioctls:
> ÂÂÂÂtest VIDIOC_QUERYCAP: OK
>
> Allow for multiple opens:
> ÂÂÂÂtest second /dev/video0 open: OK
> ÂÂÂÂtest VIDIOC_QUERYCAP: OK
> ÂÂÂÂtest VIDIOC_G/S_PRIORITY: OK
> ÂÂÂÂtest for unlimited opens: OK
>
> Debug ioctls:
> ÂÂÂÂtest VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_LOG_STATUS: OK (Not Supported)
>
> Input ioctls:
> ÂÂÂÂtest VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_ENUMAUDIO: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G/S_AUDIO: OK (Not Supported)
> ÂÂÂÂInputs: 0 Audio Inputs: 0 Tuners: 0
>
> Output ioctls:
> ÂÂÂÂtest VIDIOC_G/S_MODULATOR: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G/S_FREQUENCY: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_ENUMAUDOUT: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G/S_AUDOUT: OK (Not Supported)
> ÂÂÂÂOutputs: 0 Audio Outputs: 0 Modulators: 0
>
> Input/Output configuration ioctls:
> ÂÂÂÂtest VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G/S_EDID: OK (Not Supported)
>
> Control ioctls:
> ÂÂÂÂtest VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
> ÂÂÂÂtest VIDIOC_QUERYCTRL: OK
> ÂÂÂÂtest VIDIOC_G/S_CTRL: OK
> ÂÂÂÂtest VIDIOC_G/S/TRY_EXT_CTRLS: OK
> ÂÂÂÂtest VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
> ÂÂÂÂtest VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> ÂÂÂÂStandard Controls: 2 Private Controls: 0
>
> Format ioctls:
> ÂÂÂÂÂÂÂ fail: v4l2-test-formats.cpp(263): unknown flag 00000009 returned
> ÂÂÂÂtest VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL
> ÂÂÂÂtest VIDIOC_G/S_PARM: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G_FBUF: OK (Not Supported)
> ÂÂÂÂÂÂÂ fail: v4l2-test-formats.cpp(457): pixelformat 34363248 (H264) for buftype 10 not reported by ENUM_FMT
> ÂÂÂÂtest VIDIOC_G_FMT: FAIL
> ÂÂÂÂÂÂÂ fail: v4l2-test-formats.cpp(457): pixelformat 34363248 (H264) for buftype 10 not reported by ENUM_FMT
> ÂÂÂÂtest VIDIOC_TRY_FMT: FAIL
> ÂÂÂÂÂÂÂ fail: v4l2-test-formats.cpp(457): pixelformat 3247504d (MPG2) for buftype 10 not reported by ENUM_FMT
> ÂÂÂÂtest VIDIOC_S_FMT: FAIL
> ÂÂÂÂtest VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> ÂÂÂÂtest Cropping: OK (Not Supported)
> ÂÂÂÂtest Composing: OK (Not Supported)
> ÂÂÂÂtest Scaling: OK
>
> Codec ioctls:
> ÂÂÂÂtest VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_G_ENC_INDEX: OK (Not Supported)
> ÂÂÂÂtest VIDIOC_(TRY_)DECODER_CMD: OK
>
> Buffer ioctls:
> ÂÂÂÂtest VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
> ÂÂÂÂtest VIDIOC_EXPBUF: OK
> ÂÂÂÂtest Requests: OK (Not Supported)
>
> Test input 0:
>
> Streaming ioctls:
> ÂÂÂÂtest read/write: OK (Not Supported)
> ÂÂÂÂtest blocking wait: OK
> ÂÂÂÂVideo Capture Multiplanar: Captured 250 buffers
> ÂÂÂÂtest MMAP (select): OK
> ÂÂÂÂVideo Capture Multiplanar: Captured 250 buffers
> ÂÂÂÂtest MMAP (epoll): OK
> ÂÂÂÂtest USERPTR (select): OK (Not Supported)
> ÂÂÂÂtest DMABUF: Cannot test, specify --expbuf-device
>
> Total for meson-vdec device /dev/video0: 49, Succeeded: 45, Failed: 4, Warnings: 0
>
> -------------------------------
>
> Should I be using another branch than vicodec ?
>
>
>> Regards,
>>
>> ÂÂÂÂHans
>>