Skip to content

Commit

Permalink
Merge branch 'linux-rga-multi' of github.com:JeffyCN/mirrors
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukumijima committed Jan 6, 2024
2 parents f8c78f8 + d7a0a48 commit 46d74b2
Show file tree
Hide file tree
Showing 84 changed files with 1,418 additions and 9,186 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# 更新日志

## 1.10.0 (2023-09-12)

该版本RGA驱动建议更新至1.3.0及以上版本,最低支持1.2.4。

### 新增

- 支持更多Porter-Duff混合模型,src-in/dst-in/src-out/dst-out/src-atop/dst-atop/xor。(驱动须更新至1.3.0)
- 新增配置单独通道透明度API imsetOpacity()。
- 新增配置单独通道色域空间API imsetColorSpace()。
- 新增配置全局alpha示例代码。
- 支持GKI。(驱动须更新至1.3.0)

### 优化

- 补充FAQ中对于常见RGA2 不支持大于4G内存空间问题的Q&A。

### 变更

- samples/padding_demo使用dma32分配内存。
- 配置色域转换方式更改为通过imsetColorSpace()配置对应通道的色域空间。

### 修复

- RGA2可以支持 RGB2YUV模式下BT 709 limit range。(驱动须更新至1.3.0)
- 修复一些条件下调用task API参数会丢失的异常。
- 修复部分示例代码的笔误。

### 移除

- 移除对SDK环境变量ANDROID_12的依赖。

## 1.9.3 (2023-06-28)

该版本RGA驱动建议更新至1.2.27及以上版本,最低支持1.2.4。
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ set(OBJECT_NAME ${PROJECT_NAME}-object)

add_library(${OBJECT_NAME} OBJECT ${IM2D_SRCS})

target_include_directories(${OBJECT_NAME} PUBLIC ${IM2D_INCLUDE})
target_include_directories(${OBJECT_NAME} PRIVATE ${IM2D_INCLUDE})
# Some older compilers need to explicitly set this property
# After setting this property, it can be used to generate a shared library
set_target_properties(${OBJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1)
Expand All @@ -116,7 +116,7 @@ set(SHARED_LIB_NAME ${PROJECT_NAME})

add_library(${SHARED_LIB_NAME} SHARED $<TARGET_OBJECTS:${OBJECT_NAME}>)

target_include_directories(${SHARED_LIB_NAME} PUBLIC ${IM2D_INCLUDE})
target_include_directories(${SHARED_LIB_NAME} PRIVATE ${IM2D_INCLUDE})

if(NOT DEFINED IM2D_API_VERSION)
set_target_properties(${SHARED_LIB_NAME} PROPERTIES
Expand All @@ -133,7 +133,7 @@ set(STATIC_LIB_NAME ${PROJECT_NAME}-static)

add_library(${STATIC_LIB_NAME} STATIC $<TARGET_OBJECTS:${OBJECT_NAME}>)

target_include_directories(${STATIC_LIB_NAME} PUBLIC ${IM2D_INCLUDE})
target_include_directories(${STATIC_LIB_NAME} PRIVATE ${IM2D_INCLUDE})
set_target_properties(${STATIC_LIB_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})

# If cmake version is 3.5.1, FIXIT
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RGA (Raster Graphic Acceleration Unit)是一个独立的2D硬件加速器,可

## 版本说明

**RGA API** 版本: 1.9.3
**RGA API** 版本: 1.10.0

## 适用芯片平台

Expand Down
130 changes: 73 additions & 57 deletions core/NormalRga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ int get_int_property(void) {
return atoi(level);
}

static void rga_set_driver_feature(struct rgaContext *ctx) {
if (rga_version_compare(ctx->mDriverVersion, (struct rga_version_t){ 1, 3, 0, {0} }) >= 0)
ctx->driver_feature |= RGA_DRIVER_FEATURE_USER_CLOSE_FENCE;
}

int NormalRgaOpen(void **context) {
struct rgaContext *ctx = NULL;
int fd = -1;
Expand Down Expand Up @@ -126,6 +131,8 @@ int NormalRgaOpen(void **context) {
ALOGE("librga fail to get driver version! Compatibility mode will be enabled.\n");
}

rga_set_driver_feature(ctx);

NormalRgaInitTables();

rgaCtx = ctx;
Expand Down Expand Up @@ -374,7 +381,7 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1) {
int src1VirW,src1VirH,src1ActW,src1ActH,src1XPos,src1YPos;
int scaleMode,rotateMode,orientation,ditherEn;
int srcType,dstType,src1Type,srcMmuFlag,dstMmuFlag,src1MmuFlag;
int planeAlpha;
int fg_global_alpha, bg_global_alpha;
int dstFd = -1;
int srcFd = -1;
int src1Fd = -1;
Expand Down Expand Up @@ -403,6 +410,8 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1) {

//init
memset(&rgaReg, 0, sizeof(struct rga_req));
if (rgaCtx->driver_feature & RGA_DRIVER_FEATURE_USER_CLOSE_FENCE)
rgaReg.feature.user_close_fence = true;

srcType = dstType = srcMmuFlag = dstMmuFlag = 0;
src1Type = src1MmuFlag = 0;
Expand Down Expand Up @@ -686,73 +695,63 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1) {
}
#endif

/* blend bit[16:23] is to set global alpha. */
planeAlpha = (blend & 0xFF0000) >> 16;

/* determined by format, need pixel alpha or not. */
perpixelAlpha = NormalRgaFormatHasAlpha(RkRgaGetRgaFormat(relSrcRect.format));

if(is_out_log())
ALOGE("blend = %x , perpixelAlpha = %d",blend,perpixelAlpha);

/* blend bit[0:15] is to set which way to blend,such as whether need glabal alpha,and so on. */
switch ((blend & 0xFFFF)) {
case 0x0001:/* src */
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 2, planeAlpha , 1, 1, 0);
break;

case 0x0002:/* dst */
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 2, planeAlpha , 1, 2, 0);
break;
if (blend & 0xfff) {
/* blend bit[16:23] is to set global alpha. */
fg_global_alpha = (blend >> 16) & 0xff;
bg_global_alpha = (blend >> 24) & 0xff;

case 0x0105:/* src over , no need to Premultiplied. */
if (perpixelAlpha && planeAlpha < 255) {
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 2, planeAlpha, 1, 9, 0);
} else if (perpixelAlpha)
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 1, 0, 1, 3, 0);
else
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 0, planeAlpha, 0, 0, 0);
break;
/*
* In the legacy interface, the src-over mode supports globalAlpha
* configuration for the src channel, while the other modes do not
* support globalAlpha configuration.
*/
switch (blend) {
case 0x405:
fg_global_alpha = (blend >> 16) & 0xff;
bg_global_alpha = 0xff;

case 0x0405:/* src over , need to Premultiplied. */
if (perpixelAlpha && planeAlpha < 255)
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 2, planeAlpha, 1, 9, 0);
else if (perpixelAlpha)
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 1, 0, 1, 3, 0);
else
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 0, planeAlpha, 0, 0, 0);
blend = RGA_ALPHA_BLEND_SRC_OVER;
blend |= 0x1 << 12;
break;
case 0x504:
fg_global_alpha = 0xff;
bg_global_alpha = 0xff;

rgaReg.alpha_rop_flag |= (1 << 9); //real color mode
blend = RGA_ALPHA_BLEND_DST_OVER;
blend |= 0x1 << 12;
break;
case 0x105:
fg_global_alpha = (blend >> 16) & 0xff;
bg_global_alpha = 0xff;

break;
blend = RGA_ALPHA_BLEND_SRC_OVER;
break;
case 0x501:
fg_global_alpha = 0xff;
bg_global_alpha = 0xff;

case 0x0501:/* dst over , no need premultiplied. */
if (perpixelAlpha && planeAlpha < 255)
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 2, planeAlpha , 1, 4, 0);
else if (perpixelAlpha)
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 1, planeAlpha , 1, 4, 0);
else
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 3, planeAlpha , 1, 4, 0);
break;
blend = RGA_ALPHA_BLEND_DST_OVER;
break;
case 0x100:
fg_global_alpha = 0xff;
bg_global_alpha = 0xff;

case 0x0504:/* dst over, need premultiplied. */
if (perpixelAlpha && planeAlpha < 255)
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 2, planeAlpha , 1, 4, 0);
else if (perpixelAlpha)
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 1, planeAlpha , 1, 4, 0);
else
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 3, planeAlpha , 1, 4, 0);
blend = RGA_ALPHA_BLEND_SRC;
break;
}

rgaReg.alpha_rop_flag |= (1 << 9); //real color mode
break;
rgaReg.feature.global_alpha_en = true;
NormalRgaSetAlphaEnInfo(&rgaReg, 1, 1, fg_global_alpha, bg_global_alpha , 1, blend & 0xfff, 0);

case 0x0100:
default:
/* Tips: BLENDING_NONE is non-zero value, handle zero value as
* BLENDING_NONE. */
/* C = Cs
* A = As */
break;
/* need to pre-multiply. */
if ((blend >> 12) & 0x1)
rgaReg.alpha_rop_flag |= (1 << 9);
}

/* discripe a picture need high stride.If high stride not to be set, need use height as high stride. */
Expand Down Expand Up @@ -1296,7 +1295,14 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1) {
NormalRgaSetPatActiveInfo(&rgaReg, src1ActW, src1ActH, src1XPos, src1YPos);

if (dst->color_space_mode & full_csc_mask) {
NormalRgaFullColorSpaceConvert(&rgaReg, dst->color_space_mode);
ret = NormalRgaFullColorSpaceConvert(&rgaReg, dst->color_space_mode);
if (ret < 0) {
ALOGE("Not support full csc mode [%x]\n", dst->color_space_mode);
return -EINVAL;
}

if (dst->color_space_mode == rgb2yuv_709_limit)
yuvToRgbMode |= 0x3 << 2;
} else {
if (src1) {
/* special config for yuv + rgb => rgb */
Expand Down Expand Up @@ -1470,6 +1476,11 @@ int RgaBlit(rga_info *src, rga_info *dst, rga_info *src1) {

dst->out_fence_fd = rgaReg.out_fence_fd;

if (rgaCtx->driver_feature & RGA_DRIVER_FEATURE_USER_CLOSE_FENCE &&
dst->in_fence_fd > 0 &&
sync_mode == RGA_BLIT_ASYNC)
close(dst->in_fence_fd);

return 0;
}

Expand Down Expand Up @@ -1521,6 +1532,7 @@ int RgaCollorFill(rga_info *dst) {
}

memset(&rgaReg, 0, sizeof(struct rga_req));
rgaReg.feature.user_close_fence = true;

dstType = dstMmuFlag = 0;

Expand Down Expand Up @@ -1770,6 +1782,11 @@ int RgaCollorFill(rga_info *dst) {

dst->out_fence_fd = rgaReg.out_fence_fd;

if (rgaCtx->driver_feature & RGA_DRIVER_FEATURE_USER_CLOSE_FENCE &&
dst->in_fence_fd > 0 &&
sync_mode == RGA_BLIT_ASYNC)
close(dst->in_fence_fd);

return 0;
}

Expand Down Expand Up @@ -1801,6 +1818,7 @@ int RgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut) {

//init
memset(&rgaReg, 0, sizeof(struct rga_req));
rgaReg.feature.user_close_fence = true;

srcType = dstType = lutType = srcMmuFlag = dstMmuFlag = lutMmuFlag = 0;

Expand Down Expand Up @@ -2385,8 +2403,6 @@ int RgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut) {
return -errno;
}

dst->out_fence_fd = rgaReg.out_fence_fd;

return 0;
}

Expand Down
9 changes: 5 additions & 4 deletions core/NormalRga.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ int NormalRgaSetRopMaskInfo(struct rga_req *msg,

/* use dst alpha */

int NormalRgaSetAlphaEnInfo(struct rga_req *msg,
unsigned int alpha_cal_mode, unsigned int alpha_mode,
unsigned int global_a_value, unsigned int PD_en,
unsigned int PD_mode, unsigned int dst_alpha_en );
int NormalRgaSetAlphaEnInfo(struct rga_req *msg,
unsigned int alpha_cal_mode, unsigned int alpha_mode,
unsigned int fg_global_alpha, unsigned int bg_global_alpha,
unsigned int PD_en, unsigned int PD_mode,
unsigned int dst_alpha_en);



Expand Down
Loading

0 comments on commit 46d74b2

Please sign in to comment.