bcm2835-codec: Return empty buffers to the VPU instead of queueing to vbuf2
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Mon, 28 Mar 2022 10:52:48 +0000 (11:52 +0100)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Mon, 28 Mar 2022 12:22:15 +0000 (13:22 +0100)
commita51218097a20b10e4696fa19bef8bebf3833020c
treec1535334e49b136c07ad831364ebe96ec33ddb2b
parent16c245274a5237b7f338b9fcad1d253e881ca468
bcm2835-codec: Return empty buffers to the VPU instead of queueing to vbuf2

The encoder can skip frames totally should rate control overshoot
the target bitrate too far. In this situation it generates an
output buffer of length 0.
V4L2 treats a buffer of length 0 as an end of stream flag, which is
not appropriate in this case, therefore we can not return that buffer
to the client.

The driver was returning the buffer to videobuf2 in the QUEUED state,
however that buffer was then not dequeued again, so the number of
buffers was reduced each time this happened. In the pathological
case of using GStreamer's videotestsrc in mode 1 for noise, this happens
sufficiently frequently to totally stall the pipeline.

If the port is still enabled then return the buffer straight back to
the VPU rather than to videobuf2.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c