mbox series

[v7,0/5] Add ZynqMP VCU/Allegro DVT H.264 encoder driver

Message ID 20190528130920.4450-1-m.tretter@pengutronix.de (mailing list archive)
Headers show
Series Add ZynqMP VCU/Allegro DVT H.264 encoder driver | expand

Message

Michael Tretter May 28, 2019, 1:09 p.m. UTC
This is v7 of the Allegro DVT H.264 encoder driver found in the EV
family of the Xilinx ZynqMP platform.

I moved the driver back to staging, because the v4l2 stateful encoder spec is
not finished, yet. Once the spec is finished, this driver shall be tested
against the final v4l2-compliance and moved to mainline again.

Further, I converted the allegro vendor prefix to the new json format in
vendor-prefixes.yaml.

The observed occasional failures in v4l2-compliance in v6 of this series
turned out to be caused by a race condition with v4l2_m2m_poll(). I will send
patches to fix this issue as a separate series.

This is the v4l2-compliance test result using the vicodec branch:

v4l2-compliance SHA: c2ad13e4b7aef9ae160303189c67a91e1775f025, 64 bits

Compliance test for allegro device /dev/video2:

Driver Info:
        Driver name      : allegro
        Card type        : Allegro DVT Video Encoder
        Bus info         : platform:a0009000.video-codec
        Driver version   : 5.2.0
        Capabilities     : 0x84208000
                Video Memory-to-Memory
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04208000
                Video Memory-to-Memory
                Streaming
                Extended Pix Format
        Detected Stateful Encoder

Required ioctls:
        test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
        test second /dev/video2 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
        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: 10 Private Controls: 0

Format ioctls:
        test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
        test VIDIOC_G/S_PARM: OK (Not Supported)
        test VIDIOC_G_FBUF: OK (Not Supported)
        test VIDIOC_G_FMT: OK
        test VIDIOC_TRY_FMT: OK
        test VIDIOC_S_FMT: OK
        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
        test VIDIOC_G_ENC_INDEX: OK (Not Supported)
        test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

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: Captured 60 buffers                
        test MMAP (select): OK
        Video Capture: Captured 60 buffers                
        test MMAP (epoll): OK
        test USERPTR (select): OK (Not Supported)
        test DMABUF: Cannot test, specify --expbuf-device

Total for allegro device /dev/video2: 49, Succeeded: 49, Failed: 0, Warnings: 0

Michael

v6 -> v7:
- move driver back into staging
- convert to json format for vendor-prefixes.yaml
- remove unused allegro_state_get_name()

v5 -> v6:
- drop selection api and document visual size
- drop references to the video decoder
- fix sparse warnings regarding non-static functions
- fix return type of rbsp_read_bit

v4 -> v5:
- add patch for allegro vendor prefix
- move driver out of staging
- implement draining with CMD_STOP and CMD_START
- rewrite NAL unit RBSP generator

v3 -> v4:
- fix checkpatch and compiler warnings
- use v4l2_m2m_buf_copy_metadata to copy buffer metadata
- resolve FIXME regarding channel creation and streamon
- resolve various TODOs
- add mailbox format to firmware info
- add suballocator_size to firmware info
- use struct_size to allocate mcu_msg_push_buffers_internal
- handle *_response messages in a union
- cleanup mcu_send_msg functions
- increase maximum video resolution to 4k
- handle errors when creating a channel
- do not update ctrls after channel is created
- add documentation for nal_h264.h

v2 -> v3:
- add clocks to devicetree bindings
- fix devicetree binding according to review comments on v2
- add missing v4l2 callbacks
- drop unnecessary v4l2 callbacks
- drop debug module parameter poison_capture_buffers
- check firmware size before loading firmware
- rework error handling

v1 -> v2:
- clean up debug log levels
- fix unused variable in allegro_mbox_init
- fix uninitialized variable in allegro_mbox_write
- fix global module parameters
- fix Kconfig dependencies
- return h264 as default codec for mcu
- implement device reset as documented
- document why irq does not wait for clear
- rename ENCODE_ONE_FRM to ENCODE_FRAME
- allow error codes for mcu_channel_id
- move control handler to channel
- add fw version check
- add support for colorspaces
- enable configuration of H.264 levels
- enable configuration of frame size
- enable configuration of bit rate and CPB size
- enable configuration of GOP size
- rework response handling
- fix missing error handling in allegro_h264_write_sps

Hans Verkuil (1):
  videobuf2-v4l2: set last_buffer_dequeued in dqbuf

Michael Tretter (4):
  media: dt-bindings: media: document allegro-dvt bindings
  media: dt-bindings: media: Add vendor prefix for allegro
  [media] allegro: add Allegro DVT video IP core driver
  [media] allegro: add SPS/PPS nal unit writer

 .../devicetree/bindings/media/allegro.txt     |   43 +
 .../devicetree/bindings/vendor-prefixes.yaml  |    2 +
 MAINTAINERS                                   |    7 +
 .../media/common/videobuf2/videobuf2-v4l2.c   |   10 +-
 drivers/staging/media/Kconfig                 |    2 +
 drivers/staging/media/Makefile                |    1 +
 drivers/staging/media/allegro-dvt/Kconfig     |   16 +
 drivers/staging/media/allegro-dvt/Makefile    |    6 +
 drivers/staging/media/allegro-dvt/TODO        |    4 +
 .../staging/media/allegro-dvt/allegro-core.c  | 3032 +++++++++++++++++
 drivers/staging/media/allegro-dvt/nal-h264.c  | 1001 ++++++
 drivers/staging/media/allegro-dvt/nal-h264.h  |  208 ++
 12 files changed, 4327 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/allegro.txt
 create mode 100644 drivers/staging/media/allegro-dvt/Kconfig
 create mode 100644 drivers/staging/media/allegro-dvt/Makefile
 create mode 100644 drivers/staging/media/allegro-dvt/TODO
 create mode 100644 drivers/staging/media/allegro-dvt/allegro-core.c
 create mode 100644 drivers/staging/media/allegro-dvt/nal-h264.c
 create mode 100644 drivers/staging/media/allegro-dvt/nal-h264.h

Comments

Hans Verkuil May 28, 2019, 1:54 p.m. UTC | #1
Hi Michael,

On 5/28/19 3:09 PM, Michael Tretter wrote:
> This is v7 of the Allegro DVT H.264 encoder driver found in the EV
> family of the Xilinx ZynqMP platform.
> 
> I moved the driver back to staging, because the v4l2 stateful encoder spec is
> not finished, yet. Once the spec is finished, this driver shall be tested
> against the final v4l2-compliance and moved to mainline again.
> 
> Further, I converted the allegro vendor prefix to the new json format in
> vendor-prefixes.yaml.
> 
> The observed occasional failures in v4l2-compliance in v6 of this series
> turned out to be caused by a race condition with v4l2_m2m_poll(). I will send
> patches to fix this issue as a separate series.

I'm getting these smatch warnings:

drivers/staging/media/allegro-dvt/allegro-core.c:1849:36: warning: constant 0xffffffff00000000 is so big it is unsigned long
drivers/staging/media/allegro-dvt/nal-h264.c:751: warning: Function parameter or member 'dev' not described in 'nal_h264_write_sps'
drivers/staging/media/allegro-dvt/nal-h264.c:792: warning: Function parameter or member 'dev' not described in 'nal_h264_read_sps'
drivers/staging/media/allegro-dvt/nal-h264.c:842: warning: Function parameter or member 'dev' not described in 'nal_h264_write_pps'
drivers/staging/media/allegro-dvt/nal-h264.c:884: warning: Function parameter or member 'dev' not described in 'nal_h264_read_pps'
drivers/staging/media/allegro-dvt/nal-h264.c:926: warning: Function parameter or member 'dev' not described in 'nal_h264_write_filler'
drivers/staging/media/allegro-dvt/nal-h264.c:969: warning: Function parameter or member 'dev' not described in 'nal_h264_read_filler'

Can you take a look? The nal-h264.c warnings look trivial to fix, the
allegro-core.c warnings looks more interesting.

Regards,

	Hans
Michael Tretter May 28, 2019, 3 p.m. UTC | #2
On Tue, 28 May 2019 15:54:58 +0200, Hans Verkuil wrote:
> Hi Michael,
> 
> On 5/28/19 3:09 PM, Michael Tretter wrote:
> > This is v7 of the Allegro DVT H.264 encoder driver found in the EV
> > family of the Xilinx ZynqMP platform.
> > 
> > I moved the driver back to staging, because the v4l2 stateful encoder spec is
> > not finished, yet. Once the spec is finished, this driver shall be tested
> > against the final v4l2-compliance and moved to mainline again.
> > 
> > Further, I converted the allegro vendor prefix to the new json format in
> > vendor-prefixes.yaml.
> > 
> > The observed occasional failures in v4l2-compliance in v6 of this series
> > turned out to be caused by a race condition with v4l2_m2m_poll(). I will send
> > patches to fix this issue as a separate series.  
> 
> I'm getting these smatch warnings:
> 
> drivers/staging/media/allegro-dvt/allegro-core.c:1849:36: warning: constant 0xffffffff00000000 is so big it is unsigned long

The constant is used to calculate an offset, which is used by the
hardware as offset for addresses in mailbox messages. The hardware
expects a 64 bit value, but the driver calculates the value using a
dma_addr_t, which is fine for 64 bit systems (e.g. ZynqMP), but is a
problem on 32 bit systems.

I am currently working on improving the handling of frame addresses and
make it fit for using the PL-RAM (in the FPGA) instead of the normal
system RAM (PS-RAM). I would fix the warning with that patch set, if
it is OK.

> drivers/staging/media/allegro-dvt/nal-h264.c:751: warning: Function parameter or member 'dev' not described in 'nal_h264_write_sps'
> drivers/staging/media/allegro-dvt/nal-h264.c:792: warning: Function parameter or member 'dev' not described in 'nal_h264_read_sps'
> drivers/staging/media/allegro-dvt/nal-h264.c:842: warning: Function parameter or member 'dev' not described in 'nal_h264_write_pps'
> drivers/staging/media/allegro-dvt/nal-h264.c:884: warning: Function parameter or member 'dev' not described in 'nal_h264_read_pps'
> drivers/staging/media/allegro-dvt/nal-h264.c:926: warning: Function parameter or member 'dev' not described in 'nal_h264_write_filler'
> drivers/staging/media/allegro-dvt/nal-h264.c:969: warning: Function parameter or member 'dev' not described in 'nal_h264_read_filler'

I didn't describe the "struct device *dev" parameter, because it really
doesn't add any value.

Michael

> 
> Can you take a look? The nal-h264.c warnings look trivial to fix, the
> allegro-core.c warnings looks more interesting.
> 
> Regards,
> 
> 	Hans
>
Hans Verkuil May 28, 2019, 3:40 p.m. UTC | #3
On 5/28/19 5:00 PM, Michael Tretter wrote:
> On Tue, 28 May 2019 15:54:58 +0200, Hans Verkuil wrote:
>> Hi Michael,
>>
>> On 5/28/19 3:09 PM, Michael Tretter wrote:
>>> This is v7 of the Allegro DVT H.264 encoder driver found in the EV
>>> family of the Xilinx ZynqMP platform.
>>>
>>> I moved the driver back to staging, because the v4l2 stateful encoder spec is
>>> not finished, yet. Once the spec is finished, this driver shall be tested
>>> against the final v4l2-compliance and moved to mainline again.
>>>
>>> Further, I converted the allegro vendor prefix to the new json format in
>>> vendor-prefixes.yaml.
>>>
>>> The observed occasional failures in v4l2-compliance in v6 of this series
>>> turned out to be caused by a race condition with v4l2_m2m_poll(). I will send
>>> patches to fix this issue as a separate series.  
>>
>> I'm getting these smatch warnings:
>>
>> drivers/staging/media/allegro-dvt/allegro-core.c:1849:36: warning: constant 0xffffffff00000000 is so big it is unsigned long
> 
> The constant is used to calculate an offset, which is used by the
> hardware as offset for addresses in mailbox messages. The hardware
> expects a 64 bit value, but the driver calculates the value using a
> dma_addr_t, which is fine for 64 bit systems (e.g. ZynqMP), but is a
> problem on 32 bit systems.
> 
> I am currently working on improving the handling of frame addresses and
> make it fit for using the PL-RAM (in the FPGA) instead of the normal
> system RAM (PS-RAM). I would fix the warning with that patch set, if
> it is OK.

Sorry, no. I don't want new drivers creating new warnings. It's OK to
do a quick workaround and fix it properly later, though.

Regards,

	Hans

> 
>> drivers/staging/media/allegro-dvt/nal-h264.c:751: warning: Function parameter or member 'dev' not described in 'nal_h264_write_sps'
>> drivers/staging/media/allegro-dvt/nal-h264.c:792: warning: Function parameter or member 'dev' not described in 'nal_h264_read_sps'
>> drivers/staging/media/allegro-dvt/nal-h264.c:842: warning: Function parameter or member 'dev' not described in 'nal_h264_write_pps'
>> drivers/staging/media/allegro-dvt/nal-h264.c:884: warning: Function parameter or member 'dev' not described in 'nal_h264_read_pps'
>> drivers/staging/media/allegro-dvt/nal-h264.c:926: warning: Function parameter or member 'dev' not described in 'nal_h264_write_filler'
>> drivers/staging/media/allegro-dvt/nal-h264.c:969: warning: Function parameter or member 'dev' not described in 'nal_h264_read_filler'
> 
> I didn't describe the "struct device *dev" parameter, because it really
> doesn't add any value.
> 
> Michael
> 
>>
>> Can you take a look? The nal-h264.c warnings look trivial to fix, the
>> allegro-core.c warnings looks more interesting.
>>
>> Regards,
>>
>> 	Hans
>>