mirror of
https://github.com/LuckfoxTECH/luckfox-pico.git
synced 2026-01-19 17:59:18 +01:00
project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp: Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem. sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately. sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades. sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for fastboot. Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
@@ -21,6 +21,10 @@ PKG_CONF_OPTS += -DLIBDRM_FILE_INCLUDE=$(CURRENT_DIR)/../libdrm/out/include
|
||||
PKG_CONF_OPTS += -DLIBDRM_FILE_LIB=$(CURRENT_DIR)/../libdrm/out/lib
|
||||
endif
|
||||
|
||||
PKG_CONF_OPTS += -DRKRGA_TARGET_SOC=$(CONFIG_RK_CHIP)
|
||||
|
||||
PKG_CONF_OPTS += -DRGA_ENABLE_INSTALL_SAMPLES=ON
|
||||
|
||||
ifeq ($(CONFIG_RK_RGA2),y)
|
||||
PKG_TARGET := rga-build
|
||||
endif
|
||||
@@ -63,6 +67,7 @@ rga-build: libdrm rga-release
|
||||
popd; \
|
||||
mkdir -p $(CURRENT_DIR)/$(PKG_BIN)/include/rga; \
|
||||
mv -f `find $(CURRENT_DIR)/$(PKG_BIN)/include -type f` $(CURRENT_DIR)/$(PKG_BIN)/include/rga; \
|
||||
mv $(CURRENT_DIR)/$(PKG_BIN)/samples $(CURRENT_DIR)/$(PKG_BIN)/rga_samples; \
|
||||
) || exit -1;
|
||||
|
||||
rga-release:
|
||||
@@ -70,7 +75,7 @@ rga-release:
|
||||
|
||||
libdrm:
|
||||
ifeq ($(CONFIG_RK_RGA2_USE_LIBDRM),y)
|
||||
@make -C ../libdrm
|
||||
@test -f $(RK_MEDIA_OUTPUT)/lib/libdrm.so || make -C $(RK_MEDIA_TOP_DIR)/libdrm
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
||||
@@ -22,36 +22,38 @@
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <vector>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <system/graphics.h>
|
||||
|
||||
#include <utils/Thread.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <linux/stddef.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include <android/log.h>
|
||||
#include <log/log_main.h>
|
||||
#include <utils/Atomic.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <android/log.h>
|
||||
#include <utils/Log.h>
|
||||
#include <log/log_main.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "rga.h"
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
int RkRgaGetHandleFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleAttributes(buffer_handle_t handle, std::vector<int> *attrs);
|
||||
int RkRgaGetHandleMapAddress(buffer_handle_t handle, void **buf);
|
||||
#endif // Android
|
||||
int RkRgaGetHandleFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleAttributes(buffer_handle_t handle,
|
||||
std::vector<int> *attrs);
|
||||
int RkRgaGetHandleMapAddress(buffer_handle_t handle,
|
||||
void **buf);
|
||||
#endif //Android
|
||||
|
||||
#endif //_rk_graphic_buffer_h_
|
||||
#endif //_rk_graphic_buffer_h_
|
||||
|
||||
@@ -18,23 +18,23 @@
|
||||
#ifndef _rockchip_rga_c_h_
|
||||
#define _rockchip_rga_c_h_
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <linux/stddef.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "rga.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -44,28 +44,26 @@ extern "C" {
|
||||
* compatibility with the old C interface, so please do
|
||||
* not use ctx, because it is usually a NULL.
|
||||
*/
|
||||
#define RgaInit(ctx) \
|
||||
({ \
|
||||
int ret = 0; \
|
||||
ret = c_RkRgaInit(); \
|
||||
c_RkRgaGetContext(ctx); \
|
||||
ret; \
|
||||
})
|
||||
#define RgaDeInit(ctx) \
|
||||
{ \
|
||||
(void)ctx; /* unused */ \
|
||||
c_RkRgaDeInit(); \
|
||||
}
|
||||
#define RgaInit(ctx) ({ \
|
||||
int ret = 0; \
|
||||
ret = c_RkRgaInit(); \
|
||||
c_RkRgaGetContext(ctx); \
|
||||
ret;\
|
||||
})
|
||||
#define RgaDeInit(ctx) { \
|
||||
(void)ctx; /* unused */ \
|
||||
c_RkRgaDeInit(); \
|
||||
}
|
||||
#define RgaBlit(...) c_RkRgaBlit(__VA_ARGS__)
|
||||
#define RgaCollorFill(...) c_RkRgaColorFill(__VA_ARGS__)
|
||||
#define RgaFlush() c_RkRgaFlush()
|
||||
|
||||
int c_RkRgaInit();
|
||||
int c_RkRgaInit();
|
||||
void c_RkRgaDeInit();
|
||||
void c_RkRgaGetContext(void **ctx);
|
||||
int c_RkRgaBlit(rga_info_t *src, rga_info_t *dst, rga_info_t *src1);
|
||||
int c_RkRgaColorFill(rga_info_t *dst);
|
||||
int c_RkRgaFlush();
|
||||
int c_RkRgaBlit(rga_info_t *src, rga_info_t *dst, rga_info_t *src1);
|
||||
int c_RkRgaColorFill(rga_info_t *dst);
|
||||
int c_RkRgaFlush();
|
||||
|
||||
#ifndef ANDROID /* linux */
|
||||
int c_RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LIBS_RGA_MUTEX_H
|
||||
#define _LIBS_RGA_MUTEX_H
|
||||
|
||||
@@ -26,12 +27,13 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
// Enable thread safety attributes only with clang.
|
||||
// The attributes can be safely erased when compiling with other compilers.
|
||||
#if defined(__clang__) && (!defined(SWIG))
|
||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
|
||||
#else
|
||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
|
||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
|
||||
#endif
|
||||
|
||||
#define CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
|
||||
@@ -42,47 +44,36 @@
|
||||
|
||||
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
|
||||
|
||||
#define ACQUIRED_BEFORE(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
|
||||
#define ACQUIRED_BEFORE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRED_AFTER(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
|
||||
#define ACQUIRED_AFTER(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
|
||||
|
||||
#define REQUIRES(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
|
||||
#define REQUIRES(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
|
||||
|
||||
#define REQUIRES_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
|
||||
#define REQUIRES_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRE(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
|
||||
#define ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
|
||||
#define ACQUIRE_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define RELEASE(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
|
||||
#define RELEASE(...) THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
|
||||
|
||||
#define RELEASE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
|
||||
#define RELEASE_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define TRY_ACQUIRE(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
|
||||
#define TRY_ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
|
||||
|
||||
#define TRY_ACQUIRE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
|
||||
#define TRY_ACQUIRE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
|
||||
|
||||
#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
|
||||
|
||||
#define ASSERT_SHARED_CAPABILITY(x) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
|
||||
#define ASSERT_SHARED_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
|
||||
|
||||
#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
|
||||
|
||||
#define NO_THREAD_SAFETY_ANALYSIS \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
|
||||
#define NO_THREAD_SAFETY_ANALYSIS THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
|
||||
|
||||
class Condition;
|
||||
|
||||
@@ -97,81 +88,96 @@ class Condition;
|
||||
* recursive, i.e. the same thread can't lock it multiple times.
|
||||
*/
|
||||
class CAPABILITY("mutex") Mutex {
|
||||
public:
|
||||
enum { PRIVATE = 0, SHARED = 1 };
|
||||
|
||||
Mutex();
|
||||
explicit Mutex(const char *name);
|
||||
explicit Mutex(int type, const char *name = nullptr);
|
||||
~Mutex();
|
||||
|
||||
// lock or unlock the mutex
|
||||
int32_t lock() ACQUIRE();
|
||||
void unlock() RELEASE();
|
||||
|
||||
// lock if possible; returns 0 on success, error otherwise
|
||||
int32_t tryLock() TRY_ACQUIRE(0);
|
||||
|
||||
int32_t timedLock(int64_t timeoutNs) TRY_ACQUIRE(0);
|
||||
|
||||
// Manages the mutex automatically. It'll be locked when Autolock is
|
||||
// constructed and released when Autolock goes out of scope.
|
||||
class SCOPED_CAPABILITY Autolock {
|
||||
public:
|
||||
inline explicit Autolock(Mutex &mutex) ACQUIRE(mutex) : mLock(mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline explicit Autolock(Mutex *mutex) ACQUIRE(mutex) : mLock(*mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline ~Autolock() RELEASE() { mLock.unlock(); }
|
||||
enum {
|
||||
PRIVATE = 0,
|
||||
SHARED = 1
|
||||
};
|
||||
|
||||
Mutex();
|
||||
explicit Mutex(const char* name);
|
||||
explicit Mutex(int type, const char* name = nullptr);
|
||||
~Mutex();
|
||||
|
||||
// lock or unlock the mutex
|
||||
int32_t lock() ACQUIRE();
|
||||
void unlock() RELEASE();
|
||||
|
||||
// lock if possible; returns 0 on success, error otherwise
|
||||
int32_t tryLock() TRY_ACQUIRE(0);
|
||||
|
||||
int32_t timedLock(int64_t timeoutNs) TRY_ACQUIRE(0);
|
||||
|
||||
// Manages the mutex automatically. It'll be locked when Autolock is
|
||||
// constructed and released when Autolock goes out of scope.
|
||||
class SCOPED_CAPABILITY Autolock {
|
||||
public:
|
||||
inline explicit Autolock(Mutex& mutex) ACQUIRE(mutex) : mLock(mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline explicit Autolock(Mutex* mutex) ACQUIRE(mutex) : mLock(*mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline ~Autolock() RELEASE() {
|
||||
mLock.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
Mutex& mLock;
|
||||
// Cannot be copied or moved - declarations only
|
||||
Autolock(const Autolock&);
|
||||
Autolock& operator=(const Autolock&);
|
||||
};
|
||||
|
||||
private:
|
||||
Mutex &mLock;
|
||||
// Cannot be copied or moved - declarations only
|
||||
Autolock(const Autolock &);
|
||||
Autolock &operator=(const Autolock &);
|
||||
};
|
||||
friend class Condition;
|
||||
|
||||
private:
|
||||
friend class Condition;
|
||||
// A mutex cannot be copied
|
||||
Mutex(const Mutex&);
|
||||
Mutex& operator=(const Mutex&);
|
||||
|
||||
// A mutex cannot be copied
|
||||
Mutex(const Mutex &);
|
||||
Mutex &operator=(const Mutex &);
|
||||
|
||||
pthread_mutex_t mMutex;
|
||||
pthread_mutex_t mMutex;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline Mutex::Mutex() { pthread_mutex_init(&mMutex, nullptr); }
|
||||
inline Mutex::Mutex(__attribute__((unused)) const char *name) {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
inline Mutex::Mutex(int type, __attribute__((unused)) const char *name) {
|
||||
if (type == SHARED) {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||
pthread_mutex_init(&mMutex, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
} else {
|
||||
inline Mutex::Mutex() {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
}
|
||||
inline Mutex::~Mutex() { pthread_mutex_destroy(&mMutex); }
|
||||
inline int32_t Mutex::lock() { return -pthread_mutex_lock(&mMutex); }
|
||||
inline void Mutex::unlock() { pthread_mutex_unlock(&mMutex); }
|
||||
inline int32_t Mutex::tryLock() { return -pthread_mutex_trylock(&mMutex); }
|
||||
inline Mutex::Mutex(__attribute__((unused)) const char* name) {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) {
|
||||
if (type == SHARED) {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||
pthread_mutex_init(&mMutex, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
} else {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
}
|
||||
inline Mutex::~Mutex() {
|
||||
pthread_mutex_destroy(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::lock() {
|
||||
return -pthread_mutex_lock(&mMutex);
|
||||
}
|
||||
inline void Mutex::unlock() {
|
||||
pthread_mutex_unlock(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::tryLock() {
|
||||
return -pthread_mutex_trylock(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::timedLock(int64_t timeoutNs) {
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
timeoutNs += now.tv_sec * 1000000000 + now.tv_nsec;
|
||||
const struct timespec ts = {
|
||||
/* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),
|
||||
/* .tv_nsec = */ static_cast<long>(timeoutNs % 1000000000),
|
||||
};
|
||||
return -pthread_mutex_timedlock(&mMutex, &ts);
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
timeoutNs += now.tv_sec*1000000000 + now.tv_nsec;
|
||||
const struct timespec ts = {
|
||||
/* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),
|
||||
/* .tv_nsec = */ static_cast<long>(timeoutNs % 1000000000),
|
||||
};
|
||||
return -pthread_mutex_timedlock(&mMutex, &ts);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LIBS_RGA_SINGLETON_H
|
||||
#define _LIBS_RGA_SINGLETON_H
|
||||
|
||||
@@ -27,42 +27,44 @@
|
||||
#pragma clang diagnostic ignored "-Wundefined-var-template"
|
||||
#endif
|
||||
|
||||
template <typename TYPE> class Singleton {
|
||||
public:
|
||||
static TYPE &getInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
TYPE *instance = sInstance;
|
||||
if (instance == nullptr) {
|
||||
instance = new TYPE();
|
||||
sInstance = instance;
|
||||
template <typename TYPE>
|
||||
class Singleton {
|
||||
public:
|
||||
static TYPE& getInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
TYPE* instance = sInstance;
|
||||
if (instance == nullptr) {
|
||||
instance = new TYPE();
|
||||
sInstance = instance;
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
|
||||
static bool hasInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
return sInstance != nullptr;
|
||||
}
|
||||
static bool hasInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
return sInstance != nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
~Singleton() {}
|
||||
Singleton() {}
|
||||
protected:
|
||||
~Singleton() { }
|
||||
Singleton() { }
|
||||
|
||||
private:
|
||||
Singleton(const Singleton &);
|
||||
Singleton &operator=(const Singleton &);
|
||||
static Mutex sLock;
|
||||
static TYPE *sInstance;
|
||||
private:
|
||||
Singleton(const Singleton&);
|
||||
Singleton& operator = (const Singleton&);
|
||||
static Mutex sLock;
|
||||
static TYPE* sInstance;
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#define RGA_SINGLETON_STATIC_INSTANCE(TYPE) \
|
||||
template <>::Mutex(::Singleton<TYPE>::sLock)(::Mutex::PRIVATE); \
|
||||
template <> TYPE * ::Singleton<TYPE>::sInstance(nullptr); /* NOLINT */ \
|
||||
template class ::Singleton<TYPE>;
|
||||
#define RGA_SINGLETON_STATIC_INSTANCE(TYPE) \
|
||||
template<> ::Mutex \
|
||||
(::Singleton< TYPE >::sLock)(::Mutex::PRIVATE); \
|
||||
template<> TYPE* ::Singleton< TYPE >::sInstance(nullptr); /* NOLINT */ \
|
||||
template class ::Singleton< TYPE >;
|
||||
|
||||
#endif // ANDROID
|
||||
#endif //ANDROID
|
||||
#endif //_LIBS_RGA_SINGLETON_H
|
||||
|
||||
@@ -28,3 +28,4 @@ const char *translate_format_str(int format);
|
||||
int get_buf_from_file_FBC(void *buf, int f, int sw, int sh, int index);
|
||||
int output_buf_data_to_file_FBC(void *buf, int f, int sw, int sh, int index);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
#ifndef _rockchip_rga_h_
|
||||
#define _rockchip_rga_h_
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "GrallocOps.h"
|
||||
#include "RgaUtils.h"
|
||||
#include "drmrga.h"
|
||||
#include "rga.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -41,61 +41,70 @@
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <hardware/hardware.h>
|
||||
#include <utils/Singleton.h>
|
||||
#include <utils/Thread.h>
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
namespace android {
|
||||
#endif
|
||||
|
||||
class RockchipRga : public Singleton<RockchipRga> {
|
||||
public:
|
||||
static inline RockchipRga &get() { return getInstance(); }
|
||||
class RockchipRga :public Singleton<RockchipRga> {
|
||||
public:
|
||||
|
||||
int RkRgaInit();
|
||||
void RkRgaDeInit();
|
||||
void RkRgaGetContext(void **ctx);
|
||||
static inline RockchipRga& get() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
int RkRgaInit();
|
||||
void RkRgaDeInit();
|
||||
void RkRgaGetContext(void **ctx);
|
||||
#ifndef ANDROID /* LINUX */
|
||||
int RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info, int width,
|
||||
int height, int bpp, int flags);
|
||||
int RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
|
||||
int RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp,
|
||||
int flags);
|
||||
int RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetMmap(bo_t *bo_info);
|
||||
int RkRgaUnmap(bo_t *bo_info);
|
||||
int RkRgaFree(bo_t *bo_info);
|
||||
int RkRgaGetBufferFd(bo_t *bo_info, int *fd);
|
||||
int RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
|
||||
int width, int height, int bpp, int flags);
|
||||
int RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
|
||||
int RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
|
||||
int RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetMmap(bo_t *bo_info);
|
||||
int RkRgaUnmap(bo_t *bo_info);
|
||||
int RkRgaFree(bo_t *bo_info);
|
||||
int RkRgaGetBufferFd(bo_t *bo_info, int *fd);
|
||||
#else
|
||||
int RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
|
||||
int RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
|
||||
#endif
|
||||
int RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
|
||||
int RkRgaCollorFill(rga_info *dst);
|
||||
int RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
|
||||
int RkRgaFlush();
|
||||
int RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
|
||||
int RkRgaCollorFill(rga_info *dst);
|
||||
int RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
|
||||
int RkRgaFlush();
|
||||
|
||||
void RkRgaSetLogOnceFlag(int log) { mLogOnce = log; }
|
||||
void RkRgaSetAlwaysLogFlag(bool log) { mLogAlways = log; }
|
||||
void RkRgaLogOutRgaReq(struct rga_req rgaReg);
|
||||
int RkRgaLogOutUserPara(rga_info *rgaInfo);
|
||||
inline bool RkRgaIsReady() { return mSupportRga; }
|
||||
|
||||
RockchipRga();
|
||||
~RockchipRga();
|
||||
void RkRgaSetLogOnceFlag(int log) {
|
||||
mLogOnce = log;
|
||||
}
|
||||
void RkRgaSetAlwaysLogFlag(bool log) {
|
||||
mLogAlways = log;
|
||||
}
|
||||
void RkRgaLogOutRgaReq(struct rga_req rgaReg);
|
||||
int RkRgaLogOutUserPara(rga_info *rgaInfo);
|
||||
inline bool RkRgaIsReady() {
|
||||
return mSupportRga;
|
||||
}
|
||||
|
||||
private:
|
||||
bool mSupportRga;
|
||||
int mLogOnce;
|
||||
int mLogAlways;
|
||||
void *mContext;
|
||||
RockchipRga();
|
||||
~RockchipRga();
|
||||
private:
|
||||
bool mSupportRga;
|
||||
int mLogOnce;
|
||||
int mLogAlways;
|
||||
void * mContext;
|
||||
|
||||
friend class Singleton<RockchipRga>;
|
||||
};
|
||||
friend class Singleton<RockchipRga>;
|
||||
};
|
||||
|
||||
#ifdef ANDROID
|
||||
}; // namespace android
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#ifndef _rk_drm_rga_
|
||||
#define _rk_drm_rga_
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include "rga.h"
|
||||
@@ -28,10 +28,10 @@
|
||||
#ifdef ANDROID
|
||||
#define DRMRGA_HARDWARE_MODULE_ID "librga"
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
#include <hardware/gralloc.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <system/graphics.h>
|
||||
#include <cutils/native_handle.h>
|
||||
|
||||
#ifdef ANDROID_12
|
||||
#include <hardware/hardware_rockchip.h>
|
||||
@@ -41,67 +41,67 @@
|
||||
|
||||
#ifndef ANDROID /* LINUX */
|
||||
/* flip source image horizontally (around the vertical axis) */
|
||||
#define HAL_TRANSFORM_FLIP_H 0x01
|
||||
#define HAL_TRANSFORM_FLIP_H 0x01
|
||||
/* flip source image vertically (around the horizontal axis)*/
|
||||
#define HAL_TRANSFORM_FLIP_V 0x02
|
||||
#define HAL_TRANSFORM_FLIP_V 0x02
|
||||
/* rotate source image 90 degrees clockwise */
|
||||
#define HAL_TRANSFORM_ROT_90 0x04
|
||||
#define HAL_TRANSFORM_ROT_90 0x04
|
||||
/* rotate source image 180 degrees */
|
||||
#define HAL_TRANSFORM_ROT_180 0x03
|
||||
#define HAL_TRANSFORM_ROT_180 0x03
|
||||
/* rotate source image 270 degrees clockwise */
|
||||
#define HAL_TRANSFORM_ROT_270 0x07
|
||||
#define HAL_TRANSFORM_ROT_270 0x07
|
||||
#endif
|
||||
|
||||
#define HAL_TRANSFORM_FLIP_H_V 0x08
|
||||
#define HAL_TRANSFORM_FLIP_H_V 0x08
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* for compatibility */
|
||||
#define DRM_RGA_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1
|
||||
#define DRM_RGA_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1
|
||||
#define DRM_RGA_API_VERSION HWC_DEVICE_API_VERSION
|
||||
#define DRM_RGA_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1
|
||||
#define DRM_RGA_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1
|
||||
#define DRM_RGA_API_VERSION HWC_DEVICE_API_VERSION
|
||||
|
||||
#define DRM_RGA_TRANSFORM_ROT_MASK 0x0000000F
|
||||
#define DRM_RGA_TRANSFORM_ROT_0 0x00000000
|
||||
#define DRM_RGA_TRANSFORM_ROT_90 HAL_TRANSFORM_ROT_90
|
||||
#define DRM_RGA_TRANSFORM_ROT_180 HAL_TRANSFORM_ROT_180
|
||||
#define DRM_RGA_TRANSFORM_ROT_270 HAL_TRANSFORM_ROT_270
|
||||
#define DRM_RGA_TRANSFORM_ROT_MASK 0x0000000F
|
||||
#define DRM_RGA_TRANSFORM_ROT_0 0x00000000
|
||||
#define DRM_RGA_TRANSFORM_ROT_90 HAL_TRANSFORM_ROT_90
|
||||
#define DRM_RGA_TRANSFORM_ROT_180 HAL_TRANSFORM_ROT_180
|
||||
#define DRM_RGA_TRANSFORM_ROT_270 HAL_TRANSFORM_ROT_270
|
||||
|
||||
#define DRM_RGA_TRANSFORM_FLIP_MASK 0x00000003
|
||||
#define DRM_RGA_TRANSFORM_FLIP_H HAL_TRANSFORM_FLIP_H
|
||||
#define DRM_RGA_TRANSFORM_FLIP_V HAL_TRANSFORM_FLIP_V
|
||||
#define DRM_RGA_TRANSFORM_FLIP_MASK 0x00000003
|
||||
#define DRM_RGA_TRANSFORM_FLIP_H HAL_TRANSFORM_FLIP_H
|
||||
#define DRM_RGA_TRANSFORM_FLIP_V HAL_TRANSFORM_FLIP_V
|
||||
|
||||
enum {
|
||||
AWIDTH = 0,
|
||||
AHEIGHT,
|
||||
ASTRIDE,
|
||||
AFORMAT,
|
||||
ASIZE,
|
||||
ATYPE,
|
||||
AWIDTH = 0,
|
||||
AHEIGHT,
|
||||
ASTRIDE,
|
||||
AFORMAT,
|
||||
ASIZE,
|
||||
ATYPE,
|
||||
};
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef ANDROID
|
||||
/* memory type definitions. */
|
||||
enum drm_rockchip_gem_mem_type {
|
||||
/* Physically Continuous memory and used as default. */
|
||||
ROCKCHIP_BO_CONTIG = 1 << 0,
|
||||
/* cachable mapping. */
|
||||
ROCKCHIP_BO_CACHABLE = 1 << 1,
|
||||
/* write-combine mapping. */
|
||||
ROCKCHIP_BO_WC = 1 << 2,
|
||||
ROCKCHIP_BO_SECURE = 1 << 3,
|
||||
ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE |
|
||||
ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE
|
||||
/* Physically Continuous memory and used as default. */
|
||||
ROCKCHIP_BO_CONTIG = 1 << 0,
|
||||
/* cachable mapping. */
|
||||
ROCKCHIP_BO_CACHABLE = 1 << 1,
|
||||
/* write-combine mapping. */
|
||||
ROCKCHIP_BO_WC = 1 << 2,
|
||||
ROCKCHIP_BO_SECURE = 1 << 3,
|
||||
ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE |
|
||||
ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE
|
||||
};
|
||||
|
||||
typedef struct bo {
|
||||
int fd;
|
||||
void *ptr;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
size_t pitch;
|
||||
unsigned handle;
|
||||
int fd;
|
||||
void *ptr;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
size_t pitch;
|
||||
unsigned handle;
|
||||
} bo_t;
|
||||
#endif
|
||||
|
||||
@@ -109,33 +109,33 @@ typedef struct bo {
|
||||
@value size: user not need care about.For avoid read/write out of memory
|
||||
*/
|
||||
typedef struct rga_rect {
|
||||
int xoffset;
|
||||
int yoffset;
|
||||
int width;
|
||||
int height;
|
||||
int wstride;
|
||||
int hstride;
|
||||
int format;
|
||||
int size;
|
||||
int xoffset;
|
||||
int yoffset;
|
||||
int width;
|
||||
int height;
|
||||
int wstride;
|
||||
int hstride;
|
||||
int format;
|
||||
int size;
|
||||
} rga_rect_t;
|
||||
|
||||
typedef struct rga_nn {
|
||||
int nn_flag;
|
||||
int scale_r;
|
||||
int scale_g;
|
||||
int scale_b;
|
||||
int offset_r;
|
||||
int offset_g;
|
||||
int offset_b;
|
||||
int nn_flag;
|
||||
int scale_r;
|
||||
int scale_g;
|
||||
int scale_b;
|
||||
int offset_r;
|
||||
int offset_g;
|
||||
int offset_b;
|
||||
} rga_nn_t;
|
||||
|
||||
typedef struct rga_dither {
|
||||
int enable;
|
||||
int mode;
|
||||
int lut0_l;
|
||||
int lut0_h;
|
||||
int lut1_l;
|
||||
int lut1_h;
|
||||
int enable;
|
||||
int mode;
|
||||
int lut0_l;
|
||||
int lut0_h;
|
||||
int lut1_l;
|
||||
int lut1_h;
|
||||
} rga_dither_t;
|
||||
|
||||
/*
|
||||
@@ -145,61 +145,62 @@ typedef struct rga_dither {
|
||||
@value hnd: use buffer_handle_t
|
||||
*/
|
||||
typedef struct rga_info {
|
||||
int fd;
|
||||
void *virAddr;
|
||||
void *phyAddr;
|
||||
int fd;
|
||||
void *virAddr;
|
||||
void *phyAddr;
|
||||
#ifndef ANDROID /* LINUX */
|
||||
unsigned hnd;
|
||||
unsigned hnd;
|
||||
#else /* Android */
|
||||
buffer_handle_t hnd;
|
||||
buffer_handle_t hnd;
|
||||
#endif
|
||||
int format;
|
||||
rga_rect_t rect;
|
||||
unsigned int blend;
|
||||
int bufferSize;
|
||||
int rotation;
|
||||
int color;
|
||||
int testLog;
|
||||
int mmuFlag;
|
||||
int colorkey_en;
|
||||
int colorkey_mode;
|
||||
int colorkey_max;
|
||||
int colorkey_min;
|
||||
int scale_mode;
|
||||
int color_space_mode;
|
||||
int sync_mode;
|
||||
rga_nn_t nn;
|
||||
rga_dither_t dither;
|
||||
int rop_code;
|
||||
int rd_mode;
|
||||
unsigned short is_10b_compact;
|
||||
unsigned short is_10b_endian;
|
||||
int format;
|
||||
rga_rect_t rect;
|
||||
unsigned int blend;
|
||||
int bufferSize;
|
||||
int rotation;
|
||||
int color;
|
||||
int testLog;
|
||||
int mmuFlag;
|
||||
int colorkey_en;
|
||||
int colorkey_mode;
|
||||
int colorkey_max;
|
||||
int colorkey_min;
|
||||
int scale_mode;
|
||||
int color_space_mode;
|
||||
int sync_mode;
|
||||
rga_nn_t nn;
|
||||
rga_dither_t dither;
|
||||
int rop_code;
|
||||
int rd_mode;
|
||||
unsigned short is_10b_compact;
|
||||
unsigned short is_10b_endian;
|
||||
|
||||
int in_fence_fd;
|
||||
int out_fence_fd;
|
||||
int in_fence_fd;
|
||||
int out_fence_fd;
|
||||
|
||||
int core;
|
||||
int priority;
|
||||
int core;
|
||||
int priority;
|
||||
|
||||
unsigned short enable;
|
||||
unsigned short enable;
|
||||
|
||||
int handle;
|
||||
int handle;
|
||||
|
||||
struct rga_mosaic_info mosaic_info;
|
||||
struct rga_mosaic_info mosaic_info;
|
||||
|
||||
struct rga_osd_info osd_info;
|
||||
struct rga_osd_info osd_info;
|
||||
|
||||
struct rga_pre_intr_info pre_intr;
|
||||
struct rga_pre_intr_info pre_intr;
|
||||
|
||||
int mpi_mode;
|
||||
int ctx_id;
|
||||
int mpi_mode;
|
||||
int ctx_id;
|
||||
|
||||
char reserve[402];
|
||||
char reserve[402];
|
||||
} rga_info_t;
|
||||
|
||||
|
||||
typedef struct drm_rga {
|
||||
rga_rect_t src;
|
||||
rga_rect_t dst;
|
||||
rga_rect_t src;
|
||||
rga_rect_t dst;
|
||||
} drm_rga_t;
|
||||
|
||||
/*
|
||||
@@ -210,30 +211,30 @@ typedef struct drm_rga {
|
||||
rga_set_rect(rects.src,0,0,1920,1080,1920,NV12);
|
||||
mean to set the src rect to the value.
|
||||
*/
|
||||
static inline int rga_set_rect(rga_rect_t *rect, int x, int y, int w, int h,
|
||||
int sw, int sh, int f) {
|
||||
if (!rect)
|
||||
return -EINVAL;
|
||||
static inline int rga_set_rect(rga_rect_t *rect,
|
||||
int x, int y, int w, int h, int sw, int sh, int f) {
|
||||
if (!rect)
|
||||
return -EINVAL;
|
||||
|
||||
rect->xoffset = x;
|
||||
rect->yoffset = y;
|
||||
rect->width = w;
|
||||
rect->height = h;
|
||||
rect->wstride = sw;
|
||||
rect->hstride = sh;
|
||||
rect->format = f;
|
||||
rect->xoffset = x;
|
||||
rect->yoffset = y;
|
||||
rect->width = w;
|
||||
rect->height = h;
|
||||
rect->wstride = sw;
|
||||
rect->hstride = sh;
|
||||
rect->format = f;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef ANDROID /* LINUX */
|
||||
static inline void rga_set_rotation(rga_info_t *info, int angle) {
|
||||
if (angle == 90)
|
||||
info->rotation = HAL_TRANSFORM_ROT_90;
|
||||
else if (angle == 180)
|
||||
info->rotation = HAL_TRANSFORM_ROT_180;
|
||||
else if (angle == 270)
|
||||
info->rotation = HAL_TRANSFORM_ROT_270;
|
||||
if (angle == 90)
|
||||
info->rotation = HAL_TRANSFORM_ROT_90;
|
||||
else if (angle == 180)
|
||||
info->rotation = HAL_TRANSFORM_ROT_180;
|
||||
else if (angle == 270)
|
||||
info->rotation = HAL_TRANSFORM_ROT_270;
|
||||
}
|
||||
#endif
|
||||
/*****************************************************************************/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,323 +22,291 @@
|
||||
#include "rga.h"
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_HW_VERSION_RGA_V_ERR_INDEX = 0x0,
|
||||
IM_RGA_HW_VERSION_RGA_1_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_1_PLUS_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_LITE0_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_LITE1_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_ENHANCE_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_3_INDEX,
|
||||
IM_RGA_HW_VERSION_MASK_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_V_ERR_INDEX = 0x0,
|
||||
IM_RGA_HW_VERSION_RGA_1_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_1_PLUS_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_LITE0_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_LITE1_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_ENHANCE_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_3_INDEX,
|
||||
IM_RGA_HW_VERSION_MASK_INDEX,
|
||||
} IM_RGA_HW_VERSION_INDEX;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_HW_VERSION_RGA_V_ERR = 1 << IM_RGA_HW_VERSION_RGA_V_ERR_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_1 = 1 << IM_RGA_HW_VERSION_RGA_1_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_1_PLUS = 1 << IM_RGA_HW_VERSION_RGA_1_PLUS_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2 = 1 << IM_RGA_HW_VERSION_RGA_2_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_LITE0 = 1 << IM_RGA_HW_VERSION_RGA_2_LITE0_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_LITE1 = 1 << IM_RGA_HW_VERSION_RGA_2_LITE1_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_ENHANCE = 1 << IM_RGA_HW_VERSION_RGA_2_ENHANCE_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_3 = 1 << IM_RGA_HW_VERSION_RGA_3_INDEX,
|
||||
IM_RGA_HW_VERSION_MASK =
|
||||
~((~(unsigned int)0x0 << IM_RGA_HW_VERSION_MASK_INDEX) | 1),
|
||||
} IM_RGA_HW_VERSION;
|
||||
IM_RGA_HW_VERSION_RGA_V_ERR = 1 << IM_RGA_HW_VERSION_RGA_V_ERR_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_1 = 1 << IM_RGA_HW_VERSION_RGA_1_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_1_PLUS = 1 << IM_RGA_HW_VERSION_RGA_1_PLUS_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2 = 1 << IM_RGA_HW_VERSION_RGA_2_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_LITE0 = 1 << IM_RGA_HW_VERSION_RGA_2_LITE0_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_LITE1 = 1 << IM_RGA_HW_VERSION_RGA_2_LITE1_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_2_ENHANCE = 1 << IM_RGA_HW_VERSION_RGA_2_ENHANCE_INDEX,
|
||||
IM_RGA_HW_VERSION_RGA_3 = 1 << IM_RGA_HW_VERSION_RGA_3_INDEX,
|
||||
IM_RGA_HW_VERSION_MASK = ~((~(unsigned int)0x0 << IM_RGA_HW_VERSION_MASK_INDEX) | 1),
|
||||
}IM_RGA_HW_VERSION;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_SUPPORT_FORMAT_ERROR_INDEX = 0,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_420_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_400_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_Y4_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGBA2BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_MASK_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_ERROR_INDEX = 0,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_420_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_400_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_Y4_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGBA2BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_MASK_INDEX,
|
||||
} IM_RGA_SUPPORT_FORMAT_INDEX;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_SUPPORT_FORMAT_ERROR = 1 << IM_RGA_SUPPORT_FORMAT_ERROR_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB = 1 << IM_RGA_SUPPORT_FORMAT_RGB_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER = 1 << IM_RGA_SUPPORT_FORMAT_RGB_OTHER_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_BPP = 1 << IM_RGA_SUPPORT_FORMAT_BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT =
|
||||
1 << IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT =
|
||||
1 << IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT =
|
||||
1 << IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT =
|
||||
1 << IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT =
|
||||
1 << IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT =
|
||||
1 << IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT =
|
||||
1 << IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT =
|
||||
1 << IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_420 = 1 << IM_RGA_SUPPORT_FORMAT_YUYV_420_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422 = 1 << IM_RGA_SUPPORT_FORMAT_YUYV_422_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_400 = 1 << IM_RGA_SUPPORT_FORMAT_YUV_400_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_Y4 = 1 << IM_RGA_SUPPORT_FORMAT_Y4_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGBA2BPP = 1 << IM_RGA_SUPPORT_FORMAT_RGBA2BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_MASK =
|
||||
~((~(unsigned int)0x0 << IM_RGA_SUPPORT_FORMAT_MASK_INDEX) | 1),
|
||||
IM_RGA_SUPPORT_FORMAT_ERROR = 1 << IM_RGA_SUPPORT_FORMAT_ERROR_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB = 1 << IM_RGA_SUPPORT_FORMAT_RGB_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER = 1 << IM_RGA_SUPPORT_FORMAT_RGB_OTHER_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_BPP = 1 << IM_RGA_SUPPORT_FORMAT_BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT = 1 << IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT = 1 << IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT = 1 << IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT = 1 << IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT = 1 << IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT = 1 << IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT = 1 << IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT = 1 << IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_420 = 1 << IM_RGA_SUPPORT_FORMAT_YUYV_420_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422 = 1 << IM_RGA_SUPPORT_FORMAT_YUYV_422_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_400 = 1 << IM_RGA_SUPPORT_FORMAT_YUV_400_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_Y4 = 1 << IM_RGA_SUPPORT_FORMAT_Y4_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_RGBA2BPP = 1 << IM_RGA_SUPPORT_FORMAT_RGBA2BPP_INDEX,
|
||||
IM_RGA_SUPPORT_FORMAT_MASK = ~((~(unsigned int)0x0 << IM_RGA_SUPPORT_FORMAT_MASK_INDEX) | 1),
|
||||
} IM_RGA_SUPPORT_FORMAT;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_SUPPORT_FEATURE_ERROR_INDEX = 0,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_ROP_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_QUANTIZE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_FBC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_BLEND_YUV_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_BT2020_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MOSAIC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_OSD_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_PRE_INTR_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MASK_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_ERROR_INDEX = 0,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_ROP_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_QUANTIZE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_FBC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_BLEND_YUV_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_BT2020_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MOSAIC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_OSD_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_PRE_INTR_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MASK_INDEX,
|
||||
} IM_RGA_SUPPORT_FEATURE_INDEX;
|
||||
|
||||
typedef enum {
|
||||
IM_RGA_SUPPORT_FEATURE_ERROR = 1 << IM_RGA_SUPPORT_FEATURE_ERROR_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL =
|
||||
1 << IM_RGA_SUPPORT_FEATURE_COLOR_FILL_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE =
|
||||
1 << IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_ROP = 1 << IM_RGA_SUPPORT_FEATURE_ROP_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_QUANTIZE = 1 << IM_RGA_SUPPORT_FEATURE_QUANTIZE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC =
|
||||
1 << IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC =
|
||||
1 << IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_FBC = 1 << IM_RGA_SUPPORT_FEATURE_FBC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_BLEND_YUV = 1
|
||||
<< IM_RGA_SUPPORT_FEATURE_BLEND_YUV_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_BT2020 = 1 << IM_RGA_SUPPORT_FEATURE_BT2020_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MOSAIC = 1 << IM_RGA_SUPPORT_FEATURE_MOSAIC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_OSD = 1 << IM_RGA_SUPPORT_FEATURE_OSD_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_PRE_INTR = 1 << IM_RGA_SUPPORT_FEATURE_PRE_INTR_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MASK =
|
||||
~((~(unsigned int)0x0 << IM_RGA_SUPPORT_FEATURE_MASK_INDEX) | 1),
|
||||
IM_RGA_SUPPORT_FEATURE_ERROR = 1 << IM_RGA_SUPPORT_FEATURE_ERROR_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL = 1 << IM_RGA_SUPPORT_FEATURE_COLOR_FILL_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE = 1 << IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_ROP = 1 << IM_RGA_SUPPORT_FEATURE_ROP_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_QUANTIZE = 1 << IM_RGA_SUPPORT_FEATURE_QUANTIZE_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC = 1 << IM_RGA_SUPPORT_FEATURE_SRC1_R2Y_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC = 1 << IM_RGA_SUPPORT_FEATURE_DST_FULL_CSC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_FBC = 1 << IM_RGA_SUPPORT_FEATURE_FBC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_BLEND_YUV = 1 << IM_RGA_SUPPORT_FEATURE_BLEND_YUV_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_BT2020 = 1 << IM_RGA_SUPPORT_FEATURE_BT2020_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MOSAIC = 1 << IM_RGA_SUPPORT_FEATURE_MOSAIC_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_OSD = 1 << IM_RGA_SUPPORT_FEATURE_OSD_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_PRE_INTR = 1 << IM_RGA_SUPPORT_FEATURE_PRE_INTR_INDEX,
|
||||
IM_RGA_SUPPORT_FEATURE_MASK = ~((~(unsigned int)0x0 << IM_RGA_SUPPORT_FEATURE_MASK_INDEX) | 1),
|
||||
} IM_RGA_SUPPORT_FEATURE;
|
||||
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
unsigned int input_resolution;
|
||||
unsigned int output_resolution;
|
||||
unsigned int byte_stride;
|
||||
unsigned int scale_limit;
|
||||
unsigned int performance;
|
||||
unsigned int input_format;
|
||||
unsigned int output_format;
|
||||
unsigned int feature;
|
||||
char reserved[24];
|
||||
unsigned int version;
|
||||
unsigned int input_resolution;
|
||||
unsigned int output_resolution;
|
||||
unsigned int byte_stride;
|
||||
unsigned int scale_limit;
|
||||
unsigned int performance;
|
||||
unsigned int input_format;
|
||||
unsigned int output_format;
|
||||
unsigned int feature;
|
||||
char reserved[24];
|
||||
} rga_info_table_entry;
|
||||
|
||||
typedef struct {
|
||||
struct rga_version_t user;
|
||||
struct rga_version_t driver;
|
||||
struct rga_version_t user;
|
||||
struct rga_version_t driver;
|
||||
} rga_dirver_bind_table_entry;
|
||||
|
||||
const rga_info_table_entry hw_info_table[] = {
|
||||
{IM_RGA_HW_VERSION_RGA_V_ERR, 0, 0, 0, 0, 0, 0, 0, 0, {0}},
|
||||
{IM_RGA_HW_VERSION_RGA_1,
|
||||
8192,
|
||||
2048,
|
||||
4,
|
||||
8,
|
||||
1,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_BPP |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL | IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE |
|
||||
IM_RGA_SUPPORT_FEATURE_ROP,
|
||||
/* reserved */
|
||||
{0}},
|
||||
{IM_RGA_HW_VERSION_RGA_1_PLUS,
|
||||
8192,
|
||||
2048,
|
||||
4,
|
||||
8,
|
||||
1,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_BPP |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL | IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE,
|
||||
/* reserved */
|
||||
{0}},
|
||||
{IM_RGA_HW_VERSION_RGA_2,
|
||||
8192,
|
||||
4096,
|
||||
4,
|
||||
16,
|
||||
2,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL | IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE |
|
||||
IM_RGA_SUPPORT_FEATURE_ROP,
|
||||
/* reserved */
|
||||
{0}},
|
||||
{IM_RGA_HW_VERSION_RGA_2_LITE0,
|
||||
8192,
|
||||
4096,
|
||||
4,
|
||||
8,
|
||||
2,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL | IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE |
|
||||
IM_RGA_SUPPORT_FEATURE_ROP,
|
||||
/* reserved */
|
||||
{0}},
|
||||
{IM_RGA_HW_VERSION_RGA_2_LITE1,
|
||||
8192,
|
||||
4096,
|
||||
4,
|
||||
8,
|
||||
2,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL | IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE,
|
||||
/* reserved */
|
||||
{0}},
|
||||
{IM_RGA_HW_VERSION_RGA_2_ENHANCE,
|
||||
8192,
|
||||
4096,
|
||||
4,
|
||||
16,
|
||||
2,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB | IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_420 | IM_RGA_SUPPORT_FORMAT_YUYV_422,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL | IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE |
|
||||
IM_RGA_SUPPORT_FEATURE_ROP,
|
||||
/* reserved */
|
||||
{0}},
|
||||
{IM_RGA_HW_VERSION_RGA_3,
|
||||
8176,
|
||||
8128,
|
||||
16,
|
||||
8,
|
||||
4,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_FBC | IM_RGA_SUPPORT_FEATURE_BLEND_YUV |
|
||||
IM_RGA_SUPPORT_FEATURE_BT2020,
|
||||
/* reserved */
|
||||
{0}},
|
||||
{ IM_RGA_HW_VERSION_RGA_V_ERR , 0, 0, 0, 0, 0, 0, 0, 0, {0} },
|
||||
{ IM_RGA_HW_VERSION_RGA_1 , 8192, 2048, 4, 8, 1,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_BPP |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL |
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE |
|
||||
IM_RGA_SUPPORT_FEATURE_ROP,
|
||||
/* reserved */
|
||||
{0} },
|
||||
{ IM_RGA_HW_VERSION_RGA_1_PLUS , 8192, 2048, 4, 8, 1,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_BPP |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL |
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE,
|
||||
/* reserved */
|
||||
{0} },
|
||||
{ IM_RGA_HW_VERSION_RGA_2 , 8192, 4096, 4, 16, 2,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL |
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE |
|
||||
IM_RGA_SUPPORT_FEATURE_ROP,
|
||||
/* reserved */
|
||||
{0} },
|
||||
{ IM_RGA_HW_VERSION_RGA_2_LITE0 , 8192, 4096, 4, 8, 2,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL |
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE |
|
||||
IM_RGA_SUPPORT_FEATURE_ROP,
|
||||
/* reserved */
|
||||
{0} },
|
||||
{ IM_RGA_HW_VERSION_RGA_2_LITE1 , 8192, 4096, 4, 8, 2,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL |
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE,
|
||||
/* reserved */
|
||||
{0} },
|
||||
{ IM_RGA_HW_VERSION_RGA_2_ENHANCE , 8192, 4096, 4, 16, 2,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_10_BIT,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_RGB_OTHER |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_420 |
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_FILL |
|
||||
IM_RGA_SUPPORT_FEATURE_COLOR_PALETTE |
|
||||
IM_RGA_SUPPORT_FEATURE_ROP,
|
||||
/* reserved */
|
||||
{0} },
|
||||
{ IM_RGA_HW_VERSION_RGA_3 , 8176, 8128, 16, 8, 4,
|
||||
/* input format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422,
|
||||
/* output format */
|
||||
IM_RGA_SUPPORT_FORMAT_RGB |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_8_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_420_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUV_422_SEMI_PLANNER_10_BIT |
|
||||
IM_RGA_SUPPORT_FORMAT_YUYV_422,
|
||||
/* feature */
|
||||
IM_RGA_SUPPORT_FEATURE_FBC |
|
||||
IM_RGA_SUPPORT_FEATURE_BLEND_YUV |
|
||||
IM_RGA_SUPPORT_FEATURE_BT2020,
|
||||
/* reserved */
|
||||
{0} },
|
||||
};
|
||||
|
||||
/* The range of the version is [min, max), that is version >= min, version <
|
||||
* max. */
|
||||
/* The range of the version is [min, max), that is version >= min, version < max. */
|
||||
const rga_dirver_bind_table_entry driver_bind_table[] = {
|
||||
{{0, 0, 0, "0.0.0"}, {0, 0, 0, "0.0.0"}},
|
||||
{{1, 0, 3, "1.0.3"}, {0, 0, 0, "0.0.0"}},
|
||||
{{1, 6, 0, "1.6.0"}, {1, 1, 5, "1.1.5"}},
|
||||
{{1, 7, 2, "1.7.2"}, {1, 2, 0, "1.2.0"}},
|
||||
{{1, 7, 3, "1.7.3"}, {1, 2, 4, "1.2.4"}},
|
||||
{ { 0, 0, 0, "0.0.0" }, {0, 0, 0, "0.0.0" } },
|
||||
{ { 1, 0, 3, "1.0.3" }, {0, 0, 0, "0.0.0" } },
|
||||
{ { 1, 6, 0, "1.6.0" }, {1, 1, 5, "1.1.5" } },
|
||||
{ { 1, 7, 2, "1.7.2" }, {1, 2, 0, "1.2.0" } },
|
||||
{ { 1, 7, 3, "1.7.3" }, {1, 2, 4, "1.2.4" } },
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,213 +22,211 @@
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
/* Rotation */
|
||||
IM_HAL_TRANSFORM_ROT_90 = 1 << 0,
|
||||
IM_HAL_TRANSFORM_ROT_180 = 1 << 1,
|
||||
IM_HAL_TRANSFORM_ROT_270 = 1 << 2,
|
||||
IM_HAL_TRANSFORM_FLIP_H = 1 << 3,
|
||||
IM_HAL_TRANSFORM_FLIP_V = 1 << 4,
|
||||
IM_HAL_TRANSFORM_FLIP_H_V = 1 << 5,
|
||||
IM_HAL_TRANSFORM_MASK = 0x3f,
|
||||
/* Rotation */
|
||||
IM_HAL_TRANSFORM_ROT_90 = 1 << 0,
|
||||
IM_HAL_TRANSFORM_ROT_180 = 1 << 1,
|
||||
IM_HAL_TRANSFORM_ROT_270 = 1 << 2,
|
||||
IM_HAL_TRANSFORM_FLIP_H = 1 << 3,
|
||||
IM_HAL_TRANSFORM_FLIP_V = 1 << 4,
|
||||
IM_HAL_TRANSFORM_FLIP_H_V = 1 << 5,
|
||||
IM_HAL_TRANSFORM_MASK = 0x3f,
|
||||
|
||||
/*
|
||||
* Blend
|
||||
* Additional blend usage, can be used with both source and target configs.
|
||||
* If none of the below is set, the default "SRC over DST" is applied.
|
||||
*/
|
||||
IM_ALPHA_BLEND_SRC_OVER = 1 << 6, /* Default, Porter-Duff "SRC over DST" */
|
||||
IM_ALPHA_BLEND_SRC = 1 << 7, /* Porter-Duff "SRC" */
|
||||
IM_ALPHA_BLEND_DST = 1 << 8, /* Porter-Duff "DST" */
|
||||
IM_ALPHA_BLEND_SRC_IN = 1 << 9, /* Porter-Duff "SRC in DST" */
|
||||
IM_ALPHA_BLEND_DST_IN = 1 << 10, /* Porter-Duff "DST in SRC" */
|
||||
IM_ALPHA_BLEND_SRC_OUT = 1 << 11, /* Porter-Duff "SRC out DST" */
|
||||
IM_ALPHA_BLEND_DST_OUT = 1 << 12, /* Porter-Duff "DST out SRC" */
|
||||
IM_ALPHA_BLEND_DST_OVER = 1 << 13, /* Porter-Duff "DST over SRC" */
|
||||
IM_ALPHA_BLEND_SRC_ATOP = 1 << 14, /* Porter-Duff "SRC ATOP" */
|
||||
IM_ALPHA_BLEND_DST_ATOP = 1 << 15, /* Porter-Duff "DST ATOP" */
|
||||
IM_ALPHA_BLEND_XOR = 1 << 16, /* Xor */
|
||||
IM_ALPHA_BLEND_MASK = 0x1ffc0,
|
||||
/*
|
||||
* Blend
|
||||
* Additional blend usage, can be used with both source and target configs.
|
||||
* If none of the below is set, the default "SRC over DST" is applied.
|
||||
*/
|
||||
IM_ALPHA_BLEND_SRC_OVER = 1 << 6, /* Default, Porter-Duff "SRC over DST" */
|
||||
IM_ALPHA_BLEND_SRC = 1 << 7, /* Porter-Duff "SRC" */
|
||||
IM_ALPHA_BLEND_DST = 1 << 8, /* Porter-Duff "DST" */
|
||||
IM_ALPHA_BLEND_SRC_IN = 1 << 9, /* Porter-Duff "SRC in DST" */
|
||||
IM_ALPHA_BLEND_DST_IN = 1 << 10, /* Porter-Duff "DST in SRC" */
|
||||
IM_ALPHA_BLEND_SRC_OUT = 1 << 11, /* Porter-Duff "SRC out DST" */
|
||||
IM_ALPHA_BLEND_DST_OUT = 1 << 12, /* Porter-Duff "DST out SRC" */
|
||||
IM_ALPHA_BLEND_DST_OVER = 1 << 13, /* Porter-Duff "DST over SRC" */
|
||||
IM_ALPHA_BLEND_SRC_ATOP = 1 << 14, /* Porter-Duff "SRC ATOP" */
|
||||
IM_ALPHA_BLEND_DST_ATOP = 1 << 15, /* Porter-Duff "DST ATOP" */
|
||||
IM_ALPHA_BLEND_XOR = 1 << 16, /* Xor */
|
||||
IM_ALPHA_BLEND_MASK = 0x1ffc0,
|
||||
|
||||
IM_ALPHA_COLORKEY_NORMAL = 1 << 17,
|
||||
IM_ALPHA_COLORKEY_INVERTED = 1 << 18,
|
||||
IM_ALPHA_COLORKEY_MASK = 0x60000,
|
||||
IM_ALPHA_COLORKEY_NORMAL = 1 << 17,
|
||||
IM_ALPHA_COLORKEY_INVERTED = 1 << 18,
|
||||
IM_ALPHA_COLORKEY_MASK = 0x60000,
|
||||
|
||||
IM_SYNC = 1 << 19,
|
||||
IM_CROP = 1 << 20, /* Unused */
|
||||
IM_COLOR_FILL = 1 << 21,
|
||||
IM_COLOR_PALETTE = 1 << 22,
|
||||
IM_NN_QUANTIZE = 1 << 23,
|
||||
IM_ROP = 1 << 24,
|
||||
IM_ALPHA_BLEND_PRE_MUL = 1 << 25,
|
||||
IM_ASYNC = 1 << 26,
|
||||
IM_MOSAIC = 1 << 27,
|
||||
IM_OSD = 1 << 28,
|
||||
IM_PRE_INTR = 1 << 29,
|
||||
IM_SYNC = 1 << 19,
|
||||
IM_CROP = 1 << 20, /* Unused */
|
||||
IM_COLOR_FILL = 1 << 21,
|
||||
IM_COLOR_PALETTE = 1 << 22,
|
||||
IM_NN_QUANTIZE = 1 << 23,
|
||||
IM_ROP = 1 << 24,
|
||||
IM_ALPHA_BLEND_PRE_MUL = 1 << 25,
|
||||
IM_ASYNC = 1 << 26,
|
||||
IM_MOSAIC = 1 << 27,
|
||||
IM_OSD = 1 << 28,
|
||||
IM_PRE_INTR = 1 << 29,
|
||||
} IM_USAGE;
|
||||
|
||||
typedef enum {
|
||||
IM_RASTER_MODE = 1 << 0,
|
||||
IM_FBC_MODE = 1 << 1,
|
||||
IM_TILE_MODE = 1 << 2,
|
||||
IM_RASTER_MODE = 1 << 0,
|
||||
IM_FBC_MODE = 1 << 1,
|
||||
IM_TILE_MODE = 1 << 2,
|
||||
} IM_RD_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_SCHEDULER_RGA3_CORE0 = 1 << 0,
|
||||
IM_SCHEDULER_RGA3_CORE1 = 1 << 1,
|
||||
IM_SCHEDULER_RGA2_CORE0 = 1 << 2,
|
||||
IM_SCHEDULER_RGA3_DEFAULT = IM_SCHEDULER_RGA3_CORE0,
|
||||
IM_SCHEDULER_RGA2_DEFAULT = IM_SCHEDULER_RGA2_CORE0,
|
||||
IM_SCHEDULER_MASK = 0x7,
|
||||
IM_SCHEDULER_DEFAULT = 0,
|
||||
IM_SCHEDULER_RGA3_CORE0 = 1 << 0,
|
||||
IM_SCHEDULER_RGA3_CORE1 = 1 << 1,
|
||||
IM_SCHEDULER_RGA2_CORE0 = 1 << 2,
|
||||
IM_SCHEDULER_RGA3_DEFAULT = IM_SCHEDULER_RGA3_CORE0,
|
||||
IM_SCHEDULER_RGA2_DEFAULT = IM_SCHEDULER_RGA2_CORE0,
|
||||
IM_SCHEDULER_MASK = 0x7,
|
||||
IM_SCHEDULER_DEFAULT = 0,
|
||||
} IM_SCHEDULER_CORE;
|
||||
|
||||
typedef enum {
|
||||
IM_ROP_AND = 0x88,
|
||||
IM_ROP_OR = 0xee,
|
||||
IM_ROP_NOT_DST = 0x55,
|
||||
IM_ROP_NOT_SRC = 0x33,
|
||||
IM_ROP_XOR = 0xf6,
|
||||
IM_ROP_NOT_XOR = 0xf9,
|
||||
IM_ROP_AND = 0x88,
|
||||
IM_ROP_OR = 0xee,
|
||||
IM_ROP_NOT_DST = 0x55,
|
||||
IM_ROP_NOT_SRC = 0x33,
|
||||
IM_ROP_XOR = 0xf6,
|
||||
IM_ROP_NOT_XOR = 0xf9,
|
||||
} IM_ROP_CODE;
|
||||
|
||||
typedef enum {
|
||||
IM_MOSAIC_8 = 0x0,
|
||||
IM_MOSAIC_16 = 0x1,
|
||||
IM_MOSAIC_32 = 0x2,
|
||||
IM_MOSAIC_64 = 0x3,
|
||||
IM_MOSAIC_128 = 0x4,
|
||||
IM_MOSAIC_8 = 0x0,
|
||||
IM_MOSAIC_16 = 0x1,
|
||||
IM_MOSAIC_32 = 0x2,
|
||||
IM_MOSAIC_64 = 0x3,
|
||||
IM_MOSAIC_128 = 0x4,
|
||||
} IM_MOSAIC_MODE;
|
||||
|
||||
/* Status codes, returned by any blit function */
|
||||
typedef enum {
|
||||
IM_YUV_TO_RGB_BT601_LIMIT = 1 << 0,
|
||||
IM_YUV_TO_RGB_BT601_FULL = 2 << 0,
|
||||
IM_YUV_TO_RGB_BT709_LIMIT = 3 << 0,
|
||||
IM_YUV_TO_RGB_MASK = 3 << 0,
|
||||
IM_RGB_TO_YUV_BT601_FULL = 1 << 2,
|
||||
IM_RGB_TO_YUV_BT601_LIMIT = 2 << 2,
|
||||
IM_RGB_TO_YUV_BT709_LIMIT = 3 << 2,
|
||||
IM_RGB_TO_YUV_MASK = 3 << 2,
|
||||
IM_RGB_TO_Y4 = 1 << 4,
|
||||
IM_RGB_TO_Y4_DITHER = 2 << 4,
|
||||
IM_RGB_TO_Y1_DITHER = 3 << 4,
|
||||
IM_Y4_MASK = 3 << 4,
|
||||
IM_RGB_FULL = 1 << 8,
|
||||
IM_RGB_CLIP = 2 << 8,
|
||||
IM_YUV_BT601_LIMIT_RANGE = 3 << 8,
|
||||
IM_YUV_BT601_FULL_RANGE = 4 << 8,
|
||||
IM_YUV_BT709_LIMIT_RANGE = 5 << 8,
|
||||
IM_YUV_BT709_FULL_RANGE = 6 << 8,
|
||||
IM_FULL_CSC_MASK = 0xf << 8,
|
||||
IM_COLOR_SPACE_DEFAULT = 0,
|
||||
IM_YUV_TO_RGB_BT601_LIMIT = 1 << 0,
|
||||
IM_YUV_TO_RGB_BT601_FULL = 2 << 0,
|
||||
IM_YUV_TO_RGB_BT709_LIMIT = 3 << 0,
|
||||
IM_YUV_TO_RGB_MASK = 3 << 0,
|
||||
IM_RGB_TO_YUV_BT601_FULL = 1 << 2,
|
||||
IM_RGB_TO_YUV_BT601_LIMIT = 2 << 2,
|
||||
IM_RGB_TO_YUV_BT709_LIMIT = 3 << 2,
|
||||
IM_RGB_TO_YUV_MASK = 3 << 2,
|
||||
IM_RGB_TO_Y4 = 1 << 4,
|
||||
IM_RGB_TO_Y4_DITHER = 2 << 4,
|
||||
IM_RGB_TO_Y1_DITHER = 3 << 4,
|
||||
IM_Y4_MASK = 3 << 4,
|
||||
IM_RGB_FULL = 1 << 8,
|
||||
IM_RGB_CLIP = 2 << 8,
|
||||
IM_YUV_BT601_LIMIT_RANGE = 3 << 8,
|
||||
IM_YUV_BT601_FULL_RANGE = 4 << 8,
|
||||
IM_YUV_BT709_LIMIT_RANGE = 5 << 8,
|
||||
IM_YUV_BT709_FULL_RANGE = 6 << 8,
|
||||
IM_FULL_CSC_MASK = 0xf << 8,
|
||||
IM_COLOR_SPACE_DEFAULT = 0,
|
||||
} IM_COLOR_SPACE_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_UP_SCALE,
|
||||
IM_DOWN_SCALE,
|
||||
IM_UP_SCALE,
|
||||
IM_DOWN_SCALE,
|
||||
} IM_SCALE;
|
||||
|
||||
typedef enum {
|
||||
INTER_NEAREST,
|
||||
INTER_LINEAR,
|
||||
INTER_CUBIC,
|
||||
INTER_NEAREST,
|
||||
INTER_LINEAR,
|
||||
INTER_CUBIC,
|
||||
} IM_SCALE_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_CONFIG_SCHEDULER_CORE,
|
||||
IM_CONFIG_PRIORITY,
|
||||
IM_CONFIG_CHECK,
|
||||
IM_CONFIG_SCHEDULER_CORE,
|
||||
IM_CONFIG_PRIORITY,
|
||||
IM_CONFIG_CHECK,
|
||||
} IM_CONFIG_NAME;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_MODE_STATISTICS = 0x1 << 0,
|
||||
IM_OSD_MODE_AUTO_INVERT = 0x1 << 1,
|
||||
IM_OSD_MODE_STATISTICS = 0x1 << 0,
|
||||
IM_OSD_MODE_AUTO_INVERT = 0x1 << 1,
|
||||
} IM_OSD_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_INVERT_CHANNEL_NONE = 0x0,
|
||||
IM_OSD_INVERT_CHANNEL_Y_G = 0x1 << 0,
|
||||
IM_OSD_INVERT_CHANNEL_C_RB = 0x1 << 1,
|
||||
IM_OSD_INVERT_CHANNEL_ALPHA = 0x1 << 2,
|
||||
IM_OSD_INVERT_CHANNEL_COLOR =
|
||||
IM_OSD_INVERT_CHANNEL_Y_G | IM_OSD_INVERT_CHANNEL_C_RB,
|
||||
IM_OSD_INVERT_CHANNEL_BOTH =
|
||||
IM_OSD_INVERT_CHANNEL_COLOR | IM_OSD_INVERT_CHANNEL_ALPHA,
|
||||
IM_OSD_INVERT_CHANNEL_NONE = 0x0,
|
||||
IM_OSD_INVERT_CHANNEL_Y_G = 0x1 << 0,
|
||||
IM_OSD_INVERT_CHANNEL_C_RB = 0x1 << 1,
|
||||
IM_OSD_INVERT_CHANNEL_ALPHA = 0x1 << 2,
|
||||
IM_OSD_INVERT_CHANNEL_COLOR = IM_OSD_INVERT_CHANNEL_Y_G |
|
||||
IM_OSD_INVERT_CHANNEL_C_RB,
|
||||
IM_OSD_INVERT_CHANNEL_BOTH = IM_OSD_INVERT_CHANNEL_COLOR |
|
||||
IM_OSD_INVERT_CHANNEL_ALPHA,
|
||||
} IM_OSD_INVERT_CHANNEL;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_FLAGS_INTERNAL = 0,
|
||||
IM_OSD_FLAGS_EXTERNAL,
|
||||
IM_OSD_FLAGS_INTERNAL = 0,
|
||||
IM_OSD_FLAGS_EXTERNAL,
|
||||
} IM_OSD_FLAGS_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_INVERT_USE_FACTOR,
|
||||
IM_OSD_INVERT_USE_SWAP,
|
||||
IM_OSD_INVERT_USE_FACTOR,
|
||||
IM_OSD_INVERT_USE_SWAP,
|
||||
} IM_OSD_INVERT_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_BACKGROUND_DEFAULT_BRIGHT = 0,
|
||||
IM_OSD_BACKGROUND_DEFAULT_DARK,
|
||||
IM_OSD_BACKGROUND_DEFAULT_BRIGHT = 0,
|
||||
IM_OSD_BACKGROUND_DEFAULT_DARK,
|
||||
} IM_OSD_BACKGROUND_DEFAULT;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_BLOCK_MODE_NORMAL = 0,
|
||||
IM_OSD_BLOCK_MODE_DIFFERENT,
|
||||
IM_OSD_BLOCK_MODE_NORMAL = 0,
|
||||
IM_OSD_BLOCK_MODE_DIFFERENT,
|
||||
} IM_OSD_BLOCK_WIDTH_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_MODE_HORIZONTAL,
|
||||
IM_OSD_MODE_VERTICAL,
|
||||
IM_OSD_MODE_HORIZONTAL,
|
||||
IM_OSD_MODE_VERTICAL,
|
||||
} IM_OSD_DIRECTION;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_COLOR_PIXEL,
|
||||
IM_OSD_COLOR_EXTERNAL,
|
||||
IM_OSD_COLOR_PIXEL,
|
||||
IM_OSD_COLOR_EXTERNAL,
|
||||
} IM_OSD_COLOR_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_INTR_READ_INTR = 1 << 0,
|
||||
IM_INTR_READ_HOLD = 1 << 1,
|
||||
IM_INTR_WRITE_INTR = 1 << 2,
|
||||
IM_INTR_READ_INTR = 1 << 0,
|
||||
IM_INTR_READ_HOLD = 1 << 1,
|
||||
IM_INTR_WRITE_INTR = 1 << 2,
|
||||
} IM_PRE_INTR_FLAGS;
|
||||
|
||||
typedef enum {
|
||||
IM_CONTEXT_NONE = 0x0,
|
||||
IM_CONTEXT_SRC_FIX_ENABLE =
|
||||
0x1 << 0, // Enable kernel to modify the image parameters of the channel.
|
||||
IM_CONTEXT_SRC_CACHE_INFO = 0x1 << 1, // It will replace the parameters in ctx
|
||||
// with the modified parameters.
|
||||
IM_CONTEXT_SRC1_FIX_ENABLE = 0x1 << 2,
|
||||
IM_CONTEXT_SRC1_CACHE_INFO = 0x1 << 3,
|
||||
IM_CONTEXT_DST_FIX_ENABLE = 0x1 << 4,
|
||||
IM_CONTEXT_DST_CACHE_INFO = 0x1 << 5,
|
||||
IM_CONTEXT_NONE = 0x0,
|
||||
IM_CONTEXT_SRC_FIX_ENABLE = 0x1 << 0, // Enable kernel to modify the image parameters of the channel.
|
||||
IM_CONTEXT_SRC_CACHE_INFO = 0x1 << 1, // It will replace the parameters in ctx with the modified parameters.
|
||||
IM_CONTEXT_SRC1_FIX_ENABLE = 0x1 << 2,
|
||||
IM_CONTEXT_SRC1_CACHE_INFO = 0x1 << 3,
|
||||
IM_CONTEXT_DST_FIX_ENABLE = 0x1 << 4,
|
||||
IM_CONTEXT_DST_CACHE_INFO = 0x1 << 5,
|
||||
} IM_CONTEXT_FLAGS;
|
||||
|
||||
/* Get RGA basic information index */
|
||||
typedef enum {
|
||||
RGA_VENDOR = 0,
|
||||
RGA_VERSION,
|
||||
RGA_MAX_INPUT,
|
||||
RGA_MAX_OUTPUT,
|
||||
RGA_BYTE_STRIDE,
|
||||
RGA_SCALE_LIMIT,
|
||||
RGA_INPUT_FORMAT,
|
||||
RGA_OUTPUT_FORMAT,
|
||||
RGA_FEATURE,
|
||||
RGA_EXPECTED,
|
||||
RGA_ALL,
|
||||
RGA_VENDOR = 0,
|
||||
RGA_VERSION,
|
||||
RGA_MAX_INPUT,
|
||||
RGA_MAX_OUTPUT,
|
||||
RGA_BYTE_STRIDE,
|
||||
RGA_SCALE_LIMIT,
|
||||
RGA_INPUT_FORMAT,
|
||||
RGA_OUTPUT_FORMAT,
|
||||
RGA_FEATURE,
|
||||
RGA_EXPECTED,
|
||||
RGA_ALL,
|
||||
} IM_INFORMATION;
|
||||
|
||||
/* Status codes, returned by any blit function */
|
||||
typedef enum {
|
||||
IM_STATUS_NOERROR = 2,
|
||||
IM_STATUS_SUCCESS = 1,
|
||||
IM_STATUS_NOT_SUPPORTED = -1,
|
||||
IM_STATUS_OUT_OF_MEMORY = -2,
|
||||
IM_STATUS_INVALID_PARAM = -3,
|
||||
IM_STATUS_ILLEGAL_PARAM = -4,
|
||||
IM_STATUS_ERROR_VERSION = -5,
|
||||
IM_STATUS_FAILED = 0,
|
||||
IM_STATUS_NOERROR = 2,
|
||||
IM_STATUS_SUCCESS = 1,
|
||||
IM_STATUS_NOT_SUPPORTED = -1,
|
||||
IM_STATUS_OUT_OF_MEMORY = -2,
|
||||
IM_STATUS_INVALID_PARAM = -3,
|
||||
IM_STATUS_ILLEGAL_PARAM = -4,
|
||||
IM_STATUS_ERROR_VERSION = -5,
|
||||
IM_STATUS_FAILED = 0,
|
||||
} IM_STATUS;
|
||||
|
||||
typedef uint32_t im_api_version_t;
|
||||
@@ -237,182 +235,183 @@ typedef uint32_t rga_buffer_handle_t;
|
||||
|
||||
/* Rectangle definition */
|
||||
typedef struct {
|
||||
int x; /* upper-left x */
|
||||
int y; /* upper-left y */
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
int x; /* upper-left x */
|
||||
int y; /* upper-left y */
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
} im_rect;
|
||||
|
||||
typedef struct {
|
||||
int max; /* The Maximum value of the color key */
|
||||
int min; /* The minimum value of the color key */
|
||||
int max; /* The Maximum value of the color key */
|
||||
int min; /* The minimum value of the color key */
|
||||
} im_colorkey_range;
|
||||
|
||||
|
||||
typedef struct im_nn {
|
||||
int scale_r; /* scaling factor on R channal */
|
||||
int scale_g; /* scaling factor on G channal */
|
||||
int scale_b; /* scaling factor on B channal */
|
||||
int offset_r; /* offset on R channal */
|
||||
int offset_g; /* offset on G channal */
|
||||
int offset_b; /* offset on B channal */
|
||||
int scale_r; /* scaling factor on R channal */
|
||||
int scale_g; /* scaling factor on G channal */
|
||||
int scale_b; /* scaling factor on B channal */
|
||||
int offset_r; /* offset on R channal */
|
||||
int offset_g; /* offset on G channal */
|
||||
int offset_b; /* offset on B channal */
|
||||
} im_nn_t;
|
||||
|
||||
/* im_info definition */
|
||||
typedef struct {
|
||||
void *vir_addr; /* virtual address */
|
||||
void *phy_addr; /* physical address */
|
||||
int fd; /* shared fd */
|
||||
void* vir_addr; /* virtual address */
|
||||
void* phy_addr; /* physical address */
|
||||
int fd; /* shared fd */
|
||||
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
int wstride; /* wstride */
|
||||
int hstride; /* hstride */
|
||||
int format; /* format */
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
int wstride; /* wstride */
|
||||
int hstride; /* hstride */
|
||||
int format; /* format */
|
||||
|
||||
int color_space_mode; /* color_space_mode */
|
||||
int global_alpha; /* global_alpha */
|
||||
int rd_mode;
|
||||
int color_space_mode; /* color_space_mode */
|
||||
int global_alpha; /* global_alpha */
|
||||
int rd_mode;
|
||||
|
||||
/* legarcy */
|
||||
int color; /* color, used by color fill */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
/* legarcy */
|
||||
int color; /* color, used by color fill */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
|
||||
rga_buffer_handle_t handle; /* buffer handle */
|
||||
rga_buffer_handle_t handle; /* buffer handle */
|
||||
} rga_buffer_t;
|
||||
|
||||
typedef struct im_color {
|
||||
union {
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t alpha;
|
||||
union {
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t alpha;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
} im_color_t;
|
||||
|
||||
typedef struct im_osd_invert_factor {
|
||||
uint8_t alpha_max;
|
||||
uint8_t alpha_min;
|
||||
uint8_t yg_max;
|
||||
uint8_t yg_min;
|
||||
uint8_t crb_max;
|
||||
uint8_t crb_min;
|
||||
uint8_t alpha_max;
|
||||
uint8_t alpha_min;
|
||||
uint8_t yg_max;
|
||||
uint8_t yg_min;
|
||||
uint8_t crb_max;
|
||||
uint8_t crb_min;
|
||||
} im_osd_invert_factor_t;
|
||||
|
||||
typedef struct im_osd_bpp2 {
|
||||
uint8_t ac_swap; // ac swap flag
|
||||
// 0: CA
|
||||
// 1: AC
|
||||
uint8_t endian_swap; // rgba2bpp endian swap
|
||||
// 0: Big endian
|
||||
// 1: Little endian
|
||||
im_color_t color0;
|
||||
im_color_t color1;
|
||||
uint8_t ac_swap; // ac swap flag
|
||||
// 0: CA
|
||||
// 1: AC
|
||||
uint8_t endian_swap; // rgba2bpp endian swap
|
||||
// 0: Big endian
|
||||
// 1: Little endian
|
||||
im_color_t color0;
|
||||
im_color_t color1;
|
||||
} im_osd_bpp2_t;
|
||||
|
||||
typedef struct im_osd_block {
|
||||
int width_mode; // normal or different
|
||||
// IM_OSD_BLOCK_MODE_NORMAL
|
||||
// IM_OSD_BLOCK_MODE_DIFFERENT
|
||||
union {
|
||||
int width; // normal_mode block width
|
||||
int width_index; // different_mode block width index in RAM
|
||||
};
|
||||
int width_mode; // normal or different
|
||||
// IM_OSD_BLOCK_MODE_NORMAL
|
||||
// IM_OSD_BLOCK_MODE_DIFFERENT
|
||||
union {
|
||||
int width; // normal_mode block width
|
||||
int width_index; // different_mode block width index in RAM
|
||||
};
|
||||
|
||||
int block_count; // block count
|
||||
int block_count; // block count
|
||||
|
||||
int background_config; // background config is bright or dark
|
||||
// IM_OSD_BACKGROUND_DEFAULT_BRIGHT
|
||||
// IM_OSD_BACKGROUND_DEFAULT_DARK
|
||||
int background_config; // background config is bright or dark
|
||||
// IM_OSD_BACKGROUND_DEFAULT_BRIGHT
|
||||
// IM_OSD_BACKGROUND_DEFAULT_DARK
|
||||
|
||||
int direction; // osd block direction
|
||||
// IM_OSD_MODE_HORIZONTAL
|
||||
// IM_OSD_MODE_VERTICAL
|
||||
int direction; // osd block direction
|
||||
// IM_OSD_MODE_HORIZONTAL
|
||||
// IM_OSD_MODE_VERTICAL
|
||||
|
||||
int color_mode; // using src1 color or config color
|
||||
// IM_OSD_COLOR_PIXEL
|
||||
// IM_OSD_COLOR_EXTERNAL
|
||||
im_color_t normal_color; // config color: normal
|
||||
im_color_t invert_color; // config color: invert
|
||||
int color_mode; // using src1 color or config color
|
||||
// IM_OSD_COLOR_PIXEL
|
||||
// IM_OSD_COLOR_EXTERNAL
|
||||
im_color_t normal_color; // config color: normal
|
||||
im_color_t invert_color; // config color: invert
|
||||
} im_osd_block_t;
|
||||
|
||||
typedef struct im_osd_invert {
|
||||
int invert_channel; // invert channel config:
|
||||
// IM_OSD_INVERT_CHANNEL_NONE
|
||||
// IM_OSD_INVERT_CHANNEL_Y_G
|
||||
// IM_OSD_INVERT_CHANNEL_C_RB
|
||||
// IM_OSD_INVERT_CHANNEL_ALPHA
|
||||
// IM_OSD_INVERT_CHANNEL_COLOR
|
||||
// IM_OSD_INVERT_CHANNEL_BOTH
|
||||
int flags_mode; // use external or inertnal RAM invert flags
|
||||
// IM_OSD_FLAGS_EXTERNAL
|
||||
// IM_OSD_FLAGS_INTERNAL
|
||||
int flags_index; // flags index when using internal RAM invert flags
|
||||
int invert_channel; // invert channel config:
|
||||
// IM_OSD_INVERT_CHANNEL_NONE
|
||||
// IM_OSD_INVERT_CHANNEL_Y_G
|
||||
// IM_OSD_INVERT_CHANNEL_C_RB
|
||||
// IM_OSD_INVERT_CHANNEL_ALPHA
|
||||
// IM_OSD_INVERT_CHANNEL_COLOR
|
||||
// IM_OSD_INVERT_CHANNEL_BOTH
|
||||
int flags_mode; // use external or inertnal RAM invert flags
|
||||
// IM_OSD_FLAGS_EXTERNAL
|
||||
// IM_OSD_FLAGS_INTERNAL
|
||||
int flags_index; // flags index when using internal RAM invert flags
|
||||
|
||||
uint64_t invert_flags; // external invert flags
|
||||
uint64_t current_flags; // current flags
|
||||
uint64_t invert_flags; // external invert flags
|
||||
uint64_t current_flags; // current flags
|
||||
|
||||
int invert_mode; // invert use swap or factor
|
||||
// IM_OSD_INVERT_USE_FACTOR
|
||||
// IM_OSD_INVERT_USE_SWAP
|
||||
im_osd_invert_factor_t factor;
|
||||
int invert_mode; // invert use swap or factor
|
||||
// IM_OSD_INVERT_USE_FACTOR
|
||||
// IM_OSD_INVERT_USE_SWAP
|
||||
im_osd_invert_factor_t factor;
|
||||
|
||||
int threash;
|
||||
int threash;
|
||||
} im_osd_invert_t;
|
||||
|
||||
typedef struct im_osd {
|
||||
int osd_mode; // osd mode: statistics or auto_invert
|
||||
// IM_OSD_MODE_STATISTICS
|
||||
// IM_OSD_MODE_AUTO_INVERT
|
||||
im_osd_block_t block_parm; // osd block info config
|
||||
int osd_mode; // osd mode: statistics or auto_invert
|
||||
// IM_OSD_MODE_STATISTICS
|
||||
// IM_OSD_MODE_AUTO_INVERT
|
||||
im_osd_block_t block_parm; // osd block info config
|
||||
|
||||
im_osd_invert_t invert_config;
|
||||
im_osd_invert_t invert_config;
|
||||
|
||||
im_osd_bpp2_t bpp2_info;
|
||||
im_osd_bpp2_t bpp2_info;
|
||||
} im_osd_t;
|
||||
|
||||
typedef struct im_intr_config {
|
||||
uint32_t flags;
|
||||
uint32_t flags;
|
||||
|
||||
int read_threshold;
|
||||
int write_start;
|
||||
int write_step;
|
||||
int read_threshold;
|
||||
int write_start;
|
||||
int write_step;
|
||||
} im_intr_config_t;
|
||||
|
||||
typedef struct im_opt {
|
||||
im_api_version_t version;
|
||||
im_api_version_t version;
|
||||
|
||||
int color; /* color, used by color fill */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
int color; /* color, used by color fill */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
|
||||
int priority;
|
||||
int core;
|
||||
int priority;
|
||||
int core;
|
||||
|
||||
int mosaic_mode;
|
||||
int mosaic_mode;
|
||||
|
||||
im_osd_t osd_config;
|
||||
im_osd_t osd_config;
|
||||
|
||||
im_intr_config_t intr_config;
|
||||
im_intr_config_t intr_config;
|
||||
|
||||
char reserve[128];
|
||||
char reserve[128];
|
||||
} im_opt_t;
|
||||
|
||||
typedef struct im_context {
|
||||
int priority;
|
||||
IM_SCHEDULER_CORE core;
|
||||
int check_mode;
|
||||
int priority;
|
||||
IM_SCHEDULER_CORE core;
|
||||
int check_mode;
|
||||
} im_context_t;
|
||||
|
||||
typedef struct im_handle_param {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
} im_handle_param_t;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
}im_handle_param_t;
|
||||
|
||||
#endif /* _RGA_IM2D_TYPE_H_ */
|
||||
|
||||
@@ -23,20 +23,23 @@
|
||||
#define RGA_VERSION_STR(x) RGA_VERSION_STR_HELPER(x)
|
||||
|
||||
/* RGA im2d api verison */
|
||||
#define RGA_API_MAJOR_VERSION 1
|
||||
#define RGA_API_MINOR_VERSION 8
|
||||
#define RGA_API_REVISION_VERSION 1
|
||||
#define RGA_API_BUILD_VERSION 2
|
||||
#define RGA_API_MAJOR_VERSION 1
|
||||
#define RGA_API_MINOR_VERSION 8
|
||||
#define RGA_API_REVISION_VERSION 1
|
||||
#define RGA_API_BUILD_VERSION 2
|
||||
|
||||
#define RGA_API_VERSION \
|
||||
RGA_VERSION_STR(RGA_API_MAJOR_VERSION) \
|
||||
"." RGA_VERSION_STR(RGA_API_MINOR_VERSION) "." RGA_VERSION_STR( \
|
||||
RGA_API_REVISION_VERSION) "_[" RGA_VERSION_STR(RGA_API_BUILD_VERSION) "]"
|
||||
#define RGA_API_VERSION \
|
||||
RGA_VERSION_STR(RGA_API_MAJOR_VERSION) "." \
|
||||
RGA_VERSION_STR(RGA_API_MINOR_VERSION) "." \
|
||||
RGA_VERSION_STR(RGA_API_REVISION_VERSION) "_[" \
|
||||
RGA_VERSION_STR(RGA_API_BUILD_VERSION) "]"
|
||||
#define RGA_API_FULL_VERSION "rga_api version " RGA_API_VERSION
|
||||
|
||||
#define RGA_SET_CURRENT_API_VERISON \
|
||||
((RGA_API_MAJOR_VERSION & 0xff) << 24 | \
|
||||
(RGA_API_MINOR_VERSION & 0xff) << 16 | \
|
||||
(RGA_API_REVISION_VERSION & 0xff) << 8 | (RGA_API_BUILD_VERSION & 0xff))
|
||||
#define RGA_SET_CURRENT_API_VERISON (\
|
||||
(RGA_API_MAJOR_VERSION & 0xff) << 24 | \
|
||||
(RGA_API_MINOR_VERSION & 0xff) << 16 | \
|
||||
(RGA_API_REVISION_VERSION & 0xff) << 8 | \
|
||||
(RGA_API_BUILD_VERSION & 0xff)\
|
||||
)
|
||||
|
||||
#endif /* _RGA_IM2D_VERSION_H_ */
|
||||
|
||||
@@ -23,39 +23,40 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Use 'r' as magic number */
|
||||
#define RGA_IOC_MAGIC 'r'
|
||||
#define RGA_IOW(nr, type) _IOW(RGA_IOC_MAGIC, nr, type)
|
||||
#define RGA_IOR(nr, type) _IOR(RGA_IOC_MAGIC, nr, type)
|
||||
#define RGA_IOWR(nr, type) _IOWR(RGA_IOC_MAGIC, nr, type)
|
||||
#define RGA_IOC_MAGIC 'r'
|
||||
#define RGA_IOW(nr, type) _IOW(RGA_IOC_MAGIC, nr, type)
|
||||
#define RGA_IOR(nr, type) _IOR(RGA_IOC_MAGIC, nr, type)
|
||||
#define RGA_IOWR(nr, type) _IOWR(RGA_IOC_MAGIC, nr, type)
|
||||
|
||||
#define RGA_IOC_GET_DRVIER_VERSION RGA_IOR(0x1, struct rga_version_t)
|
||||
#define RGA_IOC_GET_HW_VERSION RGA_IOR(0x2, struct rga_hw_versions_t)
|
||||
#define RGA_IOC_IMPORT_BUFFER RGA_IOWR(0x3, struct rga_buffer_pool)
|
||||
#define RGA_IOC_RELEASE_BUFFER RGA_IOW(0x4, struct rga_buffer_pool)
|
||||
#define RGA_START_CONFIG RGA_IOR(0x5, uint32_t)
|
||||
#define RGA_END_CONFIG RGA_IOWR(0x6, struct rga_user_ctx_t)
|
||||
#define RGA_CMD_CONFIG RGA_IOWR(0x7, struct rga_user_ctx_t)
|
||||
#define RGA_CANCEL_CONFIG RGA_IOWR(0x8, uint32_t)
|
||||
#define RGA_IOC_GET_DRVIER_VERSION RGA_IOR(0x1, struct rga_version_t)
|
||||
#define RGA_IOC_GET_HW_VERSION RGA_IOR(0x2, struct rga_hw_versions_t)
|
||||
#define RGA_IOC_IMPORT_BUFFER RGA_IOWR(0x3, struct rga_buffer_pool)
|
||||
#define RGA_IOC_RELEASE_BUFFER RGA_IOW(0x4, struct rga_buffer_pool)
|
||||
#define RGA_START_CONFIG RGA_IOR(0x5, uint32_t)
|
||||
#define RGA_END_CONFIG RGA_IOWR(0x6, struct rga_user_ctx_t)
|
||||
#define RGA_CMD_CONFIG RGA_IOWR(0x7, struct rga_user_ctx_t)
|
||||
#define RGA_CANCEL_CONFIG RGA_IOWR(0x8, uint32_t)
|
||||
|
||||
#define RGA_BLIT_SYNC 0x5017
|
||||
#define RGA_BLIT_ASYNC 0x5018
|
||||
#define RGA_FLUSH 0x5019
|
||||
#define RGA_GET_RESULT 0x501a
|
||||
#define RGA_BLIT_SYNC 0x5017
|
||||
#define RGA_BLIT_ASYNC 0x5018
|
||||
#define RGA_FLUSH 0x5019
|
||||
#define RGA_GET_RESULT 0x501a
|
||||
#define RGA_GET_VERSION 0x501b
|
||||
|
||||
#define RGA2_BLIT_SYNC 0x6017
|
||||
#define RGA2_BLIT_ASYNC 0x6018
|
||||
#define RGA2_FLUSH 0x6019
|
||||
#define RGA2_GET_RESULT 0x601a
|
||||
#define RGA2_BLIT_SYNC 0x6017
|
||||
#define RGA2_BLIT_ASYNC 0x6018
|
||||
#define RGA2_FLUSH 0x6019
|
||||
#define RGA2_GET_RESULT 0x601a
|
||||
#define RGA2_GET_VERSION 0x601b
|
||||
|
||||
#define RGA_REG_CTRL_LEN 0x8 /* 8 */
|
||||
#define RGA_REG_CMD_LEN 0x1c /* 28 */
|
||||
#define RGA_CMD_BUF_SIZE 0x700 /* 16*28*4 */
|
||||
#define RGA_REG_CTRL_LEN 0x8 /* 8 */
|
||||
#define RGA_REG_CMD_LEN 0x1c /* 28 */
|
||||
#define RGA_CMD_BUF_SIZE 0x700 /* 16*28*4 */
|
||||
|
||||
#ifndef ENABLE
|
||||
#define ENABLE 1
|
||||
@@ -66,514 +67,519 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
enum rga_memory_type {
|
||||
RGA_DMA_BUFFER = 0,
|
||||
RGA_VIRTUAL_ADDRESS,
|
||||
RGA_PHYSICAL_ADDRESS
|
||||
RGA_DMA_BUFFER = 0,
|
||||
RGA_VIRTUAL_ADDRESS,
|
||||
RGA_PHYSICAL_ADDRESS
|
||||
};
|
||||
|
||||
/* RGA process mode enum */
|
||||
enum {
|
||||
bitblt_mode = 0x0,
|
||||
color_palette_mode = 0x1,
|
||||
color_fill_mode = 0x2,
|
||||
line_point_drawing_mode = 0x3,
|
||||
blur_sharp_filter_mode = 0x4,
|
||||
pre_scaling_mode = 0x5,
|
||||
update_palette_table_mode = 0x6,
|
||||
update_patten_buff_mode = 0x7,
|
||||
bitblt_mode = 0x0,
|
||||
color_palette_mode = 0x1,
|
||||
color_fill_mode = 0x2,
|
||||
line_point_drawing_mode = 0x3,
|
||||
blur_sharp_filter_mode = 0x4,
|
||||
pre_scaling_mode = 0x5,
|
||||
update_palette_table_mode = 0x6,
|
||||
update_patten_buff_mode = 0x7,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
rop_enable_mask = 0x2,
|
||||
dither_enable_mask = 0x8,
|
||||
fading_enable_mask = 0x10,
|
||||
PD_enbale_mask = 0x20,
|
||||
};
|
||||
|
||||
enum {
|
||||
rop_enable_mask = 0x2,
|
||||
dither_enable_mask = 0x8,
|
||||
fading_enable_mask = 0x10,
|
||||
PD_enbale_mask = 0x20,
|
||||
};
|
||||
yuv2rgb_mode0 = 0x0, /* BT.601 MPEG */
|
||||
yuv2rgb_mode1 = 0x1, /* BT.601 JPEG */
|
||||
yuv2rgb_mode2 = 0x2, /* BT.709 */
|
||||
|
||||
enum {
|
||||
yuv2rgb_mode0 = 0x0, /* BT.601 MPEG */
|
||||
yuv2rgb_mode1 = 0x1, /* BT.601 JPEG */
|
||||
yuv2rgb_mode2 = 0x2, /* BT.709 */
|
||||
|
||||
rgb2yuv_601_full = 0x1 << 8,
|
||||
rgb2yuv_709_full = 0x2 << 8,
|
||||
yuv2yuv_601_limit_2_709_limit = 0x3 << 8,
|
||||
yuv2yuv_601_limit_2_709_full = 0x4 << 8,
|
||||
yuv2yuv_709_limit_2_601_limit = 0x5 << 8,
|
||||
yuv2yuv_709_limit_2_601_full = 0x6 << 8, // not support
|
||||
yuv2yuv_601_full_2_709_limit = 0x7 << 8,
|
||||
yuv2yuv_601_full_2_709_full = 0x8 << 8, // not support
|
||||
yuv2yuv_709_full_2_601_limit = 0x9 << 8, // not support
|
||||
yuv2yuv_709_full_2_601_full = 0xa << 8, // not support
|
||||
full_csc_mask = 0xf00,
|
||||
rgb2yuv_601_full = 0x1 << 8,
|
||||
rgb2yuv_709_full = 0x2 << 8,
|
||||
yuv2yuv_601_limit_2_709_limit = 0x3 << 8,
|
||||
yuv2yuv_601_limit_2_709_full = 0x4 << 8,
|
||||
yuv2yuv_709_limit_2_601_limit = 0x5 << 8,
|
||||
yuv2yuv_709_limit_2_601_full = 0x6 << 8, //not support
|
||||
yuv2yuv_601_full_2_709_limit = 0x7 << 8,
|
||||
yuv2yuv_601_full_2_709_full = 0x8 << 8, //not support
|
||||
yuv2yuv_709_full_2_601_limit = 0x9 << 8, //not support
|
||||
yuv2yuv_709_full_2_601_full = 0xa << 8, //not support
|
||||
full_csc_mask = 0xf00,
|
||||
};
|
||||
|
||||
/* RGA rotate mode */
|
||||
enum {
|
||||
rotate_mode0 = 0x0, /* no rotate */
|
||||
rotate_mode1 = 0x1, /* rotate */
|
||||
rotate_mode2 = 0x2, /* x_mirror */
|
||||
rotate_mode3 = 0x3, /* y_mirror */
|
||||
rotate_mode0 = 0x0, /* no rotate */
|
||||
rotate_mode1 = 0x1, /* rotate */
|
||||
rotate_mode2 = 0x2, /* x_mirror */
|
||||
rotate_mode3 = 0x3, /* y_mirror */
|
||||
};
|
||||
|
||||
enum {
|
||||
color_palette_mode0 = 0x0, /* 1K */
|
||||
color_palette_mode1 = 0x1, /* 2K */
|
||||
color_palette_mode2 = 0x2, /* 4K */
|
||||
color_palette_mode3 = 0x3, /* 8K */
|
||||
color_palette_mode0 = 0x0, /* 1K */
|
||||
color_palette_mode1 = 0x1, /* 2K */
|
||||
color_palette_mode2 = 0x2, /* 4K */
|
||||
color_palette_mode3 = 0x3, /* 8K */
|
||||
};
|
||||
|
||||
enum {
|
||||
BB_BYPASS = 0x0, /* no rotate */
|
||||
BB_ROTATE = 0x1, /* rotate */
|
||||
BB_X_MIRROR = 0x2, /* x_mirror */
|
||||
BB_Y_MIRROR = 0x3 /* y_mirror */
|
||||
BB_BYPASS = 0x0, /* no rotate */
|
||||
BB_ROTATE = 0x1, /* rotate */
|
||||
BB_X_MIRROR = 0x2, /* x_mirror */
|
||||
BB_Y_MIRROR = 0x3 /* y_mirror */
|
||||
};
|
||||
|
||||
enum {
|
||||
nearby = 0x0, /* no rotate */
|
||||
bilinear = 0x1, /* rotate */
|
||||
bicubic = 0x2, /* x_mirror */
|
||||
nearby = 0x0, /* no rotate */
|
||||
bilinear = 0x1, /* rotate */
|
||||
bicubic = 0x2, /* x_mirror */
|
||||
};
|
||||
|
||||
#define RGA_SCHED_PRIORITY_DEFAULT 0
|
||||
#define RGA_SCHED_PRIORITY_MAX 6
|
||||
|
||||
enum {
|
||||
RGA3_SCHEDULER_CORE0 = 1 << 0,
|
||||
RGA3_SCHEDULER_CORE1 = 1 << 1,
|
||||
RGA2_SCHEDULER_CORE0 = 1 << 2,
|
||||
RGA3_SCHEDULER_CORE0 = 1 << 0,
|
||||
RGA3_SCHEDULER_CORE1 = 1 << 1,
|
||||
RGA2_SCHEDULER_CORE0 = 1 << 2,
|
||||
};
|
||||
|
||||
/*
|
||||
// Alpha Red Green Blue
|
||||
{ 4, 32, {{32,24, 8, 0, 16, 8, 24,16 }}, GGL_RGBA }, //
|
||||
RK_FORMAT_RGBA_8888 { 4, 24, {{ 0, 0, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, //
|
||||
RK_FORMAT_RGBX_8888 { 3, 24, {{ 0, 0, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, //
|
||||
RK_FORMAT_RGB_888 { 4, 32, {{32,24, 24,16, 16, 8, 8, 0 }}, GGL_BGRA }, //
|
||||
RK_FORMAT_BGRA_8888 { 2, 16, {{ 0, 0, 16,11, 11, 5, 5, 0 }}, GGL_RGB }, //
|
||||
RK_FORMAT_RGB_565 { 2, 16, {{ 1, 0, 16,11, 11, 6, 6, 1 }}, GGL_RGBA }, //
|
||||
RK_FORMAT_RGBA_5551 { 2, 16, {{ 4, 0, 16,12, 12, 8, 8, 4 }}, GGL_RGBA }, //
|
||||
RK_FORMAT_RGBA_4444 { 3, 24, {{ 0, 0, 24,16, 16, 8, 8, 0 }}, GGL_BGR }, //
|
||||
RK_FORMAT_BGB_888
|
||||
{ 4, 32, {{32,24, 8, 0, 16, 8, 24,16 }}, GGL_RGBA }, // RK_FORMAT_RGBA_8888
|
||||
{ 4, 24, {{ 0, 0, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, // RK_FORMAT_RGBX_8888
|
||||
{ 3, 24, {{ 0, 0, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, // RK_FORMAT_RGB_888
|
||||
{ 4, 32, {{32,24, 24,16, 16, 8, 8, 0 }}, GGL_BGRA }, // RK_FORMAT_BGRA_8888
|
||||
{ 2, 16, {{ 0, 0, 16,11, 11, 5, 5, 0 }}, GGL_RGB }, // RK_FORMAT_RGB_565
|
||||
{ 2, 16, {{ 1, 0, 16,11, 11, 6, 6, 1 }}, GGL_RGBA }, // RK_FORMAT_RGBA_5551
|
||||
{ 2, 16, {{ 4, 0, 16,12, 12, 8, 8, 4 }}, GGL_RGBA }, // RK_FORMAT_RGBA_4444
|
||||
{ 3, 24, {{ 0, 0, 24,16, 16, 8, 8, 0 }}, GGL_BGR }, // RK_FORMAT_BGB_888
|
||||
|
||||
*/
|
||||
/* In order to be compatible with RK_FORMAT_XX and HAL_PIXEL_FORMAT_XX,
|
||||
* RK_FORMAT_XX is shifted to the left by 8 bits to distinguish. */
|
||||
typedef enum _Rga_SURF_FORMAT {
|
||||
RK_FORMAT_RGBA_8888 = 0x0 << 8,
|
||||
RK_FORMAT_RGBX_8888 = 0x1 << 8,
|
||||
RK_FORMAT_RGB_888 = 0x2 << 8,
|
||||
RK_FORMAT_BGRA_8888 = 0x3 << 8,
|
||||
RK_FORMAT_RGB_565 = 0x4 << 8,
|
||||
RK_FORMAT_RGBA_5551 = 0x5 << 8,
|
||||
RK_FORMAT_RGBA_4444 = 0x6 << 8,
|
||||
RK_FORMAT_BGR_888 = 0x7 << 8,
|
||||
RK_FORMAT_RGBA_8888 = 0x0 << 8,
|
||||
RK_FORMAT_RGBX_8888 = 0x1 << 8,
|
||||
RK_FORMAT_RGB_888 = 0x2 << 8,
|
||||
RK_FORMAT_BGRA_8888 = 0x3 << 8,
|
||||
RK_FORMAT_RGB_565 = 0x4 << 8,
|
||||
RK_FORMAT_RGBA_5551 = 0x5 << 8,
|
||||
RK_FORMAT_RGBA_4444 = 0x6 << 8,
|
||||
RK_FORMAT_BGR_888 = 0x7 << 8,
|
||||
|
||||
RK_FORMAT_YCbCr_422_SP = 0x8 << 8,
|
||||
RK_FORMAT_YCbCr_422_P = 0x9 << 8,
|
||||
RK_FORMAT_YCbCr_420_SP = 0xa << 8,
|
||||
RK_FORMAT_YCbCr_420_P = 0xb << 8,
|
||||
RK_FORMAT_YCbCr_422_SP = 0x8 << 8,
|
||||
RK_FORMAT_YCbCr_422_P = 0x9 << 8,
|
||||
RK_FORMAT_YCbCr_420_SP = 0xa << 8,
|
||||
RK_FORMAT_YCbCr_420_P = 0xb << 8,
|
||||
|
||||
RK_FORMAT_YCrCb_422_SP = 0xc << 8,
|
||||
RK_FORMAT_YCrCb_422_P = 0xd << 8,
|
||||
RK_FORMAT_YCrCb_420_SP = 0xe << 8,
|
||||
RK_FORMAT_YCrCb_420_P = 0xf << 8,
|
||||
RK_FORMAT_YCrCb_422_SP = 0xc << 8,
|
||||
RK_FORMAT_YCrCb_422_P = 0xd << 8,
|
||||
RK_FORMAT_YCrCb_420_SP = 0xe << 8,
|
||||
RK_FORMAT_YCrCb_420_P = 0xf << 8,
|
||||
|
||||
RK_FORMAT_BPP1 = 0x10 << 8,
|
||||
RK_FORMAT_BPP2 = 0x11 << 8,
|
||||
RK_FORMAT_BPP4 = 0x12 << 8,
|
||||
RK_FORMAT_BPP8 = 0x13 << 8,
|
||||
RK_FORMAT_BPP1 = 0x10 << 8,
|
||||
RK_FORMAT_BPP2 = 0x11 << 8,
|
||||
RK_FORMAT_BPP4 = 0x12 << 8,
|
||||
RK_FORMAT_BPP8 = 0x13 << 8,
|
||||
|
||||
RK_FORMAT_Y4 = 0x14 << 8,
|
||||
RK_FORMAT_YCbCr_400 = 0x15 << 8,
|
||||
RK_FORMAT_Y4 = 0x14 << 8,
|
||||
RK_FORMAT_YCbCr_400 = 0x15 << 8,
|
||||
|
||||
RK_FORMAT_BGRX_8888 = 0x16 << 8,
|
||||
RK_FORMAT_BGRX_8888 = 0x16 << 8,
|
||||
|
||||
RK_FORMAT_YVYU_422 = 0x18 << 8,
|
||||
RK_FORMAT_YVYU_420 = 0x19 << 8,
|
||||
RK_FORMAT_VYUY_422 = 0x1a << 8,
|
||||
RK_FORMAT_VYUY_420 = 0x1b << 8,
|
||||
RK_FORMAT_YUYV_422 = 0x1c << 8,
|
||||
RK_FORMAT_YUYV_420 = 0x1d << 8,
|
||||
RK_FORMAT_UYVY_422 = 0x1e << 8,
|
||||
RK_FORMAT_UYVY_420 = 0x1f << 8,
|
||||
RK_FORMAT_YVYU_422 = 0x18 << 8,
|
||||
RK_FORMAT_YVYU_420 = 0x19 << 8,
|
||||
RK_FORMAT_VYUY_422 = 0x1a << 8,
|
||||
RK_FORMAT_VYUY_420 = 0x1b << 8,
|
||||
RK_FORMAT_YUYV_422 = 0x1c << 8,
|
||||
RK_FORMAT_YUYV_420 = 0x1d << 8,
|
||||
RK_FORMAT_UYVY_422 = 0x1e << 8,
|
||||
RK_FORMAT_UYVY_420 = 0x1f << 8,
|
||||
|
||||
RK_FORMAT_YCbCr_420_SP_10B = 0x20 << 8,
|
||||
RK_FORMAT_YCrCb_420_SP_10B = 0x21 << 8,
|
||||
RK_FORMAT_YCbCr_422_SP_10B = 0x22 << 8,
|
||||
RK_FORMAT_YCrCb_422_SP_10B = 0x23 << 8,
|
||||
/* For compatibility with misspellings */
|
||||
RK_FORMAT_YCbCr_422_10b_SP = RK_FORMAT_YCbCr_422_SP_10B,
|
||||
RK_FORMAT_YCrCb_422_10b_SP = RK_FORMAT_YCrCb_422_SP_10B,
|
||||
RK_FORMAT_YCbCr_420_SP_10B = 0x20 << 8,
|
||||
RK_FORMAT_YCrCb_420_SP_10B = 0x21 << 8,
|
||||
RK_FORMAT_YCbCr_422_SP_10B = 0x22 << 8,
|
||||
RK_FORMAT_YCrCb_422_SP_10B = 0x23 << 8,
|
||||
/* For compatibility with misspellings */
|
||||
RK_FORMAT_YCbCr_422_10b_SP = RK_FORMAT_YCbCr_422_SP_10B,
|
||||
RK_FORMAT_YCrCb_422_10b_SP = RK_FORMAT_YCrCb_422_SP_10B,
|
||||
|
||||
RK_FORMAT_BGR_565 = 0x24 << 8,
|
||||
RK_FORMAT_BGRA_5551 = 0x25 << 8,
|
||||
RK_FORMAT_BGRA_4444 = 0x26 << 8,
|
||||
RK_FORMAT_BGR_565 = 0x24 << 8,
|
||||
RK_FORMAT_BGRA_5551 = 0x25 << 8,
|
||||
RK_FORMAT_BGRA_4444 = 0x26 << 8,
|
||||
|
||||
RK_FORMAT_ARGB_8888 = 0x28 << 8,
|
||||
RK_FORMAT_XRGB_8888 = 0x29 << 8,
|
||||
RK_FORMAT_ARGB_5551 = 0x2a << 8,
|
||||
RK_FORMAT_ARGB_4444 = 0x2b << 8,
|
||||
RK_FORMAT_ABGR_8888 = 0x2c << 8,
|
||||
RK_FORMAT_XBGR_8888 = 0x2d << 8,
|
||||
RK_FORMAT_ABGR_5551 = 0x2e << 8,
|
||||
RK_FORMAT_ABGR_4444 = 0x2f << 8,
|
||||
RK_FORMAT_ARGB_8888 = 0x28 << 8,
|
||||
RK_FORMAT_XRGB_8888 = 0x29 << 8,
|
||||
RK_FORMAT_ARGB_5551 = 0x2a << 8,
|
||||
RK_FORMAT_ARGB_4444 = 0x2b << 8,
|
||||
RK_FORMAT_ABGR_8888 = 0x2c << 8,
|
||||
RK_FORMAT_XBGR_8888 = 0x2d << 8,
|
||||
RK_FORMAT_ABGR_5551 = 0x2e << 8,
|
||||
RK_FORMAT_ABGR_4444 = 0x2f << 8,
|
||||
|
||||
RK_FORMAT_RGBA2BPP = 0x30 << 8,
|
||||
RK_FORMAT_RGBA2BPP = 0x30 << 8,
|
||||
|
||||
RK_FORMAT_UNKNOWN = 0x100 << 8,
|
||||
RK_FORMAT_UNKNOWN = 0x100 << 8,
|
||||
} RgaSURF_FORMAT;
|
||||
|
||||
/* RGA3 rd_mode */
|
||||
enum {
|
||||
raster_mode = 0x1 << 0,
|
||||
fbc_mode = 0x1 << 1,
|
||||
tile_mode = 0x1 << 2,
|
||||
enum
|
||||
{
|
||||
raster_mode = 0x1 << 0,
|
||||
fbc_mode = 0x1 << 1,
|
||||
tile_mode = 0x1 << 2,
|
||||
};
|
||||
|
||||
typedef struct rga_img_info_t {
|
||||
uint64_t yrgb_addr; /* yrgb mem addr */
|
||||
uint64_t uv_addr; /* cb/cr mem addr */
|
||||
uint64_t v_addr; /* cr mem addr */
|
||||
uint64_t yrgb_addr; /* yrgb mem addr */
|
||||
uint64_t uv_addr; /* cb/cr mem addr */
|
||||
uint64_t v_addr; /* cr mem addr */
|
||||
|
||||
uint32_t format; // definition by RK_FORMAT
|
||||
uint16_t act_w;
|
||||
uint16_t act_h;
|
||||
uint16_t x_offset;
|
||||
uint16_t y_offset;
|
||||
uint32_t format; //definition by RK_FORMAT
|
||||
uint16_t act_w;
|
||||
uint16_t act_h;
|
||||
uint16_t x_offset;
|
||||
uint16_t y_offset;
|
||||
|
||||
uint16_t vir_w;
|
||||
uint16_t vir_h;
|
||||
uint16_t vir_w;
|
||||
uint16_t vir_h;
|
||||
|
||||
uint16_t endian_mode; // for BPP
|
||||
uint16_t alpha_swap;
|
||||
uint16_t endian_mode; //for BPP
|
||||
uint16_t alpha_swap;
|
||||
|
||||
// used by RGA3
|
||||
uint16_t rotate_mode;
|
||||
uint16_t rd_mode;
|
||||
//used by RGA3
|
||||
uint16_t rotate_mode;
|
||||
uint16_t rd_mode;
|
||||
|
||||
uint16_t is_10b_compact;
|
||||
uint16_t is_10b_endian;
|
||||
uint16_t is_10b_compact;
|
||||
uint16_t is_10b_endian;
|
||||
|
||||
uint16_t enable;
|
||||
} rga_img_info_t;
|
||||
uint16_t enable;
|
||||
}
|
||||
rga_img_info_t;
|
||||
|
||||
typedef struct POINT {
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
} POINT;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
}
|
||||
POINT;
|
||||
|
||||
typedef struct RECT {
|
||||
uint16_t xmin;
|
||||
uint16_t xmax; // width - 1
|
||||
uint16_t ymin;
|
||||
uint16_t ymax; // height - 1
|
||||
uint16_t xmin;
|
||||
uint16_t xmax; // width - 1
|
||||
uint16_t ymin;
|
||||
uint16_t ymax; // height - 1
|
||||
} RECT;
|
||||
|
||||
typedef struct MMU {
|
||||
uint8_t mmu_en;
|
||||
uint64_t base_addr;
|
||||
uint32_t mmu_flag; /* [0] mmu enable [1] src_flush [2] dst_flush [3] CMD_flush
|
||||
[4~5] page size*/
|
||||
uint8_t mmu_en;
|
||||
uint64_t base_addr;
|
||||
uint32_t mmu_flag; /* [0] mmu enable [1] src_flush [2] dst_flush [3] CMD_flush [4~5] page size*/
|
||||
} MMU;
|
||||
|
||||
typedef struct COLOR_FILL {
|
||||
int16_t gr_x_a;
|
||||
int16_t gr_y_a;
|
||||
int16_t gr_x_b;
|
||||
int16_t gr_y_b;
|
||||
int16_t gr_x_g;
|
||||
int16_t gr_y_g;
|
||||
int16_t gr_x_r;
|
||||
int16_t gr_y_r;
|
||||
// u8 cp_gr_saturation;
|
||||
} COLOR_FILL;
|
||||
int16_t gr_x_a;
|
||||
int16_t gr_y_a;
|
||||
int16_t gr_x_b;
|
||||
int16_t gr_y_b;
|
||||
int16_t gr_x_g;
|
||||
int16_t gr_y_g;
|
||||
int16_t gr_x_r;
|
||||
int16_t gr_y_r;
|
||||
//u8 cp_gr_saturation;
|
||||
}
|
||||
COLOR_FILL;
|
||||
|
||||
typedef struct FADING {
|
||||
uint8_t b;
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
uint8_t res;
|
||||
} FADING;
|
||||
uint8_t b;
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
uint8_t res;
|
||||
}
|
||||
FADING;
|
||||
|
||||
typedef struct line_draw_t {
|
||||
POINT start_point; /* LineDraw_start_point */
|
||||
POINT end_point; /* LineDraw_end_point */
|
||||
uint32_t color; /* LineDraw_color */
|
||||
uint32_t flag; /* (enum) LineDrawing mode sel */
|
||||
uint32_t line_width; /* range 1~16 */
|
||||
} line_draw_t;
|
||||
POINT start_point; /* LineDraw_start_point */
|
||||
POINT end_point; /* LineDraw_end_point */
|
||||
uint32_t color; /* LineDraw_color */
|
||||
uint32_t flag; /* (enum) LineDrawing mode sel */
|
||||
uint32_t line_width; /* range 1~16 */
|
||||
}
|
||||
line_draw_t;
|
||||
|
||||
/* color space convert coefficient. */
|
||||
typedef struct csc_coe_t {
|
||||
int16_t r_v;
|
||||
int16_t g_y;
|
||||
int16_t b_u;
|
||||
int32_t off;
|
||||
int16_t r_v;
|
||||
int16_t g_y;
|
||||
int16_t b_u;
|
||||
int32_t off;
|
||||
} csc_coe_t;
|
||||
|
||||
typedef struct full_csc_t {
|
||||
uint8_t flag;
|
||||
csc_coe_t coe_y;
|
||||
csc_coe_t coe_u;
|
||||
csc_coe_t coe_v;
|
||||
uint8_t flag;
|
||||
csc_coe_t coe_y;
|
||||
csc_coe_t coe_u;
|
||||
csc_coe_t coe_v;
|
||||
} full_csc_t;
|
||||
|
||||
struct rga_mosaic_info {
|
||||
uint8_t enable;
|
||||
uint8_t mode;
|
||||
uint8_t enable;
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
struct rga_pre_intr_info {
|
||||
uint8_t enable;
|
||||
uint8_t enable;
|
||||
|
||||
uint8_t read_intr_en;
|
||||
uint8_t write_intr_en;
|
||||
uint8_t read_hold_en;
|
||||
uint32_t read_threshold;
|
||||
uint32_t write_start;
|
||||
uint32_t write_step;
|
||||
uint8_t read_intr_en;
|
||||
uint8_t write_intr_en;
|
||||
uint8_t read_hold_en;
|
||||
uint32_t read_threshold;
|
||||
uint32_t write_start;
|
||||
uint32_t write_step;
|
||||
};
|
||||
|
||||
/* MAX(min, (max - channel_value)) */
|
||||
struct rga_osd_invert_factor {
|
||||
uint8_t alpha_max;
|
||||
uint8_t alpha_min;
|
||||
uint8_t yg_max;
|
||||
uint8_t yg_min;
|
||||
uint8_t crb_max;
|
||||
uint8_t crb_min;
|
||||
uint8_t alpha_max;
|
||||
uint8_t alpha_min;
|
||||
uint8_t yg_max;
|
||||
uint8_t yg_min;
|
||||
uint8_t crb_max;
|
||||
uint8_t crb_min;
|
||||
};
|
||||
|
||||
struct rga_color {
|
||||
union {
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t alpha;
|
||||
union {
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t alpha;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
};
|
||||
|
||||
struct rga_osd_bpp2 {
|
||||
uint8_t ac_swap; // ac swap flag
|
||||
// 0: CA
|
||||
// 1: AC
|
||||
uint8_t endian_swap; // rgba2bpp endian swap
|
||||
// 0: Big endian
|
||||
// 1: Little endian
|
||||
struct rga_color color0;
|
||||
struct rga_color color1;
|
||||
uint8_t ac_swap; // ac swap flag
|
||||
// 0: CA
|
||||
// 1: AC
|
||||
uint8_t endian_swap; // rgba2bpp endian swap
|
||||
// 0: Big endian
|
||||
// 1: Little endian
|
||||
struct rga_color color0;
|
||||
struct rga_color color1;
|
||||
};
|
||||
|
||||
struct rga_osd_mode_ctrl {
|
||||
uint8_t mode; // OSD cal mode:
|
||||
// 0b'1: statistics mode
|
||||
// 1b'1: auto inversion overlap mode
|
||||
uint8_t direction_mode; // horizontal or vertical
|
||||
// 0: horizontal
|
||||
// 1: vertical
|
||||
uint8_t width_mode; // using @fix_width or LUT width
|
||||
// 0: fix width
|
||||
// 1: LUT width
|
||||
uint16_t block_fix_width; // OSD block fixed width
|
||||
// real width = (fix_width + 1) * 2
|
||||
uint8_t block_num; // OSD block num
|
||||
uint16_t flags_index; // auto invert flags index
|
||||
uint8_t mode; // OSD cal mode:
|
||||
// 0b'1: statistics mode
|
||||
// 1b'1: auto inversion overlap mode
|
||||
uint8_t direction_mode; // horizontal or vertical
|
||||
// 0: horizontal
|
||||
// 1: vertical
|
||||
uint8_t width_mode; // using @fix_width or LUT width
|
||||
// 0: fix width
|
||||
// 1: LUT width
|
||||
uint16_t block_fix_width; // OSD block fixed width
|
||||
// real width = (fix_width + 1) * 2
|
||||
uint8_t block_num; // OSD block num
|
||||
uint16_t flags_index; // auto invert flags index
|
||||
|
||||
/* invertion config */
|
||||
uint8_t color_mode; // selete color
|
||||
// 0: src1 color
|
||||
// 1: config data color
|
||||
uint8_t invert_flags_mode; // invert flag selete
|
||||
// 0: use RAM flag
|
||||
// 1: usr last result
|
||||
uint8_t default_color_sel; // default color mode
|
||||
// 0: default is bright
|
||||
// 1: default is dark
|
||||
uint8_t invert_enable; // invert channel enable
|
||||
// 1 << 0: aplha enable
|
||||
// 1 << 1: Y/G disable
|
||||
// 1 << 2: C/RB disable
|
||||
uint8_t invert_mode; // invert cal mode
|
||||
// 0: normal(max-data)
|
||||
// 1: swap
|
||||
uint8_t invert_thresh; // if luma > thresh, osd_flag to be 1
|
||||
uint8_t unfix_index; // OSD width config index
|
||||
/* invertion config */
|
||||
uint8_t color_mode; // selete color
|
||||
// 0: src1 color
|
||||
// 1: config data color
|
||||
uint8_t invert_flags_mode; // invert flag selete
|
||||
// 0: use RAM flag
|
||||
// 1: usr last result
|
||||
uint8_t default_color_sel; // default color mode
|
||||
// 0: default is bright
|
||||
// 1: default is dark
|
||||
uint8_t invert_enable; // invert channel enable
|
||||
// 1 << 0: aplha enable
|
||||
// 1 << 1: Y/G disable
|
||||
// 1 << 2: C/RB disable
|
||||
uint8_t invert_mode; // invert cal mode
|
||||
// 0: normal(max-data)
|
||||
// 1: swap
|
||||
uint8_t invert_thresh; // if luma > thresh, osd_flag to be 1
|
||||
uint8_t unfix_index; // OSD width config index
|
||||
};
|
||||
|
||||
struct rga_osd_info {
|
||||
uint8_t enable;
|
||||
uint8_t enable;
|
||||
|
||||
struct rga_osd_mode_ctrl mode_ctrl;
|
||||
struct rga_osd_invert_factor cal_factor;
|
||||
struct rga_osd_bpp2 bpp2_info;
|
||||
struct rga_osd_mode_ctrl mode_ctrl;
|
||||
struct rga_osd_invert_factor cal_factor;
|
||||
struct rga_osd_bpp2 bpp2_info;
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t last_flags1;
|
||||
uint32_t last_flags0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t last_flags1;
|
||||
uint32_t last_flags0;
|
||||
};
|
||||
uint64_t last_flags;
|
||||
};
|
||||
uint64_t last_flags;
|
||||
};
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t cur_flags1;
|
||||
uint32_t cur_flags0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t cur_flags1;
|
||||
uint32_t cur_flags0;
|
||||
};
|
||||
uint64_t cur_flags;
|
||||
};
|
||||
uint64_t cur_flags;
|
||||
};
|
||||
};
|
||||
|
||||
#define RGA_VERSION_SIZE 16
|
||||
#define RGA_HW_SIZE 5
|
||||
#define RGA_VERSION_SIZE 16
|
||||
#define RGA_HW_SIZE 5
|
||||
|
||||
struct rga_version_t {
|
||||
uint32_t major;
|
||||
uint32_t minor;
|
||||
uint32_t revision;
|
||||
uint8_t str[RGA_VERSION_SIZE];
|
||||
uint32_t major;
|
||||
uint32_t minor;
|
||||
uint32_t revision;
|
||||
uint8_t str[RGA_VERSION_SIZE];
|
||||
};
|
||||
|
||||
struct rga_hw_versions_t {
|
||||
struct rga_version_t version[RGA_HW_SIZE];
|
||||
uint32_t size;
|
||||
struct rga_version_t version[RGA_HW_SIZE];
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct rga_memory_parm {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
|
||||
uint32_t size;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct rga_external_buffer {
|
||||
uint64_t memory;
|
||||
uint32_t type;
|
||||
uint64_t memory;
|
||||
uint32_t type;
|
||||
|
||||
uint32_t handle;
|
||||
struct rga_memory_parm memory_info;
|
||||
uint32_t handle;
|
||||
struct rga_memory_parm memory_info;
|
||||
|
||||
uint8_t reserve[252];
|
||||
uint8_t reserve[252];
|
||||
};
|
||||
|
||||
struct rga_buffer_pool {
|
||||
uint64_t buffers;
|
||||
uint32_t size;
|
||||
uint64_t buffers;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct rga_req {
|
||||
uint8_t render_mode; /* (enum) process mode sel */
|
||||
uint8_t render_mode; /* (enum) process mode sel */
|
||||
|
||||
rga_img_info_t src; /* src image info */
|
||||
rga_img_info_t dst; /* dst image info */
|
||||
rga_img_info_t pat; /* patten image info */
|
||||
rga_img_info_t src; /* src image info */
|
||||
rga_img_info_t dst; /* dst image info */
|
||||
rga_img_info_t pat; /* patten image info */
|
||||
|
||||
uint64_t rop_mask_addr; /* rop4 mask addr */
|
||||
uint64_t LUT_addr; /* LUT addr */
|
||||
uint64_t rop_mask_addr; /* rop4 mask addr */
|
||||
uint64_t LUT_addr; /* LUT addr */
|
||||
|
||||
RECT clip; /* dst clip window default value is dst_vir */
|
||||
/* value from [0, w-1] / [0, h-1]*/
|
||||
RECT clip; /* dst clip window default value is dst_vir */
|
||||
/* value from [0, w-1] / [0, h-1]*/
|
||||
|
||||
int32_t sina; /* dst angle default value 0 16.16 scan from table */
|
||||
int32_t cosa; /* dst angle default value 0 16.16 scan from table */
|
||||
int32_t sina; /* dst angle default value 0 16.16 scan from table */
|
||||
int32_t cosa; /* dst angle default value 0 16.16 scan from table */
|
||||
|
||||
uint16_t alpha_rop_flag; /* alpha rop process flag */
|
||||
/* ([0] = 1 alpha_rop_enable) */
|
||||
/* ([1] = 1 rop enable) */
|
||||
/* ([2] = 1 fading_enable) */
|
||||
/* ([3] = 1 PD_enable) */
|
||||
/* ([4] = 1 alpha cal_mode_sel) */
|
||||
/* ([5] = 1 dither_enable) */
|
||||
/* ([6] = 1 gradient fill mode sel) */
|
||||
/* ([7] = 1 AA_enable) */
|
||||
/* ([8] = 1 nn_quantize) */
|
||||
/* ([9] = 1 Real color mode) */
|
||||
uint16_t alpha_rop_flag; /* alpha rop process flag */
|
||||
/* ([0] = 1 alpha_rop_enable) */
|
||||
/* ([1] = 1 rop enable) */
|
||||
/* ([2] = 1 fading_enable) */
|
||||
/* ([3] = 1 PD_enable) */
|
||||
/* ([4] = 1 alpha cal_mode_sel) */
|
||||
/* ([5] = 1 dither_enable) */
|
||||
/* ([6] = 1 gradient fill mode sel) */
|
||||
/* ([7] = 1 AA_enable) */
|
||||
/* ([8] = 1 nn_quantize) */
|
||||
/* ([9] = 1 Real color mode) */
|
||||
|
||||
uint8_t scale_mode; /* 0 nearst / 1 bilnear / 2 bicubic */
|
||||
uint8_t scale_mode; /* 0 nearst / 1 bilnear / 2 bicubic */
|
||||
|
||||
uint32_t color_key_max; /* color key max */
|
||||
uint32_t color_key_min; /* color key min */
|
||||
uint32_t color_key_max; /* color key max */
|
||||
uint32_t color_key_min; /* color key min */
|
||||
|
||||
uint32_t fg_color; /* foreground color */
|
||||
uint32_t bg_color; /* background color */
|
||||
uint32_t fg_color; /* foreground color */
|
||||
uint32_t bg_color; /* background color */
|
||||
|
||||
COLOR_FILL gr_color; /* color fill use gradient */
|
||||
COLOR_FILL gr_color; /* color fill use gradient */
|
||||
|
||||
line_draw_t line_draw_info;
|
||||
line_draw_t line_draw_info;
|
||||
|
||||
FADING fading;
|
||||
FADING fading;
|
||||
|
||||
uint8_t PD_mode; /* porter duff alpha mode sel */
|
||||
uint8_t PD_mode; /* porter duff alpha mode sel */
|
||||
|
||||
uint8_t alpha_global_value; /* global alpha value */
|
||||
uint8_t alpha_global_value; /* global alpha value */
|
||||
|
||||
uint16_t rop_code; /* rop2/3/4 code scan from rop code table*/
|
||||
uint16_t rop_code; /* rop2/3/4 code scan from rop code table*/
|
||||
|
||||
uint8_t bsfilter_flag; /* [2] 0 blur 1 sharp / [1:0] filter_type*/
|
||||
uint8_t bsfilter_flag; /* [2] 0 blur 1 sharp / [1:0] filter_type*/
|
||||
|
||||
uint8_t palette_mode; /* (enum) color palatte 0/1bpp, 1/2bpp 2/4bpp 3/8bpp*/
|
||||
uint8_t palette_mode; /* (enum) color palatte 0/1bpp, 1/2bpp 2/4bpp 3/8bpp*/
|
||||
|
||||
uint8_t yuv2rgb_mode; /* (enum) BT.601 MPEG / BT.601 JPEG / BT.709 */
|
||||
uint8_t yuv2rgb_mode; /* (enum) BT.601 MPEG / BT.601 JPEG / BT.709 */
|
||||
|
||||
uint8_t endian_mode; /* 0/big endian 1/little endian*/
|
||||
uint8_t endian_mode; /* 0/big endian 1/little endian*/
|
||||
|
||||
uint8_t rotate_mode; /* (enum) rotate mode */
|
||||
/* 0x0, no rotate */
|
||||
/* 0x1, rotate */
|
||||
/* 0x2, x_mirror */
|
||||
/* 0x3, y_mirror */
|
||||
uint8_t rotate_mode; /* (enum) rotate mode */
|
||||
/* 0x0, no rotate */
|
||||
/* 0x1, rotate */
|
||||
/* 0x2, x_mirror */
|
||||
/* 0x3, y_mirror */
|
||||
|
||||
uint8_t color_fill_mode; /* 0 solid color / 1 patten color */
|
||||
uint8_t color_fill_mode; /* 0 solid color / 1 patten color */
|
||||
|
||||
MMU mmu_info; /* mmu information */
|
||||
MMU mmu_info; /* mmu information */
|
||||
|
||||
uint8_t alpha_rop_mode; /* ([0~1] alpha mode) */
|
||||
/* ([2~3] rop mode) */
|
||||
/* ([4] zero mode en) */
|
||||
/* ([5] dst alpha mode) (RGA1) */
|
||||
uint8_t alpha_rop_mode; /* ([0~1] alpha mode) */
|
||||
/* ([2~3] rop mode) */
|
||||
/* ([4] zero mode en) */
|
||||
/* ([5] dst alpha mode) (RGA1) */
|
||||
|
||||
uint8_t src_trans_mode;
|
||||
uint8_t src_trans_mode;
|
||||
|
||||
uint8_t dither_mode;
|
||||
uint8_t dither_mode;
|
||||
|
||||
full_csc_t full_csc; /* full color space convert */
|
||||
full_csc_t full_csc; /* full color space convert */
|
||||
|
||||
int32_t in_fence_fd;
|
||||
uint8_t core;
|
||||
uint8_t priority;
|
||||
int32_t out_fence_fd;
|
||||
int32_t in_fence_fd;
|
||||
uint8_t core;
|
||||
uint8_t priority;
|
||||
int32_t out_fence_fd;
|
||||
|
||||
uint8_t handle_flag;
|
||||
uint8_t handle_flag;
|
||||
|
||||
/* RGA2 1106 add */
|
||||
struct rga_mosaic_info mosaic_info;
|
||||
/* RGA2 1106 add */
|
||||
struct rga_mosaic_info mosaic_info;
|
||||
|
||||
uint8_t uvhds_mode;
|
||||
uint8_t uvvds_mode;
|
||||
uint8_t uvhds_mode;
|
||||
uint8_t uvvds_mode;
|
||||
|
||||
struct rga_osd_info osd_info;
|
||||
struct rga_osd_info osd_info;
|
||||
|
||||
struct rga_pre_intr_info pre_intr_info;
|
||||
struct rga_pre_intr_info pre_intr_info;
|
||||
|
||||
uint8_t reservr[59];
|
||||
uint8_t reservr[59];
|
||||
};
|
||||
|
||||
struct rga_user_ctx_t {
|
||||
uint64_t cmd_ptr;
|
||||
uint32_t cmd_num;
|
||||
uint32_t id;
|
||||
uint32_t sync_mode;
|
||||
uint32_t out_fence_fd;
|
||||
uint64_t cmd_ptr;
|
||||
uint32_t cmd_num;
|
||||
uint32_t id;
|
||||
uint32_t sync_mode;
|
||||
uint32_t out_fence_fd;
|
||||
|
||||
uint32_t mpi_config_flags;
|
||||
uint32_t mpi_config_flags;
|
||||
|
||||
uint8_t reservr[124];
|
||||
uint8_t reservr[124];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Binary file not shown.
@@ -22,36 +22,38 @@
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <vector>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <system/graphics.h>
|
||||
|
||||
#include <utils/Thread.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <linux/stddef.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include <android/log.h>
|
||||
#include <log/log_main.h>
|
||||
#include <utils/Atomic.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <android/log.h>
|
||||
#include <utils/Log.h>
|
||||
#include <log/log_main.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "rga.h"
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
int RkRgaGetHandleFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleAttributes(buffer_handle_t handle, std::vector<int> *attrs);
|
||||
int RkRgaGetHandleMapAddress(buffer_handle_t handle, void **buf);
|
||||
#endif // Android
|
||||
int RkRgaGetHandleFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleAttributes(buffer_handle_t handle,
|
||||
std::vector<int> *attrs);
|
||||
int RkRgaGetHandleMapAddress(buffer_handle_t handle,
|
||||
void **buf);
|
||||
#endif //Android
|
||||
|
||||
#endif //_rk_graphic_buffer_h_
|
||||
#endif //_rk_graphic_buffer_h_
|
||||
|
||||
@@ -18,23 +18,23 @@
|
||||
#ifndef _rockchip_rga_c_h_
|
||||
#define _rockchip_rga_c_h_
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <linux/stddef.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "rga.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -44,28 +44,26 @@ extern "C" {
|
||||
* compatibility with the old C interface, so please do
|
||||
* not use ctx, because it is usually a NULL.
|
||||
*/
|
||||
#define RgaInit(ctx) \
|
||||
({ \
|
||||
int ret = 0; \
|
||||
ret = c_RkRgaInit(); \
|
||||
c_RkRgaGetContext(ctx); \
|
||||
ret; \
|
||||
})
|
||||
#define RgaDeInit(ctx) \
|
||||
{ \
|
||||
(void)ctx; /* unused */ \
|
||||
c_RkRgaDeInit(); \
|
||||
}
|
||||
#define RgaInit(ctx) ({ \
|
||||
int ret = 0; \
|
||||
ret = c_RkRgaInit(); \
|
||||
c_RkRgaGetContext(ctx); \
|
||||
ret;\
|
||||
})
|
||||
#define RgaDeInit(ctx) { \
|
||||
(void)ctx; /* unused */ \
|
||||
c_RkRgaDeInit(); \
|
||||
}
|
||||
#define RgaBlit(...) c_RkRgaBlit(__VA_ARGS__)
|
||||
#define RgaCollorFill(...) c_RkRgaColorFill(__VA_ARGS__)
|
||||
#define RgaFlush() c_RkRgaFlush()
|
||||
|
||||
int c_RkRgaInit();
|
||||
int c_RkRgaInit();
|
||||
void c_RkRgaDeInit();
|
||||
void c_RkRgaGetContext(void **ctx);
|
||||
int c_RkRgaBlit(rga_info_t *src, rga_info_t *dst, rga_info_t *src1);
|
||||
int c_RkRgaColorFill(rga_info_t *dst);
|
||||
int c_RkRgaFlush();
|
||||
int c_RkRgaBlit(rga_info_t *src, rga_info_t *dst, rga_info_t *src1);
|
||||
int c_RkRgaColorFill(rga_info_t *dst);
|
||||
int c_RkRgaFlush();
|
||||
|
||||
#ifndef ANDROID /* linux */
|
||||
int c_RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LIBS_RGA_MUTEX_H
|
||||
#define _LIBS_RGA_MUTEX_H
|
||||
|
||||
@@ -26,12 +27,13 @@
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
// Enable thread safety attributes only with clang.
|
||||
// The attributes can be safely erased when compiling with other compilers.
|
||||
#if defined(__clang__) && (!defined(SWIG))
|
||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
|
||||
#else
|
||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
|
||||
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
|
||||
#endif
|
||||
|
||||
#define CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
|
||||
@@ -42,47 +44,36 @@
|
||||
|
||||
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
|
||||
|
||||
#define ACQUIRED_BEFORE(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
|
||||
#define ACQUIRED_BEFORE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRED_AFTER(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
|
||||
#define ACQUIRED_AFTER(...) THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
|
||||
|
||||
#define REQUIRES(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
|
||||
#define REQUIRES(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
|
||||
|
||||
#define REQUIRES_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
|
||||
#define REQUIRES_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRE(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
|
||||
#define ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
|
||||
|
||||
#define ACQUIRE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
|
||||
#define ACQUIRE_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define RELEASE(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
|
||||
#define RELEASE(...) THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
|
||||
|
||||
#define RELEASE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
|
||||
#define RELEASE_SHARED(...) THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define TRY_ACQUIRE(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
|
||||
#define TRY_ACQUIRE(...) THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
|
||||
|
||||
#define TRY_ACQUIRE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
|
||||
#define TRY_ACQUIRE_SHARED(...) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
|
||||
|
||||
#define EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
|
||||
|
||||
#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
|
||||
|
||||
#define ASSERT_SHARED_CAPABILITY(x) \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
|
||||
#define ASSERT_SHARED_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
|
||||
|
||||
#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
|
||||
|
||||
#define NO_THREAD_SAFETY_ANALYSIS \
|
||||
THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
|
||||
#define NO_THREAD_SAFETY_ANALYSIS THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
|
||||
|
||||
class Condition;
|
||||
|
||||
@@ -97,81 +88,96 @@ class Condition;
|
||||
* recursive, i.e. the same thread can't lock it multiple times.
|
||||
*/
|
||||
class CAPABILITY("mutex") Mutex {
|
||||
public:
|
||||
enum { PRIVATE = 0, SHARED = 1 };
|
||||
|
||||
Mutex();
|
||||
explicit Mutex(const char *name);
|
||||
explicit Mutex(int type, const char *name = nullptr);
|
||||
~Mutex();
|
||||
|
||||
// lock or unlock the mutex
|
||||
int32_t lock() ACQUIRE();
|
||||
void unlock() RELEASE();
|
||||
|
||||
// lock if possible; returns 0 on success, error otherwise
|
||||
int32_t tryLock() TRY_ACQUIRE(0);
|
||||
|
||||
int32_t timedLock(int64_t timeoutNs) TRY_ACQUIRE(0);
|
||||
|
||||
// Manages the mutex automatically. It'll be locked when Autolock is
|
||||
// constructed and released when Autolock goes out of scope.
|
||||
class SCOPED_CAPABILITY Autolock {
|
||||
public:
|
||||
inline explicit Autolock(Mutex &mutex) ACQUIRE(mutex) : mLock(mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline explicit Autolock(Mutex *mutex) ACQUIRE(mutex) : mLock(*mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline ~Autolock() RELEASE() { mLock.unlock(); }
|
||||
enum {
|
||||
PRIVATE = 0,
|
||||
SHARED = 1
|
||||
};
|
||||
|
||||
Mutex();
|
||||
explicit Mutex(const char* name);
|
||||
explicit Mutex(int type, const char* name = nullptr);
|
||||
~Mutex();
|
||||
|
||||
// lock or unlock the mutex
|
||||
int32_t lock() ACQUIRE();
|
||||
void unlock() RELEASE();
|
||||
|
||||
// lock if possible; returns 0 on success, error otherwise
|
||||
int32_t tryLock() TRY_ACQUIRE(0);
|
||||
|
||||
int32_t timedLock(int64_t timeoutNs) TRY_ACQUIRE(0);
|
||||
|
||||
// Manages the mutex automatically. It'll be locked when Autolock is
|
||||
// constructed and released when Autolock goes out of scope.
|
||||
class SCOPED_CAPABILITY Autolock {
|
||||
public:
|
||||
inline explicit Autolock(Mutex& mutex) ACQUIRE(mutex) : mLock(mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline explicit Autolock(Mutex* mutex) ACQUIRE(mutex) : mLock(*mutex) {
|
||||
mLock.lock();
|
||||
}
|
||||
inline ~Autolock() RELEASE() {
|
||||
mLock.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
Mutex& mLock;
|
||||
// Cannot be copied or moved - declarations only
|
||||
Autolock(const Autolock&);
|
||||
Autolock& operator=(const Autolock&);
|
||||
};
|
||||
|
||||
private:
|
||||
Mutex &mLock;
|
||||
// Cannot be copied or moved - declarations only
|
||||
Autolock(const Autolock &);
|
||||
Autolock &operator=(const Autolock &);
|
||||
};
|
||||
friend class Condition;
|
||||
|
||||
private:
|
||||
friend class Condition;
|
||||
// A mutex cannot be copied
|
||||
Mutex(const Mutex&);
|
||||
Mutex& operator=(const Mutex&);
|
||||
|
||||
// A mutex cannot be copied
|
||||
Mutex(const Mutex &);
|
||||
Mutex &operator=(const Mutex &);
|
||||
|
||||
pthread_mutex_t mMutex;
|
||||
pthread_mutex_t mMutex;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline Mutex::Mutex() { pthread_mutex_init(&mMutex, nullptr); }
|
||||
inline Mutex::Mutex(__attribute__((unused)) const char *name) {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
inline Mutex::Mutex(int type, __attribute__((unused)) const char *name) {
|
||||
if (type == SHARED) {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||
pthread_mutex_init(&mMutex, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
} else {
|
||||
inline Mutex::Mutex() {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
}
|
||||
inline Mutex::~Mutex() { pthread_mutex_destroy(&mMutex); }
|
||||
inline int32_t Mutex::lock() { return -pthread_mutex_lock(&mMutex); }
|
||||
inline void Mutex::unlock() { pthread_mutex_unlock(&mMutex); }
|
||||
inline int32_t Mutex::tryLock() { return -pthread_mutex_trylock(&mMutex); }
|
||||
inline Mutex::Mutex(__attribute__((unused)) const char* name) {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) {
|
||||
if (type == SHARED) {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
|
||||
pthread_mutex_init(&mMutex, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
} else {
|
||||
pthread_mutex_init(&mMutex, nullptr);
|
||||
}
|
||||
}
|
||||
inline Mutex::~Mutex() {
|
||||
pthread_mutex_destroy(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::lock() {
|
||||
return -pthread_mutex_lock(&mMutex);
|
||||
}
|
||||
inline void Mutex::unlock() {
|
||||
pthread_mutex_unlock(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::tryLock() {
|
||||
return -pthread_mutex_trylock(&mMutex);
|
||||
}
|
||||
inline int32_t Mutex::timedLock(int64_t timeoutNs) {
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
timeoutNs += now.tv_sec * 1000000000 + now.tv_nsec;
|
||||
const struct timespec ts = {
|
||||
/* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),
|
||||
/* .tv_nsec = */ static_cast<long>(timeoutNs % 1000000000),
|
||||
};
|
||||
return -pthread_mutex_timedlock(&mMutex, &ts);
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
timeoutNs += now.tv_sec*1000000000 + now.tv_nsec;
|
||||
const struct timespec ts = {
|
||||
/* .tv_sec = */ static_cast<time_t>(timeoutNs / 1000000000),
|
||||
/* .tv_nsec = */ static_cast<long>(timeoutNs % 1000000000),
|
||||
};
|
||||
return -pthread_mutex_timedlock(&mMutex, &ts);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _LIBS_RGA_SINGLETON_H
|
||||
#define _LIBS_RGA_SINGLETON_H
|
||||
|
||||
@@ -27,42 +27,44 @@
|
||||
#pragma clang diagnostic ignored "-Wundefined-var-template"
|
||||
#endif
|
||||
|
||||
template <typename TYPE> class Singleton {
|
||||
public:
|
||||
static TYPE &getInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
TYPE *instance = sInstance;
|
||||
if (instance == nullptr) {
|
||||
instance = new TYPE();
|
||||
sInstance = instance;
|
||||
template <typename TYPE>
|
||||
class Singleton {
|
||||
public:
|
||||
static TYPE& getInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
TYPE* instance = sInstance;
|
||||
if (instance == nullptr) {
|
||||
instance = new TYPE();
|
||||
sInstance = instance;
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
|
||||
static bool hasInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
return sInstance != nullptr;
|
||||
}
|
||||
static bool hasInstance() {
|
||||
Mutex::Autolock _l(sLock);
|
||||
return sInstance != nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
~Singleton() {}
|
||||
Singleton() {}
|
||||
protected:
|
||||
~Singleton() { }
|
||||
Singleton() { }
|
||||
|
||||
private:
|
||||
Singleton(const Singleton &);
|
||||
Singleton &operator=(const Singleton &);
|
||||
static Mutex sLock;
|
||||
static TYPE *sInstance;
|
||||
private:
|
||||
Singleton(const Singleton&);
|
||||
Singleton& operator = (const Singleton&);
|
||||
static Mutex sLock;
|
||||
static TYPE* sInstance;
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#define RGA_SINGLETON_STATIC_INSTANCE(TYPE) \
|
||||
template <>::Mutex(::Singleton<TYPE>::sLock)(::Mutex::PRIVATE); \
|
||||
template <> TYPE * ::Singleton<TYPE>::sInstance(nullptr); /* NOLINT */ \
|
||||
template class ::Singleton<TYPE>;
|
||||
#define RGA_SINGLETON_STATIC_INSTANCE(TYPE) \
|
||||
template<> ::Mutex \
|
||||
(::Singleton< TYPE >::sLock)(::Mutex::PRIVATE); \
|
||||
template<> TYPE* ::Singleton< TYPE >::sInstance(nullptr); /* NOLINT */ \
|
||||
template class ::Singleton< TYPE >;
|
||||
|
||||
#endif // ANDROID
|
||||
#endif //ANDROID
|
||||
#endif //_LIBS_RGA_SINGLETON_H
|
||||
|
||||
@@ -28,3 +28,4 @@ const char *translate_format_str(int format);
|
||||
int get_buf_from_file_FBC(void *buf, int f, int sw, int sh, int index);
|
||||
int output_buf_data_to_file_FBC(void *buf, int f, int sw, int sh, int index);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
#ifndef _rockchip_rga_h_
|
||||
#define _rockchip_rga_h_
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "drmrga.h"
|
||||
#include "GrallocOps.h"
|
||||
#include "RgaUtils.h"
|
||||
#include "drmrga.h"
|
||||
#include "rga.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -41,61 +41,70 @@
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <hardware/hardware.h>
|
||||
#include <utils/Singleton.h>
|
||||
#include <utils/Thread.h>
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
namespace android {
|
||||
#endif
|
||||
|
||||
class RockchipRga : public Singleton<RockchipRga> {
|
||||
public:
|
||||
static inline RockchipRga &get() { return getInstance(); }
|
||||
class RockchipRga :public Singleton<RockchipRga> {
|
||||
public:
|
||||
|
||||
int RkRgaInit();
|
||||
void RkRgaDeInit();
|
||||
void RkRgaGetContext(void **ctx);
|
||||
static inline RockchipRga& get() {
|
||||
return getInstance();
|
||||
}
|
||||
|
||||
int RkRgaInit();
|
||||
void RkRgaDeInit();
|
||||
void RkRgaGetContext(void **ctx);
|
||||
#ifndef ANDROID /* LINUX */
|
||||
int RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info, int width,
|
||||
int height, int bpp, int flags);
|
||||
int RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
|
||||
int RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp,
|
||||
int flags);
|
||||
int RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetMmap(bo_t *bo_info);
|
||||
int RkRgaUnmap(bo_t *bo_info);
|
||||
int RkRgaFree(bo_t *bo_info);
|
||||
int RkRgaGetBufferFd(bo_t *bo_info, int *fd);
|
||||
int RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
|
||||
int width, int height, int bpp, int flags);
|
||||
int RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
|
||||
int RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
|
||||
int RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
|
||||
int RkRgaGetMmap(bo_t *bo_info);
|
||||
int RkRgaUnmap(bo_t *bo_info);
|
||||
int RkRgaFree(bo_t *bo_info);
|
||||
int RkRgaGetBufferFd(bo_t *bo_info, int *fd);
|
||||
#else
|
||||
int RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
|
||||
int RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
|
||||
int RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
|
||||
#endif
|
||||
int RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
|
||||
int RkRgaCollorFill(rga_info *dst);
|
||||
int RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
|
||||
int RkRgaFlush();
|
||||
int RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
|
||||
int RkRgaCollorFill(rga_info *dst);
|
||||
int RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
|
||||
int RkRgaFlush();
|
||||
|
||||
void RkRgaSetLogOnceFlag(int log) { mLogOnce = log; }
|
||||
void RkRgaSetAlwaysLogFlag(bool log) { mLogAlways = log; }
|
||||
void RkRgaLogOutRgaReq(struct rga_req rgaReg);
|
||||
int RkRgaLogOutUserPara(rga_info *rgaInfo);
|
||||
inline bool RkRgaIsReady() { return mSupportRga; }
|
||||
|
||||
RockchipRga();
|
||||
~RockchipRga();
|
||||
void RkRgaSetLogOnceFlag(int log) {
|
||||
mLogOnce = log;
|
||||
}
|
||||
void RkRgaSetAlwaysLogFlag(bool log) {
|
||||
mLogAlways = log;
|
||||
}
|
||||
void RkRgaLogOutRgaReq(struct rga_req rgaReg);
|
||||
int RkRgaLogOutUserPara(rga_info *rgaInfo);
|
||||
inline bool RkRgaIsReady() {
|
||||
return mSupportRga;
|
||||
}
|
||||
|
||||
private:
|
||||
bool mSupportRga;
|
||||
int mLogOnce;
|
||||
int mLogAlways;
|
||||
void *mContext;
|
||||
RockchipRga();
|
||||
~RockchipRga();
|
||||
private:
|
||||
bool mSupportRga;
|
||||
int mLogOnce;
|
||||
int mLogAlways;
|
||||
void * mContext;
|
||||
|
||||
friend class Singleton<RockchipRga>;
|
||||
};
|
||||
friend class Singleton<RockchipRga>;
|
||||
};
|
||||
|
||||
#ifdef ANDROID
|
||||
}; // namespace android
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#ifndef _rk_drm_rga_
|
||||
#define _rk_drm_rga_
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include "rga.h"
|
||||
@@ -28,83 +28,83 @@
|
||||
#ifdef ANDROID
|
||||
#define DRMRGA_HARDWARE_MODULE_ID "librga"
|
||||
|
||||
#include <cutils/native_handle.h>
|
||||
#include <hardware/gralloc.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <system/graphics.h>
|
||||
#include <cutils/native_handle.h>
|
||||
|
||||
#ifdef ANDROID_12
|
||||
#if defined(ANDROID_12) || defined(USE_HARDWARE_ROCKCHIP)
|
||||
#include <hardware/hardware_rockchip.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define RGA_BLIT_SYNC 0x5017
|
||||
#define RGA_BLIT_ASYNC 0x5018
|
||||
#define RGA_BLIT_SYNC 0x5017
|
||||
#define RGA_BLIT_ASYNC 0x5018
|
||||
|
||||
#ifndef ANDROID /* LINUX */
|
||||
/* flip source image horizontally (around the vertical axis) */
|
||||
#define HAL_TRANSFORM_FLIP_H 0x01
|
||||
#define HAL_TRANSFORM_FLIP_H 0x01
|
||||
/* flip source image vertically (around the horizontal axis)*/
|
||||
#define HAL_TRANSFORM_FLIP_V 0x02
|
||||
#define HAL_TRANSFORM_FLIP_V 0x02
|
||||
/* rotate source image 90 degrees clockwise */
|
||||
#define HAL_TRANSFORM_ROT_90 0x04
|
||||
#define HAL_TRANSFORM_ROT_90 0x04
|
||||
/* rotate source image 180 degrees */
|
||||
#define HAL_TRANSFORM_ROT_180 0x03
|
||||
#define HAL_TRANSFORM_ROT_180 0x03
|
||||
/* rotate source image 270 degrees clockwise */
|
||||
#define HAL_TRANSFORM_ROT_270 0x07
|
||||
#define HAL_TRANSFORM_ROT_270 0x07
|
||||
#endif
|
||||
|
||||
#define HAL_TRANSFORM_FLIP_H_V 0x08
|
||||
#define HAL_TRANSFORM_FLIP_H_V 0x08
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* for compatibility */
|
||||
#define DRM_RGA_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1
|
||||
#define DRM_RGA_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1
|
||||
#define DRM_RGA_API_VERSION HWC_DEVICE_API_VERSION
|
||||
#define DRM_RGA_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1
|
||||
#define DRM_RGA_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1
|
||||
#define DRM_RGA_API_VERSION HWC_DEVICE_API_VERSION
|
||||
|
||||
#define DRM_RGA_TRANSFORM_ROT_MASK 0x0000000F
|
||||
#define DRM_RGA_TRANSFORM_ROT_0 0x00000000
|
||||
#define DRM_RGA_TRANSFORM_ROT_90 HAL_TRANSFORM_ROT_90
|
||||
#define DRM_RGA_TRANSFORM_ROT_180 HAL_TRANSFORM_ROT_180
|
||||
#define DRM_RGA_TRANSFORM_ROT_270 HAL_TRANSFORM_ROT_270
|
||||
#define DRM_RGA_TRANSFORM_ROT_MASK 0x0000000F
|
||||
#define DRM_RGA_TRANSFORM_ROT_0 0x00000000
|
||||
#define DRM_RGA_TRANSFORM_ROT_90 HAL_TRANSFORM_ROT_90
|
||||
#define DRM_RGA_TRANSFORM_ROT_180 HAL_TRANSFORM_ROT_180
|
||||
#define DRM_RGA_TRANSFORM_ROT_270 HAL_TRANSFORM_ROT_270
|
||||
|
||||
#define DRM_RGA_TRANSFORM_FLIP_MASK 0x00000003
|
||||
#define DRM_RGA_TRANSFORM_FLIP_H HAL_TRANSFORM_FLIP_H
|
||||
#define DRM_RGA_TRANSFORM_FLIP_V HAL_TRANSFORM_FLIP_V
|
||||
#define DRM_RGA_TRANSFORM_FLIP_MASK 0x00000003
|
||||
#define DRM_RGA_TRANSFORM_FLIP_H HAL_TRANSFORM_FLIP_H
|
||||
#define DRM_RGA_TRANSFORM_FLIP_V HAL_TRANSFORM_FLIP_V
|
||||
|
||||
enum {
|
||||
AWIDTH = 0,
|
||||
AHEIGHT,
|
||||
ASTRIDE,
|
||||
AFORMAT,
|
||||
ASIZE,
|
||||
ATYPE,
|
||||
AWIDTH = 0,
|
||||
AHEIGHT,
|
||||
ASTRIDE,
|
||||
AFORMAT,
|
||||
ASIZE,
|
||||
ATYPE,
|
||||
};
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef ANDROID
|
||||
#ifndef ANDROID /* LINUX */
|
||||
/* memory type definitions. */
|
||||
enum drm_rockchip_gem_mem_type {
|
||||
/* Physically Continuous memory and used as default. */
|
||||
ROCKCHIP_BO_CONTIG = 1 << 0,
|
||||
/* cachable mapping. */
|
||||
ROCKCHIP_BO_CACHABLE = 1 << 1,
|
||||
/* write-combine mapping. */
|
||||
ROCKCHIP_BO_WC = 1 << 2,
|
||||
ROCKCHIP_BO_SECURE = 1 << 3,
|
||||
ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE |
|
||||
ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE
|
||||
/* Physically Continuous memory and used as default. */
|
||||
ROCKCHIP_BO_CONTIG = 1 << 0,
|
||||
/* cachable mapping. */
|
||||
ROCKCHIP_BO_CACHABLE = 1 << 1,
|
||||
/* write-combine mapping. */
|
||||
ROCKCHIP_BO_WC = 1 << 2,
|
||||
ROCKCHIP_BO_SECURE = 1 << 3,
|
||||
ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE |
|
||||
ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE
|
||||
};
|
||||
|
||||
typedef struct bo {
|
||||
int fd;
|
||||
void *ptr;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
size_t pitch;
|
||||
unsigned handle;
|
||||
int fd;
|
||||
void *ptr;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
size_t pitch;
|
||||
unsigned handle;
|
||||
} bo_t;
|
||||
#endif
|
||||
|
||||
@@ -112,142 +112,142 @@ typedef struct bo {
|
||||
@value size: user not need care about.For avoid read/write out of memory
|
||||
*/
|
||||
typedef struct rga_rect {
|
||||
int xoffset;
|
||||
int yoffset;
|
||||
int width;
|
||||
int height;
|
||||
int wstride;
|
||||
int hstride;
|
||||
int format;
|
||||
int size;
|
||||
int xoffset;
|
||||
int yoffset;
|
||||
int width;
|
||||
int height;
|
||||
int wstride;
|
||||
int hstride;
|
||||
int format;
|
||||
int size;
|
||||
} rga_rect_t;
|
||||
|
||||
typedef struct rga_nn {
|
||||
int nn_flag;
|
||||
int scale_r;
|
||||
int scale_g;
|
||||
int scale_b;
|
||||
int offset_r;
|
||||
int offset_g;
|
||||
int offset_b;
|
||||
int nn_flag;
|
||||
int scale_r;
|
||||
int scale_g;
|
||||
int scale_b;
|
||||
int offset_r;
|
||||
int offset_g;
|
||||
int offset_b;
|
||||
} rga_nn_t;
|
||||
|
||||
typedef struct rga_dither {
|
||||
int enable;
|
||||
int mode;
|
||||
int lut0_l;
|
||||
int lut0_h;
|
||||
int lut1_l;
|
||||
int lut1_h;
|
||||
int enable;
|
||||
int mode;
|
||||
int lut0_l;
|
||||
int lut0_h;
|
||||
int lut1_l;
|
||||
int lut1_h;
|
||||
} rga_dither_t;
|
||||
|
||||
struct rga_mosaic_info {
|
||||
uint8_t enable;
|
||||
uint8_t mode;
|
||||
uint8_t enable;
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
struct rga_pre_intr_info {
|
||||
uint8_t enable;
|
||||
uint8_t enable;
|
||||
|
||||
uint8_t read_intr_en;
|
||||
uint8_t write_intr_en;
|
||||
uint8_t read_hold_en;
|
||||
uint32_t read_threshold;
|
||||
uint32_t write_start;
|
||||
uint32_t write_step;
|
||||
uint8_t read_intr_en;
|
||||
uint8_t write_intr_en;
|
||||
uint8_t read_hold_en;
|
||||
uint32_t read_threshold;
|
||||
uint32_t write_start;
|
||||
uint32_t write_step;
|
||||
};
|
||||
|
||||
/* MAX(min, (max - channel_value)) */
|
||||
struct rga_osd_invert_factor {
|
||||
uint8_t alpha_max;
|
||||
uint8_t alpha_min;
|
||||
uint8_t yg_max;
|
||||
uint8_t yg_min;
|
||||
uint8_t crb_max;
|
||||
uint8_t crb_min;
|
||||
uint8_t alpha_max;
|
||||
uint8_t alpha_min;
|
||||
uint8_t yg_max;
|
||||
uint8_t yg_min;
|
||||
uint8_t crb_max;
|
||||
uint8_t crb_min;
|
||||
};
|
||||
|
||||
struct rga_color {
|
||||
union {
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t alpha;
|
||||
union {
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t alpha;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
};
|
||||
|
||||
struct rga_osd_bpp2 {
|
||||
uint8_t ac_swap; // ac swap flag
|
||||
// 0: CA
|
||||
// 1: AC
|
||||
uint8_t endian_swap; // rgba2bpp endian swap
|
||||
// 0: Big endian
|
||||
// 1: Little endian
|
||||
struct rga_color color0;
|
||||
struct rga_color color1;
|
||||
uint8_t ac_swap; // ac swap flag
|
||||
// 0: CA
|
||||
// 1: AC
|
||||
uint8_t endian_swap; // rgba2bpp endian swap
|
||||
// 0: Big endian
|
||||
// 1: Little endian
|
||||
struct rga_color color0;
|
||||
struct rga_color color1;
|
||||
};
|
||||
|
||||
struct rga_osd_mode_ctrl {
|
||||
uint8_t mode; // OSD cal mode:
|
||||
// 0b'1: statistics mode
|
||||
// 1b'1: auto inversion overlap mode
|
||||
uint8_t direction_mode; // horizontal or vertical
|
||||
// 0: horizontal
|
||||
// 1: vertical
|
||||
uint8_t width_mode; // using @fix_width or LUT width
|
||||
// 0: fix width
|
||||
// 1: LUT width
|
||||
uint16_t block_fix_width; // OSD block fixed width
|
||||
// real width = (fix_width + 1) * 2
|
||||
uint8_t block_num; // OSD block num
|
||||
uint16_t flags_index; // auto invert flags index
|
||||
uint8_t mode; // OSD cal mode:
|
||||
// 0b'1: statistics mode
|
||||
// 1b'1: auto inversion overlap mode
|
||||
uint8_t direction_mode; // horizontal or vertical
|
||||
// 0: horizontal
|
||||
// 1: vertical
|
||||
uint8_t width_mode; // using @fix_width or LUT width
|
||||
// 0: fix width
|
||||
// 1: LUT width
|
||||
uint16_t block_fix_width; // OSD block fixed width
|
||||
// real width = (fix_width + 1) * 2
|
||||
uint8_t block_num; // OSD block num
|
||||
uint16_t flags_index; // auto invert flags index
|
||||
|
||||
/* invertion config */
|
||||
uint8_t color_mode; // selete color
|
||||
// 0: src1 color
|
||||
// 1: config data color
|
||||
uint8_t invert_flags_mode; // invert flag selete
|
||||
// 0: use RAM flag
|
||||
// 1: usr last result
|
||||
uint8_t default_color_sel; // default color mode
|
||||
// 0: default is bright
|
||||
// 1: default is dark
|
||||
uint8_t invert_enable; // invert channel enable
|
||||
// 1 << 0: aplha enable
|
||||
// 1 << 1: Y/G disable
|
||||
// 1 << 2: C/RB disable
|
||||
uint8_t invert_mode; // invert cal mode
|
||||
// 0: normal(max-data)
|
||||
// 1: swap
|
||||
uint8_t invert_thresh; // if luma > thresh, osd_flag to be 1
|
||||
uint8_t unfix_index; // OSD width config index
|
||||
/* invertion config */
|
||||
uint8_t color_mode; // selete color
|
||||
// 0: src1 color
|
||||
// 1: config data color
|
||||
uint8_t invert_flags_mode; // invert flag selete
|
||||
// 0: use RAM flag
|
||||
// 1: usr last result
|
||||
uint8_t default_color_sel; // default color mode
|
||||
// 0: default is bright
|
||||
// 1: default is dark
|
||||
uint8_t invert_enable; // invert channel enable
|
||||
// 1 << 0: aplha enable
|
||||
// 1 << 1: Y/G disable
|
||||
// 1 << 2: C/RB disable
|
||||
uint8_t invert_mode; // invert cal mode
|
||||
// 0: normal(max-data)
|
||||
// 1: swap
|
||||
uint8_t invert_thresh; // if luma > thresh, osd_flag to be 1
|
||||
uint8_t unfix_index; // OSD width config index
|
||||
};
|
||||
|
||||
struct rga_osd_info {
|
||||
uint8_t enable;
|
||||
uint8_t enable;
|
||||
|
||||
struct rga_osd_mode_ctrl mode_ctrl;
|
||||
struct rga_osd_invert_factor cal_factor;
|
||||
struct rga_osd_bpp2 bpp2_info;
|
||||
struct rga_osd_mode_ctrl mode_ctrl;
|
||||
struct rga_osd_invert_factor cal_factor;
|
||||
struct rga_osd_bpp2 bpp2_info;
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t last_flags1;
|
||||
uint32_t last_flags0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t last_flags1;
|
||||
uint32_t last_flags0;
|
||||
};
|
||||
uint64_t last_flags;
|
||||
};
|
||||
uint64_t last_flags;
|
||||
};
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t cur_flags1;
|
||||
uint32_t cur_flags0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t cur_flags1;
|
||||
uint32_t cur_flags0;
|
||||
};
|
||||
uint64_t cur_flags;
|
||||
};
|
||||
uint64_t cur_flags;
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -257,65 +257,70 @@ struct rga_osd_info {
|
||||
@value hnd: use buffer_handle_t
|
||||
*/
|
||||
typedef struct rga_info {
|
||||
int fd;
|
||||
void *virAddr;
|
||||
void *phyAddr;
|
||||
int fd;
|
||||
void *virAddr;
|
||||
void *phyAddr;
|
||||
#ifndef ANDROID /* LINUX */
|
||||
unsigned hnd;
|
||||
unsigned hnd;
|
||||
#else /* Android */
|
||||
buffer_handle_t hnd;
|
||||
buffer_handle_t hnd;
|
||||
#endif
|
||||
int format;
|
||||
rga_rect_t rect;
|
||||
unsigned int blend;
|
||||
int bufferSize;
|
||||
int rotation;
|
||||
int color;
|
||||
int testLog;
|
||||
int mmuFlag;
|
||||
int colorkey_en;
|
||||
int colorkey_mode;
|
||||
int colorkey_max;
|
||||
int colorkey_min;
|
||||
int scale_mode;
|
||||
int color_space_mode;
|
||||
int sync_mode;
|
||||
rga_nn_t nn;
|
||||
rga_dither_t dither;
|
||||
int rop_code;
|
||||
int rd_mode;
|
||||
unsigned short is_10b_compact;
|
||||
unsigned short is_10b_endian;
|
||||
int format;
|
||||
rga_rect_t rect;
|
||||
unsigned int blend;
|
||||
int bufferSize;
|
||||
int rotation;
|
||||
int color;
|
||||
int testLog;
|
||||
int mmuFlag;
|
||||
int colorkey_en;
|
||||
int colorkey_mode;
|
||||
int colorkey_max;
|
||||
int colorkey_min;
|
||||
int scale_mode;
|
||||
int color_space_mode;
|
||||
int sync_mode;
|
||||
rga_nn_t nn;
|
||||
rga_dither_t dither;
|
||||
int rop_code;
|
||||
int rd_mode;
|
||||
unsigned short is_10b_compact;
|
||||
unsigned short is_10b_endian;
|
||||
|
||||
int in_fence_fd;
|
||||
int out_fence_fd;
|
||||
int in_fence_fd;
|
||||
int out_fence_fd;
|
||||
|
||||
int core;
|
||||
int priority;
|
||||
int core;
|
||||
int priority;
|
||||
|
||||
unsigned short enable;
|
||||
unsigned short enable;
|
||||
|
||||
int handle;
|
||||
int handle;
|
||||
|
||||
struct rga_mosaic_info mosaic_info;
|
||||
struct rga_mosaic_info mosaic_info;
|
||||
|
||||
struct rga_osd_info osd_info;
|
||||
struct rga_osd_info osd_info;
|
||||
|
||||
struct rga_pre_intr_info pre_intr;
|
||||
struct rga_pre_intr_info pre_intr;
|
||||
|
||||
int mpi_mode;
|
||||
int mpi_mode;
|
||||
|
||||
union {
|
||||
int ctx_id;
|
||||
int job_handle;
|
||||
};
|
||||
union {
|
||||
int ctx_id;
|
||||
int job_handle;
|
||||
};
|
||||
|
||||
char reserve[402];
|
||||
uint16_t rgba5551_flags;
|
||||
uint8_t rgba5551_alpha0;
|
||||
uint8_t rgba5551_alpha1;
|
||||
|
||||
char reserve[398];
|
||||
} rga_info_t;
|
||||
|
||||
|
||||
typedef struct drm_rga {
|
||||
rga_rect_t src;
|
||||
rga_rect_t dst;
|
||||
rga_rect_t src;
|
||||
rga_rect_t dst;
|
||||
} drm_rga_t;
|
||||
|
||||
/*
|
||||
@@ -326,30 +331,30 @@ typedef struct drm_rga {
|
||||
rga_set_rect(rects.src,0,0,1920,1080,1920,NV12);
|
||||
mean to set the src rect to the value.
|
||||
*/
|
||||
static inline int rga_set_rect(rga_rect_t *rect, int x, int y, int w, int h,
|
||||
int sw, int sh, int f) {
|
||||
if (!rect)
|
||||
return -EINVAL;
|
||||
static inline int rga_set_rect(rga_rect_t *rect,
|
||||
int x, int y, int w, int h, int sw, int sh, int f) {
|
||||
if (!rect)
|
||||
return -EINVAL;
|
||||
|
||||
rect->xoffset = x;
|
||||
rect->yoffset = y;
|
||||
rect->width = w;
|
||||
rect->height = h;
|
||||
rect->wstride = sw;
|
||||
rect->hstride = sh;
|
||||
rect->format = f;
|
||||
rect->xoffset = x;
|
||||
rect->yoffset = y;
|
||||
rect->width = w;
|
||||
rect->height = h;
|
||||
rect->wstride = sw;
|
||||
rect->hstride = sh;
|
||||
rect->format = f;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef ANDROID /* LINUX */
|
||||
static inline void rga_set_rotation(rga_info_t *info, int angle) {
|
||||
if (angle == 90)
|
||||
info->rotation = HAL_TRANSFORM_ROT_90;
|
||||
else if (angle == 180)
|
||||
info->rotation = HAL_TRANSFORM_ROT_180;
|
||||
else if (angle == 270)
|
||||
info->rotation = HAL_TRANSFORM_ROT_270;
|
||||
if (angle == 90)
|
||||
info->rotation = HAL_TRANSFORM_ROT_90;
|
||||
else if (angle == 180)
|
||||
info->rotation = HAL_TRANSFORM_ROT_180;
|
||||
else if (angle == 270)
|
||||
info->rotation = HAL_TRANSFORM_ROT_270;
|
||||
}
|
||||
#endif
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
#ifndef _im2d_h_
|
||||
#define _im2d_h_
|
||||
|
||||
#include "im2d_type.h"
|
||||
#include "im2d_version.h"
|
||||
#include "im2d_type.h"
|
||||
|
||||
#include "im2d_buffer.h"
|
||||
#include "im2d_common.h"
|
||||
#include "im2d_mpi.h"
|
||||
#include "im2d_buffer.h"
|
||||
#include "im2d_single.h"
|
||||
#include "im2d_task.h"
|
||||
#include "im2d_mpi.h"
|
||||
|
||||
#endif /* #ifndef _im2d_h_ */
|
||||
|
||||
@@ -51,12 +51,9 @@ IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, int size);
|
||||
* @return rga_buffer_handle_t
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
IM_API rga_buffer_handle_t importbuffer_fd(int fd, int width, int height,
|
||||
int format);
|
||||
IM_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, int width,
|
||||
int height, int format);
|
||||
IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, int width,
|
||||
int height, int format);
|
||||
IM_API rga_buffer_handle_t importbuffer_fd(int fd, int width, int height, int format);
|
||||
IM_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, int width, int height, int format);
|
||||
IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, int width, int height, int format);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -69,12 +66,9 @@ IM_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, int width,
|
||||
*
|
||||
* @return rga_buffer_handle_t
|
||||
*/
|
||||
IM_EXPORT_API rga_buffer_handle_t importbuffer_fd(int fd,
|
||||
im_handle_param_t *param);
|
||||
IM_EXPORT_API rga_buffer_handle_t
|
||||
importbuffer_virtualaddr(void *va, im_handle_param_t *param);
|
||||
IM_EXPORT_API rga_buffer_handle_t
|
||||
importbuffer_physicaladdr(uint64_t pa, im_handle_param_t *param);
|
||||
IM_EXPORT_API rga_buffer_handle_t importbuffer_fd(int fd, im_handle_param_t *param);
|
||||
IM_EXPORT_API rga_buffer_handle_t importbuffer_virtualaddr(void *va, im_handle_param_t *param);
|
||||
IM_EXPORT_API rga_buffer_handle_t importbuffer_physicaladdr(uint64_t pa, im_handle_param_t *param);
|
||||
|
||||
/**
|
||||
* Import external buffers into RGA driver.
|
||||
@@ -104,97 +98,86 @@ IM_EXPORT_API IM_STATUS releasebuffer_handle(rga_buffer_handle_t handle);
|
||||
*
|
||||
* @return rga_buffer_t
|
||||
*/
|
||||
#define wrapbuffer_handle(handle, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t im2d_api_buffer; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args) / sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_buffer = \
|
||||
wrapbuffer_handle_t(handle, width, height, width, height, format); \
|
||||
} else if (__argc == 2) { \
|
||||
im2d_api_buffer = wrapbuffer_handle_t(handle, width, height, __args[0], \
|
||||
__args[1], format); \
|
||||
} else { \
|
||||
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
im2d_api_buffer; \
|
||||
})
|
||||
#define wrapbuffer_handle(handle, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t im2d_api_buffer; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args)/sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_buffer = wrapbuffer_handle_t(handle, width, height, width, height, format); \
|
||||
} else if (__argc == 2){ \
|
||||
im2d_api_buffer = wrapbuffer_handle_t(handle, width, height, __args[0], __args[1], format); \
|
||||
} else { \
|
||||
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
im2d_api_buffer; \
|
||||
})
|
||||
|
||||
#define wrapbuffer_virtualaddr(vir_addr, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t im2d_api_buffer; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args) / sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_buffer = wrapbuffer_virtualaddr_t(vir_addr, width, height, \
|
||||
width, height, format); \
|
||||
} else if (__argc == 2) { \
|
||||
im2d_api_buffer = wrapbuffer_virtualaddr_t( \
|
||||
vir_addr, width, height, __args[0], __args[1], format); \
|
||||
} else { \
|
||||
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
im2d_api_buffer; \
|
||||
})
|
||||
#define wrapbuffer_virtualaddr(vir_addr, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t im2d_api_buffer; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args)/sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_buffer = wrapbuffer_virtualaddr_t(vir_addr, width, height, width, height, format); \
|
||||
} else if (__argc == 2){ \
|
||||
im2d_api_buffer = wrapbuffer_virtualaddr_t(vir_addr, width, height, __args[0], __args[1], format); \
|
||||
} else { \
|
||||
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
im2d_api_buffer; \
|
||||
})
|
||||
|
||||
#define wrapbuffer_physicaladdr(phy_addr, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t im2d_api_buffer; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args) / sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_buffer = wrapbuffer_physicaladdr_t(phy_addr, width, height, \
|
||||
width, height, format); \
|
||||
} else if (__argc == 2) { \
|
||||
im2d_api_buffer = wrapbuffer_physicaladdr_t( \
|
||||
phy_addr, width, height, __args[0], __args[1], format); \
|
||||
} else { \
|
||||
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
im2d_api_buffer; \
|
||||
})
|
||||
#define wrapbuffer_physicaladdr(phy_addr, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t im2d_api_buffer; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args)/sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_buffer = wrapbuffer_physicaladdr_t(phy_addr, width, height, width, height, format); \
|
||||
} else if (__argc == 2){ \
|
||||
im2d_api_buffer = wrapbuffer_physicaladdr_t(phy_addr, width, height, __args[0], __args[1], format); \
|
||||
} else { \
|
||||
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
im2d_api_buffer; \
|
||||
})
|
||||
|
||||
#define wrapbuffer_fd(fd, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t im2d_api_buffer; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args) / sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_buffer = \
|
||||
wrapbuffer_fd_t(fd, width, height, width, height, format); \
|
||||
} else if (__argc == 2) { \
|
||||
im2d_api_buffer = \
|
||||
wrapbuffer_fd_t(fd, width, height, __args[0], __args[1], format); \
|
||||
} else { \
|
||||
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
im2d_api_buffer; \
|
||||
})
|
||||
#define wrapbuffer_fd(fd, width, height, format, ...) \
|
||||
({ \
|
||||
rga_buffer_t im2d_api_buffer; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args)/sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_buffer = wrapbuffer_fd_t(fd, width, height, width, height, format); \
|
||||
} else if (__argc == 2){ \
|
||||
im2d_api_buffer = wrapbuffer_fd_t(fd, width, height, __args[0], __args[1], format); \
|
||||
} else { \
|
||||
memset(&im2d_api_buffer, 0x0, sizeof(im2d_api_buffer)); \
|
||||
printf("invalid parameter\n"); \
|
||||
} \
|
||||
im2d_api_buffer; \
|
||||
})
|
||||
/* Symbols for define *_t functions */
|
||||
IM_C_API rga_buffer_t wrapbuffer_handle_t(rga_buffer_handle_t handle, int width,
|
||||
int height, int wstride, int hstride,
|
||||
int format);
|
||||
IM_C_API rga_buffer_t wrapbuffer_virtualaddr_t(void *vir_addr, int width,
|
||||
int height, int wstride,
|
||||
int hstride, int format);
|
||||
IM_C_API rga_buffer_t wrapbuffer_physicaladdr_t(void *phy_addr, int width,
|
||||
int height, int wstride,
|
||||
int hstride, int format);
|
||||
IM_C_API rga_buffer_t wrapbuffer_fd_t(int fd, int width, int height,
|
||||
int wstride, int hstride, int format);
|
||||
IM_C_API rga_buffer_t wrapbuffer_handle_t(rga_buffer_handle_t handle, int width, int height, int wstride, int hstride, int format);
|
||||
IM_C_API rga_buffer_t wrapbuffer_virtualaddr_t(void* vir_addr, int width, int height, int wstride, int hstride, int format);
|
||||
IM_C_API rga_buffer_t wrapbuffer_physicaladdr_t(void* phy_addr, int width, int height, int wstride, int hstride, int format);
|
||||
IM_C_API rga_buffer_t wrapbuffer_fd_t(int fd, int width, int height, int wstride, int hstride, int format);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#undef wrapbuffer_handle
|
||||
IM_API rga_buffer_t wrapbuffer_handle(rga_buffer_handle_t handle, int width,
|
||||
int height, int format);
|
||||
IM_API rga_buffer_t wrapbuffer_handle(rga_buffer_handle_t handle, int width,
|
||||
int height, int format, int wstride,
|
||||
int hstride);
|
||||
IM_API rga_buffer_t wrapbuffer_handle(rga_buffer_handle_t handle,
|
||||
int width, int height, int format);
|
||||
IM_API rga_buffer_t wrapbuffer_handle(rga_buffer_handle_t handle,
|
||||
int width, int height, int format,
|
||||
int wstride, int hstride);
|
||||
#endif
|
||||
|
||||
void imsetAlphaBit(rga_buffer_t *buf, uint8_t alpha0, uint8_t alpha1);
|
||||
void imsetOpacity(rga_buffer_t *buf, uint8_t alpha);
|
||||
void imsetColorSpace(rga_buffer_t *buf, IM_COLOR_SPACE_MODE mode);
|
||||
|
||||
#endif /* #ifndef _im2d_buffer_h_ */
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
*
|
||||
* @returns a string describing properties of RGA.
|
||||
*/
|
||||
IM_EXPORT_API const char *querystring(int name);
|
||||
IM_EXPORT_API const char* querystring(int name);
|
||||
|
||||
/**
|
||||
* String to output the error message
|
||||
@@ -45,35 +45,33 @@ IM_EXPORT_API const char *querystring(int name);
|
||||
*
|
||||
* @returns error message.
|
||||
*/
|
||||
#define imStrError(...) \
|
||||
({ \
|
||||
const char *im2d_api_err; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args) / sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_err = imStrError_t(IM_STATUS_INVALID_PARAM); \
|
||||
} else if (__argc == 1) { \
|
||||
im2d_api_err = imStrError_t((IM_STATUS)__args[0]); \
|
||||
} else { \
|
||||
im2d_api_err = ("Fatal error, imStrError() too many parameters\n"); \
|
||||
printf("Fatal error, imStrError() too many parameters\n"); \
|
||||
} \
|
||||
im2d_api_err; \
|
||||
})
|
||||
IM_C_API const char *imStrError_t(IM_STATUS status);
|
||||
#define imStrError(...) \
|
||||
({ \
|
||||
const char* im2d_api_err; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args)/sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
im2d_api_err = imStrError_t(IM_STATUS_INVALID_PARAM); \
|
||||
} else if (__argc == 1){ \
|
||||
im2d_api_err = imStrError_t((IM_STATUS)__args[0]); \
|
||||
} else { \
|
||||
im2d_api_err = ("Fatal error, imStrError() too many parameters\n"); \
|
||||
printf("Fatal error, imStrError() too many parameters\n"); \
|
||||
} \
|
||||
im2d_api_err; \
|
||||
})
|
||||
IM_C_API const char* imStrError_t(IM_STATUS status);
|
||||
|
||||
/**
|
||||
* check im2d api header file
|
||||
*
|
||||
* @param header_version
|
||||
* Default is RGA_CURRENT_API_HEADER_VERSION, no need to change if there
|
||||
* are no special cases.
|
||||
* Default is RGA_CURRENT_API_HEADER_VERSION, no need to change if there are no special cases.
|
||||
*
|
||||
* @returns no error or else negative error code.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
IM_API IM_STATUS
|
||||
imcheckHeader(im_api_version_t header_version = RGA_CURRENT_API_HEADER_VERSION);
|
||||
IM_API IM_STATUS imcheckHeader(im_api_version_t header_version = RGA_CURRENT_API_HEADER_VERSION);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -89,51 +87,45 @@ imcheckHeader(im_api_version_t header_version = RGA_CURRENT_API_HEADER_VERSION);
|
||||
*
|
||||
* @returns no error or else negative error code.
|
||||
*/
|
||||
#define imcheck(src, dst, src_rect, dst_rect, ...) \
|
||||
({ \
|
||||
IM_STATUS __ret = IM_STATUS_NOERROR; \
|
||||
rga_buffer_t __pat; \
|
||||
im_rect __pat_rect; \
|
||||
memset(&__pat, 0, sizeof(rga_buffer_t)); \
|
||||
memset(&__pat_rect, 0, sizeof(im_rect)); \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args) / sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
__ret = imcheck_t(src, dst, __pat, src_rect, dst_rect, __pat_rect, 0); \
|
||||
} else if (__argc == 1) { \
|
||||
__ret = imcheck_t(src, dst, __pat, src_rect, dst_rect, __pat_rect, \
|
||||
__args[0]); \
|
||||
} else { \
|
||||
__ret = IM_STATUS_FAILED; \
|
||||
printf("check failed\n"); \
|
||||
} \
|
||||
__ret; \
|
||||
})
|
||||
#define imcheck_composite(src, dst, pat, src_rect, dst_rect, pat_rect, ...) \
|
||||
({ \
|
||||
IM_STATUS __ret = IM_STATUS_NOERROR; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args) / sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
__ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, 0); \
|
||||
} else if (__argc == 1) { \
|
||||
__ret = \
|
||||
imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, __args[0]); \
|
||||
} else { \
|
||||
__ret = IM_STATUS_FAILED; \
|
||||
printf("check failed\n"); \
|
||||
} \
|
||||
__ret; \
|
||||
})
|
||||
IM_C_API IM_STATUS imcheck_t(const rga_buffer_t src, const rga_buffer_t dst,
|
||||
const rga_buffer_t pat, const im_rect src_rect,
|
||||
const im_rect dst_rect, const im_rect pat_rect,
|
||||
const int mode_usage);
|
||||
#define imcheck(src, dst, src_rect, dst_rect, ...) \
|
||||
({ \
|
||||
IM_STATUS __ret = IM_STATUS_NOERROR; \
|
||||
rga_buffer_t __pat; \
|
||||
im_rect __pat_rect; \
|
||||
memset(&__pat, 0, sizeof(rga_buffer_t)); \
|
||||
memset(&__pat_rect, 0, sizeof(im_rect)); \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args)/sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
__ret = imcheck_t(src, dst, __pat, src_rect, dst_rect, __pat_rect, 0); \
|
||||
} else if (__argc == 1){ \
|
||||
__ret = imcheck_t(src, dst, __pat, src_rect, dst_rect, __pat_rect, __args[0]); \
|
||||
} else { \
|
||||
__ret = IM_STATUS_FAILED; \
|
||||
printf("check failed\n"); \
|
||||
} \
|
||||
__ret; \
|
||||
})
|
||||
#define imcheck_composite(src, dst, pat, src_rect, dst_rect, pat_rect, ...) \
|
||||
({ \
|
||||
IM_STATUS __ret = IM_STATUS_NOERROR; \
|
||||
int __args[] = {__VA_ARGS__}; \
|
||||
int __argc = sizeof(__args)/sizeof(int); \
|
||||
if (__argc == 0) { \
|
||||
__ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, 0); \
|
||||
} else if (__argc == 1){ \
|
||||
__ret = imcheck_t(src, dst, pat, src_rect, dst_rect, pat_rect, __args[0]); \
|
||||
} else { \
|
||||
__ret = IM_STATUS_FAILED; \
|
||||
printf("check failed\n"); \
|
||||
} \
|
||||
__ret; \
|
||||
})
|
||||
IM_C_API IM_STATUS imcheck_t(const rga_buffer_t src, const rga_buffer_t dst, const rga_buffer_t pat,
|
||||
const im_rect src_rect, const im_rect dst_rect, const im_rect pat_rect, const int mode_usage);
|
||||
/* Compatible with the legacy symbol */
|
||||
IM_C_API void rga_check_perpare(rga_buffer_t *src, rga_buffer_t *dst,
|
||||
rga_buffer_t *pat, im_rect *src_rect,
|
||||
im_rect *dst_rect, im_rect *pat_rect,
|
||||
int mode_usage);
|
||||
IM_C_API void rga_check_perpare(rga_buffer_t *src, rga_buffer_t *dst, rga_buffer_t *pat,
|
||||
im_rect *src_rect, im_rect *dst_rect, im_rect *pat_rect, int mode_usage);
|
||||
|
||||
/**
|
||||
* block until all execution is complete
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
|
||||
using namespace android;
|
||||
|
||||
IM_API rga_buffer_handle_t
|
||||
importbuffer_GraphicBuffer_handle(buffer_handle_t hnd);
|
||||
IM_API rga_buffer_handle_t importbuffer_GraphicBuffer_handle(buffer_handle_t hnd);
|
||||
IM_API rga_buffer_handle_t importbuffer_GraphicBuffer(sp<GraphicBuffer> buf);
|
||||
|
||||
IM_API rga_buffer_t wrapbuffer_handle(buffer_handle_t hnd);
|
||||
|
||||
@@ -72,11 +72,9 @@ IM_API IM_STATUS improcess(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
|
||||
int acquire_fence_fd, int *release_fence_fd,
|
||||
im_opt_t *opt, int usage, im_ctx_id_t ctx_id);
|
||||
#endif
|
||||
IM_EXPORT_API IM_STATUS improcess_ctx(rga_buffer_t src, rga_buffer_t dst,
|
||||
rga_buffer_t pat, im_rect srect,
|
||||
im_rect drect, im_rect prect,
|
||||
int acquire_fence_fd,
|
||||
int *release_fence_fd, im_opt_t *opt,
|
||||
int usage, im_ctx_id_t ctx_id);
|
||||
IM_EXPORT_API IM_STATUS improcess_ctx(rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
|
||||
im_rect srect, im_rect drect, im_rect prect,
|
||||
int acquire_fence_fd, int *release_fence_fd,
|
||||
im_opt_t *opt, int usage, im_ctx_id_t ctx_id);
|
||||
|
||||
#endif /* #ifndef _im2d_mpi_hpp_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,9 +46,9 @@ IM_API im_job_handle_t imbeginJob(uint64_t flags = 0);
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imendJob(im_job_handle_t job_handle, int sync_mode = IM_SYNC,
|
||||
int acquire_fence_fd = 0,
|
||||
int *release_fence_fd = NULL);
|
||||
IM_API IM_STATUS imendJob(im_job_handle_t job_handle,
|
||||
int sync_mode = IM_SYNC,
|
||||
int acquire_fence_fd = 0, int *release_fence_fd = NULL);
|
||||
|
||||
/**
|
||||
* Cancel and delete an rga job
|
||||
@@ -72,8 +72,7 @@ IM_API IM_STATUS imcancelJob(im_job_handle_t job_handle);
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imcopyTask(im_job_handle_t job_handle, const rga_buffer_t src,
|
||||
rga_buffer_t dst);
|
||||
IM_API IM_STATUS imcopyTask(im_job_handle_t job_handle, const rga_buffer_t src, rga_buffer_t dst);
|
||||
|
||||
/**
|
||||
* Add resize task
|
||||
@@ -112,8 +111,8 @@ IM_API IM_STATUS imresizeTask(im_job_handle_t job_handle,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imcropTask(im_job_handle_t job_handle, const rga_buffer_t src,
|
||||
rga_buffer_t dst, im_rect rect);
|
||||
IM_API IM_STATUS imcropTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t src, rga_buffer_t dst, im_rect rect);
|
||||
|
||||
/**
|
||||
* Add translate task
|
||||
@@ -125,17 +124,14 @@ IM_API IM_STATUS imcropTask(im_job_handle_t job_handle, const rga_buffer_t src,
|
||||
* @param dst
|
||||
* The output destination image.
|
||||
* @param x
|
||||
* Output the coordinates of the starting point in the X-direction of the
|
||||
* destination image.
|
||||
* Output the coordinates of the starting point in the X-direction of the destination image.
|
||||
* @param y
|
||||
* Output the coordinates of the starting point in the Y-direction of the
|
||||
* destination image.
|
||||
* Output the coordinates of the starting point in the Y-direction of the destination image.
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imtranslateTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t src, rga_buffer_t dst,
|
||||
int x, int y);
|
||||
const rga_buffer_t src, rga_buffer_t dst, int x, int y);
|
||||
|
||||
/**
|
||||
* Add format convert task
|
||||
@@ -161,9 +157,9 @@ IM_API IM_STATUS imtranslateTask(im_job_handle_t job_handle,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imcvtcolorTask(im_job_handle_t job_handle, rga_buffer_t src,
|
||||
rga_buffer_t dst, int sfmt, int dfmt,
|
||||
int mode = IM_COLOR_SPACE_DEFAULT);
|
||||
IM_API IM_STATUS imcvtcolorTask(im_job_handle_t job_handle,
|
||||
rga_buffer_t src, rga_buffer_t dst,
|
||||
int sfmt, int dfmt, int mode = IM_COLOR_SPACE_DEFAULT);
|
||||
|
||||
/**
|
||||
* Add rotation task
|
||||
@@ -182,8 +178,7 @@ IM_API IM_STATUS imcvtcolorTask(im_job_handle_t job_handle, rga_buffer_t src,
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imrotateTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t src, rga_buffer_t dst,
|
||||
int rotation);
|
||||
const rga_buffer_t src, rga_buffer_t dst, int rotation);
|
||||
|
||||
/**
|
||||
* Add flip task
|
||||
@@ -200,8 +195,8 @@ IM_API IM_STATUS imrotateTask(im_job_handle_t job_handle,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imflipTask(im_job_handle_t job_handle, const rga_buffer_t src,
|
||||
rga_buffer_t dst, int mode);
|
||||
IM_API IM_STATUS imflipTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t src, rga_buffer_t dst, int mode);
|
||||
|
||||
/**
|
||||
* Add blend(SRC + DST -> DST) task
|
||||
@@ -246,8 +241,7 @@ IM_API IM_STATUS imblendTask(im_job_handle_t job_handle,
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imcompositeTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t fg_image,
|
||||
const rga_buffer_t bg_image,
|
||||
const rga_buffer_t fg_image, const rga_buffer_t bg_image,
|
||||
rga_buffer_t output_image,
|
||||
int mode = IM_ALPHA_BLEND_SRC_OVER);
|
||||
|
||||
@@ -266,9 +260,8 @@ IM_API IM_STATUS imcompositeTask(im_job_handle_t job_handle,
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imcolorkeyTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t fg_image,
|
||||
rga_buffer_t bg_image, im_colorkey_range range,
|
||||
int mode = IM_ALPHA_COLORKEY_NORMAL);
|
||||
const rga_buffer_t fg_image, rga_buffer_t bg_image,
|
||||
im_colorkey_range range, int mode = IM_ALPHA_COLORKEY_NORMAL);
|
||||
|
||||
/**
|
||||
* Add OSD task
|
||||
@@ -286,9 +279,9 @@ IM_API IM_STATUS imcolorkeyTask(im_job_handle_t job_handle,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imosdTask(im_job_handle_t job_handle, const rga_buffer_t osd,
|
||||
const rga_buffer_t bg_image, const im_rect osd_rect,
|
||||
im_osd_t *osd_config);
|
||||
IM_API IM_STATUS imosdTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t osd,const rga_buffer_t bg_image,
|
||||
const im_rect osd_rect, im_osd_t *osd_config);
|
||||
|
||||
/**
|
||||
* Add nn quantize task
|
||||
@@ -305,8 +298,7 @@ IM_API IM_STATUS imosdTask(im_job_handle_t job_handle, const rga_buffer_t osd,
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imquantizeTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t src, rga_buffer_t dst,
|
||||
im_nn_t nn_info);
|
||||
const rga_buffer_t src, rga_buffer_t dst, im_nn_t nn_info);
|
||||
|
||||
/**
|
||||
* Add ROP task
|
||||
@@ -322,8 +314,8 @@ IM_API IM_STATUS imquantizeTask(im_job_handle_t job_handle,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imropTask(im_job_handle_t job_handle, const rga_buffer_t src,
|
||||
rga_buffer_t dst, int rop_code);
|
||||
IM_API IM_STATUS imropTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t src, rga_buffer_t dst, int rop_code);
|
||||
|
||||
/**
|
||||
* Add color fill task
|
||||
@@ -339,8 +331,7 @@ IM_API IM_STATUS imropTask(im_job_handle_t job_handle, const rga_buffer_t src,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imfillTask(im_job_handle_t job_handle, rga_buffer_t dst,
|
||||
im_rect rect, uint32_t color);
|
||||
IM_API IM_STATUS imfillTask(im_job_handle_t job_handle, rga_buffer_t dst, im_rect rect, uint32_t color);
|
||||
|
||||
/**
|
||||
* Add color fill task array
|
||||
@@ -350,8 +341,7 @@ IM_API IM_STATUS imfillTask(im_job_handle_t job_handle, rga_buffer_t dst,
|
||||
* @param dst
|
||||
* The output destination image.
|
||||
* @param rect_array
|
||||
* The rectangle arrays on the source image that needs to be filled with
|
||||
* color.
|
||||
* The rectangle arrays on the source image that needs to be filled with color.
|
||||
* @param array_size
|
||||
* The size of rectangular area arrays.
|
||||
* @param color
|
||||
@@ -359,9 +349,9 @@ IM_API IM_STATUS imfillTask(im_job_handle_t job_handle, rga_buffer_t dst,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imfillTaskArray(im_job_handle_t job_handle, rga_buffer_t dst,
|
||||
im_rect *rect_array, int array_size,
|
||||
uint32_t color);
|
||||
IM_API IM_STATUS imfillTaskArray(im_job_handle_t job_handle,
|
||||
rga_buffer_t dst,
|
||||
im_rect *rect_array, int array_size, uint32_t color);
|
||||
|
||||
/**
|
||||
* Add fill rectangle task
|
||||
@@ -380,8 +370,10 @@ IM_API IM_STATUS imfillTaskArray(im_job_handle_t job_handle, rga_buffer_t dst,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imrectangleTask(im_job_handle_t job_handle, rga_buffer_t dst,
|
||||
im_rect rect, uint32_t color, int thickness);
|
||||
IM_API IM_STATUS imrectangleTask(im_job_handle_t job_handle,
|
||||
rga_buffer_t dst,
|
||||
im_rect rect,
|
||||
uint32_t color, int thickness);
|
||||
|
||||
/**
|
||||
* Add fill rectangle task array
|
||||
@@ -391,8 +383,7 @@ IM_API IM_STATUS imrectangleTask(im_job_handle_t job_handle, rga_buffer_t dst,
|
||||
* @param dst
|
||||
* The output destination image.
|
||||
* @param rect_array
|
||||
* The rectangle arrays on the source image that needs to be filled with
|
||||
* color.
|
||||
* The rectangle arrays on the source image that needs to be filled with color.
|
||||
* @param array_size
|
||||
* The size of rectangular area arrays.
|
||||
* @param color
|
||||
@@ -404,9 +395,9 @@ IM_API IM_STATUS imrectangleTask(im_job_handle_t job_handle, rga_buffer_t dst,
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS imrectangleTaskArray(im_job_handle_t job_handle,
|
||||
rga_buffer_t dst, im_rect *rect_array,
|
||||
int array_size, uint32_t color,
|
||||
int thickness);
|
||||
rga_buffer_t dst,
|
||||
im_rect *rect_array, int array_size,
|
||||
uint32_t color, int thickness);
|
||||
|
||||
/**
|
||||
* Add mosaic task
|
||||
@@ -428,8 +419,7 @@ IM_API IM_STATUS imrectangleTaskArray(im_job_handle_t job_handle,
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS immosaicTask(im_job_handle_t job_handle,
|
||||
const rga_buffer_t image, im_rect rect,
|
||||
int mosaic_mode);
|
||||
const rga_buffer_t image, im_rect rect, int mosaic_mode);
|
||||
|
||||
/**
|
||||
* Add mosaic task
|
||||
@@ -439,8 +429,7 @@ IM_API IM_STATUS immosaicTask(im_job_handle_t job_handle,
|
||||
* @param image
|
||||
* The output destination image.
|
||||
* @param rect_array
|
||||
* The rectangle arrays on the source image that needs to be filled with
|
||||
* color.
|
||||
* The rectangle arrays on the source image that needs to be filled with color.
|
||||
* @param array_size
|
||||
* The size of rectangular area arrays.
|
||||
* @param mosaic_mode
|
||||
@@ -455,8 +444,7 @@ IM_API IM_STATUS immosaicTask(im_job_handle_t job_handle,
|
||||
*/
|
||||
IM_API IM_STATUS immosaicTaskArray(im_job_handle_t job_handle,
|
||||
const rga_buffer_t image,
|
||||
im_rect *rect_array, int array_size,
|
||||
int mosaic_mode);
|
||||
im_rect *rect_array, int array_size, int mosaic_mode);
|
||||
|
||||
/**
|
||||
* Add palette task
|
||||
@@ -472,8 +460,8 @@ IM_API IM_STATUS immosaicTaskArray(im_job_handle_t job_handle,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS impaletteTask(im_job_handle_t job_handle, rga_buffer_t src,
|
||||
rga_buffer_t dst, rga_buffer_t lut);
|
||||
IM_API IM_STATUS impaletteTask(im_job_handle_t job_handle,
|
||||
rga_buffer_t src, rga_buffer_t dst, rga_buffer_t lut);
|
||||
|
||||
/**
|
||||
* Add process task
|
||||
@@ -499,8 +487,8 @@ IM_API IM_STATUS impaletteTask(im_job_handle_t job_handle, rga_buffer_t src,
|
||||
*
|
||||
* @returns success or else negative error code.
|
||||
*/
|
||||
IM_API IM_STATUS improcessTask(im_job_handle_t job_handle, rga_buffer_t src,
|
||||
rga_buffer_t dst, rga_buffer_t pat,
|
||||
IM_API IM_STATUS improcessTask(im_job_handle_t job_handle,
|
||||
rga_buffer_t src, rga_buffer_t dst, rga_buffer_t pat,
|
||||
im_rect srect, im_rect drect, im_rect prect,
|
||||
im_opt_t *opt_ptr, int usage);
|
||||
|
||||
|
||||
@@ -45,394 +45,426 @@ typedef uint32_t im_ctx_id_t;
|
||||
typedef uint32_t rga_buffer_handle_t;
|
||||
|
||||
typedef enum {
|
||||
/* Rotation */
|
||||
IM_HAL_TRANSFORM_ROT_90 = 1 << 0,
|
||||
IM_HAL_TRANSFORM_ROT_180 = 1 << 1,
|
||||
IM_HAL_TRANSFORM_ROT_270 = 1 << 2,
|
||||
IM_HAL_TRANSFORM_FLIP_H = 1 << 3,
|
||||
IM_HAL_TRANSFORM_FLIP_V = 1 << 4,
|
||||
IM_HAL_TRANSFORM_FLIP_H_V = 1 << 5,
|
||||
IM_HAL_TRANSFORM_MASK = 0x3f,
|
||||
/* Rotation */
|
||||
IM_HAL_TRANSFORM_ROT_90 = 1 << 0,
|
||||
IM_HAL_TRANSFORM_ROT_180 = 1 << 1,
|
||||
IM_HAL_TRANSFORM_ROT_270 = 1 << 2,
|
||||
IM_HAL_TRANSFORM_FLIP_H = 1 << 3,
|
||||
IM_HAL_TRANSFORM_FLIP_V = 1 << 4,
|
||||
IM_HAL_TRANSFORM_FLIP_H_V = 1 << 5,
|
||||
IM_HAL_TRANSFORM_MASK = 0x3f,
|
||||
|
||||
/*
|
||||
* Blend
|
||||
* Additional blend usage, can be used with both source and target configs.
|
||||
* If none of the below is set, the default "SRC over DST" is applied.
|
||||
*/
|
||||
IM_ALPHA_BLEND_SRC_OVER = 1 << 6, /* Default, Porter-Duff "SRC over DST" */
|
||||
IM_ALPHA_BLEND_SRC = 1 << 7, /* Porter-Duff "SRC" */
|
||||
IM_ALPHA_BLEND_DST = 1 << 8, /* Porter-Duff "DST" */
|
||||
IM_ALPHA_BLEND_SRC_IN = 1 << 9, /* Porter-Duff "SRC in DST" */
|
||||
IM_ALPHA_BLEND_DST_IN = 1 << 10, /* Porter-Duff "DST in SRC" */
|
||||
IM_ALPHA_BLEND_SRC_OUT = 1 << 11, /* Porter-Duff "SRC out DST" */
|
||||
IM_ALPHA_BLEND_DST_OUT = 1 << 12, /* Porter-Duff "DST out SRC" */
|
||||
IM_ALPHA_BLEND_DST_OVER = 1 << 13, /* Porter-Duff "DST over SRC" */
|
||||
IM_ALPHA_BLEND_SRC_ATOP = 1 << 14, /* Porter-Duff "SRC ATOP" */
|
||||
IM_ALPHA_BLEND_DST_ATOP = 1 << 15, /* Porter-Duff "DST ATOP" */
|
||||
IM_ALPHA_BLEND_XOR = 1 << 16, /* Xor */
|
||||
IM_ALPHA_BLEND_MASK = 0x1ffc0,
|
||||
/*
|
||||
* Blend
|
||||
* Additional blend usage, can be used with both source and target configs.
|
||||
* If none of the below is set, the default "SRC over DST" is applied.
|
||||
*/
|
||||
IM_ALPHA_BLEND_SRC_OVER = 1 << 6, /* Default, Porter-Duff "SRC over DST" */
|
||||
IM_ALPHA_BLEND_SRC = 1 << 7, /* Porter-Duff "SRC" */
|
||||
IM_ALPHA_BLEND_DST = 1 << 8, /* Porter-Duff "DST" */
|
||||
IM_ALPHA_BLEND_SRC_IN = 1 << 9, /* Porter-Duff "SRC in DST" */
|
||||
IM_ALPHA_BLEND_DST_IN = 1 << 10, /* Porter-Duff "DST in SRC" */
|
||||
IM_ALPHA_BLEND_SRC_OUT = 1 << 11, /* Porter-Duff "SRC out DST" */
|
||||
IM_ALPHA_BLEND_DST_OUT = 1 << 12, /* Porter-Duff "DST out SRC" */
|
||||
IM_ALPHA_BLEND_DST_OVER = 1 << 13, /* Porter-Duff "DST over SRC" */
|
||||
IM_ALPHA_BLEND_SRC_ATOP = 1 << 14, /* Porter-Duff "SRC ATOP" */
|
||||
IM_ALPHA_BLEND_DST_ATOP = 1 << 15, /* Porter-Duff "DST ATOP" */
|
||||
IM_ALPHA_BLEND_XOR = 1 << 16, /* Xor */
|
||||
IM_ALPHA_BLEND_MASK = 0x1ffc0,
|
||||
|
||||
IM_ALPHA_COLORKEY_NORMAL = 1 << 17,
|
||||
IM_ALPHA_COLORKEY_INVERTED = 1 << 18,
|
||||
IM_ALPHA_COLORKEY_MASK = 0x60000,
|
||||
IM_ALPHA_COLORKEY_NORMAL = 1 << 17,
|
||||
IM_ALPHA_COLORKEY_INVERTED = 1 << 18,
|
||||
IM_ALPHA_COLORKEY_MASK = 0x60000,
|
||||
|
||||
IM_SYNC = 1 << 19,
|
||||
IM_CROP = 1 << 20, /* Unused */
|
||||
IM_COLOR_FILL = 1 << 21,
|
||||
IM_COLOR_PALETTE = 1 << 22,
|
||||
IM_NN_QUANTIZE = 1 << 23,
|
||||
IM_ROP = 1 << 24,
|
||||
IM_ALPHA_BLEND_PRE_MUL = 1 << 25,
|
||||
IM_ASYNC = 1 << 26,
|
||||
IM_MOSAIC = 1 << 27,
|
||||
IM_OSD = 1 << 28,
|
||||
IM_PRE_INTR = 1 << 29,
|
||||
IM_SYNC = 1 << 19,
|
||||
IM_CROP = 1 << 20, /* Unused */
|
||||
IM_COLOR_FILL = 1 << 21,
|
||||
IM_COLOR_PALETTE = 1 << 22,
|
||||
IM_NN_QUANTIZE = 1 << 23,
|
||||
IM_ROP = 1 << 24,
|
||||
IM_ALPHA_BLEND_PRE_MUL = 1 << 25,
|
||||
IM_ASYNC = 1 << 26,
|
||||
IM_MOSAIC = 1 << 27,
|
||||
IM_OSD = 1 << 28,
|
||||
IM_PRE_INTR = 1 << 29,
|
||||
IM_ALPHA_BIT_MAP = 1 << 30,
|
||||
} IM_USAGE;
|
||||
|
||||
typedef enum {
|
||||
IM_RASTER_MODE = 1 << 0,
|
||||
IM_FBC_MODE = 1 << 1,
|
||||
IM_TILE_MODE = 1 << 2,
|
||||
IM_RASTER_MODE = 1 << 0,
|
||||
IM_AFBC16x16_MODE = 1 << 1,
|
||||
IM_TILE8x8_MODE = 1 << 2,
|
||||
IM_TILE4x4_MODE = 1 << 3,
|
||||
IM_RKFBC64x4_MODE = 1 << 4,
|
||||
IM_AFBC32x8_MODE = 1 << 5,
|
||||
/* legacy */
|
||||
IM_FBC_MODE = IM_AFBC16x16_MODE,
|
||||
IM_TILE_MODE = IM_TILE8x8_MODE,
|
||||
} IM_RD_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_SCHEDULER_RGA3_CORE0 = 1 << 0,
|
||||
IM_SCHEDULER_RGA3_CORE1 = 1 << 1,
|
||||
IM_SCHEDULER_RGA2_CORE0 = 1 << 2,
|
||||
IM_SCHEDULER_RGA3_DEFAULT = IM_SCHEDULER_RGA3_CORE0,
|
||||
IM_SCHEDULER_RGA2_DEFAULT = IM_SCHEDULER_RGA2_CORE0,
|
||||
IM_SCHEDULER_MASK = 0x7,
|
||||
IM_SCHEDULER_DEFAULT = 0,
|
||||
IM_SCHEDULER_RGA3_CORE0 = 1 << 0,
|
||||
IM_SCHEDULER_RGA3_CORE1 = 1 << 1,
|
||||
IM_SCHEDULER_RGA2_CORE0 = 1 << 2,
|
||||
IM_SCHEDULER_RGA2_CORE1 = 1 << 3,
|
||||
IM_SCHEDULER_RGA3_DEFAULT = IM_SCHEDULER_RGA3_CORE0,
|
||||
IM_SCHEDULER_RGA2_DEFAULT = IM_SCHEDULER_RGA2_CORE0,
|
||||
IM_SCHEDULER_MASK = 0xf,
|
||||
IM_SCHEDULER_DEFAULT = 0,
|
||||
} IM_SCHEDULER_CORE;
|
||||
|
||||
typedef enum {
|
||||
IM_ROP_AND = 0x88,
|
||||
IM_ROP_OR = 0xee,
|
||||
IM_ROP_NOT_DST = 0x55,
|
||||
IM_ROP_NOT_SRC = 0x33,
|
||||
IM_ROP_XOR = 0xf6,
|
||||
IM_ROP_NOT_XOR = 0xf9,
|
||||
IM_ROP_AND = 0x88,
|
||||
IM_ROP_OR = 0xee,
|
||||
IM_ROP_NOT_DST = 0x55,
|
||||
IM_ROP_NOT_SRC = 0x33,
|
||||
IM_ROP_XOR = 0xf6,
|
||||
IM_ROP_NOT_XOR = 0xf9,
|
||||
} IM_ROP_CODE;
|
||||
|
||||
typedef enum {
|
||||
IM_MOSAIC_8 = 0x0,
|
||||
IM_MOSAIC_16 = 0x1,
|
||||
IM_MOSAIC_32 = 0x2,
|
||||
IM_MOSAIC_64 = 0x3,
|
||||
IM_MOSAIC_128 = 0x4,
|
||||
IM_MOSAIC_8 = 0x0,
|
||||
IM_MOSAIC_16 = 0x1,
|
||||
IM_MOSAIC_32 = 0x2,
|
||||
IM_MOSAIC_64 = 0x3,
|
||||
IM_MOSAIC_128 = 0x4,
|
||||
} IM_MOSAIC_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_BORDER_CONSTANT =
|
||||
0, /* iiiiii|abcdefgh|iiiiiii with some specified value 'i' */
|
||||
IM_BORDER_REFLECT = 2, /* fedcba|abcdefgh|hgfedcb */
|
||||
IM_BORDER_WRAP = 3, /* cdefgh|abcdefgh|abcdefg */
|
||||
IM_BORDER_CONSTANT = 0, /* iiiiii|abcdefgh|iiiiiii with some specified value 'i' */
|
||||
IM_BORDER_REFLECT = 2, /* fedcba|abcdefgh|hgfedcb */
|
||||
IM_BORDER_WRAP = 3, /* cdefgh|abcdefgh|abcdefg */
|
||||
} IM_BORDER_TYPE;
|
||||
|
||||
/* Status codes, returned by any blit function */
|
||||
typedef enum {
|
||||
IM_YUV_TO_RGB_BT601_LIMIT = 1 << 0,
|
||||
IM_YUV_TO_RGB_BT601_FULL = 2 << 0,
|
||||
IM_YUV_TO_RGB_BT709_LIMIT = 3 << 0,
|
||||
IM_YUV_TO_RGB_MASK = 3 << 0,
|
||||
IM_RGB_TO_YUV_BT601_FULL = 1 << 2,
|
||||
IM_RGB_TO_YUV_BT601_LIMIT = 2 << 2,
|
||||
IM_RGB_TO_YUV_BT709_LIMIT = 3 << 2,
|
||||
IM_RGB_TO_YUV_MASK = 3 << 2,
|
||||
IM_RGB_TO_Y4 = 1 << 4,
|
||||
IM_RGB_TO_Y4_DITHER = 2 << 4,
|
||||
IM_RGB_TO_Y1_DITHER = 3 << 4,
|
||||
IM_Y4_MASK = 3 << 4,
|
||||
IM_RGB_FULL = 1 << 8,
|
||||
IM_RGB_CLIP = 2 << 8,
|
||||
IM_YUV_BT601_LIMIT_RANGE = 3 << 8,
|
||||
IM_YUV_BT601_FULL_RANGE = 4 << 8,
|
||||
IM_YUV_BT709_LIMIT_RANGE = 5 << 8,
|
||||
IM_YUV_BT709_FULL_RANGE = 6 << 8,
|
||||
IM_FULL_CSC_MASK = 0xf << 8,
|
||||
IM_COLOR_SPACE_DEFAULT = 0,
|
||||
IM_YUV_TO_RGB_BT601_LIMIT = 1 << 0,
|
||||
IM_YUV_TO_RGB_BT601_FULL = 2 << 0,
|
||||
IM_YUV_TO_RGB_BT709_LIMIT = 3 << 0,
|
||||
IM_YUV_TO_RGB_MASK = 3 << 0,
|
||||
IM_RGB_TO_YUV_BT601_FULL = 1 << 2,
|
||||
IM_RGB_TO_YUV_BT601_LIMIT = 2 << 2,
|
||||
IM_RGB_TO_YUV_BT709_LIMIT = 3 << 2,
|
||||
IM_RGB_TO_YUV_MASK = 3 << 2,
|
||||
IM_RGB_TO_Y4 = 1 << 4,
|
||||
IM_RGB_TO_Y4_DITHER = 2 << 4,
|
||||
IM_RGB_TO_Y1_DITHER = 3 << 4,
|
||||
IM_Y4_MASK = 3 << 4,
|
||||
IM_RGB_FULL = 1 << 8,
|
||||
IM_RGB_CLIP = 2 << 8,
|
||||
IM_YUV_BT601_LIMIT_RANGE = 3 << 8,
|
||||
IM_YUV_BT601_FULL_RANGE = 4 << 8,
|
||||
IM_YUV_BT709_LIMIT_RANGE = 5 << 8,
|
||||
IM_YUV_BT709_FULL_RANGE = 6 << 8,
|
||||
IM_FULL_CSC_MASK = 0xf << 8,
|
||||
IM_COLOR_SPACE_DEFAULT = 0,
|
||||
} IM_COLOR_SPACE_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_UP_SCALE,
|
||||
IM_DOWN_SCALE,
|
||||
IM_UP_SCALE,
|
||||
IM_DOWN_SCALE,
|
||||
} IM_SCALE;
|
||||
|
||||
/* legacy */
|
||||
typedef enum {
|
||||
INTER_NEAREST,
|
||||
INTER_LINEAR,
|
||||
INTER_CUBIC,
|
||||
INTER_NEAREST,
|
||||
INTER_LINEAR,
|
||||
INTER_CUBIC,
|
||||
} IM_SCALE_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_CONFIG_SCHEDULER_CORE,
|
||||
IM_CONFIG_PRIORITY,
|
||||
IM_CONFIG_CHECK,
|
||||
IM_INTERP_DEFAULT = 0,
|
||||
IM_INTERP_LINEAR = 1,
|
||||
IM_INTERP_CUBIC = 2,
|
||||
IM_INTERP_AVERAGE = 3,
|
||||
|
||||
IM_INTERP_MASK = 0xf,
|
||||
IM_INTERP_HORIZ_SHIFT = 0,
|
||||
IM_INTERP_VERTI_SHIFT = 4,
|
||||
IM_INTERP_HORIZ_FLAG = 0x1 << 8,
|
||||
IM_INTERP_VERTI_FLAG = 0x1 << 9,
|
||||
} IM_INTER_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_CONFIG_SCHEDULER_CORE,
|
||||
IM_CONFIG_PRIORITY,
|
||||
IM_CONFIG_CHECK,
|
||||
} IM_CONFIG_NAME;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_MODE_STATISTICS = 0x1 << 0,
|
||||
IM_OSD_MODE_AUTO_INVERT = 0x1 << 1,
|
||||
IM_OSD_MODE_STATISTICS = 0x1 << 0,
|
||||
IM_OSD_MODE_AUTO_INVERT = 0x1 << 1,
|
||||
} IM_OSD_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_INVERT_CHANNEL_NONE = 0x0,
|
||||
IM_OSD_INVERT_CHANNEL_Y_G = 0x1 << 0,
|
||||
IM_OSD_INVERT_CHANNEL_C_RB = 0x1 << 1,
|
||||
IM_OSD_INVERT_CHANNEL_ALPHA = 0x1 << 2,
|
||||
IM_OSD_INVERT_CHANNEL_COLOR =
|
||||
IM_OSD_INVERT_CHANNEL_Y_G | IM_OSD_INVERT_CHANNEL_C_RB,
|
||||
IM_OSD_INVERT_CHANNEL_BOTH =
|
||||
IM_OSD_INVERT_CHANNEL_COLOR | IM_OSD_INVERT_CHANNEL_ALPHA,
|
||||
IM_OSD_INVERT_CHANNEL_NONE = 0x0,
|
||||
IM_OSD_INVERT_CHANNEL_Y_G = 0x1 << 0,
|
||||
IM_OSD_INVERT_CHANNEL_C_RB = 0x1 << 1,
|
||||
IM_OSD_INVERT_CHANNEL_ALPHA = 0x1 << 2,
|
||||
IM_OSD_INVERT_CHANNEL_COLOR = IM_OSD_INVERT_CHANNEL_Y_G |
|
||||
IM_OSD_INVERT_CHANNEL_C_RB,
|
||||
IM_OSD_INVERT_CHANNEL_BOTH = IM_OSD_INVERT_CHANNEL_COLOR |
|
||||
IM_OSD_INVERT_CHANNEL_ALPHA,
|
||||
} IM_OSD_INVERT_CHANNEL;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_FLAGS_INTERNAL = 0,
|
||||
IM_OSD_FLAGS_EXTERNAL,
|
||||
IM_OSD_FLAGS_INTERNAL = 0,
|
||||
IM_OSD_FLAGS_EXTERNAL,
|
||||
} IM_OSD_FLAGS_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_INVERT_USE_FACTOR,
|
||||
IM_OSD_INVERT_USE_SWAP,
|
||||
IM_OSD_INVERT_USE_FACTOR,
|
||||
IM_OSD_INVERT_USE_SWAP,
|
||||
} IM_OSD_INVERT_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_BACKGROUND_DEFAULT_BRIGHT = 0,
|
||||
IM_OSD_BACKGROUND_DEFAULT_DARK,
|
||||
IM_OSD_BACKGROUND_DEFAULT_BRIGHT = 0,
|
||||
IM_OSD_BACKGROUND_DEFAULT_DARK,
|
||||
} IM_OSD_BACKGROUND_DEFAULT;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_BLOCK_MODE_NORMAL = 0,
|
||||
IM_OSD_BLOCK_MODE_DIFFERENT,
|
||||
IM_OSD_BLOCK_MODE_NORMAL = 0,
|
||||
IM_OSD_BLOCK_MODE_DIFFERENT,
|
||||
} IM_OSD_BLOCK_WIDTH_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_MODE_HORIZONTAL,
|
||||
IM_OSD_MODE_VERTICAL,
|
||||
IM_OSD_MODE_HORIZONTAL,
|
||||
IM_OSD_MODE_VERTICAL,
|
||||
} IM_OSD_DIRECTION;
|
||||
|
||||
typedef enum {
|
||||
IM_OSD_COLOR_PIXEL,
|
||||
IM_OSD_COLOR_EXTERNAL,
|
||||
IM_OSD_COLOR_PIXEL,
|
||||
IM_OSD_COLOR_EXTERNAL,
|
||||
} IM_OSD_COLOR_MODE;
|
||||
|
||||
typedef enum {
|
||||
IM_INTR_READ_INTR = 1 << 0,
|
||||
IM_INTR_READ_HOLD = 1 << 1,
|
||||
IM_INTR_WRITE_INTR = 1 << 2,
|
||||
IM_INTR_READ_INTR = 1 << 0,
|
||||
IM_INTR_READ_HOLD = 1 << 1,
|
||||
IM_INTR_WRITE_INTR = 1 << 2,
|
||||
} IM_PRE_INTR_FLAGS;
|
||||
|
||||
typedef enum {
|
||||
IM_CONTEXT_NONE = 0x0,
|
||||
IM_CONTEXT_SRC_FIX_ENABLE =
|
||||
0x1 << 0, // Enable kernel to modify the image parameters of the channel.
|
||||
IM_CONTEXT_SRC_CACHE_INFO = 0x1 << 1, // It will replace the parameters in ctx
|
||||
// with the modified parameters.
|
||||
IM_CONTEXT_SRC1_FIX_ENABLE = 0x1 << 2,
|
||||
IM_CONTEXT_SRC1_CACHE_INFO = 0x1 << 3,
|
||||
IM_CONTEXT_DST_FIX_ENABLE = 0x1 << 4,
|
||||
IM_CONTEXT_DST_CACHE_INFO = 0x1 << 5,
|
||||
IM_CONTEXT_NONE = 0x0,
|
||||
IM_CONTEXT_SRC_FIX_ENABLE = 0x1 << 0, // Enable kernel to modify the image parameters of the channel.
|
||||
IM_CONTEXT_SRC_CACHE_INFO = 0x1 << 1, // It will replace the parameters in ctx with the modified parameters.
|
||||
IM_CONTEXT_SRC1_FIX_ENABLE = 0x1 << 2,
|
||||
IM_CONTEXT_SRC1_CACHE_INFO = 0x1 << 3,
|
||||
IM_CONTEXT_DST_FIX_ENABLE = 0x1 << 4,
|
||||
IM_CONTEXT_DST_CACHE_INFO = 0x1 << 5,
|
||||
} IM_CONTEXT_FLAGS;
|
||||
|
||||
/* Get RGA basic information index */
|
||||
typedef enum {
|
||||
RGA_VENDOR = 0,
|
||||
RGA_VERSION,
|
||||
RGA_MAX_INPUT,
|
||||
RGA_MAX_OUTPUT,
|
||||
RGA_BYTE_STRIDE,
|
||||
RGA_SCALE_LIMIT,
|
||||
RGA_INPUT_FORMAT,
|
||||
RGA_OUTPUT_FORMAT,
|
||||
RGA_FEATURE,
|
||||
RGA_EXPECTED,
|
||||
RGA_ALL,
|
||||
RGA_VENDOR = 0,
|
||||
RGA_VERSION,
|
||||
RGA_MAX_INPUT,
|
||||
RGA_MAX_OUTPUT,
|
||||
RGA_BYTE_STRIDE,
|
||||
RGA_SCALE_LIMIT,
|
||||
RGA_INPUT_FORMAT,
|
||||
RGA_OUTPUT_FORMAT,
|
||||
RGA_FEATURE,
|
||||
RGA_EXPECTED,
|
||||
RGA_ALL,
|
||||
} IM_INFORMATION;
|
||||
|
||||
/* Status codes, returned by any blit function */
|
||||
typedef enum {
|
||||
IM_STATUS_NOERROR = 2,
|
||||
IM_STATUS_SUCCESS = 1,
|
||||
IM_STATUS_NOT_SUPPORTED = -1,
|
||||
IM_STATUS_OUT_OF_MEMORY = -2,
|
||||
IM_STATUS_INVALID_PARAM = -3,
|
||||
IM_STATUS_ILLEGAL_PARAM = -4,
|
||||
IM_STATUS_ERROR_VERSION = -5,
|
||||
IM_STATUS_FAILED = 0,
|
||||
IM_STATUS_NOERROR = 2,
|
||||
IM_STATUS_SUCCESS = 1,
|
||||
IM_STATUS_NOT_SUPPORTED = -1,
|
||||
IM_STATUS_OUT_OF_MEMORY = -2,
|
||||
IM_STATUS_INVALID_PARAM = -3,
|
||||
IM_STATUS_ILLEGAL_PARAM = -4,
|
||||
IM_STATUS_ERROR_VERSION = -5,
|
||||
IM_STATUS_FAILED = 0,
|
||||
} IM_STATUS;
|
||||
|
||||
/* Rectangle definition */
|
||||
typedef struct {
|
||||
int x; /* upper-left x */
|
||||
int y; /* upper-left y */
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
int x; /* upper-left x */
|
||||
int y; /* upper-left y */
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
} im_rect;
|
||||
|
||||
typedef struct {
|
||||
int max; /* The Maximum value of the color key */
|
||||
int min; /* The minimum value of the color key */
|
||||
int max; /* The Maximum value of the color key */
|
||||
int min; /* The minimum value of the color key */
|
||||
} im_colorkey_range;
|
||||
|
||||
|
||||
typedef struct im_nn {
|
||||
int scale_r; /* scaling factor on R channal */
|
||||
int scale_g; /* scaling factor on G channal */
|
||||
int scale_b; /* scaling factor on B channal */
|
||||
int offset_r; /* offset on R channal */
|
||||
int offset_g; /* offset on G channal */
|
||||
int offset_b; /* offset on B channal */
|
||||
int scale_r; /* scaling factor on R channal */
|
||||
int scale_g; /* scaling factor on G channal */
|
||||
int scale_b; /* scaling factor on B channal */
|
||||
int offset_r; /* offset on R channal */
|
||||
int offset_g; /* offset on G channal */
|
||||
int offset_b; /* offset on B channal */
|
||||
} im_nn_t;
|
||||
|
||||
/* im_info definition */
|
||||
typedef struct {
|
||||
void *vir_addr; /* virtual address */
|
||||
void *phy_addr; /* physical address */
|
||||
int fd; /* shared fd */
|
||||
void* vir_addr; /* virtual address */
|
||||
void* phy_addr; /* physical address */
|
||||
int fd; /* shared fd */
|
||||
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
int wstride; /* wstride */
|
||||
int hstride; /* hstride */
|
||||
int format; /* format */
|
||||
int width; /* width */
|
||||
int height; /* height */
|
||||
int wstride; /* wstride */
|
||||
int hstride; /* hstride */
|
||||
int format; /* format */
|
||||
|
||||
int color_space_mode; /* color_space_mode */
|
||||
int global_alpha; /* global_alpha */
|
||||
int rd_mode;
|
||||
int color_space_mode; /* color_space_mode */
|
||||
union {
|
||||
int global_alpha; /* global_alpha, the default should be 0xff */
|
||||
struct {
|
||||
uint16_t alpha0;
|
||||
uint16_t alpha1;
|
||||
} alpha_bit; /* alpha bit(e.g. RGBA5551), 0: alpha0, 1: alpha1 */
|
||||
};
|
||||
int rd_mode;
|
||||
|
||||
/* legarcy */
|
||||
int color; /* color, used by color fill */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
/* legacy */
|
||||
int color; /* color, used by color fill */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
|
||||
rga_buffer_handle_t handle; /* buffer handle */
|
||||
rga_buffer_handle_t handle; /* buffer handle */
|
||||
} rga_buffer_t;
|
||||
|
||||
typedef struct im_color {
|
||||
union {
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t alpha;
|
||||
union {
|
||||
struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t alpha;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
uint32_t value;
|
||||
};
|
||||
} im_color_t;
|
||||
|
||||
typedef struct im_osd_invert_factor {
|
||||
uint8_t alpha_max;
|
||||
uint8_t alpha_min;
|
||||
uint8_t yg_max;
|
||||
uint8_t yg_min;
|
||||
uint8_t crb_max;
|
||||
uint8_t crb_min;
|
||||
uint8_t alpha_max;
|
||||
uint8_t alpha_min;
|
||||
uint8_t yg_max;
|
||||
uint8_t yg_min;
|
||||
uint8_t crb_max;
|
||||
uint8_t crb_min;
|
||||
} im_osd_invert_factor_t;
|
||||
|
||||
typedef struct im_osd_bpp2 {
|
||||
uint8_t ac_swap; // ac swap flag
|
||||
// 0: CA
|
||||
// 1: AC
|
||||
uint8_t endian_swap; // rgba2bpp endian swap
|
||||
// 0: Big endian
|
||||
// 1: Little endian
|
||||
im_color_t color0;
|
||||
im_color_t color1;
|
||||
uint8_t ac_swap; // ac swap flag
|
||||
// 0: CA
|
||||
// 1: AC
|
||||
uint8_t endian_swap; // rgba2bpp endian swap
|
||||
// 0: Big endian
|
||||
// 1: Little endian
|
||||
im_color_t color0;
|
||||
im_color_t color1;
|
||||
} im_osd_bpp2_t;
|
||||
|
||||
typedef struct im_osd_block {
|
||||
int width_mode; // normal or different
|
||||
// IM_OSD_BLOCK_MODE_NORMAL
|
||||
// IM_OSD_BLOCK_MODE_DIFFERENT
|
||||
union {
|
||||
int width; // normal_mode block width
|
||||
int width_index; // different_mode block width index in RAM
|
||||
};
|
||||
int width_mode; // normal or different
|
||||
// IM_OSD_BLOCK_MODE_NORMAL
|
||||
// IM_OSD_BLOCK_MODE_DIFFERENT
|
||||
union {
|
||||
int width; // normal_mode block width
|
||||
int width_index; // different_mode block width index in RAM
|
||||
};
|
||||
|
||||
int block_count; // block count
|
||||
int block_count; // block count
|
||||
|
||||
int background_config; // background config is bright or dark
|
||||
// IM_OSD_BACKGROUND_DEFAULT_BRIGHT
|
||||
// IM_OSD_BACKGROUND_DEFAULT_DARK
|
||||
int background_config; // background config is bright or dark
|
||||
// IM_OSD_BACKGROUND_DEFAULT_BRIGHT
|
||||
// IM_OSD_BACKGROUND_DEFAULT_DARK
|
||||
|
||||
int direction; // osd block direction
|
||||
// IM_OSD_MODE_HORIZONTAL
|
||||
// IM_OSD_MODE_VERTICAL
|
||||
int direction; // osd block direction
|
||||
// IM_OSD_MODE_HORIZONTAL
|
||||
// IM_OSD_MODE_VERTICAL
|
||||
|
||||
int color_mode; // using src1 color or config color
|
||||
// IM_OSD_COLOR_PIXEL
|
||||
// IM_OSD_COLOR_EXTERNAL
|
||||
im_color_t normal_color; // config color: normal
|
||||
im_color_t invert_color; // config color: invert
|
||||
int color_mode; // using src1 color or config color
|
||||
// IM_OSD_COLOR_PIXEL
|
||||
// IM_OSD_COLOR_EXTERNAL
|
||||
im_color_t normal_color; // config color: normal
|
||||
im_color_t invert_color; // config color: invert
|
||||
} im_osd_block_t;
|
||||
|
||||
typedef struct im_osd_invert {
|
||||
int invert_channel; // invert channel config:
|
||||
// IM_OSD_INVERT_CHANNEL_NONE
|
||||
// IM_OSD_INVERT_CHANNEL_Y_G
|
||||
// IM_OSD_INVERT_CHANNEL_C_RB
|
||||
// IM_OSD_INVERT_CHANNEL_ALPHA
|
||||
// IM_OSD_INVERT_CHANNEL_COLOR
|
||||
// IM_OSD_INVERT_CHANNEL_BOTH
|
||||
int flags_mode; // use external or inertnal RAM invert flags
|
||||
// IM_OSD_FLAGS_EXTERNAL
|
||||
// IM_OSD_FLAGS_INTERNAL
|
||||
int flags_index; // flags index when using internal RAM invert flags
|
||||
int invert_channel; // invert channel config:
|
||||
// IM_OSD_INVERT_CHANNEL_NONE
|
||||
// IM_OSD_INVERT_CHANNEL_Y_G
|
||||
// IM_OSD_INVERT_CHANNEL_C_RB
|
||||
// IM_OSD_INVERT_CHANNEL_ALPHA
|
||||
// IM_OSD_INVERT_CHANNEL_COLOR
|
||||
// IM_OSD_INVERT_CHANNEL_BOTH
|
||||
int flags_mode; // use external or inertnal RAM invert flags
|
||||
// IM_OSD_FLAGS_EXTERNAL
|
||||
// IM_OSD_FLAGS_INTERNAL
|
||||
int flags_index; // flags index when using internal RAM invert flags
|
||||
|
||||
uint64_t invert_flags; // external invert flags
|
||||
uint64_t current_flags; // current flags
|
||||
uint64_t invert_flags; // external invert flags
|
||||
uint64_t current_flags; // current flags
|
||||
|
||||
int invert_mode; // invert use swap or factor
|
||||
// IM_OSD_INVERT_USE_FACTOR
|
||||
// IM_OSD_INVERT_USE_SWAP
|
||||
im_osd_invert_factor_t factor;
|
||||
int invert_mode; // invert use swap or factor
|
||||
// IM_OSD_INVERT_USE_FACTOR
|
||||
// IM_OSD_INVERT_USE_SWAP
|
||||
im_osd_invert_factor_t factor;
|
||||
|
||||
int threash;
|
||||
int threash;
|
||||
} im_osd_invert_t;
|
||||
|
||||
typedef struct im_osd {
|
||||
int osd_mode; // osd mode: statistics or auto_invert
|
||||
// IM_OSD_MODE_STATISTICS
|
||||
// IM_OSD_MODE_AUTO_INVERT
|
||||
im_osd_block_t block_parm; // osd block info config
|
||||
int osd_mode; // osd mode: statistics or auto_invert
|
||||
// IM_OSD_MODE_STATISTICS
|
||||
// IM_OSD_MODE_AUTO_INVERT
|
||||
im_osd_block_t block_parm; // osd block info config
|
||||
|
||||
im_osd_invert_t invert_config;
|
||||
im_osd_invert_t invert_config;
|
||||
|
||||
im_osd_bpp2_t bpp2_info;
|
||||
im_osd_bpp2_t bpp2_info;
|
||||
} im_osd_t;
|
||||
|
||||
typedef struct im_intr_config {
|
||||
uint32_t flags;
|
||||
uint32_t flags;
|
||||
|
||||
int read_threshold;
|
||||
int write_start;
|
||||
int write_step;
|
||||
int read_threshold;
|
||||
int write_start;
|
||||
int write_step;
|
||||
} im_intr_config_t;
|
||||
|
||||
typedef struct im_opt {
|
||||
im_api_version_t version DEFAULT_INITIALIZER(RGA_CURRENT_API_HEADER_VERSION);
|
||||
im_api_version_t version DEFAULT_INITIALIZER(RGA_CURRENT_API_HEADER_VERSION);
|
||||
|
||||
int color; /* color, used by color fill */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
int color; /* color, used by color fill */
|
||||
im_colorkey_range colorkey_range; /* range value of color key */
|
||||
im_nn_t nn;
|
||||
int rop_code;
|
||||
|
||||
int priority;
|
||||
int core;
|
||||
int priority;
|
||||
int core;
|
||||
|
||||
int mosaic_mode;
|
||||
int mosaic_mode;
|
||||
|
||||
im_osd_t osd_config;
|
||||
im_osd_t osd_config;
|
||||
|
||||
im_intr_config_t intr_config;
|
||||
im_intr_config_t intr_config;
|
||||
|
||||
char reserve[128];
|
||||
int interp;
|
||||
|
||||
char reserve[124];
|
||||
} im_opt_t;
|
||||
|
||||
typedef struct im_handle_param {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
} im_handle_param_t;
|
||||
|
||||
#define IM_INTERP_HORIZ(x) ( ((x) & IM_INTERP_MASK) << IM_INTERP_HORIZ_SHIFT | IM_INTERP_HORIZ_FLAG )
|
||||
#define IM_INTERP_VERTI(x) ( ((x) & IM_INTERP_MASK) << IM_INTERP_VERTI_SHIFT | IM_INTERP_VERTI_FLAG )
|
||||
#define IM_INTERP(h,v) ( IM_INTERP_HORIZ(h) | IM_INTERP_VERTI(v) )
|
||||
|
||||
#endif /* _RGA_IM2D_TYPE_H_ */
|
||||
|
||||
@@ -23,22 +23,27 @@
|
||||
#define RGA_VERSION_STR(x) RGA_VERSION_STR_HELPER(x)
|
||||
|
||||
/* RGA im2d api verison */
|
||||
#define RGA_API_MAJOR_VERSION 1
|
||||
#define RGA_API_MINOR_VERSION 9
|
||||
#define RGA_API_REVISION_VERSION 1
|
||||
#define RGA_API_BUILD_VERSION 0
|
||||
#define RGA_API_MAJOR_VERSION 1
|
||||
#define RGA_API_MINOR_VERSION 10
|
||||
#define RGA_API_REVISION_VERSION 1
|
||||
#define RGA_API_BUILD_VERSION 0
|
||||
|
||||
#define RGA_API_VERSION \
|
||||
RGA_VERSION_STR(RGA_API_MAJOR_VERSION) \
|
||||
"." RGA_VERSION_STR(RGA_API_MINOR_VERSION) "." RGA_VERSION_STR( \
|
||||
RGA_API_REVISION_VERSION) "_[" RGA_VERSION_STR(RGA_API_BUILD_VERSION) "]"
|
||||
#define RGA_API_FULL_VERSION "rga_api version " RGA_API_VERSION
|
||||
#define RGA_API_SUFFIX
|
||||
|
||||
#define RGA_API_VERSION \
|
||||
RGA_VERSION_STR(RGA_API_MAJOR_VERSION) "." \
|
||||
RGA_VERSION_STR(RGA_API_MINOR_VERSION) "." \
|
||||
RGA_VERSION_STR(RGA_API_REVISION_VERSION) "_[" \
|
||||
RGA_VERSION_STR(RGA_API_BUILD_VERSION) "]"
|
||||
#define RGA_API_FULL_VERSION "rga_api version " RGA_API_VERSION RGA_API_SUFFIX
|
||||
|
||||
/* For header file version verification */
|
||||
#define RGA_CURRENT_API_VERSION \
|
||||
((RGA_API_MAJOR_VERSION & 0xff) << 24 | \
|
||||
(RGA_API_MINOR_VERSION & 0xff) << 16 | \
|
||||
(RGA_API_REVISION_VERSION & 0xff) << 8 | (RGA_API_BUILD_VERSION & 0xff))
|
||||
#define RGA_CURRENT_API_VERSION (\
|
||||
(RGA_API_MAJOR_VERSION & 0xff) << 24 | \
|
||||
(RGA_API_MINOR_VERSION & 0xff) << 16 | \
|
||||
(RGA_API_REVISION_VERSION & 0xff) << 8 | \
|
||||
(RGA_API_BUILD_VERSION & 0xff)\
|
||||
)
|
||||
#define RGA_CURRENT_API_HEADER_VERSION RGA_CURRENT_API_VERSION
|
||||
|
||||
#endif /* _RGA_IM2D_VERSION_H_ */
|
||||
|
||||
@@ -19,114 +19,166 @@
|
||||
#ifndef _RGA_DRIVER_H_
|
||||
#define _RGA_DRIVER_H_
|
||||
|
||||
#ifndef ENABLE
|
||||
#define ENABLE 1
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE
|
||||
#define DISABLE 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* In order to be compatible with RK_FORMAT_XX and HAL_PIXEL_FORMAT_XX,
|
||||
* RK_FORMAT_XX is shifted to the left by 8 bits to distinguish. */
|
||||
typedef enum _Rga_SURF_FORMAT {
|
||||
RK_FORMAT_RGBA_8888 = 0x0 << 8,
|
||||
RK_FORMAT_RGBX_8888 = 0x1 << 8,
|
||||
RK_FORMAT_RGB_888 = 0x2 << 8,
|
||||
RK_FORMAT_BGRA_8888 = 0x3 << 8,
|
||||
RK_FORMAT_RGB_565 = 0x4 << 8,
|
||||
RK_FORMAT_RGBA_5551 = 0x5 << 8,
|
||||
RK_FORMAT_RGBA_4444 = 0x6 << 8,
|
||||
RK_FORMAT_BGR_888 = 0x7 << 8,
|
||||
RK_FORMAT_RGBA_8888 = 0x0 << 8, /* [0:31] R:G:B:A 8:8:8:8 little endian */
|
||||
RK_FORMAT_RGBX_8888 = 0x1 << 8, /* [0:31] R:G:B:X 8:8:8:8 little endian */
|
||||
RK_FORMAT_RGB_888 = 0x2 << 8, /* [0:23] R:G:B 8:8:8 little endian */
|
||||
RK_FORMAT_BGRA_8888 = 0x3 << 8, /* [0:31] B:G:R:A 8:8:8:8 little endian */
|
||||
RK_FORMAT_RGB_565 = 0x4 << 8, /* [0:15] R:G:B 5:6:5 little endian */
|
||||
RK_FORMAT_RGBA_5551 = 0x5 << 8, /* [0:15] R:G:B:A 5:5:5:1 little endian */
|
||||
RK_FORMAT_RGBA_4444 = 0x6 << 8, /* [0:15] R:G:B:A 4:4:4:4 little endian */
|
||||
RK_FORMAT_BGR_888 = 0x7 << 8, /* [0:23] B:G:R 8:8:8 little endian */
|
||||
|
||||
RK_FORMAT_YCbCr_422_SP = 0x8 << 8,
|
||||
RK_FORMAT_YCbCr_422_P = 0x9 << 8,
|
||||
RK_FORMAT_YCbCr_420_SP = 0xa << 8,
|
||||
RK_FORMAT_YCbCr_420_P = 0xb << 8,
|
||||
RK_FORMAT_YCbCr_422_SP = 0x8 << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: 2x1 subsampled [0:15] Cb:Cr 8:8 */
|
||||
RK_FORMAT_YCbCr_422_P = 0x9 << 8, /* 3 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: 2x1 subsampled [0:7] Cb
|
||||
* plane 2: 2x1 subsampled [0:7] Cr */
|
||||
RK_FORMAT_YCbCr_420_SP = 0xa << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: 2x2 subsampled [0:15] Cr:Cb 8:8 */
|
||||
RK_FORMAT_YCbCr_420_P = 0xb << 8, /* 3 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: 2x2 subsampled [0:7] Cb
|
||||
* plane 2: 2x2 subsampled [0:7] Cr */
|
||||
|
||||
RK_FORMAT_YCrCb_422_SP = 0xc << 8,
|
||||
RK_FORMAT_YCrCb_422_P = 0xd << 8,
|
||||
RK_FORMAT_YCrCb_420_SP = 0xe << 8,
|
||||
RK_FORMAT_YCrCb_420_P = 0xf << 8,
|
||||
RK_FORMAT_YCrCb_422_SP = 0xc << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: 2x1 subsampled [0:15] Cb:Cr 8:8 */
|
||||
RK_FORMAT_YCrCb_422_P = 0xd << 8, /* 3 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: 2x1 subsampled [0:7] Cr
|
||||
* plane 2: 2x1 subsampled [0:7] Cb */
|
||||
RK_FORMAT_YCrCb_420_SP = 0xe << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: 2x2 subsampled [0:15] Cb:Cr 8:8 */
|
||||
RK_FORMAT_YCrCb_420_P = 0xf << 8, /* 3 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: 2x2 subsampled [0:7] Cr
|
||||
* plane 2: 2x2 subsampled [0:7] Cb */
|
||||
|
||||
RK_FORMAT_BPP1 = 0x10 << 8,
|
||||
RK_FORMAT_BPP2 = 0x11 << 8,
|
||||
RK_FORMAT_BPP4 = 0x12 << 8,
|
||||
RK_FORMAT_BPP8 = 0x13 << 8,
|
||||
RK_FORMAT_BPP1 = 0x10 << 8, /* [0] little endian */
|
||||
RK_FORMAT_BPP2 = 0x11 << 8, /* [0:1] little endian */
|
||||
RK_FORMAT_BPP4 = 0x12 << 8, /* [0:3] little endian */
|
||||
RK_FORMAT_BPP8 = 0x13 << 8, /* [0:7] little endian */
|
||||
|
||||
RK_FORMAT_Y4 = 0x14 << 8,
|
||||
RK_FORMAT_YCbCr_400 = 0x15 << 8,
|
||||
RK_FORMAT_Y4 = 0x14 << 8, /* [0:3] Y little endian */
|
||||
RK_FORMAT_YCbCr_400 = 0x15 << 8, /* [0:7] Y little endian */
|
||||
|
||||
RK_FORMAT_BGRX_8888 = 0x16 << 8,
|
||||
RK_FORMAT_BGRX_8888 = 0x16 << 8, /* [0:31] B:G:R:X 8:8:8:8 little endian */
|
||||
|
||||
RK_FORMAT_YVYU_422 = 0x18 << 8,
|
||||
RK_FORMAT_YVYU_420 = 0x19 << 8,
|
||||
RK_FORMAT_VYUY_422 = 0x1a << 8,
|
||||
RK_FORMAT_VYUY_420 = 0x1b << 8,
|
||||
RK_FORMAT_YUYV_422 = 0x1c << 8,
|
||||
RK_FORMAT_YUYV_420 = 0x1d << 8,
|
||||
RK_FORMAT_UYVY_422 = 0x1e << 8,
|
||||
RK_FORMAT_UYVY_420 = 0x1f << 8,
|
||||
RK_FORMAT_YVYU_422 = 0x18 << 8, /* [0:31] Y0:Cr0:Y1:cb0 8:8:8:8 little endian */
|
||||
RK_FORMAT_YVYU_420 = 0x19 << 8, /* ODD : [0:31] Y0:Cr0:Y1:cb0 8:8:8:8 little endian
|
||||
* EVEN: [0:31] Y2:Y3:X:X 8:8:8:8 little endian */
|
||||
RK_FORMAT_VYUY_422 = 0x1a << 8, /* [0:31] Cr0:Y0:Cb0:Y1 8:8:8:8 little endian */
|
||||
RK_FORMAT_VYUY_420 = 0x1b << 8, /* ODD : [0:31] Cr0:Y0:Cb0:Y1 8:8:8:8 little endian
|
||||
* EVEN: [0:31] Y2:Y3:X:X 8:8:8:8 little endian */
|
||||
RK_FORMAT_YUYV_422 = 0x1c << 8, /* [0:31] Y0:Cb0:Y1:cr0 8:8:8:8 little endian */
|
||||
RK_FORMAT_YUYV_420 = 0x1d << 8, /* ODD : [0:31] Y0:Cb0:Y1:cr0 8:8:8:8 little endian
|
||||
* EVEN: [0:31] Y2:Y3:X:X 8:8:8:8 little endian */
|
||||
RK_FORMAT_UYVY_422 = 0x1e << 8, /* [0:31] Cb0:Y0:Cr0:Y1 8:8:8:8 little endian */
|
||||
RK_FORMAT_UYVY_420 = 0x1f << 8, /* ODD : [0:31] Cb0:Y0:Cr0:Y1 8:8:8:8 little endian
|
||||
* EVEN: [0:31] Y2:Y3:X:X 8:8:8:8 little endian */
|
||||
|
||||
RK_FORMAT_YCbCr_420_SP_10B = 0x20 << 8,
|
||||
RK_FORMAT_YCrCb_420_SP_10B = 0x21 << 8,
|
||||
RK_FORMAT_YCbCr_422_SP_10B = 0x22 << 8,
|
||||
RK_FORMAT_YCrCb_422_SP_10B = 0x23 << 8,
|
||||
/* For compatibility with misspellings */
|
||||
RK_FORMAT_YCbCr_422_10b_SP = RK_FORMAT_YCbCr_422_SP_10B,
|
||||
RK_FORMAT_YCrCb_422_10b_SP = RK_FORMAT_YCrCb_422_SP_10B,
|
||||
RK_FORMAT_YCbCr_420_SP_10B = 0x20 << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:9] Y
|
||||
* plane 1: 2x2 subsampled [0:19] Cb:Cr 10: 10 (default)
|
||||
* or
|
||||
* plane 1: 2x2 subsampled [0:23] Cb:Cr 16: 16 */
|
||||
RK_FORMAT_YCrCb_420_SP_10B = 0x21 << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:9] Y
|
||||
* plane 1: 2x2 subsampled [0:19] Cr:Cb 10: 10 (default)
|
||||
* or
|
||||
* plane 1: 2x2 subsampled [0:23] Cr:Cb 16: 16 */
|
||||
RK_FORMAT_YCbCr_422_SP_10B = 0x22 << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:9] Y
|
||||
* plane 1: 2x1 subsampled [0:19] Cb:Cr 10:10 (default)
|
||||
* or
|
||||
* plane 1: 2x1 subsampled [0:23] Cb:Cr 16: 16 */
|
||||
RK_FORMAT_YCrCb_422_SP_10B = 0x23 << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:9] Y
|
||||
* plane 1: 2x1 subsampled [0:19] Cr:Cb 10:10 (default)
|
||||
* or
|
||||
* plane 1: 2x1 subsampled [0:23] Cr:Cb 16: 16 */
|
||||
/* For compatibility with misspellings */
|
||||
RK_FORMAT_YCbCr_422_10b_SP = RK_FORMAT_YCbCr_422_SP_10B << 8,
|
||||
RK_FORMAT_YCrCb_422_10b_SP = RK_FORMAT_YCrCb_422_SP_10B << 8,
|
||||
|
||||
RK_FORMAT_BGR_565 = 0x24 << 8,
|
||||
RK_FORMAT_BGRA_5551 = 0x25 << 8,
|
||||
RK_FORMAT_BGRA_4444 = 0x26 << 8,
|
||||
RK_FORMAT_BGR_565 = 0x24 << 8, /* [0:16] B:G:R 5:6:5 little endian */
|
||||
RK_FORMAT_BGRA_5551 = 0x25 << 8, /* [0:16] B:G:R:A 5:5:5:1 little endian */
|
||||
RK_FORMAT_BGRA_4444 = 0x26 << 8, /* [0:16] B:G:R:A 4:4:4:4 little endian */
|
||||
|
||||
RK_FORMAT_ARGB_8888 = 0x28 << 8,
|
||||
RK_FORMAT_XRGB_8888 = 0x29 << 8,
|
||||
RK_FORMAT_ARGB_5551 = 0x2a << 8,
|
||||
RK_FORMAT_ARGB_4444 = 0x2b << 8,
|
||||
RK_FORMAT_ABGR_8888 = 0x2c << 8,
|
||||
RK_FORMAT_XBGR_8888 = 0x2d << 8,
|
||||
RK_FORMAT_ABGR_5551 = 0x2e << 8,
|
||||
RK_FORMAT_ABGR_4444 = 0x2f << 8,
|
||||
RK_FORMAT_ARGB_8888 = 0x28 << 8, /* [0:31] A:R:G:B 8:8:8:8 little endian */
|
||||
RK_FORMAT_XRGB_8888 = 0x29 << 8, /* [0:31] X:R:G:B 8:8:8:8 little endian */
|
||||
RK_FORMAT_ARGB_5551 = 0x2a << 8, /* [0:16] A:R:G:B 5:5:5:1 little endian */
|
||||
RK_FORMAT_ARGB_4444 = 0x2b << 8, /* [0:16] A:R:G:B 4:4:4:4 little endian */
|
||||
RK_FORMAT_ABGR_8888 = 0x2c << 8, /* [0:31] A:B:G:R 8:8:8:8 little endian */
|
||||
RK_FORMAT_XBGR_8888 = 0x2d << 8, /* [0:31] X:B:G:R 8:8:8:8 little endian */
|
||||
RK_FORMAT_ABGR_5551 = 0x2e << 8, /* [0:16] A:B:G:R 5:5:5:1 little endian */
|
||||
RK_FORMAT_ABGR_4444 = 0x2f << 8, /* [0:16] A:B:G:R 4:4:4:4 little endian */
|
||||
|
||||
RK_FORMAT_RGBA2BPP = 0x30 << 8,
|
||||
RK_FORMAT_RGBA2BPP = 0x30 << 8, /* [0:1] Color:Alpha 1:1 little endian */
|
||||
RK_FORMAT_A8 = 0x31 << 8, /* [0:7] Alpha */
|
||||
|
||||
RK_FORMAT_UNKNOWN = 0x100 << 8,
|
||||
RK_FORMAT_YCbCr_444_SP = 0x32 << 8, /* 2 plane YCbCr little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: non-subsampled [0:15] Cb:Cr 8:8 */
|
||||
RK_FORMAT_YCrCb_444_SP = 0x33 << 8, /* 2 plane YCrCb little endian
|
||||
* plane 0: [0:7] Y
|
||||
* plane 1: non-subsampled [0:15] Cr:Cb 8:8 */
|
||||
RK_FORMAT_Y8 = 0x34 << 8, /* [0:7] zero:Y 4:4 little endian */
|
||||
|
||||
RK_FORMAT_UNKNOWN = 0x100 << 8,
|
||||
} RgaSURF_FORMAT;
|
||||
|
||||
enum {
|
||||
yuv2rgb_mode0 = 0x0, /* BT.601 MPEG */
|
||||
yuv2rgb_mode1 = 0x1, /* BT.601 JPEG */
|
||||
yuv2rgb_mode2 = 0x2, /* BT.709 */
|
||||
yuv2rgb_mode0 = 0x0, /* BT.601 MPEG */
|
||||
yuv2rgb_mode1 = 0x1, /* BT.601 JPEG */
|
||||
yuv2rgb_mode2 = 0x2, /* BT.709 */
|
||||
|
||||
rgb2yuv_601_full = 0x1 << 8,
|
||||
rgb2yuv_709_full = 0x2 << 8,
|
||||
yuv2yuv_601_limit_2_709_limit = 0x3 << 8,
|
||||
yuv2yuv_601_limit_2_709_full = 0x4 << 8,
|
||||
yuv2yuv_709_limit_2_601_limit = 0x5 << 8,
|
||||
yuv2yuv_709_limit_2_601_full = 0x6 << 8, // not support
|
||||
yuv2yuv_601_full_2_709_limit = 0x7 << 8,
|
||||
yuv2yuv_601_full_2_709_full = 0x8 << 8, // not support
|
||||
yuv2yuv_709_full_2_601_limit = 0x9 << 8, // not support
|
||||
yuv2yuv_709_full_2_601_full = 0xa << 8, // not support
|
||||
full_csc_mask = 0xf00,
|
||||
rgb2yuv_601_full = 0x1 << 8,
|
||||
rgb2yuv_709_full = 0x2 << 8,
|
||||
yuv2yuv_601_limit_2_709_limit = 0x3 << 8,
|
||||
yuv2yuv_601_limit_2_709_full = 0x4 << 8,
|
||||
yuv2yuv_709_limit_2_601_limit = 0x5 << 8,
|
||||
yuv2yuv_709_limit_2_601_full = 0x6 << 8, //not support
|
||||
yuv2yuv_601_full_2_709_limit = 0x7 << 8,
|
||||
yuv2yuv_601_full_2_709_full = 0x8 << 8, //not support
|
||||
yuv2yuv_709_full_2_601_limit = 0x9 << 8, //not support
|
||||
yuv2yuv_709_full_2_601_full = 0xa << 8, //not support
|
||||
rgb2yuv_709_limit = 0xb << 8,
|
||||
yuv2rgb_709_full = 0xc << 8, //not support
|
||||
yuv2yuv_601_limit_2_601_full = 0xd << 8, //not support
|
||||
yuv2yuv_601_full_2_601_limit = 0xe << 8, //not support
|
||||
yuv2yuv_709_limit_2_709_full = 0xf << 8, //not support
|
||||
yuv2yuv_709_full_2_709_limit = 0x10 << 8, //not support
|
||||
full_csc_mask = 0xf00,
|
||||
};
|
||||
|
||||
enum {
|
||||
RGA3_SCHEDULER_CORE0 = 1 << 0,
|
||||
RGA3_SCHEDULER_CORE1 = 1 << 1,
|
||||
RGA2_SCHEDULER_CORE0 = 1 << 2,
|
||||
RGA3_SCHEDULER_CORE0 = 1 << 0,
|
||||
RGA3_SCHEDULER_CORE1 = 1 << 1,
|
||||
RGA2_SCHEDULER_CORE0 = 1 << 2,
|
||||
RGA2_SCHEDULER_CORE1 = 1 << 3,
|
||||
RGA_CORE_MASK = 0xf,
|
||||
RGA_NONE_CORE = 0x0,
|
||||
};
|
||||
|
||||
/* RGA3 rd_mode */
|
||||
enum {
|
||||
raster_mode = 0x1 << 0,
|
||||
fbc_mode = 0x1 << 1,
|
||||
tile_mode = 0x1 << 2,
|
||||
enum
|
||||
{
|
||||
raster_mode = 0x1 << 0,
|
||||
fbc_mode = 0x1 << 1,
|
||||
tile_mode = 0x1 << 2,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,10 +1,8 @@
|
||||
commit 6dcee5b53480cb16bc41d17c5fb0b6253d9872e3
|
||||
commit 8f3e18eb5b18c14c90f6e2f8468e506fd0b52fb5
|
||||
Author: Yu Qiaowei <cerf.yu@rock-chips.com>
|
||||
Date: Tue Sep 27 21:09:26 2022 +0800
|
||||
Date: Wed Apr 3 18:19:48 2024 +0800
|
||||
|
||||
im2d_api: support RK3562
|
||||
|
||||
version: 1.9.1_[0]
|
||||
docs: FAQ: fix network disk link cannot be opened
|
||||
|
||||
Signed-off-by: Yu Qiaowei <cerf.yu@rock-chips.com>
|
||||
Change-Id: I8d6515a1ec61c202a3a198618925c438c6c8076b
|
||||
Change-Id: I6ffd4741ee473738e862670450943b2c09206301
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
add_subdirectory(allocator_demo)
|
||||
add_subdirectory(alpha_demo)
|
||||
add_subdirectory(async_demo)
|
||||
add_subdirectory(config_demo)
|
||||
add_subdirectory(copy_demo)
|
||||
add_subdirectory(crop_demo)
|
||||
add_subdirectory(cvtcolor_demo)
|
||||
add_subdirectory(fill_demo)
|
||||
add_subdirectory(mosaic_demo)
|
||||
add_subdirectory(padding_demo)
|
||||
add_subdirectory(resize_demo)
|
||||
add_subdirectory(rop_demo)
|
||||
add_subdirectory(transform_demo)
|
||||
@@ -0,0 +1,175 @@
|
||||
# librga IM2D API 示例代码说明
|
||||
|
||||
该目录下为librga IM2D API示例代码,包含常见的图像缩放、裁剪、旋转、Blit、alpha混合等操作的示例代码。
|
||||
|
||||
## 目录说明
|
||||
|
||||
├── **im2d_api_demo**:IM2D API快速演示DEMO<br/>
|
||||
├── **im2d_slt**:slt测试工具<br/>
|
||||
├── **allocator_demo**:内存分配器相关示例代码<br/>
|
||||
│ └── **src**
|
||||
│ ├── **rga_allocator_1106_cma_demo.cpp**:RV1106没有搭载IOMMU,须分配物理连续内存调用RGA,该平台CMA节点路径与其他平台不同。<br/>
|
||||
│ ├── **rga_allocator_dma32_demo.cpp**:使用dma_heap分配4G以内内存空间的内存(不保证物理连续)调用RGA。<br/>
|
||||
│ ├── **rga_allocator_dma_cache_demo.cpp**:使用dma_heap分配cacheable的内存调用RGA。<br/>
|
||||
│ ├── **rga_allocator_dma_demo.cpp**:使用dma_heap分配内存调用RGA。<br/>
|
||||
│ ├── **rga_allocator_drm_demo.cpp**:使用DRM分配内存调用RGA。<br/>
|
||||
│ ├── **rga_allocator_drm_phy_demo.cpp**:使用DRM分配物理连续的内存调用RGA。<br/>
|
||||
│ ├── **rga_allocator_graphicbuffer_demo.cpp**:使用GraphicBuffer分配4G内存空间以内的内存调用RGA。<br/>
|
||||
│ └── **rga_allocator_malloc_demo.cpp**:使用malloc分配虚拟地址调用RGA。<br/>
|
||||
├── **alpha_demo**:alpha混合、叠加相关示例代码<br/>
|
||||
│ └── **src**
|
||||
│ ├── **rga_alpha_3channel_demo.cpp**:调用RGA实现三通道alpha叠加。<br/>
|
||||
│ ├── **rga_alpha_colorkey_demo.cpp**:调用RGA实现colorkey。<br/>
|
||||
│ ├── **rga_alpha_demo.cpp**:调用RGA实现双通道alpha叠加。<br/>
|
||||
│ ├── **rga_alpha_osd_demo.cpp**:调用RGA实现常见OSD场景<br/>
|
||||
│ └── **rga_alpha_yuv_demo.cpp**:调用RGA实现RGBA图像与YUV图像alpha叠加。<br/>
|
||||
├── **async_demo**:异步模式相关示例代码<br/>
|
||||
├── **config_demo**:线程全局配置相关示例代码<br/>
|
||||
│ └── **src**
|
||||
│ ├── **rga_config_single_core_demo.cpp**:指定核心执行当前RGA任务。<br/>
|
||||
│ └── **rga_config_thread_core_demo.cpp**:当前线程均指定核心执行RGA任务。<br/>
|
||||
├── **copy_demo**:图像搬运、拷贝相关示例代码<br/>
|
||||
│ └── **src**
|
||||
│ ├── **rga_copy_demo.cpp**:调用RGA实现图像拷贝。<br/>
|
||||
│ ├── **rga_copy_fbc_demo.cpp**:调用RGA实现FBC图像拷贝。<br/>
|
||||
│ ├── **rga_copy_tile8x8_demo.cpp**:调用RGA实现tile8*8图像拷贝。<br/>
|
||||
│ ├── **rga_copy_splice_demo.cpp**:调用RGA实现图像拼接。<br/>
|
||||
│ └── **rga_copy_splice_task_demo.cpp**:批处理方式调用RGA实现图像拼接。<br/>
|
||||
├── **crop_demo**:图像裁剪、拼接相关示例代码<br/>
|
||||
│ └──** src**
|
||||
│ ├── **rga_crop_demo.cpp**:调用RGA实现图像裁剪。<br/>
|
||||
│ └── **rga_crop_rect_demo.cpp**:调用RGA实现裁剪源图像并输出到目标图像上某一区域。<br/>
|
||||
├── **cvtcolor_demo**:图像格式转换、色域转换相关示例代码<br/>
|
||||
│ └── **src**
|
||||
│ ├── **rga_cvtcolor_demo.cpp**:调用RGA实现图像格式转换。<br/>
|
||||
│ ├── **rga_cvtcolor_csc_demo.cpp**:调用RGA指定色域空间转换配置实现图像格式转换。<br/>
|
||||
│ └── **rga_cvtcolor_gray256_demo.cpp**:调用RGA实现256阶灰度图转换。<br/>
|
||||
├── **fill_demo**:图像填充、画框相关示例代码<br/>
|
||||
│ └── **src**
|
||||
│ ├── **rga_fill_demo.cpp**:调用RGA实现颜色填充。<br/>
|
||||
│ ├── **rga_fill_rectangle_demo.cpp**:调用RGA实现矩形框绘制。<br/>
|
||||
│ ├── **rga_fill_rectangle_array_demo.cpp**:调用RGA实现多个矩形框绘制。<br/>
|
||||
│ ├── **rga_fill_rectangle_task_demo.cpp**:批处理方式调用RGA实现矩形框绘制。<br/>
|
||||
│ └── **rga_fill_rectangle_task_array_demo.cpp**:批处理方式调用RGA实现多个矩形框绘制。<br/>
|
||||
├── **mosaic_demo**:马赛克遮盖相关示例代码<br/>
|
||||
├── **padding_demo**:padding相关示例代码<br/>
|
||||
├── **resize_demo**:图像缩放相关示例代码<br/>
|
||||
│ └── **src**
|
||||
│ ├── **rga_resize_demo.cpp**:调用RGA实现图像缩放。<br/>
|
||||
│ ├── **rga_resize_rect_demo.cpp**:调用RGA实现源图像缩放并输出到目标图像指定区域。<br/>
|
||||
│ └── **rga_resize_uv_downsampling_demo.cpp**:调用RGA实现YUV422均值降采样到YUV420。<br/>
|
||||
├── **rop_demo**:ROP运算相关示例代码<br/>
|
||||
├── **transform_demo**:图像变换相关示例代码<br/>
|
||||
│ └── **src**
|
||||
│ ├── **rga_transform_flip_demo.cpp**:调用RGA实现图像镜像。<br/>
|
||||
│ ├── **rga_transform_rotate_demo.cpp**:调用RGA实现图像旋转。<br/>
|
||||
│ └── **rga_transform_rotate_flip_demo.cpp**:调用RGA实现图像镜像同事旋转。<br/>
|
||||
├── **utils**:示例代码中使用的第三方引用、通用工具代码<br/>
|
||||
└── **sample_file**:演示代码使用图像数据文件<br/>
|
||||
|
||||
## 编译说明
|
||||
|
||||
本仓库示例代码支持CMAKE编译,可以通过修改toolchain_*.cmake文件以及编译脚本实现快速编译。
|
||||
|
||||
### 工具链修改
|
||||
|
||||
- **Android NDK(build for android)**
|
||||
|
||||
参考librga源码目录下**toolchains/toolchain_android_ndk.cmake**写法,修改NDK路径、Android版本信息等。
|
||||
|
||||
| 工具链选项 | 描述 |
|
||||
| ----------------------------------- | -------------------------------------------- |
|
||||
| CMAKE_ANDROID_NDK | NDK编译包路径 |
|
||||
| CMAKE_SYSTEM_NAME | 平台名,默认为Android |
|
||||
| CMAKE_SYSTEM_VERSION | Android版本 |
|
||||
| CMAKE_ANDROID_ARCH_ABI | 处理器版本 |
|
||||
| CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION | 工具链选择(clang/gcc) |
|
||||
| CMAKE_ANDROID_STL_TYPE | NDK C++库的链接方式(c++_static/c++_shared) |
|
||||
|
||||
- **Linux(buildroot/debian)**
|
||||
|
||||
参考librga源码目录下**toolchains/toolchain_linux.cmake**写法,修改工具链路径、名称。
|
||||
|
||||
| 工具链选项 | 描述 |
|
||||
| -------------- | ---------- |
|
||||
| TOOLCHAIN_HOME | 工具链目录 |
|
||||
| TOOLCHAIN_NAME | 工具链名称 |
|
||||
|
||||
### 编译脚本修改
|
||||
|
||||
修改samples目录或需要编译的示例代码目录下**cmake_*.sh**,指定toolchain路径。
|
||||
|
||||
| 编译选项 | 描述 |
|
||||
| -------------- | ------------------------------------------------------------ |
|
||||
| TOOLCHAIN_PATH | toolchain的绝对路径,即《工具链修改》小节中修改后的toolchain_*.cmake文件的绝对路径 |
|
||||
| LIBRGA_PATH | 需要链接的librga.so的绝对路径,默认为librga cmake编译时的默认打包路径 |
|
||||
| BUILD_DIR | 编译生成文件存放的相对路径 |
|
||||
|
||||
### 执行编译脚本
|
||||
|
||||
- **Android NDK(build for android)**
|
||||
|
||||
```bash
|
||||
$ chmod +x ./cmake_android.sh
|
||||
$ ./cmake_android.sh
|
||||
```
|
||||
|
||||
- **Linux(buildroot/debian)**
|
||||
|
||||
```bash
|
||||
$ chmod +x ./cmake_linux.sh
|
||||
$ ./cmake_linux.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 测试文件说明
|
||||
|
||||
### 示例文件
|
||||
|
||||
用于测试的输入与输出二进制文件需提前准备好,在/sample/sample_file目录下,存放着默认的RGBA8888格式的源图像文件可以直接使用。
|
||||
|
||||
### 路径说明
|
||||
|
||||
在示例代码中,可以通过配置以下宏定义来修改读取图像文件的路径:
|
||||
|
||||
| 宏定义 | 描述 |
|
||||
| --------------- | ------------------------------------------------------------ |
|
||||
| LOCAL_FILE_PATH | read_image_from_file/write_image_to_file函数第二个传参,用于描述当前读/写示例文件的路径,默认路径为"/data" |
|
||||
|
||||
### 示例文件名说明
|
||||
|
||||
文件命名规则如下:
|
||||
|
||||
```
|
||||
in%dw%d-h%d-%s.bin
|
||||
out%dw%d-h%d-%s.bin
|
||||
|
||||
示例:
|
||||
1280×720 RGBA8888的输入图像: in0w1280-h720-rgba8888.bin
|
||||
1280×720 RGBA8888的输出图像: out0w1280-h720-rgba8888.bin
|
||||
```
|
||||
|
||||
参数解释如下:
|
||||
|
||||
> 输入文件为 in , 输出文件为 out
|
||||
> --->第一个%d 是文件的索引, 一般为 0, 用于区别格式及宽高完全相同的文件
|
||||
> --->第二个%d 是宽的意思, 这里的宽一般指虚宽
|
||||
> --->第三个%d 是高的意思, 这里的高一般指虚高
|
||||
> --->第四个%s 是格式的名字。
|
||||
>
|
||||
> 预置测试的部分常用图像格式如下,其他格式对应字符串名可以查看rgaUtils.cpp中查看:
|
||||
|
||||
| format(Android) | format(Linux) | name |
|
||||
| :-------------------------------- | -------------------------- | ----------- |
|
||||
| HAL_PIXEL_FORMAT_RGB_565 | RK_FORMAT_RGB_565 | "rgb565" |
|
||||
| HAL_PIXEL_FORMAT_RGB_888 | RK_FORMAT_RGB_888 | "rgb888" |
|
||||
| HAL_PIXEL_FORMAT_RGBA_8888 | RK_FORMAT_RGBA_8888 | "rgba8888" |
|
||||
| HAL_PIXEL_FORMAT_RGBX_8888 | RK_FORMAT_RGBX_8888 | "rgbx8888" |
|
||||
| HAL_PIXEL_FORMAT_BGRA_8888 | RK_FORMAT_BGRA_8888 | "bgra8888" |
|
||||
| HAL_PIXEL_FORMAT_YCrCb_420_SP | RK_FORMAT_YCrCb_420_SP | "crcb420sp" |
|
||||
| HAL_PIXEL_FORMAT_YCrCb_NV12 | RK_FORMAT_YCbCr_420_SP | "nv12" |
|
||||
| HAL_PIXEL_FORMAT_YCrCb_NV12_VIDEO | / | "nv12" |
|
||||
| HAL_PIXEL_FORMAT_YCrCb_NV12_10 | RK_FORMAT_YCbCr_420_SP_10B | "nv12_10" |
|
||||
|
||||
> 通常demo中默认配置的输入图像分辨率为1280x720,格式为RGBA8888。因此需在对应配置的读文件路径下提前准备好in0w1280-h720-rgba8888.bin的源图像文件,图像合成模式还需额外准备好名为in1w1280-h720-rgba8888.bin的源图像文件。
|
||||
@@ -0,0 +1,44 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
#======================================================================
|
||||
#
|
||||
# rga_allocator_graphicbuffer_demo
|
||||
#
|
||||
#======================================================================
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
|
||||
LOCAL_CFLAGS += -Wall -Werror -Wunreachable-code
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
hardware/rockchip/librga \
|
||||
hardware/rockchip/librga/include \
|
||||
hardware/rockchip/librga/im2d_api
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
hardware/rockchip/librga/samples/utils \
|
||||
hardware/rockchip/librga/samples/3rdparty \
|
||||
hardware/rockchip/librga/samples/3rdparty/libdrm/include \
|
||||
hardware/rockchip/librga/samples/3rdparty/libdrm/include/libdrm \
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libui \
|
||||
libutils \
|
||||
librga
|
||||
|
||||
LOCAL_HEADER_LIBRARIES += \
|
||||
libhardware_headers \
|
||||
libgui_headers \
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
../utils/utils.cpp \
|
||||
src/rga_allocator_graphicbuffer_demo.cpp
|
||||
|
||||
LOCAL_MODULE:= \
|
||||
rga_allocator_graphicbuffer_demo
|
||||
|
||||
ifdef TARGET_32_BIT_SURFACEFLINGER
|
||||
LOCAL_32_BIT_ONLY := true
|
||||
endif
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${LIBRGA_FILE_LIB}/librga.so)
|
||||
message("load ${LIBRGA_FILE_LIB}/librga.so")
|
||||
set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so)
|
||||
else ()
|
||||
set(RGA_LIB rga)
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
#install path
|
||||
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl")
|
||||
|
||||
set(RGA_INCLUDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api)
|
||||
include_directories(${RGA_INCLUDE})
|
||||
|
||||
if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt)
|
||||
endif()
|
||||
|
||||
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# Modify to the local toolchain path.
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux_1106.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux_1106/install/lib
|
||||
BUILD_DIR=build/build_linux_1106
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DTARGET_SOC=RV1106 \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,71 @@
|
||||
# rga_allocator_malloc_demo
|
||||
add_executable(rga_allocator_malloc_demo
|
||||
rga_allocator_malloc_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_allocator_malloc_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_allocator_malloc_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
if (TARGET_SOC STREQUAL "RV1106")
|
||||
# rga_allocator_dma32_demo
|
||||
add_executable(rga_allocator_1106_cma_demo
|
||||
rga_allocator_1106_cma_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_allocator_1106_cma_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_allocator_1106_cma_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
else ()
|
||||
# rga_allocator_drm_demo
|
||||
add_executable(rga_allocator_drm_demo
|
||||
rga_allocator_drm_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_allocator_drm_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_allocator_drm_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_allocator_drm_phy_demo
|
||||
add_executable(rga_allocator_drm_phy_demo
|
||||
rga_allocator_drm_phy_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_allocator_drm_phy_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_allocator_drm_phy_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_allocator_dma_demo
|
||||
add_executable(rga_allocator_dma_demo
|
||||
rga_allocator_dma_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_allocator_dma_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_allocator_dma_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_allocator_dma_cache_demo
|
||||
add_executable(rga_allocator_dma_cache_demo
|
||||
rga_allocator_dma_cache_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_allocator_dma_cache_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_allocator_dma_cache_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_allocator_dma32_demo
|
||||
add_executable(rga_allocator_dma32_demo
|
||||
rga_allocator_dma32_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_allocator_dma32_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_allocator_dma32_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_allocator_cma_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "im2d.h"
|
||||
#include "RgaUtils.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "dma_alloc.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main(void) {
|
||||
int ret = 0;
|
||||
int64_t ts;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int src_buf_size, dst_buf_size;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_dma_fd, dst_dma_fd;
|
||||
rga_buffer_t src = {};
|
||||
rga_buffer_t dst = {};
|
||||
im_rect src_rect = {};
|
||||
im_rect dst_rect = {};
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
/* Allocate dma_buf from CMA, return dma_fd and virtual address */
|
||||
ret = dma_buf_alloc(RV1106_CMA_HEAP_PATH, src_buf_size, &src_dma_fd, (void **)&src_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc src CMA buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = dma_buf_alloc(RV1106_CMA_HEAP_PATH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc dst CMA buffer failed!\n");
|
||||
dma_buf_free(src_buf_size, &src_dma_fd, src_buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0);
|
||||
if (ret < 0) {
|
||||
printf ("open file %s so memset!\n", "fault");
|
||||
draw_rgba((char *)src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x33, dst_buf_size);
|
||||
|
||||
/*
|
||||
* Import the allocated dma_fd into RGA by calling
|
||||
* importbuffer_fd, and use the returned buffer_handle
|
||||
* to call RGA to process the image.
|
||||
*/
|
||||
src_handle = importbuffer_fd(src_dma_fd, src_buf_size);
|
||||
dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("import dma_fd error!\n");
|
||||
ret = -1;
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
src = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src, dst, src_rect, dst_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ts = get_cur_us();
|
||||
|
||||
ret = imcopy(src, dst);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle > 0)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle > 0)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
free_buf:
|
||||
dma_buf_free(src_buf_size, &src_dma_fd, src_buf);
|
||||
dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_allocator_dma32_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "im2d.h"
|
||||
#include "RgaUtils.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "dma_alloc.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main(void) {
|
||||
int ret = 0;
|
||||
int64_t ts;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int dst_buf_size;
|
||||
char *dst_buf;
|
||||
int dst_dma_fd;
|
||||
rga_buffer_t dst = {};
|
||||
im_rect dst_rect = {};
|
||||
rga_buffer_handle_t dst_handle;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
/*
|
||||
* Allocate dma_buf within 4G from dma32_heap,
|
||||
* return dma_fd and virtual address.
|
||||
*/
|
||||
ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHED_PATH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc dma32_heap buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(dst_buf, 0x33, dst_buf_size);
|
||||
|
||||
/*
|
||||
* Import the allocated dma_fd into RGA by calling
|
||||
* importbuffer_fd, and use the returned buffer_handle
|
||||
* to call RGA to process the image.
|
||||
*/
|
||||
dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size);
|
||||
if (dst_handle == 0) {
|
||||
printf("import dma_fd error!\n");
|
||||
ret = -1;
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
dst_rect.x = 0;
|
||||
dst_rect.y = 0;
|
||||
dst_rect.width = 300;
|
||||
dst_rect.height = 200;
|
||||
|
||||
ret = imcheck({}, dst, {}, dst_rect, IM_COLOR_FILL);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ts = get_cur_us();
|
||||
|
||||
ret = imfill(dst, dst_rect, 0xff00ff00);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (dst_handle > 0)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
free_buf:
|
||||
dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_allocator_dma_cache_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "im2d.h"
|
||||
#include "RgaUtils.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "dma_alloc.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main(void) {
|
||||
int ret = 0;
|
||||
int64_t ts;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int src_buf_size, dst_buf_size;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_dma_fd, dst_dma_fd;
|
||||
rga_buffer_t src = {};
|
||||
rga_buffer_t dst = {};
|
||||
im_rect src_rect = {};
|
||||
im_rect dst_rect = {};
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
/* Allocate cacheable dma_buf, return dma_fd and virtual address. */
|
||||
ret = dma_buf_alloc(DMA_HEAP_PATH, src_buf_size, &src_dma_fd, (void **)&src_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc src dma_heap buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = dma_buf_alloc(DMA_HEAP_PATH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc dst dma_heap buffer failed!\n");
|
||||
dma_buf_free(src_buf_size, &src_dma_fd, src_buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0);
|
||||
if (ret < 0) {
|
||||
printf ("open file %s so memset!\n", "fault");
|
||||
draw_rgba((char *)src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x33, dst_buf_size);
|
||||
|
||||
/* clear CPU cache */
|
||||
dma_sync_cpu_to_device(src_dma_fd);
|
||||
dma_sync_cpu_to_device(dst_dma_fd);
|
||||
|
||||
/*
|
||||
* Import the allocated dma_fd into RGA by calling
|
||||
* importbuffer_fd, and use the returned buffer_handle
|
||||
* to call RGA to process the image.
|
||||
*/
|
||||
src_handle = importbuffer_fd(src_dma_fd, src_buf_size);
|
||||
dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("import dma_fd error!\n");
|
||||
ret = -1;
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
src = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src, dst, src_rect, dst_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ts = get_cur_us();
|
||||
|
||||
ret = imcopy(src, dst);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("Before flushing the cache [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
/* invalid CPU cache */
|
||||
dma_sync_device_to_cpu(src_dma_fd);
|
||||
dma_sync_device_to_cpu(dst_dma_fd);
|
||||
|
||||
printf("After flushing the cache [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 1);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle > 0)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle > 0)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
free_buf:
|
||||
dma_buf_free(src_buf_size, &src_dma_fd, src_buf);
|
||||
dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_allocator_dma_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "im2d.h"
|
||||
#include "RgaUtils.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "dma_alloc.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main(void) {
|
||||
int ret = 0;
|
||||
int64_t ts;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int src_buf_size, dst_buf_size;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_dma_fd, dst_dma_fd;
|
||||
rga_buffer_t src = {};
|
||||
rga_buffer_t dst = {};
|
||||
im_rect src_rect = {};
|
||||
im_rect dst_rect = {};
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
/* Allocate dma_buf, return dma_fd and virtual address. */
|
||||
ret = dma_buf_alloc(DMA_HEAP_UNCACHE_PATH, src_buf_size, &src_dma_fd, (void **)&src_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc src dma_heap buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = dma_buf_alloc(DMA_HEAP_UNCACHE_PATH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc dst dma_heap buffer failed!\n");
|
||||
dma_buf_free(src_buf_size, &src_dma_fd, src_buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0);
|
||||
if (ret < 0) {
|
||||
printf ("open file %s so memset!\n", "fault");
|
||||
draw_rgba((char *)src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x33, dst_buf_size);
|
||||
|
||||
/*
|
||||
* Import the allocated dma_fd into RGA by calling
|
||||
* importbuffer_fd, and use the returned buffer_handle
|
||||
* to call RGA to process the image.
|
||||
*/
|
||||
src_handle = importbuffer_fd(src_dma_fd, src_buf_size);
|
||||
dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("import dma_fd error!\n");
|
||||
ret = -1;
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
src = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src, dst, src_rect, dst_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ts = get_cur_us();
|
||||
|
||||
ret = imcopy(src, dst);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle > 0)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle > 0)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
free_buf:
|
||||
dma_buf_free(src_buf_size, &src_dma_fd, src_buf);
|
||||
dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_allocator_drm_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "im2d.h"
|
||||
#include "RgaUtils.h"
|
||||
|
||||
#include "drm_alloc.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
class DrmObject {
|
||||
public:
|
||||
int drm_buffer_fd;
|
||||
int drm_buffer_handle;
|
||||
size_t actual_size;
|
||||
uint8_t * drm_buf;
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
int ret = 0;
|
||||
int64_t ts;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int src_alloc_flags = 0, dst_alloc_flags = 0;
|
||||
rga_buffer_t src = {};
|
||||
rga_buffer_t dst = {};
|
||||
im_rect src_rect = {};
|
||||
im_rect dst_rect = {};
|
||||
DrmObject drm_src;
|
||||
DrmObject drm_dst;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
/* Allocate drm_buf, return dma_fd and virtual address. */
|
||||
drm_src.drm_buf = (uint8_t *)drm_buf_alloc(src_width, src_height,
|
||||
get_bpp_from_format(src_format) * 8,
|
||||
&drm_src.drm_buffer_fd,
|
||||
&drm_src.drm_buffer_handle,
|
||||
&drm_src.actual_size,
|
||||
src_alloc_flags);
|
||||
|
||||
drm_dst.drm_buf = (uint8_t *)drm_buf_alloc(dst_width, dst_height,
|
||||
get_bpp_from_format(dst_format) * 8,
|
||||
&drm_dst.drm_buffer_fd,
|
||||
&drm_dst.drm_buffer_handle,
|
||||
&drm_dst.actual_size,
|
||||
dst_alloc_flags);
|
||||
if (drm_src.drm_buf == NULL || drm_dst.drm_buf == NULL) {
|
||||
printf("alloc drm buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = read_image_from_file(drm_src.drm_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0);
|
||||
if (ret < 0) {
|
||||
printf ("open file %s so memset!\n", "fault");
|
||||
draw_rgba((char *)drm_src.drm_buf, src_width, src_height);
|
||||
}
|
||||
memset(drm_dst.drm_buf, 0x33, drm_dst.actual_size);
|
||||
|
||||
/*
|
||||
* Import the allocated dma_fd into RGA by calling
|
||||
* importbuffer_fd, and use the returned buffer_handle
|
||||
* to call RGA to process the image.
|
||||
*/
|
||||
src_handle = importbuffer_fd(drm_src.drm_buffer_fd, drm_src.actual_size);
|
||||
dst_handle = importbuffer_fd(drm_dst.drm_buffer_fd, drm_dst.actual_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("import drm fd error!\n");
|
||||
ret = -1;
|
||||
goto drm_buf_destroy;
|
||||
}
|
||||
|
||||
src = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src, dst, src_rect, dst_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ts = get_cur_us();
|
||||
|
||||
ret = imcopy(src, dst);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", drm_dst.drm_buf[0], drm_dst.drm_buf[1], drm_dst.drm_buf[2], drm_dst.drm_buf[3]);
|
||||
write_image_to_file(drm_dst.drm_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle > 0)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle > 0)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
drm_buf_destroy:
|
||||
drm_buf_destroy(drm_src.drm_buffer_fd, drm_src.drm_buffer_handle, drm_src.drm_buf, drm_src.actual_size);
|
||||
drm_buf_destroy(drm_dst.drm_buffer_fd, drm_dst.drm_buffer_handle, drm_dst.drm_buf, drm_dst.actual_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_allocator_drm_phy_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "im2d.h"
|
||||
#include "RgaUtils.h"
|
||||
|
||||
#include "drm_alloc.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
class DrmObject {
|
||||
public:
|
||||
int drm_buffer_fd;
|
||||
int drm_buffer_handle;
|
||||
size_t actual_size;
|
||||
uint8_t * drm_buf;
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
int ret = 0;
|
||||
int64_t ts;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int src_alloc_flags = 0, dst_alloc_flags = 0;
|
||||
long src_phy, dst_phy;
|
||||
rga_buffer_t src = {};
|
||||
rga_buffer_t dst = {};
|
||||
im_rect src_rect = {};
|
||||
im_rect dst_rect = {};
|
||||
DrmObject drm_src;
|
||||
DrmObject drm_dst;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_alloc_flags |= RGA_UTILS_ROCKCHIP_BO_CONTIG;
|
||||
dst_alloc_flags |= RGA_UTILS_ROCKCHIP_BO_CONTIG;
|
||||
|
||||
/*
|
||||
* Allocate a physically continuous drm_buf, return dma_fd and
|
||||
* virtual address, and get the physical address.
|
||||
*/
|
||||
drm_src.drm_buf = (uint8_t *)drm_buf_alloc(src_width, src_height,
|
||||
get_bpp_from_format(src_format) * 8,
|
||||
&drm_src.drm_buffer_fd,
|
||||
&drm_src.drm_buffer_handle,
|
||||
&drm_src.actual_size,
|
||||
src_alloc_flags);
|
||||
|
||||
drm_dst.drm_buf = (uint8_t *)drm_buf_alloc(dst_width, dst_height,
|
||||
get_bpp_from_format(dst_format) * 8,
|
||||
&drm_dst.drm_buffer_fd,
|
||||
&drm_dst.drm_buffer_handle,
|
||||
&drm_dst.actual_size,
|
||||
dst_alloc_flags);
|
||||
if (drm_src.drm_buf == NULL || drm_dst.drm_buf == NULL) {
|
||||
printf("alloc physically continuous drm buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
src_phy = drm_buf_get_phy(drm_src.drm_buffer_handle);
|
||||
dst_phy = drm_buf_get_phy(drm_dst.drm_buffer_handle);
|
||||
if (src_phy == 0 || dst_phy == 0) {
|
||||
printf("get drm buffer phy_addr failed!\n");
|
||||
goto drm_buf_destroy;
|
||||
}
|
||||
|
||||
ret = read_image_from_file(drm_src.drm_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0);
|
||||
if (ret < 0) {
|
||||
printf ("open file %s so memset!\n", "fault");
|
||||
draw_rgba((char *)drm_src.drm_buf, src_width, src_height);
|
||||
}
|
||||
memset(drm_dst.drm_buf, 0x33, drm_dst.actual_size);
|
||||
|
||||
/*
|
||||
* Import the allocated physical address into RGA by calling
|
||||
* importbuffer_physicaladdr, and use the returned buffer_handle
|
||||
* to call RGA to process the image.
|
||||
*/
|
||||
src_handle = importbuffer_physicaladdr(src_phy, drm_src.actual_size);
|
||||
dst_handle = importbuffer_physicaladdr(dst_phy, drm_dst.actual_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("import drm phy_addr error!\n");
|
||||
ret = -1;
|
||||
goto drm_buf_destroy;
|
||||
}
|
||||
|
||||
src = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src, dst, src_rect, dst_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ts = get_cur_us();
|
||||
|
||||
ret = imcopy(src, dst);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", drm_dst.drm_buf[0], drm_dst.drm_buf[1], drm_dst.drm_buf[2], drm_dst.drm_buf[3]);
|
||||
write_image_to_file(drm_dst.drm_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle > 0)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle > 0)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
drm_buf_destroy:
|
||||
drm_buf_destroy(drm_src.drm_buffer_fd, drm_src.drm_buffer_handle, drm_src.drm_buf, drm_src.actual_size);
|
||||
drm_buf_destroy(drm_dst.drm_buffer_fd, drm_dst.drm_buffer_handle, drm_dst.drm_buf, drm_dst.actual_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_allocator_graphicbuffer_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "im2d.hpp"
|
||||
#include "RgaUtils.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
/*
|
||||
* In order to be compatible with different android versions,
|
||||
* some gralloc usage is defined here.
|
||||
* The correct usage should be to refer to the corresponding header file:
|
||||
* Android 12 and above: #include "hardware/gralloc_rockchip.h"
|
||||
* Android 11 and below: #include "hardware/gralloc.h"
|
||||
*/
|
||||
#define GRALLOC_USAGE_PRIVATE_11 (1ULL << 56)
|
||||
#define RK_GRALLOC_USAGE_WITHIN_4G GRALLOC_USAGE_PRIVATE_11
|
||||
#define RK_GRALLOC_USAGE_RGA_ACCESS RK_GRALLOC_USAGE_WITHIN_4G
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
using namespace android;
|
||||
|
||||
int main(void) {
|
||||
int ret = 0;
|
||||
int64_t ts;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int src_buf_size, dst_buf_size;
|
||||
char *src_buf, *dst_buf;
|
||||
rga_buffer_t src = {};
|
||||
rga_buffer_t dst = {};
|
||||
im_rect src_rect = {};
|
||||
im_rect dst_rect = {};
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
uint64_t src_gb_flags = 0, dst_gb_flags = 0;
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = HAL_PIXEL_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = HAL_PIXEL_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
/* allocate GraphicBuffer */
|
||||
src_gb_flags |= GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
dst_gb_flags |= GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN;
|
||||
|
||||
/* for CORE_RGA2 */
|
||||
src_gb_flags |= RK_GRALLOC_USAGE_WITHIN_4G;
|
||||
dst_gb_flags |= RK_GRALLOC_USAGE_WITHIN_4G;
|
||||
|
||||
sp<GraphicBuffer> src_gb(new GraphicBuffer(src_width, src_height, src_format, 0, src_gb_flags));
|
||||
if (src_gb->initCheck()) {
|
||||
printf("src GraphicBuffer check error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
sp<GraphicBuffer> dst_gb(new GraphicBuffer(dst_width, dst_height, dst_format, 0, dst_gb_flags));
|
||||
if (dst_gb->initCheck()) {
|
||||
printf("dst GraphicBuffer check error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = src_gb->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void **)&src_buf);
|
||||
if (ret) {
|
||||
printf("lock buffer error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0);
|
||||
if (ret < 0) {
|
||||
printf ("open file %s so memset!\n", "fault");
|
||||
draw_rgba((char *)src_buf, src_width, src_height);
|
||||
}
|
||||
|
||||
ret = src_gb->unlock();
|
||||
if (ret) {
|
||||
printf("unlock buffer error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = dst_gb->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void **)&dst_buf);
|
||||
if (ret) {
|
||||
printf("lock buffer error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(dst_buf, 0x33, dst_buf_size);
|
||||
|
||||
ret = dst_gb->unlock();
|
||||
if (ret) {
|
||||
printf("unlock buffer error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Import the allocated GraphicBuffer into RGA by calling
|
||||
* importbuffer_GraphicBuffer, and use the returned buffer_handle
|
||||
* to call RGA to process the image.
|
||||
*/
|
||||
src_handle = importbuffer_GraphicBuffer(src_gb);
|
||||
dst_handle = importbuffer_GraphicBuffer(dst_gb);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("import GraphicBuffer error!\n");
|
||||
ret = -1;
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
src = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src, dst, src_rect, dst_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ts = get_cur_us();
|
||||
|
||||
ret = imcopy(src, dst);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ret = dst_gb->lock(GRALLOC_USAGE_SW_READ_OFTEN, (void **)&dst_buf);
|
||||
if (ret) {
|
||||
printf("lock buffer error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
ret = dst_gb->unlock();
|
||||
if (ret) {
|
||||
printf("unlock buffer error : %s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
release_buffer:
|
||||
if (src_handle > 0)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle > 0)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
free_buf:
|
||||
src_gb = NULL;
|
||||
dst_gb = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_allocator_malloc_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "im2d.h"
|
||||
#include "RgaUtils.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main(void) {
|
||||
int ret = 0;
|
||||
int64_t ts;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int src_buf_size, dst_buf_size;
|
||||
char *src_buf, *dst_buf;
|
||||
rga_buffer_t src = {};
|
||||
rga_buffer_t dst = {};
|
||||
im_rect src_rect = {};
|
||||
im_rect dst_rect = {};
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
if (src_buf == NULL || dst_buf == NULL) {
|
||||
printf("malloc buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0);
|
||||
if (ret < 0) {
|
||||
printf ("open file %s so memset!\n", "fault");
|
||||
draw_rgba((char *)src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x33, dst_buf_size);
|
||||
|
||||
/*
|
||||
* Import the allocated virtual address into RGA by calling
|
||||
* importbuffer_virtualaddr, and use the returned buffer_handle
|
||||
* to call RGA to process the image.
|
||||
*/
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("import malloc virt_addr error!\n");
|
||||
ret = -1;
|
||||
goto free_buf;
|
||||
}
|
||||
|
||||
src = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src, dst, src_rect, dst_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ts = get_cur_us();
|
||||
|
||||
ret = imcopy(src, dst);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success! cost %ld us\n", LOG_TAG, get_cur_us() - ts);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle > 0)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle > 0)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
free_buf:
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
#======================================================================
|
||||
#
|
||||
# alphaTest
|
||||
#
|
||||
#======================================================================
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
|
||||
LOCAL_CFLAGS += -Wall -Werror -Wunreachable-code
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
hardware/rockchip/librga \
|
||||
hardware/rockchip/librga/include \
|
||||
hardware/rockchip/librga/im2d_api
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
hardware/rockchip/librga/samples/utils \
|
||||
hardware/rockchip/librga/samples/3rdparty \
|
||||
hardware/rockchip/librga/samples/3rdparty/libdrm/include \
|
||||
hardware/rockchip/librga/samples/3rdparty/libdrm/include/libdrm
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libui \
|
||||
libutils \
|
||||
librga
|
||||
|
||||
LOCAL_HEADER_LIBRARIES += \
|
||||
libhardware_headers \
|
||||
libgui_headers \
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
../utils/utils.cpp \
|
||||
src/rga_alpha_demo.cpp
|
||||
|
||||
LOCAL_MODULE:= \
|
||||
rga_alpha_demo
|
||||
|
||||
ifdef TARGET_32_BIT_SURFACEFLINGER
|
||||
LOCAL_32_BIT_ONLY := true
|
||||
endif
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${LIBRGA_FILE_LIB}/librga.so)
|
||||
message("load ${LIBRGA_FILE_LIB}/librga.so")
|
||||
set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so)
|
||||
else ()
|
||||
set(RGA_LIB rga)
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
#install path
|
||||
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl")
|
||||
|
||||
set(RGA_INCLUDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api)
|
||||
include_directories(${RGA_INCLUDE})
|
||||
|
||||
if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt)
|
||||
endif()
|
||||
|
||||
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,70 @@
|
||||
# rga_alpha_demo
|
||||
add_executable(rga_alpha_demo
|
||||
rga_alpha_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_alpha_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_alpha_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_alpha_global_alpha_demo
|
||||
add_executable(rga_alpha_global_alpha_demo
|
||||
rga_alpha_global_alpha_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_alpha_global_alpha_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_alpha_global_alpha_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_alpha_3channel_demo
|
||||
add_executable(rga_alpha_3channel_demo
|
||||
rga_alpha_3channel_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_alpha_3channel_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_alpha_3channel_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_alpha_3channel_demo
|
||||
add_executable(rga_alpha_rgba5551_demo
|
||||
rga_alpha_rgba5551_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_alpha_rgba5551_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_alpha_rgba5551_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_alpha_yuv_demo
|
||||
add_executable(rga_alpha_yuv_demo
|
||||
rga_alpha_yuv_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_alpha_yuv_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_alpha_yuv_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_alpha_colorkey_demo
|
||||
add_executable(rga_alpha_colorkey_demo
|
||||
rga_alpha_colorkey_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_alpha_colorkey_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_alpha_colorkey_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_alpha_osd_demo
|
||||
add_executable(rga_alpha_osd_demo
|
||||
rga_alpha_osd_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_alpha_osd_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_alpha_osd_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_alpha_3channel_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int fg_width, fg_height, fg_format;
|
||||
int bg_width, bg_height, bg_format;
|
||||
int output_width, output_height, output_format;
|
||||
char *fg_buf, *bg_buf, *output_buf;
|
||||
int fg_buf_size, bg_buf_size, output_buf_size;
|
||||
|
||||
rga_buffer_t fg_img, bg_img, output_img;
|
||||
rga_buffer_handle_t fg_handle, bg_handle, output_handle;
|
||||
|
||||
memset(&fg_img, 0, sizeof(fg_img));
|
||||
memset(&bg_img, 0, sizeof(bg_img));
|
||||
memset(&output_img, 0, sizeof(output_img));
|
||||
|
||||
fg_width = 1280;
|
||||
fg_height = 720;
|
||||
fg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
bg_width = 1280;
|
||||
bg_height = 720;
|
||||
bg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
output_width = 1280;
|
||||
output_height = 720;
|
||||
output_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
fg_buf_size = fg_width * fg_height * get_bpp_from_format(fg_format);
|
||||
bg_buf_size = bg_width * bg_height * get_bpp_from_format(bg_format);
|
||||
output_buf_size = output_width * output_height * get_bpp_from_format(output_format);
|
||||
|
||||
fg_buf = (char *)malloc(fg_buf_size);
|
||||
bg_buf = (char *)malloc(bg_buf_size);
|
||||
output_buf = (char *)malloc(output_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(fg_buf, LOCAL_FILE_PATH, fg_width, fg_height, fg_format, 0)) {
|
||||
printf("foreground image read err\n");
|
||||
memset(fg_buf, 0xaa, fg_buf_size);
|
||||
}
|
||||
if (0 != read_image_from_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 1)) {
|
||||
printf("background image read err\n");
|
||||
memset(bg_buf, 0x66, bg_buf_size);
|
||||
}
|
||||
memset(output_buf, 0x80, output_buf_size);
|
||||
|
||||
fg_handle = importbuffer_virtualaddr(fg_buf, fg_buf_size);
|
||||
bg_handle = importbuffer_virtualaddr(bg_buf, bg_buf_size);
|
||||
output_handle = importbuffer_virtualaddr(output_buf, output_buf_size);
|
||||
if (fg_handle == 0 || bg_handle == 0 || output_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
fg_img = wrapbuffer_handle(fg_handle, fg_width, fg_height, fg_format);
|
||||
bg_img = wrapbuffer_handle(bg_handle, bg_width, bg_height, bg_format);
|
||||
output_img = wrapbuffer_handle(output_handle, output_width, output_height, output_format);
|
||||
|
||||
/*
|
||||
* Here are two RGBA8888 images of the same size for src_over overlay and
|
||||
* output them to another buffer.
|
||||
-------------- -------------- --------------
|
||||
| | | | | output_img |
|
||||
| fg_img | + | bg_img | => | fg over bg |
|
||||
| | | | | |
|
||||
-------------- -------------- --------------
|
||||
*/
|
||||
|
||||
ret = imcheck_composite(fg_img, output_img, bg_img, {}, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = imcomposite(fg_img, bg_img, output_img, IM_ALPHA_BLEND_SRC_OVER | IM_ALPHA_BLEND_PRE_MUL);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(output_buf, LOCAL_FILE_PATH, output_width, output_height, output_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (fg_handle)
|
||||
releasebuffer_handle(fg_handle);
|
||||
if (bg_handle)
|
||||
releasebuffer_handle(bg_handle);
|
||||
if (output_handle)
|
||||
releasebuffer_handle(output_handle);
|
||||
|
||||
if (fg_buf)
|
||||
free(fg_buf);
|
||||
if (bg_buf)
|
||||
free(bg_buf);
|
||||
if (output_buf)
|
||||
free(output_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_alpha_colorkey_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int fg_width, fg_height, fg_format;
|
||||
int bg_width, bg_height, bg_format;
|
||||
char *fg_buf, *bg_buf;
|
||||
int fg_buf_size, bg_buf_size;
|
||||
|
||||
int usage = 0;
|
||||
rga_buffer_t fg_img, bg_img;
|
||||
rga_buffer_handle_t fg_handle, bg_handle;
|
||||
im_colorkey_range range;
|
||||
|
||||
memset(&fg_img, 0, sizeof(fg_img));
|
||||
memset(&bg_img, 0, sizeof(bg_img));
|
||||
|
||||
fg_width = 1280;
|
||||
fg_height = 720;
|
||||
fg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
bg_width = 1280;
|
||||
bg_height = 720;
|
||||
bg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
fg_buf_size = fg_width * fg_height * get_bpp_from_format(fg_format);
|
||||
bg_buf_size = bg_width * bg_height * get_bpp_from_format(bg_format);
|
||||
|
||||
fg_buf = (char *)malloc(fg_buf_size);
|
||||
bg_buf = (char *)malloc(bg_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(fg_buf, LOCAL_FILE_PATH, fg_width, fg_height, fg_format, 0)) {
|
||||
printf("foreground image read err\n");
|
||||
memset(fg_buf, 0xaa, fg_buf_size);
|
||||
}
|
||||
if (0 != read_image_from_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 1)) {
|
||||
printf("background image read err\n");
|
||||
memset(bg_buf, 0x66, bg_buf_size);
|
||||
}
|
||||
|
||||
/* Fill color on foreground image. */
|
||||
for (int i = 0; i < fg_height; i++) {
|
||||
for (int j = 0; j < fg_width/8; j++) {
|
||||
fg_buf[(i*fg_width*4) + j*4 + 0] = 0x11; //R
|
||||
fg_buf[(i*fg_width*4) + j*4 + 1] = 0x11; //G
|
||||
fg_buf[(i*fg_width*4) + j*4 + 2] = 0x11; //B
|
||||
fg_buf[(i*fg_width*4) + j*4 + 3] = 0xff; //A
|
||||
}
|
||||
for (int j = fg_width/8; j < fg_width/4; j++) {
|
||||
fg_buf[(i*fg_width*4) + j*4 + 0] = 0x66;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 1] = 0x66;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 2] = 0x66;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 3] = 0xff;
|
||||
}
|
||||
for (int j = fg_width/4; j < fg_width/8*3; j++) {
|
||||
fg_buf[(i*fg_width*4) + j*4 + 0] = 0xaa;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 1] = 0xaa;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 2] = 0xaa;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 3] = 0xff;
|
||||
}
|
||||
for (int j = fg_width/8*3; j < fg_width/2; j++) {
|
||||
fg_buf[(i*fg_width*4) + j*4 + 0] = 0xff;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 1] = 0xff;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 2] = 0xff;
|
||||
fg_buf[(i*fg_width*4) + j*4 + 3] = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
fg_handle = importbuffer_virtualaddr(fg_buf, fg_buf_size);
|
||||
bg_handle = importbuffer_virtualaddr(bg_buf, bg_buf_size);
|
||||
if (fg_handle == 0 || bg_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
fg_img = wrapbuffer_handle(fg_handle, fg_width, fg_height, fg_format);
|
||||
bg_img = wrapbuffer_handle(bg_handle, bg_width, bg_height, bg_format);
|
||||
|
||||
/*
|
||||
* Overlays the background image after removing a specified
|
||||
* range of colors in the foreground image.
|
||||
-------------- -------------- --------------
|
||||
| | | | | |
|
||||
| fg_img | + | bg_img | => | fg over bg |
|
||||
| | | | | |
|
||||
-------------- -------------- --------------
|
||||
*/
|
||||
|
||||
ret = imcheck(fg_img, bg_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
range.min = 0xFF666666; //ABGR
|
||||
range.max = 0xFFaaaaaa;
|
||||
|
||||
ret = imcolorkey(fg_img, bg_img, range, IM_ALPHA_COLORKEY_NORMAL);
|
||||
printf("%s .... %s\n", LOG_TAG, imStrError(ret));
|
||||
if (ret != IM_STATUS_SUCCESS)
|
||||
goto release_buffer;
|
||||
|
||||
write_image_to_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (fg_handle)
|
||||
releasebuffer_handle(fg_handle);
|
||||
if (bg_handle)
|
||||
releasebuffer_handle(bg_handle);
|
||||
|
||||
if (fg_buf)
|
||||
free(fg_buf);
|
||||
if (bg_buf)
|
||||
free(bg_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_alpha_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int fg_width, fg_height, fg_format;
|
||||
int bg_width, bg_height, bg_format;
|
||||
char *fg_buf, *bg_buf;
|
||||
int fg_buf_size, bg_buf_size;
|
||||
|
||||
rga_buffer_t fg_img, bg_img;
|
||||
rga_buffer_handle_t fg_handle, bg_handle;
|
||||
|
||||
memset(&fg_img, 0, sizeof(fg_img));
|
||||
memset(&bg_img, 0, sizeof(bg_img));
|
||||
|
||||
fg_width = 1280;
|
||||
fg_height = 720;
|
||||
fg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
bg_width = 1280;
|
||||
bg_height = 720;
|
||||
bg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
fg_buf_size = fg_width * fg_height * get_bpp_from_format(fg_format);
|
||||
bg_buf_size = bg_width * bg_height * get_bpp_from_format(bg_format);
|
||||
|
||||
fg_buf = (char *)malloc(fg_buf_size);
|
||||
bg_buf = (char *)malloc(bg_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(fg_buf, LOCAL_FILE_PATH, fg_width, fg_height, fg_format, 0)) {
|
||||
printf("foreground image read err\n");
|
||||
memset(fg_buf, 0xaa, fg_buf_size);
|
||||
}
|
||||
if (0 != read_image_from_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 1)) {
|
||||
printf("background image read err\n");
|
||||
memset(bg_buf, 0x66, bg_buf_size);
|
||||
}
|
||||
|
||||
fg_handle = importbuffer_virtualaddr(fg_buf, fg_buf_size);
|
||||
bg_handle = importbuffer_virtualaddr(bg_buf, bg_buf_size);
|
||||
if (fg_handle == 0 || bg_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
fg_img = wrapbuffer_handle(fg_handle, fg_width, fg_height, fg_format);
|
||||
bg_img = wrapbuffer_handle(bg_handle, bg_width, bg_height, bg_format);
|
||||
|
||||
/*
|
||||
* Here are two RGBA8888 images of the same size for src_over overlay.
|
||||
-------------- -------------- --------------
|
||||
| | | | | |
|
||||
| fg_img | + | bg_img | => | fg over bg |
|
||||
| | | | | |
|
||||
-------------- -------------- --------------
|
||||
*/
|
||||
|
||||
ret = imcheck(fg_img, bg_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = imblend(fg_img, bg_img, IM_ALPHA_BLEND_SRC_OVER | IM_ALPHA_BLEND_PRE_MUL);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (fg_handle)
|
||||
releasebuffer_handle(fg_handle);
|
||||
if (bg_handle)
|
||||
releasebuffer_handle(bg_handle);
|
||||
|
||||
if (fg_buf)
|
||||
free(fg_buf);
|
||||
if (bg_buf)
|
||||
free(bg_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_alpha_global_alpha_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int fg_width, fg_height, fg_format;
|
||||
int bg_width, bg_height, bg_format;
|
||||
char *fg_buf, *bg_buf;
|
||||
int fg_buf_size, bg_buf_size;
|
||||
|
||||
rga_buffer_t fg_img, bg_img;
|
||||
rga_buffer_handle_t fg_handle, bg_handle;
|
||||
|
||||
memset(&fg_img, 0, sizeof(fg_img));
|
||||
memset(&bg_img, 0, sizeof(bg_img));
|
||||
|
||||
fg_width = 1280;
|
||||
fg_height = 720;
|
||||
fg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
bg_width = 1280;
|
||||
bg_height = 720;
|
||||
bg_format = RK_FORMAT_YCbCr_420_SP;
|
||||
|
||||
fg_buf_size = fg_width * fg_height * get_bpp_from_format(fg_format);
|
||||
bg_buf_size = bg_width * bg_height * get_bpp_from_format(bg_format);
|
||||
|
||||
fg_buf = (char *)malloc(fg_buf_size);
|
||||
bg_buf = (char *)malloc(bg_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(fg_buf, LOCAL_FILE_PATH, fg_width, fg_height, fg_format, 0)) {
|
||||
printf("foreground image read err\n");
|
||||
memset(fg_buf, 0xaa, fg_buf_size);
|
||||
}
|
||||
if (0 != read_image_from_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 1)) {
|
||||
printf("background image read err\n");
|
||||
memset(bg_buf, 0x66, bg_buf_size);
|
||||
}
|
||||
|
||||
fg_handle = importbuffer_virtualaddr(fg_buf, fg_buf_size);
|
||||
bg_handle = importbuffer_virtualaddr(bg_buf, bg_buf_size);
|
||||
if (fg_handle == 0 || bg_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
fg_img = wrapbuffer_handle(fg_handle, fg_width, fg_height, fg_format);
|
||||
bg_img = wrapbuffer_handle(bg_handle, bg_width, bg_height, bg_format);
|
||||
|
||||
/*
|
||||
* Set the opacity from 0 to 0xFF (255), and use it as the global alpha for
|
||||
* the current layer to guide the blending.
|
||||
* If the current layer has per-pixel alpha, then the alpha value is calculated as
|
||||
* alpha = (per-pixel alpha * global alpha) >> 8.
|
||||
*/
|
||||
imsetOpacity(&fg_img, 0x80);
|
||||
imsetOpacity(&bg_img, 0xe0);
|
||||
|
||||
/*
|
||||
* Here are two RGBA8888 images of the same size for src_over overlay.
|
||||
-------------- -------------- --------------
|
||||
| | | | | |
|
||||
| fg_img | + | bg_img | => | fg over bg |
|
||||
| | | | | |
|
||||
-------------- -------------- --------------
|
||||
*/
|
||||
|
||||
ret = imcheck(fg_img, bg_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = imblend(fg_img, bg_img, IM_ALPHA_BLEND_SRC_OVER | IM_ALPHA_BLEND_PRE_MUL);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (fg_handle)
|
||||
releasebuffer_handle(fg_handle);
|
||||
if (bg_handle)
|
||||
releasebuffer_handle(bg_handle);
|
||||
|
||||
if (fg_buf)
|
||||
free(fg_buf);
|
||||
if (bg_buf)
|
||||
free(bg_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_alpha_osd_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
#include "dma_alloc.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int block_witdh, block_height;
|
||||
int fg_width, fg_height, fg_format;
|
||||
int bg_width, bg_height, bg_format;
|
||||
char *fg_buf, *bg_buf;
|
||||
int fg_dma_fd, bg_dma_fd;
|
||||
int fg_buf_size, bg_buf_size;
|
||||
int block_size, block_count;
|
||||
|
||||
int usage = 0;
|
||||
rga_buffer_t fg_img, bg_img;
|
||||
im_rect bg_rect;
|
||||
rga_buffer_handle_t fg_handle, bg_handle;
|
||||
im_osd_t osd_config;
|
||||
|
||||
memset(&fg_img, 0, sizeof(fg_img));
|
||||
memset(&bg_img, 0, sizeof(bg_img));
|
||||
memset(&bg_rect, 0, sizeof(bg_rect));
|
||||
memset(&osd_config, 0, sizeof(osd_config));
|
||||
|
||||
block_witdh = 64;
|
||||
block_height = 96;
|
||||
block_count = 6;
|
||||
|
||||
fg_width = block_witdh;
|
||||
fg_height = block_height * block_count;
|
||||
fg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
bg_width = 1280;
|
||||
bg_height = 720;
|
||||
bg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
block_size = block_witdh * block_height * get_bpp_from_format(fg_format);
|
||||
fg_buf_size = fg_width * fg_height * get_bpp_from_format(fg_format);
|
||||
bg_buf_size = bg_width * bg_height * get_bpp_from_format(bg_format);
|
||||
|
||||
/* Allocate dma_buf from CMA, return dma_fd and virtual address */
|
||||
ret = dma_buf_alloc(DMA_HEAP_UNCACHE_PATH, fg_buf_size, &fg_dma_fd, (void **)&fg_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc fg CMA buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = dma_buf_alloc(DMA_HEAP_UNCACHE_PATH, bg_buf_size, &bg_dma_fd, (void **)&bg_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc bg CMA buffer failed!\n");
|
||||
dma_buf_free(fg_buf_size, &fg_dma_fd, fg_buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* fill image data */
|
||||
for (int i = 0; (i < block_count) && ((block_height * i) < fg_height); i++) {
|
||||
if (0 != read_image_from_file(fg_buf + i * block_size, LOCAL_FILE_PATH, block_witdh, block_height, fg_format, 0)) {
|
||||
printf("block image read err\n");
|
||||
memset(fg_buf, 0xaa, fg_buf_size);
|
||||
}
|
||||
}
|
||||
output_buf_data_to_file(fg_buf, fg_format, fg_width, fg_height, 0);
|
||||
|
||||
if (0 != read_image_from_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 0)) {
|
||||
printf("background image read err\n");
|
||||
memset(bg_buf, 0x66, bg_buf_size);
|
||||
}
|
||||
|
||||
fg_handle = importbuffer_fd(fg_dma_fd, fg_buf_size);
|
||||
bg_handle = importbuffer_fd(bg_dma_fd, bg_buf_size);
|
||||
if (fg_handle == 0 || bg_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
fg_img = wrapbuffer_handle(fg_handle, fg_width, fg_height, fg_format);
|
||||
bg_img = wrapbuffer_handle(bg_handle, bg_width, bg_height, bg_format);
|
||||
|
||||
/*
|
||||
* Overlay multiple blocks on the background image and guide the color of
|
||||
* the blocks according to the external inversion flag.
|
||||
---- --------------------- ---------------------
|
||||
| | | | | ---- |
|
||||
---- | | | | | |
|
||||
| | | | | ---- |
|
||||
---- + | | => | | | |
|
||||
| | | | | ---- |
|
||||
---- | | | | | |
|
||||
| | | ---- |
|
||||
--------------------- ---------------------
|
||||
|
||||
*/
|
||||
|
||||
bg_rect.x = 100;
|
||||
bg_rect.y = 100;
|
||||
bg_rect.width = fg_width;
|
||||
bg_rect.height = fg_height;
|
||||
|
||||
osd_config.osd_mode = IM_OSD_MODE_STATISTICS | IM_OSD_MODE_AUTO_INVERT;
|
||||
|
||||
osd_config.block_parm.width_mode = IM_OSD_BLOCK_MODE_NORMAL;
|
||||
osd_config.block_parm.width = block_height;
|
||||
osd_config.block_parm.block_count = block_count;
|
||||
osd_config.block_parm.background_config = IM_OSD_BACKGROUND_DEFAULT_BRIGHT;
|
||||
osd_config.block_parm.direction = IM_OSD_MODE_VERTICAL;
|
||||
osd_config.block_parm.color_mode = IM_OSD_COLOR_PIXEL;
|
||||
|
||||
osd_config.invert_config.invert_channel = IM_OSD_INVERT_CHANNEL_COLOR;
|
||||
osd_config.invert_config.flags_mode = IM_OSD_FLAGS_EXTERNAL;
|
||||
osd_config.invert_config.invert_flags = 0x000000000000002a;
|
||||
osd_config.invert_config.flags_index = 1;
|
||||
osd_config.invert_config.threash = 40;
|
||||
osd_config.invert_config.invert_mode = IM_OSD_INVERT_USE_SWAP;
|
||||
|
||||
ret = imcheck(fg_img, bg_img, {}, bg_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = imosd(fg_img, bg_img, bg_rect, &osd_config);
|
||||
printf("%s .... %s\n", LOG_TAG, imStrError(ret));
|
||||
if (ret != IM_STATUS_SUCCESS)
|
||||
goto release_buffer;
|
||||
|
||||
write_image_to_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (fg_handle)
|
||||
releasebuffer_handle(fg_handle);
|
||||
if (bg_handle)
|
||||
releasebuffer_handle(bg_handle);
|
||||
|
||||
dma_buf_free(fg_buf_size, &fg_dma_fd, fg_buf);
|
||||
dma_buf_free(bg_buf_size, &bg_dma_fd, bg_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_alpha_rgba5551_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int fg_width, fg_height, fg_format;
|
||||
int bg_width, bg_height, bg_format;
|
||||
int output_width, output_height, output_format;
|
||||
char *fg_buf, *bg_buf, *output_buf;
|
||||
int fg_buf_size, bg_buf_size, output_buf_size;
|
||||
|
||||
int usage = 0;
|
||||
rga_buffer_t fg_img, bg_img, output_img;
|
||||
im_rect fg_rect, bg_rect, output_rect;
|
||||
rga_buffer_handle_t fg_handle, bg_handle, output_handle;
|
||||
|
||||
memset(&fg_img, 0, sizeof(fg_img));
|
||||
memset(&bg_img, 0, sizeof(bg_img));
|
||||
memset(&output_img, 0, sizeof(output_img));
|
||||
memset(&fg_rect, 0, sizeof(fg_rect));
|
||||
memset(&bg_rect, 0, sizeof(bg_rect));
|
||||
memset(&output_rect, 0, sizeof(output_rect));
|
||||
|
||||
fg_width = 1920;
|
||||
fg_height = 1080;
|
||||
fg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
bg_width = 1280;
|
||||
bg_height = 720;
|
||||
bg_format = RK_FORMAT_ARGB_5551;
|
||||
|
||||
output_width = 1920;
|
||||
output_height = 1080;
|
||||
output_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
fg_buf_size = fg_width * fg_height * get_bpp_from_format(fg_format);
|
||||
bg_buf_size = bg_width * bg_height * get_bpp_from_format(bg_format);
|
||||
output_buf_size = output_width * output_height * get_bpp_from_format(output_format);
|
||||
|
||||
fg_buf = (char *)malloc(fg_buf_size);
|
||||
bg_buf = (char *)malloc(bg_buf_size);
|
||||
output_buf = (char *)malloc(output_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(fg_buf, LOCAL_FILE_PATH, fg_width, fg_height, fg_format, 0)) {
|
||||
printf("foreground image read err\n");
|
||||
memset(fg_buf, 0xaa, fg_buf_size);
|
||||
}
|
||||
if (0 != read_image_from_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 0)) {
|
||||
printf("background image read err\n");
|
||||
for (int i = 0; i < bg_width * bg_height; i++) {
|
||||
((uint16_t *)bg_buf)[0 + i] = ((i % 2) ? (0x1 & 0x1) : (0) << 0) | // a
|
||||
((0x1f & 0x1f) << 1) | // r
|
||||
((0x1 & 0x1f) << 6) | // g
|
||||
((0x2 & 0x1f) << 11); // b
|
||||
}
|
||||
}
|
||||
memset(output_buf, 0x80, output_buf_size);
|
||||
|
||||
fg_handle = importbuffer_virtualaddr(fg_buf, fg_buf_size);
|
||||
bg_handle = importbuffer_virtualaddr(bg_buf, bg_buf_size);
|
||||
output_handle = importbuffer_virtualaddr(output_buf, output_buf_size);
|
||||
if (fg_handle == 0 || bg_handle == 0 || output_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
fg_img = wrapbuffer_handle(fg_handle, fg_width, fg_height, fg_format);
|
||||
bg_img = wrapbuffer_handle(bg_handle, bg_width, bg_height, bg_format);
|
||||
output_img = wrapbuffer_handle(output_handle, output_width, output_height, output_format);
|
||||
|
||||
/*
|
||||
* Configure the blended rectangular area here.
|
||||
* Here is intercepted from the foreground image (100, 200) as the starting point,
|
||||
* and a rectangle with the same resolution as the background image is blended with
|
||||
* the background image, and finally output to the output layer where (100, 200) is
|
||||
* the starting point.
|
||||
* The alpha bit of ARGB5551 is mapped into two alpha values through 0/1.
|
||||
* fg_img => src_channel
|
||||
* bg_img => src1_channel
|
||||
* output_img => dst_channel
|
||||
--------------------------- -------------- ---------------------------
|
||||
| fg_img | | bg_img/ | | output_img |
|
||||
| -------------- | | bg_rect | | -------------- |
|
||||
| | | | | | | | | |
|
||||
| | fg_rect | | + -------------- => | | output_rect| |
|
||||
| | | | | |(bg over fg)| |
|
||||
| -------------- | | -------------- |
|
||||
| | | |
|
||||
--------------------------- ---------------------------
|
||||
*/
|
||||
|
||||
fg_rect.x = 100;
|
||||
fg_rect.y = 200;
|
||||
fg_rect.width = bg_width;
|
||||
fg_rect.height = bg_height;
|
||||
|
||||
bg_rect.x = 0;
|
||||
bg_rect.y = 0;
|
||||
bg_rect.width = fg_rect.width;
|
||||
bg_rect.height = fg_rect.height;
|
||||
|
||||
output_rect.x = fg_rect.x;
|
||||
output_rect.y = fg_rect.y;
|
||||
output_rect.width = fg_rect.width;
|
||||
output_rect.height = fg_rect.height;
|
||||
|
||||
imsetAlphaBit(&bg_img, 0x20, 0xe0);
|
||||
|
||||
usage = IM_SYNC | IM_ALPHA_BLEND_DST_OVER | IM_ALPHA_BLEND_PRE_MUL | IM_ALPHA_BIT_MAP;
|
||||
|
||||
ret = imcheck_composite(fg_img, output_img, bg_img, fg_rect, output_rect, bg_rect, usage);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = improcess(fg_img, output_img, bg_img, fg_rect, output_rect, bg_rect, -1, NULL, NULL, usage);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(output_buf, LOCAL_FILE_PATH, output_width, output_height, output_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (fg_handle)
|
||||
releasebuffer_handle(fg_handle);
|
||||
if (bg_handle)
|
||||
releasebuffer_handle(bg_handle);
|
||||
if (output_handle)
|
||||
releasebuffer_handle(output_handle);
|
||||
|
||||
if (fg_buf)
|
||||
free(fg_buf);
|
||||
if (bg_buf)
|
||||
free(bg_buf);
|
||||
if (output_buf)
|
||||
free(output_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_alpha_rgba_yuv_demo"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int fg_width, fg_height, fg_format;
|
||||
int bg_width, bg_height, bg_format;
|
||||
int output_width, output_height, output_format;
|
||||
char *fg_buf, *bg_buf, *output_buf;
|
||||
int fg_buf_size, bg_buf_size, output_buf_size;
|
||||
|
||||
int usage = 0;
|
||||
rga_buffer_t fg_img, bg_img, output_img;
|
||||
im_rect fg_rect, bg_rect, output_rect;
|
||||
rga_buffer_handle_t fg_handle, bg_handle, output_handle;
|
||||
|
||||
memset(&fg_img, 0, sizeof(fg_img));
|
||||
memset(&bg_img, 0, sizeof(bg_img));
|
||||
memset(&output_img, 0, sizeof(output_img));
|
||||
memset(&fg_rect, 0, sizeof(fg_rect));
|
||||
memset(&bg_rect, 0, sizeof(bg_rect));
|
||||
memset(&output_rect, 0, sizeof(output_rect));
|
||||
|
||||
fg_width = 1920;
|
||||
fg_height = 1080;
|
||||
fg_format = RK_FORMAT_YCbCr_420_SP;
|
||||
|
||||
bg_width = 1280;
|
||||
bg_height = 720;
|
||||
bg_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
output_width = 1920;
|
||||
output_height = 1080;
|
||||
output_format = RK_FORMAT_YCbCr_420_SP;
|
||||
|
||||
fg_buf_size = fg_width * fg_height * get_bpp_from_format(fg_format);
|
||||
bg_buf_size = bg_width * bg_height * get_bpp_from_format(bg_format);
|
||||
output_buf_size = output_width * output_height * get_bpp_from_format(output_format);
|
||||
|
||||
fg_buf = (char *)malloc(fg_buf_size);
|
||||
bg_buf = (char *)malloc(bg_buf_size);
|
||||
output_buf = (char *)malloc(output_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(fg_buf, LOCAL_FILE_PATH, fg_width, fg_height, fg_format, 0)) {
|
||||
printf("foreground image read err\n");
|
||||
memset(fg_buf, 0xaa, fg_buf_size);
|
||||
}
|
||||
if (0 != read_image_from_file(bg_buf, LOCAL_FILE_PATH, bg_width, bg_height, bg_format, 0)) {
|
||||
printf("background image read err\n");
|
||||
memset(bg_buf, 0x66, bg_buf_size);
|
||||
}
|
||||
memset(output_buf, 0x80, output_buf_size);
|
||||
|
||||
fg_handle = importbuffer_virtualaddr(fg_buf, fg_buf_size);
|
||||
bg_handle = importbuffer_virtualaddr(bg_buf, bg_buf_size);
|
||||
output_handle = importbuffer_virtualaddr(output_buf, output_buf_size);
|
||||
if (fg_handle == 0 || bg_handle == 0 || output_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
fg_img = wrapbuffer_handle(fg_handle, fg_width, fg_height, fg_format);
|
||||
bg_img = wrapbuffer_handle(bg_handle, bg_width, bg_height, bg_format);
|
||||
output_img = wrapbuffer_handle(output_handle, output_width, output_height, output_format);
|
||||
|
||||
/*
|
||||
* Configure the blended rectangular area here.
|
||||
* Here is intercepted from the foreground image (100, 200) as the starting point,
|
||||
* and a rectangle with the same resolution as the background image is blended with
|
||||
* the background image, and finally output to the output layer where (100, 200) is
|
||||
* the starting point.
|
||||
* fg_img => src_channel
|
||||
* bg_img => src1_channel
|
||||
* output_img => dst_channel
|
||||
--------------------------- -------------- ---------------------------
|
||||
| fg_img | | bg_img/ | | output_img |
|
||||
| -------------- | | bg_rect | | -------------- |
|
||||
| | | | | | | | | |
|
||||
| | fg_rect | | + -------------- => | | output_rect| |
|
||||
| | | | | |(bg over fg)| |
|
||||
| -------------- | | -------------- |
|
||||
| | | |
|
||||
--------------------------- ---------------------------
|
||||
*/
|
||||
|
||||
fg_rect.x = 100;
|
||||
fg_rect.y = 200;
|
||||
fg_rect.width = bg_width;
|
||||
fg_rect.height = bg_height;
|
||||
|
||||
bg_rect.x = 0;
|
||||
bg_rect.y = 0;
|
||||
bg_rect.width = fg_rect.width;
|
||||
bg_rect.height = fg_rect.height;
|
||||
|
||||
output_rect.x = fg_rect.x;
|
||||
output_rect.y = fg_rect.y;
|
||||
output_rect.width = fg_rect.width;
|
||||
output_rect.height = fg_rect.height;
|
||||
|
||||
ret = imcheck_composite(fg_img, output_img, bg_img, fg_rect, output_rect, bg_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
usage = IM_SYNC | IM_ALPHA_BLEND_DST_OVER | IM_ALPHA_BLEND_PRE_MUL;
|
||||
|
||||
ret = improcess(fg_img, output_img, bg_img, fg_rect, output_rect, bg_rect, -1, NULL, NULL, usage);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(output_buf, LOCAL_FILE_PATH, output_width, output_height, output_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (fg_handle)
|
||||
releasebuffer_handle(fg_handle);
|
||||
if (bg_handle)
|
||||
releasebuffer_handle(bg_handle);
|
||||
if (output_handle)
|
||||
releasebuffer_handle(output_handle);
|
||||
|
||||
if (fg_buf)
|
||||
free(fg_buf);
|
||||
if (bg_buf)
|
||||
free(bg_buf);
|
||||
if (output_buf)
|
||||
free(output_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${LIBRGA_FILE_LIB}/librga.so)
|
||||
message("load ${LIBRGA_FILE_LIB}/librga.so")
|
||||
set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so)
|
||||
else ()
|
||||
set(RGA_LIB rga)
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
#install path
|
||||
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl")
|
||||
|
||||
set(RGA_INCLUDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api)
|
||||
include_directories(${RGA_INCLUDE})
|
||||
|
||||
if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt)
|
||||
endif()
|
||||
|
||||
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,11 @@
|
||||
# rga_async_demo
|
||||
SET(DEMO_NAME rga_async_demo)
|
||||
add_executable(${DEMO_NAME}
|
||||
${DEMO_NAME}.cpp
|
||||
)
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_async_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int tmp_width, tmp_height, tmp_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *tmp_buf, *dst_buf;
|
||||
int src_buf_size, tmp_buf_size, dst_buf_size;
|
||||
int acquire_fence_fd, release_fence_fd;
|
||||
|
||||
rga_buffer_t src_img, tmp_img, dst_img;
|
||||
rga_buffer_handle_t src_handle, tmp_handle, dst_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&tmp_img, 0, sizeof(tmp_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
tmp_width = 1280;
|
||||
tmp_height = 720;
|
||||
tmp_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
tmp_buf_size = tmp_width * tmp_height * get_bpp_from_format(tmp_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
tmp_buf = (char *)malloc(tmp_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image image read err\n");
|
||||
draw_rgba(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(tmp_buf, 0x40, tmp_buf_size);
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
tmp_handle = importbuffer_virtualaddr(tmp_buf, tmp_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || tmp_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
tmp_img = wrapbuffer_handle(tmp_handle, tmp_width, tmp_height, tmp_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
/*
|
||||
* The image will be asynchronously copied from src_image to tmp, and
|
||||
* rely on fence to copy src_image to tmp_image and then copy to dst_image.
|
||||
-------------- -------------- --------------
|
||||
| | | | | |
|
||||
| src_image | => | tmp_image | => | dst_image |
|
||||
| | | | | |
|
||||
-------------- -------------- --------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* (1). Copy src_image to tmp_image and get release_fence.
|
||||
*/
|
||||
ret = imcheck(src_img, tmp_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
release_fence_fd = -1;
|
||||
ret = imcopy(src_img, tmp_img, 0, &release_fence_fd);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s src->tmp running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s src->tmp running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
if (release_fence_fd < 0) {
|
||||
printf("get release_fence_fd failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* (2). Copy tmp_image to dst_image, use the release_fence obtained in
|
||||
* operation 1 as acquire_fence, and get the release_fence of this task.
|
||||
*/
|
||||
acquire_fence_fd = release_fence_fd;
|
||||
release_fence_fd = -1;
|
||||
|
||||
ret = imcheck(tmp_img, dst_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ret = improcess(tmp_img, dst_img, {}, {}, {}, {}, acquire_fence_fd, &release_fence_fd, NULL, IM_ASYNC);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s tmp->dst running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s tmp->dst running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
if (release_fence_fd < 0) {
|
||||
printf("get release_fence_fd failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* (3). Will wait for the release_fence of the last operation, when it is
|
||||
* signed it indicates that all tasks are completed.
|
||||
*/
|
||||
ret = imsync(release_fence_fd);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s waiting success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s waiting failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (tmp_handle)
|
||||
releasebuffer_handle(tmp_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (tmp_buf)
|
||||
free(tmp_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${LIBRGA_FILE_LIB}/librga.so)
|
||||
message("load ${LIBRGA_FILE_LIB}/librga.so")
|
||||
set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so)
|
||||
else ()
|
||||
set(RGA_LIB rga)
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
#install path
|
||||
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl")
|
||||
|
||||
set(RGA_INCLUDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api)
|
||||
include_directories(${RGA_INCLUDE})
|
||||
|
||||
if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt)
|
||||
endif()
|
||||
|
||||
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,19 @@
|
||||
# rga_config_thread_core_demo
|
||||
add_executable(rga_config_thread_core_demo
|
||||
rga_config_thread_core_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_config_thread_core_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_config_thread_core_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_config_single_core_demo
|
||||
add_executable(rga_config_single_core_demo
|
||||
rga_config_single_core_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_config_single_core_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_config_single_core_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_config_single_core_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
im_opt_t opt;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
memset(&opt, 0, sizeof(opt));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
draw_rgba(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src_img, dst_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure the current job to use only RGA3_core0. */
|
||||
opt.core = IM_SCHEDULER_RGA3_CORE0;
|
||||
ret = improcess(src_img, dst_img, {}, {}, {}, {}, -1, NULL, &opt, IM_SYNC);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_config_thread_core_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
draw_rgba(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src_img, dst_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Configure the current thread to use only RGA3_core0 or RGA3_core1. */
|
||||
imconfig(IM_CONFIG_SCHEDULER_CORE, IM_SCHEDULER_RGA3_CORE0 | IM_SCHEDULER_RGA3_CORE1);
|
||||
|
||||
ret = imcopy(src_img, dst_img);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${LIBRGA_FILE_LIB}/librga.so)
|
||||
message("load ${LIBRGA_FILE_LIB}/librga.so")
|
||||
set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so)
|
||||
else ()
|
||||
set(RGA_LIB rga)
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
#install path
|
||||
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl")
|
||||
|
||||
set(RGA_INCLUDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api)
|
||||
include_directories(${RGA_INCLUDE})
|
||||
|
||||
if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt)
|
||||
endif()
|
||||
|
||||
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,54 @@
|
||||
# rga_copy_demo
|
||||
SET(DEMO_NAME rga_copy_demo)
|
||||
add_executable(${DEMO_NAME}
|
||||
${DEMO_NAME}.cpp
|
||||
)
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_copy_fbc_demo
|
||||
SET(DEMO_NAME rga_copy_fbc_demo)
|
||||
add_executable(${DEMO_NAME}
|
||||
${DEMO_NAME}.cpp
|
||||
)
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_copy_tile_demo
|
||||
SET(DEMO_NAME rga_copy_tile_demo)
|
||||
add_executable(${DEMO_NAME}
|
||||
${DEMO_NAME}.cpp
|
||||
)
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_copy_splice_demo
|
||||
SET(DEMO_NAME rga_copy_splice_demo)
|
||||
add_executable(${DEMO_NAME}
|
||||
${DEMO_NAME}.cpp
|
||||
)
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_copy_splice_task_demo
|
||||
SET(DEMO_NAME rga_copy_splice_task_demo)
|
||||
add_executable(${DEMO_NAME}
|
||||
${DEMO_NAME}.cpp
|
||||
)
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS ${DEMO_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_copy_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
draw_rgba(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
/*
|
||||
* Copy the src image to the dst buffer.
|
||||
-------------- --------------
|
||||
| | | |
|
||||
| src_image | => | dst_image |
|
||||
| | | |
|
||||
-------------- --------------
|
||||
*/
|
||||
|
||||
ret = imcheck(src_img, dst_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = imcopy(src_img, dst_img);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_copy_fbc_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf, *fbc_buf;
|
||||
int src_buf_size, dst_buf_size, fbc_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img, fbc_img;
|
||||
rga_buffer_handle_t src_handle, dst_handle, fbc_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_YCbCr_420_SP;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_YCbCr_420_SP;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
fbc_buf_size = dst_buf_size * 1.5;
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
fbc_buf = (char *)malloc(fbc_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
draw_YUV420(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
memset(fbc_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
fbc_handle = importbuffer_virtualaddr(fbc_buf, fbc_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
fbc_img = wrapbuffer_handle(fbc_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
/*
|
||||
* Copy the src(RASTER) image to the fbc(FBC) image.
|
||||
-------------- --------------
|
||||
| | | |
|
||||
| src_image | => | fbc_image |
|
||||
| | | |
|
||||
-------------- --------------
|
||||
*/
|
||||
|
||||
src_img.rd_mode = IM_RASTER_MODE;
|
||||
|
||||
/* Select the required FBC mode. */
|
||||
fbc_img.rd_mode = IM_AFBC16x16_MODE;
|
||||
// fbc_img.rd_mode = IM_AFBC32x8_MODE;
|
||||
// fbc_img.rd_mode = IM_RKFBC64x4_MODE;
|
||||
|
||||
ret = imcopy(src_img, fbc_img);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s RASTER -> FBC running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s RASTER -> FBC running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("FBC [0x%x, 0x%x, 0x%x, 0x%x]\n", fbc_buf[0], fbc_buf[1], fbc_buf[2], fbc_buf[3]);
|
||||
write_image_to_fbc_file(fbc_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
/*
|
||||
* Copy the fbc(FBC) image to the dst(RASTER) image.
|
||||
-------------- --------------
|
||||
| | | |
|
||||
| fbc_image | => | dst_image |
|
||||
| | | |
|
||||
-------------- --------------
|
||||
*/
|
||||
|
||||
/* Select the required FBC mode. */
|
||||
fbc_img.rd_mode = IM_AFBC16x16_MODE;
|
||||
// fbc_img.rd_mode = IM_AFBC32x8_MODE;
|
||||
// fbc_img.rd_mode = IM_RKFBC64x4_MODE;
|
||||
|
||||
dst_img.rd_mode = IM_RASTER_MODE;
|
||||
|
||||
ret = imcopy(fbc_img, dst_img);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s FBC -> RASTER running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s FBC -> RASTER running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("RASTER [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 1);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
if (fbc_handle)
|
||||
releasebuffer_handle(fbc_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
if (fbc_buf)
|
||||
free(fbc_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_copy_splice_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int left_width, left_height, left_format;
|
||||
int right_width, right_height, right_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *left_buf, *right_buf, *dst_buf;
|
||||
int left_buf_size, right_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t left_img, right_img, dst_img;
|
||||
im_rect left_rect, right_rect;
|
||||
rga_buffer_handle_t left_handle, right_handle, dst_handle;
|
||||
|
||||
memset(&left_img, 0, sizeof(left_img));
|
||||
memset(&right_img, 0, sizeof(right_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
memset(&left_rect, 0, sizeof(left_rect));
|
||||
memset(&right_rect, 0, sizeof(right_rect));
|
||||
|
||||
left_width = 1280;
|
||||
left_height = 720;
|
||||
left_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
right_width = 1280;
|
||||
right_height = 720;
|
||||
right_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 2560;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
left_buf_size = left_width * left_height * get_bpp_from_format(left_format);
|
||||
right_buf_size = right_width * right_height * get_bpp_from_format(right_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
left_buf = (char *)malloc(left_buf_size);
|
||||
right_buf = (char *)malloc(right_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(left_buf, LOCAL_FILE_PATH, left_width, left_height, left_format, 0)) {
|
||||
printf("left image read err\n");
|
||||
memset(left_buf, 0xaa, left_buf_size);
|
||||
}
|
||||
if (0 != read_image_from_file(right_buf, LOCAL_FILE_PATH, right_width, right_height, right_format, 0)) {
|
||||
printf("right image read err\n");
|
||||
memset(left_buf, 0xbb, left_buf_size);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
left_handle = importbuffer_virtualaddr(left_buf, left_buf_size);
|
||||
right_handle = importbuffer_virtualaddr(right_buf, left_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (left_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
left_img = wrapbuffer_handle(left_handle, left_width, left_height, left_format);
|
||||
right_img = wrapbuffer_handle(right_handle, right_width, right_height, right_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
/*
|
||||
* Splicing the left and right images to output.
|
||||
---------------------------
|
||||
| | |
|
||||
| left_rect | right_rect |
|
||||
| | |
|
||||
---------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1). copy left image.
|
||||
dst_img
|
||||
-------------- ---------------------------
|
||||
| | | | |
|
||||
| left_img | => | left_rect | |
|
||||
| | | | |
|
||||
-------------- ---------------------------
|
||||
*/
|
||||
left_rect.x = 0;
|
||||
left_rect.y = 0;
|
||||
left_rect.width = left_width;
|
||||
left_rect.height = left_height;
|
||||
|
||||
ret = imcheck(left_img, dst_img, {}, left_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ret = improcess(left_img, dst_img, {}, {}, left_rect, {}, IM_SYNC);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s left running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s left running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* 2). copy right image.
|
||||
dst_img
|
||||
-------------- ---------------------------
|
||||
| | | | |
|
||||
| right_img | => | | right_rect |
|
||||
| | | | |
|
||||
-------------- ---------------------------
|
||||
*/
|
||||
right_rect.x = left_width;
|
||||
right_rect.y = 0;
|
||||
right_rect.width = right_width;
|
||||
right_rect.height = right_height;
|
||||
|
||||
ret = imcheck(right_img, dst_img, {}, right_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ret = improcess(right_img, dst_img, {}, {}, right_rect, {}, IM_SYNC);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s right running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s right running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (left_handle)
|
||||
releasebuffer_handle(left_handle);
|
||||
if (right_handle)
|
||||
releasebuffer_handle(right_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (left_buf)
|
||||
free(left_buf);
|
||||
if (right_buf)
|
||||
free(right_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_copy_splice_task_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int left_width, left_height, left_format;
|
||||
int right_width, right_height, right_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *left_buf, *right_buf, *dst_buf;
|
||||
int left_buf_size, right_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t left_img, right_img, dst_img;
|
||||
im_rect left_rect, right_rect;
|
||||
rga_buffer_handle_t left_handle, right_handle, dst_handle;
|
||||
im_job_handle_t job_handle;
|
||||
|
||||
memset(&left_img, 0, sizeof(left_img));
|
||||
memset(&right_img, 0, sizeof(right_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
memset(&left_rect, 0, sizeof(left_rect));
|
||||
memset(&right_rect, 0, sizeof(right_rect));
|
||||
|
||||
left_width = 1280;
|
||||
left_height = 720;
|
||||
left_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
right_width = 1280;
|
||||
right_height = 720;
|
||||
right_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 2560;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
left_buf_size = left_width * left_height * get_bpp_from_format(left_format);
|
||||
right_buf_size = right_width * right_height * get_bpp_from_format(right_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
left_buf = (char *)malloc(left_buf_size);
|
||||
right_buf = (char *)malloc(right_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(left_buf, LOCAL_FILE_PATH, left_width, left_height, left_format, 0)) {
|
||||
printf("left image read err\n");
|
||||
memset(left_buf, 0xaa, left_buf_size);
|
||||
}
|
||||
if (0 != read_image_from_file(right_buf, LOCAL_FILE_PATH, right_width, right_height, right_format, 0)) {
|
||||
printf("right image read err\n");
|
||||
memset(left_buf, 0xbb, left_buf_size);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
left_handle = importbuffer_virtualaddr(left_buf, left_buf_size);
|
||||
right_handle = importbuffer_virtualaddr(right_buf, left_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (left_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
left_img = wrapbuffer_handle(left_handle, left_width, left_height, left_format);
|
||||
right_img = wrapbuffer_handle(right_handle, right_width, right_height, right_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
/*
|
||||
* Splicing the left and right images to output.
|
||||
---------------------------
|
||||
| | |
|
||||
| left_rect | right_rect |
|
||||
| | |
|
||||
---------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* 1). Create a job handle.
|
||||
*/
|
||||
job_handle = imbeginJob();
|
||||
if (job_handle <= 0) {
|
||||
printf("job begin failed![%d], %s\n", job_handle, imStrError());
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* 2). Add a task of copying the left image.
|
||||
dst_img
|
||||
-------------- ---------------------------
|
||||
| | | | |
|
||||
| left_img | => | left_rect | |
|
||||
| | | | |
|
||||
-------------- ---------------------------
|
||||
*/
|
||||
left_rect.x = 0;
|
||||
left_rect.y = 0;
|
||||
left_rect.width = left_width;
|
||||
left_rect.height = left_height;
|
||||
|
||||
ret = imcheck(left_img, dst_img, {}, left_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
imcancelJob(job_handle);
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ret = improcessTask(job_handle, left_img, dst_img, {}, {}, left_rect, {}, NULL, IM_SYNC);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s job[%d] add left task success!\n", LOG_TAG, job_handle);
|
||||
} else {
|
||||
printf("%s job[%d] add left task failed, %s\n", LOG_TAG, job_handle, imStrError((IM_STATUS)ret));
|
||||
imcancelJob(job_handle);
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* 3). Add a task of copying the right image.
|
||||
dst_img
|
||||
-------------- ---------------------------
|
||||
| | | | |
|
||||
| right_img | => | | right_rect |
|
||||
| | | | |
|
||||
-------------- ---------------------------
|
||||
*/
|
||||
right_rect.x = left_width;
|
||||
right_rect.y = 0;
|
||||
right_rect.width = right_width;
|
||||
right_rect.height = right_height;
|
||||
|
||||
ret = imcheck(right_img, dst_img, {}, right_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
imcancelJob(job_handle);
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ret = improcessTask(job_handle, right_img, dst_img, {}, {}, right_rect, {}, NULL, IM_SYNC);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s job[%d] add right task success!\n", LOG_TAG, job_handle);
|
||||
} else {
|
||||
printf("%s job[%d] add right task failed, %s\n", LOG_TAG, job_handle, imStrError((IM_STATUS)ret));
|
||||
imcancelJob(job_handle);
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* 4). Submit and wait for the job to complete.
|
||||
*/
|
||||
ret = imendJob(job_handle);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s job[%d] running success!\n", LOG_TAG, job_handle);
|
||||
} else {
|
||||
printf("%s job[%d] running failed, %s\n", LOG_TAG, job_handle, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("output [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (left_handle)
|
||||
releasebuffer_handle(left_handle);
|
||||
if (right_handle)
|
||||
releasebuffer_handle(right_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (left_buf)
|
||||
free(left_buf);
|
||||
if (right_buf)
|
||||
free(right_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_copy_tile_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf, *tile_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img, tile_img;
|
||||
rga_buffer_handle_t src_handle, dst_handle, tile_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_YCbCr_420_SP;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_YCbCr_420_SP;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
tile_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
draw_YUV420(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
memset(tile_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
tile_handle = importbuffer_virtualaddr(tile_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
tile_img = wrapbuffer_handle(tile_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
/*
|
||||
* Copy the src(raster) image to the tile image.
|
||||
-------------- --------------
|
||||
| | | |
|
||||
| src_image | => | tile_image |
|
||||
| | | |
|
||||
-------------- --------------
|
||||
*/
|
||||
|
||||
src_img.rd_mode = IM_RASTER_MODE;
|
||||
|
||||
/* Select the required TILE mode. */
|
||||
tile_img.rd_mode = IM_TILE8x8_MODE;
|
||||
// tile_img.rd_mode = IM_TILE4x4_MODE;
|
||||
|
||||
ret = imcopy(src_img, tile_img);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s raster -> tile8x8 running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s raster -> tile8x8 running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("tile8x8 [0x%x, 0x%x, 0x%x, 0x%x]\n", tile_buf[0], tile_buf[1], tile_buf[2], tile_buf[3]);
|
||||
write_image_to_file(tile_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
/*
|
||||
* Copy the tile image to the dst(raster) image.
|
||||
-------------- --------------
|
||||
| | | |
|
||||
| tile_image | => | dst_image |
|
||||
| | | |
|
||||
-------------- --------------
|
||||
*/
|
||||
|
||||
/* Select the required TILE mode. */
|
||||
tile_img.rd_mode = IM_TILE8x8_MODE;
|
||||
// tile_img.rd_mode = IM_TILE4x4_MODE;
|
||||
|
||||
dst_img.rd_mode = IM_RASTER_MODE;
|
||||
|
||||
ret = imcopy(tile_img, dst_img);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s tile8x8 -> raster running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s tile8x8 -> raster running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
printf("raster [0x%x, 0x%x, 0x%x, 0x%x]\n", dst_buf[0], dst_buf[1], dst_buf[2], dst_buf[3]);
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 1);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
if (tile_handle)
|
||||
releasebuffer_handle(tile_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
if (tile_buf)
|
||||
free(tile_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${LIBRGA_FILE_LIB}/librga.so)
|
||||
message("load ${LIBRGA_FILE_LIB}/librga.so")
|
||||
set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so)
|
||||
else ()
|
||||
set(RGA_LIB rga)
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
#install path
|
||||
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl")
|
||||
|
||||
set(RGA_INCLUDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api)
|
||||
include_directories(${RGA_INCLUDE})
|
||||
|
||||
if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt)
|
||||
endif()
|
||||
|
||||
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,19 @@
|
||||
# rga_crop_demo
|
||||
add_executable(rga_crop_demo
|
||||
rga_crop_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_crop_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_crop_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_crop_rect_demo
|
||||
add_executable(rga_crop_rect_demo
|
||||
rga_crop_rect_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_crop_rect_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_crop_rect_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_crop_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img;
|
||||
im_rect rect;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
memset(&rect, 0, sizeof(rect));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 200;
|
||||
dst_height = 200;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
draw_rgba(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
/*
|
||||
* Crop a rectangular area(200*200) of src.
|
||||
--------------------------- --------------
|
||||
| src_img | | |
|
||||
| -------------- | | dst_img |
|
||||
| | src_rect | | => | |
|
||||
| | | | --------------
|
||||
| -------------- |
|
||||
---------------------------
|
||||
*/
|
||||
|
||||
rect.x = 100;
|
||||
rect.y = 100;
|
||||
rect.width = 200;
|
||||
rect.height = 200;
|
||||
|
||||
ret = imcheck(src_img, dst_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = imcrop(src_img, dst_img, rect);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_crop_rect_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img;
|
||||
im_rect src_rect, dst_rect;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
memset(&src_rect, 0, sizeof(src_rect));
|
||||
memset(&dst_rect, 0, sizeof(dst_rect));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
draw_rgba(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
/*
|
||||
* Copy a rectangular area on the src image to a rectangular area in dst image.
|
||||
--------------------------- ---------------------------
|
||||
| src_img | | dst_img |
|
||||
| -------------- | | |
|
||||
| | | | | -------------- |
|
||||
| | src_rect | | => | | | |
|
||||
| | | | | | dst_rect | |
|
||||
| -------------- | | | | |
|
||||
| | | -------------- |
|
||||
| | | |
|
||||
--------------------------- ---------------------------
|
||||
*/
|
||||
|
||||
src_rect.x = 100;
|
||||
src_rect.y = 100;
|
||||
src_rect.width = 200;
|
||||
src_rect.height = 200;
|
||||
|
||||
dst_rect.x = 200;
|
||||
dst_rect.y = 200;
|
||||
dst_rect.width = 200;
|
||||
dst_rect.height = 200;
|
||||
|
||||
ret = imcheck(src_img, dst_img, src_rect, dst_rect);
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = improcess(src_img, dst_img, {}, src_rect, dst_rect, {}, IM_SYNC);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${LIBRGA_FILE_LIB}/librga.so)
|
||||
message("load ${LIBRGA_FILE_LIB}/librga.so")
|
||||
set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so)
|
||||
else ()
|
||||
set(RGA_LIB rga)
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
#install path
|
||||
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl")
|
||||
|
||||
set(RGA_INCLUDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api)
|
||||
include_directories(${RGA_INCLUDE})
|
||||
|
||||
if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt)
|
||||
endif()
|
||||
|
||||
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,29 @@
|
||||
# rga_cvtcolor_demo
|
||||
add_executable(rga_cvtcolor_demo
|
||||
rga_cvtcolor_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_cvtcolor_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_cvtcolor_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_cvtcolor_csc_demo
|
||||
add_executable(rga_cvtcolor_csc_demo
|
||||
rga_cvtcolor_csc_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_cvtcolor_csc_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_cvtcolor_csc_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
# rga_cvtcolor_gray256_demo
|
||||
add_executable(rga_cvtcolor_gray256_demo
|
||||
rga_cvtcolor_gray256_demo.cpp
|
||||
)
|
||||
target_link_libraries(rga_cvtcolor_gray256_demo
|
||||
utils_obj
|
||||
${RGA_LIB}
|
||||
)
|
||||
install(TARGETS rga_cvtcolor_gray256_demo DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_cvtcolor_csc_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
#include "dma_alloc.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
int src_dma_fd, dst_dma_fd;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_YCbCr_420_SP;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHED_PATH, src_buf_size, &src_dma_fd, (void **)&src_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc src dma_heap buffer failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = dma_buf_alloc(DMA_HEAP_DMA32_UNCACHED_PATH, dst_buf_size, &dst_dma_fd, (void **)&dst_buf);
|
||||
if (ret < 0) {
|
||||
printf("alloc dst dma_heap buffer failed!\n");
|
||||
dma_buf_free(src_buf_size, &src_dma_fd, src_buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
memset(src_buf, 0xaa, src_buf_size);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_fd(src_dma_fd, src_buf_size);
|
||||
dst_handle = importbuffer_fd(dst_dma_fd, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
imsetColorSpace(&src_img, IM_RGB_FULL);
|
||||
imsetColorSpace(&dst_img, IM_YUV_BT709_LIMIT_RANGE);
|
||||
|
||||
ret = imcheck(src_img, dst_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
ret = imcvtcolor(src_img, dst_img, src_format, dst_format);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
dma_buf_free(dst_buf_size, &dst_dma_fd, dst_buf);
|
||||
dma_buf_free(src_buf_size, &src_dma_fd, src_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_cvtcolor_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_RGB_565;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
memset(src_buf, 0xaa, src_buf_size);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src_img, dst_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = imcvtcolor(src_img, dst_img, src_format, dst_format);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
|
||||
* Authors:
|
||||
* YuQiaowei <cerf.yu@rock-chips.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_NDEBUG 0
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG "rga_cvtcolor_gray256_demo"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/stddef.h>
|
||||
|
||||
#include "RgaUtils.h"
|
||||
#include "im2d.hpp"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define LOCAL_FILE_PATH "/data"
|
||||
|
||||
int main() {
|
||||
int ret = 0;
|
||||
int src_width, src_height, src_format;
|
||||
int dst_width, dst_height, dst_format;
|
||||
char *src_buf, *dst_buf;
|
||||
int src_buf_size, dst_buf_size;
|
||||
|
||||
rga_buffer_t src_img, dst_img;
|
||||
rga_buffer_handle_t src_handle, dst_handle;
|
||||
|
||||
memset(&src_img, 0, sizeof(src_img));
|
||||
memset(&dst_img, 0, sizeof(dst_img));
|
||||
|
||||
src_width = 1280;
|
||||
src_height = 720;
|
||||
src_format = RK_FORMAT_RGBA_8888;
|
||||
|
||||
dst_width = 1280;
|
||||
dst_height = 720;
|
||||
dst_format = RK_FORMAT_YCbCr_400;
|
||||
|
||||
src_buf_size = src_width * src_height * get_bpp_from_format(src_format);
|
||||
dst_buf_size = dst_width * dst_height * get_bpp_from_format(dst_format);
|
||||
|
||||
src_buf = (char *)malloc(src_buf_size);
|
||||
dst_buf = (char *)malloc(dst_buf_size);
|
||||
|
||||
/* fill image data */
|
||||
if (0 != read_image_from_file(src_buf, LOCAL_FILE_PATH, src_width, src_height, src_format, 0)) {
|
||||
printf("src image read err\n");
|
||||
draw_rgba(src_buf, src_width, src_height);
|
||||
}
|
||||
memset(dst_buf, 0x80, dst_buf_size);
|
||||
|
||||
src_handle = importbuffer_virtualaddr(src_buf, src_buf_size);
|
||||
dst_handle = importbuffer_virtualaddr(dst_buf, dst_buf_size);
|
||||
if (src_handle == 0 || dst_handle == 0) {
|
||||
printf("importbuffer failed!\n");
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
src_img = wrapbuffer_handle(src_handle, src_width, src_height, src_format);
|
||||
dst_img = wrapbuffer_handle(dst_handle, dst_width, dst_height, dst_format);
|
||||
|
||||
ret = imcheck(src_img, dst_img, {}, {});
|
||||
if (IM_STATUS_NOERROR != ret) {
|
||||
printf("%d, check error! %s", __LINE__, imStrError((IM_STATUS)ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* By converting the RGBA image to a YUV image, the Y channel is used as
|
||||
* a 256-level grayscale image.
|
||||
* Since the RGB->YUV csc is introduced here, it is necessary to use the
|
||||
* BT 601 full range to obtain the complete Y channel data, otherwise the
|
||||
* Y channel data obtained by the limit range is clipped.
|
||||
*/
|
||||
ret = imcvtcolor(src_img, dst_img, src_format, dst_format, IM_RGB_TO_YUV_BT601_FULL);
|
||||
if (ret == IM_STATUS_SUCCESS) {
|
||||
printf("%s running success!\n", LOG_TAG);
|
||||
} else {
|
||||
printf("%s running failed, %s\n", LOG_TAG, imStrError((IM_STATUS)ret));
|
||||
goto release_buffer;
|
||||
}
|
||||
|
||||
write_image_to_file(dst_buf, LOCAL_FILE_PATH, dst_width, dst_height, dst_format, 0);
|
||||
|
||||
release_buffer:
|
||||
if (src_handle)
|
||||
releasebuffer_handle(src_handle);
|
||||
if (dst_handle)
|
||||
releasebuffer_handle(dst_handle);
|
||||
|
||||
if (src_buf)
|
||||
free(src_buf);
|
||||
if (dst_buf)
|
||||
free(dst_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
|
||||
message("load ${BUILD_TOOLCHAINS_PATH}")
|
||||
include(${BUILD_TOOLCHAINS_PATH})
|
||||
endif()
|
||||
|
||||
if (EXISTS ${LIBRGA_FILE_LIB}/librga.so)
|
||||
message("load ${LIBRGA_FILE_LIB}/librga.so")
|
||||
set(RGA_LIB ${LIBRGA_FILE_LIB}/librga.so)
|
||||
else ()
|
||||
set(RGA_LIB rga)
|
||||
endif()
|
||||
|
||||
get_filename_component(TARGET_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
project(rga_${TARGET_NAME})
|
||||
|
||||
#install path
|
||||
if (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR bin)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined -ldl")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined -ldl")
|
||||
|
||||
set(RGA_INCLUDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../im2d_api)
|
||||
include_directories(${RGA_INCLUDE})
|
||||
|
||||
if (NOT DEFINED RGA_SAMPLES_UTILS_COMPILED)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../utils/CMakeLists.txt)
|
||||
endif()
|
||||
|
||||
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_android_ndk.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_android_ndk/install/lib
|
||||
BUILD_DIR=build/build_android_ndk
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
|
||||
SAMPLES_DIR=${SCRIPT_DIR}/..
|
||||
|
||||
# The following options require configuration
|
||||
TOOLCHAIN_PATH=${SAMPLES_DIR}/../toolchains/toolchain_linux.cmake
|
||||
LIBRGA_PATH=${SAMPLES_DIR}/../build/build_linux/install/lib
|
||||
BUILD_DIR=build/build_linux
|
||||
BUILD_TYPE=Release
|
||||
|
||||
rm -rf $BUILD_DIR
|
||||
mkdir -p $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake ../.. \
|
||||
-DLIBRGA_FILE_LIB=${LIBRGA_PATH} \
|
||||
-DBUILD_TOOLCHAINS_PATH=${TOOLCHAIN_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_INSTALL_PREFIX=install \
|
||||
|
||||
make -j8
|
||||
make install
|
||||
|
||||
popd
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user