display: Add support for UBWC in display hal
1. Add support for UBWC allocation in the Gralloc APIs for aligned
width, aligned height and buffer size. A client can request for UBWC
allocation by sending UBWC specific HAL pixel format or by setting
GRALLOC_USAGE_PRIVATE_ALLOC_UBWC flag in the usage flags.
2. Gralloc allocates UBWC aligned buffer, only if format is supported
by GPU and MDP and no CPU usage flags are set. Otherwise it allocates
linear buffer.
3. If UBWC conditions are met, gralloc sets PRIV_FLAGS_UBWC_ALIGNED
in private handle flags to tell client that allocated buffer has UBWC
alignment. This flag remains unset by default.
4. Add helper functions in gralloc to calculate UBWC meta buffer size
for RGB* formats.
5. Add UBWC HAL pixel format HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC
which has been defined by Video module.
6. Add AdrenoMemInfo api to query, if GPU supports UBWC for a format.
7.MDP driver expects UBWC specific pixel format defined by MDP header.
Change-Id: I5b4344bc90aa498dbdb7bb8100e70ed7728e6ea5
diff --git a/liboverlay/overlayUtils.cpp b/liboverlay/overlayUtils.cpp
index dd030ef..b37eba9 100644
--- a/liboverlay/overlayUtils.cpp
+++ b/liboverlay/overlayUtils.cpp
@@ -141,12 +141,28 @@
return -1;
}
-// This function returns corresponding tile format
-// MDSS support following RGB tile formats
-// 32 bit formats
-// 16 bit formats
-int getMdpFormat(int format, bool tileEnabled)
+int getMdpFormat(int format, int flags)
{
+ bool uBwcEnabled = (flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED);
+ bool tileEnabled = (flags & private_handle_t::PRIV_FLAGS_TILE_RENDERED);
+
+ // Use UBWC extension, if UBWC is enabled
+ if (uBwcEnabled) {
+ switch (format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ return MDP_RGBA_8888_UBWC;
+ case HAL_PIXEL_FORMAT_RGB_565:
+ return MDP_RGB_565_UBWC;
+ case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC:
+ return MDP_Y_CBCR_H2V2_UBWC;
+ default:
+ ALOGE("%s: Unsupported HAL format = 0x%x", __func__, format);
+ break;
+ }
+ }
+
if(!tileEnabled) {
return getMdpFormat(format);
}