summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harkin <ryan.harkin@linaro.org>2017-05-10 17:49:25 +0100
committerRyan Harkin <ryan.harkin@linaro.org>2017-05-10 17:49:25 +0100
commit9cb5eca72214ff5bc7070f7dcff75585a00bbd56 (patch)
treecf793dc6ce8efacb8b8cede413c6e9802a4bab5e
parentb2ae48872e30ce68eb9a4d6c3afb053b274b8ce4 (diff)
downloadjuno-linaro-nougat.tar.gz
Update to Mali version r15p0-00rel0RLCR-17.05linaro-nougat
The gralloc source came from TX041-SW-99005-r15p0-00rel0.tgz downloaded from developer.arm.com, with Android.mk modified to work in Linaro builds. The binary libraries came from a file supplied by ARM called mali-t62x_r15p0-00rel0_android-7.0_1.tar.gz Change-Id: I2cf21f07ece42fb09e849b5bd8486029d2ac0d41 Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rwxr-xr-xgralloc/src/Android.mk18
-rwxr-xr-xgralloc/src/alloc_device.cpp571
-rwxr-xr-xgralloc/src/alloc_ion.cpp50
-rwxr-xr-xgralloc/src/format_chooser.cpp357
-rwxr-xr-xgralloc/src/format_chooser.h220
-rwxr-xr-xgralloc/src/format_chooser_blockinit.cpp286
-rwxr-xr-xgralloc/src/formatdef_files/display_afbc.defs35
-rwxr-xr-xgralloc/src/formatdef_files/gpu_afbc.defs56
-rwxr-xr-xgralloc/src/formatdef_files/gpu_afbc_wideblk.defs78
-rwxr-xr-xgralloc/src/formatdef_files/gpu_default.defs68
-rwxr-xr-xgralloc/src/framebuffer_device.cpp4
-rwxr-xr-xgralloc/src/framebuffer_device.h1
-rwxr-xr-xgralloc/src/gralloc_helper.h14
-rwxr-xr-xgralloc/src/gralloc_module.cpp48
-rwxr-xr-xgralloc/src/gralloc_priv.h52
-rwxr-xr-xgralloc/src/gralloc_vsync_default.cpp2
-rwxr-xr-xgralloc/src/gralloc_vsync_report.h4
-rwxr-xr-xgralloc/src/mali_gralloc_formats.cpp523
-rwxr-xr-xgralloc/src/mali_gralloc_formats.h299
-rw-r--r--mali/lib/egl/libGLES_mali.sobin24539616 -> 26670072 bytes
-rw-r--r--mali/lib/hw/gralloc.juno.sobin40000 -> 34452 bytes
-rw-r--r--mali/lib/libRSDriverArm.sobin255612 -> 255612 bytes
-rw-r--r--mali/lib/libbccArm.sobin226960 -> 226960 bytes
-rw-r--r--mali/lib/libmalicore.bcbin143156 -> 143132 bytes
-rw-r--r--mali/lib64/egl/libGLES_mali.sobin26007768 -> 28343968 bytes
-rw-r--r--mali/lib64/hw/gralloc.juno.sobin36496 -> 30928 bytes
-rw-r--r--mali/lib64/libRSDriverArm.sobin325816 -> 321720 bytes
-rw-r--r--mali/lib64/libbccArm.sobin297160 -> 297160 bytes
-rw-r--r--mali/lib64/libmalicore.bcbin152924 -> 152900 bytes
29 files changed, 1317 insertions, 1369 deletions
diff --git a/gralloc/src/Android.mk b/gralloc/src/Android.mk
index 7fbc4b4..23d7706 100755
--- a/gralloc/src/Android.mk
+++ b/gralloc/src/Android.mk
@@ -24,11 +24,14 @@ MALI_ARCHITECTURE_UTGARD?=0
MALI_ION?=1
GRALLOC_VSYNC_BACKEND?=default
DISABLE_FRAMEBUFFER_HAL?=0
+MALI_SUPPORT_AFBC_SPLITBLK?=0
MALI_SUPPORT_AFBC_WIDEBLK?=0
+MALI_SUPPORT_AFBC_TILED_HEADERS?=0
MALI_USE_YUV_AFBC_WIDEBLK?=0
GRALLOC_USE_ION_DMA_HEAP?=0
GRALLOC_USE_ION_COMPOUND_PAGE_HEAP?=0
GRALLOC_INIT_AFBC?=0
+MALI_VIDEO_VERSION?=0
# HAL module implemenation, not prelinked and stored in
# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so
@@ -37,13 +40,14 @@ include $(BUILD_SYSTEM)/version_defaults.mk
ifeq ($(TARGET_BOARD_PLATFORM), juno)
ifeq ($(MALI_MMSS), 1)
- GRALLOC_FB_SWAP_RED_BLUE = 0
+ GRALLOC_FB_SWAP_RED_BLUE = 0
GRALLOC_DEPTH = GRALLOC_32_BITS
MALI_ION = 1
MALI_AFBC_GRALLOC = 1
MALI_DISPLAY_VERSION = 550
AFBC_YUV420_EXTRA_MB_ROW_NEEDED = 1
GRALLOC_USE_ION_DMA_HEAP = 1
+ MALI_VIDEO_VERSION = 500
endif
endif
@@ -64,7 +68,6 @@ ifeq ($(MALI_ARCHITECTURE_UTGARD),1)
GRALLOC_DEPTH?=GRALLOC_32_BITS
GRALLOC_FB_SWAP_RED_BLUE?=1
MALI_DDK_INCLUDES=$(MALI_LOCAL_PATH)/include $(MALI_LOCAL_PATH)/src/ump/include
-# LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
ifeq ($(MALI_ION),1)
ALLOCATION_LIB := libion
ALLOCATOR_SPECIFIC_FILES := alloc_ion.cpp gralloc_module_ion.cpp
@@ -78,7 +81,6 @@ else
GRALLOC_DEPTH?=GRALLOC_16_BITS
GRALLOC_FB_SWAP_RED_BLUE?=0
MALI_DDK_INCLUDES=$(MALI_LOCAL_PATH)/include $(MALI_LOCAL_PATH)/kernel/include
-# LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/hw
ifeq ($(MALI_ION),1)
ALLOCATION_LIB := libion
ALLOCATOR_SPECIFIC_FILES := alloc_ion.cpp gralloc_module_ion.cpp
@@ -110,7 +112,7 @@ LOCAL_PRELINK_MODULE := false
LOCAL_SHARED_LIBRARIES := libhardware liblog libcutils libGLESv1_CM $(ALLOCATION_LIB)
LOCAL_C_INCLUDES := $(MALI_LOCAL_PATH) $(MALI_DDK_INCLUDES)
-LOCAL_CFLAGS := -DLOG_TAG=\"gralloc\" -DSTANDARD_LINUX_SCREEN -DMALI_ION=$(MALI_ION) -DMALI_AFBC_GRALLOC=$(MALI_AFBC_GRALLOC) -D$(GRALLOC_DEPTH) -DMALI_ARCHITECTURE_UTGARD=$(MALI_ARCHITECTURE_UTGARD) -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) -DDISABLE_FRAMEBUFFER_HAL=$(DISABLE_FRAMEBUFFER_HAL) -DMALI_SUPPORT_AFBC_WIDEBLK=$(MALI_SUPPORT_AFBC_WIDEBLK) -DMALI_USE_YUV_AFBC_WIDEBLK=$(MALI_USE_YUV_AFBC_WIDEBLK) -DAFBC_YUV420_EXTRA_MB_ROW_NEEDED=$(AFBC_YUV420_EXTRA_MB_ROW_NEEDED) -DGRALLOC_USE_ION_DMA_HEAP=$(GRALLOC_USE_ION_DMA_HEAP) -DGRALLOC_USE_ION_COMPOUND_PAGE_HEAP=$(GRALLOC_USE_ION_COMPOUND_PAGE_HEAP) -DGRALLOC_INIT_AFBC=$(GRALLOC_INIT_AFBC)
+LOCAL_CFLAGS := -Werror -DLOG_TAG=\"gralloc\" -DSTANDARD_LINUX_SCREEN -DMALI_ION=$(MALI_ION) -DMALI_AFBC_GRALLOC=$(MALI_AFBC_GRALLOC) -D$(GRALLOC_DEPTH) -DMALI_ARCHITECTURE_UTGARD=$(MALI_ARCHITECTURE_UTGARD) -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) -DDISABLE_FRAMEBUFFER_HAL=$(DISABLE_FRAMEBUFFER_HAL) -DMALI_SUPPORT_AFBC_WIDEBLK=$(MALI_SUPPORT_AFBC_WIDEBLK) -DMALI_USE_YUV_AFBC_WIDEBLK=$(MALI_USE_YUV_AFBC_WIDEBLK) -DMALI_SUPPORT_AFBC_TILED_HEADERS=$(MALI_SUPPORT_AFBC_TILED_HEADERS) -DAFBC_YUV420_EXTRA_MB_ROW_NEEDED=$(AFBC_YUV420_EXTRA_MB_ROW_NEEDED) -DGRALLOC_USE_ION_DMA_HEAP=$(GRALLOC_USE_ION_DMA_HEAP) -DGRALLOC_USE_ION_COMPOUND_PAGE_HEAP=$(GRALLOC_USE_ION_COMPOUND_PAGE_HEAP) -DGRALLOC_INIT_AFBC=$(GRALLOC_INIT_AFBC) -DMALI_VIDEO_VERSION=$(MALI_VIDEO_VERSION) -DMALI_SUPPORT_AFBC_SPLITBLK=$(MALI_SUPPORT_AFBC_SPLITBLK)
ifdef GRALLOC_DISP_W
LOCAL_CFLAGS += -DGRALLOC_DISP_W=$(GRALLOC_DISP_W)
@@ -138,9 +140,6 @@ ifeq ($(GRALLOC_ARM_NO_EXTERNAL_AFBC),1)
LOCAL_CFLAGS += -DGRALLOC_ARM_NO_EXTERNAL_AFBC=1
endif
-ifdef PLATFORM_CFLAGS
-LOCAL_CFLAGS += $(PLATFORM_CFLAGS)
-endif
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE := gralloc.juno
@@ -152,10 +151,9 @@ LOCAL_SRC_FILES := \
alloc_device.cpp \
$(ALLOCATOR_SPECIFIC_FILES) \
framebuffer_device.cpp \
- format_chooser.cpp \
- format_chooser_blockinit.cpp \
$(AFBC_FILES) \
- gralloc_vsync_${GRALLOC_VSYNC_BACKEND}.cpp
+ gralloc_vsync_${GRALLOC_VSYNC_BACKEND}.cpp \
+ mali_gralloc_formats.cpp
LOCAL_MODULE_OWNER := arm
diff --git a/gralloc/src/alloc_device.cpp b/gralloc/src/alloc_device.cpp
index 7851b1b..b8bc445 100755
--- a/gralloc/src/alloc_device.cpp
+++ b/gralloc/src/alloc_device.cpp
@@ -37,12 +37,21 @@
#include "gralloc_buffer_priv.h"
#endif
-#include "format_chooser.h"
+#include "mali_gralloc_formats.h"
#define AFBC_PIXELS_PER_BLOCK 16
-#define AFBC_BODY_BUFFER_BYTE_ALIGNMENT 1024
#define AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY 16
+
+#define AFBC_BODY_BUFFER_BYTE_ALIGNMENT 1024
+#define AFBC_NORMAL_WIDTH_ALIGN 16
+#define AFBC_NORMAL_HEIGHT_ALIGN 16
#define AFBC_WIDEBLK_WIDTH_ALIGN 32
+#define AFBC_WIDEBLK_HEIGHT_ALIGN 16
+// Regarding Tiled Headers AFBC mode, both header and body buffer should aligned to 4KB
+// and in non-wide mode (16x16), the width and height should be both rounded up to 128
+// in wide mode (32x8) the width should be rounded up to 256, the height should be rounded up to 64
+#define AFBC_TILED_HEADERS_WIDTH_ALIGN 128
+#define AFBC_TILED_HEADERS_HEIGHT_ALIGN 128
// This value is platform specific and should be set according to hardware YUV planes restrictions.
// Please note that EGL winsys platform config file needs to use the same value when importing buffers.
@@ -150,7 +159,12 @@ enum AllocType
AFBC_WIDEBLK,
/* AN AFBC buffer with additional padding to ensure a 64-bte alignment
* for each row of blocks in the header */
- AFBC_PADDED
+ AFBC_PADDED,
+ /* AFBC_TILED_HEADERS_AFBC mode requires buffer to have 128*128 pixels alignment(16x16 superblocks) */
+ AFBC_TILED_HEADERS_BASIC,
+
+ /* These are currently unsupported */
+ AFBC_TILED_HEADERS_WIDEBLK,
};
/*
@@ -194,20 +208,29 @@ static void get_rgb_stride_and_size(int width, int height, int pixel_size,
if (type != UNCOMPRESSED)
{
int w_aligned;
- int h_aligned = GRALLOC_ALIGN( height, AFBC_PIXELS_PER_BLOCK );
+ int h_aligned = GRALLOC_ALIGN( height, AFBC_NORMAL_HEIGHT_ALIGN );
int nblocks;
+ int buffer_byte_alignment = AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
if (type == AFBC_PADDED)
{
w_aligned = GRALLOC_ALIGN( width, 64 );
}
+ else if (type == AFBC_TILED_HEADERS_BASIC)
+ {
+ w_aligned = GRALLOC_ALIGN( width, AFBC_TILED_HEADERS_WIDTH_ALIGN );
+ h_aligned = GRALLOC_ALIGN( height, AFBC_TILED_HEADERS_HEIGHT_ALIGN );
+ buffer_byte_alignment = 4 * AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
+ }
+
else if (type == AFBC_WIDEBLK)
{
w_aligned = GRALLOC_ALIGN( width, AFBC_WIDEBLK_WIDTH_ALIGN );
+ h_aligned = GRALLOC_ALIGN( height, AFBC_WIDEBLK_HEIGHT_ALIGN );
}
else
{
- w_aligned = GRALLOC_ALIGN( width, AFBC_PIXELS_PER_BLOCK );
+ w_aligned = GRALLOC_ALIGN( width, AFBC_NORMAL_WIDTH_ALIGN );
}
nblocks = w_aligned / AFBC_PIXELS_PER_BLOCK * h_aligned / AFBC_PIXELS_PER_BLOCK;
@@ -215,7 +238,7 @@ static void get_rgb_stride_and_size(int width, int height, int pixel_size,
if ( size != NULL )
{
*size = w_aligned * h_aligned * pixel_size +
- GRALLOC_ALIGN( nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, AFBC_BODY_BUFFER_BYTE_ALIGNMENT );
+ GRALLOC_ALIGN( nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment );
}
}
}
@@ -230,16 +253,18 @@ static void get_rgb_stride_and_size(int width, int height, int pixel_size,
* byte_stride (out) stride of the buffer in bytes
* size (out) size of the buffer in bytes
* type if buffer should be allocated for a certain afbc type
- * internalHeight (out) Will store internal height if it is required to have a greater height than
- * known to public. If not it will be left untouched.
+ * internalHeight (out) The internal height, which may be greater than the public known height.
*/
-static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size, AllocType type, int *internalHeight)
+static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride,
+ size_t* size, AllocType type, int *internalHeight)
{
int yuv420_afbc_luma_stride, yuv420_afbc_chroma_stride;
+ *internalHeight = height;
+
if (type == UNCOMPRESSED)
{
- AERR(" Buffer must be allocated with AFBC mode for internal pixel format YUV420_10BIT_AFBC!");
+ AERR(" Buffer must be allocated with AFBC mode for internal pixel format YUV420_8BIT_AFBC!");
return false;
}
@@ -249,15 +274,6 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
return false;
}
- if (type == AFBC_WIDEBLK)
- {
- width = GRALLOC_ALIGN(width, AFBC_WIDEBLK_WIDTH_ALIGN);
- }
- else
- {
- width = GRALLOC_ALIGN(width, AFBC_PIXELS_PER_BLOCK);
- }
-
#if AFBC_YUV420_EXTRA_MB_ROW_NEEDED
/* If we have a greater internal height than public we set the internalHeight. This
* implies that cropping will be applied of internal dimensions to fit the public one. */
@@ -267,7 +283,17 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
/* The actual height used in size calculation must include the possible extra row. But
* it must also be AFBC-aligned. Only the extra row-padding should be reported back in
* internalHeight. This as only this row needs to be considered when cropping. */
- height = GRALLOC_ALIGN( *internalHeight, AFBC_PIXELS_PER_BLOCK );
+
+ if (type == AFBC_WIDEBLK)
+ {
+ width = GRALLOC_ALIGN(width, AFBC_WIDEBLK_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN( *internalHeight, AFBC_WIDEBLK_HEIGHT_ALIGN );
+ }
+ else
+ {
+ width = GRALLOC_ALIGN(width, AFBC_NORMAL_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN( *internalHeight, AFBC_NORMAL_HEIGHT_ALIGN );
+ }
yuv420_afbc_luma_stride = width;
yuv420_afbc_chroma_stride = GRALLOC_ALIGN(yuv420_afbc_luma_stride / 2, 16); /* Horizontal downsampling*/
@@ -304,26 +330,23 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
* byte_stride (out) stride of the buffer in bytes
* size (out) size of the buffer in bytes
* type (in) if buffer should be allocated for a certain afbc type
- * internalHeight (out) Will store internal height if it is required to have a greater height than
- * known to public. If not it will be left untouched.
+ * internalHeight (out) The internal height, which may be greater than the public known height.
* stride_alignment (in) stride aligment value in bytes.
*/
-static bool get_yv12_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride,
- size_t* size, AllocType type, int* internalHeight, int stride_alignment)
+static bool get_yv12_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size,
+ AllocType type, int* internalHeight, int stride_alignment)
{
int luma_stride;
- /* Android assumes the width and height are even withou checking, so we check here */
- if (width % 2 != 0 || height % 2 != 0)
- {
- return false;
- }
-
if (type != UNCOMPRESSED)
{
return get_afbc_yuv420_8bit_stride_and_size(width, height, pixel_stride, byte_stride, size, type, internalHeight);
}
+ /* 4:2:0 formats must have buffers with even height and width as the clump size is 2x2 pixels.
+ * Width will be even stride aligned anyway so just adjust height here for size calculation. */
+ height = GRALLOC_ALIGN(height, 2);
+
luma_stride = GRALLOC_ALIGN(width, stride_alignment);
if (size != NULL)
@@ -345,6 +368,43 @@ static bool get_yv12_stride_and_size(int width, int height, int* pixel_stride, i
return true;
}
+/*
+ * Computes the strides and size for an 8 bit YUYV 422 buffer
+ *
+ * width Public known width of the buffer in pixels
+ * height Public known height of the buffer in pixels
+ *
+ * pixel_stride (out) stride of the buffer in pixels
+ * byte_stride (out) stride of the buffer in bytes
+ * size (out) size of the buffer in bytes
+ */
+static bool get_yuv422_8bit_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size)
+{
+ int local_byte_stride, local_pixel_stride;
+
+ /* 4:2:2 formats must have buffers with even width as the clump size is 2x1 pixels.
+ * This is taken care of by the even stride alignment. */
+
+ local_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
+ local_byte_stride = GRALLOC_ALIGN(width * 2, YUV_MALI_PLANE_ALIGN); /* 4 bytes per 2 pixels */
+
+ if (size != NULL)
+ {
+ *size = local_byte_stride * height;
+ }
+
+ if (byte_stride != NULL)
+ {
+ *byte_stride = local_byte_stride;
+ }
+
+ if (pixel_stride != NULL)
+ {
+ *pixel_stride = local_pixel_stride;
+ }
+
+ return true;
+}
/*
* Computes the strides and size for an AFBC 8BIT YUV 4:2:2 buffer
@@ -363,7 +423,7 @@ static bool get_afbc_yuv422_8bit_stride_and_size(int width, int height, int* pix
if (type == UNCOMPRESSED)
{
- AERR(" Buffer must be allocated with AFBC mode for internal pixel format YUV420_10BIT_AFBC!");
+ AERR(" Buffer must be allocated with AFBC mode for internal pixel format YUV422_8BIT_AFBC!");
return false;
}
@@ -376,12 +436,13 @@ static bool get_afbc_yuv422_8bit_stride_and_size(int width, int height, int* pix
if (type == AFBC_WIDEBLK)
{
width = GRALLOC_ALIGN(width, AFBC_WIDEBLK_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(width, AFBC_WIDEBLK_HEIGHT_ALIGN);
}
else
{
- width = GRALLOC_ALIGN(width, AFBC_PIXELS_PER_BLOCK);
+ width = GRALLOC_ALIGN(width, AFBC_NORMAL_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(width, AFBC_NORMAL_HEIGHT_ALIGN);
}
- height = GRALLOC_ALIGN(height, AFBC_PIXELS_PER_BLOCK);
yuv422_afbc_luma_stride = width;
@@ -433,10 +494,12 @@ static bool get_yuv_pX10_stride_and_size(int width, int height, int vss, int* pi
return false;
}
- /* odd height is allowed for P210 (2x1 sub-sampling) */
- if ((width & 1) || (vss == 2 && (height & 1)))
+ /* 4:2:2 must have even width as the clump size is 2x1 pixels. This will be taken care of by the
+ * even stride alignment */
+ if (vss == 2)
{
- return false;
+ /* 4:2:0 must also have even height as the clump size is 2x2 */
+ height = GRALLOC_ALIGN(height, 2);
}
luma_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
@@ -462,7 +525,7 @@ static bool get_yuv_pX10_stride_and_size(int width, int height, int vss, int* pi
}
/*
- * Calculate strides and strides for Y210 (YUYV packed, 4:2:2) format buffer.
+ * Calculate strides and strides for Y210 (10 bit YUYV packed, 4:2:2) format buffer.
*
* @param width [in] Buffer width.
* @param height [in] Buffer height.
@@ -480,17 +543,15 @@ static bool get_yuv_y210_stride_and_size(int width, int height, int* pixel_strid
{
int y210_byte_stride, y210_pixel_stride;
- if (width & 1)
- {
- return false;
- }
+ /* 4:2:2 formats must have buffers with even width as the clump size is 2x1 pixels.
+ * This is taken care of by the even stride alignment */
y210_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
+ /* 4x16 bits per 2 pixels */
y210_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN);
if (size != NULL)
{
- /* 4x16bits per pixel */
*size = y210_byte_stride * height;
}
@@ -521,23 +582,24 @@ static bool get_yuv_y210_stride_and_size(int width, int height, int* pixel_strid
*
* @return true if the calculation was successful; false otherwise (invalid
* parameter)
+ *
+ * @note Each YUYAAYVYAA clump encodes a 2x2 area of pixels. YU&V are 10 bits. A is 1 bit. total 8 bytes
+ *
*/
static bool get_yuv_y0l2_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size)
{
int y0l2_byte_stride, y0l2_pixel_stride;
- if (width & 3)
- {
- return false;
- }
+ /* 4:2:0 formats must have buffers with even height and width as the clump size is 2x2 pixels.
+ * Width is take care of by the even stride alignment so just adjust height here for size calculation. */
+ height = GRALLOC_ALIGN(height, 2);
- y0l2_pixel_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN); /* 4 pixels packed per line */
- y0l2_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN); /* Packed in 64-bit chunks, 2 x downsampled horizontally */
+ y0l2_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
+ y0l2_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN); /* 2 horiz pixels per 8 byte clump */
if (size != NULL)
{
- /* 2 x downsampled vertically */
- *size = y0l2_byte_stride * (height/2);
+ *size = y0l2_byte_stride * height / 2; /* byte stride covers 2 vert pixels */
}
if (byte_stride != NULL)
@@ -610,6 +672,7 @@ static bool get_yuv_y410_stride_and_size(int width, int height, int* pixel_strid
static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size, AllocType type)
{
int yuv420_afbc_byte_stride, yuv420_afbc_pixel_stride;
+ int buffer_byte_alignment = AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
if (width & 3)
{
@@ -628,15 +691,22 @@ static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int* pi
return false;
}
- if (type == AFBC_WIDEBLK)
+ if (type == AFBC_TILED_HEADERS_BASIC)
+ {
+ width = GRALLOC_ALIGN(width, AFBC_TILED_HEADERS_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(height/2, AFBC_TILED_HEADERS_HEIGHT_ALIGN);
+ buffer_byte_alignment = 4 * AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
+ }
+ else if (type == AFBC_WIDEBLK)
{
width = GRALLOC_ALIGN(width, AFBC_WIDEBLK_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(height/2, AFBC_WIDEBLK_HEIGHT_ALIGN);
}
else
{
- width = GRALLOC_ALIGN(width, AFBC_PIXELS_PER_BLOCK);
+ width = GRALLOC_ALIGN(width, AFBC_NORMAL_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(height/2, AFBC_NORMAL_HEIGHT_ALIGN);
}
- height = GRALLOC_ALIGN(height/2, AFBC_PIXELS_PER_BLOCK); /* vertically downsampled */
yuv420_afbc_pixel_stride = GRALLOC_ALIGN(width, 16);
yuv420_afbc_byte_stride = GRALLOC_ALIGN(width * 4, 16); /* 64-bit packed and horizontally downsampled */
@@ -645,7 +715,7 @@ static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int* pi
{
int nblocks = width / AFBC_PIXELS_PER_BLOCK * height / AFBC_PIXELS_PER_BLOCK;
*size = yuv420_afbc_byte_stride * height
- + GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, AFBC_BODY_BUFFER_BYTE_ALIGNMENT);
+ + GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
}
if (byte_stride != NULL)
@@ -688,7 +758,7 @@ static bool get_yuv422_10bit_afbc_stride_and_size(int width, int height, int* pi
if (type == UNCOMPRESSED)
{
- AERR(" Buffer must be allocated with AFBC mode for internal pixel format YUV420_10BIT_AFBC!");
+ AERR(" Buffer must be allocated with AFBC mode for internal pixel format YUV422_10BIT_AFBC!");
return false;
}
@@ -701,12 +771,13 @@ static bool get_yuv422_10bit_afbc_stride_and_size(int width, int height, int* pi
if (type == AFBC_WIDEBLK)
{
width = GRALLOC_ALIGN(width, AFBC_WIDEBLK_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(height, AFBC_WIDEBLK_HEIGHT_ALIGN);
}
else
{
- width = GRALLOC_ALIGN(width, AFBC_PIXELS_PER_BLOCK);
+ width = GRALLOC_ALIGN(width, AFBC_NORMAL_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(height, AFBC_NORMAL_HEIGHT_ALIGN);
}
- height = GRALLOC_ALIGN(height, AFBC_PIXELS_PER_BLOCK); /* total number of rows must be even number */
yuv422_afbc_pixel_stride = GRALLOC_ALIGN(width, 16);
yuv422_afbc_byte_stride = GRALLOC_ALIGN(width * 2, 16);
@@ -732,6 +803,81 @@ static bool get_yuv422_10bit_afbc_stride_and_size(int width, int height, int* pi
return true;
}
+/*
+ * Calculate strides and strides for Camera RAW and Blob formats
+ *
+ * @param w [in] Buffer width.
+ * @param h [in] Buffer height.
+ * @param format [in] Requested HAL format
+ * @param out_stride [out] Pixel stride; number of pixels/bytes between
+ * consecutive rows. Format description calls for
+ * either bytes or pixels.
+ * @param size [out] Size of the buffer in bytes. Cumulative sum of
+ * sizes of all planes.
+ *
+ * @return true if the calculation was successful; false otherwise (invalid
+ * parameter)
+ */
+static bool get_camera_formats_stride_and_size(int w, int h, uint64_t format, int *out_stride, size_t *out_size)
+{
+ int stride, size;
+
+ switch (format)
+ {
+ case HAL_PIXEL_FORMAT_RAW16:
+ stride = w; /* Format assumes stride in pixels */
+ stride = GRALLOC_ALIGN(stride, 16); /* Alignment mandated by Android */
+ size = stride * h * 2; /* 2 bytes per pixel */
+ break;
+
+ case HAL_PIXEL_FORMAT_RAW12:
+ if (w % 4 != 0)
+ {
+ ALOGE("ERROR: Width for HAL_PIXEL_FORMAT_RAW12 buffers has to be multiple of 4.");
+ return false;
+ }
+ stride = (w / 2) * 3; /* Stride in bytes; 2 pixels in 3 bytes */
+ size = stride * h;
+ break;
+
+ case HAL_PIXEL_FORMAT_RAW10:
+ if (w % 4 != 0)
+ {
+ ALOGE("ERROR: Width for HAL_PIXEL_FORMAT_RAW10 buffers has to be multiple of 4.");
+ return false;
+ }
+ stride = (w / 4) * 5; /* Stride in bytes; 4 pixels in 5 bytes */
+ size = stride * h;
+ break;
+
+ case HAL_PIXEL_FORMAT_BLOB:
+ if (h != 1)
+ {
+ ALOGE("ERROR: Height for HAL_PIXEL_FORMAT_BLOB must be 1.");
+ return false;
+ }
+ stride = 0; /* No 'rows', it's effectively a long one dimensional array */
+ size = w;
+ break;
+
+ default:
+ return false;
+
+ }
+
+ if (out_size != NULL)
+ {
+ *out_size = size;
+ }
+
+ if (out_stride != NULL)
+ {
+ *out_stride = stride;
+ }
+
+ return true;
+}
+
static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int usage, buffer_handle_t* pHandle, int* pStride)
{
@@ -745,7 +891,6 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
int pixel_stride; // Stride of the buffer in pixels - as returned in pStride
uint64_t internal_format;
AllocType type = UNCOMPRESSED;
- bool alloc_for_extended_yuv = false, alloc_for_arm_afbc_yuv = false;
int internalWidth,internalHeight;
#if defined(GRALLOC_FB_SWAP_RED_BLUE)
@@ -766,27 +911,39 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
internalWidth = w;
internalHeight = h;
- internal_format = gralloc_select_format(format, usage, w*h);
-
- alloc_for_extended_yuv = (internal_format & GRALLOC_ARM_INTFMT_EXTENDED_YUV) == GRALLOC_ARM_INTFMT_EXTENDED_YUV;
- alloc_for_arm_afbc_yuv = (internal_format & GRALLOC_ARM_INTFMT_ARM_AFBC_YUV) == GRALLOC_ARM_INTFMT_ARM_AFBC_YUV;
+ internal_format = mali_gralloc_select_format(format, usage, w*h);
+ if(internal_format == 0)
+ {
+ ALOGE("Unrecognized and/or unsupported format(0x%08X) and usage(0x%08X).",format,usage);
+ return -EINVAL;
+ }
- if (internal_format & (GRALLOC_ARM_INTFMT_AFBC | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK))
+ if (internal_format & MALI_GRALLOC_INTFMT_AFBCENABLE_MASK)
{
- if (usage & GRALLOC_USAGE_PRIVATE_2)
+ if (usage & MALI_GRALLOC_USAGE_AFBC_PADDING)
{
type = AFBC_PADDED;
}
- else if (internal_format & GRALLOC_ARM_INTFMT_AFBC_WIDEBLK)
+ else if (internal_format & MALI_GRALLOC_INTFMT_AFBC_WIDEBLK)
+ {
+ type = AFBC_WIDEBLK;
+ }
+ else if (internal_format & MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS)
{
-#if 1 != MALI_USE_YUV_AFBC_WIDEBLK
- if (alloc_for_arm_afbc_yuv)
+ if (internal_format & MALI_GRALLOC_INTFMT_AFBC_BASIC)
{
- ALOGE("Unsupported format YUV AFBC WIDEBLK.");
+ type = AFBC_TILED_HEADERS_BASIC;
+ }
+ else if (internal_format & MALI_GRALLOC_INTFMT_AFBC_SPLITBLK)
+ {
+ ALOGE("Unsupported format. Splitblk in tiled header configuration.");
+ return -EINVAL;
+ }
+ else if (internal_format & MALI_GRALLOC_INTFMT_AFBC_WIDEBLK)
+ {
+ ALOGE("Unsupported format. Wideblk in tiled header configuration.");
return -EINVAL;
}
-#endif
- type = AFBC_WIDEBLK;
}
else
{
@@ -794,138 +951,162 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
}
}
- /* map format if necessary */
- uint64_t mapped_format = map_format(internal_format & GRALLOC_ARM_INTFMT_FMT_MASK);
-
- if (!alloc_for_extended_yuv && !alloc_for_arm_afbc_yuv)
+ uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+ switch (base_format)
{
- switch (mapped_format)
- {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- case HAL_PIXEL_FORMAT_RGBX_8888:
- case HAL_PIXEL_FORMAT_BGRA_8888:
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
#if (PLATFORM_SDK_VERSION >= 19) && (PLATFORM_SDK_VERSION <= 22)
- case HAL_PIXEL_FORMAT_sRGB_A_8888:
- case HAL_PIXEL_FORMAT_sRGB_X_8888:
+ case HAL_PIXEL_FORMAT_sRGB_A_8888:
+ case HAL_PIXEL_FORMAT_sRGB_X_8888:
#endif
- get_rgb_stride_and_size(w, h, 4, &pixel_stride, &byte_stride, &size, type );
- break;
- case HAL_PIXEL_FORMAT_RGB_888:
- get_rgb_stride_and_size(w, h, 3, &pixel_stride, &byte_stride, &size, type );
- break;
- case HAL_PIXEL_FORMAT_RGB_565:
+ get_rgb_stride_and_size(w, h, 4, &pixel_stride, &byte_stride, &size, type );
+ break;
+ case HAL_PIXEL_FORMAT_RGB_888:
+ get_rgb_stride_and_size(w, h, 3, &pixel_stride, &byte_stride, &size, type );
+ break;
+ case HAL_PIXEL_FORMAT_RGB_565:
#if PLATFORM_SDK_VERSION < 19
- case HAL_PIXEL_FORMAT_RGBA_5551:
- case HAL_PIXEL_FORMAT_RGBA_4444:
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ case HAL_PIXEL_FORMAT_RGBA_4444:
#endif
- get_rgb_stride_and_size(w, h, 2, &pixel_stride, &byte_stride, &size, type );
- break;
+ get_rgb_stride_and_size(w, h, 2, &pixel_stride, &byte_stride, &size, type );
+ break;
- case HAL_PIXEL_FORMAT_YCrCb_420_SP:
- case HAL_PIXEL_FORMAT_YV12:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_NV12:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_NV21:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
+ {
+ /* Mali subsystem prefers higher stride alignment values (128 bytes) for YUV, but software components assume
+ * default of 16. We only need to care about YV12 as it's the only, implicit, HAL YUV format in Android.
+ */
+ int yv12_align = YUV_MALI_PLANE_ALIGN;
+ if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
{
- // Mali subsystem prefers higher stride alignment values (128b) for YUV, but software components assume default of 16.
- // We only need to care about YV12 as it's the only, implicit, HAL YUV format in Android.
- int yv12_align = YUV_MALI_PLANE_ALIGN;
- if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
- {
- yv12_align = YUV_ANDROID_PLANE_ALIGN;
- }
-
- if (!get_yv12_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type, &internalHeight, yv12_align))
- {
- return -EINVAL;
- }
- break;
+ yv12_align = YUV_ANDROID_PLANE_ALIGN;
}
- /*
- * Additional custom formats can be added here
- * and must fill the variables pixel_stride, byte_stride and size.
- */
- default:
+ if (!get_yv12_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type,
+ &internalHeight, yv12_align))
+ {
return -EINVAL;
+ }
+ break;
}
- }
- else
- {
- switch (mapped_format)
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
{
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_Y0L2:
- /* YUYAAYUVAA 4:2:0 */
- if (false == get_yuv_y0l2_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
- {
- return -EINVAL;
- }
- break;
-
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_P010:
- /* Y-UV 4:2:0 */
- if (false == get_yuv_pX10_stride_and_size(w, h, 2, &pixel_stride, &byte_stride, &size))
- {
- return -EINVAL;
- }
- break;
-
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_P210:
- /* Y-UV 4:2:2 */
- if (false == get_yuv_pX10_stride_and_size(w, h, 1, &pixel_stride, &byte_stride, &size))
- {
- return -EINVAL;
- }
- break;
-
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_Y210:
- /* YUYV 4:2:0 */
- if (false == get_yuv_y210_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
- {
- return -EINVAL;
- }
- break;
-
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_Y410:
- /* AVYU 2-10-10-10 */
- if (false == get_yuv_y410_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
- {
- return -EINVAL;
- }
- break;
- /* 8BIT AFBC YUV 4:2:0 testing usage */
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC:
- if (!get_afbc_yuv420_8bit_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type, &internalHeight))
- {
- return -EINVAL;
- }
- break;
-
- /* 8BIT AFBC YUV4:2:2 testing usage */
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_8BIT_AFBC:
- if (!get_afbc_yuv422_8bit_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type))
- {
- return -EINVAL;
- }
- break;
-
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_10BIT_AFBC:
- /* YUV 4:2:0 compressed */
- if (false == get_yuv420_10bit_afbc_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type))
- {
- return -EINVAL;
- }
- break;
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_10BIT_AFBC:
- /* YUV 4:2:2 compressed */
- if (false == get_yuv422_10bit_afbc_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type))
- {
- return -EINVAL;
- }
- break;
- default:
- AERR("Invalid internal format %llx", internal_format & GRALLOC_ARM_INTFMT_FMT_MASK);
+ /* YUYV 4:2:2 */
+ if (type != UNCOMPRESSED || !get_yuv422_8bit_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
+ {
return -EINVAL;
+ }
+ break;
}
+ case HAL_PIXEL_FORMAT_RAW16:
+ case HAL_PIXEL_FORMAT_RAW12:
+ case HAL_PIXEL_FORMAT_RAW10:
+ case HAL_PIXEL_FORMAT_BLOB:
+ if (type != UNCOMPRESSED)
+ {
+ return -EINVAL;
+ }
+ get_camera_formats_stride_and_size(w, h, base_format, &pixel_stride, &size);
+ byte_stride = pixel_stride; /* For Raw/Blob formats stride is defined to be either in bytes or pixels per format */
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y0L2:
+ /* YUYAAYUVAA 4:2:0 */
+ if (type != UNCOMPRESSED || !get_yuv_y0l2_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
+ {
+ return -EINVAL;
+ }
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_P010:
+ /* Y-UV 4:2:0 */
+ if (type != UNCOMPRESSED || !get_yuv_pX10_stride_and_size(w, h, 2, &pixel_stride, &byte_stride, &size))
+ {
+ return -EINVAL;
+ }
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_P210:
+ /* Y-UV 4:2:2 */
+ if (type != UNCOMPRESSED || !get_yuv_pX10_stride_and_size(w, h, 1, &pixel_stride, &byte_stride, &size))
+ {
+ return -EINVAL;
+ }
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y210:
+ /* YUYV 4:2:2 */
+ if (type != UNCOMPRESSED || !get_yuv_y210_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
+ {
+ return -EINVAL;
+ }
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y410:
+ /* AVYU 2-10-10-10 */
+ if (type != UNCOMPRESSED || !get_yuv_y410_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
+ {
+ return -EINVAL;
+ }
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV420_8BIT:
+ /* 8BIT AFBC YUV 4:2:0 testing usage */
+
+ /* We only support compressed for this format right now.
+ * Below will fail in case format is uncompressed.
+ */
+ if (!get_afbc_yuv420_8bit_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type, &internalHeight))
+ {
+ return -EINVAL;
+ }
+ break;
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT:
+ /* 8BIT AFBC YUV4:2:2 testing usage */
+
+ /* We only support compressed for this format right now.
+ * Below will fail in case format is uncompressed.
+ */
+ if (!get_afbc_yuv422_8bit_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type))
+ {
+ return -EINVAL;
+ }
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV420_10BIT:
+ /* YUV 4:2:0 compressed */
+
+ /* We only support compressed for this format right now.
+ * Below will fail in case format is uncompressed.
+ */
+ if (!get_yuv420_10bit_afbc_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type))
+ {
+ return -EINVAL;
+ }
+ break;
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV422_10BIT:
+ /* YUV 4:2:2 compressed */
+
+ /* We only support compressed for this format right now.
+ * Below will fail in case format is uncompressed.
+ */
+ if (!get_yuv422_10bit_afbc_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type))
+ {
+ return -EINVAL;
+ }
+ break;
+ /*
+ * Additional custom formats can be added here
+ * and must fill the variables pixel_stride, byte_stride and size.
+ */
+ default:
+ return -EINVAL;
}
int err;
@@ -972,20 +1153,20 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
hnd->byte_stride = byte_stride;
hnd->internal_format = internal_format;
- int private_usage = usage & (GRALLOC_USAGE_PRIVATE_0 |
- GRALLOC_USAGE_PRIVATE_1);
+ int private_usage = usage & MALI_GRALLOC_USAGE_YUV_CONF_MASK;
+
switch (private_usage)
{
- case 0:
+ case MALI_GRALLOC_USAGE_YUV_CONF_0:
hnd->yuv_info = MALI_YUV_BT601_NARROW;
break;
- case GRALLOC_USAGE_PRIVATE_1:
+ case MALI_GRALLOC_USAGE_YUV_CONF_1:
hnd->yuv_info = MALI_YUV_BT601_WIDE;
break;
- case GRALLOC_USAGE_PRIVATE_0:
+ case MALI_GRALLOC_USAGE_YUV_CONF_2:
hnd->yuv_info = MALI_YUV_BT709_NARROW;
break;
- case (GRALLOC_USAGE_PRIVATE_0 | GRALLOC_USAGE_PRIVATE_1):
+ case MALI_GRALLOC_USAGE_YUV_CONF_3:
hnd->yuv_info = MALI_YUV_BT709_WIDE;
break;
}
@@ -1034,6 +1215,8 @@ int alloc_device_open(hw_module_t const* module, const char* name, hw_device_t**
{
alloc_device_t *dev;
+ GRALLOC_UNUSED(name);
+
dev = new alloc_device_t;
if (NULL == dev)
{
diff --git a/gralloc/src/alloc_ion.cpp b/gralloc/src/alloc_ion.cpp
index b7e820c..df04e38 100755
--- a/gralloc/src/alloc_ion.cpp
+++ b/gralloc/src/alloc_ion.cpp
@@ -18,6 +18,7 @@
#include <string.h>
#include <errno.h>
+#include <inttypes.h>
#include <pthread.h>
#include <cutils/log.h>
@@ -32,49 +33,47 @@
#include "gralloc_helper.h"
#include "framebuffer_device.h"
-#include "format_chooser.h"
+#include "mali_gralloc_formats.h"
#include <linux/ion.h>
#include <ion/ion.h>
-
-
-static void init_afbc(uint8_t *buf, uint64_t format, int w, int h)
+static void init_afbc(uint8_t *buf, uint64_t internal_format, int w, int h)
{
uint32_t n_headers = (w * h) / 64;
uint32_t body_offset = n_headers * 16;
uint32_t headers[][4] = { {body_offset, 0x1, 0x0, 0x0}, /* Layouts 0, 3, 4 */
{(body_offset + (1 << 28)), 0x200040, 0x4000, 0x80} /* Layouts 1, 5 */
};
- int i, layout;
+ uint32_t i, layout;
- /* map format if necessary */
- uint64_t mapped_format = map_format(format & GRALLOC_ARM_INTFMT_FMT_MASK);
+ /* map format if necessary (also removes internal extension bits) */
+ uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
- switch (mapped_format)
+ switch (base_format)
{
- case HAL_PIXEL_FORMAT_RGBA_8888:
- case HAL_PIXEL_FORMAT_RGBX_8888:
- case HAL_PIXEL_FORMAT_RGB_888:
- case HAL_PIXEL_FORMAT_RGB_565:
- case HAL_PIXEL_FORMAT_BGRA_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGB_888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGB_565:
+ case MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888:
#if (PLATFORM_SDK_VERSION >= 19) && (PLATFORM_SDK_VERSION <= 22)
- case HAL_PIXEL_FORMAT_sRGB_A_8888:
- case HAL_PIXEL_FORMAT_sRGB_X_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_sRGB_A_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_sRGB_X_8888:
#endif
layout = 0;
break;
- case HAL_PIXEL_FORMAT_YV12:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_NV12:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_NV21:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
layout = 1;
break;
default:
layout = 0;
}
- ALOGV("Writing AFBC header layout %d for format %llx", layout, format);
+ ALOGV("Writing AFBC header layout %d for format %" PRIu64, layout, base_format);
for (i = 0; i < n_headers; i++)
{
@@ -177,6 +176,10 @@ unsigned int pick_ion_heap(int usage)
void set_ion_flags(unsigned int heap_mask, int usage, unsigned int *priv_heap_flag, int *ion_flags)
{
+#if !GRALLOC_USE_ION_DMA_HEAP
+ GRALLOC_UNUSED(heap_mask);
+#endif
+
if (priv_heap_flag)
{
#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
@@ -248,10 +251,15 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand
lock_state = private_handle_t::LOCK_STATE_MAPPED;
#if GRALLOC_INIT_AFBC == 1
- if (fmt & (GRALLOC_ARM_INTFMT_AFBC | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK))
+ if (fmt & MALI_GRALLOC_INTFMT_AFBCENABLE_MASK)
{
init_afbc(cpu_ptr, fmt, w, h);
}
+#else
+ GRALLOC_UNUSED(fmt);
+ GRALLOC_UNUSED(w);
+ GRALLOC_UNUSED(h);
+
#endif /* GRALLOC_INIT_AFBC == 1 */
}
@@ -324,7 +332,7 @@ void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m)
if ( 0 != munmap( (void*)hnd->base, hnd->size ) ) AERR( "Failed to munmap handle %p", hnd );
}
close( hnd->share_fd );
- if ( 0 != ion_free( m->ion_client, hnd->ion_hnd ) ) AERR( "Failed to ion_free( ion_client: %d ion_hnd: %p )", m->ion_client, hnd->ion_hnd );
+ if ( 0 != ion_free( m->ion_client, hnd->ion_hnd ) ) AERR( "Failed to ion_free( ion_client: %d ion_hnd: %d )", m->ion_client, hnd->ion_hnd );
memset( (void*)hnd, 0, sizeof( *hnd ) );
}
}
diff --git a/gralloc/src/format_chooser.cpp b/gralloc/src/format_chooser.cpp
deleted file mode 100755
index a16b022..0000000
--- a/gralloc/src/format_chooser.cpp
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * 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.
- */
-#include <hardware/hardware.h>
-#include <cutils/log.h>
-#include <hardware/gralloc.h>
-#include "format_chooser.h"
-#include "gralloc_priv.h"
-
-#ifndef GRALLOC_DISP_W
-#define GRALLOC_DISP_W 0
-#endif
-#ifndef GRALLOC_DISP_H
-#define GRALLOC_DISP_H 0
-#endif
-
-/* Minimum size of buffer for AFBC to be enabled. Defined as percentage of total
- * display size */
-#define GRALLOC_AFBC_MIN_SIZE 75
-
-static inline int find_format_index(int format)
-{
- int index=-1;
-
- switch ( format )
- {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888;
- break;
- case HAL_PIXEL_FORMAT_RGBX_8888:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888;
- break;
- case HAL_PIXEL_FORMAT_RGB_888:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888;
- break;
- case HAL_PIXEL_FORMAT_RGB_565:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565;
- break;
- case HAL_PIXEL_FORMAT_BGRA_8888:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888;
- break;
-#if (PLATFORM_SDK_VERSION >= 19) && (PLATFORM_SDK_VERSION <= 22)
- case HAL_PIXEL_FORMAT_sRGB_A_8888:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_A_8888;
- break;
- case HAL_PIXEL_FORMAT_sRGB_X_8888:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_X_8888;
- break;
-#endif
- case HAL_PIXEL_FORMAT_YV12:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12;
- break;
-#if PLATFORM_SDK_VERSION >= 18
- case HAL_PIXEL_FORMAT_Y8:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_Y8;
- break;
- case HAL_PIXEL_FORMAT_Y16:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_Y16;
- break;
-#endif
- case HAL_PIXEL_FORMAT_YCbCr_420_888:
- index = GRALLOC_ARM_HAL_FORMAT_INDEXED_YCbCr_420_888;
- break;
- }
-
- return index;
-}
-
-static bool is_afbc_allowed(int buffer_size)
-{
- bool afbc_allowed = false;
-
-#if !defined(GRALLOC_ARM_NO_EXTERNAL_AFBC)
- if ((GRALLOC_DISP_W*GRALLOC_DISP_H) != 0)
- {
- afbc_allowed = ((buffer_size*100) / (GRALLOC_DISP_W*GRALLOC_DISP_H)) >= GRALLOC_AFBC_MIN_SIZE;
- }
- /* If display size is not valid then always allow AFBC */
- else
- {
- afbc_allowed = true;
- }
-#endif /* defined(GRALLOC_ARM_NO_EXTERNAL_AFBC) */
-
- return afbc_allowed;
-}
-
-/*
- * Define GRALLOC_ARM_FORMAT_SELECTION_DISABLE to disable the format selection completely
- * or GRALLOC_ARM_NO_EXTERNAL_AFBC to disable selection of AFBC formats for external buffers.
- */
-uint64_t gralloc_select_format(int req_format, int usage, int buffer_size)
-{
-#if defined(GRALLOC_ARM_FORMAT_SELECTION_DISABLE)
- (void) usage;
- return (uint64_t) req_format;
-
-#else
- uint64_t new_format = req_format;
- int intformat_ind;
- int n=0;
- int largest_weight_ind=-1;
- int16_t accum_weights[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST] = {0};
- int afbc_split_mode = 0;
- bool afbc_allowed = true;
-
- ALOGV("gralloc_select_format: req_format=0x%x usage=0x%x\n",req_format,usage);
-
- if ((usage & GRALLOC_ARM_USAGE_NO_AFBC) == GRALLOC_ARM_USAGE_NO_AFBC)
- {
- afbc_allowed = false;
- }
- /* The GRALLOC_USAGE_PRIVATE_3 set in the usage field indicates the req_format is
- * to be treated as encoded private format instead of trying to find closest match.
- * At the time being, the flag is used for testing AFBC and 10bit YUV that are not
- * yet supported by Android HAL */
- /* Decode the passed in private format and get the gralloc indexed formats */
- else if (usage & GRALLOC_USAGE_PRIVATE_3)
- {
- uint64_t result = 0;
- /* req_format is within the range for normal AFBC formats */
- if (GRALLOC_ANDROID_PRIVATE_IN_RANGE_OF_AFBC(req_format))
- {
- req_format = req_format - GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC;
- result = req_format | GRALLOC_ARM_INTFMT_AFBC;
- switch (req_format & GRALLOC_ARM_INTFMT_FMT_MASK)
- {
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_8BIT_AFBC:
- result |= GRALLOC_ARM_INTFMT_ARM_AFBC_YUV;
- break;
- }
- return result;
- }
- else if (GRALLOC_ANDROID_PRIVATE_IN_RANGE_OF_AFBC_SPLITBLK(req_format))
- {
- req_format = req_format - GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_SPLITBLK;
- result = req_format | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK;
- /* We don't support yuv 4:2:2 afbc split mode */
- if (req_format == GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC)
- {
- result |= GRALLOC_ARM_INTFMT_ARM_AFBC_YUV;
- }
- return result;
- }
- else if (GRALLOC_ANDROID_PRIVATE_IN_RANGE_OF_BASE_YUVEXT(req_format))
- {
- req_format = req_format - GRALLOC_ANDROID_PRIVATE_RANGE_BASE_YUVEXT;
- switch (req_format & GRALLOC_ARM_INTFMT_FMT_MASK)
- {
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_10BIT_AFBC:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_10BIT_AFBC:
- result = (GRALLOC_ARM_INTFMT_AFBC | GRALLOC_ARM_INTFMT_ARM_AFBC_YUV);
- /* pass through */
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_Y0L2:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_P010:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_P210:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_Y210:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_Y410:
- /* preserve the format + possible AFBC flag, and add extended-yuv flag */
- result |= GRALLOC_ARM_INTFMT_EXTENDED_YUV;
- result |= (req_format & (GRALLOC_ARM_INTFMT_FMT_MASK | GRALLOC_ARM_INTFMT_AFBC | GRALLOC_ARM_INTFMT_ARM_AFBC_YUV));
- break;
- }
- return result;
- }
- else if (GRALLOC_ANDROID_PRIVATE_IN_RANGE_OF_AFBC_WIDEBLK(req_format))
- {
- req_format = req_format - GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_WIDEBLK;
- switch (req_format & GRALLOC_ARM_INTFMT_FMT_MASK)
- {
- case HAL_PIXEL_FORMAT_RGBA_8888:
- case HAL_PIXEL_FORMAT_RGBX_8888:
- case HAL_PIXEL_FORMAT_BGRA_8888:
- case HAL_PIXEL_FORMAT_RGB_888:
- result = req_format | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK;
- break;
- case HAL_PIXEL_FORMAT_RGB_565:
- case HAL_PIXEL_FORMAT_YV12:
- result = req_format | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK;
- break;
-#if 1 == MALI_USE_YUV_AFBC_WIDEBLK
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_8BIT_AFBC:
- result = req_format | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK | GRALLOC_ARM_INTFMT_ARM_AFBC_YUV;
- break;
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_10BIT_AFBC:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_10BIT_AFBC:
- result = GRALLOC_ARM_INTFMT_EXTENDED_YUV | GRALLOC_ARM_INTFMT_ARM_AFBC_YUV;
- result |= (req_format & ( GRALLOC_ARM_INTFMT_FMT_MASK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK ));
- break;
-#else
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_8BIT_AFBC:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_10BIT_AFBC:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_10BIT_AFBC:
- /* invalid format value */
- return -EINVAL;
-#endif
- default:
- ALOGV("Gralloc gets internal HAL pixel format: 0x%llX", (req_format & GRALLOC_ARM_INTFMT_FMT_MASK));
- result = req_format | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK;
- break;
- }
- return result;
- }
- else
- {
- /* invalid format value */
- return -EINVAL;
- }
- }
-
- if( req_format == 0 )
- {
- return 0;
- }
-
- /* Implementation defined format set to YCbCr_420_888. */
- if(req_format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED)
- {
- new_format = HAL_PIXEL_FORMAT_YCbCr_420_888;
- }
-
-
- if( (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) != 0 ||
- usage == 0 )
- {
- return new_format;
- }
-
- /* AFBC buffers are not allowed as an input to the video encoder */
- if( (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) != 0 )
- {
- return new_format;
- }
-
-
-#if DISABLE_FRAMEBUFFER_HAL != 1
- /* This is currently a limitation with the display and will be removed eventually
- * We can't allocate fbdev framebuffer buffers in AFBC format */
- if( usage & GRALLOC_USAGE_HW_FB )
- {
- return new_format;
- }
-#endif
-
- /* if this format can't be classified in one of the groups we
- * have pre-defined, ignore it.
- */
- intformat_ind = find_format_index( req_format );
- if( intformat_ind < 0 )
- {
- return new_format;
- }
-
- if (afbc_allowed)
- {
- afbc_allowed = is_afbc_allowed(buffer_size);
- }
-
- while( blklist[n].blk_init != 0 )
- {
- if( (blklist[n].hwblkconf.usage & usage) != 0 )
- {
- uint32_t m;
-
- for(m=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST; m<GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST; m++)
- {
- uint64_t internal_format = translate_internal_indexed[m].internal_extended_format;
- bool is_afbc = internal_format & (GRALLOC_ARM_INTFMT_AFBC | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK |
- GRALLOC_ARM_INTFMT_AFBC_WIDEBLK | GRALLOC_ARM_INTFMT_ARM_AFBC_YUV);
-
- if ((blklist[n].hwblkconf.weights[intformat_ind][m] != DEFAULT_WEIGHT_UNSUPPORTED) && (!is_afbc || afbc_allowed))
- {
- accum_weights[m] += blklist[n].hwblkconf.weights[intformat_ind][m];
-
- if( largest_weight_ind < 0 ||
- accum_weights[m] > accum_weights[largest_weight_ind])
- {
- largest_weight_ind = m;
- }
- }
- else
- {
- /* Format not supported by this hwblk */
- accum_weights[m] = DEFAULT_WEIGHT_UNSUPPORTED;
- }
- }
- }
- n++;
- }
-
- if( largest_weight_ind < 0 )
- {
- new_format = 0;
- }
- else
- {
- new_format = translate_internal_indexed[largest_weight_ind].internal_extended_format;
- }
-
- ALOGV("Returned iterated format: 0x%llX", new_format);
-
- return new_format;
-#endif
-}
-
-extern "C"
-{
-void *gralloc_get_internal_info(int *blkconf_size, int *gpu_conf)
-{
- void *blkinit_address = NULL;
-
-#if !defined(GRALLOC_ARM_FORMAT_SELECTION_DISABLE)
-
- if(blkconf_size != NULL && gpu_conf != NULL)
- {
- blkinit_address = (void*) blklist;
- *blkconf_size = blklist_array_size;
-
-/*
- * Tests intended to verify gralloc format selection behavior are GPU version aware in runtime.
- * They need to know what configuration we built for. For now this is simply AFBC on or off. This
- * will likely change in the future to mean something else.
- */
-#if MALI_AFBC_GRALLOC == 1
- *gpu_conf = 1;
-#else
- *gpu_conf = 0;
-#endif /* MALI_AFBC_GRALLOC */
- }
-
-#endif /* GRALLOC_ARM_FORMAT_SELECTION_DISABLE */
-
- return blkinit_address;
-}
-
-int gralloc_get_internal_format(int hal_format)
-{
- return find_format_index(hal_format);
-}
-}
diff --git a/gralloc/src/format_chooser.h b/gralloc/src/format_chooser.h
deleted file mode 100755
index 7eedb7f..0000000
--- a/gralloc/src/format_chooser.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * 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.
- */
-
-#ifndef FORMAT_CHOOSER_H_
-#define FORMAT_CHOOSER_H_
-
-#include <hardware/hardware.h>
-
-
-#define GRALLOC_ARM_INTFMT_EXTENSION_BIT_START 32
-
-/* This format will use AFBC */
-#define GRALLOC_ARM_INTFMT_AFBC (1ULL << (GRALLOC_ARM_INTFMT_EXTENSION_BIT_START+0))
-
-/* This format uses AFBC split block mode */
-#define GRALLOC_ARM_INTFMT_AFBC_SPLITBLK (1ULL << (GRALLOC_ARM_INTFMT_EXTENSION_BIT_START+1))
-
-/* 10bit or 16bit, "extended" YUV format bit */
-#define GRALLOC_ARM_INTFMT_EXTENDED_YUV (1ULL << (GRALLOC_ARM_INTFMT_EXTENSION_BIT_START+2))
-
-/* This format uses AFBC wide block mode */
-#define GRALLOC_ARM_INTFMT_AFBC_WIDEBLK (1ULL << (GRALLOC_ARM_INTFMT_EXTENSION_BIT_START+3))
-
-/* 8bit or 10bit, Compressed ARM YUV formats */
-#define GRALLOC_ARM_INTFMT_ARM_AFBC_YUV (1ULL << (GRALLOC_ARM_INTFMT_EXTENSION_BIT_START+4))
-
-/* Internal format masks */
-#define GRALLOC_ARM_INTFMT_FMT_MASK 0x00000000ffffffffULL
-#define GRALLOC_ARM_INTFMT_EXT_MASK 0xffffffff00000000ULL
-
-/* Android pixel format private range start from 0x100 */
-#define GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC 0x100
-#define GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_SPLITBLK 0x200
-#define GRALLOC_ANDROID_PRIVATE_RANGE_BASE_YUVEXT 0x400
-#define GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_WIDEBLK 0x800
-
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC(x) (GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC + (x))
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_SPLITBLK(x) (GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_SPLITBLK + (x))
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_YUVEXT(x) (GRALLOC_ANDROID_PRIVATE_RANGE_BASE_YUVEXT + (x))
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_WIDEBLK(x) (GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_WIDEBLK + (x))
-
-/* Index of the internal formats */
-typedef enum
-{
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_A_8888,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_X_8888,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_Y8,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_Y16,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_NV12,
-
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV422_8BIT_AFBC,
-
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_AFBC_SPLITBLK_FIRST,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_AFBC_SPLITBLK_FIRST,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_SPLITBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_SPLITBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_AFBC_SPLITBLK_LAST=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_SPLITBLK,
-
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_AFBC_WIDEBLK_FIRST,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK_WIDEBLK=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_AFBC_WIDEBLK_FIRST,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK_WIDEBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK_WIDEBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_WIDEBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK_WIDEBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_WIDEBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV422_8BIT_AFBC_WIDEBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_AFBC_WIDEBLK_LAST=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV422_8BIT_AFBC_WIDEBLK,
-
- /* Extended YUV formats */
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_Y0L2,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_P010,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_P210,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_Y210,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_Y410,
-
- /* Compressed extended YUV formats */
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_10BIT_AFBC,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV422_10BIT_AFBC,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_10BIT_AFBC_WIDEBLK,
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV422_10BIT_AFBC_WIDEBLK,
-
- /* Add more internal formats here */
-
- GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST
-} gralloc_arm_internal_index_format;
-
-typedef enum
-{
- /* Having an invalid format catches lists which are initialized with not all entries. */
- GRALLOC_ARM_HAL_FORMAT_INDEXED_INVALID,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_A_8888,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_X_8888,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_NV12,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_NV21,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_Y8,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_Y16,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_YCbCr_420_888,
-
- /* Compressed 8BIT YUV format */
- GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_8BIT_AFBC,
-
- /* Extended YUV formats */
- GRALLOC_ARM_HAL_FORMAT_INDEXED_Y0L2,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_P010,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_P210,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_Y210,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_Y410,
-
- /* Compressed extended YUV formats */
- GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_10BIT_AFBC,
- GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_10BIT_AFBC,
-
- GRALLOC_ARM_HAL_FORMAT_INDEXED_LAST
-} gralloc_arm_hal_index_format;
-
-#define MAX_COMPATIBLE 3
-#define DEFAULT_WEIGHT_SUPPORTED 50
-#define DEFAULT_WEIGHT_MOST_PREFERRED 100
-#define DEFAULT_WEIGHT_UNSUPPORTED -1
-
-#define GRALLOC_ANDROID_PRIVATE_IN_RANGE_OF_AFBC(x) \
- (((x) > GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC && \
- (x) <= (GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC + 0xff)) || \
- ((x) == (GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC + HAL_PIXEL_FORMAT_YV12)))
-#define GRALLOC_ANDROID_PRIVATE_IN_RANGE_OF_AFBC_SPLITBLK(x) \
- (((x) > GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_SPLITBLK && \
- (x) <= (GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_SPLITBLK + 0xff)) || \
- ((x) == ( GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_SPLITBLK + HAL_PIXEL_FORMAT_YV12)))
-#define GRALLOC_ANDROID_PRIVATE_IN_RANGE_OF_AFBC_WIDEBLK(x) \
- (((x) > GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_WIDEBLK && \
- (x) <= (GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_WIDEBLK + 0xff)) || \
- ((x) == ( GRALLOC_ANDROID_PRIVATE_RANGE_BASE_AFBC_WIDEBLK + HAL_PIXEL_FORMAT_YV12)))
-#define GRALLOC_ANDROID_PRIVATE_IN_RANGE_OF_BASE_YUVEXT(x) \
- (((x & GRALLOC_ARM_INTFMT_FMT_MASK) >= \
- (GRALLOC_ARM_HAL_FORMAT_INDEXED_Y0L2 + GRALLOC_ANDROID_PRIVATE_RANGE_BASE_YUVEXT)) && \
- ((x & GRALLOC_ARM_INTFMT_FMT_MASK) <= \
- (GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_10BIT_AFBC + GRALLOC_ANDROID_PRIVATE_RANGE_BASE_YUVEXT)))
-
-/* Select the underlying format used to implement the HAL_PIXEL_FORMAT_YCbCr_420_888 flexible YUV format. */
-#define GRALLOC_MAPPED_HAL_PIXEL_FORMAT_YCbCr_420_888 GRALLOC_ARM_HAL_FORMAT_INDEXED_NV12
-
-typedef struct
-{
- /* The internal extended format exported outside of gralloc */
- uint64_t internal_extended_format;
-
- /* Swizzled versions of the requested format for this internal format */
- gralloc_arm_hal_index_format comp_format_list[MAX_COMPATIBLE];
-} internal_fmt_info;
-
-uint64_t gralloc_select_format(int req_format, int usage, int buffer_size);
-
-struct hwblk
-{
- uint32_t usage;
- int16_t weights[GRALLOC_ARM_HAL_FORMAT_INDEXED_LAST][GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST];
-};
-
-
-typedef struct
-{
- void (*blk_init)(struct hwblk *format_matrix, int16_t **array);
- struct hwblk hwblkconf;
-} blkinit;
-
-
-extern void initialize_blk_conf();
-extern const internal_fmt_info translate_internal_indexed[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST];
-extern blkinit blklist[];
-extern uint32_t blklist_array_size;
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
- int gralloc_get_internal_format(int hal_format);
- void *gralloc_get_internal_info(int *blkconf_size, int *gpu_conf);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* FORMAT_CHOOSER_H_ */
diff --git a/gralloc/src/format_chooser_blockinit.cpp b/gralloc/src/format_chooser_blockinit.cpp
deleted file mode 100755
index d508e79..0000000
--- a/gralloc/src/format_chooser_blockinit.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * 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.
- */
-#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
-
-/* The extension bits are defined for indexed formats when setting
- * up the definitions. This define exports them before including
- * the block definitions.
- */
-#include "format_chooser.h"
-
-#include "formatdef_files/gpu_default.defs"
-
-#if MALI_AFBC_GRALLOC == 1
-#if MALI_SUPPORT_AFBC_WIDEBLK == 1
-#include "formatdef_files/gpu_afbc_wideblk.defs"
-#else
-#include "formatdef_files/gpu_afbc.defs"
-#endif
-#ifdef MALI_DISPLAY_VERSION
-#include "formatdef_files/display_afbc.defs"
-#endif
-#endif
-
-
-/* Defines a translation list of requested formats that are compatible with the internal indexed format */
-const internal_fmt_info translate_internal_indexed[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST] =
-{
- {
- HAL_PIXEL_FORMAT_RGBA_8888,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGBX_8888,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGB_888,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGB_565,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565}
- },
-
- {
- HAL_PIXEL_FORMAT_BGRA_8888,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888}
- },
-
-#if (PLATFORM_SDK_VERSION >= 19) && (PLATFORM_SDK_VERSION <= 22)
- {HAL_PIXEL_FORMAT_sRGB_A_8888, {GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_A_8888} },
- {HAL_PIXEL_FORMAT_sRGB_X_8888, {GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_X_8888} },
-#else
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_A_8888} },
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_sRGB_X_8888} },
-#endif
-
- {
- HAL_PIXEL_FORMAT_YV12,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12}
- },
-
-#if PLATFORM_SDK_VERSION >= 18
- {HAL_PIXEL_FORMAT_Y8, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y8} },
- {HAL_PIXEL_FORMAT_Y16, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y16} },
-#else
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y8} },
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y16} },
-#endif
-
- {HAL_PIXEL_FORMAT_YCbCr_420_888, {GRALLOC_ARM_HAL_FORMAT_INDEXED_YCbCr_420_888} },
-
- {
- HAL_PIXEL_FORMAT_RGBA_8888 | GRALLOC_ARM_INTFMT_AFBC,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGBX_8888 | GRALLOC_ARM_INTFMT_AFBC,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGB_888 | GRALLOC_ARM_INTFMT_AFBC,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGB_565 | GRALLOC_ARM_INTFMT_AFBC,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565}
- },
-
- {
- HAL_PIXEL_FORMAT_BGRA_8888 | GRALLOC_ARM_INTFMT_AFBC,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_YV12 | GRALLOC_ARM_INTFMT_AFBC,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12, GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC}
- },
-
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_8BIT_AFBC}},
-
- {
- HAL_PIXEL_FORMAT_RGBA_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGBX_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGB_888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGB_565 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565}
- },
-
- {
- HAL_PIXEL_FORMAT_BGRA_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_YV12 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12, GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC}
- },
-
- {
- HAL_PIXEL_FORMAT_RGBA_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGBX_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGB_888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBX_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_RGB_565 | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_RGB_565}
- },
-
- {
- HAL_PIXEL_FORMAT_BGRA_8888 | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_BGRA_8888, GRALLOC_ARM_HAL_FORMAT_INDEXED_RGBA_8888}
- },
-
- {
- HAL_PIXEL_FORMAT_YV12 | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK,
- {GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12, GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_8BIT_AFBC}
- },
-
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_8BIT_AFBC}},
-
- /* No mapping as there is no corresponding HAL formats */
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y0L2}},
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_P010}},
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_P210}},
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y210}},
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_Y410}},
- /* Entry at GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_10BIT_AFBC */
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_10BIT_AFBC}},
- /* Entry at GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV422_10BIT_AFBC */
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_10BIT_AFBC}},
- /* Entry at GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_10BIT_AFBC_WIDEBLK */
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV420_10BIT_AFBC}},
- /* Entry at GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV422_10BIT_AFBC_WIDEBLK */
- {0, {GRALLOC_ARM_HAL_FORMAT_INDEXED_YUV422_10BIT_AFBC}},
-};
-
-blkinit blklist[] =
-{
-#if MALI_AFBC_GRALLOC == 1
-#ifdef MALI_DISPLAY_VERSION
- {
- display_afbc_hwc_blkinit,{0,{}}
- },
-#endif
- {
- gpu_afbc_write_blkinit,{0,{}}
- },
- {
- gpu_afbc_read_blkinit,{0,{}}
- },
-#else
- {
- gpu_write_blkinit,{0,{}}
- },
- {
- gpu_read_blkinit,{0,{}}
- },
-#endif
-
- /* Empty entry */
- {
- NULL,{0,{}}
- }
-};
-
-uint32_t blklist_array_size = sizeof(blklist);
-
-void initialize_blk_conf()
-{
- int i,j,k;
-
- i=0;
- while( blklist[i].blk_init != 0 )
- {
- int16_t *array=0;
-
- for(j=0;j<GRALLOC_ARM_HAL_FORMAT_INDEXED_LAST;j++)
- {
- for(k=0; k<(int) GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST; k++)
- {
- blklist[i].hwblkconf.weights[j][k] = DEFAULT_WEIGHT_UNSUPPORTED;
- }
- }
- blklist[i].blk_init( &blklist[i].hwblkconf , &array);
- if( *array != 0 )
- {
- for(k=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST; k<GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST; k++)
- {
- /* Zero weights are not suppose to be used in the preferred array because that usually means
- * uninitialized values.
- */
- if( array[k] != DEFAULT_WEIGHT_UNSUPPORTED && array[k] != 0 )
- {
- int n;
-
- /* For this internal format we will for its base format setup matching weights
- * for itself as well as swizzled versions of the format. When initializing
- * swizzled/compatible formats with same weight, we insert a slight preference
- * on the base format(which is listed first) to choose that when the base is selected.
- * Other blocks' preference might adjust this.
- */
- for(n=0; n<MAX_COMPATIBLE; n++)
- {
- if( translate_internal_indexed[k].comp_format_list[n] != GRALLOC_ARM_HAL_FORMAT_INDEXED_INVALID )
- {
- if(n==0)
- {
- blklist[i].hwblkconf.weights[translate_internal_indexed[k].comp_format_list[n]][k] = array[k]+1;
- }
- else
- {
- blklist[i].hwblkconf.weights[translate_internal_indexed[k].comp_format_list[n]][k] = array[k];
- }
- }
- }
- }
- }
- }
- i++;
- }
-}
diff --git a/gralloc/src/formatdef_files/display_afbc.defs b/gralloc/src/formatdef_files/display_afbc.defs
deleted file mode 100755
index 5ac6dbf..0000000
--- a/gralloc/src/formatdef_files/display_afbc.defs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * 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.
- */
-
-#include <cutils/memory.h>
-
-static void display_afbc_hwc_blkinit(struct hwblk *blk,int16_t **array)
-{
- static int16_t hwc_pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST];
- android_memset16((uint16_t*) hwc_pref_formats, (uint16_t) DEFAULT_WEIGHT_UNSUPPORTED, sizeof(uint16_t) * GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST);
- blk->usage = GRALLOC_USAGE_HW_COMPOSER;
- *array = hwc_pref_formats;
-
-#if MALI_DISPLAY_VERSION == 500
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED + 10;
-#elif MALI_DISPLAY_VERSION == 550
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED + 10;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED + 10;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED + 10;
-#endif
-}
diff --git a/gralloc/src/formatdef_files/gpu_afbc.defs b/gralloc/src/formatdef_files/gpu_afbc.defs
deleted file mode 100755
index 4eb6081..0000000
--- a/gralloc/src/formatdef_files/gpu_afbc.defs
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * 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.
- */
-
-static void gpu_afbc_read_blkinit(struct hwblk *blk,int16_t **array)
-{
- /* Initialize GPU default weight setup */
- gpu_read_blkinit(blk, array);
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
-}
-
-
-static void gpu_afbc_write_blkinit(struct hwblk *blk,int16_t **array)
-{
- /* Initialize GPU default weight setup */
- gpu_write_blkinit(blk, array);
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
-}
diff --git a/gralloc/src/formatdef_files/gpu_afbc_wideblk.defs b/gralloc/src/formatdef_files/gpu_afbc_wideblk.defs
deleted file mode 100755
index 3f5a298..0000000
--- a/gralloc/src/formatdef_files/gpu_afbc_wideblk.defs
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2015 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * 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.
- */
-
-static void gpu_afbc_read_blkinit(struct hwblk *blk,int16_t **array)
-{
- /* Initialize GPU default weight setup */
- gpu_read_blkinit(blk, array);
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
-#if 1 == MALI_USE_YUV_AFBC_WIDEBLK
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
-#endif
-}
-
-
-static void gpu_afbc_write_blkinit(struct hwblk *blk,int16_t **array)
-{
- /* Initialize GPU default weight setup */
- gpu_write_blkinit(blk, array);
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_10BIT_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_SPLITBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 60;
-
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC_SPLITBLK_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888_AFBC_SPLITBLK_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888_AFBC_SPLITBLK_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888_AFBC_SPLITBLK_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565_AFBC_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
-#if 1 == MALI_USE_YUV_AFBC_WIDEBLK
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_10BIT_AFBC_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
-#endif
-}
diff --git a/gralloc/src/formatdef_files/gpu_default.defs b/gralloc/src/formatdef_files/gpu_default.defs
deleted file mode 100755
index f604067..0000000
--- a/gralloc/src/formatdef_files/gpu_default.defs
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * 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.
- */
-
-#include <cutils/memory.h>
-
-static int16_t pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST];
-
-static void gpu_read_blkinit(struct hwblk *blk,int16_t **array)
-{
- android_memset16((uint16_t*) pref_formats, (uint16_t) DEFAULT_WEIGHT_UNSUPPORTED, sizeof(uint16_t) * GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST);
-
- blk->usage = GRALLOC_USAGE_HW_TEXTURE;
-
- /* Compatible internal formats for a specific input format will also be initialized */
- /* Preference on RGBA compared to BGRA because of GLES readback */
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888] = DEFAULT_WEIGHT_SUPPORTED+10;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888] = DEFAULT_WEIGHT_SUPPORTED;
-
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_NV12] = DEFAULT_WEIGHT_SUPPORTED;
-
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_A_8888] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_X_8888] = DEFAULT_WEIGHT_SUPPORTED;
-
- *array = pref_formats;
-}
-
-
-static void gpu_write_blkinit(struct hwblk *blk,int16_t **array)
-{
- android_memset16((uint16_t*) pref_formats, (uint16_t) DEFAULT_WEIGHT_UNSUPPORTED, sizeof(uint16_t) * GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST);
-
- blk->usage = GRALLOC_USAGE_HW_RENDER;
-
- /* Compatible internal formats for a specific input format will also be initialized */
- /* Preference on RGBA compared to BGRA because of GLES readback */
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888] = DEFAULT_WEIGHT_SUPPORTED+10;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBX_8888] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_BGRA_8888] = DEFAULT_WEIGHT_SUPPORTED;
-
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_888] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGB_565] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YV12] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_NV12] = DEFAULT_WEIGHT_SUPPORTED;
-
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_A_8888] = DEFAULT_WEIGHT_SUPPORTED;
- pref_formats[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_sRGB_X_8888] = DEFAULT_WEIGHT_SUPPORTED;
-
- *array = pref_formats;
-}
diff --git a/gralloc/src/framebuffer_device.cpp b/gralloc/src/framebuffer_device.cpp
index b71a88c..04240ff 100755
--- a/gralloc/src/framebuffer_device.cpp
+++ b/gralloc/src/framebuffer_device.cpp
@@ -402,6 +402,8 @@ static int fb_close(struct hw_device_t *device)
int compositionComplete(struct framebuffer_device_t* dev)
{
+ GRALLOC_UNUSED(dev);
+
/* By doing a finish here we force the GL driver to start rendering
all the drawcalls up to this point, and to wait for the rendering to be complete.*/
glFinish();
@@ -423,6 +425,8 @@ int framebuffer_device_open(hw_module_t const* module, const char* name, hw_devi
{
int status = -EINVAL;
+ GRALLOC_UNUSED(name);
+
alloc_device_t* gralloc_device;
#if DISABLE_FRAMEBUFFER_HAL == 1
AERR("Framebuffer HAL not support/disabled %s",
diff --git a/gralloc/src/framebuffer_device.h b/gralloc/src/framebuffer_device.h
index 7e63d5f..a653cef 100755
--- a/gralloc/src/framebuffer_device.h
+++ b/gralloc/src/framebuffer_device.h
@@ -17,6 +17,7 @@
*/
#include <hardware/hardware.h>
+#include "gralloc_priv.h"
// Create a framebuffer device
int framebuffer_device_open(hw_module_t const* module, const char* name, hw_device_t** device);
diff --git a/gralloc/src/gralloc_helper.h b/gralloc/src/gralloc_helper.h
index f7027ed..12adb53 100755
--- a/gralloc/src/gralloc_helper.h
+++ b/gralloc/src/gralloc_helper.h
@@ -21,19 +21,11 @@
#include <sys/mman.h>
-inline size_t round_up_to_page_size(size_t x)
-{
- return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
-}
+#define GRALLOC_UNUSED(x) ((void) x)
-/* map the flexible yuv format to the underlying format */
-inline uint64_t map_format( uint64_t format )
+static inline size_t round_up_to_page_size(size_t x)
{
- if (HAL_PIXEL_FORMAT_YCbCr_420_888 == format)
- {
- format = GRALLOC_MAPPED_HAL_PIXEL_FORMAT_YCbCr_420_888;
- }
- return format;
+ return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
}
#endif /* GRALLOC_HELPER_H_ */
diff --git a/gralloc/src/gralloc_module.cpp b/gralloc/src/gralloc_module.cpp
index e254e91..f363c00 100755
--- a/gralloc/src/gralloc_module.cpp
+++ b/gralloc/src/gralloc_module.cpp
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <inttypes.h>
#include <cutils/log.h>
#include <cutils/atomic.h>
@@ -35,7 +36,7 @@
#include "gralloc_buffer_priv.h"
#endif
-#include "format_chooser.h"
+#include "mali_gralloc_formats.h"
static pthread_mutex_t s_map_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -57,6 +58,8 @@ static int gralloc_device_open(const hw_module_t* module, const char* name, hw_d
static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle_t handle)
{
+ GRALLOC_UNUSED(module);
+
if (private_handle_t::validate(handle) < 0)
{
AERR("Registering invalid buffer %p, returning error", handle);
@@ -99,6 +102,8 @@ static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle
static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle)
{
+ GRALLOC_UNUSED(module);
+
if (private_handle_t::validate(handle) < 0)
{
AERR("unregistering invalid buffer %p, returning error", handle);
@@ -154,6 +159,12 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand
static int gralloc_lock(gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr)
{
+ GRALLOC_UNUSED(module);
+ GRALLOC_UNUSED(l);
+ GRALLOC_UNUSED(t);
+ GRALLOC_UNUSED(w);
+ GRALLOC_UNUSED(h);
+
if (private_handle_t::validate(handle) < 0)
{
AERR("Locking invalid buffer %p, returning error", handle );
@@ -183,6 +194,12 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, buffer_handle_t ha
int l, int t, int w, int h,
android_ycbcr *ycbcr)
{
+ GRALLOC_UNUSED(module);
+ GRALLOC_UNUSED(l);
+ GRALLOC_UNUSED(t);
+ GRALLOC_UNUSED(w);
+ GRALLOC_UNUSED(h);
+
if (private_handle_t::validate(handle) < 0)
{
AERR("Locking invalid buffer %p, returning error", handle );
@@ -195,23 +212,25 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, buffer_handle_t ha
{
hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
}
- if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK) &&
+ !(hnd->internal_format & MALI_GRALLOC_INTFMT_EXT_MASK))
{
char* base = (char*)hnd->base;
int y_stride = hnd->byte_stride;
- int y_size = y_stride * hnd->height;
+ /* Ensure height is aligned for subsampled chroma before calculating buffer parameters */
+ int adjusted_height = GRALLOC_ALIGN(hnd->height, 2);
+ int y_size = y_stride * adjusted_height;
int u_offset = 0;
int v_offset = 0;
int c_stride = 0;
int step = 0;
- /* map format if necessary */
- uint64_t mapped_format = map_format(hnd->internal_format & GRALLOC_ARM_INTFMT_FMT_MASK);
+ uint64_t base_format = hnd->internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
- switch (mapped_format)
+ switch (base_format)
{
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_NV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
c_stride = y_stride;
/* Y plane, UV plane */
u_offset = y_size;
@@ -219,7 +238,7 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, buffer_handle_t ha
step = 2;
break;
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_NV21:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
c_stride = y_stride;
/* Y plane, UV plane */
v_offset = y_size;
@@ -227,14 +246,13 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, buffer_handle_t ha
step = 2;
break;
- case HAL_PIXEL_FORMAT_YV12:
- case GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
{
int c_size;
/* Stride alignment set to 16 as the SW access flags were set */
c_stride = GRALLOC_ALIGN(hnd->byte_stride / 2, 16);
- c_size = c_stride * (hnd->height / 2);
+ c_size = c_stride * (adjusted_height / 2);
/* Y plane, V plane, U plane */
v_offset = y_size;
u_offset = y_size + c_size;
@@ -243,7 +261,7 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, buffer_handle_t ha
}
default:
- AERR("Can't lock buffer %p: wrong format %llx", hnd, hnd->internal_format);
+ AERR("Can't lock buffer %p: wrong format %" PRIx64, hnd, hnd->internal_format);
return -EINVAL;
}
@@ -259,6 +277,8 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, buffer_handle_t ha
static int gralloc_unlock(gralloc_module_t const* module, buffer_handle_t handle)
{
+ GRALLOC_UNUSED(module);
+
if (private_handle_t::validate(handle) < 0)
{
AERR( "Unlocking invalid buffer %p, returning error", handle );
@@ -281,7 +301,7 @@ static int gralloc_unlock(gralloc_module_t const* module, buffer_handle_t handle
static struct hw_module_methods_t gralloc_module_methods =
{
- open: gralloc_device_open
+ gralloc_device_open
};
private_module_t::private_module_t()
@@ -319,7 +339,7 @@ private_module_t::private_module_t()
fps = 0.0f;
swapInterval = 1;
- initialize_blk_conf();
+ mali_gralloc_initialize_capabilities();
#undef INIT_ZERO
};
diff --git a/gralloc/src/gralloc_priv.h b/gralloc/src/gralloc_priv.h
index 13b141a..c9f3a96 100755
--- a/gralloc/src/gralloc_priv.h
+++ b/gralloc/src/gralloc_priv.h
@@ -31,7 +31,8 @@
#include "alloc_device.h"
#include <utils/Log.h>
-#include "format_chooser.h"
+#include "mali_gralloc_formats.h"
+#include "gralloc_helper.h"
#if MALI_ION == 1
#define GRALLOC_ARM_UMP_MODULE 0
@@ -92,12 +93,6 @@ struct fb_dmabuf_export
#define NUM_INTS_IN_PRIVATE_HANDLE ((sizeof(struct private_handle_t) - sizeof(native_handle)) / sizeof(int) - sNumFds)
-enum
-{
- /* Buffer won't be allocated as AFBC */
- GRALLOC_ARM_USAGE_NO_AFBC = GRALLOC_USAGE_PRIVATE_1 | GRALLOC_USAGE_PRIVATE_2
-};
-
#if GRALLOC_ARM_UMP_MODULE
#include <ump/ump.h>
#endif
@@ -143,11 +138,14 @@ struct private_module_t
float fps;
int swapInterval;
+#ifdef __cplusplus
+ /* Never intended to be used from C code */
enum
{
// flag to indicate we'll post this buffer
PRIV_USAGE_LOCKED_FOR_POST = 0x80000000
};
+#endif
#ifdef __cplusplus
/* default constructor */
@@ -155,6 +153,14 @@ struct private_module_t
#endif
};
+#ifndef __cplusplus
+/* C99 with pedantic don't allow anonymous unions which is used in below struct
+ * Disable pedantic for C for this struct only.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
#ifdef __cplusplus
struct private_handle_t : public native_handle
{
@@ -164,6 +170,8 @@ struct private_handle_t
struct native_handle nativeHandle;
#endif
+#ifdef __cplusplus
+ /* Never intended to be used from C code */
enum
{
PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
@@ -178,6 +186,7 @@ struct private_handle_t
LOCK_STATE_MAPPED = 1<<30,
LOCK_STATE_READ_MASK = 0x3FFFFFFF
};
+#endif
#if GRALLOC_ARM_DMA_BUF_MODULE
/*
@@ -262,14 +271,14 @@ struct private_handle_t
static const int sMagic = 0x3141592;
#if GRALLOC_ARM_UMP_MODULE
- private_handle_t(int flags, int usage, int size, void *base, int lock_state, ump_secure_id secure_id, ump_handle handle):
+ private_handle_t(int _flags, int _usage, int _size, void *base, int lock_state, ump_secure_id secure_id, ump_handle handle):
#if MALI_AFBC_GRALLOC == 1
share_attr_fd(-1),
#endif
magic(sMagic),
- flags(flags),
- usage(usage),
- size(size),
+ flags(_flags),
+ usage(_usage),
+ size(_size),
width(0),
height(0),
stride(0),
@@ -293,7 +302,7 @@ struct private_handle_t
}
#endif
- private_handle_t(int flags, int usage, int size, void *base, int lock_state):
+ private_handle_t(int _flags, int _usage, int _size, void *base, int lock_state):
#if GRALLOC_ARM_DMA_BUF_MODULE
share_fd(-1),
#endif
@@ -304,9 +313,9 @@ struct private_handle_t
ion_hnd(ION_INVALID_HANDLE),
#endif
magic(sMagic),
- flags(flags),
- usage(usage),
- size(size),
+ flags(_flags),
+ usage(_usage),
+ size(_size),
width(0),
height(0),
stride(0),
@@ -332,7 +341,7 @@ struct private_handle_t
numInts = NUM_INTS_IN_PRIVATE_HANDLE;
}
- private_handle_t(int flags, int usage, int size, void *base, int lock_state, int fb_file, off_t fb_offset, int unused):
+ private_handle_t(int _flags, int _usage, int _size, void *base, int lock_state, int fb_file, off_t fb_offset, int unused):
#if GRALLOC_ARM_DMA_BUF_MODULE
share_fd(-1),
#endif
@@ -343,9 +352,9 @@ struct private_handle_t
ion_hnd(ION_INVALID_HANDLE),
#endif
magic(sMagic),
- flags(flags),
- usage(usage),
- size(size),
+ flags(_flags),
+ usage(_usage),
+ size(_size),
width(0),
height(0),
stride(0),
@@ -366,6 +375,7 @@ struct private_handle_t
#endif
{
+ GRALLOC_UNUSED(unused);
version = sizeof(native_handle);
numFds = sNumFds;
numInts = NUM_INTS_IN_PRIVATE_HANDLE;
@@ -405,5 +415,9 @@ struct private_handle_t
}
#endif
};
+#ifndef __cplusplus
+/* Restore previous diagnostic for pedantic */
+#pragma GCC diagnostic pop
+#endif
#endif /* GRALLOC_PRIV_H_ */
diff --git a/gralloc/src/gralloc_vsync_default.cpp b/gralloc/src/gralloc_vsync_default.cpp
index 3297d05..40f6699 100755
--- a/gralloc/src/gralloc_vsync_default.cpp
+++ b/gralloc/src/gralloc_vsync_default.cpp
@@ -26,11 +26,13 @@
int gralloc_vsync_enable(framebuffer_device_t *dev)
{
+ GRALLOC_UNUSED(dev);
return 0;
}
int gralloc_vsync_disable(framebuffer_device_t *dev)
{
+ GRALLOC_UNUSED(dev);
return 0;
}
diff --git a/gralloc/src/gralloc_vsync_report.h b/gralloc/src/gralloc_vsync_report.h
index 9fd5015..ea45cc4 100755
--- a/gralloc/src/gralloc_vsync_report.h
+++ b/gralloc/src/gralloc_vsync_report.h
@@ -17,6 +17,8 @@
#ifndef GRALLOC_VSYNC_REPORT_H_
#define GRALLOC_VSYNC_REPORT_H_
+#include "gralloc_helper.h"
+
#ifdef __cplusplus
extern "C"
{
@@ -35,6 +37,8 @@ inline void gralloc_mali_vsync_report(mali_vsync_event event)
{
#ifdef MALI_VSYNC_EVENT_REPORT_ENABLE
_mali_base_arch_vsync_event_report(event);
+ #else
+ GRALLOC_UNUSED(event);
#endif
}
diff --git a/gralloc/src/mali_gralloc_formats.cpp b/gralloc/src/mali_gralloc_formats.cpp
new file mode 100755
index 0000000..a597065
--- /dev/null
+++ b/gralloc/src/mali_gralloc_formats.cpp
@@ -0,0 +1,523 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#include <string.h>
+#include <hardware/gralloc.h>
+#include <inttypes.h>
+#include <cutils/log.h>
+
+#include "mali_gralloc_formats.h"
+#include "gralloc_priv.h"
+
+static mali_gralloc_format_caps dpu_runtime_caps;
+static mali_gralloc_format_caps vpu_runtime_caps;
+static mali_gralloc_format_caps gpu_runtime_caps;
+static mali_gralloc_format_caps cam_runtime_caps;
+
+static int map_flex_formats(int req_format, uint64_t *producer_runtime_mask)
+{
+ /* Map Android flexible formats to internal base formats */
+ if(req_format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED ||
+ req_format == HAL_PIXEL_FORMAT_YCbCr_420_888)
+ {
+ req_format = MALI_GRALLOC_FORMAT_INTERNAL_NV12;
+ }
+ else if(req_format == HAL_PIXEL_FORMAT_YCbCr_422_888)
+ {
+ /* To be determined */
+
+ /* Disable AFBC until we know though */
+ *producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ else if(req_format == HAL_PIXEL_FORMAT_YCbCr_444_888)
+ {
+ /* To be determined */
+
+ /* Disable AFBC until we know though */
+ *producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ return req_format;
+}
+
+static bool is_afbc_supported(int req_format_mapped)
+{
+ bool rval = true;
+
+ /* These base formats we currently don't support with compression */
+ switch(req_format_mapped)
+ {
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW16:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW10:
+ case MALI_GRALLOC_FORMAT_INTERNAL_BLOB:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y0L2:
+ case MALI_GRALLOC_FORMAT_INTERNAL_P010:
+ case MALI_GRALLOC_FORMAT_INTERNAL_P210:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y210:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y410:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ rval = false;
+ break;
+ }
+ return rval;
+}
+
+static bool is_android_yuv_format(int req_format)
+{
+ bool rval = false;
+
+ switch(req_format)
+ {
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_Y8:
+ case HAL_PIXEL_FORMAT_Y16:
+ case HAL_PIXEL_FORMAT_YCbCr_420_888:
+ case HAL_PIXEL_FORMAT_YCbCr_422_888:
+ case HAL_PIXEL_FORMAT_YCbCr_444_888:
+ rval = true;
+ break;
+ }
+ return rval;
+}
+
+static bool is_afbc_allowed(int buffer_size)
+{
+ bool afbc_allowed = false;
+
+ (void) buffer_size;
+
+#if GRALLOC_DISP_W != 0 && GRALLOC_DISP_H != 0
+ afbc_allowed = ((buffer_size*100) / (GRALLOC_DISP_W*GRALLOC_DISP_H)) >= GRALLOC_AFBC_MIN_SIZE;
+
+#else
+ /* If display size is not valid then always allow AFBC */
+ afbc_allowed = true;
+
+#endif
+
+ return afbc_allowed;
+}
+
+static bool is_afbc_format(uint64_t internal_format)
+{
+ return (internal_format & MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK) != 0;
+}
+
+static uint64_t determine_best_format(int req_format, mali_gralloc_producer_type producer, mali_gralloc_consumer_type consumer,
+ uint64_t producer_runtime_mask, uint64_t consumer_runtime_mask)
+{
+ /* Default is to return the requested format */
+ uint64_t internal_format = req_format;
+ uint64_t dpu_mask = dpu_runtime_caps.caps_mask;
+ uint64_t gpu_mask = gpu_runtime_caps.caps_mask;
+ uint64_t vpu_mask = vpu_runtime_caps.caps_mask;
+ uint64_t cam_mask = cam_runtime_caps.caps_mask;
+
+ if(producer == MALI_GRALLOC_PRODUCER_GPU && gpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
+ {
+ gpu_mask &= producer_runtime_mask;
+
+ if(consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
+ {
+ gpu_mask &= consumer_runtime_mask;
+ dpu_mask &= consumer_runtime_mask;
+
+ if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK &&
+ dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_SPLITBLK;
+ }
+ else if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+ }
+ else if(consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
+ {
+ gpu_mask &= consumer_runtime_mask;
+
+ /* When GPU acts as both producer and consumer it prefers 16x16 superblocks */
+ if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
+ }
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+ }
+ else if(consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
+ {
+ vpu_mask &= consumer_runtime_mask;
+
+ if(req_format == HAL_PIXEL_FORMAT_YV12)
+ {
+ if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+ }
+ }
+ }
+ else if(producer == MALI_GRALLOC_PRODUCER_VIDEO_DECODER && vpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
+ {
+ vpu_mask &= producer_runtime_mask;
+
+ if(consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
+ {
+ gpu_mask &= consumer_runtime_mask;
+ dpu_mask &= consumer_runtime_mask;
+
+ if(internal_format == HAL_PIXEL_FORMAT_YV12)
+ {
+ if(vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+ }
+ }
+ else if(consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
+ {
+ gpu_mask &= consumer_runtime_mask;
+
+ if(internal_format == HAL_PIXEL_FORMAT_YV12)
+ {
+ if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+ }
+ }
+ else if(consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
+ {
+ /* Fall-through. To be decided.*/
+ }
+ }
+ else if(producer == MALI_GRALLOC_PRODUCER_CAMERA && cam_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
+ {
+ if(consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
+ {
+ /* Fall-through. To be decided.*/
+ }
+ else if(consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
+ {
+ /* Fall-through. To be decided.*/
+ }
+ else if(consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
+ {
+ /* Fall-through. To be decided.*/
+ }
+ }
+ return internal_format;
+}
+
+static uint64_t decode_internal_format(int req_format)
+{
+ uint64_t internal_format, me_mask, base_format, mapped_base_format;
+ uint64_t ignore_mask;
+
+ internal_format = GRALLOC_PRIVATE_FORMAT_UNWRAP(req_format);
+
+ me_mask = internal_format & MALI_GRALLOC_INTFMT_ME_EXT_MASK;
+ if(me_mask > 0 && ((me_mask - 1) & me_mask) != 0)
+ {
+ ALOGE("Internal format contains multiple mutually exclusive modifier bits: %" PRIx64, internal_format);
+ internal_format = 0;
+ goto out;
+ }
+
+ base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+
+ /* Even though private format allocations are intended to be for specific
+ * formats, certain test cases uses the flexible formats that needs to be mapped
+ * to internal ones.
+ */
+ mapped_base_format = map_flex_formats((uint32_t ) base_format, &ignore_mask);
+
+ /* Validate the internal base format passed in */
+ switch(mapped_base_format)
+ {
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGB_888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGB_565:
+ case MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y8:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y16:
+
+#if (PLATFORM_SDK_VERSION >= 19) && (PLATFORM_SDK_VERSION <= 22)
+ case MALI_GRALLOC_FORMAT_INTERNAL_sRGB_A_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_sRGB_X_8888:
+#endif
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW16:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW10:
+ case MALI_GRALLOC_FORMAT_INTERNAL_BLOB:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV420_8BIT:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y0L2:
+ case MALI_GRALLOC_FORMAT_INTERNAL_P010:
+ case MALI_GRALLOC_FORMAT_INTERNAL_P210:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y210:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y410:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV420_10BIT:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV422_10BIT:
+ if(mapped_base_format != base_format)
+ {
+ internal_format = (internal_format & MALI_GRALLOC_INTFMT_EXT_MASK) | mapped_base_format;
+ }
+ break;
+
+ default:
+ ALOGE("Internal base format requested is unrecognized: %" PRIx64 ,internal_format);
+ internal_format = 0;
+ break;
+ }
+out:
+ return internal_format;
+}
+
+static bool determine_producer(mali_gralloc_producer_type *producer, uint64_t *producer_runtime_mask, int req_format, int usage)
+{
+ bool rval = true;
+
+ /* Default to GPU */
+ *producer = MALI_GRALLOC_PRODUCER_GPU;
+
+ if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ {
+ rval = false;
+ }
+ else if(usage & GRALLOC_USAGE_HW_RENDER)
+ {
+ if((gpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE) &&
+ is_android_yuv_format(req_format))
+ {
+ *producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ *producer = MALI_GRALLOC_PRODUCER_GPU;
+ }
+ else if(usage & GRALLOC_USAGE_HW_CAMERA_MASK)
+ {
+ *producer = MALI_GRALLOC_PRODUCER_CAMERA;
+ }
+ /* HW_TEXTURE+HW_COMPOSER+EXTERNAL_DISP is a definition set by
+ * stagefright for "video decoder". We check for it here.
+ */
+ else if((usage & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_EXTERNAL_DISP)) ==
+ (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_EXTERNAL_DISP))
+ {
+ *producer = MALI_GRALLOC_PRODUCER_VIDEO_DECODER;
+ }
+
+ return rval;
+}
+
+static bool determine_consumer(mali_gralloc_consumer_type *consumer, uint64_t *consumer_runtime_mask, int req_format, int usage)
+{
+ bool rval = true;
+
+ /* Default to GPU */
+ *consumer = MALI_GRALLOC_CONSUMER_GPU_EXCL;
+
+ if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ {
+ rval = false;
+ }
+ /* When usage explicitly targets a consumer, as it does with GRALLOC_USAGE_HW_FB,
+ * we pick DPU even if there are no runtime capabilities present.
+ */
+ else if( usage & GRALLOC_USAGE_HW_FB )
+ {
+ *consumer = MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY;
+ }
+ else if(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER)
+ {
+ if((vpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD) &&
+ is_android_yuv_format(req_format))
+ {
+ *consumer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ *consumer = MALI_GRALLOC_CONSUMER_VIDEO_ENCODER;
+ }
+ /* GRALLOC_USAGE_HW_COMPOSER is by default applied by SurfaceFlinger so we can't exclusively rely on it
+ * to determine consumer. When a buffer is targeted for either we reject the DPU when it lacks
+ * runtime capabilities, in favor of the more capable GPU.
+ */
+ else if((usage & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER )) == (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER ) &&
+ dpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
+ {
+ *consumer = MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY;
+ }
+ else if(usage & GRALLOC_USAGE_HW_TEXTURE)
+ {
+ *consumer = MALI_GRALLOC_CONSUMER_GPU_EXCL;
+ }
+ return rval;
+}
+
+/*
+ * Here we determine format capabilities for the 4 IPs we support.
+ * For now these are controlled by build defines, but in the future
+ * they should be read out from each user-space driver.
+ */
+static void determine_format_capabilities()
+{
+ memset((void*) &dpu_runtime_caps,0,sizeof(dpu_runtime_caps));
+ memset((void*) &vpu_runtime_caps,0,sizeof(vpu_runtime_caps));
+ memset((void*) &gpu_runtime_caps,0,sizeof(gpu_runtime_caps));
+ memset((void*) &cam_runtime_caps,0,sizeof(cam_runtime_caps));
+
+ /* Determine DPU format capabilities */
+#if MALI_DISPLAY_VERSION >= 500
+ dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
+ dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
+#endif
+
+#if MALI_DISPLAY_VERSION >= 550
+ dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
+#endif
+
+
+
+ /* Determine GPU format capabilities */
+#if MALI_AFBC_GRALLOC == 1
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
+
+ /* Need to verify when to remove this */
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE;
+
+#if MALI_SUPPORT_AFBC_SPLITBLK == 1
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
+#endif
+
+#if MALI_SUPPORT_AFBC_WIDEBLK == 1
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK;
+#endif
+
+#if MALI_USE_YUV_AFBC_WIDEBLK != 1
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK_YUV_DISABLE;
+#endif
+
+#if MALI_SUPPORT_AFBC_TILED_HEADERS == 1
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS;
+#endif
+
+#endif /* MALI_AFBC_GRALLOC == 1 */
+
+ /* Determine VPU format capabilities */
+#if MALI_VIDEO_VERSION >= 500
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD;
+#endif
+
+
+ /* Build specific capability changes */
+#if GRALLOC_ARM_NO_EXTERNAL_AFBC == 1
+ {
+ dpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ gpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ vpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ cam_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+#endif
+}
+
+uint64_t mali_gralloc_select_format(int req_format, int usage, int buffer_size)
+{
+ uint64_t internal_format = 0;
+ mali_gralloc_consumer_type consumer;
+ mali_gralloc_producer_type producer;
+ uint64_t producer_runtime_mask = ~(0ULL);
+ uint64_t consumer_runtime_mask = ~(0ULL);
+ int req_format_mapped=0;
+
+ /* A unique usage specifies that an internal format is in req_format */
+ if(usage & MALI_GRALLOC_USAGE_PRIVATE_FORMAT)
+ {
+ internal_format = decode_internal_format(req_format);
+ goto out;
+ }
+
+ /* Re-map special Android formats */
+ req_format_mapped = map_flex_formats(req_format, &producer_runtime_mask);
+
+ /* Determine producer/consumer */
+ if(!determine_producer(&producer, &producer_runtime_mask, req_format, usage) ||
+ !determine_consumer(&consumer, &consumer_runtime_mask, req_format, usage))
+ {
+ /* Failing to determine producer/consumer usually means
+ * client has requested sw rendering.
+ */
+ internal_format = req_format_mapped;
+ goto out;
+ }
+
+ /*
+ * Determine runtime capability limitations
+ */
+
+ /* Disable AFBC based on unique usage */
+ if ((usage & MALI_GRALLOC_USAGE_NO_AFBC) == MALI_GRALLOC_USAGE_NO_AFBC)
+ {
+ if(is_android_yuv_format(req_format_mapped))
+ {
+ ALOGE("It is invalid to specify NO_AFBC usage flags when allocating YUV formats.\
+ Requested fmt: 0x%08X Re-Mapped fmt: 0x%08X",req_format,req_format_mapped);
+ internal_format = 0;
+ goto out;
+ }
+ producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ /* Disable AFBC based on buffer dimensions */
+ else if(!is_afbc_allowed(buffer_size))
+ {
+ producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ else if(!is_afbc_supported(req_format_mapped))
+ {
+ producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+
+ /* Automatically select format in case producer/consumer identified */
+ internal_format = determine_best_format(req_format_mapped, producer, consumer, producer_runtime_mask, consumer_runtime_mask);
+
+out:
+ ALOGV("mali_gralloc_select_format: req_format=0x%08X req_fmt_mapped=0x%08X internal_format=0x%" PRIx64 " usage=0x%08X",req_format, req_format_mapped, internal_format, usage);
+
+ return internal_format;
+}
+
+void mali_gralloc_initialize_capabilities()
+{
+ determine_format_capabilities();
+}
diff --git a/gralloc/src/mali_gralloc_formats.h b/gralloc/src/mali_gralloc_formats.h
new file mode 100755
index 0000000..74e47b1
--- /dev/null
+++ b/gralloc/src/mali_gralloc_formats.h
@@ -0,0 +1,299 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#ifndef MALI_GRALLOC_FORMATS_H_
+#define MALI_GRALLOC_FORMATS_H_
+
+#include <system/graphics.h>
+
+/* Internal formats are represented in gralloc as a 64bit identifier
+ * where the 32 lower bits are a base format and the 32 upper bits are modifiers.
+ *
+ * Modifier bits are divided into mutually exclusive ones and those that are not.
+ */
+/* Internal format type */
+typedef uint64_t mali_gralloc_internal_format;
+
+/* Internal format masks */
+#define MALI_GRALLOC_INTFMT_FMT_MASK 0x00000000ffffffffULL
+#define MALI_GRALLOC_INTFMT_EXT_MASK 0xffffffff00000000ULL
+#define MALI_GRALLOC_INTFMT_ME_EXT_MASK 0x0000ffff00000000ULL
+#define MALI_GRALLOC_INTFMT_REG_EXT_MASK 0xffff000000000000ULL
+
+/* Internal base formats */
+
+/* Base formats that do not have an identical HAL match
+ * are defined starting at the Android private range
+ */
+#define MALI_GRALLOC_FORMAT_INTERNAL_RANGE_BASE 0x100
+
+typedef enum
+{
+ /* Internal definitions for HAL formats. */
+ MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888,
+ MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888,
+ MALI_GRALLOC_FORMAT_INTERNAL_RGB_888 = HAL_PIXEL_FORMAT_RGB_888,
+ MALI_GRALLOC_FORMAT_INTERNAL_RGB_565 = HAL_PIXEL_FORMAT_RGB_565 ,
+ MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888,
+ MALI_GRALLOC_FORMAT_INTERNAL_YV12 = HAL_PIXEL_FORMAT_YV12 ,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y8 = HAL_PIXEL_FORMAT_Y8,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y16 = HAL_PIXEL_FORMAT_Y16,
+ MALI_GRALLOC_FORMAT_INTERNAL_YUV420_888 = HAL_PIXEL_FORMAT_YCbCr_420_888,
+
+#if (PLATFORM_SDK_VERSION >= 19) && (PLATFORM_SDK_VERSION <= 22)
+ MALI_GRALLOC_FORMAT_INTERNAL_sRGB_A_8888 = HAL_PIXEL_FORMAT_sRGB_A_8888,
+ MALI_GRALLOC_FORMAT_INTERNAL_sRGB_X_8888 = HAL_PIXEL_FORMAT_sRGB_X_8888,
+#endif
+
+ /* Camera specific HAL formats */
+ MALI_GRALLOC_FORMAT_INTERNAL_RAW16 = HAL_PIXEL_FORMAT_RAW16,
+ MALI_GRALLOC_FORMAT_INTERNAL_RAW12 = HAL_PIXEL_FORMAT_RAW12,
+ MALI_GRALLOC_FORMAT_INTERNAL_RAW10 = HAL_PIXEL_FORMAT_RAW10,
+ MALI_GRALLOC_FORMAT_INTERNAL_BLOB = HAL_PIXEL_FORMAT_BLOB,
+
+ /* Flexible YUV formats would be parsed but not have any representation as
+ * internal format itself but one of the ones below
+ */
+
+ /* The internal private formats that have no HAL equivivalent are defined
+ * afterwards starting at a specific base range */
+ MALI_GRALLOC_FORMAT_INTERNAL_NV12 = MALI_GRALLOC_FORMAT_INTERNAL_RANGE_BASE,
+ MALI_GRALLOC_FORMAT_INTERNAL_NV21,
+ MALI_GRALLOC_FORMAT_INTERNAL_YUV420_8BIT,
+ MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT,
+
+ /* Extended YUV formats
+ *
+ * NOTE: Y0L2, P010, P210, Y210 and Y410 are only supported uncompressed.
+ * YUV420_10BIT and YUV422_10BIT are only supported compressed.
+ */
+ MALI_GRALLOC_FORMAT_INTERNAL_Y0L2,
+ MALI_GRALLOC_FORMAT_INTERNAL_P010,
+ MALI_GRALLOC_FORMAT_INTERNAL_P210,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y210,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y410,
+ MALI_GRALLOC_FORMAT_INTERNAL_YUV420_10BIT,
+ MALI_GRALLOC_FORMAT_INTERNAL_YUV422_10BIT,
+
+ /* Add more internal formats here. Make sure decode_internal_format() is updated. */
+
+ /* These are legacy 0.3 gralloc formats used only by the wrap/unwrap macros. */
+ MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP,
+
+ MALI_GRALLOC_FORMAT_INTERNAL_RANGE_LAST,
+} mali_gralloc_pixel_format;
+
+
+/* Format Modifier Bits Locations */
+#define MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START 32
+#define MALI_GRALLOC_INTFMT_EXTENSION_BIT_START (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+16)
+
+/* Mutually Exclusive Modifier Bits */
+
+/* This format will use AFBC */
+#define MALI_GRALLOC_INTFMT_AFBC_BASIC (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+0))
+
+/* This format uses AFBC split block mode */
+#define MALI_GRALLOC_INTFMT_AFBC_SPLITBLK (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+1))
+
+#define MALI_GRALLOC_INTFMT_UNUSED (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+2))
+
+/* This format uses AFBC wide block mode */
+#define MALI_GRALLOC_INTFMT_AFBC_WIDEBLK (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+3))
+
+
+/* Regular Modifier Bits */
+#define MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START+0))
+
+
+/* This mask should be used to check or clear support for AFBC for an internal format
+ * These bits are mutually exclusive so this mask should not be used to enable support
+ */
+#define MALI_GRALLOC_INTFMT_AFBCENABLE_MASK ((uint64_t) (MALI_GRALLOC_INTFMT_AFBC_BASIC | \
+ MALI_GRALLOC_INTFMT_AFBC_SPLITBLK | \
+ MALI_GRALLOC_INTFMT_AFBC_WIDEBLK))
+
+/* Prototypes */
+uint64_t mali_gralloc_select_format(int req_format,int usage, int buffer_size);
+
+/* These are legacy Gralloc 0.3 support macros for passing private formats through the 0.3 alloc interface.
+ * It packs modifier bits together with base format into a 32 bit format identifier.
+ * Gralloc 1.0 interface should use private functions to set private buffer format in the buffer descriptor.
+ *
+ * Packing:
+ *
+ * Bits 15-0: mali_gralloc_pixel_format format
+ * Bits 23-16: mutually exclusive modifier bits
+ * Bits 31-24: regular modifier bits
+ */
+static inline int mali_gralloc_format_wrapper(int format, int modifiers)
+{
+ /* Internal formats that are identical to HAL formats
+ * have the same definition. This is convenient for
+ * client parsing code to not have to parse them separately.
+ *
+ * For 3 of the HAL YUV formats that have very large definitions
+ * this causes problems for packing in modifier bits.
+ * Because of this reason we redefine these three formats
+ * while packing/unpacking them.
+ */
+ if(format == MALI_GRALLOC_FORMAT_INTERNAL_YV12)
+ {
+ format = MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP;
+ }
+ else if(format == MALI_GRALLOC_FORMAT_INTERNAL_Y8)
+ {
+ format = MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP;
+ }
+ else if(format == MALI_GRALLOC_FORMAT_INTERNAL_Y16)
+ {
+ format = MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP;
+ }
+ return (modifiers | format);
+}
+
+static inline uint64_t mali_gralloc_format_unwrap(int x)
+{
+ uint64_t internal_format = (uint64_t) ( ((((uint64_t)(x)) & 0xff000000) << 24) | // Regular modifier bits
+ ((((uint64_t)(x)) & 0x00ff0000) << 16) | // Mutually exclusive modifier bits
+ (((uint64_t)(x)) & 0x0000ffff) ); // Private format
+
+ uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+ uint64_t modifiers = internal_format & MALI_GRALLOC_INTFMT_EXT_MASK;
+
+ if(base_format == MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP)
+ {
+ base_format = MALI_GRALLOC_FORMAT_INTERNAL_YV12;
+ }
+ else if(base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP)
+ {
+ base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y8;
+ }
+ else if(base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP)
+ {
+ base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y16;
+ }
+ return (modifiers | base_format);
+}
+
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER(x) ( mali_gralloc_format_wrapper(x, 0) )
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16)) )
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_SPLITBLK(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> 16)) )
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_WIDEBLK(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> 16)) )
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_BASIC(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 24) | \
+ (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16)))
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_WIDE(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 24) | \
+ (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> 16)))
+#define GRALLOC_PRIVATE_FORMAT_UNWRAP(x) mali_gralloc_format_unwrap(x)
+
+/* IP block capability masks */
+#define MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT ((uint64_t) (1 << 0))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC ((uint64_t) (1 << 1))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK ((uint64_t) (1 << 2))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK ((uint64_t) (1 << 3))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK_YUV_DISABLE ((uint64_t) (1 << 4))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD ((uint64_t) (1 << 5))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE ((uint64_t) (1 << 6))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS ((uint64_t) (1 << 7))
+
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK ((uint64_t) (MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC | \
+ MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK | \
+ MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK | \
+ MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS))
+
+struct mali_gralloc_format_caps
+{
+ uint64_t caps_mask;
+};
+typedef struct mali_gralloc_format_caps mali_gralloc_format_caps;
+
+
+/* Producer and Consumer definitions */
+typedef enum
+{
+ MALI_GRALLOC_PRODUCER_VIDEO_DECODER,
+ MALI_GRALLOC_PRODUCER_GPU,
+ MALI_GRALLOC_PRODUCER_CAMERA,
+} mali_gralloc_producer_type;
+
+typedef enum
+{
+
+ /* For surface composition in SurfaceFlinger a producer
+ * will not know what consumer will process a buffer.
+ *
+ * MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY means the GPU
+ * MUST support the given format but it should be allocated
+ * with preference to the DPU.
+ */
+ MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY,
+ MALI_GRALLOC_CONSUMER_VIDEO_ENCODER,
+
+
+ /* This is used when no known "premium" dpu is configured.
+ * For example, HDLCD/CLCD would be such a dpu.
+ */
+ MALI_GRALLOC_CONSUMER_GPU_EXCL,
+} mali_gralloc_consumer_type;
+
+
+/*
+ * Below usage types overlap, this is intentional.
+ * The reason is that for Gralloc 0.3 there are very
+ * few usage flags we have at our disposal.
+ *
+ * The overlapping is handled by processing the definitions
+ * in a specific order.
+ *
+ * MALI_GRALLOC_USAGE_PRIVATE_FORMAT and MALI_GRALLOC_USAGE_NO_AFBC
+ * don't overlap and are processed first.
+ *
+ * MALI_GRALLOC_USAGE_YUV_CONF are only for YUV formats and clients
+ * using MALI_GRALLOC_USAGE_NO_AFBC must never allocate YUV formats.
+ * The latter is strictly enforced and allocations will fail.
+ *
+ * MALI_GRALLOC_USAGE_AFBC_PADDING is only valid if MALI_GRALLOC_USAGE_NO_AFBC
+ * is not present.
+ */
+typedef enum
+{
+ /* The client has specified a private format in the format parameter */
+ MALI_GRALLOC_USAGE_PRIVATE_FORMAT = (int) GRALLOC_USAGE_PRIVATE_3,
+
+ /* Buffer won't be allocated as AFBC */
+ MALI_GRALLOC_USAGE_NO_AFBC = (int) (GRALLOC_USAGE_PRIVATE_1 | GRALLOC_USAGE_PRIVATE_2),
+
+ /* Valid only for YUV allocations */
+ MALI_GRALLOC_USAGE_YUV_CONF_0 = 0,
+ MALI_GRALLOC_USAGE_YUV_CONF_1 = (int) GRALLOC_USAGE_PRIVATE_1,
+ MALI_GRALLOC_USAGE_YUV_CONF_2 = (int) GRALLOC_USAGE_PRIVATE_0,
+ MALI_GRALLOC_USAGE_YUV_CONF_3 = (int) (GRALLOC_USAGE_PRIVATE_0 | GRALLOC_USAGE_PRIVATE_1),
+ MALI_GRALLOC_USAGE_YUV_CONF_MASK = MALI_GRALLOC_USAGE_YUV_CONF_3,
+
+ /* A very specific alignment is requested on some buffers */
+ MALI_GRALLOC_USAGE_AFBC_PADDING = GRALLOC_USAGE_PRIVATE_2,
+
+} mali_gralloc_usage_type;
+
+/* Prototypes */
+uint64_t mali_gralloc_select_format(int req_format,int usage, int buffer_size);
+void mali_gralloc_initialize_capabilities(void);
+
+#endif /* MALI_GRALLOC_FORMATS_H_ */
diff --git a/mali/lib/egl/libGLES_mali.so b/mali/lib/egl/libGLES_mali.so
index f5daafc..61c9411 100644
--- a/mali/lib/egl/libGLES_mali.so
+++ b/mali/lib/egl/libGLES_mali.so
Binary files differ
diff --git a/mali/lib/hw/gralloc.juno.so b/mali/lib/hw/gralloc.juno.so
index 232ac00..64c1c19 100644
--- a/mali/lib/hw/gralloc.juno.so
+++ b/mali/lib/hw/gralloc.juno.so
Binary files differ
diff --git a/mali/lib/libRSDriverArm.so b/mali/lib/libRSDriverArm.so
index 4d50ee6..cb32cab 100644
--- a/mali/lib/libRSDriverArm.so
+++ b/mali/lib/libRSDriverArm.so
Binary files differ
diff --git a/mali/lib/libbccArm.so b/mali/lib/libbccArm.so
index 918d746..aff68fc 100644
--- a/mali/lib/libbccArm.so
+++ b/mali/lib/libbccArm.so
Binary files differ
diff --git a/mali/lib/libmalicore.bc b/mali/lib/libmalicore.bc
index 7f01bec..c546a06 100644
--- a/mali/lib/libmalicore.bc
+++ b/mali/lib/libmalicore.bc
Binary files differ
diff --git a/mali/lib64/egl/libGLES_mali.so b/mali/lib64/egl/libGLES_mali.so
index fd5d6cf..dc89eea 100644
--- a/mali/lib64/egl/libGLES_mali.so
+++ b/mali/lib64/egl/libGLES_mali.so
Binary files differ
diff --git a/mali/lib64/hw/gralloc.juno.so b/mali/lib64/hw/gralloc.juno.so
index da79ca4..49afd76 100644
--- a/mali/lib64/hw/gralloc.juno.so
+++ b/mali/lib64/hw/gralloc.juno.so
Binary files differ
diff --git a/mali/lib64/libRSDriverArm.so b/mali/lib64/libRSDriverArm.so
index 38321e7..d0d346d 100644
--- a/mali/lib64/libRSDriverArm.so
+++ b/mali/lib64/libRSDriverArm.so
Binary files differ
diff --git a/mali/lib64/libbccArm.so b/mali/lib64/libbccArm.so
index 4900fbb..e9bc987 100644
--- a/mali/lib64/libbccArm.so
+++ b/mali/lib64/libbccArm.so
Binary files differ
diff --git a/mali/lib64/libmalicore.bc b/mali/lib64/libmalicore.bc
index abe6262..45e6d45 100644
--- a/mali/lib64/libmalicore.bc
+++ b/mali/lib64/libmalicore.bc
Binary files differ