├── .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