├── debian ├── compat ├── librga2.dirs ├── librga2.install ├── librga-dev.dirs ├── librga-dev.install ├── rules ├── changelog ├── control └── copyright ├── docs └── RGA_FAQ.assets │ ├── image-blend.png │ ├── image-normal.png │ ├── image-alpha-0x0.png │ ├── image-alpha-normal.png │ ├── image-alpha-abnormal.png │ ├── image-cache-abnormal.png │ ├── image-color-abnormal.png │ ├── image-resize-abnormal.png │ ├── image-rotate-90-normal.png │ └── image-rotate-90-abnormal.png ├── samples ├── utils │ ├── 3rdparty │ │ └── libdrm │ │ │ ├── include │ │ │ ├── demo.h │ │ │ ├── tool.h │ │ │ ├── demo_define.h │ │ │ └── libdrm │ │ │ │ ├── sis_drm.h │ │ │ │ └── drm_sarea.h │ │ │ └── lib │ │ │ ├── arm32 │ │ │ └── libdrm.so │ │ │ ├── arm64 │ │ │ └── libdrm.so │ │ │ └── android │ │ │ ├── arm32 │ │ │ └── libdrm.so │ │ │ └── arm64 │ │ │ └── libdrm.so │ ├── CMakeLists.txt │ ├── allocator │ │ ├── CMakeLists.txt │ │ └── include │ │ │ ├── dma_alloc.h │ │ │ └── drm_alloc.h │ └── utils.h ├── sample_file │ ├── in0w1280-h720-rgba8888.bin │ ├── in1w1280-h720-rgba8888.bin │ └── README.txt ├── im2d_slt │ ├── third-party │ │ └── libdrm │ │ │ └── include │ │ │ ├── demo.h │ │ │ ├── tool.h │ │ │ ├── demo_define.h │ │ │ └── libdrm │ │ │ ├── sis_drm.h │ │ │ └── drm_sarea.h │ ├── cmake-linux.sh │ ├── cmake │ │ └── buildroot.cmake │ ├── sources │ │ ├── dma_alloc.h │ │ ├── drm_alloc.h │ │ └── slt_config.h │ ├── Android.mk │ ├── chip_config │ │ ├── rk3588_slt_config.h.template │ │ ├── rv1106_slt_config.h.template │ │ └── rk3528_rk3562_android_slt_config.h.template │ ├── CMakeLists.txt │ └── README.md ├── mosaic_demo │ ├── src │ │ ├── CMakeLists.txt │ │ └── rga_mosaic_demo.cpp │ ├── cmake-linux.sh │ ├── cmake-android.sh │ └── CMakeLists.txt ├── rop_demo │ ├── src │ │ └── CMakeLists.txt │ ├── cmake-linux.sh │ ├── cmake-android.sh │ └── CMakeLists.txt ├── async_demo │ ├── src │ │ └── CMakeLists.txt │ ├── cmake-linux.sh │ ├── cmake-android.sh │ └── CMakeLists.txt ├── padding_demo │ ├── src │ │ └── CMakeLists.txt │ ├── cmake-linux.sh │ ├── cmake-android.sh │ └── CMakeLists.txt ├── crop_demo │ ├── src │ │ └── CMakeLists.txt │ ├── cmake-linux.sh │ ├── cmake-android.sh │ └── CMakeLists.txt ├── config_demo │ ├── src │ │ ├── CMakeLists.txt │ │ ├── rga_config_single_core_demo.cpp │ │ └── rga_config_thread_core_demo.cpp │ ├── cmake-linux.sh │ ├── cmake-android.sh │ └── CMakeLists.txt ├── cmake-linux.sh ├── alpha_demo │ ├── cmake-linux.sh │ ├── cmake-android.sh │ ├── Android.mk │ ├── CMakeLists.txt │ └── src │ │ └── CMakeLists.txt ├── copy_demo │ ├── cmake-linux.sh │ ├── cmake-android.sh │ ├── CMakeLists.txt │ └── src │ │ └── CMakeLists.txt ├── fill_demo │ ├── cmake-linux.sh │ ├── cmake-android.sh │ ├── CMakeLists.txt │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_fill_demo.cpp │ │ ├── rga_fill_rectangle_demo.cpp │ │ └── rga_fill_rectangle_array_demo.cpp ├── allocator_demo │ ├── cmake-linux.sh │ ├── cmake-android.sh │ ├── cmake-linux-rv1106-1103.sh │ ├── CMakeLists.txt │ ├── Android.mk │ └── src │ │ ├── CMakeLists.txt │ │ └── rga_allocator_dma32_demo.cpp ├── cvtcolor_demo │ ├── cmake-linux.sh │ ├── cmake-android.sh │ ├── src │ │ ├── CMakeLists.txt │ │ ├── rga_cvtcolor_demo.cpp │ │ └── rga_cvtcolor_csc_demo.cpp │ └── CMakeLists.txt ├── resize_demo │ ├── cmake-linux.sh │ ├── cmake-android.sh │ ├── src │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── transform_demo │ ├── cmake-linux.sh │ ├── cmake-android.sh │ ├── src │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── cmake-android.sh ├── im2d_api_demo │ ├── cmake-linux.sh │ ├── cmake-android.sh │ ├── Android.mk │ ├── README.md │ ├── args.h │ └── CMakeLists.txt ├── CMakeLists.txt └── README.md ├── .gitignore ├── meson_options.txt ├── toolchains ├── toolchain_android_ndk.cmake └── toolchain_linux.cmake ├── meson.sh ├── cmake-linux.sh ├── cmake-android.sh ├── im2d_api ├── im2d.hpp ├── im2d.h ├── im2d_expand.h ├── im2d_version.h ├── im2d_mpi.h └── src │ ├── im2d_log.cpp │ └── im2d_log.h ├── cross ├── cross_file_arm32.txt └── cross_file_aarch64.txt ├── core ├── utils │ ├── android_utils │ │ ├── android_utils.h │ │ └── src │ │ │ └── android_utils.cpp │ ├── drm_utils │ │ ├── drm_utils.h │ │ └── src │ │ │ └── drm_utils.cpp │ ├── utils.h │ └── utils.cpp ├── rga_sync.h ├── NormalRgaContext.h └── RgaApi.cpp ├── cmake └── utils.cmake ├── include ├── RgaUtils.h ├── GrallocOps.h ├── RgaSingleton.h ├── RgaApi.h └── RockchipRga.h ├── Android.bp ├── meson.build └── README.md /debian/compat: -------------------------------------------------------------------------------- 1 | 11 2 | -------------------------------------------------------------------------------- /debian/librga2.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | -------------------------------------------------------------------------------- /debian/librga2.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/lib*.so.* 2 | -------------------------------------------------------------------------------- /debian/librga-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/include 3 | -------------------------------------------------------------------------------- /debian/librga-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/* 2 | usr/lib/*/lib*.so 3 | usr/lib/*/pkgconfig/* 4 | -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-blend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-blend.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-normal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-alpha-0x0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-alpha-0x0.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-alpha-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-alpha-normal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-alpha-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-alpha-abnormal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-cache-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-cache-abnormal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-color-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-color-abnormal.png -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/include/demo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/utils/3rdparty/libdrm/include/demo.h -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/include/tool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/utils/3rdparty/libdrm/include/tool.h -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-resize-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-resize-abnormal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-rotate-90-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-rotate-90-normal.png -------------------------------------------------------------------------------- /samples/sample_file/in0w1280-h720-rgba8888.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/sample_file/in0w1280-h720-rgba8888.bin -------------------------------------------------------------------------------- /samples/sample_file/in1w1280-h720-rgba8888.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/sample_file/in1w1280-h720-rgba8888.bin -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-rotate-90-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/docs/RGA_FAQ.assets/image-rotate-90-abnormal.png -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/lib/arm32/libdrm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/utils/3rdparty/libdrm/lib/arm32/libdrm.so -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/lib/arm64/libdrm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/utils/3rdparty/libdrm/lib/arm64/libdrm.so -------------------------------------------------------------------------------- /samples/im2d_slt/third-party/libdrm/include/demo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/im2d_slt/third-party/libdrm/include/demo.h -------------------------------------------------------------------------------- /samples/im2d_slt/third-party/libdrm/include/tool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/im2d_slt/third-party/libdrm/include/tool.h -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/include/demo_define.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/utils/3rdparty/libdrm/include/demo_define.h -------------------------------------------------------------------------------- /samples/im2d_slt/third-party/libdrm/include/demo_define.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/im2d_slt/third-party/libdrm/include/demo_define.h -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/lib/android/arm32/libdrm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/utils/3rdparty/libdrm/lib/android/arm32/libdrm.so -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/lib/android/arm64/libdrm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hardkernel/rk3568_linux_linux-rga/HEAD/samples/utils/3rdparty/libdrm/lib/android/arm64/libdrm.so -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles/ 3 | Makefile 4 | cmake_install.cmake 5 | install_manifest.txt 6 | librga.so 7 | rgaImDemo 8 | .vscode/ 9 | *.patch 10 | build/ 11 | build_linux/ 12 | build_android_ndk/ 13 | .DS_Store 14 | local_* 15 | *.cpp.* 16 | -------------------------------------------------------------------------------- /samples/mosaic_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_mosaic_demo 2 | add_executable(rga_mosaic_demo 3 | rga_mosaic_demo.cpp 4 | ) 5 | target_link_libraries(rga_mosaic_demo 6 | utils_obj 7 | ${RGA_LIB} 8 | ) 9 | install(TARGETS rga_mosaic_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 10 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # See debhelper(7) (uncomment to enable) 3 | # output every command that modifies files on the build system. 4 | export DH_VERBOSE = 1 5 | 6 | override_dh_auto_configure: 7 | dh_auto_configure -- -Dlibdrm=true 8 | 9 | %: 10 | dh $@ --buildsystem=meson 11 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('libdrm', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', 2 | description: 'With libdrm (default: auto)') 3 | option('librga_demo', type: 'combo', choices: ['true', 'false', 'auto'], value: 'false', 4 | description: 'With librga_demo (default: false)') 5 | -------------------------------------------------------------------------------- /samples/rop_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_rop_demo 2 | SET(DEMO_NAME rga_rop_demo) 3 | add_executable(${DEMO_NAME} 4 | ${DEMO_NAME}.cpp 5 | ) 6 | target_link_libraries(${DEMO_NAME} 7 | utils_obj 8 | ${RGA_LIB} 9 | ) 10 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 11 | 12 | -------------------------------------------------------------------------------- /samples/async_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_async_demo 2 | SET(DEMO_NAME rga_async_demo) 3 | add_executable(${DEMO_NAME} 4 | ${DEMO_NAME}.cpp 5 | ) 6 | target_link_libraries(${DEMO_NAME} 7 | utils_obj 8 | ${RGA_LIB} 9 | ) 10 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 11 | 12 | -------------------------------------------------------------------------------- /samples/padding_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_padding_demo 2 | SET(DEMO_NAME rga_padding_demo) 3 | add_executable(${DEMO_NAME} 4 | ${DEMO_NAME}.cpp 5 | ) 6 | target_link_libraries(${DEMO_NAME} 7 | utils_obj 8 | ${RGA_LIB} 9 | ) 10 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 11 | 12 | -------------------------------------------------------------------------------- /toolchains/toolchain_android_ndk.cmake: -------------------------------------------------------------------------------- 1 | # Modify to the local android ndk path. 2 | SET(CMAKE_ANDROID_NDK "/home/yqw/library/AndroidNDK/android-ndk-r16b") 3 | 4 | SET(CMAKE_SYSTEM_NAME Android) 5 | SET(CMAKE_SYSTEM_VERSION 24) 6 | SET(CMAKE_ANDROID_ARCH_ABI arm64-v8a) 7 | SET(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang) 8 | SET(CMAKE_ANDROID_STL_TYPE c++_static) 9 | -------------------------------------------------------------------------------- /meson.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SOURCE_PATH=${SCRIPT_DIR} 5 | 6 | # Modify to the local toolchain path. 7 | TOOLCHAIN_PATH=cross/cross_file_aarch64.txt 8 | BUILD_PATH=build/meson_aarch64 9 | INSTALL_PATH="${SOURCE_PATH}/${BUILD_PATH}/install" 10 | 11 | rm -rf ${BUILD_PATH} 12 | 13 | meson ${BUILD_PATH} --prefix=${INSTALL_PATH} --cross-file=${TOOLCHAIN_PATH} 14 | 15 | ninja -C ${BUILD_PATH} install 16 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | librga (2.2.0-1) unstable; urgency=medium 2 | 3 | * debian: Update to support rga3 4 | 5 | -- Jeffy Chen Fri, 7 Jan 2022 15:44:00 +0800 6 | 7 | librga (2.1.0-1) unstable; urgency=medium 8 | 9 | * debian: Update license 10 | 11 | -- Jeffy Chen Thu, 20 May 2021 10:05:29 +0800 12 | 13 | librga (2.0.0-1) stable; urgency=medium 14 | 15 | * Initial release. 16 | 17 | -- Jeffy Chen Thu, 23 Jul 2020 17:49:04 +0800 18 | -------------------------------------------------------------------------------- /samples/sample_file/README.txt: -------------------------------------------------------------------------------- 1 | 使用示例图片时,Android系统须将源图片存储在设备/data/目录下,Linux系统须将源图储存在设备/usr/data目录下。 2 | 命名规则如下,输入文件为 in , 输出文件为 out: 3 | --->第一个%d 是文件的索引, 一般为 0, 用于区别格式及宽高完全相同的文件 4 | --->第二个%d 是宽的意思, 这里的宽一般指虚宽 5 | --->第三个%d 是高的意思, 这里的高一般指虚高 6 | --->第四个%s 是格式的名字。 7 | 8 | 示例图片:in0w1280-h720-rgba8888.bin 9 | 分辨率:1280×720 10 | 格式 :RGBA8888 11 | 描述 :除logo外为全透明。 12 | 13 | 示例图片:in1w1280-h720-rgba8888.bin 14 | 分辨率:1280×720 15 | 格式 :RGBA8888 16 | 描述 :全不透明。 17 | 18 | 19 | 更加详尽的使用测试用例方法以及API说明请至librga/docs/README.md查看。 -------------------------------------------------------------------------------- /samples/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(utils_obj OBJECT "") 2 | 3 | SET(THIRD_PARTY_PATH ${CMAKE_CURRENT_LIST_DIR}/3rdparty) 4 | 5 | include(${CMAKE_CURRENT_LIST_DIR}/allocator/CMakeLists.txt) 6 | 7 | target_sources(utils_obj 8 | PRIVATE 9 | ${CMAKE_CURRENT_LIST_DIR}/utils.cpp 10 | PUBLIC 11 | ${CMAKE_CURRENT_LIST_DIR}/utils.h 12 | ) 13 | 14 | target_include_directories(utils_obj 15 | PUBLIC 16 | ${CMAKE_CURRENT_LIST_DIR} 17 | ) 18 | 19 | SET(RGA_SAMPLES_UTILS_COMPILED "true" CACHE STRING "") 20 | -------------------------------------------------------------------------------- /samples/utils/allocator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(utils_obj 2 | PRIVATE 3 | ${CMAKE_CURRENT_LIST_DIR}/dma_alloc.cpp 4 | ${CMAKE_CURRENT_LIST_DIR}/drm_alloc.cpp 5 | PUBLIC 6 | ${CMAKE_CURRENT_LIST_DIR}/include/dma_alloc.h 7 | ${CMAKE_CURRENT_LIST_DIR}/include/drm_alloc.h 8 | ) 9 | 10 | target_include_directories(utils_obj 11 | PUBLIC 12 | ${THIRD_PARTY_PATH}/libdrm/include 13 | ${THIRD_PARTY_PATH}/libdrm/include/libdrm 14 | ${CMAKE_CURRENT_LIST_DIR}/include 15 | ) 16 | -------------------------------------------------------------------------------- /samples/crop_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_crop_demo 2 | add_executable(rga_crop_demo 3 | rga_crop_demo.cpp 4 | ) 5 | target_link_libraries(rga_crop_demo 6 | utils_obj 7 | ${RGA_LIB} 8 | ) 9 | install(TARGETS rga_crop_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 10 | 11 | # rga_crop_rect_demo 12 | add_executable(rga_crop_rect_demo 13 | rga_crop_rect_demo.cpp 14 | ) 15 | target_link_libraries(rga_crop_rect_demo 16 | utils_obj 17 | ${RGA_LIB} 18 | ) 19 | install(TARGETS rga_crop_rect_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 20 | -------------------------------------------------------------------------------- /samples/im2d_slt/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BUILD_DIR=build_linux 4 | BINARY_DIR=$BUILD_DIR/bin 5 | 6 | rm -rf $BUILD_DIR 7 | mkdir -p $BUILD_DIR 8 | mkdir -p $BINARY_DIR 9 | pushd $BUILD_DIR 10 | 11 | if [ "$1" = "drm" ];then 12 | echo "using drm" 13 | cmake -DCMAKE_BUILD_TARGET=buildroot \ 14 | -DCMAKE_BUILD_THIRD_PARTY=drm \ 15 | -DCMAKE_INSTALL_PREFIX=install \ 16 | .. 17 | else 18 | echo "Default mode" 19 | cmake -DCMAKE_BUILD_TARGET=buildroot \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | .. 22 | fi 23 | 24 | make 25 | make install 26 | 27 | popd 28 | -------------------------------------------------------------------------------- /cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SOURCE_PATH=${SCRIPT_DIR} 5 | 6 | # Modify to the local toolchain path. 7 | TOOLCHAIN_PATH=${SOURCE_PATH}/toolchains/toolchain_linux.cmake 8 | BUILD_DIR=build/build_linux 9 | BUILD_TYPE=Release 10 | 11 | rm -rf $BUILD_DIR 12 | mkdir -p $BUILD_DIR 13 | pushd $BUILD_DIR 14 | 15 | cmake ../.. \ 16 | -DCMAKE_BUILD_TARGET=buildroot \ 17 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 18 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 19 | -DCMAKE_INSTALL_PREFIX=install \ 20 | 21 | make -j8 22 | make install 23 | 24 | popd 25 | -------------------------------------------------------------------------------- /cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SOURCE_PATH=${SCRIPT_DIR} 5 | 6 | # Modify to the local toolchain path. 7 | TOOLCHAIN_PATH=${SOURCE_PATH}/toolchains/toolchain_android_ndk.cmake 8 | BUILD_DIR=build/build_android_ndk 9 | BUILD_TYPE=Release 10 | 11 | rm -rf $BUILD_DIR 12 | mkdir -p $BUILD_DIR 13 | pushd $BUILD_DIR 14 | 15 | cmake ../.. \ 16 | -DCMAKE_BUILD_TARGET=android_ndk \ 17 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 18 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 19 | -DCMAKE_INSTALL_PREFIX=install \ 20 | 21 | make -j8 22 | make install 23 | 24 | popd 25 | -------------------------------------------------------------------------------- /samples/config_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_config_thread_core_demo 2 | add_executable(rga_config_thread_core_demo 3 | rga_config_thread_core_demo.cpp 4 | ) 5 | target_link_libraries(rga_config_thread_core_demo 6 | utils_obj 7 | ${RGA_LIB} 8 | ) 9 | install(TARGETS rga_config_thread_core_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 10 | 11 | # rga_config_single_core_demo 12 | add_executable(rga_config_single_core_demo 13 | rga_config_single_core_demo.cpp 14 | ) 15 | target_link_libraries(rga_config_single_core_demo 16 | utils_obj 17 | ${RGA_LIB} 18 | ) 19 | install(TARGETS rga_config_single_core_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 20 | -------------------------------------------------------------------------------- /samples/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR} 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/alpha_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/async_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/copy_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/crop_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/fill_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/rop_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/allocator_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/config_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/cvtcolor_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/mosaic_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/padding_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/resize_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/transform_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR} 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/alpha_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/async_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/copy_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/crop_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/fill_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/rop_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/allocator_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/config_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/cvtcolor_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/mosaic_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/padding_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/resize_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/transform_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 18 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 19 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 20 | -DCMAKE_INSTALL_PREFIX=install \ 21 | 22 | make -j8 23 | make install 24 | 25 | popd 26 | -------------------------------------------------------------------------------- /samples/allocator_demo/cmake-linux-rv1106-1103.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # Modify to the local toolchain path. 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DTARGET_SOC=RV1106 \ 18 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 19 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 20 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 21 | -DCMAKE_INSTALL_PREFIX=install \ 22 | 23 | make -j8 24 | make install 25 | 26 | popd 27 | -------------------------------------------------------------------------------- /samples/im2d_api_demo/cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib 9 | BUILD_DIR=build/build_linux 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DCMAKE_BUILD_TARGET=buildroot \ 18 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 19 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 20 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 21 | -DCMAKE_INSTALL_PREFIX=install \ 22 | 23 | make -j8 24 | make install 25 | 26 | popd 27 | -------------------------------------------------------------------------------- /samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 9 | project(rga_${TARGET_NAME}) 10 | 11 | add_subdirectory(allocator_demo) 12 | add_subdirectory(alpha_demo) 13 | add_subdirectory(async_demo) 14 | add_subdirectory(config_demo) 15 | add_subdirectory(copy_demo) 16 | add_subdirectory(crop_demo) 17 | add_subdirectory(cvtcolor_demo) 18 | add_subdirectory(fill_demo) 19 | add_subdirectory(mosaic_demo) 20 | add_subdirectory(padding_demo) 21 | add_subdirectory(resize_demo) 22 | add_subdirectory(rop_demo) 23 | add_subdirectory(transform_demo) 24 | -------------------------------------------------------------------------------- /samples/im2d_api_demo/cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SAMPLES_DIR=${SCRIPT_DIR}/.. 5 | 6 | # The following options require configuration 7 | TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib 9 | BUILD_DIR=build/build_android_ndk 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | cmake ../.. \ 17 | -DCMAKE_BUILD_TARGET=android_ndk \ 18 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 19 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 20 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 21 | -DCMAKE_INSTALL_PREFIX=install \ 22 | 23 | make -j8 24 | make install 25 | 26 | popd 27 | -------------------------------------------------------------------------------- /samples/im2d_slt/cmake/buildroot.cmake: -------------------------------------------------------------------------------- 1 | SET(TOOLCHAIN_HOME "/home1/yqw/linux/1106_ipc/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf") 2 | 3 | # this is required 4 | #SET(CMAKE_SYSTEM_NAME Linux) 5 | 6 | # specify the cross compiler 7 | SET(CMAKE_C_COMPILER ${TOOLCHAIN_HOME}/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc) 8 | SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/arm-rockchip830-linux-uclibcgnueabihf-g++) 9 | 10 | # where is the target environment 11 | SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_HOME}) 12 | 13 | # search for programs in the build host directories (not necessary) 14 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 15 | # for libraries and headers in the target directories 16 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 17 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 18 | -------------------------------------------------------------------------------- /toolchains/toolchain_linux.cmake: -------------------------------------------------------------------------------- 1 | SET(TOOLCHAIN_HOME "/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu") 2 | SET(TOOLCHAIN_NAME "aarch64-rockchip1031-linux-gnu") 3 | 4 | # this is required 5 | #SET(CMAKE_SYSTEM_NAME Linux) 6 | 7 | # specify the cross compiler 8 | SET(CMAKE_C_COMPILER ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-gcc) 9 | SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-g++) 10 | 11 | # where is the target environment 12 | SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_HOME}) 13 | 14 | # search for programs in the build host directories (not necessary) 15 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 16 | # for libraries and headers in the target directories 17 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 18 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 19 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: librga 2 | Priority: optional 3 | Maintainer: Putin Lee 4 | Uploaders: Jeffy Chen 5 | Build-Depends: debhelper (>= 11), 6 | libdrm-dev (>= 2.4.0), 7 | meson, 8 | pkg-config 9 | Standards-Version: 4.1.3 10 | Section: libs 11 | Homepage: https://github.com/rockchip-linux/linux-rga 12 | Vcs-Git: https://github.com/rockchip-linux/linux-rga 13 | Vcs-Browser: https://github.com/rockchip-linux/linux-rga 14 | 15 | Package: librga-dev 16 | Section: libdevel 17 | Architecture: any 18 | Depends: librga2 (= ${binary:Version}) 19 | Description: Userspace interface to Rockchip RGA 2D accelerator 20 | 21 | Package: librga2 22 | Architecture: any 23 | Depends: ${shlibs:Depends}, ${misc:Depends} 24 | Description: Userspace interface to Rockchip RGA 2D accelerator 25 | -------------------------------------------------------------------------------- /samples/cvtcolor_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_cvtcolor_demo 2 | add_executable(rga_cvtcolor_demo 3 | rga_cvtcolor_demo.cpp 4 | ) 5 | target_link_libraries(rga_cvtcolor_demo 6 | utils_obj 7 | ${RGA_LIB} 8 | ) 9 | install(TARGETS rga_cvtcolor_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 10 | 11 | # rga_cvtcolor_csc_demo 12 | add_executable(rga_cvtcolor_csc_demo 13 | rga_cvtcolor_csc_demo.cpp 14 | ) 15 | target_link_libraries(rga_cvtcolor_csc_demo 16 | utils_obj 17 | ${RGA_LIB} 18 | ) 19 | install(TARGETS rga_cvtcolor_csc_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 20 | 21 | # rga_cvtcolor_gray256_demo 22 | add_executable(rga_cvtcolor_gray256_demo 23 | rga_cvtcolor_gray256_demo.cpp 24 | ) 25 | target_link_libraries(rga_cvtcolor_gray256_demo 26 | utils_obj 27 | ${RGA_LIB} 28 | ) 29 | install(TARGETS rga_cvtcolor_gray256_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 30 | -------------------------------------------------------------------------------- /samples/resize_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_resize_demo 2 | SET(DEMO_NAME rga_resize_demo) 3 | add_executable(${DEMO_NAME} 4 | ${DEMO_NAME}.cpp 5 | ) 6 | target_link_libraries(${DEMO_NAME} 7 | utils_obj 8 | ${RGA_LIB} 9 | ) 10 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 11 | 12 | # rga_resize_uv_downsampling_demo 13 | SET(DEMO_NAME rga_resize_uv_downsampling_demo) 14 | add_executable(${DEMO_NAME} 15 | ${DEMO_NAME}.cpp 16 | ) 17 | target_link_libraries(${DEMO_NAME} 18 | utils_obj 19 | ${RGA_LIB} 20 | ) 21 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 22 | 23 | # rga_resize_rect_demo 24 | SET(DEMO_NAME rga_resize_rect_demo) 25 | add_executable(${DEMO_NAME} 26 | ${DEMO_NAME}.cpp 27 | ) 28 | target_link_libraries(${DEMO_NAME} 29 | utils_obj 30 | ${RGA_LIB} 31 | ) 32 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 33 | 34 | -------------------------------------------------------------------------------- /samples/transform_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_transform_rotate_demo 2 | SET(DEMO_NAME rga_transform_rotate_demo) 3 | add_executable(${DEMO_NAME} 4 | ${DEMO_NAME}.cpp 5 | ) 6 | target_link_libraries(${DEMO_NAME} 7 | utils_obj 8 | ${RGA_LIB} 9 | ) 10 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 11 | 12 | # rga_transform_flip_demo 13 | SET(DEMO_NAME rga_transform_flip_demo) 14 | add_executable(${DEMO_NAME} 15 | ${DEMO_NAME}.cpp 16 | ) 17 | target_link_libraries(${DEMO_NAME} 18 | utils_obj 19 | ${RGA_LIB} 20 | ) 21 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 22 | 23 | # rga_transform_rotate_flip_demo 24 | SET(DEMO_NAME rga_transform_rotate_flip_demo) 25 | add_executable(${DEMO_NAME} 26 | ${DEMO_NAME}.cpp 27 | ) 28 | target_link_libraries(${DEMO_NAME} 29 | utils_obj 30 | ${RGA_LIB} 31 | ) 32 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 33 | 34 | -------------------------------------------------------------------------------- /im2d_api/im2d.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * PutinLee 5 | * Cerf Yu 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | #ifndef _im2d_hpp_ 20 | #define _im2d_hpp_ 21 | 22 | #include "im2d.h" 23 | #include "im2d_expand.h" 24 | 25 | #endif /* #ifndef _im2d_hpp_ */ 26 | 27 | 28 | -------------------------------------------------------------------------------- /cross/cross_file_arm32.txt: -------------------------------------------------------------------------------- 1 | [binaries] 2 | c = '/home/lee/rv1126/buildroot/output/rockchip_puma/host/bin/arm-linux-gnueabihf-gcc' 3 | cpp = '/home/lee/rv1126/buildroot/output/rockchip_puma/host/bin/arm-linux-gnueabihf-g++' 4 | ar = '/home/lee/rv1126/buildroot/output/rockchip_puma/host/bin/arm-linux-gnueabihf-ar' 5 | strip = '/home/lee/rv1126/buildroot/output/rockchip_puma/host/bin/arm-linux-gnueabihf-gcc-strip' 6 | pkgconfig = '/home/lee/rv1126/buildroot/output/rockchip_puma/host/bin/pkg-config' 7 | 8 | [host_machine] 9 | system = 'linux' 10 | cpu_family = 'arm' 11 | cpu = 'arm' 12 | endian = 'little' 13 | 14 | [properties] 15 | needs_exe_wrapper = true 16 | c_args = ['-I/home/lee/rv1126/buildroot/output/rockchip_puma/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include', '-L/home/lee/rv1126/buildroot/output/rockchip_puma/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib', '-L/home/lee/rv1126/buildroot/output/rockchip_puma/host/lib', '-I/home/lee/rv1126/buildroot/output/rockchip_puma/host/include'] 17 | -------------------------------------------------------------------------------- /core/utils/android_utils/android_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef _RGA_UTILS_ADNDROID_UTILS_H_ 20 | #define _RGA_UTILS_ADNDROID_UTILS_H_ 21 | 22 | #include 23 | 24 | #define is_android_hal_format(format) ((format) & 0xff) 25 | 26 | uint32_t get_format_from_android_hal(uint32_t android_hal_format); 27 | 28 | #endif /* #ifndef _RGA_UTILS_ADNDROID_UTILS_H_ */ 29 | -------------------------------------------------------------------------------- /im2d_api/im2d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * PutinLee 5 | * Cerf Yu 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef _im2d_h_ 21 | #define _im2d_h_ 22 | 23 | #include "im2d_version.h" 24 | #include "im2d_type.h" 25 | 26 | #include "im2d_common.h" 27 | #include "im2d_buffer.h" 28 | #include "im2d_single.h" 29 | #include "im2d_task.h" 30 | #include "im2d_mpi.h" 31 | 32 | #endif /* #ifndef _im2d_h_ */ 33 | -------------------------------------------------------------------------------- /samples/im2d_slt/sources/dma_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __DMA_ALLOC_H__ 20 | #define __DMA_ALLOC_H__ 21 | 22 | int dma_sync_device_to_cpu(int fd); 23 | int dma_sync_cpu_to_device(int fd); 24 | 25 | int dma_buf_alloc(int width, int height, int format, int *fd, void **va); 26 | void dma_buf_free(int width, int height, int format, int *fd, void *va); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /cmake/utils.cmake: -------------------------------------------------------------------------------- 1 | FUNCTION(im2d_api_extract_version) 2 | FILE(READ "${CMAKE_CURRENT_LIST_DIR}/im2d_api/im2d_version.h" version_file) 3 | 4 | STRING(REGEX MATCH "RGA_API_MAJOR_VERSION ([0-9]+)" _ "${version_file}") 5 | if(NOT CMAKE_MATCH_COUNT EQUAL 1) 6 | message(FATAL_ERROR "Could not extract major version number from im2d_version.h") 7 | endif() 8 | set(VER_MAJOR ${CMAKE_MATCH_1}) 9 | 10 | STRING(REGEX MATCH "RGA_API_MINOR_VERSION ([0-9]+)" _ "${version_file}") 11 | if(NOT CMAKE_MATCH_COUNT EQUAL 1) 12 | message(FATAL_ERROR "Could not extract minor version number from im2d_version.h") 13 | endif() 14 | set(VER_MINOR ${CMAKE_MATCH_1}) 15 | 16 | STRING(REGEX MATCH "RGA_API_REVISION_VERSION ([0-9]+)" _ "${version_file}") 17 | if(NOT CMAKE_MATCH_COUNT EQUAL 1) 18 | message(FATAL_ERROR "Could not extract revision version number from im2d_version.h") 19 | endif() 20 | set(VER_REVISION ${CMAKE_MATCH_1}) 21 | 22 | set(IM2D_API_VERSION_MAJOR ${VER_MAJOR} PARENT_SCOPE) 23 | set(IM2D_API_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}" PARENT_SCOPE) 24 | ENDFUNCTION() 25 | -------------------------------------------------------------------------------- /samples/alpha_demo/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | #====================================================================== 3 | # 4 | # alphaTest 5 | # 6 | #====================================================================== 7 | include $(CLEAR_VARS) 8 | LOCAL_VENDOR_MODULE := true 9 | 10 | LOCAL_CFLAGS += -Wall -Werror -Wunreachable-code 11 | 12 | LOCAL_C_INCLUDES += \ 13 | hardware/rockchip/librga \ 14 | hardware/rockchip/librga/include \ 15 | hardware/rockchip/librga/im2d_api 16 | 17 | LOCAL_C_INCLUDES += \ 18 | hardware/rockchip/librga/samples/utils \ 19 | hardware/rockchip/librga/samples/3rdparty \ 20 | hardware/rockchip/librga/samples/3rdparty/libdrm/include \ 21 | hardware/rockchip/librga/samples/3rdparty/libdrm/include/libdrm 22 | 23 | LOCAL_SHARED_LIBRARIES := \ 24 | libui \ 25 | libutils \ 26 | librga 27 | 28 | LOCAL_HEADER_LIBRARIES += \ 29 | libhardware_headers \ 30 | libgui_headers \ 31 | 32 | LOCAL_SRC_FILES:= \ 33 | ../utils/utils.cpp \ 34 | src/rga_alpha_demo.cpp 35 | 36 | LOCAL_MODULE:= \ 37 | rga_alpha_demo 38 | 39 | ifdef TARGET_32_BIT_SURFACEFLINGER 40 | LOCAL_32_BIT_ONLY := true 41 | endif 42 | 43 | include $(BUILD_EXECUTABLE) 44 | 45 | -------------------------------------------------------------------------------- /samples/alpha_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/async_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/config_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/copy_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/crop_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/fill_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/mosaic_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/resize_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/rop_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/allocator_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/cvtcolor_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/padding_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /samples/transform_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 9 | message("load ${LIBRGA_FILE_LIB}/librga.so") 10 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 11 | else () 12 | set(RGA_LIB rga) 13 | endif() 14 | 15 | get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) 16 | project(rga_${TARGET_NAME}) 17 | 18 | #install path 19 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 20 | set(CMAKE_INSTALL_BINDIR bin) 21 | endif() 22 | 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl") 25 | 26 | set(RGA_INCLUDE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 28 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api) 29 | include_directories(${RGA_INCLUDE}) 30 | 31 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 32 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 33 | endif() 34 | 35 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 36 | 37 | add_subdirectory(src) 38 | 39 | -------------------------------------------------------------------------------- /core/utils/drm_utils/drm_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef _RGA_UTILS_DRM_UTILS_H_ 20 | #define _RGA_UTILS_DRM_UTILS_H_ 21 | 22 | #include 23 | 24 | #define is_drm_fourcc(format) (((format >> 24) & 0xff) && \ 25 | ((format >> 16) & 0xff) && \ 26 | ((format >> 8) & 0xff) && \ 27 | ((format) & 0xff)) 28 | 29 | uint32_t get_format_from_drm_fourcc(uint32_t drm_fourcc); 30 | 31 | #endif /* #ifndef _RGA_UTILS_DRM_UTILS_H_ */ 32 | -------------------------------------------------------------------------------- /core/utils/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "android_utils/android_utils.h" 20 | #include "drm_utils/drm_utils.h" 21 | 22 | /* 23 | * When a pointer is converted to uint64_t, it must first be assigned to 24 | * an integer of the same size, and then converted to uint64_t. The opposite 25 | * is true. 26 | */ 27 | #define ptr_to_u64(ptr) ((uint64_t)(uintptr_t)(ptr)) 28 | #define u64_to_ptr(var) ((void *)(uintptr_t)(var)) 29 | 30 | #define is_rga_format(format) ((format) & 0xff00 || (format) == 0) 31 | 32 | int convert_to_rga_format(int ex_format); 33 | -------------------------------------------------------------------------------- /samples/allocator_demo/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | #====================================================================== 3 | # 4 | # rga_allocator_graphicbuffer_demo 5 | # 6 | #====================================================================== 7 | include $(CLEAR_VARS) 8 | LOCAL_VENDOR_MODULE := true 9 | 10 | LOCAL_CFLAGS += -Wall -Werror -Wunreachable-code 11 | 12 | LOCAL_C_INCLUDES += \ 13 | hardware/rockchip/librga \ 14 | hardware/rockchip/librga/include \ 15 | hardware/rockchip/librga/im2d_api 16 | 17 | LOCAL_C_INCLUDES += \ 18 | hardware/rockchip/librga/samples/utils \ 19 | hardware/rockchip/librga/samples/3rdparty \ 20 | hardware/rockchip/librga/samples/3rdparty/libdrm/include \ 21 | hardware/rockchip/librga/samples/3rdparty/libdrm/include/libdrm \ 22 | 23 | LOCAL_SHARED_LIBRARIES := \ 24 | libui \ 25 | libutils \ 26 | librga 27 | 28 | LOCAL_HEADER_LIBRARIES += \ 29 | libhardware_headers \ 30 | libgui_headers \ 31 | 32 | LOCAL_SRC_FILES:= \ 33 | ../utils/utils.cpp \ 34 | src/rga_allocator_graphicbuffer_demo.cpp 35 | 36 | LOCAL_MODULE:= \ 37 | rga_allocator_graphicbuffer_demo 38 | 39 | ifdef TARGET_32_BIT_SURFACEFLINGER 40 | LOCAL_32_BIT_ONLY := true 41 | endif 42 | 43 | include $(BUILD_EXECUTABLE) 44 | 45 | -------------------------------------------------------------------------------- /include/RgaUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Zhiqin Wei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef _rga_utils_h_ 20 | #define _rga_utils_h_ 21 | 22 | // ------------------------------------------------------------------------------- 23 | float get_bpp_from_format(int format); 24 | int get_perPixel_stride_from_format(int format); 25 | int get_buf_from_file(void *buf, int f, int sw, int sh, int index); 26 | int output_buf_data_to_file(void *buf, int f, int sw, int sh, int index); 27 | const char *translate_format_str(int format); 28 | int get_buf_from_file_FBC(void *buf, int f, int sw, int sh, int index); 29 | int output_buf_data_to_file_FBC(void *buf, int f, int sw, int sh, int index); 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /samples/alpha_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_alpha_demo 2 | add_executable(rga_alpha_demo 3 | rga_alpha_demo.cpp 4 | ) 5 | target_link_libraries(rga_alpha_demo 6 | utils_obj 7 | ${RGA_LIB} 8 | ) 9 | install(TARGETS rga_alpha_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 10 | 11 | # rga_alpha_3channel_demo 12 | add_executable(rga_alpha_3channel_demo 13 | rga_alpha_3channel_demo.cpp 14 | ) 15 | target_link_libraries(rga_alpha_3channel_demo 16 | utils_obj 17 | ${RGA_LIB} 18 | ) 19 | install(TARGETS rga_alpha_3channel_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 20 | 21 | # rga_alpha_yuv_demo 22 | add_executable(rga_alpha_yuv_demo 23 | rga_alpha_yuv_demo.cpp 24 | ) 25 | target_link_libraries(rga_alpha_yuv_demo 26 | utils_obj 27 | ${RGA_LIB} 28 | ) 29 | install(TARGETS rga_alpha_yuv_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 30 | 31 | # rga_alpha_colorkey_demo 32 | add_executable(rga_alpha_colorkey_demo 33 | rga_alpha_colorkey_demo.cpp 34 | ) 35 | target_link_libraries(rga_alpha_colorkey_demo 36 | utils_obj 37 | ${RGA_LIB} 38 | ) 39 | install(TARGETS rga_alpha_colorkey_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 40 | 41 | # rga_alpha_osd_demo 42 | add_executable(rga_alpha_osd_demo 43 | rga_alpha_osd_demo.cpp 44 | ) 45 | target_link_libraries(rga_alpha_osd_demo 46 | utils_obj 47 | ${RGA_LIB} 48 | ) 49 | install(TARGETS rga_alpha_osd_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 50 | 51 | -------------------------------------------------------------------------------- /samples/copy_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_copy_demo 2 | SET(DEMO_NAME rga_copy_demo) 3 | add_executable(${DEMO_NAME} 4 | ${DEMO_NAME}.cpp 5 | ) 6 | target_link_libraries(${DEMO_NAME} 7 | utils_obj 8 | ${RGA_LIB} 9 | ) 10 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 11 | 12 | # rga_copy_fbc_demo 13 | SET(DEMO_NAME rga_copy_fbc_demo) 14 | add_executable(${DEMO_NAME} 15 | ${DEMO_NAME}.cpp 16 | ) 17 | target_link_libraries(${DEMO_NAME} 18 | utils_obj 19 | ${RGA_LIB} 20 | ) 21 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 22 | 23 | # rga_copy_tile8x8_demo 24 | SET(DEMO_NAME rga_copy_tile8x8_demo) 25 | add_executable(${DEMO_NAME} 26 | ${DEMO_NAME}.cpp 27 | ) 28 | target_link_libraries(${DEMO_NAME} 29 | utils_obj 30 | ${RGA_LIB} 31 | ) 32 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 33 | 34 | # rga_copy_splice_demo 35 | SET(DEMO_NAME rga_copy_splice_demo) 36 | add_executable(${DEMO_NAME} 37 | ${DEMO_NAME}.cpp 38 | ) 39 | target_link_libraries(${DEMO_NAME} 40 | utils_obj 41 | ${RGA_LIB} 42 | ) 43 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 44 | 45 | # rga_copy_splice_task_demo 46 | SET(DEMO_NAME rga_copy_splice_task_demo) 47 | add_executable(${DEMO_NAME} 48 | ${DEMO_NAME}.cpp 49 | ) 50 | target_link_libraries(${DEMO_NAME} 51 | utils_obj 52 | ${RGA_LIB} 53 | ) 54 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 55 | -------------------------------------------------------------------------------- /samples/fill_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_fill_demo 2 | SET(DEMO_NAME rga_fill_demo) 3 | add_executable(${DEMO_NAME} 4 | ${DEMO_NAME}.cpp 5 | ) 6 | target_link_libraries(${DEMO_NAME} 7 | utils_obj 8 | ${RGA_LIB} 9 | ) 10 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 11 | 12 | # rga_fill_rectangle_demo 13 | SET(DEMO_NAME rga_fill_rectangle_demo) 14 | add_executable(${DEMO_NAME} 15 | ${DEMO_NAME}.cpp 16 | ) 17 | target_link_libraries(${DEMO_NAME} 18 | utils_obj 19 | ${RGA_LIB} 20 | ) 21 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 22 | 23 | # rga_fill_rectangle_array_demo 24 | SET(DEMO_NAME rga_fill_rectangle_array_demo) 25 | add_executable(${DEMO_NAME} 26 | ${DEMO_NAME}.cpp 27 | ) 28 | target_link_libraries(${DEMO_NAME} 29 | utils_obj 30 | ${RGA_LIB} 31 | ) 32 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 33 | 34 | # rga_fill_rectangle_task_demo 35 | SET(DEMO_NAME rga_fill_rectangle_task_demo) 36 | add_executable(${DEMO_NAME} 37 | ${DEMO_NAME}.cpp 38 | ) 39 | target_link_libraries(${DEMO_NAME} 40 | utils_obj 41 | ${RGA_LIB} 42 | ) 43 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 44 | 45 | # rga_fill_rectangle_task_array_demo 46 | SET(DEMO_NAME rga_fill_rectangle_task_array_demo) 47 | add_executable(${DEMO_NAME} 48 | ${DEMO_NAME}.cpp 49 | ) 50 | target_link_libraries(${DEMO_NAME} 51 | utils_obj 52 | ${RGA_LIB} 53 | ) 54 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 55 | 56 | -------------------------------------------------------------------------------- /core/utils/utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "rga.h" 20 | #include "utils.h" 21 | 22 | static int get_compatible_format(int format) { 23 | #if LINUX 24 | if (format == 0) 25 | return format; 26 | 27 | if ((format >> 8) != 0) { 28 | return format; 29 | } else { 30 | return format << 8; 31 | } 32 | #endif 33 | return format; 34 | } 35 | 36 | int convert_to_rga_format(int ex_format) { 37 | int fmt; 38 | 39 | if (is_drm_fourcc(ex_format)) 40 | return get_format_from_drm_fourcc(ex_format); 41 | 42 | ex_format = get_compatible_format(ex_format); 43 | if (is_android_hal_format(ex_format)) 44 | return get_format_from_android_hal(ex_format); 45 | else if (is_rga_format(ex_format)) 46 | return ex_format; 47 | 48 | return RK_FORMAT_UNKNOWN; 49 | } 50 | -------------------------------------------------------------------------------- /core/rga_sync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __RGA_IM2D_SYNC_H__ 18 | #define __RGA_IM2D_SYNC_H__ 19 | 20 | #include 21 | 22 | /* timeout in msecs */ 23 | int rga_sync_wait(int fd, int timeout); 24 | 25 | /** 26 | * Merge two sync files. 27 | * 28 | * This produces a new sync file with the given name which has the union of the 29 | * two original sync file's fences; redundant fences may be removed. 30 | * 31 | * If one of the input sync files is signaled or invalid, then this function 32 | * may behave like dup(): the new file descriptor refers to the valid/unsignaled 33 | * sync file with its original name, rather than a new sync file. 34 | * 35 | * The original fences remain valid, and the caller is responsible for closing 36 | * them. 37 | * 38 | * Available since API level 26. 39 | */ 40 | int32_t rga_sync_merge(const char* name, int32_t fd1, int32_t fd2); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /core/NormalRgaContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Zhiqin Wei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef _rockchip_normal_rga_context_h_ 20 | #define _rockchip_normal_rga_context_h_ 21 | 22 | #include "rga_ioctl.h" 23 | 24 | #ifndef ANDROID 25 | #define ALOGD(...) { printf(__VA_ARGS__); printf("\n"); } 26 | #define ALOGE(...) { printf(__VA_ARGS__); printf("\n"); } 27 | #endif 28 | 29 | typedef enum { 30 | RGA_DRIVER_IOC_UNKONW = 0, 31 | RGA_DRIVER_IOC_RGA2, 32 | RGA_DRIVER_IOC_MULTI_RGA, 33 | 34 | RGA_DRIVER_IOC_DEFAULT = RGA_DRIVER_IOC_MULTI_RGA, 35 | } RGA_DRIVER_IOC_TYPE; 36 | 37 | struct rgaContext { 38 | int rgaFd; 39 | int mLogAlways; 40 | int mLogOnce; 41 | float mVersion; 42 | int Is_debug; 43 | struct rga_hw_versions_t mHwVersions; 44 | struct rga_version_t mDriverVersion; 45 | RGA_DRIVER_IOC_TYPE driver = RGA_DRIVER_IOC_DEFAULT; 46 | }; 47 | #endif 48 | -------------------------------------------------------------------------------- /cross/cross_file_aarch64.txt: -------------------------------------------------------------------------------- 1 | [binaries] 2 | c = '/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-rockchip1031-linux-gnu-gcc' 3 | cpp = '/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-rockchip1031-linux-gnu-g++' 4 | ar = '/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-rockchip1031-linux-gnu-ar' 5 | strip = '/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-rockchip1031-linux-gnu-strip' 6 | pkgconfig = '/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/bin/pkg-config' 7 | 8 | [host_machine] 9 | system = 'linux' 10 | cpu_family = 'aarch64' 11 | cpu = 'aarch64' 12 | endian = 'little' 13 | 14 | [properties] 15 | needs_exe_wrapper = true 16 | c_args = ['-I/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/aarch64-rockchip-linux-gnu/sysroot/usr/include', '-L/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/aarch64-rockchip-linux-gnu/sysroot/usr/lib', '-L/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/lib', '-I/home1/yqw/linux/rk3588/prebuilts/gcc/linux-x86/aarch64/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/include'] 17 | -------------------------------------------------------------------------------- /samples/utils/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __RGA_SAMPLES_UTILS_H__ 20 | #define __RGA_SAMPLES_UTILS_H__ 21 | 22 | #include 23 | 24 | int64_t get_cur_us(); 25 | int64_t get_cur_ms(); 26 | void draw_rgba(char *buffer, int width, int height); 27 | void draw_YUV420(char *buffer, int width, int height); 28 | void draw_YUV422(char *buffer, int width, int height); 29 | void draw_gray256(char *buffer, int width, int height); 30 | int read_image_from_fbc_file(void *buf, const char *path, int sw, int sh, int fmt, int index); 31 | int read_image_from_file(void *buf, const char *path, int sw, int sh, int fmt, int index); 32 | int write_image_to_fbc_file(void *buf, const char *path, int sw, int sh, int fmt, int index); 33 | int write_image_to_file(void *buf, const char *path, int sw, int sh, int fmt, int index); 34 | 35 | #endif /* #ifndef __RGA_SAMPLES_UTILS_H__ */ 36 | -------------------------------------------------------------------------------- /samples/utils/allocator/include/dma_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __RGA_SAMPLES_ALLOCATOR_DMA_ALLOC_H__ 20 | #define __RGA_SAMPLES_ALLOCATOR_DMA_ALLOC_H__ 21 | 22 | #define DMA_HEAP_UNCACHE_PATH "/dev/dma_heap/system-uncached" 23 | #define DMA_HEAP_PATH "/dev/dma_heap/system" 24 | #define DMA_HEAP_DMA32_UNCACHE_PATCH "/dev/dma_heap/system-uncached-dma32" 25 | #define DMA_HEAP_DMA32_PATCH "/dev/dma_heap/system-dma32" 26 | #define CMA_HEAP_UNCACHE_PATH "/dev/dma_heap/cma-uncached" 27 | #define RV1106_CMA_HEAP_PATH "/dev/rk_dma_heap/rk-dma-heap-cma" 28 | 29 | int dma_sync_device_to_cpu(int fd); 30 | int dma_sync_cpu_to_device(int fd); 31 | 32 | int dma_buf_alloc(const char *path, size_t size, int *fd, void **va); 33 | void dma_buf_free(size_t size, int *fd, void *va); 34 | 35 | #endif /* #ifndef __RGA_SAMPLES_ALLOCATOR_DMA_ALLOC_H__ */ 36 | -------------------------------------------------------------------------------- /im2d_api/im2d_expand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _im2d_expand_h_ 19 | #define _im2d_expand_h_ 20 | 21 | #ifdef __cplusplus 22 | 23 | #include "im2d_type.h" 24 | 25 | #if ANDROID 26 | 27 | #include 28 | 29 | using namespace android; 30 | 31 | IM_API rga_buffer_handle_t importbuffer_GraphicBuffer_handle(buffer_handle_t hnd); 32 | IM_API rga_buffer_handle_t importbuffer_GraphicBuffer(sp buf); 33 | 34 | IM_API rga_buffer_t wrapbuffer_handle(buffer_handle_t hnd); 35 | IM_API rga_buffer_t wrapbuffer_GraphicBuffer(sp buf); 36 | 37 | #if USE_AHARDWAREBUFFER 38 | #include 39 | IM_API rga_buffer_handle_t importbuffer_AHardwareBuffer(AHardwareBuffer *buf); 40 | IM_API rga_buffer_t wrapbuffer_AHardwareBuffer(AHardwareBuffer *buf); 41 | 42 | #endif /* #if USE_AHARDWAREBUFFER */ 43 | #endif /* #if ANDROID */ 44 | 45 | #endif /* #ifdef __cplusplus */ 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /samples/utils/allocator/include/drm_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Randall zhuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __RGA_SAMPLES_ALLOCATOR_DRM_ALLOC_H__ 20 | #define __RGA_SAMPLES_ALLOCATOR_DRM_ALLOC_H__ 21 | 22 | /* memory type definitions. */ 23 | enum drm_rockchip_gem_mem_type 24 | { 25 | /* Physically Continuous memory and used as default. */ 26 | ROCKCHIP_BO_CONTIG = 1 << 0, 27 | /* cachable mapping. */ 28 | ROCKCHIP_BO_CACHABLE = 1 << 1, 29 | /* write-combine mapping. */ 30 | ROCKCHIP_BO_WC = 1 << 2, 31 | ROCKCHIP_BO_SECURE = 1 << 3, 32 | ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE | 33 | ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE 34 | }; 35 | 36 | void* drm_buf_alloc(int TexWidth, int TexHeight,int bpp, int *fd, int *handle, size_t *actual_size, int flags = 0); 37 | int drm_buf_destroy(int buf_fd, int handle, void *drm_buf, size_t size); 38 | uint32_t drm_buf_get_phy(int handle); 39 | 40 | #endif /* #ifndef __RGA_SAMPLES_ALLOCATOR_DRM_ALLOC_H__ */ 41 | -------------------------------------------------------------------------------- /samples/im2d_slt/sources/drm_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Randall Zhuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef __DRM_ALLOC_H__ 20 | #define __DRM_ALLOC_H__ 21 | 22 | /* memory type definitions. */ 23 | enum drm_rockchip_gem_mem_type 24 | { 25 | /* Physically Continuous memory and used as default. */ 26 | ROCKCHIP_BO_CONTIG = 1 << 0, 27 | /* cachable mapping. */ 28 | ROCKCHIP_BO_CACHABLE = 1 << 1, 29 | /* write-combine mapping. */ 30 | ROCKCHIP_BO_WC = 1 << 2, 31 | ROCKCHIP_BO_SECURE = 1 << 3, 32 | ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE | 33 | ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE 34 | }; 35 | 36 | struct drm_object { 37 | int drm_buffer_fd; 38 | int drm_buffer_handle; 39 | size_t actual_size; 40 | uint8_t *drm_buf; 41 | }; 42 | 43 | void* drm_buf_alloc(int TexWidth, int TexHeight,int bpp, int *fd, int *handle, size_t *actual_size, int flags=0); 44 | int drm_buf_destroy(int buf_fd, int handle, void *drm_buf, size_t size); 45 | uint32_t drm_buf_get_phy(int handle); 46 | 47 | #endif -------------------------------------------------------------------------------- /samples/im2d_slt/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | #====================================================================== 3 | # 4 | #im2d_slt 5 | # 6 | #====================================================================== 7 | include $(CLEAR_VARS) 8 | LOCAL_VENDOR_MODULE := true 9 | 10 | LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES 11 | 12 | LOCAL_CFLAGS += -DROCKCHIP_GPU_LIB_ENABLE 13 | 14 | LOCAL_CFLAGS += -Wall -Werror -Wunreachable-code 15 | 16 | LOCAL_C_INCLUDES += external/tinyalsa/include 17 | 18 | LOCAL_C_INCLUDES += hardware/rockchip/librga 19 | LOCAL_C_INCLUDES += hardware/rk29/librga \ 20 | system/core \ 21 | system/core/include/utils \ 22 | system/core/liblog/include \ 23 | hardware/rockchip/librga\ 24 | hardware/rockchip/librga/include \ 25 | $(LOCAL_PATH)/third-party/libdrm/include \ 26 | $(LOCAL_PATH)/third-party/libdrm/include/libdrm 27 | 28 | LOCAL_SHARED_LIBRARIES := \ 29 | libcutils \ 30 | liblog \ 31 | libutils \ 32 | libui \ 33 | libEGL \ 34 | libGLESv1_CM \ 35 | libhardware \ 36 | librga 37 | 38 | LOCAL_HEADER_LIBRARIES += \ 39 | libutils_headers \ 40 | libcutils_headers \ 41 | libhardware_headers \ 42 | liblog_headers \ 43 | libgui_headers \ 44 | libbinder_headers 45 | 46 | #has no "external/stlport" from Android 6.0 on 47 | ifeq (1,$(strip $(shell expr $(PLATFORM_VERSION) \< 6.0))) 48 | LOCAL_C_INCLUDES += \ 49 | external/stlport/stlport 50 | 51 | LOCAL_C_INCLUDES += bionic 52 | endif 53 | 54 | LOCAL_SRC_FILES += \ 55 | sources/rga_im2d_slt.cpp \ 56 | sources/drm_alloc.cpp \ 57 | sources/dma_alloc.cpp 58 | 59 | LOCAL_MODULE:= im2d_slt 60 | 61 | ifdef TARGET_32_BIT_SURFACEFLINGER 62 | LOCAL_32_BIT_ONLY := true 63 | endif 64 | 65 | include $(BUILD_EXECUTABLE) 66 | 67 | -------------------------------------------------------------------------------- /include/GrallocOps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Zhiqin Wei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef _rk_graphic_buffer_h_ 20 | #define _rk_graphic_buffer_h_ 21 | 22 | #ifdef ANDROID 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "drmrga.h" 49 | #include "rga.h" 50 | 51 | // ------------------------------------------------------------------------------- 52 | int RkRgaGetHandleFd(buffer_handle_t handle, int *fd); 53 | int RkRgaGetHandleAttributes(buffer_handle_t handle, 54 | std::vector *attrs); 55 | int RkRgaGetHandleMapAddress(buffer_handle_t handle, 56 | void **buf); 57 | #endif //Android 58 | 59 | #endif //_rk_graphic_buffer_h_ 60 | -------------------------------------------------------------------------------- /im2d_api/im2d_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef _RGA_IM2D_VERSION_H_ 20 | #define _RGA_IM2D_VERSION_H_ 21 | 22 | #define RGA_VERSION_STR_HELPER(x) #x 23 | #define RGA_VERSION_STR(x) RGA_VERSION_STR_HELPER(x) 24 | 25 | /* RGA im2d api verison */ 26 | #define RGA_API_MAJOR_VERSION 1 27 | #define RGA_API_MINOR_VERSION 9 28 | #define RGA_API_REVISION_VERSION 2 29 | #define RGA_API_BUILD_VERSION 0 30 | 31 | #define RGA_API_SUFFIX 32 | 33 | #define RGA_API_VERSION \ 34 | RGA_VERSION_STR(RGA_API_MAJOR_VERSION) "." \ 35 | RGA_VERSION_STR(RGA_API_MINOR_VERSION) "." \ 36 | RGA_VERSION_STR(RGA_API_REVISION_VERSION) "_[" \ 37 | RGA_VERSION_STR(RGA_API_BUILD_VERSION) "]" 38 | #define RGA_API_FULL_VERSION "rga_api version " RGA_API_VERSION RGA_API_SUFFIX 39 | 40 | /* For header file version verification */ 41 | #define RGA_CURRENT_API_VERSION (\ 42 | (RGA_API_MAJOR_VERSION & 0xff) << 24 | \ 43 | (RGA_API_MINOR_VERSION & 0xff) << 16 | \ 44 | (RGA_API_REVISION_VERSION & 0xff) << 8 | \ 45 | (RGA_API_BUILD_VERSION & 0xff)\ 46 | ) 47 | #define RGA_CURRENT_API_HEADER_VERSION RGA_CURRENT_API_VERSION 48 | 49 | #endif /* _RGA_IM2D_VERSION_H_ */ 50 | -------------------------------------------------------------------------------- /Android.bp: -------------------------------------------------------------------------------- 1 | bootstrap_go_package { 2 | name: "soong-librga", 3 | pkgPath: "android/soong/librga", 4 | deps: [ 5 | "blueprint", 6 | "blueprint-pathtools", 7 | "soong", 8 | "soong-android", 9 | "soong-cc", 10 | "soong-genrule", 11 | ], 12 | srcs: [ 13 | "Android.go", 14 | ], 15 | pluginFor: ["soong_build"], 16 | } 17 | 18 | cc_librga { 19 | name: "cc_librga_defaults" 20 | } 21 | 22 | cc_library_shared { 23 | name: "librga", 24 | defaults: [ 25 | "cc_librga_defaults" 26 | ], 27 | 28 | vendor_available: true, 29 | 30 | header_libs: [ 31 | "gl_headers", 32 | "libgui_headers", 33 | "libhardware_headers", 34 | "libbinder_headers", 35 | "liblog_headers", 36 | ], 37 | srcs: [ 38 | "core/utils/android_utils/src/android_utils.cpp", 39 | "core/utils/drm_utils/src/drm_utils.cpp", 40 | "core/utils/utils.cpp", 41 | "core/RockchipRga.cpp", 42 | "core/GrallocOps.cpp", 43 | "core/NormalRga.cpp", 44 | "core/NormalRgaApi.cpp", 45 | "core/RgaApi.cpp", 46 | "core/RgaUtils.cpp", 47 | "core/rga_sync.cpp", 48 | "im2d_api/src/im2d_log.cpp", 49 | "im2d_api/src/im2d_impl.cpp", 50 | "im2d_api/src/im2d.cpp", 51 | ], 52 | export_include_dirs: [ 53 | "include", 54 | "im2d_api", 55 | ], 56 | include_dirs: [ 57 | "hardware/rockchip/librga/core/hardware", 58 | "hardware/rockchip/librga/core/utils", 59 | "hardware/rockchip/librga/core/3rdparty/libdrm/include/drm", 60 | "frameworks/native/libs/nativewindow/include", 61 | ], 62 | 63 | shared_libs: [ 64 | "liblog", 65 | "libui", 66 | "libutils", 67 | "libcutils", 68 | "libhardware", 69 | "libsync", 70 | ], 71 | 72 | cflags: ["-Wno-error"] +["-DLOG_TAG=\"librga\""] + ["-DRK_DRM_GRALLOC=1"] + ["-DANDROID_8"] + ["-DANDROID_7_DRM"] + ["-DUSE_AHARDWAREBUFFER=1"] + ["-DANDROID"], 73 | } 74 | -------------------------------------------------------------------------------- /samples/im2d_api_demo/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | #====================================================================== 3 | # 4 | #rgaImDemo 5 | # 6 | #====================================================================== 7 | include $(CLEAR_VARS) 8 | LOCAL_VENDOR_MODULE := true 9 | 10 | LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES 11 | 12 | LOCAL_CFLAGS += -DROCKCHIP_GPU_LIB_ENABLE 13 | 14 | ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \> 25))) 15 | LOCAL_CFLAGS += -DUSE_AHARDWAREBUFFER=1 16 | endif 17 | 18 | LOCAL_CFLAGS += -Wall -Werror -Wunreachable-code 19 | 20 | LOCAL_C_INCLUDES += \ 21 | $(LOCAL_PATH)/../.. \ 22 | $(LOCAL_PATH)/../../im2d_api \ 23 | $(LOCAL_PATH)/../../include 24 | 25 | LOCAL_SHARED_LIBRARIES := \ 26 | libcutils \ 27 | liblog \ 28 | libutils \ 29 | libui \ 30 | libEGL \ 31 | libGLESv1_CM \ 32 | libhardware \ 33 | librga \ 34 | libnativewindow 35 | 36 | LOCAL_HEADER_LIBRARIES += \ 37 | libutils_headers \ 38 | libcutils_headers \ 39 | libhardware_headers \ 40 | liblog_headers \ 41 | libgui_headers \ 42 | libbinder_headers 43 | 44 | #has no "external/stlport" from Android 6.0 on 45 | ifeq (1,$(strip $(shell expr $(PLATFORM_VERSION) \< 6.0))) 46 | LOCAL_C_INCLUDES += \ 47 | external/stlport/stlport 48 | 49 | LOCAL_C_INCLUDES += bionic 50 | endif 51 | 52 | #ifeq ($(strip $(BOARD_USE_DRM)), true) 53 | #ifneq (1,$(strip $(shell expr $(PLATFORM_VERSION) \< 6.9))) 54 | LOCAL_CFLAGS += -DANDROID_7_DRM -DANDROID 55 | #endif 56 | #endif 57 | 58 | ifeq ($(strip $(TARGET_BOARD_PLATFORM)),rk3368) 59 | LOCAL_CFLAGS += -DRK3368 60 | endif 61 | 62 | ifneq (1,$(strip $(shell expr $(PLATFORM_VERSION) \< 8.0))) 63 | LOCAL_CFLAGS += -DANDROID_8 64 | endif 65 | 66 | ifeq ($(strip $(TARGET_BOARD_PLATFORM)),rk3188) 67 | LOCAL_CFLAGS += -DRK3188 68 | endif 69 | 70 | LOCAL_SRC_FILES:= \ 71 | rgaImDemo.cpp \ 72 | args.cpp 73 | 74 | LOCAL_MODULE:= rgaImDemo 75 | 76 | ifdef TARGET_32_BIT_SURFACEFLINGER 77 | LOCAL_32_BIT_ONLY := true 78 | endif 79 | 80 | include $(BUILD_EXECUTABLE) 81 | 82 | -------------------------------------------------------------------------------- /samples/im2d_api_demo/README.md: -------------------------------------------------------------------------------- 1 | # librga IM2D API快速演示DEMO 2 | 3 | ​ librga IM2D API快速演示DEMO可以通过配置指令快速演示RGA功能。 4 | 5 | ## 编译说明 6 | 7 | ​ 本仓库示例代码支持CMAKE编译,可以通过修改toolchain_*.cmake文件以及编译脚本实现快速编译。 8 | 9 | ### 工具链修改 10 | 11 | - **Android NDK(build for android)** 12 | 13 | ​ 参考librga源码目录下**toolchains/toolchain_android_ndk.cmake**写法,修改NDK路径、Android版本信息等。 14 | 15 | | 工具链选项 | 描述 | 16 | | ----------------------------------- | -------------------------------------------- | 17 | | CMAKE_ANDROID_NDK | NDK编译包路径 | 18 | | CMAKE_SYSTEM_NAME | 平台名,默认为Android | 19 | | CMAKE_SYSTEM_VERSION | Android版本 | 20 | | CMAKE_ANDROID_ARCH_ABI | 处理器版本 | 21 | | CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION | 工具链选择(clang/gcc) | 22 | | CMAKE_ANDROID_STL_TYPE | NDK C++库的链接方式(c++_static/c++_shared) | 23 | 24 | - **Linux(buildroot/debian)** 25 | 26 | ​ 参考librga源码目录下**toolchains/toolchain_linux.cmake**写法,修改工具链路径、名称。 27 | 28 | | 工具链选项 | 描述 | 29 | | -------------- | ---------- | 30 | | TOOLCHAIN_HOME | 工具链目录 | 31 | | TOOLCHAIN_NAME | 工具链名称 | 32 | 33 | ### 编译脚本修改 34 | 35 | ​ 修改samples目录或需要编译的示例代码目录下**cmake_*.sh**,指定toolchain路径。 36 | 37 | | 编译选项 | 描述 | 38 | | -------------- | ------------------------------------------------------------ | 39 | | TOOLCHAIN_PATH | toolchain的绝对路径,即《工具链修改》小节中修改后的toolchain_*.cmake文件的绝对路径 | 40 | | LIBRGA_PATH | 需要链接的librga.so的绝对路径,默认为librga cmake编译时的默认打包路径 | 41 | | BUILD_DIR | 编译生成文件存放的相对路径 | 42 | 43 | ### 执行编译脚本 44 | 45 | - **Android NDK(build for android)** 46 | 47 | ```bash 48 | $ chmod +x ./cmake_android.sh 49 | $ ./cmake_android.sh 50 | ``` 51 | 52 | - **Linux(buildroot/debian)** 53 | 54 | ```bash 55 | $ chmod +x ./cmake_linux.sh 56 | $ ./cmake_linux.sh 57 | ``` 58 | 59 | ### 使用说明 60 | 61 | 62 | 见docs目录下《Rockchip_Developer_Guide_RGA_CN.md》——测试用例及调试方法 章节。 -------------------------------------------------------------------------------- /include/RgaSingleton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Zhiqin Wei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef _LIBS_RGA_SINGLETON_H 20 | #define _LIBS_RGA_SINGLETON_H 21 | 22 | #ifndef ANDROID 23 | #include "RgaMutex.h" 24 | 25 | #if defined(__clang__) 26 | #pragma clang diagnostic push 27 | #pragma clang diagnostic ignored "-Wundefined-var-template" 28 | #endif 29 | 30 | template 31 | class Singleton { 32 | public: 33 | static TYPE& getInstance() { 34 | Mutex::Autolock _l(sLock); 35 | TYPE* instance = sInstance; 36 | if (instance == nullptr) { 37 | instance = new TYPE(); 38 | sInstance = instance; 39 | } 40 | return *instance; 41 | } 42 | 43 | static bool hasInstance() { 44 | Mutex::Autolock _l(sLock); 45 | return sInstance != nullptr; 46 | } 47 | 48 | protected: 49 | ~Singleton() { } 50 | Singleton() { } 51 | 52 | private: 53 | Singleton(const Singleton&); 54 | Singleton& operator = (const Singleton&); 55 | static Mutex sLock; 56 | static TYPE* sInstance; 57 | }; 58 | 59 | #if defined(__clang__) 60 | #pragma clang diagnostic pop 61 | #endif 62 | 63 | #define RGA_SINGLETON_STATIC_INSTANCE(TYPE) \ 64 | template<> ::Mutex \ 65 | (::Singleton< TYPE >::sLock)(::Mutex::PRIVATE); \ 66 | template<> TYPE* ::Singleton< TYPE >::sInstance(nullptr); /* NOLINT */ \ 67 | template class ::Singleton< TYPE >; 68 | 69 | #endif //ANDROID 70 | #endif //_LIBS_RGA_SINGLETON_H 71 | -------------------------------------------------------------------------------- /samples/im2d_api_demo/args.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * PutinLee 5 | * Cerf Yu 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef ARGS_H 21 | #define ARGS_H 22 | 23 | #include "im2d.hpp" 24 | 25 | typedef enum _mode_code { 26 | MODE_QUERYSTRING = 0, 27 | MODE_COPY, 28 | MODE_RESIZE, 29 | MODE_CROP, 30 | MODE_ROTATE, 31 | MODE_FLIP, 32 | MODE_TRANSLATE, 33 | MODE_BLEND, 34 | MODE_CVTCOLOR, 35 | MODE_FILL, 36 | MODE_WHILE, 37 | MODE_NONE, 38 | MODE_MAX 39 | } MODE_CODE; 40 | 41 | #define MODE_QUERYSTRING_CHAR (char) (MODE_QUERYSTRING+'0') 42 | #define MODE_COPY_CHAR (char) (MODE_COPY +'0') 43 | #define MODE_RESIZE_CHAR (char) (MODE_RESIZE +'0') 44 | #define MODE_CROP_CHAR (char) (MODE_CROP +'0') 45 | #define MODE_ROTATE_CHAR (char) (MODE_ROTATE +'0') 46 | #define MODE_FLIP_CHAR (char) (MODE_FLIP +'0') 47 | #define MODE_TRANSLATE_CHAR (char) (MODE_TRANSLATE +'0') 48 | #define MODE_BLEND_CHAR (char) (MODE_BLEND +'0') 49 | #define MODE_CVTCOLOR_CHAR (char) (MODE_CVTCOLOR +'0') 50 | #define MODE_FILL_CHAR (char) (MODE_FILL +'0') 51 | #define MODE_NONE_CHAR (char) (MODE_NONE +'0') 52 | 53 | #define BLUE_COLOR 0xffff0000 54 | #define GREEN_COLOR 0xff00ff00 55 | #define RED_COLOR 0xff0000ff 56 | #define WHILE_FLAG (1 << 7) 57 | 58 | int readArguments(int argc, char *argv[], int* parm); 59 | IM_INFORMATION readInfo(char* targ); 60 | int readParm(char* targ); 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: linux-rga 3 | Source: https://github.com/rockchip-linux/linux-rga 4 | 5 | Files: * 6 | Copyright: 2016 Zhiqin Wei 7 | 2017 Putin Lee 8 | 2020 Yu Qiaowei 9 | License: Apache-2.0 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | . 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | . 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | . 22 | On Debian systems, the complete text of the Apache version 2.0 license 23 | can be found in "/usr/share/common-licenses/Apache-2.0". 24 | 25 | Files: debian/* 26 | Copyright: 2020 Jeffy Chen 27 | License: GPL-2+ 28 | This package is free software; you can redistribute it and/or modify 29 | it under the terms of the GNU General Public License as published by 30 | the Free Software Foundation; either version 2 of the License, or 31 | (at your option) any later version. 32 | . 33 | This package is distributed in the hope that it will be useful, 34 | but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36 | GNU General Public License for more details. 37 | . 38 | You should have received a copy of the GNU General Public License 39 | along with this program. If not, see 40 | . 41 | On Debian systems, the complete text of the GNU General 42 | Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". 43 | 44 | # Please also look if there are files or directories which have a 45 | # different copyright/license attached and list them here. 46 | # Please avoid picking licenses with terms that are more restrictive than the 47 | # packaged work, as it may make Debian's contributions unacceptable upstream. 48 | -------------------------------------------------------------------------------- /samples/im2d_api_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | project(rgaImDemo) 9 | 10 | if(NOT CMAKE_BUILD_TYPE) 11 | message("default to Release build for GCC builds") 12 | set(CMAKE_BUILD_TYPE Release CACHE STRING 13 | "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." 14 | FORCE) 15 | endif() 16 | 17 | if(CMAKE_BUILD_TARGET STREQUAL android_ndk) 18 | message("cmake build android ndk") 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-error -DLOG_TAG=librga") 20 | add_compile_options(-DLINUX) 21 | add_compile_options(-DANDROID_VNDK) 22 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 23 | endif() 24 | 25 | if(CMAKE_BUILD_TARGET STREQUAL buildroot) 26 | message("cmake build buildroot") 27 | set(CMAKE_CXX_FLAGS "-std=c++11 -O2 -pthread") 28 | add_compile_options(-DLINUX) 29 | endif() 30 | 31 | if(CMAKE_BUILD_TARGET STREQUAL cmake_linux) 32 | message("RGA build with cmake") 33 | add_compile_options(-DLINUX) 34 | # TO support pass external CMAKE_CXX_FLAGS 35 | set(CMAKE_CXX_FLAGS_EXT "-std=c++11 -O2 -pthread") 36 | 37 | if (NOT DEFINED CMAKE_C_COMPILER) 38 | message(FATAL_ERROR "RGA: CMAKE_C_COMPILER not define") 39 | endif() 40 | 41 | if (NOT DEFINED CMAKE_CXX_COMPILER) 42 | message(FATAL_ERROR "RGA: CMAKE_CXX_COMPILER not define") 43 | endif() 44 | 45 | endif() 46 | 47 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 48 | message("load ${LIBRGA_FILE_LIB}/librga.so") 49 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 50 | else () 51 | set(RGA_LIB rga) 52 | endif() 53 | 54 | #install path 55 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 56 | set(CMAKE_INSTALL_BINDIR bin) 57 | endif() 58 | 59 | set(IM2D_DEMO_NAME ${PROJECT_NAME}) 60 | set(IM2D_DEMO_SRCS 61 | args.cpp 62 | rgaImDemo.cpp) 63 | set(IM2D_DEMO_INCLUDE 64 | ./ 65 | ../../include 66 | ../../im2d_api) 67 | 68 | add_executable(${IM2D_DEMO_NAME} ${IM2D_DEMO_SRCS}) 69 | target_include_directories(${IM2D_DEMO_NAME} PUBLIC ${IM2D_DEMO_INCLUDE}) 70 | target_link_libraries(${IM2D_DEMO_NAME} ${RGA_LIB}) 71 | 72 | install(TARGETS ${IM2D_DEMO_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 73 | -------------------------------------------------------------------------------- /samples/allocator_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_allocator_malloc_demo 2 | add_executable(rga_allocator_malloc_demo 3 | rga_allocator_malloc_demo.cpp 4 | ) 5 | target_link_libraries(rga_allocator_malloc_demo 6 | utils_obj 7 | ${RGA_LIB} 8 | ) 9 | install(TARGETS rga_allocator_malloc_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 10 | 11 | if (TARGET_SOC STREQUAL "RV1106") 12 | # rga_allocator_dma32_demo 13 | add_executable(rga_allocator_1106_cma_demo 14 | rga_allocator_1106_cma_demo.cpp 15 | ) 16 | target_link_libraries(rga_allocator_1106_cma_demo 17 | utils_obj 18 | ${RGA_LIB} 19 | ) 20 | install(TARGETS rga_allocator_1106_cma_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 21 | else () 22 | # rga_allocator_drm_demo 23 | add_executable(rga_allocator_drm_demo 24 | rga_allocator_drm_demo.cpp 25 | ) 26 | target_link_libraries(rga_allocator_drm_demo 27 | utils_obj 28 | ${RGA_LIB} 29 | ) 30 | install(TARGETS rga_allocator_drm_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 31 | 32 | # rga_allocator_drm_phy_demo 33 | add_executable(rga_allocator_drm_phy_demo 34 | rga_allocator_drm_phy_demo.cpp 35 | ) 36 | target_link_libraries(rga_allocator_drm_phy_demo 37 | utils_obj 38 | ${RGA_LIB} 39 | ) 40 | install(TARGETS rga_allocator_drm_phy_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 41 | 42 | # rga_allocator_dma_demo 43 | add_executable(rga_allocator_dma_demo 44 | rga_allocator_dma_demo.cpp 45 | ) 46 | target_link_libraries(rga_allocator_dma_demo 47 | utils_obj 48 | ${RGA_LIB} 49 | ) 50 | install(TARGETS rga_allocator_dma_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 51 | 52 | # rga_allocator_dma_cache_demo 53 | add_executable(rga_allocator_dma_cache_demo 54 | rga_allocator_dma_cache_demo.cpp 55 | ) 56 | target_link_libraries(rga_allocator_dma_cache_demo 57 | utils_obj 58 | ${RGA_LIB} 59 | ) 60 | install(TARGETS rga_allocator_dma_cache_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 61 | 62 | # rga_allocator_dma32_demo 63 | add_executable(rga_allocator_dma32_demo 64 | rga_allocator_dma32_demo.cpp 65 | ) 66 | target_link_libraries(rga_allocator_dma32_demo 67 | utils_obj 68 | ${RGA_LIB} 69 | ) 70 | install(TARGETS rga_allocator_dma32_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 71 | endif() 72 | -------------------------------------------------------------------------------- /samples/im2d_slt/chip_config/rk3588_slt_config.h.template: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* im2d_slt config */ 20 | #define IM2D_SLT_THREAD_EN 1 /* Enable multi-threaded mode. */ 21 | #define IM2D_SLT_THREAD_MAX 10 /* Maximum number of threads. */ 22 | #define IM2D_SLT_WHILE_EN 1 /* Enable while mode, 1: while, 0 single. */ 23 | #define IM2D_SLT_WHILE_NUM 3 /* Number of while mode. */ 24 | 25 | #define IM2D_SLT_DRM_BUFFER_EN 0 /* Enable use drm buffer. */ 26 | #define IM2D_SLT_GRAPHICBUFFER_EN 1 /* Enable use GraphicBuffer. */ 27 | #define IM2D_SLT_BUFFER_CACHEABLE 0 /* Enable buffer cache. Only support GraphicBuffer. */ 28 | #define IM2D_SLT_BUFFER_PHY_EN 0 /* Enable physical memory. Only support drm buffer.*/ 29 | 30 | #define IM2D_SLT_TEST_RGA2_EN 1 /* Enable rga2 case. */ 31 | #define IM2D_SLT_TEST_RGA3_0_EN 1 /* Enable rga3_core0 case. */ 32 | #define IM2D_SLT_TEST_RGA3_1_EN 1 /* Enable rga3_core1 case. */ 33 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 1 /* Enable rga3_core0 fbc_mode case. */ 34 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 1 /* Enable rga3_core1 fbc_mode case. */ 35 | 36 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 37 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 38 | #if IM2D_SLT_GRAPHICBUFFER_EN 39 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 40 | #else 41 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 42 | #endif 43 | 44 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/data" 45 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/data" -------------------------------------------------------------------------------- /samples/im2d_slt/sources/slt_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* im2d_slt config */ 20 | #define IM2D_SLT_THREAD_EN 1 /* Enable multi-threaded mode. */ 21 | #define IM2D_SLT_THREAD_MAX 10 /* Maximum number of threads. */ 22 | #define IM2D_SLT_WHILE_EN 1 /* Enable while mode, 1: while, 0 single. */ 23 | #define IM2D_SLT_WHILE_NUM 3 /* Number of while mode. */ 24 | 25 | #define IM2D_SLT_DRM_BUFFER_EN 0 /* Enable use drm buffer. */ 26 | #define IM2D_SLT_GRAPHICBUFFER_EN 0 /* Enable use GraphicBuffer. */ 27 | #define IM2D_SLT_RK_DMA_HEAP_EN 1 /* Enable rk_dma_heap. Only rv1106. */ 28 | #define IM2D_SLT_BUFFER_CACHEABLE 0 /* Enable buffer cache. Only support GraphicBuffer. */ 29 | #define IM2D_SLT_BUFFER_PHY_EN 0 /* Enable physical memory. Only support drm buffer.*/ 30 | 31 | #define IM2D_SLT_TEST_RGA2_EN 1 /* Enable rga2 case. */ 32 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 33 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 34 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 fbc_mode case. */ 35 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 fbc_mode case. */ 36 | 37 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 38 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 39 | #if IM2D_SLT_GRAPHICBUFFER_EN 40 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 41 | #else 42 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 43 | #endif 44 | 45 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/userdata" 46 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/userdata" -------------------------------------------------------------------------------- /samples/im2d_slt/chip_config/rv1106_slt_config.h.template: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* im2d_slt config */ 20 | #define IM2D_SLT_THREAD_EN 1 /* Enable multi-threaded mode. */ 21 | #define IM2D_SLT_THREAD_MAX 10 /* Maximum number of threads. */ 22 | #define IM2D_SLT_WHILE_EN 1 /* Enable while mode, 1: while, 0 single. */ 23 | #define IM2D_SLT_WHILE_NUM 3 /* Number of while mode. */ 24 | 25 | #define IM2D_SLT_DRM_BUFFER_EN 0 /* Enable use drm buffer. */ 26 | #define IM2D_SLT_GRAPHICBUFFER_EN 0 /* Enable use GraphicBuffer. */ 27 | #define IM2D_SLT_RK_DMA_HEAP_EN 1 /* Enable rk_dma_heap. Only rv1106. */ 28 | #define IM2D_SLT_BUFFER_CACHEABLE 0 /* Enable buffer cache. Only support GraphicBuffer. */ 29 | #define IM2D_SLT_BUFFER_PHY_EN 0 /* Enable physical memory. Only support drm buffer.*/ 30 | 31 | #define IM2D_SLT_TEST_RGA2_EN 1 /* Enable rga2 case. */ 32 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 33 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 34 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 fbc_mode case. */ 35 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 fbc_mode case. */ 36 | 37 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 38 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 39 | #if IM2D_SLT_GRAPHICBUFFER_EN 40 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 41 | #else 42 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 43 | #endif 44 | 45 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/userdata" 46 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/userdata" -------------------------------------------------------------------------------- /samples/im2d_slt/chip_config/rk3528_rk3562_android_slt_config.h.template: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* im2d_slt config */ 20 | #define IM2D_SLT_THREAD_EN 1 /* Enable multi-threaded mode. */ 21 | #define IM2D_SLT_THREAD_MAX 10 /* Maximum number of threads. */ 22 | #define IM2D_SLT_WHILE_EN 1 /* Enable while mode, 1: while, 0 single. */ 23 | #define IM2D_SLT_WHILE_NUM 3 /* Number of while mode. */ 24 | 25 | #define IM2D_SLT_DRM_BUFFER_EN 0 /* Enable use drm buffer. */ 26 | #define IM2D_SLT_GRAPHICBUFFER_EN 1 /* Enable use GraphicBuffer. */ 27 | #define IM2D_SLT_RK_DMA_HEAP_EN 0 /* Enable rk_dma_heap. Only rv1106. */ 28 | #define IM2D_SLT_BUFFER_CACHEABLE 0 /* Enable buffer cache. Only support GraphicBuffer. */ 29 | #define IM2D_SLT_BUFFER_PHY_EN 0 /* Enable physical memory. Only support drm buffer.*/ 30 | 31 | #define IM2D_SLT_TEST_RGA2_EN 1 /* Enable rga2 case. */ 32 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 33 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 34 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 fbc_mode case. */ 35 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 fbc_mode case. */ 36 | 37 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 38 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 39 | #if IM2D_SLT_GRAPHICBUFFER_EN 40 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 41 | #else 42 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 43 | #endif 44 | 45 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/userdata" 46 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/userdata" -------------------------------------------------------------------------------- /include/RgaApi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Zhiqin Wei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _rockchip_rga_c_h_ 19 | #define _rockchip_rga_c_h_ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | #include "drmrga.h" 34 | #include "rga.h" 35 | 36 | #ifdef __cplusplus 37 | extern "C"{ 38 | #endif 39 | 40 | /* 41 | * Compatible with the old version of C interface.The new 42 | * version of the C interface no longer requires users to 43 | * initialize rga, so RgaInit and RgaDeInit are just for 44 | * compatibility with the old C interface, so please do 45 | * not use ctx, because it is usually a NULL. 46 | */ 47 | #define RgaInit(ctx) ({ \ 48 | int ret = 0; \ 49 | ret = c_RkRgaInit(); \ 50 | c_RkRgaGetContext(ctx); \ 51 | ret;\ 52 | }) 53 | #define RgaDeInit(ctx) { \ 54 | (void)ctx; /* unused */ \ 55 | c_RkRgaDeInit(); \ 56 | } 57 | #define RgaBlit(...) c_RkRgaBlit(__VA_ARGS__) 58 | #define RgaCollorFill(...) c_RkRgaColorFill(__VA_ARGS__) 59 | #define RgaFlush() c_RkRgaFlush() 60 | 61 | int c_RkRgaInit(); 62 | void c_RkRgaDeInit(); 63 | void c_RkRgaGetContext(void **ctx); 64 | int c_RkRgaBlit(rga_info_t *src, rga_info_t *dst, rga_info_t *src1); 65 | int c_RkRgaColorFill(rga_info_t *dst); 66 | int c_RkRgaFlush(); 67 | 68 | #ifndef ANDROID /* linux */ 69 | int c_RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp); 70 | int c_RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp); 71 | int c_RkRgaGetMmap(bo_t *bo_info); 72 | int c_RkRgaUnmap(bo_t *bo_info); 73 | int c_RkRgaFree(bo_t *bo_info); 74 | int c_RkRgaGetBufferFd(bo_t *bo_info, int *fd); 75 | #endif /* #ifndef ANDROID */ 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif /* #ifndef _rockchip_rga_c_h_ */ 82 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project( 2 | 'librga', 3 | 'cpp', 4 | version : '2.1.0', 5 | meson_version : '>=0.47.0', 6 | default_options : ['warning_level=3', 'cpp_std=c++14'] 7 | ) 8 | 9 | pkgconfig = import('pkgconfig') 10 | 11 | libthreads_dep = dependency('threads') 12 | 13 | add_project_arguments('-DLINUX=1', language : 'cpp') 14 | 15 | librga_srcs = [ 16 | 'core/utils/android_utils/src/android_utils.cpp', 17 | 'core/utils/drm_utils/src/drm_utils.cpp', 18 | 'core/utils/utils.cpp', 19 | 'core/GrallocOps.cpp', 20 | 'core/NormalRgaApi.cpp', 21 | 'core/NormalRga.cpp', 22 | 'core/RgaUtils.cpp', 23 | 'core/RockchipRga.cpp', 24 | 'core/RgaApi.cpp', 25 | 'core/rga_sync.cpp', 26 | 'im2d_api/src/im2d_log.cpp', 27 | 'im2d_api/src/im2d_impl.cpp', 28 | 'im2d_api/src/im2d.cpp', 29 | ] 30 | 31 | incdir = include_directories('include', 'im2d_api', 'core/hardware', 'core/utils', 'core/3rdparty/libdrm/include/drm') 32 | 33 | librga = shared_library( 34 | 'rga', 35 | librga_srcs, 36 | dependencies : [libthreads_dep], 37 | include_directories : incdir, 38 | version : meson.project_version(), 39 | cpp_args : ['-w'], 40 | install : true, 41 | ) 42 | 43 | install_headers( 44 | 'include/rga.h', 45 | 'include/drmrga.h', 46 | 'include/GrallocOps.h', 47 | 'include/RockchipRga.h', 48 | 'include/RgaMutex.h', 49 | 'include/RgaSingleton.h', 50 | 'include/RgaUtils.h', 51 | 'include/RgaApi.h', 52 | 'im2d_api/im2d.h', 53 | 'im2d_api/im2d.hpp', 54 | 'im2d_api/im2d_type.h', 55 | 'im2d_api/im2d_version.h', 56 | 'im2d_api/im2d_buffer.h', 57 | 'im2d_api/im2d_common.h', 58 | 'im2d_api/im2d_single.h', 59 | 'im2d_api/im2d_task.h', 60 | 'im2d_api/im2d_mpi.h', 61 | 'im2d_api/im2d_expand.h', 62 | subdir : 'rga', 63 | ) 64 | 65 | pkgconfig.generate( 66 | libraries : librga, 67 | filebase : 'librga', 68 | name : 'librga', 69 | version : meson.project_version(), 70 | description : 'Userspace interface to Rockchip RGA 2D accelerator', 71 | ) 72 | 73 | librga_demo_option = get_option('librga_demo') 74 | if librga_demo_option != 'false' 75 | demo_src = [ 76 | 'samples/im2d_api_demo/rgaImDemo.cpp', 77 | 'samples/im2d_api_demo/args.cpp' 78 | ] 79 | demo_incdir = include_directories('include', 'im2d_api') 80 | librga_dep = dependency('librga') 81 | executable( 82 | 'rgaImDemo', 83 | demo_src, 84 | include_directories : demo_incdir, 85 | dependencies : librga_dep, 86 | cpp_args : ['-Wno-pedantic'], 87 | install : true, 88 | ) 89 | endif 90 | -------------------------------------------------------------------------------- /core/RgaApi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Zhiqin Wei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "RgaApi.h" 20 | 21 | #include "RockchipRga.h" 22 | 23 | #ifdef ANDROID 24 | using namespace android; 25 | #endif 26 | 27 | int c_RkRgaInit() { 28 | return 0; 29 | } 30 | 31 | void c_RkRgaDeInit() {} 32 | 33 | void c_RkRgaGetContext(void **ctx) { 34 | RockchipRga& c_rkRga(RockchipRga::get()); 35 | 36 | c_rkRga.RkRgaGetContext(ctx); 37 | } 38 | 39 | int c_RkRgaBlit(rga_info_t *src, rga_info_t *dst, rga_info_t *src1) { 40 | RockchipRga& c_rkRga(RockchipRga::get()); 41 | 42 | return c_rkRga.RkRgaBlit(src, dst, src1); 43 | } 44 | 45 | int c_RkRgaColorFill(rga_info_t *dst) { 46 | RockchipRga& c_rkRga(RockchipRga::get()); 47 | 48 | return c_rkRga.RkRgaCollorFill(dst); 49 | } 50 | 51 | int c_RkRgaFlush() { 52 | RockchipRga& c_rkRga(RockchipRga::get()); 53 | 54 | return c_rkRga.RkRgaFlush(); 55 | } 56 | 57 | #ifndef ANDROID /* linux */ 58 | int c_RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp) { 59 | RockchipRga& c_rkRga(RockchipRga::get()); 60 | 61 | return c_rkRga.RkRgaGetAllocBuffer(bo_info, width, height, bpp); 62 | } 63 | 64 | int c_RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp) { 65 | RockchipRga& c_rkRga(RockchipRga::get()); 66 | 67 | return c_rkRga.RkRgaGetAllocBufferCache(bo_info, width, height, bpp); 68 | } 69 | 70 | int c_RkRgaGetMmap(bo_t *bo_info) { 71 | RockchipRga& c_rkRga(RockchipRga::get()); 72 | 73 | return c_rkRga.RkRgaGetMmap(bo_info); 74 | } 75 | 76 | int c_RkRgaUnmap(bo_t *bo_info) { 77 | RockchipRga& c_rkRga(RockchipRga::get()); 78 | 79 | return c_rkRga.RkRgaUnmap(bo_info); 80 | } 81 | 82 | int c_RkRgaFree(bo_t *bo_info) { 83 | RockchipRga& c_rkRga(RockchipRga::get()); 84 | 85 | return c_rkRga.RkRgaFree(bo_info); 86 | } 87 | 88 | int c_RkRgaGetBufferFd(bo_t *bo_info, int *fd) { 89 | RockchipRga& c_rkRga(RockchipRga::get()); 90 | 91 | return c_rkRga.RkRgaGetBufferFd(bo_info, fd); 92 | } 93 | #endif /* #ifndef Andorid */ 94 | 95 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | # librga IM2D API 示例代码说明 2 | 3 | ​ 该目录下为librga IM2D API示例代码,包含常见的图像缩放、裁剪、旋转、Blit、alpha混合等操作的示例代码。 4 | 5 | ## 目录说明 6 | 7 | ├── **im2d_api_demo**:IM2D API快速演示DEMO
8 | ├── **im2d_slt**:slt测试工具
9 | ├── **allocator_demo**:内存分配器相关示例代码
10 | ├── **alpha_demo**:alpha混合、叠加相关示例代码
11 | ├── **async_demo**:异步模式相关示例代码
12 | ├── **config_demo**:线程全局配置相关示例代码
13 | ├── **copy_demo**:图像搬运、拷贝相关示例代码
14 | ├── **crop_demo**:图像裁剪、拼接相关示例代码
15 | ├── **cvtcolor_demo**:图像格式转换、色域转换相关示例代码
16 | ├── **fill_demo**:图像填充、画框相关示例代码
17 | ├── **mosaic_demo**:马赛克遮盖相关示例代码
18 | ├── **padding_demo**:padding相关示例代码
19 | ├── **resize_demo**:图像缩放相关示例代码
20 | ├── **rop_demo**:ROP运算相关示例代码
21 | ├── **transform_demo**:图像变换相关示例代码
22 | ├── **utils**:示例代码中使用的第三方引用、通用工具代码
23 | └── **sample_file**:演示代码使用图像数据文件
24 | 25 | ## 编译说明 26 | 27 | ​ 本仓库示例代码支持CMAKE编译,可以通过修改toolchain_*.cmake文件以及编译脚本实现快速编译。 28 | 29 | ### 工具链修改 30 | 31 | - **Android NDK(build for android)** 32 | 33 | ​ 参考librga源码目录下**toolchains/toolchain_android_ndk.cmake**写法,修改NDK路径、Android版本信息等。 34 | 35 | | 工具链选项 | 描述 | 36 | | ----------------------------------- | -------------------------------------------- | 37 | | CMAKE_ANDROID_NDK | NDK编译包路径 | 38 | | CMAKE_SYSTEM_NAME | 平台名,默认为Android | 39 | | CMAKE_SYSTEM_VERSION | Android版本 | 40 | | CMAKE_ANDROID_ARCH_ABI | 处理器版本 | 41 | | CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION | 工具链选择(clang/gcc) | 42 | | CMAKE_ANDROID_STL_TYPE | NDK C++库的链接方式(c++_static/c++_shared) | 43 | 44 | - **Linux(buildroot/debian)** 45 | 46 | ​ 参考librga源码目录下**toolchains/toolchain_linux.cmake**写法,修改工具链路径、名称。 47 | 48 | | 工具链选项 | 描述 | 49 | | -------------- | ---------- | 50 | | TOOLCHAIN_HOME | 工具链目录 | 51 | | TOOLCHAIN_NAME | 工具链名称 | 52 | 53 | ### 编译脚本修改 54 | 55 | ​ 修改samples目录或需要编译的示例代码目录下**cmake_*.sh**,指定toolchain路径。 56 | 57 | | 编译选项 | 描述 | 58 | | -------------- | ------------------------------------------------------------ | 59 | | TOOLCHAIN_PATH | toolchain的绝对路径,即《工具链修改》小节中修改后的toolchain_*.cmake文件的绝对路径 | 60 | | LIBRGA_PATH | 需要链接的librga.so的绝对路径,默认为librga cmake编译时的默认打包路径 | 61 | | BUILD_DIR | 编译生成文件存放的相对路径 | 62 | 63 | ### 执行编译脚本 64 | 65 | - **Android NDK(build for android)** 66 | 67 | ```bash 68 | $ chmod +x ./cmake_android.sh 69 | $ ./cmake_android.sh 70 | ``` 71 | 72 | - **Linux(buildroot/debian)** 73 | 74 | ```bash 75 | $ chmod +x ./cmake_linux.sh 76 | $ ./cmake_linux.sh 77 | ``` 78 | 79 | -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/include/libdrm/sis_drm.h: -------------------------------------------------------------------------------- 1 | /* sis_drv.h -- Private header for sis driver -*- linux-c -*- */ 2 | /* 3 | * Copyright 2005 Eric Anholt 4 | * All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice (including the next 14 | * paragraph) shall be included in all copies or substantial portions of the 15 | * Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | */ 26 | 27 | #ifndef __SIS_DRM_H__ 28 | #define __SIS_DRM_H__ 29 | 30 | #include "drm.h" 31 | 32 | #if defined(__cplusplus) 33 | extern "C" { 34 | #endif 35 | 36 | /* SiS specific ioctls */ 37 | #define NOT_USED_0_3 38 | #define DRM_SIS_FB_ALLOC 0x04 39 | #define DRM_SIS_FB_FREE 0x05 40 | #define NOT_USED_6_12 41 | #define DRM_SIS_AGP_INIT 0x13 42 | #define DRM_SIS_AGP_ALLOC 0x14 43 | #define DRM_SIS_AGP_FREE 0x15 44 | #define DRM_SIS_FB_INIT 0x16 45 | 46 | #define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_FB_ALLOC, drm_sis_mem_t) 47 | #define DRM_IOCTL_SIS_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_FREE, drm_sis_mem_t) 48 | #define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_INIT, drm_sis_agp_t) 49 | #define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_ALLOC, drm_sis_mem_t) 50 | #define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_AGP_FREE, drm_sis_mem_t) 51 | #define DRM_IOCTL_SIS_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_INIT, drm_sis_fb_t) 52 | /* 53 | #define DRM_IOCTL_SIS_FLIP DRM_IOW( 0x48, drm_sis_flip_t) 54 | #define DRM_IOCTL_SIS_FLIP_INIT DRM_IO( 0x49) 55 | #define DRM_IOCTL_SIS_FLIP_FINAL DRM_IO( 0x50) 56 | */ 57 | 58 | typedef struct { 59 | int context; 60 | unsigned int offset; 61 | unsigned int size; 62 | unsigned long free; 63 | } drm_sis_mem_t; 64 | 65 | typedef struct { 66 | unsigned int offset, size; 67 | } drm_sis_agp_t; 68 | 69 | typedef struct { 70 | unsigned int offset, size; 71 | } drm_sis_fb_t; 72 | 73 | #if defined(__cplusplus) 74 | } 75 | #endif 76 | 77 | #endif /* __SIS_DRM_H__ */ 78 | -------------------------------------------------------------------------------- /im2d_api/im2d_mpi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _im2d_mpi_hpp_ 19 | #define _im2d_mpi_hpp_ 20 | 21 | #include "im2d_type.h" 22 | 23 | /** 24 | * Create and config an rga ctx for rockit-ko 25 | * 26 | * @param flags 27 | * Some configuration flags for this job 28 | * 29 | * @returns job id. 30 | */ 31 | IM_EXPORT_API im_ctx_id_t imbegin(uint32_t flags); 32 | 33 | /** 34 | * Cancel and delete an rga ctx for rockit-ko 35 | * 36 | * @param flags 37 | * Some configuration flags for this job 38 | * 39 | * @returns success or else negative error code. 40 | */ 41 | IM_EXPORT_API IM_STATUS imcancel(im_ctx_id_t id); 42 | 43 | /** 44 | * process for rockit-ko 45 | * 46 | * @param src 47 | * The input source image and is also the foreground image in blend. 48 | * @param dst 49 | * The output destination image and is also the foreground image in blend. 50 | * @param pat 51 | * The foreground image, or a LUT table. 52 | * @param srect 53 | * The rectangle on the src channel image that needs to be processed. 54 | * @param drect 55 | * The rectangle on the dst channel image that needs to be processed. 56 | * @param prect 57 | * The rectangle on the pat channel image that needs to be processed. 58 | * @param acquire_fence_fd 59 | * @param release_fence_fd 60 | * @param opt 61 | * The image processing options configuration. 62 | * @param usage 63 | * The image processing usage. 64 | * @param ctx_id 65 | * ctx id 66 | * 67 | * @returns success or else negative error code. 68 | */ 69 | #ifdef __cplusplus 70 | IM_API IM_STATUS improcess(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat, 71 | im_rect srect, im_rect drect, im_rect prect, 72 | int acquire_fence_fd, int *release_fence_fd, 73 | im_opt_t *opt, int usage, im_ctx_id_t ctx_id); 74 | #endif 75 | IM_EXPORT_API IM_STATUS improcess_ctx(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat, 76 | im_rect srect, im_rect drect, im_rect prect, 77 | int acquire_fence_fd, int *release_fence_fd, 78 | im_opt_t *opt, int usage, im_ctx_id_t ctx_id); 79 | 80 | #endif /* #ifndef _im2d_mpi_hpp_ */ -------------------------------------------------------------------------------- /samples/im2d_slt/third-party/libdrm/include/libdrm/sis_drm.h: -------------------------------------------------------------------------------- 1 | /* sis_drv.h -- Private header for sis driver -*- linux-c -*- */ 2 | /* 3 | * Copyright 2005 Eric Anholt 4 | * All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice (including the next 14 | * paragraph) shall be included in all copies or substantial portions of the 15 | * Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | */ 26 | 27 | #ifndef __SIS_DRM_H__ 28 | #define __SIS_DRM_H__ 29 | 30 | #include "drm.h" 31 | 32 | #if defined(__cplusplus) 33 | extern "C" { 34 | #endif 35 | 36 | /* SiS specific ioctls */ 37 | #define NOT_USED_0_3 38 | #define DRM_SIS_FB_ALLOC 0x04 39 | #define DRM_SIS_FB_FREE 0x05 40 | #define NOT_USED_6_12 41 | #define DRM_SIS_AGP_INIT 0x13 42 | #define DRM_SIS_AGP_ALLOC 0x14 43 | #define DRM_SIS_AGP_FREE 0x15 44 | #define DRM_SIS_FB_INIT 0x16 45 | 46 | #define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_FB_ALLOC, drm_sis_mem_t) 47 | #define DRM_IOCTL_SIS_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_FREE, drm_sis_mem_t) 48 | #define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_INIT, drm_sis_agp_t) 49 | #define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_ALLOC, drm_sis_mem_t) 50 | #define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_AGP_FREE, drm_sis_mem_t) 51 | #define DRM_IOCTL_SIS_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_INIT, drm_sis_fb_t) 52 | /* 53 | #define DRM_IOCTL_SIS_FLIP DRM_IOW( 0x48, drm_sis_flip_t) 54 | #define DRM_IOCTL_SIS_FLIP_INIT DRM_IO( 0x49) 55 | #define DRM_IOCTL_SIS_FLIP_FINAL DRM_IO( 0x50) 56 | */ 57 | 58 | typedef struct { 59 | int context; 60 | unsigned int offset; 61 | unsigned int size; 62 | unsigned long free; 63 | } drm_sis_mem_t; 64 | 65 | typedef struct { 66 | unsigned int offset, size; 67 | } drm_sis_agp_t; 68 | 69 | typedef struct { 70 | unsigned int offset, size; 71 | } drm_sis_fb_t; 72 | 73 | #if defined(__cplusplus) 74 | } 75 | #endif 76 | 77 | #endif /* __SIS_DRM_H__ */ 78 | -------------------------------------------------------------------------------- /samples/im2d_slt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | enable_testing() 3 | 4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 5 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 6 | 7 | message(${CMAKE_CURRENT_SOURCE_DIR}) 8 | 9 | if(NOT CMAKE_BUILD_TYPE) 10 | message("default to Release build for GCC builds") 11 | set(CMAKE_BUILD_TYPE Release CACHE STRING 12 | "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." 13 | FORCE) 14 | endif() 15 | 16 | ########################## 17 | # Command 18 | #execute_process(COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/version.sh) 19 | #execute_process(COMMAND ls) 20 | 21 | ########################## 22 | # Choose compilation method 23 | set(TOOL_CHAIN_DIR ${CMAKE_MODULE_PATH}) 24 | 25 | if(CMAKE_BUILD_TARGET STREQUAL android_ndk) 26 | message("set android_ndk toolchain") 27 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error -DLOG_TAG=librga") 28 | add_compile_options(-DLINUX) 29 | add_compile_options(-DANDROID) 30 | # add_compile_options(-DANDROID_VNDK) 31 | endif() 32 | 33 | if(CMAKE_BUILD_TARGET STREQUAL buildroot) 34 | message("set buildroot toolchain") 35 | set(CMAKE_TOOLCHAIN_FILE 36 | ${TOOL_CHAIN_DIR}/buildroot.cmake) 37 | include(${TOOL_CHAIN_DIR}/buildroot.cmake) 38 | add_compile_options(-DLINUX) 39 | set(CMAKE_CXX_FLAGS "-std=c++11 -O2 -pthread") 40 | endif() 41 | 42 | ########################## 43 | # Choose a third-party library 44 | if(CMAKE_BUILD_THIRD_PARTY STREQUAL drm) 45 | message("set third party drm") 46 | add_compile_options(-DLIBDRM=1) 47 | endif() 48 | #add_compile_options(-DRGA3=1) 49 | 50 | ########################## 51 | # Set project 52 | project(im2d_rga_slt) 53 | 54 | include_directories( 55 | ${CMAKE_CURRENT_SOURCE_DIR} 56 | ${CMAKE_CURRENT_SOURCE_DIR}/sources 57 | ${CMAKE_CURRENT_SOURCE_DIR}/../../ 58 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 59 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api 60 | ) 61 | 62 | if(CMAKE_BUILD_THIRD_PARTY STREQUAL drm) 63 | include_directories( 64 | ${CMAKE_CURRENT_SOURCE_DIR}/third-party/libdrm/include 65 | ${CMAKE_CURRENT_SOURCE_DIR}/third-party/libdrm/include/libdrm 66 | ) 67 | endif() 68 | 69 | set(IM2D_RGA_SLT_SRCS 70 | ${CMAKE_CURRENT_SOURCE_DIR}/sources/rga_im2d_slt.cpp 71 | ${CMAKE_CURRENT_SOURCE_DIR}/sources/dma_alloc.cpp 72 | ) 73 | if(CMAKE_BUILD_THIRD_PARTY STREQUAL drm) 74 | set(IM2D_RGA_SLT_SRCS 75 | ${CMAKE_CURRENT_SOURCE_DIR}/sources/drm_alloc.cpp 76 | ) 77 | endif() 78 | 79 | add_executable(im2d_slt ${IM2D_RGA_SLT_SRCS}) 80 | 81 | target_link_libraries(im2d_slt "-Wl,--allow-shlib-undefined" dl) 82 | target_link_libraries(im2d_slt ${CMAKE_CURRENT_SOURCE_DIR}/../../build_linux/install/lib/librga.so) 83 | 84 | if(CMAKE_BUILD_THIRD_PARTY STREQUAL drm) 85 | target_link_libraries(im2d_slt drm) 86 | endif() 87 | 88 | if(CMAKE_BUILD_TARGET STREQUAL ndk) 89 | string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 90 | endif() 91 | 92 | SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 93 | 94 | install(TARGETS im2d_slt RUNTIME DESTINATION bin) 95 | -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/include/libdrm/drm_sarea.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file drm_sarea.h 3 | * \brief SAREA definitions 4 | * 5 | * \author Michel Dänzer 6 | */ 7 | 8 | /* 9 | * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. 10 | * All Rights Reserved. 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining a 13 | * copy of this software and associated documentation files (the "Software"), 14 | * to deal in the Software without restriction, including without limitation 15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16 | * and/or sell copies of the Software, and to permit persons to whom the 17 | * Software is furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice (including the next 20 | * paragraph) shall be included in all copies or substantial portions of the 21 | * Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | * TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 27 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 28 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 29 | * OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | #ifndef _DRM_SAREA_H_ 33 | #define _DRM_SAREA_H_ 34 | 35 | #include "drm.h" 36 | 37 | #if defined(__cplusplus) 38 | extern "C" { 39 | #endif 40 | 41 | /* SAREA area needs to be at least a page */ 42 | #if defined(__alpha__) 43 | #define SAREA_MAX 0x2000U 44 | #elif defined(__mips__) 45 | #define SAREA_MAX 0x4000U 46 | #elif defined(__ia64__) 47 | #define SAREA_MAX 0x10000U /* 64kB */ 48 | #else 49 | /* Intel 830M driver needs at least 8k SAREA */ 50 | #define SAREA_MAX 0x2000U 51 | #endif 52 | 53 | /** Maximum number of drawables in the SAREA */ 54 | #define SAREA_MAX_DRAWABLES 256 55 | 56 | #define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000 57 | 58 | /** SAREA drawable */ 59 | struct drm_sarea_drawable { 60 | unsigned int stamp; 61 | unsigned int flags; 62 | }; 63 | 64 | /** SAREA frame */ 65 | struct drm_sarea_frame { 66 | unsigned int x; 67 | unsigned int y; 68 | unsigned int width; 69 | unsigned int height; 70 | unsigned int fullscreen; 71 | }; 72 | 73 | /** SAREA */ 74 | struct drm_sarea { 75 | /** first thing is always the DRM locking structure */ 76 | struct drm_hw_lock lock; 77 | /** \todo Use readers/writer lock for drm_sarea::drawable_lock */ 78 | struct drm_hw_lock drawable_lock; 79 | struct drm_sarea_drawable drawableTable[SAREA_MAX_DRAWABLES]; /**< drawables */ 80 | struct drm_sarea_frame frame; /**< frame */ 81 | drm_context_t dummy_context; 82 | }; 83 | 84 | typedef struct drm_sarea_drawable drm_sarea_drawable_t; 85 | typedef struct drm_sarea_frame drm_sarea_frame_t; 86 | typedef struct drm_sarea drm_sarea_t; 87 | 88 | #if defined(__cplusplus) 89 | } 90 | #endif 91 | 92 | #endif /* _DRM_SAREA_H_ */ 93 | -------------------------------------------------------------------------------- /im2d_api/src/im2d_log.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #ifndef __cplusplus 25 | # include 26 | #else 27 | # include 28 | # define _Atomic(X) std::atomic< X > 29 | using namespace std; 30 | #endif 31 | 32 | #ifdef ANDROID 33 | #include 34 | #include 35 | #endif 36 | 37 | #include "im2d_log.h" 38 | 39 | static int rga_log_property_get(void); 40 | static int rga_log_level_property_get(void); 41 | 42 | __thread char g_rga_err_str[IM_ERR_MSG_LEN] = "The current error message is empty!"; 43 | static atomic_int g_log_en = ATOMIC_VAR_INIT(rga_log_property_get()); 44 | static atomic_int g_log_level = ATOMIC_VAR_INIT(rga_log_level_property_get()); 45 | static size_t g_start_time = rga_get_current_time_ms(); 46 | 47 | int rga_error_msg_set(const char* format, ...) { 48 | int ret = 0; 49 | va_list ap; 50 | 51 | va_start(ap, format); 52 | ret = vsnprintf(g_rga_err_str, IM_ERR_MSG_LEN, format, ap); 53 | va_end(ap); 54 | 55 | return ret; 56 | } 57 | 58 | static int inline rga_log_property_get(void) { 59 | #ifdef ANDROID 60 | char level[PROP_VALUE_MAX]; 61 | __system_property_get("vendor.rga.log" ,level); 62 | #else 63 | char *level = getenv("ROCKCHIP_RGA_LOG"); 64 | if (level == nullptr) 65 | level = (char *)"0"; 66 | #endif 67 | 68 | return atoi(level); 69 | } 70 | 71 | static int inline rga_log_level_property_get(void) { 72 | #ifdef ANDROID 73 | char level[PROP_VALUE_MAX]; 74 | __system_property_get("vendor.rga.log_level" ,level); 75 | #else 76 | char *level = getenv("ROCKCHIP_RGA_LOG_LEVEL"); 77 | if (level == nullptr) 78 | level = (char *)"0"; 79 | #endif 80 | 81 | return atoi(level); 82 | } 83 | 84 | int rga_log_level_init(void) { 85 | return rga_log_level_get(); 86 | } 87 | 88 | void rga_log_level_update(void) { 89 | g_log_level = rga_log_level_get(); 90 | } 91 | 92 | int rga_log_level_get(void) { 93 | return g_log_level; 94 | } 95 | 96 | int rga_log_enable_get(void) { 97 | return g_log_en; 98 | } 99 | 100 | size_t rga_get_current_time_ms(void) { 101 | struct timeval tv; 102 | gettimeofday(&tv,NULL); 103 | return tv.tv_sec * 1000 + tv.tv_usec / 1000; 104 | } 105 | 106 | size_t rga_get_start_time_ms(void) { 107 | return g_start_time; 108 | } 109 | -------------------------------------------------------------------------------- /samples/im2d_slt/third-party/libdrm/include/libdrm/drm_sarea.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file drm_sarea.h 3 | * \brief SAREA definitions 4 | * 5 | * \author Michel Dänzer 6 | */ 7 | 8 | /* 9 | * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. 10 | * All Rights Reserved. 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining a 13 | * copy of this software and associated documentation files (the "Software"), 14 | * to deal in the Software without restriction, including without limitation 15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16 | * and/or sell copies of the Software, and to permit persons to whom the 17 | * Software is furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice (including the next 20 | * paragraph) shall be included in all copies or substantial portions of the 21 | * Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | * TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 27 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 28 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 29 | * OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | #ifndef _DRM_SAREA_H_ 33 | #define _DRM_SAREA_H_ 34 | 35 | #include "drm.h" 36 | 37 | #if defined(__cplusplus) 38 | extern "C" { 39 | #endif 40 | 41 | /* SAREA area needs to be at least a page */ 42 | #if defined(__alpha__) 43 | #define SAREA_MAX 0x2000U 44 | #elif defined(__mips__) 45 | #define SAREA_MAX 0x4000U 46 | #elif defined(__ia64__) 47 | #define SAREA_MAX 0x10000U /* 64kB */ 48 | #else 49 | /* Intel 830M driver needs at least 8k SAREA */ 50 | #define SAREA_MAX 0x2000U 51 | #endif 52 | 53 | /** Maximum number of drawables in the SAREA */ 54 | #define SAREA_MAX_DRAWABLES 256 55 | 56 | #define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000 57 | 58 | /** SAREA drawable */ 59 | struct drm_sarea_drawable { 60 | unsigned int stamp; 61 | unsigned int flags; 62 | }; 63 | 64 | /** SAREA frame */ 65 | struct drm_sarea_frame { 66 | unsigned int x; 67 | unsigned int y; 68 | unsigned int width; 69 | unsigned int height; 70 | unsigned int fullscreen; 71 | }; 72 | 73 | /** SAREA */ 74 | struct drm_sarea { 75 | /** first thing is always the DRM locking structure */ 76 | struct drm_hw_lock lock; 77 | /** \todo Use readers/writer lock for drm_sarea::drawable_lock */ 78 | struct drm_hw_lock drawable_lock; 79 | struct drm_sarea_drawable drawableTable[SAREA_MAX_DRAWABLES]; /**< drawables */ 80 | struct drm_sarea_frame frame; /**< frame */ 81 | drm_context_t dummy_context; 82 | }; 83 | 84 | typedef struct drm_sarea_drawable drm_sarea_drawable_t; 85 | typedef struct drm_sarea_frame drm_sarea_frame_t; 86 | typedef struct drm_sarea drm_sarea_t; 87 | 88 | #if defined(__cplusplus) 89 | } 90 | #endif 91 | 92 | #endif /* _DRM_SAREA_H_ */ 93 | -------------------------------------------------------------------------------- /core/utils/android_utils/src/android_utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #include "rga.h" 23 | 24 | #ifdef ANDROID 25 | #include 26 | #include 27 | 28 | #ifdef ANDROID_12 29 | #include 30 | #endif 31 | 32 | const static std::unordered_map android_hal_table = { 33 | // { , RK_FORMAT_ABGR_8888 }, 34 | // { , RK_FORMAT_ARGB_8888 }, 35 | { HAL_PIXEL_FORMAT_BGRA_8888, RK_FORMAT_BGRA_8888 }, 36 | { HAL_PIXEL_FORMAT_RGBA_8888, RK_FORMAT_RGBA_8888 }, 37 | // { , RK_FORMAT_XBGR_8888 }, 38 | // { , RK_FORMAT_XRGB_8888 }, 39 | // { , RK_FORMAT_BGRX_8888 }, 40 | { HAL_PIXEL_FORMAT_RGBX_8888, RK_FORMAT_RGBX_8888 }, 41 | 42 | // { , RK_FORMAT_ABGR_5551 }, 43 | // { , RK_FORMAT_ARGB_5551 }, 44 | // { , RK_FORMAT_BGRA_5551 }, 45 | // { , RK_FORMAT_RGBA_5551 }, 46 | // { , RK_FORMAT_ABGR_4444 }, 47 | // { , RK_FORMAT_ARGB_4444 }, 48 | // { , RK_FORMAT_BGRA_4444 }, 49 | // { , RK_FORMAT_RGBA_4444 }, 50 | 51 | // { , RK_FORMAT_BGR_888 }, 52 | { HAL_PIXEL_FORMAT_RGB_888, RK_FORMAT_RGB_888 }, 53 | // { , RK_FORMAT_BGR_565 }, 54 | { HAL_PIXEL_FORMAT_RGB_565, RK_FORMAT_RGB_565 }, 55 | 56 | // { , RK_FORMAT_YCbCr_422_SP }, 57 | // { , RK_FORMAT_YCrCb_422_SP }, 58 | // { , RK_FORMAT_YCbCr_422_P }, 59 | // { , RK_FORMAT_YCrCb_422_P }, 60 | // { , RK_FORMAT_YCbCr_422_SP_10B }, 61 | // { , RK_FORMAT_YCrCb_422_SP_10B }, 62 | { HAL_PIXEL_FORMAT_YCrCb_NV12, RK_FORMAT_YCbCr_420_SP }, 63 | { HAL_PIXEL_FORMAT_YCrCb_420_SP, RK_FORMAT_YCrCb_420_SP }, 64 | // { , RK_FORMAT_YCbCr_420_P }, 65 | // { , RK_FORMAT_YCrCb_420_P }, 66 | { HAL_PIXEL_FORMAT_YCrCb_NV12_10, RK_FORMAT_YCbCr_420_SP_10B }, 67 | // { , RK_FORMAT_YCrCb_420_SP_10B }, 68 | 69 | // { , RK_FORMAT_YUYV_422 }, 70 | // { , RK_FORMAT_YVYU_422 }, 71 | // { , RK_FORMAT_UYVY_422 }, 72 | // { , RK_FORMAT_VYUY_422 }, 73 | // { , RK_FORMAT_YUYV_420 }, 74 | // { , RK_FORMAT_YVYU_420 }, 75 | // { , RK_FORMAT_UYVY_420 }, 76 | // { , RK_FORMAT_VYUY_420 }, 77 | 78 | // { , RK_FORMAT_Y4 }, 79 | // { , RK_FORMAT_YCbCr_400 }, 80 | 81 | // { , RK_FORMAT_BPP1 }, 82 | // { , RK_FORMAT_BPP2 }, 83 | // { , RK_FORMAT_BPP4 }, 84 | // { , RK_FORMAT_BPP8 }, 85 | // { , RK_FORMAT_RGBA2BPP }, 86 | // { , RK_FORMAT_UNKNOWN }, 87 | }; 88 | #else 89 | const static std::unordered_map android_hal_table; 90 | #endif 91 | 92 | uint32_t get_format_from_android_hal(uint32_t android_hal_format) { 93 | auto entry = android_hal_table.find(android_hal_format); 94 | if (entry == android_hal_table.end()) 95 | return RK_FORMAT_UNKNOWN; 96 | 97 | return entry->second; 98 | } 99 | -------------------------------------------------------------------------------- /samples/mosaic_demo/src/rga_mosaic_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_mosaic_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "im2d.h" 34 | #include "RgaUtils.h" 35 | 36 | #include "utils.h" 37 | 38 | #define LOCAL_FILE_PATH "/data" 39 | 40 | int main(void) { 41 | int ret = 0; 42 | int64_t ts; 43 | int dst_width, dst_height, dst_format; 44 | int dst_buf_size; 45 | char *dst_buf; 46 | rga_buffer_t dst = {}; 47 | im_rect dst_rect = {}; 48 | rga_buffer_handle_t dst_handle; 49 | 50 | dst_width = 1280; 51 | dst_height = 720; 52 | dst_format = RK_FORMAT_RGBA_8888; 53 | 54 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 55 | 56 | dst_buf = (char *)malloc(dst_buf_size); 57 | 58 | /* fill image data */ 59 | if (0 != read_image_from_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0)) { 60 | printf("dst image write err\n"); 61 | draw_rgba(dst_buf, dst_width, dst_height); 62 | } 63 | 64 | dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size); 65 | if (dst_handle == 0) { 66 | printf("importbuffer failed!\n"); 67 | ret = -1; 68 | goto free_buf; 69 | } 70 | 71 | dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 72 | 73 | /* 74 | * mosaic a rectangular area on the dst image. 75 | dst_image 76 | -------------- 77 | | -------- | 78 | | |mosaic| | 79 | | -------- | 80 | -------------- 81 | */ 82 | 83 | dst_rect.x = 0; 84 | dst_rect.y = 0; 85 | dst_rect.width = 300; 86 | dst_rect.height = 200; 87 | 88 | ret = imcheck({}, dst, {}, dst_rect, IM_MOSAIC); 89 | if (IM_STATUS_NOERROR != ret) { 90 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 91 | goto release_buffer; 92 | } 93 | 94 | ret = immosaic(dst, dst_rect, IM_MOSAIC_32); 95 | if (ret == IM_STATUS_SUCCESS) { 96 | printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts); 97 | } else { 98 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 99 | goto release_buffer; 100 | } 101 | 102 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 103 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 104 | 105 | release_buffer: 106 | if (dst_handle > 0) 107 | releasebuffer_handle(dst_handle); 108 | 109 | free_buf: 110 | if (dst_buf) 111 | free(dst_buf); 112 | 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /core/utils/drm_utils/src/drm_utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "drm_fourcc.h" 22 | 23 | #include "rga.h" 24 | 25 | enum format_colormodel 26 | { 27 | rgb, 28 | yuv, 29 | }; 30 | 31 | struct table_entry 32 | { 33 | uint32_t fourcc; 34 | format_colormodel colormodel; 35 | }; 36 | 37 | const static std::unordered_map drm_fourcc_table = { 38 | { DRM_FORMAT_RGBA8888, RK_FORMAT_ABGR_8888 }, 39 | { DRM_FORMAT_BGRA8888, RK_FORMAT_ARGB_8888 }, 40 | { DRM_FORMAT_ARGB8888, RK_FORMAT_BGRA_8888 }, 41 | { DRM_FORMAT_ABGR8888, RK_FORMAT_RGBA_8888 }, 42 | { DRM_FORMAT_RGBX8888, RK_FORMAT_XBGR_8888 }, 43 | { DRM_FORMAT_BGRX8888, RK_FORMAT_XRGB_8888 }, 44 | { DRM_FORMAT_XRGB8888, RK_FORMAT_BGRX_8888 }, 45 | { DRM_FORMAT_XBGR8888, RK_FORMAT_RGBX_8888 }, 46 | 47 | { DRM_FORMAT_RGBA5551, RK_FORMAT_ABGR_5551 }, 48 | { DRM_FORMAT_BGRA5551, RK_FORMAT_ARGB_5551 }, 49 | { DRM_FORMAT_ARGB1555, RK_FORMAT_BGRA_5551 }, 50 | { DRM_FORMAT_ABGR1555, RK_FORMAT_RGBA_5551 }, 51 | { DRM_FORMAT_RGBA4444, RK_FORMAT_ABGR_4444 }, 52 | { DRM_FORMAT_BGRA4444, RK_FORMAT_ARGB_4444 }, 53 | { DRM_FORMAT_ARGB4444, RK_FORMAT_BGRA_4444 }, 54 | { DRM_FORMAT_ABGR4444, RK_FORMAT_RGBA_4444 }, 55 | 56 | { DRM_FORMAT_RGB888, RK_FORMAT_BGR_888 }, 57 | { DRM_FORMAT_BGR888, RK_FORMAT_RGB_888 }, 58 | { DRM_FORMAT_RGB565, RK_FORMAT_BGR_565 }, 59 | { DRM_FORMAT_BGR565, RK_FORMAT_RGB_565 }, 60 | 61 | { DRM_FORMAT_NV16, RK_FORMAT_YCbCr_422_SP }, 62 | { DRM_FORMAT_NV61, RK_FORMAT_YCrCb_422_SP }, 63 | { DRM_FORMAT_YUV422, RK_FORMAT_YCbCr_422_P }, 64 | { DRM_FORMAT_YVU422, RK_FORMAT_YCrCb_422_P }, 65 | // { , RK_FORMAT_YCbCr_422_SP_10B }, 66 | // { , RK_FORMAT_YCrCb_422_SP_10B }, 67 | { DRM_FORMAT_NV12, RK_FORMAT_YCbCr_420_SP }, 68 | { DRM_FORMAT_NV21, RK_FORMAT_YCrCb_420_SP }, 69 | { DRM_FORMAT_YUV420, RK_FORMAT_YCbCr_420_P }, 70 | { DRM_FORMAT_YVU420, RK_FORMAT_YCrCb_420_P }, 71 | { DRM_FORMAT_NV15, RK_FORMAT_YCbCr_420_SP_10B }, 72 | // { , RK_FORMAT_YCrCb_420_SP_10B }, 73 | 74 | { DRM_FORMAT_YUYV, RK_FORMAT_YUYV_422 }, 75 | { DRM_FORMAT_YVYU, RK_FORMAT_YVYU_422 }, 76 | { DRM_FORMAT_UYVY, RK_FORMAT_UYVY_422 }, 77 | { DRM_FORMAT_VYUY, RK_FORMAT_VYUY_422 }, 78 | // { , RK_FORMAT_YUYV_420 }, 79 | // { , RK_FORMAT_YVYU_420 }, 80 | // { , RK_FORMAT_UYVY_420 }, 81 | // { , RK_FORMAT_VYUY_420 }, 82 | 83 | // { , RK_FORMAT_Y4 }, 84 | // { , RK_FORMAT_YCbCr_400 }, 85 | 86 | // { , RK_FORMAT_BPP1 }, 87 | // { , RK_FORMAT_BPP2 }, 88 | // { , RK_FORMAT_BPP4 }, 89 | // { , RK_FORMAT_BPP8 }, 90 | // { , RK_FORMAT_RGBA2BPP }, 91 | { DRM_FORMAT_INVALID, RK_FORMAT_UNKNOWN }, 92 | }; 93 | 94 | uint32_t get_format_from_drm_fourcc(uint32_t drm_fourcc) { 95 | auto entry = drm_fourcc_table.find(drm_fourcc); 96 | if (entry == drm_fourcc_table.end()) 97 | return RK_FORMAT_UNKNOWN; 98 | 99 | return entry->second; 100 | } 101 | -------------------------------------------------------------------------------- /samples/allocator_demo/src/rga_allocator_dma32_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_allocator_dma32_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "im2d.h" 34 | #include "RgaUtils.h" 35 | 36 | #include "utils.h" 37 | #include "dma_alloc.h" 38 | 39 | #define LOCAL_FILE_PATH "/data" 40 | 41 | int main(void) { 42 | int ret = 0; 43 | int64_t ts; 44 | int dst_width, dst_height, dst_format; 45 | int dst_buf_size; 46 | char *dst_buf; 47 | int dst_dma_fd; 48 | rga_buffer_t dst = {}; 49 | im_rect dst_rect = {}; 50 | rga_buffer_handle_t dst_handle; 51 | 52 | dst_width = 1280; 53 | dst_height = 720; 54 | dst_format = RK_FORMAT_RGBA_8888; 55 | 56 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 57 | 58 | /* 59 | * Allocate dma_buf within 4G from dma32_heap, 60 | * return dma_fd and virtual address. 61 | */ 62 | ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHE_PATCH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf); 63 | if (ret < 0) { 64 | printf("alloc dma32_heap buffer failed!\n"); 65 | return -1; 66 | } 67 | 68 | memset(dst_buf, 0x33, dst_buf_size); 69 | 70 | /* 71 | * Import the allocated dma_fd into RGA by calling 72 | * importbuffer_fd, and use the returned buffer_handle 73 | * to call RGA to process the image. 74 | */ 75 | dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size); 76 | if (dst_handle == 0) { 77 | printf("import dma_fd error!\n"); 78 | ret = -1; 79 | goto free_buf; 80 | } 81 | 82 | dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 83 | 84 | dst_rect.x = 0; 85 | dst_rect.y = 0; 86 | dst_rect.width = 300; 87 | dst_rect.height = 200; 88 | 89 | ret = imcheck({}, dst, {}, dst_rect, IM_COLOR_FILL); 90 | if (IM_STATUS_NOERROR != ret) { 91 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 92 | goto release_buffer; 93 | } 94 | 95 | ts = get_cur_us(); 96 | 97 | ret = imfill(dst, dst_rect, 0xff00ff00); 98 | if (ret == IM_STATUS_SUCCESS) { 99 | printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts); 100 | } else { 101 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 102 | goto release_buffer; 103 | } 104 | 105 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 106 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 107 | 108 | release_buffer: 109 | if (dst_handle > 0) 110 | releasebuffer_handle(dst_handle); 111 | 112 | free_buf: 113 | dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf); 114 | 115 | return 0; 116 | } 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # librga 2 | 3 | RGA (Raster Graphic Acceleration Unit)是一个独立的2D硬件加速器,可用于加速点/线绘制,执行图像缩放、旋转、bitBlt、alpha混合等常见的2D图形操作。本仓库代码实现了RGA用户空间驱动,并提供了一系列2D图形操作API。 4 | 5 | ## 版本说明 6 | 7 | **RGA API** 版本: 1.9.2 8 | 9 | ## 适用芯片平台 10 | 11 | Rockchip RK3066 | RK3188 | RK2926 | RK2928 | RK3026 | RK3028 | RK3128 | Sofia3gr | RK3288 | RK3288w | RK3190 | RK1108 | RK3368 | RK3326 | RK3228 | RK3228H | RK3326 | RK1808 | RV1126 | RV1109 | RK3399 | RK3399pro | RK3566 | RK3568 | RK3588 | RK3326S | RV1106 | RV1103 | RK3528 | RK3562 12 | 13 | ## 目录说明 14 | 15 | ├── **im2d_api**:RGA API相关实现及头文件
16 | ├── **include**:RGA硬件相关头文件
17 | ├── **core**:RGA用户空间驱动实现
18 | ├── **docs**:FAQ以及API说明文档
19 | ├── **samples**:示例代码
20 | ├── **toolchains**:示例工具链配置文件
21 | └──其余编译相关文件
22 | 23 | ## 编译说明 24 | 25 | ### Android Source Project 26 | 27 | ​ 下载librga仓库拷贝至android源码工程 hardware/rockchip目录,配置好编译环境后,执行**mm**进行编译,根据不同的Android版本将自动选择Android.mk或Android.bp作为编译脚本。 28 | 29 | ```bash 30 | $ mm -j16 31 | ``` 32 | 33 | ### CMAKE 34 | 35 | ​ 本仓库示例代码支持CMAKE编译,可以通过修改toolchain_*.cmake文件以及编译脚本实现快速编译。 36 | 37 | #### 工具链修改 38 | 39 | - **Android NDK(build for android)** 40 | 41 | ​ 参考librga源码目录下**toolchains/toolchain_android_ndk.cmake**写法,修改NDK路径、Android版本信息等。 42 | 43 | | 工具链选项 | 描述 | 44 | | ----------------------------------- | -------------------------------------------- | 45 | | CMAKE_ANDROID_NDK | NDK编译包路径 | 46 | | CMAKE_SYSTEM_NAME | 平台名,默认为Android | 47 | | CMAKE_SYSTEM_VERSION | Android版本 | 48 | | CMAKE_ANDROID_ARCH_ABI | 处理器版本 | 49 | | CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION | 工具链选择(clang/gcc) | 50 | | CMAKE_ANDROID_STL_TYPE | NDK C++库的链接方式(c++_static/c++_shared) | 51 | 52 | - **Linux(buildroot/debian)** 53 | 54 | ​ 参考librga源码目录下**toolchains/toolchain_linux.cmake**写法,修改工具链路径、名称。 55 | 56 | | 工具链选项 | 描述 | 57 | | -------------- | ---------- | 58 | | TOOLCHAIN_HOME | 工具链目录 | 59 | | TOOLCHAIN_NAME | 工具链名称 | 60 | 61 | #### 编译脚本修改 62 | 63 | ​ 修改samples目录或需要编译的示例代码目录下**cmake_*.sh**,指定toolchain路径。 64 | 65 | | 编译选项 | 描述 | 66 | | -------------- | ------------------------------------------------------------ | 67 | | TOOLCHAIN_PATH | toolchain的绝对路径,即《工具链修改》小节中修改后的toolchain_*.cmake文件的绝对路径 | 68 | | LIBRGA_PATH | 需要链接的librga.so的绝对路径,默认为librga cmake编译时的默认打包路径 | 69 | | BUILD_DIR | 编译生成文件存放的相对路径 | 70 | 71 | #### 执行编译脚本 72 | 73 | - **Android NDK(build for android)** 74 | 75 | ```bash 76 | $ chmod +x ./cmake_android.sh 77 | $ ./cmake_android.sh 78 | ``` 79 | 80 | - **Linux(buildroot/debian)** 81 | 82 | ```bash 83 | $ chmod +x ./cmake_linux.sh 84 | $ ./cmake_linux.sh 85 | ``` 86 | 87 | ### Meson 88 | 89 | ​ 本仓库提供了meson.build,buildroot/debian支持meson编译。单独编译可以使用meson.sh 脚本进行config,需要自行修改meson.sh 内指定install 路径,以及PATH等环境变量,cross目录下是交叉编译工具配置文件,也需要自行修改为对应交叉编译工具路径。 90 | 91 | ​ 执行以下操作完成编译: 92 | 93 | ```bash 94 | $ ./meson.sh 95 | ``` 96 | 97 | ## 使用说明 98 | 99 | * **头文件引用** 100 | 101 | * C++调用im2d api 102 | 103 | im2d_api/im2d.hpp 104 | 105 | * C调用im2d api 106 | 107 | im2d_api/im2d.h 108 | 109 | * **库文件** 110 | 111 | librga.so 112 | 113 | librga.a 114 | 115 | * **librga应用开发接口说明文档** 116 | 117 | [IM2D API说明文档【中文】](docs/Rockchip_Developer_Guide_RGA_CN.md) 118 | 119 | [IM2D API说明文档【英文】](docs/Rockchip_Developer_Guide_RGA_EN.md) 120 | 121 | * **RGA模块FAQ文档** 122 | 123 | [RGA_FAQ【中文】](docs/Rockchip_FAQ_RGA_CN.md) 124 | 125 | [RGA_FAQ【英文】](docs/Rockchip_FAQ_RGA_EN.md) 126 | 127 | -------------------------------------------------------------------------------- /samples/cvtcolor_demo/src/rga_cvtcolor_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_cvtcolor_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "RgaUtils.h" 39 | #include "im2d.hpp" 40 | 41 | #include "utils.h" 42 | 43 | #define LOCAL_FILE_PATH "/data" 44 | 45 | int main() { 46 | int ret = 0; 47 | int src_width, src_height, src_format; 48 | int dst_width, dst_height, dst_format; 49 | char *src_buf, *dst_buf; 50 | int src_buf_size, dst_buf_size; 51 | 52 | rga_buffer_t src_img, dst_img; 53 | rga_buffer_handle_t src_handle, dst_handle; 54 | 55 | memset(&src_img, 0, sizeof(src_img)); 56 | memset(&dst_img, 0, sizeof(dst_img)); 57 | 58 | src_width = 1280; 59 | src_height = 720; 60 | src_format = RK_FORMAT_RGBA_8888; 61 | 62 | dst_width = 1280; 63 | dst_height = 720; 64 | dst_format = RK_FORMAT_RGB_565; 65 | 66 | src_buf_size = src_width * src_height * get_bpp_from_format(src_format); 67 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 68 | 69 | src_buf = (char *)malloc(src_buf_size); 70 | dst_buf = (char *)malloc(dst_buf_size); 71 | 72 | /* fill image data */ 73 | if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) { 74 | printf("src image read err\n"); 75 | memset(src_buf, 0xaa, src_buf_size); 76 | } 77 | memset(dst_buf, 0x80, dst_buf_size); 78 | 79 | src_handle = importbuffer_virtualaddr(src_buf, src_buf_size); 80 | dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size); 81 | if (src_handle == 0 || dst_handle == 0) { 82 | printf("importbuffer failed!\n"); 83 | goto release_buffer; 84 | } 85 | 86 | src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format); 87 | dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 88 | 89 | ret = imcheck(src_img, dst_img, {}, {}); 90 | if (IM_STATUS_NOERROR != ret) { 91 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 92 | return -1; 93 | } 94 | 95 | ret = imcvtcolor(src_img, dst_img, src_format, dst_format); 96 | if (ret == IM_STATUS_SUCCESS) { 97 | printf("%s running success!\n", LOG_TAG); 98 | } else { 99 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 100 | goto release_buffer; 101 | } 102 | 103 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 104 | 105 | release_buffer: 106 | if (src_handle) 107 | releasebuffer_handle(src_handle); 108 | if (dst_handle) 109 | releasebuffer_handle(dst_handle); 110 | 111 | if (src_buf) 112 | free(src_buf); 113 | if (dst_buf) 114 | free(dst_buf); 115 | 116 | return ret; 117 | } 118 | -------------------------------------------------------------------------------- /samples/cvtcolor_demo/src/rga_cvtcolor_csc_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_cvtcolor_csc_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "RgaUtils.h" 39 | #include "im2d.hpp" 40 | 41 | #include "utils.h" 42 | 43 | #define LOCAL_FILE_PATH "/data" 44 | 45 | int main() { 46 | int ret = 0; 47 | int src_width, src_height, src_format; 48 | int dst_width, dst_height, dst_format; 49 | char *src_buf, *dst_buf; 50 | int src_buf_size, dst_buf_size; 51 | 52 | rga_buffer_t src_img, dst_img; 53 | rga_buffer_handle_t src_handle, dst_handle; 54 | 55 | memset(&src_img, 0, sizeof(src_img)); 56 | memset(&dst_img, 0, sizeof(dst_img)); 57 | 58 | src_width = 1280; 59 | src_height = 720; 60 | src_format = RK_FORMAT_RGBA_8888; 61 | 62 | dst_width = 1280; 63 | dst_height = 720; 64 | dst_format = RK_FORMAT_YCbCr_420_SP; 65 | 66 | src_buf_size = src_width * src_height * get_bpp_from_format(src_format); 67 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 68 | 69 | src_buf = (char *)malloc(src_buf_size); 70 | dst_buf = (char *)malloc(dst_buf_size); 71 | 72 | /* fill image data */ 73 | if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) { 74 | printf("src image read err\n"); 75 | memset(src_buf, 0xaa, src_buf_size); 76 | } 77 | memset(dst_buf, 0x80, dst_buf_size); 78 | 79 | src_handle = importbuffer_virtualaddr(src_buf, src_buf_size); 80 | dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size); 81 | if (src_handle == 0 || dst_handle == 0) { 82 | printf("importbuffer failed!\n"); 83 | goto release_buffer; 84 | } 85 | 86 | src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format); 87 | dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 88 | 89 | ret = imcheck(src_img, dst_img, {}, {}); 90 | if (IM_STATUS_NOERROR != ret) { 91 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 92 | return -1; 93 | } 94 | 95 | ret = imcvtcolor(src_img, dst_img, src_format, dst_format, IM_RGB_TO_YUV_BT709_LIMIT); 96 | if (ret == IM_STATUS_SUCCESS) { 97 | printf("%s running success!\n", LOG_TAG); 98 | } else { 99 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 100 | goto release_buffer; 101 | } 102 | 103 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 104 | 105 | release_buffer: 106 | if (src_handle) 107 | releasebuffer_handle(src_handle); 108 | if (dst_handle) 109 | releasebuffer_handle(dst_handle); 110 | 111 | if (src_buf) 112 | free(src_buf); 113 | if (dst_buf) 114 | free(dst_buf); 115 | 116 | return ret; 117 | } 118 | -------------------------------------------------------------------------------- /include/RockchipRga.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Zhiqin Wei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef _rockchip_rga_h_ 20 | #define _rockchip_rga_h_ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "drmrga.h" 34 | #include "GrallocOps.h" 35 | #include "RgaUtils.h" 36 | #include "rga.h" 37 | 38 | ////////////////////////////////////////////////////////////////////////////////// 39 | #ifndef ANDROID 40 | #include "RgaSingleton.h" 41 | #endif 42 | 43 | #ifdef ANDROID 44 | #include 45 | #include 46 | #include 47 | 48 | namespace android { 49 | #endif 50 | 51 | class RockchipRga :public Singleton { 52 | public: 53 | 54 | static inline RockchipRga& get() { 55 | return getInstance(); 56 | } 57 | 58 | int RkRgaInit(); 59 | void RkRgaDeInit(); 60 | void RkRgaGetContext(void **ctx); 61 | #ifndef ANDROID /* LINUX */ 62 | int RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info, 63 | int width, int height, int bpp, int flags); 64 | int RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info); 65 | int RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp); 66 | int RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags); 67 | int RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp); 68 | int RkRgaGetMmap(bo_t *bo_info); 69 | int RkRgaUnmap(bo_t *bo_info); 70 | int RkRgaFree(bo_t *bo_info); 71 | int RkRgaGetBufferFd(bo_t *bo_info, int *fd); 72 | #else 73 | int RkRgaGetBufferFd(buffer_handle_t handle, int *fd); 74 | int RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf); 75 | #endif 76 | int RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1); 77 | int RkRgaCollorFill(rga_info *dst); 78 | int RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut); 79 | int RkRgaFlush(); 80 | 81 | 82 | void RkRgaSetLogOnceFlag(int log) { 83 | mLogOnce = log; 84 | } 85 | void RkRgaSetAlwaysLogFlag(bool log) { 86 | mLogAlways = log; 87 | } 88 | void RkRgaLogOutRgaReq(struct rga_req rgaReg); 89 | int RkRgaLogOutUserPara(rga_info *rgaInfo); 90 | inline bool RkRgaIsReady() { 91 | return mSupportRga; 92 | } 93 | 94 | RockchipRga(); 95 | ~RockchipRga(); 96 | private: 97 | bool mSupportRga; 98 | int mLogOnce; 99 | int mLogAlways; 100 | void * mContext; 101 | 102 | friend class Singleton; 103 | }; 104 | 105 | #ifdef ANDROID 106 | }; // namespace android 107 | #endif 108 | 109 | #endif 110 | 111 | -------------------------------------------------------------------------------- /samples/fill_demo/src/rga_fill_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_fill_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "im2d.h" 34 | #include "RgaUtils.h" 35 | 36 | #include "utils.h" 37 | #include "dma_alloc.h" 38 | 39 | #define LOCAL_FILE_PATH "/data" 40 | 41 | int main(void) { 42 | int ret = 0; 43 | int64_t ts; 44 | int dst_width, dst_height, dst_format; 45 | int dst_buf_size; 46 | char *dst_buf; 47 | int dst_dma_fd; 48 | rga_buffer_t dst = {}; 49 | im_rect dst_rect = {}; 50 | rga_buffer_handle_t dst_handle; 51 | 52 | dst_width = 1280; 53 | dst_height = 720; 54 | dst_format = RK_FORMAT_RGBA_8888; 55 | 56 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 57 | 58 | /* 59 | * Allocate dma_buf within 4G from dma32_heap, 60 | * return dma_fd and virtual address. 61 | * ColorFill can only be used on buffers within 4G. 62 | */ 63 | ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHE_PATCH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf); 64 | if (ret < 0) { 65 | printf("alloc dma32_heap buffer failed!\n"); 66 | return -1; 67 | } 68 | 69 | memset(dst_buf, 0x33, dst_buf_size); 70 | 71 | /* 72 | * Import the allocated dma_fd into RGA by calling 73 | * importbuffer_fd, and use the returned buffer_handle 74 | * to call RGA to process the image. 75 | */ 76 | dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size); 77 | if (dst_handle == 0) { 78 | printf("import dma_fd error!\n"); 79 | ret = -1; 80 | goto free_buf; 81 | } 82 | 83 | dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 84 | 85 | /* 86 | * Fills a rectangular area on the dst image with the specified color. 87 | dst_image 88 | -------------- 89 | | ------- | 90 | | |color| | 91 | | ------- | 92 | -------------- 93 | */ 94 | 95 | dst_rect.x = 0; 96 | dst_rect.y = 0; 97 | dst_rect.width = 300; 98 | dst_rect.height = 200; 99 | 100 | ret = imcheck({}, dst, {}, dst_rect, IM_COLOR_FILL); 101 | if (IM_STATUS_NOERROR != ret) { 102 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 103 | goto release_buffer; 104 | } 105 | 106 | ret = imfill(dst, dst_rect, 0xff00ff00); 107 | if (ret == IM_STATUS_SUCCESS) { 108 | printf("%s running success!\n", LOG_TAG); 109 | } else { 110 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 111 | goto release_buffer; 112 | } 113 | 114 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 115 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 116 | 117 | release_buffer: 118 | if (dst_handle > 0) 119 | releasebuffer_handle(dst_handle); 120 | 121 | free_buf: 122 | dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf); 123 | 124 | return 0; 125 | } 126 | -------------------------------------------------------------------------------- /samples/fill_demo/src/rga_fill_rectangle_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_fill_rectangle_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "im2d.h" 34 | #include "RgaUtils.h" 35 | 36 | #include "utils.h" 37 | #include "dma_alloc.h" 38 | 39 | #define LOCAL_FILE_PATH "/data" 40 | 41 | int main(void) { 42 | int ret = 0; 43 | int64_t ts; 44 | int dst_width, dst_height, dst_format; 45 | int dst_buf_size; 46 | char *dst_buf; 47 | int dst_dma_fd; 48 | rga_buffer_t dst = {}; 49 | im_rect dst_rect = {}; 50 | rga_buffer_handle_t dst_handle; 51 | 52 | dst_width = 1280; 53 | dst_height = 720; 54 | dst_format = RK_FORMAT_RGBA_8888; 55 | 56 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 57 | 58 | /* 59 | * Allocate dma_buf within 4G from dma32_heap, 60 | * return dma_fd and virtual address. 61 | * ColorFill can only be used on buffers within 4G. 62 | */ 63 | ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHE_PATCH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf); 64 | if (ret < 0) { 65 | printf("alloc dma32_heap buffer failed!\n"); 66 | return -1; 67 | } 68 | 69 | memset(dst_buf, 0x33, dst_buf_size); 70 | 71 | /* 72 | * Import the allocated dma_fd into RGA by calling 73 | * importbuffer_fd, and use the returned buffer_handle 74 | * to call RGA to process the image. 75 | */ 76 | dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size); 77 | if (dst_handle == 0) { 78 | printf("import dma_fd error!\n"); 79 | ret = -1; 80 | goto free_buf; 81 | } 82 | 83 | dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 84 | 85 | /* 86 | * Fills a rectangular area on the dst image with the specified color. 87 | dst_image 88 | -------------- 89 | | ------- | 90 | | |rect | | 91 | | ------- | 92 | -------------- 93 | */ 94 | 95 | dst_rect.x = 0; 96 | dst_rect.y = 0; 97 | dst_rect.width = 300; 98 | dst_rect.height = 200; 99 | 100 | ret = imcheck({}, dst, {}, dst_rect, IM_COLOR_FILL); 101 | if (IM_STATUS_NOERROR != ret) { 102 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 103 | goto release_buffer; 104 | } 105 | 106 | ret = imrectangle(dst, dst_rect, 0xff00ff00, 2); 107 | if (ret == IM_STATUS_SUCCESS) { 108 | printf("%s running success!\n", LOG_TAG); 109 | } else { 110 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 111 | goto release_buffer; 112 | } 113 | 114 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 115 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 116 | 117 | release_buffer: 118 | if (dst_handle > 0) 119 | releasebuffer_handle(dst_handle); 120 | 121 | free_buf: 122 | dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf); 123 | 124 | return 0; 125 | } 126 | -------------------------------------------------------------------------------- /im2d_api/src/im2d_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * Cerf Yu 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _im2d_log_hpp_ 19 | #define _im2d_log_hpp_ 20 | 21 | #define IM_ERR_MSG_LEN 512 22 | 23 | typedef enum { 24 | IM_LOG_UNKNOWN = 0x0, 25 | IM_LOG_DEFAULT = 0x1, 26 | IM_LOG_DEBUG = 0x3, 27 | IM_LOG_INFO = 0x4, 28 | IM_LOG_WARN = 0x5, 29 | IM_LOG_ERROR = 0x6, 30 | IM_LOG_LEVEL_MASK = 0xff, 31 | 32 | IM_LOG_FORCE = 0x1 << 8, /* This will force output to stdout, not to internal error messages. */ 33 | } IM_LOG_LEVEL; 34 | 35 | #define GET_LOG_LEVEL(level) ((level) & IM_LOG_LEVEL_MASK) 36 | #define LOG_LEVEL_CHECK(level) ((level) >= rga_log_level_get()) 37 | 38 | int rga_error_msg_set(const char* format, ...); 39 | int rga_log_level_init(void); 40 | void rga_log_level_update(void); 41 | int rga_log_level_get(void); 42 | int rga_log_enable_get(void); 43 | 44 | size_t rga_get_current_time_ms(void); 45 | size_t rga_get_start_time_ms(void); 46 | 47 | #ifdef ANDROID 48 | #define IM_LOG(level, ...) \ 49 | do { \ 50 | if (!((level) & IM_LOG_FORCE)) \ 51 | rga_error_msg_set(__VA_ARGS__); \ 52 | if ((rga_log_enable_get() > 0 && LOG_LEVEL_CHECK(level)) || \ 53 | GET_LOG_LEVEL(level) == ANDROID_LOG_ERROR || \ 54 | (level) & IM_LOG_FORCE) \ 55 | ((void)__android_log_print(GET_LOG_LEVEL(level), LOG_TAG, __VA_ARGS__)); \ 56 | } while(0) 57 | #define IM_LOGD(_str, ...) IM_LOG(ANDROID_LOG_DEBUG, _str , ## __VA_ARGS__) 58 | #define IM_LOGI(_str, ...) IM_LOG(ANDROID_LOG_INFO, _str , ## __VA_ARGS__) 59 | #define IM_LOGW(_str, ...) IM_LOG(ANDROID_LOG_WARN, _str , ## __VA_ARGS__) 60 | #define IM_LOGE(_str, ...) IM_LOG(ANDROID_LOG_ERROR, _str , ## __VA_ARGS__) 61 | #define IM_LOGFD(_str, ...) IM_LOG(ANDROID_LOG_DEBUG | IM_LOG_FORCE, _str , ## __VA_ARGS__) 62 | #define IM_LOGFI(_str, ...) IM_LOG(ANDROID_LOG_INFO | IM_LOG_FORCE, _str , ## __VA_ARGS__) 63 | #define IM_LOGFW(_str, ...) IM_LOG(ANDROID_LOG_WARN | IM_LOG_FORCE, _str , ## __VA_ARGS__) 64 | #define IM_LOGFE(_str, ...) IM_LOG(ANDROID_LOG_ERROR | IM_LOG_FORCE, _str , ## __VA_ARGS__) 65 | 66 | #else 67 | #define IM_LOG(level, _str, ...) \ 68 | do { \ 69 | if (!((level) & IM_LOG_FORCE)) \ 70 | rga_error_msg_set(_str, ## __VA_ARGS__); \ 71 | if ((rga_log_enable_get() > 0 && LOG_LEVEL_CHECK(level)) || \ 72 | GET_LOG_LEVEL(level) == IM_LOG_ERROR || \ 73 | (level) & IM_LOG_FORCE) \ 74 | fprintf(stdout, "%ld " LOG_TAG " %s(%d): " _str "\n", \ 75 | (unsigned long)(rga_get_current_time_ms()-rga_get_start_time_ms()), \ 76 | __FUNCTION__, __LINE__, ## __VA_ARGS__); \ 77 | } while(0) 78 | #define IM_LOGD(_str, ...) IM_LOG(IM_LOG_DEBUG, _str , ## __VA_ARGS__) 79 | #define IM_LOGI(_str, ...) IM_LOG(IM_LOG_INFO, _str , ## __VA_ARGS__) 80 | #define IM_LOGW(_str, ...) IM_LOG(IM_LOG_WARN, _str , ## __VA_ARGS__) 81 | #define IM_LOGE(_str, ...) IM_LOG(IM_LOG_ERROR, _str , ## __VA_ARGS__) 82 | #define IM_LOGFD(_str, ...) IM_LOG(IM_LOG_DEBUG | IM_LOG_FORCE, _str , ## __VA_ARGS__) 83 | #define IM_LOGFI(_str, ...) IM_LOG(IM_LOG_INFO | IM_LOG_FORCE, _str , ## __VA_ARGS__) 84 | #define IM_LOGFW(_str, ...) IM_LOG(IM_LOG_WARN | IM_LOG_FORCE, _str , ## __VA_ARGS__) 85 | #define IM_LOGFE(_str, ...) IM_LOG(IM_LOG_ERROR | IM_LOG_FORCE, _str , ## __VA_ARGS__) 86 | #endif 87 | 88 | #endif /* #define _im2d_log_hpp_ */ 89 | -------------------------------------------------------------------------------- /samples/config_demo/src/rga_config_single_core_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_config_single_core_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "RgaUtils.h" 39 | #include "im2d.hpp" 40 | #include "utils.h" 41 | 42 | #define LOCAL_FILE_PATH "/data" 43 | 44 | int main() { 45 | int ret = 0; 46 | int src_width, src_height, src_format; 47 | int dst_width, dst_height, dst_format; 48 | char *src_buf, *dst_buf; 49 | int src_buf_size, dst_buf_size; 50 | 51 | rga_buffer_t src_img, dst_img; 52 | rga_buffer_handle_t src_handle, dst_handle; 53 | im_opt_t opt; 54 | 55 | memset(&src_img, 0, sizeof(src_img)); 56 | memset(&dst_img, 0, sizeof(dst_img)); 57 | memset(&opt, 0, sizeof(opt)); 58 | 59 | src_width = 1280; 60 | src_height = 720; 61 | src_format = RK_FORMAT_RGBA_8888; 62 | 63 | dst_width = 1280; 64 | dst_height = 720; 65 | dst_format = RK_FORMAT_RGBA_8888; 66 | 67 | src_buf_size = src_width * src_height * get_bpp_from_format(src_format); 68 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 69 | 70 | src_buf = (char *)malloc(src_buf_size); 71 | dst_buf = (char *)malloc(dst_buf_size); 72 | 73 | /* fill image data */ 74 | if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) { 75 | printf("src image read err\n"); 76 | draw_rgba(src_buf, src_width, src_height); 77 | } 78 | memset(dst_buf, 0x80, dst_buf_size); 79 | 80 | src_handle = importbuffer_virtualaddr(src_buf, src_buf_size); 81 | dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size); 82 | if (src_handle == 0 || dst_handle == 0) { 83 | printf("importbuffer failed!\n"); 84 | goto release_buffer; 85 | } 86 | 87 | src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format); 88 | dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 89 | 90 | ret = imcheck(src_img, dst_img, {}, {}); 91 | if (IM_STATUS_NOERROR != ret) { 92 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 93 | return -1; 94 | } 95 | 96 | /* Configure the current job to use only RGA3_core0. */ 97 | opt.core = IM_SCHEDULER_RGA3_CORE0; 98 | ret = improcess(src_img, dst_img, {}, {}, {}, {}, -1, NULL, &opt, IM_SYNC); 99 | if (ret == IM_STATUS_SUCCESS) { 100 | printf("%s running success!\n", LOG_TAG); 101 | } else { 102 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 103 | goto release_buffer; 104 | } 105 | 106 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 107 | 108 | release_buffer: 109 | if (src_handle) 110 | releasebuffer_handle(src_handle); 111 | if (dst_handle) 112 | releasebuffer_handle(dst_handle); 113 | 114 | if (src_buf) 115 | free(src_buf); 116 | if (dst_buf) 117 | free(dst_buf); 118 | 119 | return ret; 120 | } 121 | -------------------------------------------------------------------------------- /samples/config_demo/src/rga_config_thread_core_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_config_thread_core_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "RgaUtils.h" 39 | #include "im2d.hpp" 40 | #include "utils.h" 41 | 42 | #define LOCAL_FILE_PATH "/data" 43 | 44 | int main() { 45 | int ret = 0; 46 | int src_width, src_height, src_format; 47 | int dst_width, dst_height, dst_format; 48 | char *src_buf, *dst_buf; 49 | int src_buf_size, dst_buf_size; 50 | 51 | rga_buffer_t src_img, dst_img; 52 | rga_buffer_handle_t src_handle, dst_handle; 53 | 54 | memset(&src_img, 0, sizeof(src_img)); 55 | memset(&dst_img, 0, sizeof(dst_img)); 56 | 57 | src_width = 1280; 58 | src_height = 720; 59 | src_format = RK_FORMAT_RGBA_8888; 60 | 61 | dst_width = 1280; 62 | dst_height = 720; 63 | dst_format = RK_FORMAT_RGBA_8888; 64 | 65 | src_buf_size = src_width * src_height * get_bpp_from_format(src_format); 66 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 67 | 68 | src_buf = (char *)malloc(src_buf_size); 69 | dst_buf = (char *)malloc(dst_buf_size); 70 | 71 | /* fill image data */ 72 | if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) { 73 | printf("src image read err\n"); 74 | draw_rgba(src_buf, src_width, src_height); 75 | } 76 | memset(dst_buf, 0x80, dst_buf_size); 77 | 78 | src_handle = importbuffer_virtualaddr(src_buf, src_buf_size); 79 | dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size); 80 | if (src_handle == 0 || dst_handle == 0) { 81 | printf("importbuffer failed!\n"); 82 | goto release_buffer; 83 | } 84 | 85 | src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format); 86 | dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 87 | 88 | ret = imcheck(src_img, dst_img, {}, {}); 89 | if (IM_STATUS_NOERROR != ret) { 90 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 91 | return -1; 92 | } 93 | 94 | /* Configure the current thread to use only RGA3_core0 or RGA3_core1. */ 95 | imconfig(IM_CONFIG_SCHEDULER_CORE, IM_SCHEDULER_RGA3_CORE0 | IM_SCHEDULER_RGA3_CORE1); 96 | 97 | ret = imcopy(src_img, dst_img); 98 | if (ret == IM_STATUS_SUCCESS) { 99 | printf("%s running success!\n", LOG_TAG); 100 | } else { 101 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 102 | goto release_buffer; 103 | } 104 | 105 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 106 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 107 | 108 | release_buffer: 109 | if (src_handle) 110 | releasebuffer_handle(src_handle); 111 | if (dst_handle) 112 | releasebuffer_handle(dst_handle); 113 | 114 | if (src_buf) 115 | free(src_buf); 116 | if (dst_buf) 117 | free(dst_buf); 118 | 119 | return ret; 120 | } 121 | -------------------------------------------------------------------------------- /samples/fill_demo/src/rga_fill_rectangle_array_demo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 3 | * Authors: 4 | * YuQiaowei 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #define LOG_NDEBUG 0 20 | #undef LOG_TAG 21 | #define LOG_TAG "rga_fill_rectangle_array_demo" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "im2d.h" 34 | #include "RgaUtils.h" 35 | 36 | #include "utils.h" 37 | #include "dma_alloc.h" 38 | 39 | #define LOCAL_FILE_PATH "/data" 40 | 41 | int main(void) { 42 | int ret = 0; 43 | int64_t ts; 44 | int dst_width, dst_height, dst_format; 45 | int dst_buf_size; 46 | char *dst_buf; 47 | int dst_dma_fd; 48 | rga_buffer_t dst = {}; 49 | im_rect dst_rect[4] = {}; 50 | rga_buffer_handle_t dst_handle; 51 | 52 | dst_width = 1280; 53 | dst_height = 720; 54 | dst_format = RK_FORMAT_RGBA_8888; 55 | 56 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 57 | 58 | /* 59 | * Allocate dma_buf within 4G from dma32_heap, 60 | * return dma_fd and virtual address. 61 | * ColorFill can only be used on buffers within 4G. 62 | */ 63 | ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHE_PATCH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf); 64 | if (ret < 0) { 65 | printf("alloc dma32_heap buffer failed!\n"); 66 | return -1; 67 | } 68 | 69 | memset(dst_buf, 0x33, dst_buf_size); 70 | 71 | /* 72 | * Import the allocated dma_fd into RGA by calling 73 | * importbuffer_fd, and use the returned buffer_handle 74 | * to call RGA to process the image. 75 | */ 76 | dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size); 77 | if (dst_handle == 0) { 78 | printf("import dma_fd error!\n"); 79 | ret = -1; 80 | goto free_buf; 81 | } 82 | 83 | dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format); 84 | 85 | /* 86 | * Fills an array of rectangular areas on the dst image with the specified color. 87 | dst_image 88 | -------------- 89 | | ------- | 90 | | | --|-- | 91 | | ----|-- | | 92 | | ----- | 93 | -------------- 94 | */ 95 | 96 | dst_rect[0] = {0, 0, 100, 100}; 97 | dst_rect[1] = {50, 50, 150, 150}; 98 | dst_rect[2] = {100, 100, 200, 200}; 99 | dst_rect[3] = {150, 150, 250, 250}; 100 | 101 | for (int i = 0; i < 4; i++) { 102 | ret = imcheck({}, dst, {}, dst_rect[i], IM_COLOR_FILL); 103 | if (IM_STATUS_NOERROR != ret) { 104 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 105 | goto release_buffer; 106 | } 107 | } 108 | 109 | ret = imrectangleArray(dst, dst_rect, 4, 0xff00ff00, 2); 110 | if (ret == IM_STATUS_SUCCESS) { 111 | printf("%s running success!\n", LOG_TAG); 112 | } else { 113 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 114 | goto release_buffer; 115 | } 116 | 117 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 118 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 119 | 120 | release_buffer: 121 | if (dst_handle > 0) 122 | releasebuffer_handle(dst_handle); 123 | 124 | free_buf: 125 | dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf); 126 | 127 | return 0; 128 | } 129 | -------------------------------------------------------------------------------- /samples/im2d_slt/README.md: -------------------------------------------------------------------------------- 1 | # RGA模块SLT测试工具 2 | 3 | 4 | 5 | ## 概述 6 | 7 | 该工具用于芯片SLT阶段使用,可以通过配置实现对RGA模块硬件进行测验。 8 | 9 | 10 | 11 | ## 使用说明 12 | 13 | ### 前置条件 14 | 15 | #### 图像准备 16 | 17 | 由于RGA硬件执行需要外部输入图像进行处理,所以需要提前准备对应的图片并确保将图像存入设备指定目录。 18 | 19 | 图像存储的目录可以在slt_config.h中进行配置,文件命名规则如下: 20 | 21 | - Raster mode 22 | 23 | ``` 24 | in%dw%d-h%d-%s.bin 25 | out%dw%d-h%d-%s.bin 26 | 27 | 示例: 28 | 1280×720 RGBA8888的输入图像: in0w1280-h720-rgba8888.bin 29 | 1280×720 RGBA8888的输出图像: out0w1280-h720-rgba8888.bin 30 | ``` 31 | 32 | - FBC mode 33 | 34 | ``` 35 | in%dw%d-h%d-%s-afbc.bin 36 | out%dw%d-h%d-%s-afbc.bin 37 | 38 | 示例: 39 | 1280×720 RGBA8888的输入图像: in0w1280-h720-rgba8888-afbc.bin 40 | 1280×720 RGBA8888的输出图像: out0w1280-h720-rgba8888-afbc.bin 41 | ``` 42 | 43 | > 参数解释如下: 44 | > 45 | > 输入文件为 in , 输出文件为 out 46 | > --->第一个%d 是文件的索引, 一般为 0, 用于区别格式及宽高完全相同的文件 47 | > --->第二个%d 是宽的意思, 这里的宽一般指虚宽 48 | > --->第三个%d 是高的意思, 这里的高一般指虚高 49 | > --->第四个%s 是格式的名字。 50 | 51 | 52 | 53 | #### 内存限制 54 | 55 | 由于RGA2硬件不支持大于32位的物理地址,所以建议测试环境保证地址映射在0~4G地址空间以内。 56 | 57 | 58 | 59 | #### 编译配置 60 | 61 | 在工具编译前,可以通过修改 slt_config.h 配置测试工具,该文件配置可以参考chip_config中的template进行替换使用。 62 | 63 | | 配置 | 说明 | 64 | | :--------------------------- | :----------------------------------------------------------- | 65 | | IM2D_SLT_THREAD_EN | 使能该配置后,将使能多线程模式,每个case都单独在一个线程运行。 | 66 | | IM2D_SLT_THREAD_MAX | 多线程模式有效,配置最大的线程数量。 | 67 | | IM2D_SLT_WHILE_EN | 使能该配置后,将使能测试case循环模式。 | 68 | | IM2D_SLT_WHILE_NUM | 循环模式有效,测试case循环次数。 | 69 | | IM2D_SLT_DRM_BUFFER_EN | 使能该配置后,测试工具的内存分配器将选择DRM。 | 70 | | IM2D_SLT_GRAPHICBUFFER_EN | 使能该配置后,测试工具的内存分配器将选择Gralloc。 | 71 | | IM2D_SLT_RK_DMA_HEAP_EN | 使能该配置后,测试工具的内存分配器将选择rk_dma_deap。 | 72 | | IM2D_SLT_BUFFER_CACHEABLE | 使能该配置后,测试工具将申请cacheable的内存。 | 73 | | IM2D_SLT_BUFFER_PHY_EN | 使能该配置后,测试工具将申请使用物理地址。 | 74 | | IM2D_SLT_TEST_RGA2_EN | 使能该配置后,将使能RGA2 拷贝测试case。 | 75 | | IM2D_SLT_TEST_RGA3_0_EN | 使能该配置后,将使能RGA3 core0 拷贝测试case。 | 76 | | IM2D_SLT_TEST_RGA3_1_EN | 使能该配置后,将使能RGA3 core1 拷贝测试case。 | 77 | | IM2D_SLT_TEST_RGA3_0_FBC_EN | 使能该配置后,将使能RGA3 core0 FBC模式 拷贝测试case。 | 78 | | IM2D_SLT_TEST_RGA3_1_FBC_EN | 使能该配置后,将使能RGA3 core1 FBC模式 拷贝测试case。 | 79 | | IM2D_SLT_DEFAULT_WIDTH | 默认的图像宽。 | 80 | | IM2D_SLT_DEFAULT_HWIGHT | 默认的图像高。 | 81 | | IM2D_SLT_DEFAULT_FORMAT | 默认的图像格式。 | 82 | | IM2D_SLT_DEFAULT_INPUT_PATH | 默认的输入图像路径 | 83 | | IM2D_SLT_DEFAULT_OUTPUT_PATH | 默认的输出图像路径 | 84 | 85 | 86 | 87 | ### 编译 88 | 89 | #### Android 90 | 91 | 在配置好Android SDK编译环境后,在源码目录下使用如下命令编译即可。 92 | 93 | ``` 94 | mm 95 | ``` 96 | 97 | 98 | 99 | #### Linux 100 | 101 | - cmake 102 | 103 | - 修改librga源码根目录下的**/cmake/buildroot.cmake**文件。执行以下脚本完成编译: 104 | 105 | ``` 106 | $ chmod +x ./cmake-linux.sh 107 | $ ./cmake-linux.sh 108 | ``` 109 | 110 | **[编译选项]** 111 | 112 | 1. 指定TOOLCHAIN_HOME为交叉编译工具的路径 113 | 2. 指定CMAKE_C_COMPILER为gcc编译命令的路径 114 | 3. 指定CMAKE_CXX_COMPILER为g++编译命令的路径 115 | 116 | - 前级librga目录未编译时,需要修改librga.so的链接路径: 117 | 118 | ``` 119 | vim CmakeList.txt +82 120 | 修改 target_link_libraries(im2d_slt librga.so)路径 121 | ``` 122 | 123 | 124 | 125 | ### 工具运行 126 | 127 | 将编译生成的im2d_slt 推入设备后,直接运行即可。 128 | 129 | 130 | 131 | ## 结果说明 132 | 133 | 如果出现以下日志,则说明测试成功。 134 | 135 | ``` 136 | :/ # im2d_slt 137 | ------------------------------------------------- 138 | ID[1]: RGA3_core0 imcopy 1 time success! 139 | ID[1]: RGA3_core0 check buffer 1 time success! 140 | ID[1]: RGA3_core0 imcopy 2 time success! 141 | ID[1]: RGA3_core0 check buffer 2 time success! 142 | ID[1]: RGA3_core0 imcopy 3 time success! 143 | ID[1]: RGA3_core0 check buffer 3 time success! 144 | ID[1] RGA3_core0 run end! 145 | ------------------------------------------------- 146 | im2d api slt success! 147 | ``` 148 | 149 | --------------------------------------------------------------------------------