├── .github └── workflows │ ├── Dockerfile │ └── build_and_release.yml ├── .gitignore ├── Android.bp ├── Android.go ├── Android.mk ├── CHANGELOG.md ├── CMakeLists.txt ├── COPYING ├── README.md ├── SConscript ├── cmake-android.sh ├── cmake-linux.sh ├── cmake-rt-thread.sh ├── cmake └── utils.cmake ├── core ├── 3rdparty │ ├── android_hal │ │ ├── hardware │ │ │ └── hardware_rockchip.h │ │ └── system │ │ │ ├── graphics-base-v1.0.h │ │ │ ├── graphics-base-v1.1.h │ │ │ ├── graphics-base-v1.2.h │ │ │ ├── graphics-base.h │ │ │ ├── graphics-sw.h │ │ │ └── graphics.h │ └── libdrm │ │ └── include │ │ └── drm │ │ ├── drm.h │ │ ├── drm_fourcc.h │ │ └── drm_mode.h ├── GrallocOps.cpp ├── NormalRga.cpp ├── NormalRga.h ├── NormalRgaApi.cpp ├── NormalRgaContext.h ├── RgaApi.cpp ├── RgaUtils.cpp ├── RockchipRga.cpp ├── adapter │ └── rt-thread │ │ ├── ioctl.h │ │ ├── lock.h │ │ └── rtt_adapter.h ├── hardware │ ├── rga2_driver.h │ └── rga_ioctl.h ├── platform_gralloc4.cpp ├── rga_sync.cpp ├── rga_sync.h └── utils │ ├── android_utils │ ├── android_utils.h │ └── src │ │ └── android_utils.cpp │ ├── drm_utils │ ├── drm_utils.h │ └── src │ │ └── drm_utils.cpp │ ├── utils.cpp │ └── utils.h ├── cross ├── cross_file_aarch64.txt └── cross_file_arm32.txt ├── debian ├── .gitignore ├── changelog ├── compat ├── control ├── copyright ├── librga-dev.dirs ├── librga-dev.install ├── librga2.dirs ├── librga2.install └── rules ├── docs ├── RGA_FAQ.assets │ ├── image-alpha-0x0.png │ ├── image-alpha-abnormal.png │ ├── image-alpha-normal.png │ ├── image-blend.png │ ├── image-cache-abnormal.png │ ├── image-color-abnormal.png │ ├── image-normal.png │ ├── image-resize-abnormal.png │ ├── image-rotate-90-abnormal.png │ └── image-rotate-90-normal.png ├── Rockchip_Developer_Guide_RGA_CN.md ├── Rockchip_Developer_Guide_RGA_EN.md ├── Rockchip_FAQ_RGA_CN.md └── Rockchip_FAQ_RGA_EN.md ├── im2d_api ├── im2d.h ├── im2d.hpp ├── im2d_buffer.h ├── im2d_common.h ├── im2d_expand.h ├── im2d_mpi.h ├── im2d_single.h ├── im2d_task.h ├── im2d_type.h ├── im2d_version.h └── src │ ├── im2d.cpp │ ├── im2d_context.cpp │ ├── im2d_context.h │ ├── im2d_debugger.cpp │ ├── im2d_debugger.h │ ├── im2d_hardware.h │ ├── im2d_impl.cpp │ ├── im2d_impl.h │ ├── im2d_job.cpp │ ├── im2d_job.h │ ├── im2d_log.cpp │ └── im2d_log.h ├── include ├── GrallocOps.h ├── RgaApi.h ├── RgaMutex.h ├── RgaSingleton.h ├── RgaUtils.h ├── RockchipRga.h ├── drmrga.h ├── platform_gralloc4.h └── rga.h ├── meson.build ├── meson.sh ├── meson_options.txt ├── samples ├── CMakeLists.txt ├── README.md ├── allocator_demo │ ├── Android.mk │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux-rv1106-1103.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_allocator_1106_cma_demo.cpp │ │ ├── rga_allocator_dma32_demo.cpp │ │ ├── rga_allocator_dma_cache_demo.cpp │ │ ├── rga_allocator_dma_demo.cpp │ │ ├── rga_allocator_drm_demo.cpp │ │ ├── rga_allocator_drm_phy_demo.cpp │ │ ├── rga_allocator_graphicbuffer_demo.cpp │ │ └── rga_allocator_malloc_demo.cpp ├── alpha_demo │ ├── Android.mk │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_alpha_3channel_demo.cpp │ │ ├── rga_alpha_colorkey_demo.cpp │ │ ├── rga_alpha_demo.cpp │ │ ├── rga_alpha_global_alpha_demo.cpp │ │ ├── rga_alpha_osd_demo.cpp │ │ ├── rga_alpha_rgba5551_demo.cpp │ │ └── rga_alpha_yuv_demo.cpp ├── async_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ └── rga_async_demo.cpp ├── cmake-android.sh ├── cmake-linux.sh ├── config_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_config_single_core_demo.cpp │ │ └── rga_config_thread_core_demo.cpp ├── copy_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_copy_demo.cpp │ │ ├── rga_copy_fbc_demo.cpp │ │ ├── rga_copy_splice_demo.cpp │ │ ├── rga_copy_splice_task_demo.cpp │ │ └── rga_copy_tile_demo.cpp ├── crop_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_crop_demo.cpp │ │ └── rga_crop_rect_demo.cpp ├── cvtcolor_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_cvtcolor_csc_demo.cpp │ │ ├── rga_cvtcolor_demo.cpp │ │ └── rga_cvtcolor_gray256_demo.cpp ├── fill_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_fill_demo.cpp │ │ ├── rga_fill_rectangle_array_demo.cpp │ │ ├── rga_fill_rectangle_demo.cpp │ │ ├── rga_fill_rectangle_task_array_demo.cpp │ │ └── rga_fill_rectangle_task_demo.cpp ├── gauss_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux-uclibc.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_gauss_demo.cpp │ │ └── rga_gauss_matrix_demo.cpp ├── im2d_api_demo │ ├── Android.mk │ ├── CMakeLists.txt │ ├── README.md │ ├── args.cpp │ ├── args.h │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── rgaImDemo.cpp ├── im2d_slt │ ├── Android.mk │ ├── CMakeLists.txt │ ├── README.md │ ├── chip_config │ │ ├── rk3506_slt_config.h.template │ │ ├── rk3528_rk3562_android_slt_config.h.template │ │ ├── rk3576_slt_config.h.template │ │ ├── rk3588_slt_config.h.template │ │ ├── rv1103b_slt_config.h.template │ │ └── rv1106_slt_config.h.template │ ├── cmake-linux.sh │ ├── cmake │ │ └── buildroot.cmake │ └── sources │ │ ├── crc.h │ │ ├── rga_im2d_slt.cpp │ │ └── slt_config.h ├── mosaic_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ └── rga_mosaic_demo.cpp ├── padding_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ └── rga_padding_demo.cpp ├── resize_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_resize_config_interpolation_demo.cpp │ │ ├── rga_resize_demo.cpp │ │ ├── rga_resize_rect_demo.cpp │ │ └── rga_resize_uv_downsampling_demo.cpp ├── rop_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ └── rga_rop_demo.cpp ├── sample_file │ ├── README.txt │ ├── in0w1280-h720-rgba8888.bin │ └── in1w1280-h720-rgba8888.bin ├── transform_demo │ ├── CMakeLists.txt │ ├── cmake-android.sh │ ├── cmake-linux.sh │ └── src │ │ ├── CMakeLists.txt │ │ ├── rga_transform_flip_demo.cpp │ │ ├── rga_transform_rotate_demo.cpp │ │ └── rga_transform_rotate_flip_demo.cpp └── utils │ ├── 3rdparty │ ├── 3rdparty.mk │ ├── CMakeLists.txt │ └── libdrm │ │ ├── include │ │ ├── libdrm │ │ │ ├── drm.h │ │ │ ├── drm_fourcc.h │ │ │ └── drm_mode.h │ │ └── xf86drm.h │ │ └── lib │ │ ├── android │ │ ├── arm32 │ │ │ └── libdrm.so │ │ └── arm64 │ │ │ └── libdrm.so │ │ ├── arm32 │ │ └── libdrm.so │ │ └── arm64 │ │ └── libdrm.so │ ├── CMakeLists.txt │ ├── allocator │ ├── CMakeLists.txt │ ├── allocator.mk │ ├── dma_alloc.cpp │ ├── drm_alloc.cpp │ └── include │ │ ├── dma_alloc.h │ │ └── drm_alloc.h │ ├── utils.cpp │ ├── utils.h │ └── utils.mk └── toolchains ├── toolchain_android_ndk.cmake ├── toolchain_linux.cmake ├── toolchain_linux_1106.cmake └── toolchain_rt_thread.cmake /.github/workflows/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE 2 | FROM ${IMAGE} 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | build-essential \ 6 | cmake \ 7 | debhelper \ 8 | devscripts \ 9 | dh-exec \ 10 | libdrm-dev \ 11 | libtool \ 12 | meson \ 13 | pkg-config && \ 14 | rm -rf /var/lib/apt/lists/* 15 | COPY . /src/ 16 | WORKDIR /src/ 17 | -------------------------------------------------------------------------------- /.github/workflows/build_and_release.yml: -------------------------------------------------------------------------------- 1 | name: Build and Release Debian Package 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | workflow_dispatch: 8 | 9 | jobs: 10 | 11 | build_and_release: 12 | name: Build and Release Debian Package 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | image: 17 | - arm64v8/ubuntu 18 | permissions: 19 | contents: write 20 | steps: 21 | 22 | - name: Checkout repository 23 | uses: actions/checkout@v3 24 | 25 | - name: Set up QEMU 26 | uses: docker/setup-qemu-action@v2 27 | with: 28 | platforms: linux/arm64 29 | 30 | - name: Set up Docker Buildx 31 | uses: docker/setup-buildx-action@v2 32 | 33 | - name: Cache Docker layers 34 | uses: docker/build-push-action@v3 35 | with: 36 | context: .github/workflows/ 37 | tags: ${{ matrix.image }}:build 38 | platforms: linux/arm64 39 | build-args: IMAGE=${{ matrix.image }}:20.04 40 | cache-from: type=gha,scope=${{ matrix.image }} 41 | cache-to: type=gha,scope=${{ matrix.image }},mode=max 42 | load: true 43 | 44 | - name: Build 45 | run: | 46 | docker run --rm -i -v $(pwd):/work -w /work ${{ matrix.image }}:build bash -c 'debuild -us -uc -b && cp -a ../*.deb ./' 47 | 48 | - name: Get version 49 | id: get_version 50 | run: | 51 | echo "version=$(docker run --rm -i -v $(pwd):/work -w /work ${{ matrix.image }}:build bash -c 'dpkg-parsechangelog --show-field Version')" >> $GITHUB_OUTPUT 52 | 53 | - name: Get commit hash 54 | id: get_commit_hash 55 | uses: pr-mpt/actions-commit-hash@v2 56 | 57 | - name: Release 58 | uses: softprops/action-gh-release@v1 59 | with: 60 | name: v${{ steps.get_version.outputs.version }}-${{ steps.get_commit_hash.outputs.short }} 61 | tag_name: v${{ steps.get_version.outputs.version }}-${{ steps.get_commit_hash.outputs.short }} 62 | generate_release_notes: true 63 | files: | 64 | ./*.deb 65 | -------------------------------------------------------------------------------- /.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 | obj-* 17 | *.deb 18 | -------------------------------------------------------------------------------- /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_debugger.cpp", 50 | "im2d_api/src/im2d_context.cpp", 51 | "im2d_api/src/im2d_job.cpp", 52 | "im2d_api/src/im2d_impl.cpp", 53 | "im2d_api/src/im2d.cpp", 54 | ], 55 | export_include_dirs: [ 56 | "include", 57 | "im2d_api", 58 | ], 59 | include_dirs: [ 60 | "hardware/rockchip/librga/core", 61 | "hardware/rockchip/librga/core/hardware", 62 | "hardware/rockchip/librga/core/utils", 63 | "hardware/rockchip/librga/core/3rdparty/libdrm/include/drm", 64 | "hardware/rockchip/librga/core/3rdparty/android_hal", 65 | "frameworks/native/libs/nativewindow/include", 66 | ], 67 | 68 | shared_libs: [ 69 | "liblog", 70 | "libui", 71 | "libutils", 72 | "libcutils", 73 | "libhardware", 74 | "libsync", 75 | ], 76 | 77 | cflags: ["-Wno-error"] +["-DLOG_TAG=\"librga\""] + ["-DRK_DRM_GRALLOC=1"] + ["-DANDROID_8"] + ["-DANDROID_7_DRM"] + ["-DUSE_AHARDWAREBUFFER=1"] + ["-DANDROID"] + ["-Wno-missing-braces"], 78 | } 79 | -------------------------------------------------------------------------------- /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.10.3 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 | RK3576 | RK3506 | RV1103B 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 | - **RT-thread** 88 | 89 | ```bash 90 | $ chmod +x ./cmake-rt-thread.sh 91 | $ ./cmake-rt-thread.sh c 92 | ``` 93 | 94 | ### Meson 95 | 96 | ​ 本仓库提供了meson.build,buildroot/debian支持meson编译。单独编译可以使用meson.sh 脚本进行config,需要自行修改meson.sh 内指定install 路径,以及PATH等环境变量,cross目录下是交叉编译工具配置文件,也需要自行修改为对应交叉编译工具路径。 97 | 98 | ​ 执行以下操作完成编译: 99 | 100 | ```bash 101 | $ ./meson.sh 102 | ``` 103 | 104 | ## 使用说明 105 | 106 | * **头文件引用** 107 | 108 | * C++调用im2d api 109 | 110 | im2d_api/im2d.hpp 111 | 112 | * C调用im2d api 113 | 114 | im2d_api/im2d.h 115 | 116 | * **库文件** 117 | 118 | librga.so 119 | 120 | librga.a 121 | 122 | * **librga应用开发接口说明文档** 123 | 124 | [IM2D API说明文档【中文】](docs/Rockchip_Developer_Guide_RGA_CN.md) 125 | 126 | [IM2D API说明文档【英文】](docs/Rockchip_Developer_Guide_RGA_EN.md) 127 | 128 | * **RGA模块FAQ文档** 129 | 130 | [RGA_FAQ【中文】](docs/Rockchip_FAQ_RGA_CN.md) 131 | 132 | [RGA_FAQ【英文】](docs/Rockchip_FAQ_RGA_EN.md) 133 | 134 | -------------------------------------------------------------------------------- /SConscript: -------------------------------------------------------------------------------- 1 | # RT-Thread building script for component 2 | Import('RTT_ROOT') 3 | Import('rtconfig') 4 | 5 | from building import * 6 | 7 | cwd = GetCurrentDir() 8 | 9 | im2d_source = [ 10 | 'core/utils/android_utils/src/android_utils.cpp', 11 | 'core/utils/drm_utils/src/drm_utils.cpp', 12 | 'core/utils/utils.cpp', 13 | 'core/NormalRgaApi.cpp', 14 | 'core/RgaUtils.cpp', 15 | 'core/rga_sync.cpp', 16 | 'im2d_api/src/im2d_log.cpp', 17 | 'im2d_api/src/im2d_debugger.cpp', 18 | 'im2d_api/src/im2d_context.cpp', 19 | 'im2d_api/src/im2d_job.cpp', 20 | 'im2d_api/src/im2d_impl.cpp', 21 | 'im2d_api/src/im2d.cpp' 22 | ] 23 | 24 | im2d_include = [ 25 | 'im2d_api', 26 | 'include', 27 | 'core', 28 | 'core/hardware', 29 | 'core/utils', 30 | 'core/adapter' 31 | ] 32 | 33 | im2d_3rdparty_include = [ 34 | 'core/3rdparty/libdrm/include/drm' 35 | ] 36 | 37 | im2d_public_include = [ 38 | 'im2d_api', 39 | 'include' 40 | ] 41 | 42 | im2d_3rdparty_include = [ 43 | 'core/3rdparty/libdrm/include/drm' 44 | ] 45 | 46 | src = [] 47 | for source in im2d_source: 48 | src.extend(Glob(source)) 49 | 50 | LOCAL_CPPPATH = [cwd] + im2d_include + im2d_3rdparty_include 51 | LOCAL_CCFLAGS = ' -x c -DLINUX -DRT_THREAD -DRGA_SYNC_DISABLE -DRGA_UTILS_DRM_DISABLE' 52 | LOCAL_CCFLAGS += ' -lm -D_USE_MATH_DEFINES -Wno-unused-command-line-argument' 53 | LOCAL_CCFLAGS += ' -Wno-maybe-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-incompatible-pointer-types -Wno-format -Wno-initializer-overrides' 54 | LOCAL_CCFLAGS += ' -w' 55 | 56 | group = DefineGroup('librga', src, depend = ['RT_USING_RGA'], LOCAL_CPPPATH = LOCAL_CPPPATH, LOCAL_CCFLAGS = LOCAL_CCFLAGS, CPPPATH = im2d_public_include) 57 | 58 | list = os.listdir(cwd) 59 | for d in list: 60 | path = os.path.join(cwd, d) 61 | if os.path.isfile(os.path.join(path, 'SConscript')): 62 | group = group + SConscript(os.path.join(d, 'SConscript')) 63 | 64 | Return('group') 65 | -------------------------------------------------------------------------------- /cmake-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SOURCE_PATH=${SCRIPT_DIR} 5 | 6 | TARGET_NAME="android_ndk" 7 | 8 | # Modify to the local toolchain path. 9 | TOOLCHAIN_PATH=${SOURCE_PATH}/toolchains/toolchain_${TARGET_NAME}.cmake 10 | BUILD_DIR=build/build_${TARGET_NAME} 11 | BUILD_TYPE=Release 12 | 13 | if [ ! -e ${TOOLCHAIN_PATH} ]; then 14 | echo "toolchain ${TOOLCHAIN_PATH} does not exist."ef 15 | exit 1 16 | fi 17 | 18 | if [ -n "${1}" ] && [ "${1}" == 'c' ]; then 19 | echo "compile with C" 20 | BUILD_SOURCE_TYPE=c 21 | else 22 | echo "compile with C++" 23 | BUILD_SOURCE_TYPE=cpp 24 | fi 25 | 26 | rm -rf $BUILD_DIR 27 | mkdir -p $BUILD_DIR 28 | pushd $BUILD_DIR 29 | 30 | cmake ../.. \ 31 | -DCMAKE_BUILD_TARGET=android_ndk \ 32 | -DRGA_SOURCE_CODE_TYPE=${BUILD_SOURCE_TYPE} \ 33 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 34 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 35 | -DCMAKE_INSTALL_PREFIX=install \ 36 | 37 | make -j32 38 | make install 39 | 40 | popd 41 | -------------------------------------------------------------------------------- /cmake-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SOURCE_PATH=${SCRIPT_DIR} 5 | 6 | TARGET_NAME="linux" 7 | 8 | # Modify to the local toolchain path. 9 | TOOLCHAIN_PATH=${SOURCE_PATH}/toolchains/toolchain_${TARGET_NAME}.cmake 10 | BUILD_DIR=build/build_${TARGET_NAME} 11 | BUILD_TYPE=Release 12 | 13 | if [ ! -e ${TOOLCHAIN_PATH} ]; then 14 | echo "toolchain ${TOOLCHAIN_PATH} does not exist." 15 | exit 1 16 | fi 17 | 18 | if [ -n "${1}" ] && [ "${1}" == 'c' ]; then 19 | echo "compile with C" 20 | BUILD_SOURCE_TYPE=c 21 | else 22 | echo "compile with C++" 23 | BUILD_SOURCE_TYPE=cpp 24 | fi 25 | 26 | rm -rf $BUILD_DIR 27 | mkdir -p $BUILD_DIR 28 | pushd $BUILD_DIR 29 | 30 | cmake ../.. \ 31 | -DCMAKE_BUILD_TARGET=buildroot \ 32 | -DRGA_SOURCE_CODE_TYPE=${BUILD_SOURCE_TYPE} \ 33 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 34 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 35 | -DCMAKE_INSTALL_PREFIX=install \ 36 | 37 | make -j32 38 | make install 39 | 40 | popd 41 | -------------------------------------------------------------------------------- /cmake-rt-thread.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) 4 | SOURCE_PATH=${SCRIPT_DIR} 5 | 6 | TARGET_NAME="rt_thread" 7 | 8 | # Modify to the local toolchain path. 9 | TOOLCHAIN_PATH=${SOURCE_PATH}/toolchains/toolchain_${TARGET_NAME}.cmake 10 | BUILD_DIR=build/build_${TARGET_NAME} 11 | RTOS_BSP=${SOURCE_PATH}/../../rtos 12 | BUILD_TYPE=Release 13 | 14 | if [ ! -e ${TOOLCHAIN_PATH} ]; then 15 | echo "toolchain ${TOOLCHAIN_PATH} does not exist."ef 16 | exit 1 17 | fi 18 | 19 | if [ -n "${1}" ] && [ "${1}" == 'c' ]; then 20 | echo "compile with C" 21 | BUILD_SOURCE_TYPE=c 22 | else 23 | echo "compile with C++" 24 | BUILD_SOURCE_TYPE=cpp 25 | fi 26 | 27 | rm -rf $BUILD_DIR 28 | mkdir -p $BUILD_DIR 29 | pushd $BUILD_DIR 30 | 31 | cmake ../.. \ 32 | -DCMAKE_BUILD_TARGET=rt_thread \ 33 | -DRGA_SOURCE_CODE_TYPE=${BUILD_SOURCE_TYPE} \ 34 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 35 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 36 | -DRTOS_BSP="${RTOS_BSP}" \ 37 | -DCMAKE_INSTALL_PREFIX=install \ 38 | 39 | make -j32 40 | make install 41 | 42 | popd 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /core/3rdparty/android_hal/hardware/hardware_rockchip.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBHARDWARE_HARDWARE_ROCKCHIP_H 2 | #define LIBHARDWARE_HARDWARE_ROCKCHIP_H 3 | 4 | #include "stdio.h" 5 | 6 | __BEGIN_DECLS 7 | 8 | #define HWC_BLENDING_DIM 0x0805 9 | #define HWC_BLENDING_CLEAR_HOLE 0x0806 10 | #define HWC_Layer_DEBUG 11 | #define LayerNameLength 60 12 | 13 | enum { 14 | HWC_TOWIN0 = 6, 15 | HWC_TOWIN1 = 7, 16 | HWC_LCDC = 8, 17 | HWC_NODRAW = 9, 18 | HWC_MIX = 10, 19 | HWC_MIX_V2 = 11 20 | }; 21 | 22 | typedef enum { 23 | 24 | /* 25 | * sRGB color pixel formats: 26 | * 27 | * The red, green and blue components are stored in sRGB space, and converted 28 | * to linear space when read, using the standard sRGB to linear equation: 29 | * 30 | * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 31 | * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 32 | * 33 | * When written the inverse transformation is performed: 34 | * 35 | * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 36 | * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 37 | * 38 | * 39 | * The alpha component, if present, is always stored in linear space and 40 | * is left unmodified when read or written. 41 | * 42 | */ 43 | 44 | /* 45 | 这里定义 rk_private_hal_formats. 46 | 它们的具体 value "不能" 和框架定义的 hal_formats 的 value 重叠. 47 | 48 | 框架定义的 hal_formats 被定义在 system/core/libsystem/include/system/ 下的如下文件中: 49 | graphics-base-v1.0.h 50 | graphics-base-v1.1.h 51 | graphics-base-v1.2.h 52 | graphics-sw.h 53 | */ 54 | 55 | HAL_PIXEL_FORMAT_sRGB_A_8888 = 0xC, // 12 56 | HAL_PIXEL_FORMAT_sRGB_X_8888 = 0xD, // 13 57 | 58 | HAL_PIXEL_FORMAT_YCrCb_NV12 = 0x15, // YUY2, 21 59 | HAL_PIXEL_FORMAT_YCrCb_NV12_VIDEO = 0x16, // 22, 和 HAL_PIXEL_FORMAT_RGBA_FP16 的 value 重叠, 60 | // 但目前 HAL_PIXEL_FORMAT_YCrCb_NV12_VIDEO 已经不被实际使用. 61 | HAL_PIXEL_FORMAT_YCrCb_NV12_10 = 0x17, // YUY2_1obit, 23 62 | HAL_PIXEL_FORMAT_YCbCr_422_SP_10 = 0x18, // 24 63 | HAL_PIXEL_FORMAT_YCrCb_420_SP_10 = 0x19, // 25 64 | 65 | HAL_PIXEL_FORMAT_YUV420_8BIT_I = 0x1A, // 420I 8bit, 26 66 | HAL_PIXEL_FORMAT_YUV420_10BIT_I = 0x1B, // 420I 10bit, 27 67 | HAL_PIXEL_FORMAT_Y210 = 0x1C, // 422I 10bit, 28 68 | HAL_PIXEL_FORMAT_BGR_888 = 29, 69 | HAL_PIXEL_FORMAT_NV30 = 30, 70 | 71 | HAL_PIXEL_FORMAT_BPP_1 = 0x30, // 48 72 | HAL_PIXEL_FORMAT_BPP_2 = 0x31, // 49 73 | HAL_PIXEL_FORMAT_BPP_4 = 0x32, // 50 74 | HAL_PIXEL_FORMAT_BPP_8 = 0x33, // 51 75 | 76 | HAL_PIXEL_FORMAT_YUV420_8BIT_RFBC = 0x200, 77 | HAL_PIXEL_FORMAT_YUV420_10BIT_RFBC = 0x201, 78 | HAL_PIXEL_FORMAT_YUV422_8BIT_RFBC = 0x202, 79 | HAL_PIXEL_FORMAT_YUV422_10BIT_RFBC = 0x203, 80 | HAL_PIXEL_FORMAT_YUV444_8BIT_RFBC = 0x204, 81 | HAL_PIXEL_FORMAT_YUV444_10BIT_RFBC = 0x205, 82 | } rk_pixel_format_t; 83 | 84 | __END_DECLS 85 | #endif // LIBHARDWARE_HARDWARE_ROCKCHIP_H 86 | -------------------------------------------------------------------------------- /core/3rdparty/android_hal/system/graphics-base-v1.1.h: -------------------------------------------------------------------------------- 1 | // This file is autogenerated by hidl-gen. Do not edit manually. 2 | // Source: android.hardware.graphics.common@1.1 3 | // Location: hardware/interfaces/graphics/common/1.1/ 4 | 5 | #ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_EXPORTED_CONSTANTS_H_ 6 | #define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_EXPORTED_CONSTANTS_H_ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef enum { 13 | HAL_PIXEL_FORMAT_DEPTH_16 = 48, 14 | HAL_PIXEL_FORMAT_DEPTH_24 = 49, 15 | HAL_PIXEL_FORMAT_DEPTH_24_STENCIL_8 = 50, 16 | HAL_PIXEL_FORMAT_DEPTH_32F = 51, 17 | HAL_PIXEL_FORMAT_DEPTH_32F_STENCIL_8 = 52, 18 | HAL_PIXEL_FORMAT_STENCIL_8 = 53, 19 | HAL_PIXEL_FORMAT_YCBCR_P010 = 54, 20 | } android_pixel_format_v1_1_t; 21 | 22 | typedef enum { 23 | HAL_DATASPACE_BT2020_ITU = 24 | 281411584, // ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) 25 | HAL_DATASPACE_BT2020_ITU_PQ = 26 | 298188800, // ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_LIMITED) 27 | HAL_DATASPACE_BT2020_ITU_HLG = 302383104, // ((STANDARD_BT2020 | TRANSFER_HLG) | RANGE_LIMITED) 28 | HAL_DATASPACE_BT2020_HLG = 168165376, // ((STANDARD_BT2020 | TRANSFER_HLG) | RANGE_FULL) 29 | } android_dataspace_v1_1_t; 30 | 31 | typedef enum { 32 | HAL_COLOR_MODE_BT2020 = 10, 33 | HAL_COLOR_MODE_BT2100_PQ = 11, 34 | HAL_COLOR_MODE_BT2100_HLG = 12, 35 | } android_color_mode_v1_1_t; 36 | 37 | typedef enum { 38 | HAL_RENDER_INTENT_COLORIMETRIC = 0, 39 | HAL_RENDER_INTENT_ENHANCE = 1, 40 | HAL_RENDER_INTENT_TONE_MAP_COLORIMETRIC = 2, 41 | HAL_RENDER_INTENT_TONE_MAP_ENHANCE = 3, 42 | } android_render_intent_v1_1_t; 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_EXPORTED_CONSTANTS_H_ 49 | -------------------------------------------------------------------------------- /core/3rdparty/android_hal/system/graphics-base-v1.2.h: -------------------------------------------------------------------------------- 1 | // This file is autogenerated by hidl-gen. Do not edit manually. 2 | // Source: android.hardware.graphics.common@1.2 3 | // Location: hardware/interfaces/graphics/common/1.2/ 4 | 5 | #ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_2_EXPORTED_CONSTANTS_H_ 6 | #define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_2_EXPORTED_CONSTANTS_H_ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef enum { 13 | HAL_HDR_HDR10_PLUS = 4, 14 | } android_hdr_v1_2_t; 15 | 16 | typedef enum { 17 | HAL_DATASPACE_DISPLAY_BT2020 = 142999552 /* STANDARD_BT2020 | TRANSFER_SRGB | RANGE_FULL */, 18 | HAL_DATASPACE_DYNAMIC_DEPTH = 4098 /* 0x1002 */, 19 | HAL_DATASPACE_JPEG_APP_SEGMENTS = 4099 /* 0x1003 */, 20 | HAL_DATASPACE_HEIF = 4100 /* 0x1004 */, 21 | } android_dataspace_v1_2_t; 22 | 23 | typedef enum { 24 | HAL_COLOR_MODE_DISPLAY_BT2020 = 13, 25 | } android_color_mode_v1_2_t; 26 | 27 | typedef enum { 28 | HAL_PIXEL_FORMAT_HSV_888 = 55 /* 0x37 */, 29 | } android_pixel_format_v1_2_t; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_2_EXPORTED_CONSTANTS_H_ 36 | -------------------------------------------------------------------------------- /core/3rdparty/android_hal/system/graphics-base.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEM_CORE_GRAPHICS_BASE_H_ 2 | #define SYSTEM_CORE_GRAPHICS_BASE_H_ 3 | 4 | #include "graphics-base-v1.0.h" 5 | #include "graphics-base-v1.1.h" 6 | #include "graphics-base-v1.2.h" 7 | 8 | #endif // SYSTEM_CORE_GRAPHICS_BASE_H_ 9 | -------------------------------------------------------------------------------- /core/3rdparty/android_hal/system/graphics-sw.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEM_CORE_GRAPHICS_SW_H_ 2 | #define SYSTEM_CORE_GRAPHICS_SW_H_ 3 | 4 | /* Software formats not in the HAL definitions. */ 5 | typedef enum { 6 | HAL_PIXEL_FORMAT_YCBCR_422_888 = 39, // 0x27 7 | HAL_PIXEL_FORMAT_YCBCR_444_888 = 40, // 0x28 8 | HAL_PIXEL_FORMAT_FLEX_RGB_888 = 41, // 0x29 9 | HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 42, // 0x2A 10 | } android_pixel_format_sw_t; 11 | 12 | /* for compatibility */ 13 | #define HAL_PIXEL_FORMAT_YCbCr_422_888 HAL_PIXEL_FORMAT_YCBCR_422_888 14 | #define HAL_PIXEL_FORMAT_YCbCr_444_888 HAL_PIXEL_FORMAT_YCBCR_444_888 15 | 16 | #endif // SYSTEM_CORE_GRAPHICS_SW_H_ 17 | -------------------------------------------------------------------------------- /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 | #include "src/im2d_context.h" 24 | 25 | #ifndef ANDROID 26 | #define ALOGI(...) { printf(__VA_ARGS__); printf("\n"); } 27 | #define ALOGD(...) { printf(__VA_ARGS__); printf("\n"); } 28 | #define ALOGE(...) { printf(__VA_ARGS__); printf("\n"); } 29 | #endif 30 | 31 | struct rgaContext { 32 | int rgaFd; 33 | int mLogAlways; 34 | int mLogOnce; 35 | float mVersion; 36 | int Is_debug; 37 | struct rga_hw_versions_t mHwVersions; 38 | struct rga_version_t mDriverVersion; 39 | RGA_DRIVER_IOC_TYPE driver; 40 | uint32_t driver_feature; 41 | }; 42 | #endif 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /core/adapter/rt-thread/lock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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 __RTT_ADAPTER_LINUX_LOCK_H__ 20 | #define __RTT_ADAPTER_LINUX_LOCK_H__ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #if 0 28 | /* mutex */ 29 | #define mutex rt_mutex 30 | 31 | #define mutex_lock rt_mutex_take 32 | #define mutex_unlock rt_mutex_release 33 | #define mutex_trylock rt_mutex_trytake 34 | 35 | static inline rt_err_t mutex_is_locked(struct rt_mutex *m) 36 | { 37 | rt_err_t rc = mutex_trylock(m); 38 | if (rc == RT_EOK) { 39 | // Locked, so was not locked; unlock and return not locked 40 | mutex_unlock(m); 41 | return 0; 42 | } else if (rc == -RT_ETIMEOUT) { 43 | // Already locked 44 | return 1; 45 | } else { 46 | // Error occurred, so we do not really know, but be conversative 47 | return 1; 48 | } 49 | } 50 | 51 | #define mutex_init(m) ({ \ 52 | int __rc = rt_mutex_init(m, "rga_mutex", RT_IPC_FLAG_FIFO); \ 53 | assert(__rc == RT_EOK); \ 54 | __rc; \ 55 | }) 56 | 57 | #define mutex_destroy(m) ({ \ 58 | int __rc = rt_mutex_detach(m); \ 59 | assert(__rc == RT_EOK); \ 60 | __rc; \ 61 | }) 62 | 63 | /* spinlock */ 64 | typedef struct rt_spinlock spinlock_t; 65 | 66 | #define spin_lock_irqsave(lock, flag) ({ \ 67 | flag = rt_spin_lock_irqsave(lock); \ 68 | }) 69 | #define spin_unlock_irqrestore rt_spin_unlock_irqrestore 70 | #define spin_lock_init rt_spin_lock_init 71 | #endif 72 | 73 | #ifndef RT_USING_PTHREADS 74 | 75 | /* pthread_mutex */ 76 | #define pthread_mutex_t struct rt_mutex 77 | // typedef struct rt_mutex pthread_mutex_t; 78 | 79 | #define pthread_mutex_lock(m) rt_mutex_take(m, RT_WAITING_FOREVER) 80 | #define pthread_mutex_unlock rt_mutex_release 81 | 82 | #define pthread_mutex_init(m, attr) ({ \ 83 | int __rc = rt_mutex_init(m, "rga_mutex", RT_IPC_FLAG_FIFO); \ 84 | assert(__rc == RT_EOK); \ 85 | __rc; \ 86 | }) 87 | 88 | #define pthread_mutex_destroy(m) ({ \ 89 | int __rc = rt_mutex_detach(m); \ 90 | assert(__rc == RT_EOK); \ 91 | __rc; \ 92 | }) 93 | 94 | /* pthread_rwlock */ 95 | typedef struct rt_mutex pthread_rwlock_t; 96 | 97 | #define pthread_rwlock_rdlock(m) rt_mutex_take(m, RT_WAITING_FOREVER) 98 | #define pthread_rwlock_wrlock(m) rt_mutex_take(m, RT_WAITING_FOREVER) 99 | #define pthread_rwlock_unlock rt_mutex_release 100 | 101 | #define pthread_rwlock_init(m, attr) ({ \ 102 | int __rc = rt_mutex_init(m, "rga_mutex_rwlock", RT_IPC_FLAG_FIFO); \ 103 | assert(__rc == RT_EOK); \ 104 | __rc; \ 105 | }) 106 | 107 | #define pthread_rwlock_destroy (m) ({ \ 108 | int __rc = rt_mutex_detach(m); \ 109 | assert(__rc == RT_EOK); \ 110 | __rc; \ 111 | }) 112 | 113 | #endif /* #ifndef RT_USING_PTHREADS */ 114 | 115 | #endif /* #ifndef __RTT_ADAPTER_LINUX_LOCK_H__ */ 116 | -------------------------------------------------------------------------------- /core/adapter/rt-thread/rtt_adapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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 __RTT_ADAPTER_H__ 20 | #define __RTT_ADAPTER_H__ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #undef ALIGN 28 | 29 | #include "rt-thread/lock.h" 30 | #include "rt-thread/ioctl.h" 31 | 32 | #endif /* #ifndef __RTT_ADAPTER_H__ */ 33 | -------------------------------------------------------------------------------- /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/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 | int get_mode_from_android_hal(uint32_t android_hal_format); 29 | 30 | #endif /* #ifndef _RGA_UTILS_ADNDROID_UTILS_H_ */ 31 | -------------------------------------------------------------------------------- /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 | int get_mode_from_drm_modifier(uint64_t modifier); 31 | 32 | #endif /* #ifndef _RGA_UTILS_DRM_UTILS_H_ */ 33 | -------------------------------------------------------------------------------- /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 20 | 21 | #include "android_utils/android_utils.h" 22 | #include "drm_utils/drm_utils.h" 23 | 24 | /* 25 | * When a pointer is converted to uint64_t, it must first be assigned to 26 | * an integer of the same size, and then converted to uint64_t. The opposite 27 | * is true. 28 | */ 29 | #define ptr_to_u64(ptr) ((uint64_t)(uintptr_t)(ptr)) 30 | #define u64_to_ptr(var) ((void *)(uintptr_t)(var)) 31 | #define PTR_ERR(ptr) ((intptr_t)(ptr)) 32 | #define ERR_PTR(err) ((void *)((intptr_t)(err))) 33 | #define IS_ERR(ptr) ((intptr_t)(ptr) < (intptr_t)ERR_PTR(-IM_ERROR_FAILED) && (intptr_t)(ptr) > (intptr_t)ERR_PTR(-IM_ERROR_MAX)) 34 | #define IS_ERR_OR_NULL(ptr) ((ptr) == NULL || IS_ERR(ptr)) 35 | 36 | #define is_rga_format(format) ((format) & 0xff00 || (format) == 0) 37 | 38 | bool is_bpp_format(int format); 39 | bool is_yuv_format(int format); 40 | bool is_rgb_format(int format); 41 | bool is_alpha_format(int format); 42 | 43 | int convert_to_rga_format(int ex_format); 44 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | /.debhelper/ 2 | /debhelper-build-stamp 3 | /files 4 | /librga-dev/ 5 | /librga-dev.substvars 6 | /librga2/ 7 | /librga2.substvars 8 | /tmp/ 9 | *.log 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 11 2 | -------------------------------------------------------------------------------- /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 | Description: Userspace interface to Rockchip RGA 2D accelerator 19 | 20 | Package: librga2 21 | Architecture: any 22 | Depends: ${shlibs:Depends}, ${misc:Depends} 23 | Description: Userspace interface to Rockchip RGA 2D accelerator 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /debian/librga-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/include 3 | -------------------------------------------------------------------------------- /debian/librga-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/* 2 | usr/lib/*/pkgconfig/* 3 | -------------------------------------------------------------------------------- /debian/librga2.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | -------------------------------------------------------------------------------- /debian/librga2.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/lib*.so 2 | usr/lib/*/lib*.so.* 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-alpha-0x0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-alpha-0x0.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-alpha-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-alpha-abnormal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-alpha-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-alpha-normal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-blend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-blend.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-cache-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-cache-abnormal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-color-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-color-abnormal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-normal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-resize-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-resize-abnormal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-rotate-90-abnormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-rotate-90-abnormal.png -------------------------------------------------------------------------------- /docs/RGA_FAQ.assets/image-rotate-90-normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/docs/RGA_FAQ.assets/image-rotate-90-normal.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_ */ -------------------------------------------------------------------------------- /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 10 28 | #define RGA_API_REVISION_VERSION 3 29 | #define RGA_API_BUILD_VERSION 2 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 | -------------------------------------------------------------------------------- /im2d_api/src/im2d_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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 _im2d_context_h_ 20 | #define _im2d_context_h_ 21 | 22 | #include 23 | #include 24 | 25 | #include "rga_ioctl.h" 26 | #include "im2d_hardware.h" 27 | 28 | #ifdef RT_THREAD 29 | #include "rt-thread/rtt_adapter.h" 30 | #endif 31 | 32 | #define RGA_DEVICE_NODE_PATH "/dev/rga" 33 | 34 | typedef enum { 35 | RGA_DRIVER_IOC_UNKONW = 0, 36 | RGA_DRIVER_IOC_RGA1, 37 | RGA_DRIVER_IOC_RGA2, 38 | RGA_DRIVER_IOC_MULTI_RGA, 39 | 40 | RGA_DRIVER_IOC_DEFAULT = RGA_DRIVER_IOC_MULTI_RGA, 41 | } RGA_DRIVER_IOC_TYPE; 42 | 43 | typedef enum { 44 | RGA_DRIVER_FEATURE_USER_CLOSE_FENCE = 1, 45 | } RGA_DRIVER_FEATURE; 46 | 47 | typedef struct rga_session { 48 | #ifdef RT_THREAD 49 | rt_device_t rga_dev_fd; 50 | #else 51 | int rga_dev_fd; 52 | #endif 53 | 54 | pthread_rwlock_t rwlock; 55 | 56 | bool is_debug; 57 | 58 | struct rga_hw_versions_t core_version; 59 | struct rga_version_t driver_verison; 60 | RGA_DRIVER_IOC_TYPE driver_type; 61 | uint32_t driver_feature; 62 | 63 | rga_info_table_entry hardware_info; 64 | } rga_session_t; 65 | 66 | int get_debug_state(); 67 | int is_debug_en(); 68 | 69 | rga_session_t *get_rga_session(); 70 | 71 | #endif /* #ifndef _im2d_context_h_ */ 72 | -------------------------------------------------------------------------------- /im2d_api/src/im2d_debugger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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_DEBUGGER_H_ 20 | #define _RGA_IM2D_DEBUGGER_H_ 21 | 22 | #include "im2d_type.h" 23 | 24 | const char *string_rd_mode(uint32_t mode); 25 | const char *string_color_space(uint32_t mode); 26 | const char *string_blend_mode(uint32_t mode); 27 | const char *string_rotate_mode(uint32_t rotate); 28 | const char *string_flip_mode(uint32_t flip); 29 | const char *string_mosaic_mode(uint32_t mode); 30 | const char *string_rop_mode(uint32_t mode); 31 | const char *string_colorkey_mode(uint32_t mode); 32 | 33 | void rga_dump_image(int log_level, 34 | const rga_buffer_t *src, const rga_buffer_t *dst, const rga_buffer_t *pat, 35 | const im_rect *srect, const im_rect *drect, const im_rect *prect); 36 | void rga_dump_opt(int log_level, const im_opt_t *opt, const int usage); 37 | void rga_dump_info(int log_level, 38 | const im_job_handle_t job_handle, 39 | const rga_buffer_t *src, const rga_buffer_t *dst, const rga_buffer_t *pat, 40 | const im_rect *srect, const im_rect *drect, const im_rect *prect, 41 | const int acquire_fence_fd, const int *release_fence_fd, 42 | const im_opt_t *opt_ptr, const int usage); 43 | 44 | #endif /* #ifndef _RGA_IM2D_DEBUGGER_H_ */ 45 | -------------------------------------------------------------------------------- /im2d_api/src/im2d_job.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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_JOB_H_ 20 | #define _RGA_IM2D_JOB_H_ 21 | 22 | #include 23 | 24 | #include "rga_ioctl.h" 25 | #include "im2d_type.h" 26 | #include "im2d_context.h" 27 | 28 | #ifdef __cplusplus 29 | #define IM2D_JOB_USE_MAP true 30 | #else 31 | #define IM2D_JOB_USE_MAP false 32 | #endif 33 | 34 | typedef struct im_rga_job { 35 | struct rga_req req[RGA_TASK_NUM_MAX]; 36 | int task_count; 37 | 38 | int id; 39 | } im_rga_job_t; 40 | 41 | #if IM2D_JOB_USE_MAP 42 | #include 43 | 44 | typedef std::map rga_job_map_t; 45 | #else 46 | typedef struct rga_map_node_data { 47 | uint64_t key; 48 | void *value; 49 | } rga_map_node_data_t; 50 | 51 | typedef struct rga_map_node rga_map_node_t; 52 | 53 | typedef struct rga_map_node { 54 | rga_map_node_t* prev; 55 | rga_map_node_t* next; 56 | 57 | rga_map_node_data_t data; 58 | } rga_map_node_t; 59 | 60 | typedef struct rga_map_list { 61 | rga_map_node_t* head; 62 | rga_map_node_t* tail; 63 | } rga_map_list_t; 64 | 65 | typedef rga_map_list_t rga_job_map_t; 66 | #endif 67 | 68 | struct im2d_job_manager { 69 | rga_job_map_t job_map; 70 | int job_count; 71 | 72 | pthread_mutex_t mutex; 73 | }; 74 | 75 | void rga_map_insert_job(rga_job_map_t *job_map, im_job_handle_t handle, im_rga_job_t *job); 76 | void rga_map_delete_job(rga_job_map_t *job_map, im_job_handle_t handle); 77 | im_rga_job_t *rga_map_find_job(rga_job_map_t *job_map, im_job_handle_t handle); 78 | 79 | extern struct im2d_job_manager g_im2d_job_manager; 80 | 81 | #endif /* #ifndef _RGA_IM2D_JOB_H_ */ 82 | -------------------------------------------------------------------------------- /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 | typedef std::vector rga_gralloc_attr_t; 52 | 53 | // ------------------------------------------------------------------------------- 54 | int RkRgaGetHandleFd(buffer_handle_t handle, int *fd); 55 | int RkRgaGetHandleAttributes(buffer_handle_t handle, 56 | rga_gralloc_attr_t *attrs); 57 | int RkRgaGetHandleMapAddress(buffer_handle_t handle, 58 | void **buf); 59 | #endif //Android 60 | 61 | #endif //_rk_graphic_buffer_h_ 62 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project( 2 | 'librga', 3 | 'cpp', 4 | version : '2.2.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_debugger.cpp', 28 | 'im2d_api/src/im2d_context.cpp', 29 | 'im2d_api/src/im2d_job.cpp', 30 | 'im2d_api/src/im2d_impl.cpp', 31 | 'im2d_api/src/im2d.cpp', 32 | ] 33 | 34 | incdir = include_directories('include', 'im2d_api', 'core/hardware', 'core/utils', 'core/3rdparty/libdrm/include/drm', 'core/3rdparty/android_hal') 35 | 36 | librga = shared_library( 37 | 'rga', 38 | librga_srcs, 39 | dependencies : [libthreads_dep], 40 | include_directories : incdir, 41 | version : meson.project_version(), 42 | cpp_args : ['-w'], 43 | install : true, 44 | ) 45 | 46 | librga = static_library( 47 | 'rga', 48 | librga_srcs, 49 | dependencies : [libthreads_dep], 50 | include_directories : incdir, 51 | cpp_args : ['-w'], 52 | install : true, 53 | ) 54 | 55 | install_headers( 56 | 'include/rga.h', 57 | 'include/drmrga.h', 58 | 'include/GrallocOps.h', 59 | 'include/RockchipRga.h', 60 | 'include/RgaMutex.h', 61 | 'include/RgaSingleton.h', 62 | 'include/RgaUtils.h', 63 | 'include/RgaApi.h', 64 | 'im2d_api/im2d.h', 65 | 'im2d_api/im2d.hpp', 66 | 'im2d_api/im2d_type.h', 67 | 'im2d_api/im2d_version.h', 68 | 'im2d_api/im2d_buffer.h', 69 | 'im2d_api/im2d_common.h', 70 | 'im2d_api/im2d_single.h', 71 | 'im2d_api/im2d_task.h', 72 | 'im2d_api/im2d_mpi.h', 73 | 'im2d_api/im2d_expand.h', 74 | subdir : 'rga', 75 | ) 76 | 77 | pkgconfig.generate( 78 | libraries : librga, 79 | filebase : 'librga', 80 | name : 'librga', 81 | version : meson.project_version(), 82 | description : 'Userspace interface to Rockchip RGA 2D accelerator', 83 | extra_cflags : ['-I${includedir}/rga'], 84 | ) 85 | 86 | librga_demo_option = get_option('librga_demo') 87 | if librga_demo_option != 'false' 88 | demo_src = [ 89 | 'samples/utils/utils.cpp', 90 | 'samples/utils/allocator/dma_alloc.cpp', 91 | 'samples/utils/allocator/drm_alloc.cpp', 92 | 'samples/im2d_api_demo/rgaImDemo.cpp', 93 | 'samples/im2d_api_demo/args.cpp', 94 | ] 95 | demo_incdir = include_directories( 96 | 'include', 97 | 'im2d_api', 98 | 'samples/utils', 99 | 'samples/utils/allocator/include', 100 | 'utils/3rdparty/libdrm/include', 101 | 'utils/3rdparty/libdrm/include/libdrm' 102 | ) 103 | librga_dep = dependency('librga') 104 | executable( 105 | 'rgaImDemo', 106 | demo_src, 107 | include_directories : demo_incdir, 108 | dependencies : librga_dep, 109 | cpp_args : ['-Wno-pedantic'], 110 | install : true, 111 | ) 112 | endif 113 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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 | -------------------------------------------------------------------------------- /samples/allocator_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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_1106.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux_1106/install/lib 9 | BUILD_DIR=build/build_linux_1106 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/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/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/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_UNCACHED_PATH, 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 | -------------------------------------------------------------------------------- /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.12) 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/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/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/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_global_alpha_demo 12 | add_executable(rga_alpha_global_alpha_demo 13 | rga_alpha_global_alpha_demo.cpp 14 | ) 15 | target_link_libraries(rga_alpha_global_alpha_demo 16 | utils_obj 17 | ${RGA_LIB} 18 | ) 19 | install(TARGETS rga_alpha_global_alpha_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 20 | 21 | # rga_alpha_3channel_demo 22 | add_executable(rga_alpha_3channel_demo 23 | rga_alpha_3channel_demo.cpp 24 | ) 25 | target_link_libraries(rga_alpha_3channel_demo 26 | utils_obj 27 | ${RGA_LIB} 28 | ) 29 | install(TARGETS rga_alpha_3channel_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 30 | 31 | # rga_alpha_3channel_demo 32 | add_executable(rga_alpha_rgba5551_demo 33 | rga_alpha_rgba5551_demo.cpp 34 | ) 35 | target_link_libraries(rga_alpha_rgba5551_demo 36 | utils_obj 37 | ${RGA_LIB} 38 | ) 39 | install(TARGETS rga_alpha_rgba5551_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 40 | 41 | # rga_alpha_yuv_demo 42 | add_executable(rga_alpha_yuv_demo 43 | rga_alpha_yuv_demo.cpp 44 | ) 45 | target_link_libraries(rga_alpha_yuv_demo 46 | utils_obj 47 | ${RGA_LIB} 48 | ) 49 | install(TARGETS rga_alpha_yuv_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 50 | 51 | # rga_alpha_colorkey_demo 52 | add_executable(rga_alpha_colorkey_demo 53 | rga_alpha_colorkey_demo.cpp 54 | ) 55 | target_link_libraries(rga_alpha_colorkey_demo 56 | utils_obj 57 | ${RGA_LIB} 58 | ) 59 | install(TARGETS rga_alpha_colorkey_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 60 | 61 | # rga_alpha_osd_demo 62 | add_executable(rga_alpha_osd_demo 63 | rga_alpha_osd_demo.cpp 64 | ) 65 | target_link_libraries(rga_alpha_osd_demo 66 | utils_obj 67 | ${RGA_LIB} 68 | ) 69 | install(TARGETS rga_alpha_osd_demo DESTINATION ${CMAKE_INSTALL_BINDIR}) 70 | 71 | -------------------------------------------------------------------------------- /samples/async_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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/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/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/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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/copy_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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_tile_demo 24 | SET(DEMO_NAME rga_copy_tile_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/crop_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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/cvtcolor_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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/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 | 37 | #include "RgaUtils.h" 38 | #include "im2d.hpp" 39 | 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_RGB_565; 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 | memset(src_buf, 0xaa, src_buf_size); 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 | ret = imcvtcolor(src_img, dst_img, src_format, dst_format); 95 | if (ret == IM_STATUS_SUCCESS) { 96 | printf("%s running success!\n", LOG_TAG); 97 | } else { 98 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 99 | goto release_buffer; 100 | } 101 | 102 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 103 | 104 | release_buffer: 105 | if (src_handle) 106 | releasebuffer_handle(src_handle); 107 | if (dst_handle) 108 | releasebuffer_handle(dst_handle); 109 | 110 | if (src_buf) 111 | free(src_buf); 112 | if (dst_buf) 113 | free(dst_buf); 114 | 115 | return ret; 116 | } 117 | -------------------------------------------------------------------------------- /samples/fill_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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 | -------------------------------------------------------------------------------- /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 | int dst_width, dst_height, dst_format; 44 | int dst_buf_size; 45 | char *dst_buf; 46 | int dst_dma_fd; 47 | rga_buffer_t dst = {}; 48 | im_rect dst_rect = {}; 49 | rga_buffer_handle_t dst_handle; 50 | 51 | dst_width = 1280; 52 | dst_height = 720; 53 | dst_format = RK_FORMAT_RGBA_8888; 54 | 55 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 56 | 57 | /* 58 | * Allocate dma_buf within 4G from dma32_heap, 59 | * return dma_fd and virtual address. 60 | * ColorFill can only be used on buffers within 4G. 61 | */ 62 | ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHED_PATH, 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 | /* 85 | * Fills a rectangular area on the dst image with the specified color. 86 | dst_image 87 | -------------- 88 | | ------- | 89 | | |color| | 90 | | ------- | 91 | -------------- 92 | */ 93 | 94 | dst_rect.x = 0; 95 | dst_rect.y = 0; 96 | dst_rect.width = 300; 97 | dst_rect.height = 200; 98 | 99 | ret = imcheck({}, dst, {}, dst_rect, IM_COLOR_FILL); 100 | if (IM_STATUS_NOERROR != ret) { 101 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 102 | goto release_buffer; 103 | } 104 | 105 | ret = imfill(dst, dst_rect, 0xff00ff00); 106 | if (ret == IM_STATUS_SUCCESS) { 107 | printf("%s running success!\n", LOG_TAG); 108 | } else { 109 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 110 | goto release_buffer; 111 | } 112 | 113 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 114 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 115 | 116 | release_buffer: 117 | if (dst_handle > 0) 118 | releasebuffer_handle(dst_handle); 119 | 120 | free_buf: 121 | dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf); 122 | 123 | return 0; 124 | } 125 | -------------------------------------------------------------------------------- /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 | int dst_width, dst_height, dst_format; 44 | int dst_buf_size; 45 | char *dst_buf; 46 | int dst_dma_fd; 47 | rga_buffer_t dst = {}; 48 | im_rect dst_rect = {}; 49 | rga_buffer_handle_t dst_handle; 50 | 51 | dst_width = 1280; 52 | dst_height = 720; 53 | dst_format = RK_FORMAT_RGBA_8888; 54 | 55 | dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format); 56 | 57 | /* 58 | * Allocate dma_buf within 4G from dma32_heap, 59 | * return dma_fd and virtual address. 60 | * ColorFill can only be used on buffers within 4G. 61 | */ 62 | ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHED_PATH, 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 | /* 85 | * Fills a rectangular area on the dst image with the specified color. 86 | dst_image 87 | -------------- 88 | | ------- | 89 | | |rect | | 90 | | ------- | 91 | -------------- 92 | */ 93 | 94 | dst_rect.x = 0; 95 | dst_rect.y = 0; 96 | dst_rect.width = 300; 97 | dst_rect.height = 200; 98 | 99 | ret = imcheck({}, dst, {}, dst_rect, IM_COLOR_FILL); 100 | if (IM_STATUS_NOERROR != ret) { 101 | printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret)); 102 | goto release_buffer; 103 | } 104 | 105 | ret = imrectangle(dst, dst_rect, 0xff00ff00, 2); 106 | if (ret == IM_STATUS_SUCCESS) { 107 | printf("%s running success!\n", LOG_TAG); 108 | } else { 109 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 110 | goto release_buffer; 111 | } 112 | 113 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 114 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 115 | 116 | release_buffer: 117 | if (dst_handle > 0) 118 | releasebuffer_handle(dst_handle); 119 | 120 | free_buf: 121 | dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf); 122 | 123 | return 0; 124 | } 125 | -------------------------------------------------------------------------------- /samples/gauss_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/gauss_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/gauss_demo/cmake-linux-uclibc.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_1106.cmake 8 | LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux_1106/install/lib 9 | BUILD_DIR=build/build_linux_1106 10 | BUILD_TYPE=Release 11 | 12 | rm -rf $BUILD_DIR 13 | mkdir -p $BUILD_DIR 14 | pushd $BUILD_DIR 15 | 16 | if [ ${1} == 'c' ] 17 | then 18 | echo "compile with C" 19 | BUILD_SOURCE_TYPE=c 20 | else 21 | echo "compile with C++" 22 | BUILD_SOURCE_TYPE=cpp 23 | fi 24 | 25 | cmake ../.. \ 26 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 27 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 28 | -DRGA_SOURCE_CODE_TYPE=${BUILD_SOURCE_TYPE} \ 29 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 30 | -DCMAKE_INSTALL_PREFIX=install \ 31 | 32 | make -j8 33 | make install 34 | 35 | popd 36 | -------------------------------------------------------------------------------- /samples/gauss_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/gauss_demo/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # rga_gauss_demo 2 | SET(DEMO_NAME rga_gauss_demo) 3 | 4 | set(DEMO_SRC 5 | ${DEMO_NAME}.cpp 6 | ) 7 | 8 | if(RGA_SOURCE_CODE_TYPE STREQUAL c) 9 | set_source_files_properties(${DEMO_SRC} PROPERTIES LANGUAGE C COMPILE_FLAGS "-x c") 10 | endif() 11 | 12 | add_executable(${DEMO_NAME} 13 | ${DEMO_SRC} 14 | ) 15 | target_link_libraries(${DEMO_NAME} 16 | utils_obj 17 | ${RGA_LIB} 18 | ) 19 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 20 | 21 | if (RGA_SOURCE_CODE_TYPE STREQUAL cpp) 22 | #rga_gauss_matrix_demo 23 | SET(DEMO_NAME rga_gauss_matrix_demo) 24 | 25 | set(DEMO_SRC 26 | ${DEMO_NAME}.cpp 27 | ) 28 | 29 | add_executable(${DEMO_NAME} 30 | ${DEMO_SRC} 31 | ) 32 | target_link_libraries(${DEMO_NAME} 33 | utils_obj 34 | ${RGA_LIB} 35 | ) 36 | install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) 37 | endif() -------------------------------------------------------------------------------- /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 | ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \> 31))) 19 | LOCAL_CFLAGS += -DUSE_HARDWARE_ROCKCHIP=1 20 | endif 21 | 22 | LOCAL_CFLAGS += -Wall -Werror -Wunreachable-code 23 | 24 | LOCAL_C_INCLUDES += \ 25 | $(LOCAL_PATH)/../.. \ 26 | $(LOCAL_PATH)/../../im2d_api \ 27 | $(LOCAL_PATH)/../../include 28 | 29 | LOCAL_SHARED_LIBRARIES := \ 30 | libcutils \ 31 | liblog \ 32 | libutils \ 33 | libui \ 34 | libEGL \ 35 | libGLESv1_CM \ 36 | libhardware \ 37 | librga \ 38 | libnativewindow 39 | 40 | LOCAL_HEADER_LIBRARIES += \ 41 | libutils_headers \ 42 | libcutils_headers \ 43 | libhardware_headers \ 44 | liblog_headers \ 45 | libgui_headers \ 46 | libbinder_headers 47 | 48 | #has no "external/stlport" from Android 6.0 on 49 | ifeq (1,$(strip $(shell expr $(PLATFORM_VERSION) \< 6.0))) 50 | LOCAL_C_INCLUDES += \ 51 | external/stlport/stlport 52 | 53 | LOCAL_C_INCLUDES += bionic 54 | endif 55 | 56 | #ifeq ($(strip $(BOARD_USE_DRM)), true) 57 | #ifneq (1,$(strip $(shell expr $(PLATFORM_VERSION) \< 6.9))) 58 | LOCAL_CFLAGS += -DANDROID_7_DRM -DANDROID 59 | #endif 60 | #endif 61 | 62 | ifeq ($(strip $(TARGET_BOARD_PLATFORM)),rk3368) 63 | LOCAL_CFLAGS += -DRK3368 64 | endif 65 | 66 | ifneq (1,$(strip $(shell expr $(PLATFORM_VERSION) \< 8.0))) 67 | LOCAL_CFLAGS += -DANDROID_8 68 | endif 69 | 70 | ifeq ($(strip $(TARGET_BOARD_PLATFORM)),rk3188) 71 | LOCAL_CFLAGS += -DRK3188 72 | endif 73 | 74 | LOCAL_SRC_FILES := \ 75 | rgaImDemo.cpp \ 76 | args.cpp 77 | 78 | include $(LOCAL_PATH)/../utils/utils.mk 79 | 80 | LOCAL_MODULE:= rgaImDemo 81 | 82 | ifdef TARGET_32_BIT_SURFACEFLINGER 83 | LOCAL_32_BIT_ONLY := true 84 | endif 85 | 86 | include $(BUILD_EXECUTABLE) 87 | 88 | -------------------------------------------------------------------------------- /samples/im2d_api_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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 | set(RKRGA_TARGET_SOC rv1106) 46 | 47 | if(RKRGA_TARGET_SOC STREQUAL rv1106) 48 | add_definitions(-DUSE_RV1106_CMA=1) 49 | endif() 50 | endif() 51 | 52 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 53 | message("load ${LIBRGA_FILE_LIB}/librga.so") 54 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 55 | else () 56 | set(RGA_LIB rga) 57 | endif() 58 | 59 | #install path 60 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 61 | set(CMAKE_INSTALL_BINDIR bin) 62 | endif() 63 | 64 | set(IM2D_DEMO_NAME ${PROJECT_NAME}) 65 | set(IM2D_DEMO_SRCS 66 | args.cpp 67 | rgaImDemo.cpp) 68 | set(IM2D_DEMO_INCLUDE 69 | ./ 70 | ../../include 71 | ../../im2d_api) 72 | 73 | if(RGA_SOURCE_CODE_TYPE STREQUAL c) 74 | set_source_files_properties(${IM2D_DEMO_SRCS} PROPERTIES LANGUAGE C COMPILE_FLAGS "-x c") 75 | endif() 76 | 77 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 78 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 79 | endif() 80 | 81 | add_executable(${IM2D_DEMO_NAME} ${IM2D_DEMO_SRCS}) 82 | target_include_directories(${IM2D_DEMO_NAME} PUBLIC ${IM2D_DEMO_INCLUDE}) 83 | target_link_libraries(${IM2D_DEMO_NAME} ${RGA_LIB} utils_obj) 84 | 85 | install(TARGETS ${IM2D_DEMO_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 86 | -------------------------------------------------------------------------------- /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》——测试用例及调试方法 章节。 -------------------------------------------------------------------------------- /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_HELP, 38 | MODE_NONE, 39 | MODE_MAX 40 | } MODE_CODE; 41 | 42 | #define MODE_QUERYSTRING_CHAR (char) (MODE_QUERYSTRING+'0') 43 | #define MODE_COPY_CHAR (char) (MODE_COPY +'0') 44 | #define MODE_RESIZE_CHAR (char) (MODE_RESIZE +'0') 45 | #define MODE_CROP_CHAR (char) (MODE_CROP +'0') 46 | #define MODE_ROTATE_CHAR (char) (MODE_ROTATE +'0') 47 | #define MODE_FLIP_CHAR (char) (MODE_FLIP +'0') 48 | #define MODE_TRANSLATE_CHAR (char) (MODE_TRANSLATE +'0') 49 | #define MODE_BLEND_CHAR (char) (MODE_BLEND +'0') 50 | #define MODE_CVTCOLOR_CHAR (char) (MODE_CVTCOLOR +'0') 51 | #define MODE_FILL_CHAR (char) (MODE_FILL +'0') 52 | #define MODE_WHILE_CHAR 'w' 53 | #define MODE_HELP_CHAR 'h' 54 | #define MODE_NONE_CHAR (char) (MODE_NONE +'0') 55 | 56 | #define BLUE_COLOR 0xffff0000 57 | #define GREEN_COLOR 0xff00ff00 58 | #define RED_COLOR 0xff0000ff 59 | #define WHILE_FLAG (1 << 7) 60 | 61 | int readArguments(int argc, char *argv[], int* parm); 62 | IM_INFORMATION readInfo(char* targ); 63 | int readParm(char* targ); 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /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_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/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 | hardware/rockchip/librga/im2d_api 26 | # $(LOCAL_PATH)/third-party/libdrm/include \ 27 | # $(LOCAL_PATH)/third-party/libdrm/include/libdrm 28 | 29 | LOCAL_SHARED_LIBRARIES := \ 30 | libcutils \ 31 | liblog \ 32 | libutils \ 33 | libui \ 34 | libEGL \ 35 | libGLESv1_CM \ 36 | libhardware \ 37 | librga 38 | 39 | LOCAL_HEADER_LIBRARIES += \ 40 | libutils_headers \ 41 | libcutils_headers \ 42 | libhardware_headers \ 43 | liblog_headers \ 44 | libgui_headers \ 45 | libbinder_headers 46 | 47 | #has no "external/stlport" from Android 6.0 on 48 | ifeq (1,$(strip $(shell expr $(PLATFORM_VERSION) \< 6.0))) 49 | LOCAL_C_INCLUDES += \ 50 | external/stlport/stlport 51 | 52 | LOCAL_C_INCLUDES += bionic 53 | endif 54 | 55 | include $(LOCAL_PATH)/../utils/utils.mk 56 | 57 | LOCAL_SRC_FILES += \ 58 | sources/rga_im2d_slt.cpp 59 | 60 | LOCAL_MODULE:= im2d_slt 61 | 62 | ifdef TARGET_32_BIT_SURFACEFLINGER 63 | LOCAL_32_BIT_ONLY := true 64 | endif 65 | 66 | include $(BUILD_EXECUTABLE) 67 | 68 | -------------------------------------------------------------------------------- /samples/im2d_slt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | if (EXISTS ${BUILD_TOOLCHAINS_PATH}) 4 | message("load ${BUILD_TOOLCHAINS_PATH}") 5 | include(${BUILD_TOOLCHAINS_PATH}) 6 | endif() 7 | 8 | project(im2d_slt) 9 | 10 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -pthread") 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -pthread") 12 | 13 | if (EXISTS ${LIBRGA_FILE_LIB}/librga.so) 14 | message("load ${LIBRGA_FILE_LIB}/librga.so") 15 | set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so) 16 | else () 17 | set(RGA_LIB rga) 18 | endif() 19 | 20 | if(NOT CMAKE_BUILD_TYPE) 21 | message("default to Release build for GCC builds") 22 | set(CMAKE_BUILD_TYPE Release CACHE STRING 23 | "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." 24 | FORCE) 25 | endif() 26 | 27 | #install path 28 | if (NOT DEFINED CMAKE_INSTALL_BINDIR) 29 | set(CMAKE_INSTALL_BINDIR bin) 30 | endif() 31 | 32 | set(IM2D_SLT_NAME ${PROJECT_NAME}) 33 | 34 | set(RGA_INCLUDE 35 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include 36 | ${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api 37 | ) 38 | set(IM2D_RGA_SLT_SRCS 39 | ${CMAKE_CURRENT_SOURCE_DIR}/sources/rga_im2d_slt.cpp 40 | ) 41 | 42 | if(RGA_SOURCE_CODE_TYPE STREQUAL c) 43 | set_source_files_properties(${IM2D_RGA_SLT_SRCS} PROPERTIES LANGUAGE C COMPILE_FLAGS "-x c") 44 | endif() 45 | 46 | if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED) 47 | include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt) 48 | endif() 49 | 50 | add_executable(${IM2D_SLT_NAME} ${IM2D_RGA_SLT_SRCS}) 51 | target_include_directories(${IM2D_SLT_NAME} PUBLIC ${RGA_INCLUDE}) 52 | target_link_libraries(${IM2D_SLT_NAME} ${RGA_LIB} utils_obj) 53 | 54 | install(TARGETS ${IM2D_SLT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 55 | -------------------------------------------------------------------------------- /samples/im2d_slt/chip_config/rk3506_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 | #ifndef _IM2D_SLT_CONFIG_H_ 20 | #define _IM2D_SLT_CONFIG_H_ 21 | 22 | /* im2d_slt config */ 23 | #define IM2D_SLT_THREAD_EN 1 /* Enable multi-threaded mode. */ 24 | #define IM2D_SLT_THREAD_MAX 10 /* Maximum number of threads. */ 25 | #define IM2D_SLT_WHILE_EN 1 /* Enable while mode, 1: while, 0 single. */ 26 | #define IM2D_SLT_WHILE_NUM 500 /* Number of while mode. */ 27 | 28 | #define IM2d_SLT_TEST_DISABLE_ALPHA 0 /* Disable Alpha case */ 29 | 30 | /* raster test */ 31 | #define IM2D_SLT_TEST_RGA2_0_EN 1 /* Enable rga2_core0 case. */ 32 | #define IM2D_SLT_TEST_RGA2_1_EN 0 /* Enable rga2_core1 case. */ 33 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 34 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 35 | 36 | #define IM2D_SLT_TEST_SPECIAL_EN 0 /* Enable special test. */ 37 | /* special test */ 38 | #define IM2D_SLT_TEST_RGA2_0_TILE_EN 0 /* Enable rga2_core0 TILE4x4 case. */ 39 | #define IM2D_SLT_TEST_RGA2_0_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 40 | #define IM2D_SLT_TEST_RGA2_0_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 41 | #define IM2D_SLT_TEST_RGA2_1_TILE_EN 0 /* Enable rga2_core1 TILE4x4 case. */ 42 | #define IM2D_SLT_TEST_RGA2_1_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 43 | #define IM2D_SLT_TEST_RGA2_1_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 44 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 AFBC16x16 case. */ 45 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 AFBC16x16 case. */ 46 | 47 | #define IM2D_SLT_TEST_PERF_EN 0 /* Enable perf test. */ 48 | 49 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 50 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 51 | #if IM2D_SLT_GRAPHICBUFFER_EN 52 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 53 | #else 54 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_ARGB_4444 /* Default image format. */ 55 | #endif 56 | 57 | #define DEFAULT_DMA_HEAP_PATH "/dev/dma_heap/system-uncached" 58 | #define DEFAULT_DMA32_HEAP_PATH "/dev/dma_heap/system-uncached-dma32" 59 | #define RV1106_DEFAULT_DMA_HEAP_PATH "/dev/rk_dma_heap/rk-dma-heap-cma" 60 | #define DEFAULT_CMA_HEAP_PATH "/dev/dma_heap/cma-uncached" 61 | 62 | #define IM2D_SLT_DMA_HEAP_PATH DEFAULT_CMA_HEAP_PATH 63 | 64 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/data/rga_slt" 65 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/data/rga_slt" 66 | 67 | /* crc32 golden config */ 68 | #define IM2D_SLT_GENERATE_CRC 0 69 | #define IM2D_SLT_GENERATE_CRC_GOLDEN_PREFIX "crcdata" 70 | #define IM2D_SLT_DEFAULT_GOLDEN_PATH "/data/rga_slt/golden" 71 | 72 | #endif /* #ifndef _IM2D_SLT_CONFIG_H_ */ 73 | -------------------------------------------------------------------------------- /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 500 /* Number of while mode. */ 24 | 25 | /* raster test */ 26 | #define IM2D_SLT_TEST_RGA2_0_EN 1 /* Enable rga2_core0 case. */ 27 | #define IM2D_SLT_TEST_RGA2_1_EN 0 /* Enable rga2_core1 case. */ 28 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 29 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 30 | 31 | #define IM2D_SLT_TEST_SPECIAL_EN 1 /* Enable special test. */ 32 | /* special test */ 33 | #define IM2D_SLT_TEST_RGA2_0_TILE_EN 0 /* Enable rga2_core0 TILE4x4 case. */ 34 | #define IM2D_SLT_TEST_RGA2_0_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 35 | #define IM2D_SLT_TEST_RGA2_0_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 36 | #define IM2D_SLT_TEST_RGA2_1_TILE_EN 0 /* Enable rga2_core1 TILE4x4 case. */ 37 | #define IM2D_SLT_TEST_RGA2_1_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 38 | #define IM2D_SLT_TEST_RGA2_1_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 39 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 AFBC16x16 case. */ 40 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 AFBC16x16 case. */ 41 | 42 | #define IM2D_SLT_TEST_PERF_EN 1 /* Enable perf test. */ 43 | 44 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 45 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 46 | #if IM2D_SLT_GRAPHICBUFFER_EN 47 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 48 | #else 49 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 50 | #endif 51 | 52 | #define DEFAULT_DMA_HEAP_PATH "/dev/dma_heap/system-uncached" 53 | #define DEFAULT_DMA32_HEAP_PATH "/dev/dma_heap/system-uncached-dma32" 54 | #define RV1106_DEFAULT_DMA_HEAP_PATH "/dev/rk_dma_heap/rk-dma-heap-cma" 55 | 56 | #define IM2D_SLT_DMA_HEAP_PATH DEFAULT_DMA32_HEAP_PATH 57 | 58 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/data/rga_slt" 59 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/data/rga_slt" 60 | #define IM2D_SLT_DEFAULT_GOLDEN_PATH "/data/rga_slt/golden" -------------------------------------------------------------------------------- /samples/im2d_slt/chip_config/rk3576_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 500 /* Number of while mode. */ 24 | 25 | /* raster test */ 26 | #define IM2D_SLT_TEST_RGA2_0_EN 1 /* Enable rga2_core0 case. */ 27 | #define IM2D_SLT_TEST_RGA2_1_EN 1 /* Enable rga2_core1 case. */ 28 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 29 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 30 | 31 | #define IM2D_SLT_TEST_SPECIAL_EN 1 /* Enable special test. */ 32 | /* special test */ 33 | #define IM2D_SLT_TEST_RGA2_0_TILE_EN 1 /* Enable rga2_core0 TILE4x4 case. */ 34 | #define IM2D_SLT_TEST_RGA2_0_AFBC32x8_EN 1 /* Enable rga2_core0 AFBC32x8 split mode case. */ 35 | #define IM2D_SLT_TEST_RGA2_0_RKFBC64x4_EN 1 /* Enable rga2_core0 AFBC32x8 split mode case. */ 36 | #define IM2D_SLT_TEST_RGA2_1_TILE_EN 1 /* Enable rga2_core1 TILE4x4 case. */ 37 | #define IM2D_SLT_TEST_RGA2_1_AFBC32x8_EN 1 /* Enable rga2_core0 AFBC32x8 split mode case. */ 38 | #define IM2D_SLT_TEST_RGA2_1_RKFBC64x4_EN 1 /* Enable rga2_core0 AFBC32x8 split mode case. */ 39 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 AFBC16x16 case. */ 40 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 AFBC16x16 case. */ 41 | 42 | #define IM2D_SLT_TEST_PERF_EN 1 /* Enable perf test. */ 43 | 44 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 45 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 46 | #if IM2D_SLT_GRAPHICBUFFER_EN 47 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 48 | #else 49 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 50 | #endif 51 | 52 | #define DEFAULT_DMA_HEAP_PATH "/dev/dma_heap/system-uncached" 53 | #define DEFAULT_DMA32_HEAP_PATH "/dev/dma_heap/system-uncached-dma32" 54 | #define RV1106_DEFAULT_DMA_HEAP_PATH "/dev/rk_dma_heap/rk-dma-heap-cma" 55 | 56 | #define IM2D_SLT_DMA_HEAP_PATH DEFAULT_DMA32_HEAP_PATH 57 | 58 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/data/rga_slt" 59 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/data/rga_slt" 60 | #define IM2D_SLT_DEFAULT_GOLDEN_PATH "/data/rga_slt/golden" -------------------------------------------------------------------------------- /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 500 /* Number of while mode. */ 24 | 25 | /* raster test */ 26 | #define IM2D_SLT_TEST_RGA2_0_EN 1 /* Enable rga2_core0 case. */ 27 | #define IM2D_SLT_TEST_RGA2_1_EN 0 /* Enable rga2_core1 case. */ 28 | #define IM2D_SLT_TEST_RGA3_0_EN 1 /* Enable rga3_core0 case. */ 29 | #define IM2D_SLT_TEST_RGA3_1_EN 1 /* Enable rga3_core1 case. */ 30 | 31 | #define IM2D_SLT_TEST_SPECIAL_EN 1 /* Enable special test. */ 32 | /* special test */ 33 | #define IM2D_SLT_TEST_RGA2_0_TILE_EN 0 /* Enable rga2_core0 TILE4x4 case. */ 34 | #define IM2D_SLT_TEST_RGA2_0_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 35 | #define IM2D_SLT_TEST_RGA2_0_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 36 | #define IM2D_SLT_TEST_RGA2_1_TILE_EN 0 /* Enable rga2_core1 TILE4x4 case. */ 37 | #define IM2D_SLT_TEST_RGA2_1_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 38 | #define IM2D_SLT_TEST_RGA2_1_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 39 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 1 /* Enable rga3_core0 AFBC16x16 case. */ 40 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 1 /* Enable rga3_core1 AFBC16x16 case. */ 41 | 42 | #define IM2D_SLT_TEST_PERF_EN 1 /* Enable perf test. */ 43 | 44 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 45 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 46 | #if IM2D_SLT_GRAPHICBUFFER_EN 47 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 48 | #else 49 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 50 | #endif 51 | 52 | #define DEFAULT_DMA_HEAP_PATH "/dev/dma_heap/system-uncached" 53 | #define DEFAULT_DMA32_HEAP_PATH "/dev/dma_heap/system-uncached-dma32" 54 | #define RV1106_DEFAULT_DMA_HEAP_PATH "/dev/rk_dma_heap/rk-dma-heap-cma" 55 | 56 | #define IM2D_SLT_DMA_HEAP_PATH DEFAULT_DMA32_HEAP_PATH 57 | 58 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/data/rga_slt" 59 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/data/rga_slt" 60 | #define IM2D_SLT_DEFAULT_GOLDEN_PATH "/data/rga_slt/golden" -------------------------------------------------------------------------------- /samples/im2d_slt/chip_config/rv1103b_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 | #ifndef _IM2D_SLT_CONFIG_H_ 20 | #define _IM2D_SLT_CONFIG_H_ 21 | 22 | /* im2d_slt config */ 23 | #define IM2D_SLT_THREAD_EN 1 /* Enable multi-threaded mode. */ 24 | #define IM2D_SLT_THREAD_MAX 10 /* Maximum number of threads. */ 25 | #define IM2D_SLT_WHILE_EN 1 /* Enable while mode, 1: while, 0 single. */ 26 | #define IM2D_SLT_WHILE_NUM 500 /* Number of while mode. */ 27 | 28 | /* raster test */ 29 | #define IM2D_SLT_TEST_RGA2_0_EN 1 /* Enable rga2_core0 case. */ 30 | #define IM2D_SLT_TEST_RGA2_1_EN 0 /* Enable rga2_core1 case. */ 31 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 32 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 33 | 34 | #define IM2d_SLT_TEST_DISABLE_ALPHA 1 /* Disable Alpha case */ 35 | 36 | #define IM2D_SLT_TEST_SPECIAL_EN 0 /* Enable special test. */ 37 | /* special test */ 38 | #define IM2D_SLT_TEST_RGA2_0_TILE_EN 0 /* Enable rga2_core0 TILE4x4 case. */ 39 | #define IM2D_SLT_TEST_RGA2_0_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 40 | #define IM2D_SLT_TEST_RGA2_0_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 41 | #define IM2D_SLT_TEST_RGA2_1_TILE_EN 0 /* Enable rga2_core1 TILE4x4 case. */ 42 | #define IM2D_SLT_TEST_RGA2_1_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 43 | #define IM2D_SLT_TEST_RGA2_1_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 44 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 AFBC16x16 case. */ 45 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 AFBC16x16 case. */ 46 | 47 | #define IM2D_SLT_TEST_PERF_EN 0 /* Enable perf test. */ 48 | 49 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 50 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 51 | #if IM2D_SLT_GRAPHICBUFFER_EN 52 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 53 | #else 54 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 55 | #endif 56 | 57 | #define DEFAULT_DMA_HEAP_PATH "/dev/dma_heap/system-uncached" 58 | #define DEFAULT_DMA32_HEAP_PATH "/dev/dma_heap/system-uncached-dma32" 59 | #define RV1106_DEFAULT_DMA_HEAP_PATH "/dev/rk_dma_heap/rk-dma-heap-cma" 60 | 61 | #define IM2D_SLT_DMA_HEAP_PATH RV1106_DEFAULT_DMA_HEAP_PATH 62 | 63 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/data/rga_slt" 64 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/data/rga_slt" 65 | 66 | /* crc32 golden config */ 67 | #define IM2D_SLT_GENERATE_CRC 0 68 | #define IM2D_SLT_GENERATE_CRC_GOLDEN_PREFIX "crcdata" 69 | #define IM2D_SLT_DEFAULT_GOLDEN_PATH "/data/rga_slt/golden" 70 | 71 | #endif /* #ifndef _IM2D_SLT_CONFIG_H_ */ 72 | -------------------------------------------------------------------------------- /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 500 /* Number of while mode. */ 24 | 25 | /* raster test */ 26 | #define IM2D_SLT_TEST_RGA2_0_EN 1 /* Enable rga2_core0 case. */ 27 | #define IM2D_SLT_TEST_RGA2_1_EN 0 /* Enable rga2_core1 case. */ 28 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 29 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 30 | 31 | #define IM2D_SLT_TEST_SPECIAL_EN 1 /* Enable special test. */ 32 | /* special test */ 33 | #define IM2D_SLT_TEST_RGA2_0_TILE_EN 0 /* Enable rga2_core0 TILE4x4 case. */ 34 | #define IM2D_SLT_TEST_RGA2_0_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 35 | #define IM2D_SLT_TEST_RGA2_0_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 36 | #define IM2D_SLT_TEST_RGA2_1_TILE_EN 0 /* Enable rga2_core1 TILE4x4 case. */ 37 | #define IM2D_SLT_TEST_RGA2_1_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 38 | #define IM2D_SLT_TEST_RGA2_1_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 39 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 AFBC16x16 case. */ 40 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 AFBC16x16 case. */ 41 | 42 | #define IM2D_SLT_TEST_PERF_EN 1 /* Enable perf test. */ 43 | 44 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 45 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 46 | #if IM2D_SLT_GRAPHICBUFFER_EN 47 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 48 | #else 49 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 50 | #endif 51 | 52 | #define DEFAULT_DMA_HEAP_PATH "/dev/dma_heap/system-uncached" 53 | #define DEFAULT_DMA32_HEAP_PATH "/dev/dma_heap/system-uncached-dma32" 54 | #define RV1106_DEFAULT_DMA_HEAP_PATH "/dev/rk_dma_heap/rk-dma-heap-cma" 55 | 56 | #define IM2D_SLT_DMA_HEAP_PATH RV1106_DEFAULT_DMA_HEAP_PATH 57 | 58 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/data/rga_slt" 59 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/data/rga_slt" 60 | #define IM2D_SLT_DEFAULT_GOLDEN_PATH "/data/rga_slt/golden" -------------------------------------------------------------------------------- /samples/im2d_slt/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 | if [ ${1} == 'c' ] 17 | then 18 | echo "compile with C" 19 | BUILD_SOURCE_TYPE=c 20 | else 21 | echo "compile with C++" 22 | BUILD_SOURCE_TYPE=cpp 23 | fi 24 | 25 | cmake ../.. \ 26 | -DLIBRGA_FILE_LIB=${LIBRGA_PATH} \ 27 | -DRGA_SOURCE_CODE_TYPE=${BUILD_SOURCE_TYPE} \ 28 | -DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \ 29 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ 30 | -DCMAKE_INSTALL_PREFIX=install \ 31 | 32 | make -j32 33 | make install 34 | 35 | popd 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | #ifndef _IM2D_SLT_CONFIG_H_ 20 | #define _IM2D_SLT_CONFIG_H_ 21 | 22 | /* im2d_slt config */ 23 | #define IM2D_SLT_THREAD_EN 1 /* Enable multi-threaded mode. */ 24 | #define IM2D_SLT_THREAD_MAX 10 /* Maximum number of threads. */ 25 | #define IM2D_SLT_WHILE_EN 1 /* Enable while mode, 1: while, 0 single. */ 26 | #define IM2D_SLT_WHILE_NUM 500 /* Number of while mode. */ 27 | 28 | /* raster test */ 29 | #define IM2D_SLT_TEST_RGA2_0_EN 1 /* Enable rga2_core0 case. */ 30 | #define IM2D_SLT_TEST_RGA2_1_EN 0 /* Enable rga2_core1 case. */ 31 | #define IM2D_SLT_TEST_RGA3_0_EN 0 /* Enable rga3_core0 case. */ 32 | #define IM2D_SLT_TEST_RGA3_1_EN 0 /* Enable rga3_core1 case. */ 33 | 34 | #define IM2d_SLT_TEST_DISABLE_ALPHA 0 /* Disable Alpha case */ 35 | 36 | #define IM2D_SLT_TEST_SPECIAL_EN 1 /* Enable special test. */ 37 | /* special test */ 38 | #define IM2D_SLT_TEST_RGA2_0_TILE_EN 0 /* Enable rga2_core0 TILE4x4 case. */ 39 | #define IM2D_SLT_TEST_RGA2_0_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 40 | #define IM2D_SLT_TEST_RGA2_0_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 41 | #define IM2D_SLT_TEST_RGA2_1_TILE_EN 0 /* Enable rga2_core1 TILE4x4 case. */ 42 | #define IM2D_SLT_TEST_RGA2_1_AFBC32x8_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 43 | #define IM2D_SLT_TEST_RGA2_1_RKFBC64x4_EN 0 /* Enable rga2_core0 AFBC32x8 split mode case. */ 44 | #define IM2D_SLT_TEST_RGA3_0_FBC_EN 0 /* Enable rga3_core0 AFBC16x16 case. */ 45 | #define IM2D_SLT_TEST_RGA3_1_FBC_EN 0 /* Enable rga3_core1 AFBC16x16 case. */ 46 | 47 | #define IM2D_SLT_TEST_PERF_EN 1 /* Enable perf test. */ 48 | 49 | #define IM2D_SLT_DEFAULT_WIDTH 1280 /* Default image width. */ 50 | #define IM2D_SLT_DEFAULT_HEIGHT 720 /* Default image height. */ 51 | #if IM2D_SLT_GRAPHICBUFFER_EN 52 | #define IM2D_SLT_DEFAULT_FORMAT HAL_PIXEL_FORMAT_RGBA_8888 /* Default image format. */ 53 | #else 54 | #define IM2D_SLT_DEFAULT_FORMAT RK_FORMAT_RGBA_8888 /* Default image format. */ 55 | #endif 56 | 57 | #define DEFAULT_DMA_HEAP_PATH "/dev/dma_heap/system-uncached" 58 | #define DEFAULT_DMA32_HEAP_PATH "/dev/dma_heap/system-uncached-dma32" 59 | #define RV1106_DEFAULT_DMA_HEAP_PATH "/dev/rk_dma_heap/rk-dma-heap-cma" 60 | 61 | #define IM2D_SLT_DMA_HEAP_PATH DEFAULT_DMA32_HEAP_PATH 62 | 63 | #define IM2D_SLT_DEFAULT_INPUT_PATH "/data/rga_slt" 64 | #define IM2D_SLT_DEFAULT_OUTPUT_PATH "/data/rga_slt" 65 | 66 | /* crc32 golden config */ 67 | #define IM2D_SLT_GENERATE_CRC 0 68 | #define IM2D_SLT_GENERATE_CRC_GOLDEN_PREFIX "crcdata" 69 | #define IM2D_SLT_DEFAULT_GOLDEN_PATH "/data/rga_slt/golden" 70 | 71 | #endif /* #ifndef _IM2D_SLT_CONFIG_H_ */ 72 | -------------------------------------------------------------------------------- /samples/mosaic_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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 | -------------------------------------------------------------------------------- /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 | ts = get_cur_us(); 95 | 96 | ret = immosaic(dst, dst_rect, IM_MOSAIC_32); 97 | if (ret == IM_STATUS_SUCCESS) { 98 | printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts); 99 | } else { 100 | printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret)); 101 | goto release_buffer; 102 | } 103 | 104 | printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]); 105 | write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0); 106 | 107 | release_buffer: 108 | if (dst_handle > 0) 109 | releasebuffer_handle(dst_handle); 110 | 111 | free_buf: 112 | if (dst_buf) 113 | free(dst_buf); 114 | 115 | return 0; 116 | } 117 | -------------------------------------------------------------------------------- /samples/padding_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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 | -------------------------------------------------------------------------------- /samples/resize_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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 | # rga_resize_config_interpolation_demo 35 | SET(DEMO_NAME rga_resize_config_interpolation_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 | -------------------------------------------------------------------------------- /samples/rop_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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/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/sample_file/in0w1280-h720-rgba8888.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/samples/sample_file/in0w1280-h720-rgba8888.bin -------------------------------------------------------------------------------- /samples/sample_file/in1w1280-h720-rgba8888.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/samples/sample_file/in1w1280-h720-rgba8888.bin -------------------------------------------------------------------------------- /samples/transform_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 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/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-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/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 | -------------------------------------------------------------------------------- /samples/utils/3rdparty/3rdparty.mk: -------------------------------------------------------------------------------- 1 | #====================================================================== 2 | # 3 | # samples/utils/3rdparty 4 | # 5 | #====================================================================== 6 | 3RDPARTY_PATH:=$(call my-dir) 7 | 8 | LOCAL_C_INCLUDES += \ 9 | $(3RDPARTY_PATH)/libdrm/include \ 10 | $(3RDPARTY_PATH)/libdrm/include/libdrm \ 11 | -------------------------------------------------------------------------------- /samples/utils/3rdparty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( 2 | ${CMAKE_CURRENT_LIST_DIR}/libdrm/include 3 | ${CMAKE_CURRENT_LIST_DIR}/libdrm/include/libdrm 4 | ) 5 | -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/lib/android/arm32/libdrm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/samples/utils/3rdparty/libdrm/lib/android/arm32/libdrm.so -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/lib/android/arm64/libdrm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/samples/utils/3rdparty/libdrm/lib/android/arm64/libdrm.so -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/lib/arm32/libdrm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/samples/utils/3rdparty/libdrm/lib/arm32/libdrm.so -------------------------------------------------------------------------------- /samples/utils/3rdparty/libdrm/lib/arm64/libdrm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tsukumijima/librga-rockchip/e454afed7e44bdc205ab5620e5aeaeeb521ce502/samples/utils/3rdparty/libdrm/lib/arm64/libdrm.so -------------------------------------------------------------------------------- /samples/utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | add_library(utils_obj OBJECT "") 4 | 5 | SET(THIRD_PARTY_PATH ${CMAKE_CURRENT_LIST_DIR}/3rdparty) 6 | SET(UTILS_LIBRGA_SOURCE_PATH ${CMAKE_CURRENT_LIST_DIR}/../..) 7 | 8 | include(${CMAKE_CURRENT_LIST_DIR}/allocator/CMakeLists.txt) 9 | include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/CMakeLists.txt) 10 | 11 | set(UTILS_SRC 12 | ${CMAKE_CURRENT_LIST_DIR}/utils.cpp 13 | ) 14 | 15 | if(RGA_SOURCE_CODE_TYPE STREQUAL c) 16 | set_source_files_properties(${UTILS_SRC} PROPERTIES LANGUAGE C COMPILE_FLAGS "-x c") 17 | endif() 18 | 19 | target_sources(utils_obj 20 | PRIVATE 21 | ${UTILS_SRC} 22 | PUBLIC 23 | ${CMAKE_CURRENT_LIST_DIR}/utils.h 24 | ) 25 | 26 | target_include_directories(utils_obj 27 | PRIVATE 28 | ${UTILS_LIBRGA_SOURCE_PATH}/include 29 | PUBLIC 30 | ${CMAKE_CURRENT_LIST_DIR} 31 | ) 32 | 33 | SET(RGA_SAMPLES_UTILS_COMPILED "true" CACHE STRING "") 34 | -------------------------------------------------------------------------------- /samples/utils/allocator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(DMA_ALLOC_SRC 2 | ${CMAKE_CURRENT_LIST_DIR}/dma_alloc.cpp 3 | ) 4 | 5 | set(DRM_ALLOC_SRC 6 | ${CMAKE_CURRENT_LIST_DIR}/drm_alloc.cpp 7 | ) 8 | 9 | if(RGA_SOURCE_CODE_TYPE STREQUAL c) 10 | set_source_files_properties(${DMA_ALLOC_SRC} PROPERTIES LANGUAGE C COMPILE_FLAGS "-x c") 11 | set_source_files_properties(${DRM_ALLOC_SRC} PROPERTIES LANGUAGE C COMPILE_FLAGS "-x c") 12 | endif() 13 | 14 | target_sources(utils_obj 15 | PRIVATE 16 | ${DMA_ALLOC_SRC} 17 | ${DRM_ALLOC_SRC} 18 | PUBLIC 19 | ${CMAKE_CURRENT_LIST_DIR}/include/dma_alloc.h 20 | ${CMAKE_CURRENT_LIST_DIR}/include/drm_alloc.h 21 | ) 22 | 23 | target_include_directories(utils_obj 24 | PUBLIC 25 | ${THIRD_PARTY_PATH}/libdrm/include 26 | ${THIRD_PARTY_PATH}/libdrm/include/libdrm 27 | ${CMAKE_CURRENT_LIST_DIR}/include 28 | ) 29 | 30 | target_link_libraries(utils_obj INTERFACE dl) 31 | -------------------------------------------------------------------------------- /samples/utils/allocator/allocator.mk: -------------------------------------------------------------------------------- 1 | #====================================================================== 2 | # 3 | # samples/utils/allocator 4 | # 5 | #====================================================================== 6 | ALLOCATOR_PATH:=$(call my-dir) 7 | ALLOCATOR_SOURCE_PATH := $(patsubst $(LOCAL_PATH)/%,%,$(ALLOCATOR_PATH)) 8 | 9 | LOCAL_C_INCLUDES += \ 10 | $(ALLOCATOR_PATH)/include \ 11 | 12 | LOCAL_SRC_FILES += \ 13 | $(ALLOCATOR_SOURCE_PATH)/drm_alloc.cpp \ 14 | $(ALLOCATOR_SOURCE_PATH)/dma_alloc.cpp \ 15 | -------------------------------------------------------------------------------- /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_UNCACHED_PATH "/dev/dma_heap/system-uncached-dma32" 25 | #define DMA_HEAP_DMA32_PATH "/dev/dma_heap/system-dma32" 26 | #define CMA_HEAP_UNCACHED_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 | -------------------------------------------------------------------------------- /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 | RGA_UTILS_ROCKCHIP_BO_CONTIG = 1 << 0, 27 | /* cachable mapping. */ 28 | RGA_UTILS_ROCKCHIP_BO_CACHABLE = 1 << 1, 29 | /* write-combine mapping. */ 30 | RGA_UTILS_ROCKCHIP_BO_WC = 1 << 2, 31 | RGA_UTILS_ROCKCHIP_BO_SECURE = 1 << 3, 32 | RGA_UTILS_ROCKCHIP_BO_MASK = RGA_UTILS_ROCKCHIP_BO_CONTIG | RGA_UTILS_ROCKCHIP_BO_CACHABLE | 33 | RGA_UTILS_ROCKCHIP_BO_WC | RGA_UTILS_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/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/utils.mk: -------------------------------------------------------------------------------- 1 | #====================================================================== 2 | # 3 | # samples/utils 4 | # 5 | #====================================================================== 6 | UTILS_PATH:=$(call my-dir) 7 | UTILS_SOURCE_PATH := $(patsubst $(LOCAL_PATH)/%,%,$(UTILS_PATH)) 8 | 9 | LOCAL_C_INCLUDES += \ 10 | $(UTILS_PATH) \ 11 | 12 | LOCAL_SRC_FILES += \ 13 | $(UTILS_SOURCE_PATH)/utils.cpp 14 | 15 | include $(UTILS_PATH)/3rdparty/3rdparty.mk 16 | include $(UTILS_PATH)/allocator/allocator.mk 17 | 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /toolchains/toolchain_linux.cmake: -------------------------------------------------------------------------------- 1 | SET(TOOLCHAIN_HOME "/home/yqw/workspace/linux/common/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 | -------------------------------------------------------------------------------- /toolchains/toolchain_linux_1106.cmake: -------------------------------------------------------------------------------- 1 | SET(TOOLCHAIN_HOME "/home/yqw/workspace/linux/ipc/1106/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf") 2 | SET(TOOLCHAIN_NAME "arm-rockchip830-linux-uclibcgnueabihf") 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 | 20 | -------------------------------------------------------------------------------- /toolchains/toolchain_rt_thread.cmake: -------------------------------------------------------------------------------- 1 | SET(TOOLCHAIN_HOME "/home/yqw/workspace/linux/common/prebuilts/gcc/linux-x86/arm/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux") 2 | SET(TOOLCHAIN_NAME "arm-none-eabi") 3 | 4 | SET(RTT_DEVICE_FLAGS " -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=vfpv4 -marm -ffast-math") 5 | 6 | # this is required 7 | SET(CMAKE_SYSTEM_NAME Generic) 8 | 9 | 10 | # specify the cross compiler 11 | SET(CMAKE_C_COMPILER ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-gcc) 12 | SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-g++) 13 | set(CMAKE_LINKER ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-ld) 14 | set(CMAKE_AR ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-ar) 15 | set(CMAKE_RANLIB ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-ranlib) 16 | set(CMAKE_STRIP ${TOOLCHAIN_HOME}/bin/${TOOLCHAIN_NAME}-strip) 17 | 18 | add_compile_options(-mcpu=cortex-a7 -mfloat-abi=hard -mfpu=vfpv4 -marm -ffast-math) 19 | set(DEVICE_FLAGS "-mcpu=cortex-a7 -mfloat-abi=hard -mfpu=vfpv4 -marm -ffast-math") 20 | 21 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -g -Wno-stringop-truncation") 22 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -g -Wno-stringop-truncation") 23 | 24 | set(ARM_LINKER_FLAGS "${DEVICE_FLAGS} -lm -lgcc -lc -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors") 25 | set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") 26 | set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}") 27 | set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") 28 | 29 | # where is the target environment 30 | SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_HOME}) 31 | 32 | # search for programs in the build host directories (not necessary) 33 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 34 | # for libraries and headers in the target directories 35 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 36 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 37 | --------------------------------------------------------------------------------