jwalds Posted March 19 Posted March 19 (edited) Hello! I am trying to get the cedar_ve device working for OPIZ2W. I am currently running this image: Orangepizero2w_1.0.4_ubuntu_noble_server_linux6.1.31 My uname -a: Linux orangepizero2w 6.1.31-sun50iw9 #1.0.4 SMP Wed Oct 9 13:39:53 CST 2024 aarch64 aarch64 aarch64 GNU/Linux To do this I am trying to follow these steps: 1. Modify a dts for OPIZ2W to include cedar_ve. 2. Donwloan cedrus driver and build it. 3. Compile modified ffmpeg with x264cedrus support Have anyone tried this? I have only found builds for recent kernel for the H3 CPU, none for the H618. I am looking for a DTS that supports cedar_ve for Orange Pi Zero 2W or any other things that can point me in the right direction. Edited March 19 by jwalds 0 Quote
robertoj Posted Thursday at 04:31 PM Posted Thursday at 04:31 PM (edited) Have you ever seen the OPIZ2w (or OPIZ3) doing HW video encoding in another Linux? Where did you find this cedrus driver? What does the website claim it can do? Where did your OS image come from? What DTS modifications did you mean? Why not just a DTS overlay? Edited Thursday at 04:34 PM by robertoj 0 Quote
jwalds Posted Thursday at 06:50 PM Author Posted Thursday at 06:50 PM I have not seen any one of them do it, but I assume they possess that capability since it is mentioned in the datasheet for H616 here: https://linux-sunxi.org/images/b/b9/H616_Datasheet_V1.0_cleaned.pdf I am looking for a DTS that has the correct parameters for the cedar driver (correct registers, memory etc) for the H618. I am absolutely open to doing a DTS overlay if that would make work easier. 0 Quote
robertoj Posted Thursday at 07:13 PM Posted Thursday at 07:13 PM This is the closest I can find https://forum.armbian.com/topic/26551-video-encoder-using-mainline-kernel/ https://gregdavill.com/posts/allwinner-s3-videoencoders/ https://linux-sunxi.org/Cedrus 0 Quote
Ryzer Posted Thursday at 08:26 PM Posted Thursday at 08:26 PM Hi Jwalds, It's definitely possible as there is Hardware support for it however the software support does not currently exist within the current Cedrus driver. To the best of my knowledge there is currently no mainline video encoding support for any Allwinner SOC. There are problem some efforts to get it working though, one such is: https://bootlin.com/blog/open-source-linux-kernel-support-for-the-allwinner-v3-v3s-s3-h-264-video-encoder/ while target at the V3 it should set the groundwork for getting encoding supported on other Allwinner SOCs. If there is already some form of decoding support then there should already be the video engine / video codec engine node within the main H616 dts. While I prefer overlays there are certain limits meaning it has to been integrated into the main dts rather than via an overlay. Found this out recently myself when exploring G2D hardware block present in some Allwinner SOCs. Best of luck Ryzer 0 Quote
going Posted Friday at 07:46 AM Posted Friday at 07:46 AM Greetings to all participants. Before configuring the software, we need to properly configure the hardware nodes on the chip that are responsible for video/audio processes. Turn on the power, make a reset, adjust the clock, etc. This should be done by the kernel driver. Currently, in the sunxi(64) family for h616-h618 chips, I see a mess in the drivers. There are several of them for the same thing. They were added by different people at different times. Today, these drivers do not want to work correctly. On at least one BPI-m4-berry (h618) board. I'm trying to fix this situation right now. Please write here whatever you think is necessary to speed up the process. After applying all the sunxi-6.12 patches, the core looks like sunxi-6.12-rebase sunxi-6.13-rebase 0 Quote
jwalds Posted Friday at 07:01 PM Author Posted Friday at 07:01 PM Thanks everyone for the answers! Upon looking at the many patches you posted there going, this one sticks out for me https://github.com/armbian/build/blob/main/patch/kernel/archive/sunxi-6.13/patches.armbian/arm64-dts-allwinner-sun50i-h616-Add-VPU-node.patch Maybe that one would work for H618 also to enable the VPU? Would that patch in itself be sufficient to compile and enable the cedrus-driver? 0 Quote
Ryzer Posted Friday at 11:01 PM Posted Friday at 11:01 PM Hi Jwalds, From what I can tell looking at the sun50i-h618-orangepi-zero2w.dts it gets it's definitions from the sun50i-h616.dtsi so it's a start but support would also need to be added to the cedrus driver to appropriately support the H616 SOC. Now I did notice this patch: https://github.com/armbian/build/blob/main/patch/kernel/archive/sunxi-6.13/patches.armbian/drv-staging-media-sunxi-cedrus-add-H616-variant.patch however I do not know if this will actually work. If you look at the kernel configuration file you need to ensure that the cedrus module is set. Best of luck Ryzer 0 Quote
going Posted Saturday at 07:28 AM Posted Saturday at 07:28 AM 8 часов назад, Ryzer сказал: you need to ensure that the cedrus module is set boot> grep -n CEDRUS config-* 7001:CONFIG_VIDEO_SUNXI_CEDRUS=m leo@bananapim4berry:~$ dmesg | grep cedrus [ 11.499288] sunxi_cedrus: module is from the staging directory, the quality is unknown, you have been warned. [ 11.522089] cedrus 1c0e000.video-codec: Device registered as /dev/video0 leo@bananapim4berry:~$ ls -al /dev/video0 crw-rw----+ 1 root video 81, 0 �м�а�р 18 11:53 /dev/video0 leo@bananapim4berry:~$ uname -r 6.13.7-edge-sunxi64 leo@bananapim4berry:~$ lsmod | grep cedrus sunxi_cedrus 49152 0 v4l2_mem2mem 28672 1 sunxi_cedrus videobuf2_dma_contig 20480 1 sunxi_cedrus videobuf2_v4l2 20480 2 sunxi_cedrus,v4l2_mem2mem videodev 249856 3 sunxi_cedrus,videobuf2_v4l2,v4l2_mem2mem videobuf2_common 53248 5 sunxi_cedrus,videobuf2_dma_contig,videobuf2_v4l2,v4l2_mem2mem,videobuf2_memops mc 53248 5 sunxi_cedrus,videodev,videobuf2_v4l2,videobuf2_common,v4l2_mem2mem P.S. add more 0 Quote
going Posted Saturday at 10:35 AM Posted Saturday at 10:35 AM sunxi-6.12: leo@bananapim4berry:~$ uname -r 6.12.19-current-sunxi64 leo@bananapim4berry:~$ dmesg | grep -iE 'audio|ahub|video|codec|hdmi|drm' [ 0.099396] /soc/hdmi@6000000: Fixed dependency cycle(s) with /soc/tcon-top@6510000 [ 0.099455] /soc/tcon-top@6510000: Fixed dependency cycle(s) with /soc/hdmi@6000000 [ 0.104244] /soc/hdmi@6000000: Fixed dependency cycle(s) with /soc/tcon-top@6510000 [ 0.104620] /soc/hdmi@6000000: Fixed dependency cycle(s) with /soc/tcon-top@6510000 [ 0.104780] /soc/tcon-top@6510000: Fixed dependency cycle(s) with /soc/hdmi@6000000 [ 0.107433] /soc/hdmi@6000000: Fixed dependency cycle(s) with /connector [ 0.107516] /connector: Fixed dependency cycle(s) with /soc/hdmi@6000000 [ 1.946257] sun4i-drm display-engine: bound 1100000.mixer (ops 0xffff80008119ae90) [ 1.946454] sun4i-drm display-engine: bound 6510000.tcon-top (ops 0xffff80008119fc60) [ 1.946768] sun4i-drm display-engine: bound 6515000.lcd-controller (ops 0xffff800081197ab0) [ 1.947062] sun8i-dw-hdmi 6000000.hdmi: Detected HDMI TX controller v2.12a with HDCP (DWC HDMI 2.0 TX PHY) [ 1.949760] sun8i-dw-hdmi 6000000.hdmi: registered DesignWare HDMI I2C bus driver [ 1.950030] sun4i-drm display-engine: bound 6000000.hdmi (ops 0xffff800081199f58) [ 1.950535] [drm] Initialized sun4i-drm 1.0.0 for display-engine on minor 0 [ 1.950566] sun8i-dw-hdmi 6000000.hdmi: read_hpd result: 1 [ 2.438265] sun8i-dw-hdmi 6000000.hdmi: EVENT=plugin [ 4.012109] sun4i-drm display-engine: [drm] fb0: sun4i-drmdrmfb frame buffer device [ 9.311566] systemd[1]: Starting modprobe@drm.service - Load Kernel Module drm... [ 9.583263] systemd[1]: modprobe@drm.service: Deactivated successfully. [ 9.590683] systemd[1]: Finished modprobe@drm.service - Load Kernel Module drm. [ 11.222612] [drm] Initialized panfrost 1.2.0 for 1800000.gpu on minor 1 [ 11.336128] videodev: Linux video capture interface: v2.00 [ 11.672804] cedrus 1c0e000.video-codec: Device registered as /dev/video0 [ 36.607644] sun8i-dw-hdmi 6000000.hdmi: EVENT=plugin [ 37.501202] sun8i-dw-hdmi 6000000.hdmi: EVENT=plugin [ 39.278755] hdmi-audio-codec hdmi-audio-codec.5.auto: Only one simultaneous stream supported! [ 39.278791] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -22 [ 39.278816] ahub_plat-i2s-hifi: ASoC: error at __soc_pcm_open on ahub_plat-i2s-hifi: -22 [ 57.559744] hdmi-audio-codec hdmi-audio-codec.5.auto: Only one simultaneous stream supported! [ 57.559772] hdmi-audio-codec hdmi-audio-codec.5.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -22 [ 57.559789] ahub_plat-i2s-hifi: ASoC: error at __soc_pcm_open on ahub_plat-i2s-hifi: -22 pkg for test: sunxi64-6.12.19 0 Quote
going Posted Saturday at 10:50 AM Posted Saturday at 10:50 AM 15 часов назад, jwalds сказал: Would that patch in itself be sufficient to compile and enable the cedrus-driver? The driver is present. You can test this by downloading the packages from the link above. 0 Quote
jwalds Posted Saturday at 06:12 PM Author Posted Saturday at 06:12 PM Okay, I have the driver loaded: root@orangepizero2w:/boot# dmesg | grep cedrus [ 8.578154] sunxi_cedrus: module is from the staging directory, the quality is unknown, you have been warned. [ 8.580382] cedrus 1c0e000.video-codec: Device registered as /dev/video2 I also did this: root@orangepizero2w:/boot# v4l2-ctl --all --device /dev/video2 Driver Info: Driver name : cedrus Card type : cedrus Bus info : platform:cedrus Driver version : 6.1.31 Capabilities : 0x84208000 Video Memory-to-Memory Streaming Extended Pix Format Device Capabilities Device Caps : 0x04208000 Video Memory-to-Memory Streaming Extended Pix Format Media Driver Info: Driver name : cedrus Model : cedrus Serial : Bus info : platform:cedrus Media version : 6.1.31 Hardware revision: 0x00000000 (0) Driver version : 6.1.31 Interface Info: ID : 0x0300000c Type : V4L Video Entity Info: ID : 0x00000001 (1) Name : cedrus-source Function : V4L2 I/O Pad 0x01000002 : 0: Source Link 0x02000008: to remote pad 0x1000004 of entity 'cedrus-proc' (Video Decoder): Data, Enabled, Immutable Priority: 2 Format Video Capture: Width/Height : 16/32 Pixel Format : 'ST12' (Y/UV 4:2:0 (32x32 Linear)) Field : None Bytes per Line : 32 Size Image : 2048 Colorspace : Default Transfer Function : Default (maps to Rec. 709) YCbCr/HSV Encoding: Default (maps to ITU-R 601) Quantization : Default (maps to Full Range) Flags : Format Video Output: Width/Height : 16/32 Pixel Format : 'MG2S' (MPEG-2 Parsed Slice Data) Field : None Bytes per Line : 0 Size Image : 1024 Colorspace : Default Transfer Function : Default (maps to Rec. 709) YCbCr/HSV Encoding: Default (maps to ITU-R 601) Quantization : Default (maps to Full Range) Flags : Codec Controls h264_profile 0x00990a6b (menu) : min=0 max=4 default=2 value=2 (Main) 0: Baseline 1: Constrained Baseline 2: Main 4: High Stateless Codec Controls h264_decode_mode 0x00a40900 (menu) : min=0 max=0 default=0 value=0 (Slice-Based) 0: Slice-Based h264_start_code 0x00a40901 (menu) : min=0 max=0 default=0 value=0 (No Start Code) 0: No Start Code h264_sequence_parameter_set 0x00a40902 (h264-sps): value=unsupported payload type flags=has-payload h264_picture_parameter_set 0x00a40903 (h264-pps): value=unsupported payload type flags=has-payload h264_scaling_matrix 0x00a40904 (h264-scaling-matrix): value=unsupported payload type flags=has-payload h264_prediction_weight_table 0x00a40905 (h264-pred-weights): value=unsupported payload type flags=has-payload h264_slice_parameters 0x00a40906 (h264-slice-params): value=unsupported payload type flags=has-payload h264_decode_parameters 0x00a40907 (h264-decode-params): value=unsupported payload type flags=has-payload vp8_frame_parameters 0x00a409c8 (vp8-frame): value=unsupported payload type flags=has-payload mpeg_2_sequence_header 0x00a409dc (mpeg2-sequence): value=unsupported payload type flags=has-payload mpeg_2_picture_header 0x00a409dd (mpeg2-picture): value=unsupported payload type flags=has-payload mpeg_2_quantisation_matrices 0x00a409de (mpeg2-quantisation): value=unsupported payload type flags=has-payload hevc_sequence_parameter_set 0x00a40a90 (hevc-sps): value=unsupported payload type flags=has-payload hevc_picture_parameter_set 0x00a40a91 (hevc-sps): value=unsupported payload type flags=has-payload hevc_slice_parameters 0x00a40a92 (hevc-slice-params): elems=1 dims=[1] flags=has-payload, dynamic-array hevc_scaling_matrix 0x00a40a93 (hevc-scaling-matrix): value=unsupported payload type flags=has-payload hevc_decode_parameters 0x00a40a94 (hevc-decode-params): value=unsupported payload type flags=has-payload hevc_decode_mode 0x00a40a95 (menu) : min=0 max=0 default=0 value=0 (Slice-Based) 0: Slice-Based hevc_start_code 0x00a40a96 (menu) : min=0 max=0 default=0 value=0 (No Start Code) 0: No Start Code hevc_entry_point_offsets 0x00a40a97 (u32) : min=0 max=4294967295 step=1 default=0 elems=1 dims=[256] flags= has-payload, dynamic-array I take that the driver is loaded successfully then, so the next step would be to build ffmpeg with cedrus support? 0 Quote
going Posted Saturday at 06:19 PM Posted Saturday at 06:19 PM 33 минуты назад, jwalds сказал: I take that the driver is loaded successfully then, so the next step would be to build ffmpeg with cedrus support? But will the system installed from the package work? I can't verify it. The internet is not working on my board. In other words. If you just install the necessary packages. 0 Quote
Ryzer Posted Saturday at 07:12 PM Posted Saturday at 07:12 PM Hi All, Good to hear that the cedrus driver appears to be initialized correctly. It has been a while since I last tried hardware accelerated playback and unfortunately did not have much success. From what I remember from another topic is that in order to utilize the cedrus, ffmpeg has to be compiled with v4l2m2m (--enable-v4l2-m2m) support in place. From what I can tell this is not set in the system packaged version of ffmpeg. Hope this helps Ryzer 1 Quote
jwalds Posted Sunday at 04:37 PM Author Posted Sunday at 04:37 PM I am not sure where I can find a version of ffmepg that supports the cedrus driver and that works with the some form of modern version of ffmpeg source tree. Anyone who knows? 0 Quote
Ryzer Posted Sunday at 07:33 PM Posted Sunday at 07:33 PM Hi Jwalds, Looking back I just realised that you are still using kernel-6.1, which is now considered "legacy" and no longer as actively supported. You are likely to have better chance of success with an image built around at least kernel 6.6 which has a more developed version of the cedrus driver. To clarify a further more the cedrus driver is exposed via the v4l framework so this is what ffmpeg has to be built with support for. Now I managed to successful build ffmpeg on my own board, a Pcduino2 (A10) which admittedly is much older than H616 but shares the same cedrus driver and some of the same codecs. In my case I found that ffmpeg failed when attempting hardware decoding. Looking into the debug output, ffmpeg was detecting the cedrus driver but apparently running into somekind of formatting issue. I don't know of it is caused by the demo clip I was using or an underlying issue in the driver. best of luck Ryzer 0 Quote
Nick A Posted Sunday at 11:05 PM Posted Sunday at 11:05 PM Maybe this patch will make ffmpeg-v4l2 work https://github.com/NickAlilovic/build/blob/v20241125/patch/kernel/archive/sunxi-6.10/patches.armbian/0551-media-cedrus-Implement-AFBC-YUV420-formats-for-H265.patch 0 Quote
going Posted yesterday at 05:42 AM Posted yesterday at 05:42 AM 9 часов назад, Ryzer сказал: Looking back I just realised that you are still using kernel-6.1, which is now considered "legacy" and no longer as actively supported. You are likely to have better chance of success with an image built around at least kernel 6.6 which has a more developed version of the cedrus driver. patch/kernel/archive/sunxi-6.1 It will be deleted tomorrow. patch/kernel/archive/sunxi-6.6 This is frozen on version v6.6.75 as stable. It will be moved to LEGACY tomorrow and will no longer be supported. 1 Quote
going Posted yesterday at 06:55 AM Posted yesterday at 06:55 AM 7 часов назад, Nick A сказал: Maybe this patch will make ffmpeg-v4l2 work https://github.com/NickAlilovic/build/blob/v20241125/patch/kernel/archive/sunxi-6.10/patches.armbian/0551-media-cedrus-Implement-AFBC-YUV420-formats-for-H265.patch There are no changes in the driver between kernel versions 6.10 and 6.12. I think this patch can be added to the current (6.12) kernel. In your opinion, what else can be added or which parts should I pay special attention to? 0 Quote
Nick A Posted 20 hours ago Posted 20 hours ago (edited) Here's some of the media patches not included in the official armbian build. I tested ffmpeg-v4l2 on my unofficial build and works with only a few frame drops. I'm compiling an image for my TV Box using the official build and these patches. I'll let you know if it works. https://github.com/NickAlilovic/build/tree/v20250306/patch/kernel/archive/warpme-6.12 0553-media-cedrus-Don-t-CPU-map-source-buffers.patch 0554-media-Add-NV12-and-P010-AFBC-compressed-formats.patch 0555-media-cedrus-add-format-filtering-based-on-depth-and.patch 0556-media-cedrus-Implement-AFBC-YUV420-formats-for-H265.patch Edited 20 hours ago by Nick A 0 Quote
Nick A Posted 18 hours ago Posted 18 hours ago (edited) The patches posted above and @jock ffmpeg-v4l2request. H264 hardware decoding now works. I'm using debian bookwarm, X11, xfce. Just follow jocks install instructions in the link below. Getting errors with 1080p mp4 video's. I fixed this before by changing the cma to a higher value (cma=512M) in the boot.cmd file. Quote DRM_IOCTL_MODE_CREATE_DUMB failed: Cannot allocate memory Failed to create scanout resource Quote setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} ubootpart=${partuuid} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs} cma=512M" 720p works ok. Quote nick@transpeed-8k618-t:~/Downloads$ mpv SampleVideo_1280x720_1mb.mp4 (+) Video --vid=1 (*) (h264 1280x720 25.000fps) (+) Audio --aid=1 (*) (aac 6ch 48000Hz) Using hardware decoding (drm). [W][00188.323572] pw.conf | [ conf.c: 939 try_load_conf()] can't load config client.conf: No such file or directory [E][00188.323871] pw.conf | [ conf.c: 963 pw_conf_load_conf_for_context()] can't load default config client.conf: No such file or directory AO: [pulse] 48000Hz 5.1 6ch float VO: [gpu] 1280x720 drm_prime[nv12] AV: 00:00:05 / 00:00:05 (98%) A-V: 0.000 Dropped: 1 Exiting... (End of file) Edited 17 hours ago by Nick A 1 Quote
jwalds Posted 4 hours ago Author Posted 4 hours ago But does this mean it does encoding aswell? 0 Quote
robertoj Posted 20 minutes ago Posted 20 minutes ago No. The driver for h264 encoding does not exist 0 Quote
Nick A Posted 17 minutes ago Posted 17 minutes ago (edited) I haven't tested encoding. You probably need something like this. https://github.com/bootlin/v4l2-cedrus-enc-test I'm still having issues playing 1080p videos shuttering and dropped frames. Trying to find patches that might be missing. Works fine on my build. I'm using warpme-6.12 patches. https://github.com/NickAlilovic/build/tree/v20250306 Edited 17 minutes ago by Nick A 0 Quote
Ryzer Posted 11 minutes ago Posted 11 minutes ago Hi Nick, Thanks for the suggestion, after doing a bit more research it does seem like v4l2-request is better suited. I did attempt following jocks instructions but I could not add the apt repo as it yielded a network unreachable error. AS a work around I will try with Kwiboo's instead: https://github.com/Kwiboo/FFmpeg as this also has v4l2-request support. Thanks for providing the patches, I am interested to see how they will preform on the A10, I will be sure to implement them next time I get round to a system build. Once I get a positive indication that hardware acceleration is working I will trying increasing the CMA size but I may need to change screens. My current system only has a cma of 96MB, in the past I found if I set it too high it will stop displaying at all on my 4K monitor. @jwalds I dont believe so, I have yet to find a patch that adds encoding to the cedrus driver. A possible start point would be here: https://github.com/bootlin/linux/tree/cedrus/h264-encoding as it looks like some work has at least started. Thanks Ryzer 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.