sdm: Add support for UBWC in C2D
Add support for UBWC in gralloc alloc_buffer api and copybit
Change-Id: I264114d51c2d3caeb1611139641d99ddb006a7ce
diff --git a/libcopybit/c2d2.h b/libcopybit/c2d2.h
index 886f38a..315a3ba 100644
--- a/libcopybit/c2d2.h
+++ b/libcopybit/c2d2.h
@@ -72,6 +72,7 @@
C2D_FORMAT_MACROTILED = (1 << 16), /* tiled in macro level */
C2D_FORMAT_TILED_4x4 = (1 << 17), /* 4x4 tiled format */
C2D_FORMAT_SWAP_RB = (1 << 18), /* Swap R & B color components */
+ C2D_FORMAT_UBWC_COMPRESSED = (1 << 23), /* UBWC compressed format */
} C2D_FORMAT_MODE;
/* Definitions of supported RGB formats, used in C2D_RGB_SURFACE_DEF.
@@ -408,7 +409,8 @@
C2D_DRIVER_SUPPORTS_TARGET_RECT_OP = (1 << 15),
C2D_DRIVER_SUPPORTS_ROTATE_OP = (1 << 16), /* all rotations */
C2D_DRIVER_SUPPORTS_FLUSH_WITH_FENCE_FD_OP = (1 << 17), /* all rotations */
- C2D_DRIVER_SUPPORTS_ALL_CAPABILITIES_OP = ((0xFFFFFFFF) >> (31 - 17)) /* mask for all capabilities supported */
+ C2D_DRIVER_SUPPORTS_UBWC_COMPRESSED_OP = (1 << 18), /* UBWC Compression */
+ C2D_DRIVER_SUPPORTS_ALL_CAPABILITIES_OP = ((0xFFFFFFFF) >> (31 - 18)) /* mask for all capabilities supported */
} C2D_DRIVER_CAPABILITIES;
/* 2D driver workaround bits used by the 2D applications */
diff --git a/libcopybit/copybit.h b/libcopybit/copybit.h
index 1fc17ed..de585ee 100644
--- a/libcopybit/copybit.h
+++ b/libcopybit/copybit.h
@@ -80,6 +80,10 @@
COPYBIT_FRAMEBUFFER_HEIGHT = 8,
COPYBIT_FG_LAYER = 9,
COPYBIT_DYNAMIC_FPS = 10,
+ /* Source Format Mode */
+ COPYBIT_SRC_FORMAT_MODE = 11,
+ /* Destination Format Mode */
+ COPYBIT_DST_FORMAT_MODE = 12,
};
/* values for copybit_set_parameter(COPYBIT_TRANSFORM) */
@@ -116,6 +120,13 @@
COPYBIT_BLENDING_COVERAGE = 0x0405
};
+enum {
+ /* Linear format mode*/
+ COPYBIT_LINEAR = 0x0000,
+ /* UBWC format mode*/
+ COPYBIT_UBWC_COMPRESSED = 0x0001,
+};
+
/* use get_static_info() to query static informations about the hardware */
enum {
/* Maximum amount of minification supported by the hardware*/
@@ -126,6 +137,8 @@
COPYBIT_SCALING_FRAC_BITS = 3,
/* Supported rotation step in degres. */
COPYBIT_ROTATION_STEP_DEG = 4,
+ /* UBWC support*/
+ COPYBIT_UBWC_SUPPORT = 5,
};
/* Image structure */
diff --git a/libcopybit/copybit_c2d.cpp b/libcopybit/copybit_c2d.cpp
index cc13fec..9936eb6 100644
--- a/libcopybit/copybit_c2d.cpp
+++ b/libcopybit/copybit_c2d.cpp
@@ -124,7 +124,8 @@
enum eC2DFlags {
FLAGS_PREMULTIPLIED_ALPHA = 1<<0,
FLAGS_YUV_DESTINATION = 1<<1,
- FLAGS_TEMP_SRC_DST = 1<<2
+ FLAGS_TEMP_SRC_DST = 1<<2,
+ FLAGS_UBWC_FORMAT_MODE = 1<<3
};
static gralloc::IAllocController* sAlloc = 0;
@@ -159,6 +160,8 @@
void* time_stamp;
bool dst_surface_mapped; // Set when dst surface is mapped to GPU addr
void* dst_surface_base; // Stores the dst surface addr
+ bool is_src_ubwc_format;
+ bool is_dst_ubwc_format;
// used for signaling the wait thread
bool wait_timestamp;
@@ -543,6 +546,10 @@
surfaceDef.format = c2d_format |
((flags & FLAGS_PREMULTIPLIED_ALPHA) ? C2D_FORMAT_PREMULTIPLIED : 0);
+
+ surfaceDef.format = surfaceDef.format |
+ ((flags & FLAGS_UBWC_FORMAT_MODE) ? C2D_FORMAT_UBWC_COMPRESSED : 0);
+
surfaceDef.width = rhs->w;
surfaceDef.height = rhs->h;
int aligned_width = ALIGN((int)surfaceDef.width,32);
@@ -699,6 +706,8 @@
int flags = FLAGS_PREMULTIPLIED_ALPHA;
int mapped_dst_idx = -1;
struct copybit_context_t* ctx = (struct copybit_context_t*)dev;
+ if (ctx->is_dst_ubwc_format)
+ flags |= FLAGS_UBWC_FORMAT_MODE;
C2D_RECT c2drect = {rect->l, rect->t, rect->r - rect->l, rect->b - rect->t};
pthread_mutex_lock(&ctx->wait_cleanup_lock);
if(!ctx->dst_surface_mapped) {
@@ -864,6 +873,12 @@
case COPYBIT_BLIT_TO_FRAMEBUFFER:
// Do nothing
break;
+ case COPYBIT_SRC_FORMAT_MODE:
+ ctx->is_src_ubwc_format = (value == COPYBIT_UBWC_COMPRESSED);
+ break;
+ case COPYBIT_DST_FORMAT_MODE:
+ ctx->is_dst_ubwc_format = (value == COPYBIT_UBWC_COMPRESSED);
+ break;
default:
ALOGE("%s: default case param=0x%x", __FUNCTION__, name);
status = -EINVAL;
@@ -897,6 +912,12 @@
case COPYBIT_ROTATION_STEP_DEG:
value = 1;
break;
+ case COPYBIT_UBWC_SUPPORT:
+ value = 0;
+ if (ctx->c2d_driver_info.capabilities_mask & C2D_DRIVER_SUPPORTS_UBWC_COMPRESSED_OP) {
+ value = 1;
+ }
+ break;
default:
ALOGE("%s: default case param=0x%x", __FUNCTION__, name);
value = -EINVAL;
@@ -1123,6 +1144,9 @@
}
int dst_surface_type;
+ if (ctx->is_dst_ubwc_format)
+ flags |= FLAGS_UBWC_FORMAT_MODE;
+
if (is_supported_rgb_format(dst->format) == COPYBIT_SUCCESS) {
dst_surface_type = RGB_SURFACE;
flags |= FLAGS_PREMULTIPLIED_ALPHA;
@@ -1305,6 +1329,7 @@
flags |= (ctx->is_premultiplied_alpha) ? FLAGS_PREMULTIPLIED_ALPHA : 0;
flags |= (ctx->dst_surface_type != RGB_SURFACE) ? FLAGS_YUV_DESTINATION : 0;
+ flags |= (ctx->is_src_ubwc_format) ? FLAGS_UBWC_FORMAT_MODE : 0;
status = set_image(ctx, src_surface.surface_id, &src_image,
(eC2DFlags)flags, mapped_src_idx);
if(status) {