Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4L2 Codec/camera fixes #4765

Closed
wants to merge 6 commits into from
Closed

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Dec 13, 2021

@jc-kynesim Fixes for the kernel WARN due to us not returning any buffers that have been queued with mmal-vchiq before the port is enabled.

@6by9 6by9 force-pushed the rpi-5.10.y-codecs branch from 53fd070 to 20e3d07 Compare December 14, 2021 14:51
@6by9
Copy link
Contributor Author

6by9 commented Dec 14, 2021

Hold fire - messed up in last changes.

6by9 added 6 commits December 14, 2021 15:35
MMAL error values were being returned to userspace by some of
the functions. Map them to appropriate Linux ones.

Signed-off-by: Dave Stevenson <[email protected]>
The mmal-vchiq layer allows submission of buffers before the port
is enabled, and it queues them to be sent on port enable.

There isn't a way of returning those buffers, which leads to
videobuf2 complaining of buffers not being returned by drivers.
Add such a call, and reuse the same code in port_disable.

Signed-off-by: Dave Stevenson <[email protected]>
Buffers submitted before VIDIOC_STREAMON would be passed to the
mmal-vchiq layer, but weren't returned to videobuf2 if STREAMON
failed as there wasn't a call into mmal-vchiq to do so.

As there is now a suitable call, ensure buffers are returned.

Signed-off-by: Dave Stevenson <[email protected]>
…ailure

If STREAMON failed, then buffers weren't being returned to videobuf2,
leading to it producing WARNs in the kernel logs.

Return all buffers stored with the V4L2 M2M framework and with
mmal-vchiq should STREAMON fail.

Signed-off-by: Dave Stevenson <[email protected]>
If the encode tunnel failed to enable, then the camera was left
enabled and that caused a failure on a subsequent request to
change format.

Disable the camera on failure.

Signed-off-by: Dave Stevenson <[email protected]>
Replace several instances of if (foo == 0) with if (!foo) and
if (foo != 0) with if (foo)

Signed-off-by: Dave Stevenson <[email protected]>
@6by9 6by9 force-pushed the rpi-5.10.y-codecs branch from 20e3d07 to 4a8ff7e Compare December 14, 2021 15:53
@6by9
Copy link
Contributor Author

6by9 commented Dec 14, 2021

OK, that should work now.

@pelwell
Copy link
Contributor

pelwell commented Dec 14, 2021

I'll wait for some feedback from @jc-kynesim, but LGTM.

@timemaster5
Copy link

Ok, I have tested this code, and the result is no HW decoding for video files. There are no errors reported, but I see only a black square instead of a rendered picture. Don't you know whether a newer GStreamer is required for this to work? I am on 1.16.

@timemaster5
Copy link

I've tried a newer GStreamer 1.18.4, and it is the same. When rendering a web page with an mp4 file included, the only black square is present on the screen. Load and unload of that element is fine without any error or warning. When I play using gst-play, I could see some warnings:

#gst-play-1.0 sample.mp4 
Press 'k' to see a list of keyboard shortcuts.
Now playing /root/html5video/sample.mp4
WARNING No decoder available for type 'audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, level=(string)2, base-profile=(string)lc, profile=(string)lc, codec_data=(buffer)1190, rate=(int)48000, channels=(int)2'.
WARNING debug information: ../gst-plugins-base-1.18.4/gst/playback/gsturidecodebin.c(957): unknown_type_cb (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0
Redistribute latency...
ERROR No valid frames decoded before end of stream for file:///root/html5video/sample.mp4
ERROR debug information: ../gst-plugins-base-1.18.4/gst-libs/gst/video/gstvideodecoder.c(1246): gst_video_decoder_sink_event_default (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/v4l2h264dec:v4l2h264dec0:
no valid frames found
Reached end of play list.

Here is the output of the gst-inspect | grep v4l

video4linux2:  v4l2src: Video (video4linux2) Source
video4linux2:  v4l2sink: Video (video4linux2) Sink
video4linux2:  v4l2radio: Radio (video4linux2) Tuner
video4linux2:  v4l2deviceprovider (GstDeviceProviderFactory)
video4linux2:  v4l2jpegdec: V4L2 JPEG Decoder
video4linux2:  v4l2mpeg4dec: V4L2 MPEG4 Decoder
video4linux2:  v4l2h263dec: V4L2 H263 Decoder
video4linux2:  v4l2h264dec: V4L2 H264 Decoder
video4linux2:  v4l2h264enc: V4L2 H.264 Encoder
video4linux2:  v4l2convert: V4L2 Video Converter
video4linux2:  v4l2video18convert: V4L2 Video Converter

@6by9
Copy link
Contributor Author

6by9 commented Feb 7, 2022

@timemaster5 GStreamer issue may well be the same as raspberrypi/firmware#1673

I'll pull these patches forward to 5.15 as 5.10 is effectively frozen now.

@6by9 6by9 closed this Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants