bootlin / libva-v4l2-request

LibVA implementation for the Linux Video4Linux2 Request API
Other
76 stars 59 forks source link

[wip] Rework backend for Linux 5.14 #38

Open fx-chun opened 2 years ago

fx-chun commented 2 years ago

This PR is intended to fix builds against 5.14, as well as get all decoders into a good working state. It currently builds, but only decodes H.264 video in its current state; however, the fix should be relatively simple (detailed in acbdfb1).

Thanks to @wolfallein, @pH5, and everyone else in #35 for much of the initial work and investigation!

nandra commented 2 years ago

@noneucat hi I've tried to use this branch and update locally kernel to 5.14-rc7. I passed -I to 5.14 kernel headers but I'm getting following issue:


include/linux/compiler.h:264:10: fatal error: asm/rwonce.h: No such file or directory
|   264 | #include <asm/rwonce.h>
|       |          ^~~~~~~~~~~~~~
| compilation terminated.
``` any ideas? Thanks.
fx-chun commented 2 years ago

@nandra Hmm, I will have to look at what's going on there. In the meanwhile, if an earlier version is OK, this branch at least builds with 5.13.7.

nandra commented 2 years ago

@noneucat how do you build? Using meson or autotools? How do you pass path to 5.14 kernel headers? Thanks.

nandra commented 2 years ago

I fetched 5.14 kernel sources then run make defconfig ARCH=x86_64 and make headers_install. Then used following to configure : CFLAGS="-I ../headers-5.14/include" ./configure

and after that I run make: and it gives me:

config.c: In function ‘RequestQueryConfigProfiles’:
config.c:121:6: error: ‘V4L2_PIX_FMT_MPEG2_SLICE’ undeclared (first use in this function); did you mean ‘V4L2_PIX_FMT_HEVC_SLICE’?
      V4L2_PIX_FMT_MPEG2_SLICE);
      ^~~~~~~~~~~~~~~~~~~~~~~~
      V4L2_PIX_FMT_HEVC_SLICE
config.c:121:6: note: each undeclared identifier is reported only once for each function it appears in
config.c:129:6: error: ‘V4L2_PIX_FMT_H264_SLICE’ undeclared (first use in this function); did you mean ‘V4L2_PIX_FMT_HEVC_SLICE’?
      V4L2_PIX_FMT_H264_SLICE);
      ^~~~~~~~~~~~~~~~~~~~~~~

Maybe it's still use old kernel headers? Thanks

nandra commented 2 years ago

Seems to be issue with ../headers-51.4/include when use full path it works. Sorry for the noise ;).

nandra commented 2 years ago

@noneucat could there be some relation between this: https://github.com/bootlin/libva-v4l2-request/issues/40 and 5.14 kernel? Did you try libva-v4l2-request with gstreamer? Thanks.

CalcProgrammer1 commented 2 years ago

I started looking into this tonight because I really want VA-API on my PinePhone. I have done some dirty hacks on my fork with a bunch of printf statements all over the place to track down where the issues occur.

When using mpv as documented here:

https://xnux.eu/devices/feature/cedrus-pp.html

the VAAPI seems to work but the video playback is choppy. With VLC, on the other hand, it fails and reverts to "libplacebo" which seems to just be CPU rendering.

I added some printouts and noticed that VLC is calling RequestCreateSurfaces2 with a count of 36 surfaces. It loops through the first 32 buffers just fine, then it errors out. I bypassed the error check just to see if it would initialize successfully in VLC and it does, except with 4 out of 36 buffers being nonexistent the video playback is glitchy and after a second of video or so it turns funny colors and gets garbled. Every once in a while it hits a keyframe and looks good again for a few frames.

I then dug through the Linux source code, tracing back from the create buffers call:

    rc = v4l2_create_buffers(driver_data->video_fd, capture_type,
                 surfaces_count, &index_base);

This calls the VIDIOC_CREATE_BUFS ioctl which seems to ultimately end up here:

https://elixir.bootlin.com/linux/latest/source/drivers/media/common/videobuf2/videobuf2-core.c#L903

The line in question is:

num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers);

VB2_MAX_FRAME is 32. I think q->num_buffers is the number of already-existing buffers, which is zero in this case. This means if VLC requests 36 surfaces, the kernel driver seems to create 32 buffers, causing the buffer query to fail once it hits index 32 in RequestCreateSurfaces2:

        rc = v4l2_query_buffer(driver_data->video_fd, capture_type,
                       index,
                       surface_object->destination_map_lengths,
                       surface_object->destination_map_offsets,
                       video_format->v4l2_buffers_count);

Anyone know why VLC seems to be requesting 36 surfaces? This seems too high from my brief investigation, but I've really never looked into this code before. I looked on the VLC side (VLC git sources):

    VA_CALL(o, vaCreateSurfaces, dpy, va_rt_format,
            fmt->i_visible_width, fmt->i_visible_height,
            instance->render_targets, instance->num_render_targets,
            fourcc_attribs, 1);

This seems to be calling "vaCreateSurfaces" instead of "vaCreateSurfaces2". The argument list seems to match the "2" version of this function. That said, I hacked the vtable to set both "vaCreateSurfaces" and "vaCreateSurfaces2" to point to RequestCreateSurfaces2 and yet it didn't change the behavior, still requesting 36 surfaces and erroring (or displaying corrupt video).

CalcProgrammer1 commented 2 years ago

This is the log with the latest commit on my fork. It "succeeds" because I commented out some of the return value checks that would've returned an error status.

[manjaro@adam-pinephone-manjaro libva-v4l2-request]$ LIBVA_DRIVER_NAME=v4l2_request vlc
VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2)
[0000aaaad8f9f630] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
[0000aaaad903e170] main playlist: playlist is empty
[0000fffef80056a0] gl gl: Initialized libplacebo v3.120.3 (API v120)
libva-v4l2-request: VA_DRIVER_INIT_FUNC() opened path /dev/video0, fd=48
libva-v4l2_request: RequestCreateSurfaces2()
libva-v4l2_request: RequestCreateSurfaces2() set format
libva-v4l2_request: RequestCreateSurfaces2() rt format check ok
libva-v4l2_request: RequestCreateSurfaces2() no video format, finding
libva-v4l2_request: RequestCreateSurfaces2() found fideo format
libva-v4l2_request: RequestCreateSurfaces2() get format ok
libva-v4l2_request: RequestCreateSurfaces2() create buffers ok
libva-v4l2_request: RequestCreateSurfaces2() number of surfaces 36, index base 0
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 0, index: 0
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 1, index: 1
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 2, index: 2
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 3, index: 3
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 4, index: 4
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 5, index: 5
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 6, index: 6
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 7, index: 7
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 8, index: 8
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 9, index: 9
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 10, index: 10
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 11, index: 11
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 12, index: 12
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 13, index: 13
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 14, index: 14
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 15, index: 15
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 16, index: 16
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 17, index: 17
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 18, index: 18
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 19, index: 19
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 20, index: 20
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 21, index: 21
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 22, index: 22
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 23, index: 23
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 24, index: 24
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 25, index: 25
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 26, index: 26
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 27, index: 27
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 28, index: 28
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 29, index: 29
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 30, index: 30
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 31, index: 31
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 32, index: 32
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
v4l2-request: Unable to query buffer: Invalid argument
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 33, index: 33
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
v4l2-request: Unable to query buffer: Invalid argument
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 34, index: 34
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
v4l2-request: Unable to query buffer: Invalid argument
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() looping through surfaces 35, index: 35
libva-v4l2_request: RequestCreateSurfaces2() object heap allocate ok
v4l2-request: Unable to query buffer: Invalid argument
libva-v4l2_request: RequestCreateSurfaces2() query buffer ok
libva-v4l2_request: RequestCreateSurfaces2() success
libva_v4l2_request: RequestCreateConfig() with H264 profile
libva_v4.2_request: RequestCreateConfig() return success
libva_v4l2_request: RequestCreateContext()
libva_v4l2_request: RequestCreateContext() video format ok
libva_v4l2_request: RequestCreateContext() heap allocate ok
libva_v4l2_request: RequestCreateContext() create buffers ok
v4l2-request: Unable to query buffer: Invalid argument
v4l2-request: Unable to query buffer: Invalid argument
v4l2-request: Unable to query buffer: Invalid argument
v4l2-request: Unable to query buffer: Invalid argument
libva_v4l2_request: RequestCreateContext() set stream ok
libva_v4l2_request: RequestCreateContext() set stream again ok
libva_v4l2_request: RequestCreateContext() success
[0000ffff1cdb7ca0] avcodec decoder: Using v4l2-request for hardware decoding
v4l2-request: Unable to queue buffer: Invalid argument
[h264 @ 0xffff1cdcbaf0] Failed to end picture decode issue: 1 (operation failed).
danboid commented 2 years ago

Should your fork also work with 5.15 @noneucat ? Its not building for me with Linux 5.15.23:

make[2]: Entering directory '/home/dan/src/libva-v4l2-request/src'
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.    -I../include -I/usr/include/libdrm  -g -O2 -MT v4l2_request_drv_video_la-config.lo -MD -MP -MF .deps/v4l2_request_drv_video_la-config.Tpo -c -o v4l2_request_drv_video_la-config.lo `test -f 'config.c' || echo './'`config.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../include -I/usr/include/libdrm -g -O2 -MT v4l2_request_drv_video_la-config.lo -MD -MP -MF .deps/v4l2_request_drv_video_la-config.Tpo -c config.c  -fPIC -DPIC -o .libs/v4l2_request_drv_video_la-config.o
In file included from config.c:38:
../include/h264-ctrls.h:52:8: error: redefinition of ‘struct v4l2_ctrl_h264_sps’
   52 | struct v4l2_ctrl_h264_sps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1306:8: note: originally defined here
 1306 | struct v4l2_ctrl_h264_sps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from config.c:38:
../include/h264-ctrls.h:82:8: error: redefinition of ‘struct v4l2_ctrl_h264_pps’
   82 | struct v4l2_ctrl_h264_pps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1362:8: note: originally defined here
 1362 | struct v4l2_ctrl_h264_pps {
      |        ^~~~~~~~~~~~~~~~~~
In file included from config.c:38:
../include/h264-ctrls.h:96:8: error: redefinition of ‘struct v4l2_ctrl_h264_scaling_matrix’
   96 | struct v4l2_ctrl_h264_scaling_matrix {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1394:8: note: originally defined here
 1394 | struct v4l2_ctrl_h264_scaling_matrix {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from config.c:38:
../include/h264-ctrls.h:101:8: error: redefinition of ‘struct v4l2_h264_weight_factors’
  101 | struct v4l2_h264_weight_factors {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1399:8: note: originally defined here
 1399 | struct v4l2_h264_weight_factors {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from config.c:38:
../include/h264-ctrls.h:122: warning: "V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED" redefined
  122 | #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED 0x04
      | 
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1436: note: this is the location of the previous definition
 1436 | #define V4L2_H264_SLICE_FLAG_DIRECT_SPATIAL_MV_PRED 0x01
      | 
In file included from config.c:38:
../include/h264-ctrls.h:123: warning: "V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH" redefined
  123 | #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH  0x08
      | 
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1437: note: this is the location of the previous definition
 1437 | #define V4L2_H264_SLICE_FLAG_SP_FOR_SWITCH  0x02
      | 
In file included from config.c:38:
../include/h264-ctrls.h:125:8: error: redefinition of ‘struct v4l2_ctrl_h264_slice_params’
  125 | struct v4l2_ctrl_h264_slice_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1497:8: note: originally defined here
 1497 | struct v4l2_ctrl_h264_slice_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from config.c:38:
../include/h264-ctrls.h:173:8: error: redefinition of ‘struct v4l2_h264_dpb_entry’
  173 | struct v4l2_h264_dpb_entry {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1542:8: note: originally defined here
 1542 | struct v4l2_h264_dpb_entry {
      |        ^~~~~~~~~~~~~~~~~~~
In file included from config.c:38:
../include/h264-ctrls.h:185:8: error: redefinition of ‘struct v4l2_ctrl_h264_decode_params’
  185 | struct v4l2_ctrl_h264_decode_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/videodev2.h:65,
                 from request.h:37,
                 from config.h:33,
                 from config.c:27:
/usr/include/linux/v4l2-controls.h:1579:8: note: originally defined here
 1579 | struct v4l2_ctrl_h264_decode_params {
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:624: v4l2_request_drv_video_la-config.lo] Error 1
make[2]: Leaving directory '/home/dan/src/libva-v4l2-request/src'
make[1]: *** [Makefile:444: all] Error 2
make[1]: Leaving directory '/home/dan/src/libva-v4l2-request/src'
make: *** [Makefile:418: all-recursive] Error 1
nnb1972 commented 2 years ago

VB2_MAX_FRAME is 32. I think q->num_buffers is the number of already-existing buffers, which is zero in this case. This means if VLC requests 36 surfaces, the kernel driver seems to create 32 buffers, causing the buffer query to fail once it hits index 32 in RequestCreateSurfaces2

In the VIDIOC_CREATE_BUFS ioctl description: When the ioctl is called with a pointer to this structure the driver will attempt to allocate up to the requested number of buffers and store the actual number allocated and the starting index in the count and the index fields respectively. On return count can be smaller than the number requested.

So v4l2_create_buffers return success, but it create only 32 buffers instead of 36. I think we need that v4l2_create_buffers also return the value of the buffers_count.

shlyakpavel commented 2 years ago

It doesn't work with Linux 5.17.5-2 any more :(

Zapeth commented 1 year ago

I tried to update just the mpeg2 portions of the code to 5.15+ headers (stubbing out h264 and hevc) since it seemed fairly straightforward, but maybe I was a bit too optimistic because it doesn't seem to work with mpv, this is what I get:

$ export LIBVA_DRIVER_NAME=v4l2_request
$ export LIBVA_V4L2_REQUEST_VIDEO_PATH=/dev/video0
$ export LIBVA_V4L2_REQUEST_MEDIA_PATH=/dev/media0
$ mpv -v --hwdec=vaapi-copy --hwdec-codecs=mpeg2video --log-file=./mpv.log big_buck_bunny_480p_MPEG2_MP2_25fps_1800K.MPG
...
[   1.479][v][vd] Codec list:
[   1.480][v][vd]     mpeg2video - MPEG-2 video
[   1.480][v][vd]     mpegvideo (mpeg2video) - MPEG-1 video
[   1.480][v][vd]     mpeg2_v4l2m2m (mpeg2video) - V4L2 mem2mem MPEG2 decoder wrapper
[   1.480][v][vd] Opening decoder mpeg2video
[   1.480][v][vd] Looking at hwdec mpeg2video-vaapi-copy...
[   1.480][d][vaapi] libva: VA-API version 1.14.0
[   1.480][d][vaapi] libva: User environment variable requested driver 'v4l2_request'
[   1.480][d][vaapi] libva: Trying to open /home/pinephone/libva-v4l2-request/build/src//v4l2_request_drv_video.so
[   1.481][d][vaapi] libva: Found init function __vaDriverInit_1_14
[   1.481][d][vaapi] libva: va_openDriver() returns 0
[   1.481][v][vaapi] Initialized VAAPI: version 1.14
[   1.481][d][ffmpeg] AVHWDeviceContext: VAAPI driver: v4l2-request.
[   1.481][d][ffmpeg] AVHWDeviceContext: Driver not found in known nonstandard list, using standard behaviour.
[   1.482][v][vd] Trying hardware decoding via mpeg2video-vaapi-copy.
[   1.482][v][vd] Selected codec: mpeg2video (MPEG-2 video)
[   1.482][v][vf] User filter list:
[   1.482][v][vf]   (empty)
[   1.508][v][ad] Codec list:
[   1.509][v][ad]     mp2 - MP2 (MPEG audio layer 2)
[   1.509][v][ad]     mp2float (mp2) - MP2 (MPEG audio layer 2)
[   1.509][v][ad] Opening decoder mp2
[   1.510][v][ad] Requesting 1 threads for decoding.
[   1.510][v][ad] Selected codec: mp2 (MP2 (MPEG audio layer 2))
[   1.510][v][af] User filter list:
[   1.510][v][af]   (empty)
[   1.510][v][cplayer] Starting playback...
[   1.517][v][af] [in] 44100Hz stereo 2ch s16p
[   1.518][v][af] [userspeed] 44100Hz stereo 2ch s16p
[   1.518][v][af] [userspeed] (disabled)
[   1.518][v][af] [convert] 44100Hz stereo 2ch s16p
[   1.518][v][vd] Pixel formats supported by decoder: vdpau vaapi yuv420p
[   1.518][v][vd] Codec profile: Main (0x4)
[   1.518][v][vd] Requesting pixfmt 'vaapi' from decoder.
[   1.552][e][ffmpeg/video] mpeg2video: Failed to create decode context: 1 (operation failed).
[   1.552][e][ffmpeg/video] mpeg2video: Failed setup for format vaapi: hwaccel initialisation returned error.
[   1.552][v][vd] Pixel formats supported by decoder: vdpau yuv420p yuv420p
[   1.552][v][vd] Codec profile: Main (0x4)
[   1.552][v][vd] Requesting pixfmt 'yuv420p' from decoder.
[   1.596][v][vd] Falling back to software decoding.

~Does mpv/ffmpeg need to be patched as well to support mpeg2 hw decoding, or how could this be further debugged?~ I found additional output from the v4l2-request driver which wasn't included in the mpv log: v4l2-request: Unable to set format for type 2: Resource busy

This apparently originates from the v4l2_set_format function, but I'm not sure what Resource busy indicates. Is some other application preventing access to the device, or is there some additional system configuration required?

shlyakpavel commented 1 year ago

@Zapeth is there any chance you're using selinux in enforce mode?

Zapeth commented 1 year ago

Not to my knowledge, no (I'm using a Pinephone with plasma-mobile on postmarketOS stable).

Though a get format request seems to work, ioctl(video_fd, VIDIOC_G_FMT, &format); doesn't return an error (inserted just before the linked line), so I'm not sure why it says Resource busy. I would assume the error to be EINVAL if there are issues with the requested format?

Zapeth commented 1 year ago

After some more troubleshooting I figured out what the issue is. Unfortunately I don't think its something that can be fixed in just the libva-v4l2-request code. but I'll write it here anyways in case someone wants to move this forward:

The current code of the cedrus driver in the kernel has this constraint: https://github.com/torvalds/linux/commit/8c608272ec3e6926ae2e258e74e84777d932ddd6#diff-79ca51b85b54b005649c31a334cc85c637aeea052cfca9cbf673869b6e66bdc2R317-R324

As written in the marked comment, this basically means that format changes to V4L2_BUF_TYPE_VIDEO_OUTPUT buffers are not allowed if buffers of type V4L2_BUF_TYPE_VIDEO_CAPTURE already exist, otherwise EBUSY is returned.

And this is exactly what happens on the mpv->ffmpeg side of things here, which boils down to the following calls to the v4l2-request backend: 1) RequestSurfaces2: set format for V4L2_BUF_TYPE_VIDEO_CAPTURE buffer types and create them 2) RequestCreateConfig 3) RequestCreateContext: set format for V4L2_BUF_TYPE_VIDEO_OUTPUT buffer types and create them <- this fails

As I said, I don't think this is fixable in just the libva-v4l2-request code (unless you hardcode the OUTPUT format, which was done in this PR). but if someone wants to pursue this further I'd be happy to give more information.

karu2003 commented 1 year ago

it works with the new kernel 5.15 ...6.2??????

kwizart commented 5 months ago

@Zapeth About mpeg2, do you have ffmpeg with v4l2-request support ? See also https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=2898 I don't know if there is a newer serie....

On my side, I've managed libva-v4l2-request to build by:



- Removing all mpeg2-ctrls.h hevc-ctrls.h to avoid function redefinition.
- Disabling h265.c from building.

No runtime tests yet....
Saketeas commented 2 months ago

@kwizart Hello, I used your modified lipva-v4l2-request, successfully compiled and installed in kernel version 6.6 I use the command: mpv -v --hwdec=vaapi

After execution, a kernel crash occurred

The only picture I was able to capture before the crash was as follows: 企业微信截图_17156668551211

The log seems to say run hardware decoding, but I don't know how to fix the crash

This is the message printed by the serial port at the time of the crash, which looks like a memory crash


[ 1584.292769] Mem abort info:
[ 1584.295565]   ESR = 0x0000000096000004
[ 1584.299310]   EC = 0x25: DABT (current EL), IL = 32 bits
[ 1584.304617]   SET = 0, FnV = 0
[ 1584.307668]   EA = 0, S1PTW = 0
[ 1584.310805]   FSC = 0x04: level 0 translation fault
[ 1584.315676] Data abort info:
[ 1584.318553]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[ 1584.324032]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 1584.329077]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 1584.334387] user pgtable: 4k pages, 48-bit VAs, pgdp=00000000459f6000
[ 1584.340821] [0000000000000000] pgd=0000000000000000, p4d=0000000000000000
[ 1584.347612] Internal error: Oops: 0000000096000004 [#1] SMP
[ 1584.353184] Modules linked in: overlay rfcomm algif_hash algif_skcipher af_alg bnep hci_uart btqca btrtl btintel btbcm bluetooth ecdh_generic ecc sprdwl_ng sunxi_addr cfg80211 sunrpc uinput lz4hc lz4 zram sunxi_cedrus(C) snd_soc_hdmi_codec v4l2_mem2mem polyval_ce videobuf2_dma_contig polyval_generic videobuf2_memops videobuf2_v4l2 videodev binfmt_misc videobuf2_common mc panfrost gpu_sched dump_reg drm_shmem_helper cpufreq_dt joydev sprdbt_tty uwe5622_bsp_sdio rfkill fuse dm_mod dw_hdmi_i2s_audio motorcomm dw_hdmi_cec dwmac_sun8i mdio_mux display_connector
[ 1584.402534] CPU: 3 PID: 3683 Comm: bash Tainted: G         C         6.6.30-current-sunxi64 #9
[ 1584.411142] Hardware name: OrangePi Zero3 (DT)
[ 1584.415585] pstate: a00000c5 (NzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 1584.422546] pc : __wake_up_common+0x5c/0x17c
[ 1584.426831] lr : __wake_up_common_lock+0x98/0x11c
[ 1584.431539] sp : ffff8000861f3a20
[ 1584.434853] x29: ffff8000861f3a20 x28: 0000000000000008 x27: 0000000000000000
[ 1584.441987] x26: 0000000000000000 x25: 0000000000000001 x24: 0000000000000000
[ 1584.449122] x23: 0000000000000000 x22: ffff8000861f3af0 x21: ffff0000050bc268
[ 1584.456258] x20: 0000000000000001 x19: ffff0000050bc260 x18: ffff8000861f3af8
[ 1584.463395] x17: 0000000000000000 x16: ffff800080f55448 x15: 0000ffffa8b8c000
[ 1584.470531] x14: 000000000000000f x13: 1fffe000043da321 x12: ffff8000861f3af8
[ 1584.477669] x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000
[ 1584.484806] x8 : 0000000000400040 x7 : 0000000000000000 x6 : ffffffffffffffe8
[ 1584.491941] x5 : ffff8000861f3af0 x4 : 0000000000000000 x3 : 0000000000000000
[ 1584.499076] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
[ 1584.506213] Call trace:
[ 1584.508660]  __wake_up_common+0x5c/0x17c
[ 1584.512590]  __wake_up_common_lock+0x98/0x11c
[ 1584.516953]  __wake_up+0x18/0x24
[ 1584.520186]  pipe_release+0x7c/0x168
[ 1584.523765]  __fput+0xbc/0x27c
[ 1584.526822]  ____fput+0x10/0x1c
[ 1584.529966]  task_work_run+0x88/0x114
[ 1584.533631]  do_exit+0x2d8/0x910
[ 1584.536865]  do_group_exit+0x34/0x90
[ 1584.540440]  __kill_pgrp_info+0x0/0x134
[ 1584.544279]  do_notify_resume+0x178/0x1358
[ 1584.548382]  el0_svc+0xe4/0xf4
[ 1584.551443]  el0t_64_sync_handler+0x13c/0x158
[ 1584.555802]  el0t_64_sync+0x190/0x194
[ 1584.559471] Code: 54000740 a90153f3 2a0203f7 52800018 (f9400cd3)
[ 1584.565563] ---[ end trace 0000000000000000 ]---
[ 1584.570178] note: bash[3683] exited with irqs disabled
[ 1584.575445] Fixing recursive fault but reboot is needed!

Message from syslogd@orangepizero3 at May 14 03:57:49 ...
 kernel:[ 1584.347612] Internal error: Oops: 0000000096000004 [#1] SMP

Message from syslogd@orangepizero3 at May 14 03:57:49 ...
 kernel:[ 1584.559471] Code: 54000740 a90153f3 2a0203f7 52800018 (f9400cd3)
[ 1590.002320] sprdwl:[WIFI_CMD_POWER_SAVE]timeout
[ 1590.006884] sprdwl:ctx_id:0 cmd: WIFI_CMD_POWER_SAVE[5] rsp timeout (mstime = 1586940), num=2298
[ 1590.015695] sprdwl:host wakeup fw cmd failed, ret=-1
[ 1590.020663] sprdwl:sprdwl_atcmd_assert ctx_id:0, cmd_id:5, reason:3, cp_asserted:0
[ 1590.028235] WCN: stop_loopcheck
[ 1590.031384] WCN: mdbg_assert_interface:[CMD] WIFI_CMD_POWER_SAVE, [REASON] CMD_RSP_TIMEOUT_ERROR
[ 1590.040161] sdiohal:carddump flag set[1]
[ 1590.044175] sdiohal:disable rx int for dump
[ 1590.048362] sdiohal:chn8 tx push old, cmdid=5, mstime=1583858, record_time=1583858
[ 1590.055935] chn8 tx push old: 00 00 00 00 10 05 0e 00 f2 2a 18 00 00 00 00 00  .........*......
[ 1590.064628] sdiohal:chn8 tx denq old, cmdid=5, mstime=1583246, record_time=1583246
[ 1590.072194] chn8 tx denq old: 00 07 00 08 10 05 0e 00 8e 28 18 00 00 00 00 00  .........(......
[ 1590.080885] sdiohal:chn22 rx dispatch old, cmdid=5, mstime=1583246, record_time=1583252
[ 1590.088887] chn22 rx dispatch old: bf 06 00 0a 00 05 0d 00 8e 28 18 00 00 79 00 00  .........(...y..
[ 1590.098010] sdiohal:chn8 tx push new, cmdid=5, mstime=1586940, record_time=1586940
[ 1590.105576] chn8 tx push new: 00 00 00 00 10 05 0e 00 fc 36 18 00 00 00 00 00  .........6......
[ 1590.114266] sdiohal:chn8 tx denq new, cmdid=5, mstime=1583858, record_time=1583858
[ 1590.121831] chn8 tx denq new: 00 07 00 08 10 05 0e 00 f2 2a 18 00 00 00 00 00  .........*......
[ 1590.130520] sdiohal:chn22 rx dispatch new, cmdid=5, mstime=1583858, record_time=1583858
[ 1590.138520] chn22 rx dispatch new: 3f 06 00 0a 00 05 0c 00 f2 2a 18 00 00 7d 00 00  ?........*...}..
[ 1590.147737] WCN: dap_sel_btwf_lite DJTAG_DAP_SEL:0x0
[ 1590.152774] WCN: dap_sel_btwf_lite DJTAG_DAP_SEL:0x2
[ 1590.157807] WCN: dap_sel_btwf_lite 2:DJTAG_DAP_SEL:0x2
[ 1590.163020] WCN: apb_eb_lite APB_EB:0x463
[ 1590.167096] WCN: apb_eb_lite APB_EB:0x463
[ 1590.171181] WCN: apb_eb_lite 2:APB_EB:0x463
[ 1590.175424] WCN: check_dap_is_ok :0x24770011
[ 1590.179696] WCN: btwf dap is ready
[ 1590.183712] WCN: read_core_reg ****R[0]: 0x0****
[ 1590.188687] WCN: read_core_reg ****R[1]: 0x0****
[ 1590.193616] WCN: read_core_reg ****R[2]: 0x8001000c****
[ 1590.199153] WCN: read_core_reg ****R[3]: 0x0****
[ 1590.204081] WCN: read_core_reg ****R[4]: 0x4083c000****
[ 1590.209616] WCN: read_core_reg ****R[5]: 0x1e694c****
[ 1590.214977] WCN: read_core_reg ****R[6]: 0x3****
[ 1590.219906] WCN: read_core_reg ****R[7]: 0x0****
[ 1590.224834] WCN: read_core_reg ****R[8]: 0x40130000****
[ 1590.230379] WCN: read_core_reg ****R[9]: 0x10d69c****
[ 1590.235734] WCN: read_core_reg ****R[10]: 0x40088000****
[ 1590.241389] WCN: read_core_reg ****R[11]: 0x1e6954****
[ 1590.246864] WCN: read_core_reg ****R[12]: 0x11fc64****
[ 1590.252350] WCN: read_core_reg ****R[13]: 0x1a0ef8****
[ 1590.257796] WCN: read_core_reg ****R[14]: 0x1e605b****
[ 1590.263254] WCN: read_core_reg ****R[15]: 0x1e67ee****
[ 1590.268702] WCN: read_core_reg ****R[16]: 0x6100000b****
[ 1590.274332] WCN: read_core_reg ****R[17]: 0x1a0ef8****
[ 1590.279777] WCN: read_core_reg ****R[18]: 0x117bd8****
[ 1590.284922] WCN: ------------[ ARM REG ]------------
[ 1590.289885] WCN: [R0 ] =     0x00000000
[ 1590.293461] WCN: [R1 ] =     0x00000000
[ 1590.297037] WCN: [R2 ] =     0x8001000c
[ 1590.300612] WCN: [R3 ] =     0x00000000
[ 1590.304187] WCN: [R4 ] =     0x4083c000
[ 1590.307763] WCN: [R5 ] =     0x001e694c
[ 1590.311338] WCN: [R6 ] =     0x00000003
[ 1590.314913] WCN: [R7 ] =     0x00000000
[ 1590.318488] WCN: [R8 ] =     0x40130000
[ 1590.322058] WCN: [R9 ] =     0x0010d69c
[ 1590.325633] WCN: [R10] =     0x40088000
[ 1590.329208] WCN: [R11] =     0x001e6954
[ 1590.332783] WCN: [R12] =     0x0011fc64
[ 1590.336358] WCN: [R13] =     0x001a0ef8
[ 1590.339933] WCN: [R14] =     0x001e605b
[ 1590.343508] WCN: [R15] =     0x001e67ee
[ 1590.347083] WCN: [PSR] =     0x6100000b
[ 1590.350658] WCN: [MSP] =     0x001a0ef8
[ 1590.354227] WCN: [PSP] =     0x00117bd8
[ 1590.357802] WCN: ------------[ ARM END ]------------
[ 1590.362880] WCN: marlin_hold_cpu reset reg val:0x0
[ 1590.367781] WCN: CP DCACHE DISENABLE
[ 1590.371362] WCN: section[0] [0x100000 0x1e73ff 0x240]
[ 1590.376414] WCN: section[1] [0x40880000 0x40880053 0xe7640]
[ 1590.381984] WCN: section[2] [0x4083c000 0x4083c353 0xe7694]
[ 1590.387559] WCN: section[3] [0x40130000 0x401303ff 0xe79e8]
[ 1590.393130] WCN: section[4] [0x40088000 0x4008828b 0xe7de8]
[ 1590.398701] WCN: section[5] [0x40844200 0x40844343 0xe8074]
[ 1590.404271] WCN: section[6] [0x40844000 0x40844047 0xe81b8]
[ 1590.409842] WCN: section[7] [0x40140000 0x4014ffff 0xe8200]
[ 1590.415412] WCN: section[8] [0x400f0000 0x400f011f 0xf8200]
[ 1590.420982] WCN: section[9] [0x400f1000 0x400fe0ff 0xf8320]
[ 1590.426553] WCN: section[10] [0x40300000 0x4034a7ff 0x105420]
[ 1590.432296] WCN: section[11] [0x400a0000 0x400a0057 0x14fc20]
[ 1590.438039] WCN: section[12] [0x400b0000 0x400b0387 0x14fc78]
[ 1590.443782] WCN: section[13] [0x400b1000 0x400b1153 0x150000]
[ 1590.449525] WCN: section[14] [0x400b2000 0x400b2a8b 0x150154]
[ 1590.455269] WCN: section[15] [0x400b3000 0x400b30af 0x150be0]
[ 1590.461012] WCN: section[16] [0x400b4000 0x400b4a6f 0x150c90]
[ 1590.466755] WCN: section[17] [0x400b7000 0x400b7617 0x151700]
[ 1590.472499] WCN: section[18] [0x40240000 0x402408f3 0x151d18]
[ 1590.478242] WCN: section[19] [0x40246000 0x40246737 0x15260c]
[ 1590.483985] WCN: section[20] [0x40248000 0x4024809f 0x152d44]
[ 1590.489729] WCN: section[21] [0x4024a000 0x4024a21b 0x152de4]
[ 1590.495472] WCN: section[22] [0x4024f000 0x4024f30f 0x153000]
[ 1590.501215] WCN: section[23] [0x40200000 0x402001ff 0x153310]
[ 1590.506958] WCN: section[24] [0x40204000 0x402041ff 0x153510]
[ 1590.512701] WCN: section[25] [0x40208000 0x402092a3 0x153710]
[ 1590.518444] WCN: section[26] [0x40200c00 0x4020c343 0x1549b4]
[ 1590.524191] WCN: section[27] [0x40210000 0x40212fff 0x1600f8]
[ 1590.529935] WCN: section[28] [0x40214000 0x40216fff 0x1630f8]
[ 1590.535679] WCN: section[29] [0x40218000 0x402182cf 0x1660f8]
[ 1590.541422] WCN: section[30] [0x4021c000 0x4021c5bf 0x1663c8]
[ 1590.547165] WCN: section[31] [0x40241000 0x402413ff 0x166988]
[ 1590.552908] WCN: section[32] [0x40242000 0x402423ff 0x166d88]
[ 1590.558651] WCN: dumpmem_rx_callback
[ 1590.564429] WCN: dumpmem_rx_callback
[ 1590.568017] WCN_ERR: dumpmem_rx_callback open  error no.-21 retry:1
[ 1590.576462] WCN: dumpmem_rx_callback
[ 1590.582202] WCN: dumpmem_rx_callback
[ 1590.587946] WCN: dumpmem_rx_callback
[ 1590.593681] WCN: dumpmem_rx_callback
[ 1590.599460] WCN: dumpmem_rx_callback
[ 1590.605198] WCN: dumpmem_rx_callback
[ 1590.610940] WCN: dumpmem_rx_callback
[ 1590.616675] WCN: dumpmem_rx_callback
[ 1590.622461] WCN: dumpmem_rx_callback
[ 1590.628251] WCN: dumpmem_rx_callback
[ 1590.634020] WCN: dumpmem_rx_callback
[ 1590.639917] WCN: dumpmem_rx_callback
[ 1590.645695] WCN: dumpmem_rx_callback
[ 1590.651477] WCN: dumpmem_rx_callback
[ 1590.657247] WCN: dumpmem_rx_callback
[ 1590.663035] WCN: dumpmem_rx_callback
[ 1590.668808] WCN: dumpmem_rx_callback
[ 1590.674604] WCN: dumpmem_rx_callback
[ 1590.680389] WCN: dumpmem_rx_callback
[ 1590.686162] WCN: dumpmem_rx_callback
[ 1590.691946] WCN: dumpmem_rx_callback
[ 1590.697717] WCN: dumpmem_rx_callback
[ 1590.703512] WCN: dumpmem_rx_callback
[ 1590.709286] WCN: dumpmem_rx_callback
[ 1590.715069] WCN: dumpmem_rx_callback
[ 1590.720840] WCN: dumpmem_rx_callback
[ 1590.726621] WCN: dumpmem_rx_callback
[ 1590.732192] WCN: dumpmem_rx_callback
[ 1590.735772] WCN: mdbg dump ram 947200 ok!
[ 1590.739853] WCN: dumpmem_rx_callback
[ 1590.743438] WCN: mdbg dump aon ahb 84 ok!
[ 1590.747621] WCN: dumpmem_rx_callback
[ 1590.751198] WCN: mdbg dump aon_apb 852 ok!
[ 1590.755424] WCN: dumpmem_rx_callback
[ 1590.759002] WCN: mdbg dump btwfahb 1024 ok!
[ 1590.763333] WCN: dumpmem_rx_callback
[ 1590.766912] WCN: mdbg dump btwfapb 652 ok!
[ 1590.771107] WCN: dumpmem_rx_callback
[ 1590.774686] WCN: mdbg dump aonclk 324 ok!
[ 1590.778769] WCN: dumpmem_rx_callback
[ 1590.782348] WCN: mdbg dump predivclk 72 ok!
[ 1590.789368] WCN: dumpmem_rx_callback
[ 1590.795759] WCN: dumpmem_rx_callback
[ 1590.799336] WCN: mdbg dump sdio 65536 ok!
[ 1590.803418] WCN: enable_cp_pll rd CLK_CTRL0 reg val:0x2fdf
[ 1590.809169] WCN: enable_cp_pll enable CLK_CTRL0 val:0x2fdf
[ 1590.814972] WCN: check_wifi_power_domain_ison CHIP_SLP reg val:0x44b0
[ 1590.821412] WCN: WIFI MAC have power down
[ 1590.826030] WCN: check_wifi_power_domain_ison WIFI_ENABLE reg val:0xa023
[ 1590.832730] WCN: WIFI_en and wifi_mac_en is disable
[ 1590.837809] WCN: dumpmem_rx_callback
[ 1590.847029] WCN: dumpmem_rx_callback
[ 1590.854192] WCN: dumpmem_rx_callback
[ 1590.859822] WCN: dumpmem_rx_callback
[ 1590.865500] WCN: dumpmem_rx_callback
[ 1590.871169] WCN: dumpmem_rx_callback
[ 1590.876900] WCN: dumpmem_rx_callback
[ 1590.882678] WCN: dumpmem_rx_callback
[ 1590.888432] WCN: dumpmem_rx_callback
[ 1590.894174] WCN: dumpmem_rx_callback
[ 1590.899932] WCN: dumpmem_rx_callback
[ 1590.905678] WCN: dumpmem_rx_callback
[ 1590.911429] WCN: dumpmem_rx_callback
[ 1590.917167] WCN: dumpmem_rx_callback
[ 1590.920749] WCN: mdbg dump wifi 360448 ok!
[ 1590.924936] WCN: dumpmem_rx_callback
[ 1590.928520] WCN: dump cp reg section[11] ok!
[ 1590.932972] WCN: dumpmem_rx_callback
[ 1590.936555] WCN: dump cp reg section[12] ok!
[ 1590.940936] WCN: dumpmem_rx_callback
[ 1590.944519] WCN: dump cp reg section[13] ok!
[ 1590.949173] WCN: dumpmem_rx_callback
[ 1590.952757] WCN: dump cp reg section[14] ok!
[ 1590.957121] WCN: dumpmem_rx_callback
[ 1590.960705] WCN: dump cp reg section[15] ok!
[ 1590.965356] WCN: dumpmem_rx_callback
[ 1590.968939] WCN: dump cp reg section[16] ok!
[ 1590.973467] WCN: dumpmem_rx_callback
[ 1590.977050] WCN: dump cp reg section[17] ok!
[ 1590.981766] WCN: dumpmem_rx_callback
[ 1590.985349] WCN: mdbg dump fm 2748 ok!
[ 1590.989363] WCN: dumpmem_rx_callback
[ 1590.992947] WCN: mdbg dump btacc 2292 ok!
[ 1590.997179] WCN: dumpmem_rx_callback
[ 1591.000762] WCN: mdbg dump btjal 1848 ok!
[ 1591.004859] WCN: dumpmem_rx_callback
[ 1591.008443] WCN: mdbg dump bthab 160 ok!
[ 1591.012496] WCN: dumpmem_rx_callback
[ 1591.016080] WCN: mdbg dump btlejal 540 ok!
[ 1591.355810] sunxi-mmc 4021000.mmc: data error, sending stop command
[ 1591.362097] sdiohal err:dt read fail ret:-110, system_addr=0x4024f000
[ 1591.368551] sdiohal:sdio dump_aon_reg entry
[ 1591.372764] sdiohal:pmu sdio status:[0x140]:0x6b
[ 1591.377411] sdiohal:pmu sdio status:[0x141]:0x3c
[ 1591.382050] sdiohal:pmu sdio status:[0x142]:0xe1
[ 1591.386695] sdiohal:pmu sdio status:[0x143]:0x0
[ 1591.391247] sdiohal:pmu sdio status:[0x144]:0x0
[ 1591.395805] sdiohal:pmu sdio status:[0x145]:0x0
[ 1591.400356] sdiohal:pmu sdio status:[0x146]:0x0
[ 1591.404914] sdiohal:pmu sdio status:[0x147]:0x0
[ 1591.409465] sdiohal:pmu sdio status:[0x148]:0x60
[ 1591.414109] sdiohal:pmu sdio status:[0x149]:0x0
[ 1591.418661] sdiohal:pmu sdio status:[0x14a]:0x0
[ 1591.423217] sdiohal:pmu sdio status:[0x14b]:0x0
[ 1591.427769] sdiohal:pmu sdio status:[0x14c]:0x0
[ 1591.432327] sdiohal:pmu sdio status:[0x14d]:0x0
[ 1591.436878] sdiohal:pmu sdio status:[0x14e]:0x0
[ 1591.441435] sdiohal:pmu sdio status:[0x14f]:0x0
[ 1591.446039] sdiohal:cm4d haddr 0:[0x144]:0x0
[ 1591.450339] sdiohal:cm4d haddr 0:[0x145]:0x0
[ 1591.454630] sdiohal:cm4d haddr 0:[0x146]:0x0
[ 1591.458929] sdiohal:cm4d haddr 0:[0x147]:0x0
[ 1591.463272] sdiohal:cm4i haddr 1:[0x144]:0x0
[ 1591.467569] sdiohal:cm4i haddr 1:[0x145]:0x0
[ 1591.471861] sdiohal:cm4i haddr 1:[0x146]:0x0
[ 1591.476159] sdiohal:cm4i haddr 1:[0x147]:0x0
[ 1591.480502] sdiohal:cm4s haddr 2:[0x144]:0x0
[ 1591.484801] sdiohal:cm4s haddr 2:[0x145]:0x0
[ 1591.489092] sdiohal:cm4s haddr 2:[0x146]:0x0
[ 1591.493382] sdiohal:cm4s haddr 2:[0x147]:0x0
[ 1591.497724] sdiohal:dmaw haddr 3:[0x144]:0x0
[ 1591.502013] sdiohal:dmaw haddr 3:[0x145]:0x0
[ 1591.506306] sdiohal:dmaw haddr 3:[0x146]:0x0
[ 1591.510596] sdiohal:dmaw haddr 3:[0x147]:0x0
[ 1591.514941] sdiohal:dmar haddr 4:[0x144]:0x0
[ 1591.519239] sdiohal:dmar haddr 4:[0x145]:0x0
[ 1591.523550] sdiohal:dmar haddr 4:[0x146]:0x0
[ 1591.527846] sdiohal:dmar haddr 4:[0x147]:0x0
[ 1591.532192] sdiohal:aon_to_ahb haddr 5:[0x144]:0x0
[ 1591.537013] sdiohal:aon_to_ahb haddr 5:[0x145]:0x0
[ 1591.541829] sdiohal:aon_to_ahb haddr 5:[0x146]:0x0
[ 1591.546643] sdiohal:aon_to_ahb haddr 5:[0x147]:0x0
[ 1591.551506] sdiohal:axi_to_ahb haddr 6:[0x144]:0x4
[ 1591.556324] sdiohal:axi_to_ahb haddr 6:[0x145]:0xf0
[ 1591.561223] sdiohal:axi_to_ahb haddr 6:[0x146]:0x24
[ 1591.566128] sdiohal:axi_to_ahb haddr 6:[0x147]:0x40
[ 1591.571079] sdiohal:hready_status haddr 7:[0x144]:0xcf
[ 1591.576245] sdiohal:hready_status haddr 7:[0x145]:0xff
[ 1591.581404] sdiohal:hready_status haddr 7:[0x146]:0xf9
[ 1591.586569] sdiohal:hready_status haddr 7:[0x147]:0x10
[ 1591.591713] sdiohal:val:0xc
[ 1591.594554] sdiohal:after reset hready status:[0x144]:0xcf
[ 1591.600050] sdiohal:after reset hready status:[0x145]:0xff
[ 1591.605561] sdiohal:after reset hready status:[0x146]:0xf9
[ 1591.611066] sdiohal:after reset hready status:[0x147]:0x10
[ 1591.616555] sdiohal:sdio dump_aon_reg end
[ 1591.616555]
[ 1591.622041] sdiohal:sdiohal_abort
[ 1591.625364] sdiohal:carddump flag set[1]
[ 1591.629319] sdiohal:disable rx int for dump
[ 1591.633505] sdiohal:chn8 tx push old, cmdid=5, mstime=1583858, record_time=1583858
[ 1591.641078] chn8 tx push old: 00 00 00 00 10 05 0e 00 f2 2a 18 00 00 00 00 00  .........*......
[ 1591.649774] sdiohal:chn8 tx denq old, cmdid=5, mstime=1583246, record_time=1583246
[ 1591.657344] chn8 tx denq old: 00 07 00 08 10 05 0e 00 8e 28 18 00 00 00 00 00  .........(......
[ 1591.666036] sdiohal:chn22 rx dispatch old, cmdid=5, mstime=1583246, record_time=1583252
[ 1591.674061] chn22 rx dispatch old: bf 06 00 0a 00 05 0d 00 8e 28 18 00 00 79 00 00  .........(...y..
[ 1591.683188] sdiohal:chn8 tx push new, cmdid=5, mstime=1586940, record_time=1586940
[ 1591.690758] chn8 tx push new: 00 00 00 00 10 05 0e 00 fc 36 18 00 00 00 00 00  .........6......
[ 1591.699451] sdiohal:chn8 tx denq new, cmdid=5, mstime=1583858, record_time=1583858
[ 1591.707020] chn8 tx denq new: 00 07 00 08 10 05 0e 00 f2 2a 18 00 00 00 00 00  .........*......
[ 1591.715712] sdiohal:chn22 rx dispatch new, cmdid=5, mstime=1583858, record_time=1583858
[ 1591.723715] chn22 rx dispatch new: 3f 06 00 0a 00 05 0c 00 f2 2a 18 00 00 7d 00 00  ?........*...}..
[ 1591.732841] WCN_ERR: mdbg_dump_data dump memory error:-110
[ 1591.738332] WCN: mdbg dump bt modem 0 ok!
[ 1591.742346] WCN_ERR: read HCI_ARM_WR_RD_MODE reg error:-1
[ 1591.747750] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.753064] WCN: mdbg dump bt_cmd buf 0 ok!
[ 1591.757251] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.762571] WCN: mdbg dump btevent buf 0 ok!
[ 1591.766844] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.772157] WCN: mdbg dump bt_lmp_tx_buf 0 ok!
[ 1591.776603] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.781916] WCN: mdbg dump bt_lmp_rx_buf 0 ok!
[ 1591.786363] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.791676] WCN: mdbg dump bt_acl_tx_buf0 ok!
[ 1591.796042] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.801355] WCN: mdbg dump bt_acl_rx_buf 0 ok!
[ 1591.805801] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.811114] WCN: mdbg dump bt_sco_tx_buf 0 ok!
[ 1591.815560] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.820874] WCN: mdbg dump bt_sco_rx_buf 0 ok!
[ 1591.825328] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.830642] WCN: mdbg dump bt_bb_tx_buf 0 ok!
[ 1591.835001] WCN_ERR: mdbg_dump_data dump memory error:-1
[ 1591.840314] WCN: mdbg dump bt_bb_rx_buf 0 ok!
[ 1591.902303] WCN: dumpmem_rx_callback
[ 1591.905875] WCN: dump str finish!
[ 1591.905878] WCN: mdbg dump memory finish
[ 1592.802296] ------------[ cut here ]------------
[ 1592.806916] NETDEV WATCHDOG: wlan0 (unisoc_wifi): transmit queue 0 timed out 4720 ms
[ 1592.814730] WARNING: CPU: 2 PID: 0 at net/sched/sch_generic.c:525 dev_watchdog+0x240/0x248
[ 1592.822999] Modules linked in: overlay rfcomm algif_hash algif_skcipher af_alg bnep hci_uart btqca btrtl btintel btbcm bluetooth ecdh_generic ecc sprdwl_ng sunxi_addr cfg80211 sunrpc uinput lz4hc lz4 zram sunxi_cedrus(C) snd_soc_hdmi_codec v4l2_mem2mem polyval_ce videobuf2_dma_contig polyval_generic videobuf2_memops videobuf2_v4l2 videodev binfmt_misc videobuf2_common mc panfrost gpu_sched dump_reg drm_shmem_helper cpufreq_dt joydev sprdbt_tty uwe5622_bsp_sdio rfkill fuse dm_mod dw_hdmi_i2s_audio motorcomm dw_hdmi_cec dwmac_sun8i mdio_mux display_connector
[ 1592.872302] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G      D  C         6.6.30-current-sunxi64 #9
[ 1592.881077] Hardware name: OrangePi Zero3 (DT)
[ 1592.885515] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 1592.892471] pc : dev_watchdog+0x240/0x248
[ 1592.896482] lr : dev_watchdog+0x240/0x248
[ 1592.900490] sp : ffff8000816bbe20
[ 1592.903801] x29: ffff8000816bbe20 x28: ffff000001cb7000 x27: ffff8000816bbef0
[ 1592.910935] x26: ffff8000814c69c0 x25: ffff8000816bbef0 x24: 0000000000001270
[ 1592.918069] x23: ffff8000814c6000 x22: 0000000000000000 x21: ffff000004888000
[ 1592.925202] x20: ffff000003a12a00 x19: ffff0000048884c8 x18: ffffffffffffffff
[ 1592.932336] x17: 74756f2064656d69 x16: 7420302065756575 x15: 712074696d736e61
[ 1592.939470] x14: 7274203a29696669 x13: 00000000000003ff x12: 00000000ffffffea
[ 1592.946604] x11: 00000000ffffefff x10: 00000000ffffefff x9 : ffff8000815379d0
[ 1592.953737] x8 : 0000000000017fe8 x7 : c0000000ffffefff x6 : 0000000000000001
[ 1592.960870] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
[ 1592.968003] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000001cb7000
[ 1592.975137] Call trace:
[ 1592.977582]  dev_watchdog+0x240/0x248
[ 1592.981245]  call_timer_fn.constprop.0+0x24/0x80
[ 1592.985866]  __run_timers.part.0+0x244/0x2ac
[ 1592.990135]  run_timer_softirq+0x3c/0x74
[ 1592.994058]  __do_softirq+0x11c/0x264
[ 1592.997719]  ____do_softirq+0x10/0x1c
[ 1593.001381]  call_on_irq_stack+0x24/0x4c
[ 1593.005303]  do_softirq_own_stack+0x1c/0x28
[ 1593.009485]  irq_exit_rcu+0x84/0xc0
[ 1593.012976]  el1_interrupt+0x38/0x54
[ 1593.016553]  el1h_64_irq_handler+0x18/0x24
[ 1593.020648]  el1h_64_irq+0x64/0x68
[ 1593.024049]  default_idle_call+0x28/0x3c
[ 1593.027972]  do_idle+0x214/0x270
[ 1593.031201]  cpu_startup_entry+0x38/0x3c
[ 1593.035123]  secondary_start_kernel+0x12c/0x14c
[ 1593.039654]  __secondary_switched+0xb8/0xbc
[ 1593.043838] ---[ end trace 0000000000000000 ]---
[ 1644.602200] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[ 1644.608144] rcu:     1-...0: (1 GPs behind) idle=6274/1/0x4000000000000000 softirq=110544/110545 fqs=3001
[ 1644.617442] rcu:     (detected by 3, t=15006 jiffies, g=192965, q=8438 ncpus=4)
[ 1644.624482] Task dump for CPU 1:
[ 1644.627706] task:sshd            state:R  running task     stack:0     pid:2006  ppid:1210   flags:0x0010000e
[ 1644.637614] Call trace:
[ 1644.640058]  __switch_to+0xe4/0x15c
[ 1644.643557]  0xffff8000814cbe60
danboid commented 2 months ago

Seems to be issue with ../headers-51.4/include when use full path it works. Sorry for the noise ;).

Did you get this get this patch working with Linux 5.14 and mpv? Can you play 4K h264 videos OK?

In one of your older posts you said you ran make defconfig ARCH=x86_64 which wouldn't be correct for an ARM build but maybe you didn't use that in the end?

kwizart commented 2 months ago

@kwizart Hello, I used your modified lipva-v4l2-request, successfully compiled and installed in kernel version 6.6 I use the command: mpv -v --hwdec=vaapi

After execution, a kernel crash occurred

Yep in-between, I wasn't able to succeed with runtime tests either using modern kernel (6.6+). I don't remember to have experienced similar crash, but at least there is no reason for a kernel to crash and you could eventually report the problem to the appropriate kernel maintainer.

Saketeas commented 1 month ago

@kwizart The ffmpeg-v4l2request tutorial is available at this link:https://forum.armbian.com/topic/32449-repository-for-v4l2request-hardware-video-decoding-rockchip-allwinner/#comment-191209 It is valid to use on kernel6.6, will his patch be helpful to modify this project? I'd love to change it but I'm so bad at it. ffmpeg patch:https://github.com/LibreELEC/LibreELEC.tv/tree/master/packages/multimedia/ffmpeg/patches