瑞芯微RK35xx升级RGA驱动版本和API版本
瑞芯微RK35xx升级RGA驱动版本和API版本
- 1、开发环境
- 2、RGA升级步骤
- 2.1 RGA内核驱动
- 2.2 RGA API库升级
- 3、异常情况解决
1、开发环境
Ubuntu版本:20.04
内核版本:5.10
Ubuntu板卡端版本:20.04
RGA驱动版本:RGA multicore Device Driver: v1.2.23
RGA API版本:v1.10.1
2、RGA升级步骤
2.1 RGA内核驱动
如果想更换RGA的驱动,可以在github下载RGA的最新驱动,地址如下
https://github.com/airockchip/librga
1、将下载到的驱动替换SDK中kernel/drivers/video/rockchip/rga3
2、如果一开始没有打开RGA3的配置,可以参考如下配置,否则可以忽略
CONFIG_VIDEO_ROCKCHIP_RGA=y
# CONFIG_ROCKCHIP_RGA is not set
CONFIG_ROCKCHIP_MULTI_RGA=y
CONFIG_ROCKCHIP_RGA_ASYNC=y
# CONFIG_ROCKCHIP_RGA_PROC_FS is not set
CONFIG_ROCKCHIP_RGA_DEBUG_FS=y
CONFIG_ROCKCHIP_RGA_DEBUGGER=y
3、重新编译即可,如果报错,请自行查找原因
4、查看RGA驱动版本
root@admin:~# cat /sys/kernel/debug/rkrga/driver_version
RGA multicore Device Driver: v1.2.23
2.2 RGA API库升级
1、首先去github上下载librga最新版本包
下载地址如下
https://github.com/airockchip/librga

2、查看源码根目录下的README.md是否兼容内核驱动版本。

3、编译librga.so库
修改toolchains/toolchain_linux.cmake中的TOOLCHAIN_NAME和TOOLCHAIN_HOME
SET(TOOLCHAIN_NAME "aarch64-linux-gnu")
SET(TOOLCHAIN_HOME "/home/admin/3588/gcc-arm-8.2-2018.08-x86_64-aarch64-linux-gnu")# this is required
#SET(CMAKE_SYSTEM_NAME Linux)# specify the cross compiler
SET(CMAKE_C_COMPILER ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-g++)# where is the target environment
SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_HOME})# search for programs in the build host directories (not necessary)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
执行指令./cmake-linux.sh,编译完成后,会在librga/build/build_linux/install/出现编译后的库和测试程序。

把lib中的库文件移到文件系统中的/usr/lib/aarch64-linux-gnu/目录下。
把bin文件夹中的rgaImDemo拷贝到文件系统/bin目录下
4、查看RGA的API版本,如下
root@admin:~# rgaImDemo --querystring
Start selecting mode 0
im2d querystring ..
RGA demo mode = 0x0RGA vendor : Rockchip Electronics Co.,Ltd.
RGA_api version : v1.10.1_[0]
RGA version : RGA_2_Enhance RGA_3
Max input : 8192x8192
Max output : 8128x8128
Byte stride : 16 byte
Scale limit : 0.0625 ~ 16
Input support format : RGBA/ARGB_8888 RGB_888 RGB_565 ARGB_4444 ARGB_5551 YUV420_sp_8bit YUV420_sp_10bit YUV420_p_8bit YUV420_p_10bit YUV422_sp_8bit YUV422_sp_10bit YUV422_p_8bit YUV422_p_10bit YUYV422 YUV400
output support format : RGBA/ARGB_8888 RGB_888 RGB_565 ARGB_4444 ARGB_5551 RGBA_4444 RGBA_5551 YUV420_sp_8bit YUV420_sp_10bit YUV420_p_8bit YUV422_sp_8bit YUV422_sp_10bit YUV422_p_8bit YUYV420 YUYV422 YUV400 Y4
RGA feature : color_fill color_palette ROP quantize src1_r2y_csc dst_full_csc FBC_mode blend_in_YUV BT.2020
expected performance : max 4 pixel/cycle
5、测试是否可用
root@admin:~# rgaImDemo -w6 --copy
Start selecting mode 0
im2d while .. 6 time.
Start selecting mode 80
im2d copy ..
RGA demo mode = 0x81
alloc buffer from "/dev/dma_heap/system-uncached-dma32".
Could not open /data/in0w1280-h720-rgba8888.bin
can not open file for src channel, memset to 0x11.
This is 1 time in the loop
copying .... cost time 675 us
This is 2 time in the loop
copying .... cost time 722 us
This is 3 time in the loop
copying .... cost time 762 us
This is 4 time in the loop
copying .... cost time 758 us
This is 5 time in the loop
copying .... cost time 720 us
This is 6 time in the loop
copying .... cost time 724 us
open /data/out0w1280-h720-rgba8888.bin and write ok
3、异常情况解决
在RK3568中更新过程中,试过运行./rgaImDemo -w6 --copy时报一下错误
root@admin:~# ./rgaImDemo -w6 --copy
Start selecting mode 0
im2d while .. 6 time.
Start selecting mode 80
im2d copy ..
RGA demo mode = 0x81
"/dev/dma_heap/system-uncached-dma32" does not exist, so use malloc.
rga_api version 1.10.1_[0]
[ 1343.362455] rga_mm: RGA_MMU unsupported memory largFeailed to import virtualaddr for src chanrnel! Invalid parameters: The current er ror tmessageh is empty!
an 4G!
[ 1343.362512] rga_mm: schedulerroot@lanxus:~# core[4] unsupported mm_flag[0x0]!
[ 1343.362643] rga_mm: rga_mm_map_buffer map virtual address error!
[ 1343.362674] rga: buffer[0] mm import buffer failed! memory = 0x7fb5efe010, type = virt_addr(0x1)
解决办法如下:
修改Uboot中uboot/arch/arm/mach-rockchip/param.c文件
for (i = 0, n = 0; i < count; i++, n++) {base = t->u.ddr_mem.bank[i];size = t->u.ddr_mem.bank[i + count];/* 0~4GB */if (base < SZ_4GB) {mem[n].base = base;mem[n].size = ddr_mem_get_usable_size(base, size);if (base + size > SZ_4GB) {n++;mem[n].base_u64 = SZ_4GB;mem[n].size_u64 = base + size - SZ_4GB;}}
+ //else {
+ // /* 4GB+ */
+ // mem[n].base_u64 = base;
+ // mem[n].size_u64 = size;
+ //}assert(n < count + MEM_RESV_COUNT);}
