summaryrefslogtreecommitdiff
authorStark Li <stark.li@amlogic.com>2016-05-23 03:17:32 (GMT)
committer Jiyu Yang <jiyu.yang@amlogic.com>2016-05-23 03:18:49 (GMT)
commitcc5d2dfc3c37baa497f113e64bf78e3b95721229 (patch)
tree3fa13e9d00cbbaf0a39e6683390cec03a9eaf18a
parente645920e31144822763f84d9403f075a897a3dc3 (diff)
downloadgralloc-cc5d2dfc3c37baa497f113e64bf78e3b95721229.zip
gralloc-cc5d2dfc3c37baa497f113e64bf78e3b95721229.tar.gz
gralloc-cc5d2dfc3c37baa497f113e64bf78e3b95721229.tar.bz2
PD#125571 gralloc: update with t83x r11p0
Change-Id: Ieb249e2920a897e99bbd3743c943550b643528ed
Diffstat
-rw-r--r--Android.mk26
-rw-r--r--alloc_device.cpp92
-rw-r--r--alloc_ion.cpp3
-rw-r--r--alloc_ion.cpp.rej159
-rw-r--r--format_chooser.cpp75
-rw-r--r--format_chooser.h22
-rw-r--r--format_chooser_blockinit.cpp1
-rwxr-xr-xformatdef_files/gpu_afbc_wideblk.defs6
-rwxr-xr-xformatdef_files/gpu_default.defs2
-rw-r--r--framebuffer_device.cpp17
-rw-r--r--gralloc_buffer_priv.h17
-rw-r--r--gralloc_module.cpp69
-rw-r--r--gralloc_module_ion.cpp7
-rw-r--r--gralloc_priv.h12
14 files changed, 436 insertions, 72 deletions
diff --git a/Android.mk b/Android.mk
index d2df9ce..bce99bb 100644
--- a/Android.mk
+++ b/Android.mk
@@ -17,10 +17,15 @@
LOCAL_PATH := $(call my-dir)
+# Include platform specific makefiles
+include $(if $(wildcard $(LOCAL_PATH)/Android.$(TARGET_BOARD_PLATFORM).mk), $(LOCAL_PATH)/Android.$(TARGET_BOARD_PLATFORM).mk,)
+
MALI_ION?=1
GRALLOC_VSYNC_BACKEND?=default
DISABLE_FRAMEBUFFER_HAL?=0
MALI_SUPPORT_AFBC_WIDEBLK?=0
+GRALLOC_USE_ION_DMA_HEAP?=0
+GRALLOC_USE_ION_COMPOUND_PAGE_HEAP?=0
#framebuffer apis
include $(CLEAR_VARS)
@@ -110,7 +115,14 @@ endif
$(info MALI_AFBC_GRALLOC is $(MALI_AFBC_GRALLOC))
#If cropping should be enabled for AFBC YUV420 buffers
-AFBC_YUV420_EXTRA_MB_ROW_NEEDED = 0
+AFBC_YUV420_EXTRA_MB_ROW_NEEDED ?= 0
+
+ifdef GRALLOC_DISP_W
+LOCAL_CFLAGS += -DGRALLOC_DISP_W=$(GRALLOC_DISP_W)
+endif
+ifdef GRALLOC_DISP_H
+LOCAL_CFLAGS += -DGRALLOC_DISP_H=$(GRALLOC_DISP_H)
+endif
ifdef MALI_DISPLAY_VERSION
#if Mali display is available, should disable framebuffer HAL
@@ -122,7 +134,7 @@ LOCAL_PRELINK_MODULE := false
LOCAL_SHARED_LIBRARIES := libhardware liblog libcutils libGLESv1_CM $(ALLOCATION_LIB) libfbcnf
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) -DAFBC_YUV420_EXTRA_MB_ROW_NEEDED=$(AFBC_YUV420_EXTRA_MB_ROW_NEEDED)
+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) -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)
ifdef MALI_DISPLAY_VERSION
LOCAL_CFLAGS += -DMALI_DISPLAY_VERSION=$(MALI_DISPLAY_VERSION)
@@ -139,6 +151,14 @@ ifeq ($(GRALLOC_FB_SWAP_RED_BLUE),1)
LOCAL_CFLAGS += -DGRALLOC_FB_SWAP_RED_BLUE
endif
+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_PATH_32 := $(TARGET_OUT)/lib
LOCAL_MODULE_PATH_64 := $(TARGET_OUT)/lib64
LOCAL_MODULE_RELATIVE_PATH := hw
@@ -161,4 +181,6 @@ LOCAL_SRC_FILES := \
$(AFBC_FILES) \
gralloc_vsync_${GRALLOC_VSYNC_BACKEND}.cpp
+LOCAL_MODULE_OWNER := arm
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/alloc_device.cpp b/alloc_device.cpp
index ec866f3..f081f88 100644
--- a/alloc_device.cpp
+++ b/alloc_device.cpp
@@ -42,6 +42,13 @@
#define AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY 16
#define AFBC_WIDEBLK_WIDTH_ALIGN 32
+// 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.
+#define YUV_MALI_PLANE_ALIGN 128
+
+// Default YUV stride aligment in Android
+#define YUV_ANDROID_PLANE_ALIGN 16
+
static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle, int* stride, int* byte_stride)
{
private_module_t* private_t = reinterpret_cast<private_module_t*>(dev->common.module);
@@ -268,7 +275,6 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
{
width = GRALLOC_ALIGN(width, AFBC_PIXELS_PER_BLOCK);
}
- height = GRALLOC_ALIGN(height, 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
@@ -276,6 +282,11 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
*internalHeight += AFBC_PIXELS_PER_BLOCK;
#endif
+ /* 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 );
+
yuv420_afbc_luma_stride = width;
yuv420_afbc_chroma_stride = GRALLOC_ALIGN(yuv420_afbc_luma_stride / 2, 16); /* Horizontal downsampling*/
@@ -283,8 +294,9 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
{
int nblocks = width / AFBC_PIXELS_PER_BLOCK * height / AFBC_PIXELS_PER_BLOCK;
/* Simplification of (height * luma-stride + 2 * (height /2 * chroma_stride) */
- *size = (yuv420_afbc_luma_stride + yuv420_afbc_chroma_stride) * height
- + GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, AFBC_BODY_BUFFER_BYTE_ALIGNMENT);
+ *size =
+ ( yuv420_afbc_luma_stride + yuv420_afbc_chroma_stride ) * height +
+ GRALLOC_ALIGN( nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, AFBC_BODY_BUFFER_BYTE_ALIGNMENT );
}
if (byte_stride != NULL)
@@ -303,18 +315,19 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
/*
* Computes the strides and size for an YV12 buffer
*
- * width Public known width of the buffer in pixels
- * height Public known height of the buffer in pixels
+ * 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
- * 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.
+ * 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
+ * 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.
+ * 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)
+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;
@@ -330,11 +343,11 @@ static bool get_yv12_stride_and_size(int width, int height,
}
/* Android assumes the buffer should be aligned to 16. */
- luma_stride = GRALLOC_ALIGN(width, 16);
+ luma_stride = GRALLOC_ALIGN(width, stride_alignment);
if (size != NULL)
{
- int chroma_stride = GRALLOC_ALIGN(luma_stride / 2, 16);
+ int chroma_stride = GRALLOC_ALIGN(luma_stride / 2, stride_alignment);
/* Simplification of ((height * luma_stride ) + 2 * ((height / 2) * chroma_stride)). */
*size = height * (luma_stride + chroma_stride);
}
@@ -496,12 +509,12 @@ static bool get_yuv_pX10_stride_and_size(int width, int height, int vss, int* pi
return false;
}
- luma_pixel_stride = GRALLOC_ALIGN(width, 16);
- luma_byte_stride = GRALLOC_ALIGN(width * 2, 16);
+ luma_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
+ luma_byte_stride = GRALLOC_ALIGN(width * 2, YUV_MALI_PLANE_ALIGN);
if (size != NULL)
{
- int chroma_size = GRALLOC_ALIGN(width * 2, 16) * (height / vss);
+ int chroma_size = GRALLOC_ALIGN(width * 2, YUV_MALI_PLANE_ALIGN) * (height / vss);
*size = luma_byte_stride * height + chroma_size;
}
@@ -542,8 +555,8 @@ static bool get_yuv_y210_stride_and_size(int width, int height, int* pixel_strid
return false;
}
- y210_pixel_stride = GRALLOC_ALIGN(width, 16);
- y210_byte_stride = GRALLOC_ALIGN(width * 4, 16);
+ y210_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
+ y210_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN);
if (size != NULL)
{
@@ -588,8 +601,8 @@ static bool get_yuv_y0l2_stride_and_size(int width, int height, int* pixel_strid
return false;
}
- y0l2_pixel_stride = GRALLOC_ALIGN(width * 4, 16); /* 4 pixels packed per line */
- y0l2_byte_stride = GRALLOC_ALIGN(width * 4, 16); /* Packed in 64-bit chunks, 2 x downsampled horizontally */
+ 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 */
if (size != NULL)
{
@@ -627,8 +640,8 @@ static bool get_yuv_y410_stride_and_size(int width, int height, int* pixel_strid
{
int y410_byte_stride, y410_pixel_stride;
- y410_pixel_stride = GRALLOC_ALIGN(width, 16);
- y410_byte_stride = GRALLOC_ALIGN(width * 4, 16);
+ y410_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
+ y410_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN);
if (size != NULL)
{
@@ -857,7 +870,10 @@ 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);
+ 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;
if (internal_format & (GRALLOC_ARM_INTFMT_AFBC | GRALLOC_ARM_INTFMT_AFBC_SPLITBLK | GRALLOC_ARM_INTFMT_AFBC_WIDEBLK))
{
@@ -867,6 +883,13 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
}
else if (internal_format & GRALLOC_ARM_INTFMT_AFBC_WIDEBLK)
{
+#if 1 != MALI_USE_YUV_AFBC_WIDEBLK
+ if (alloc_for_arm_afbc_yuv)
+ {
+ ALOGE("Unsupported format YUV AFBC WIDEBLK.");
+ return -EINVAL;
+ }
+#endif
type = AFBC_WIDEBLK;
}
else
@@ -875,11 +898,9 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
}
}
- 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;
-
if (!alloc_for_extended_yuv && !alloc_for_arm_afbc_yuv)
{
+ int yv12_align = YUV_MALI_PLANE_ALIGN;
switch (internal_format & GRALLOC_ARM_INTFMT_FMT_MASK)
{
case HAL_PIXEL_FORMAT_RGBA_8888:
@@ -903,8 +924,17 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
break;
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_420_888:
case HAL_PIXEL_FORMAT_YV12:
- if (!get_yv12_stride_and_size(GRALLOC_ALIGN(w, 2), GRALLOC_ALIGN(h, 2), &pixel_stride, &byte_stride, &size, type, &internalHeight))
+ // 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.
+ if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ {
+ yv12_align = YUV_ANDROID_PLANE_ALIGN;
+ }
+
+
+ if (!get_yv12_stride_and_size(GRALLOC_ALIGN(w, 2), GRALLOC_ALIGN(h, 2), &pixel_stride, &byte_stride, &size, type, &internalHeight, yv12_align))
{
return -EINVAL;
}
@@ -917,9 +947,9 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
case HAL_PIXEL_FORMAT_BLOB:
get_blob_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type);
break;
- case HAL_PIXEL_FORMAT_YCbCr_420_888:
+ /*case HAL_PIXEL_FORMAT_YCbCr_420_888:
get_yuv_420_888_stride_and_size(w, h, &pixel_stride, &byte_stride, &size);
- break;
+ break;*/
default:
return -EINVAL;
}
diff --git a/alloc_ion.cpp b/alloc_ion.cpp
index 15bfd24..3a19a07 100644
--- a/alloc_ion.cpp
+++ b/alloc_ion.cpp
@@ -119,13 +119,14 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand
lock_state = private_handle_t::LOCK_STATE_MAPPED;
}
- private_handle_t *hnd = new private_handle_t( private_handle_t::PRIV_FLAGS_USES_ION, usage, size, cpu_ptr,
+ private_handle_t *hnd = new private_handle_t( private_handle_t::PRIV_FLAGS_USES_ION /*TODO ion extend*| priv_heap_flag*/, usage, size, cpu_ptr,
lock_state );
if ( NULL != hnd )
{
hnd->share_fd = shared_fd;
hnd->ion_hnd = ion_hnd;
+ /*TODO ion extend hnd->min_pgsz = min_pgsz; */
*pHandle = hnd;
return 0;
}
diff --git a/alloc_ion.cpp.rej b/alloc_ion.cpp.rej
new file mode 100644
index 0000000..670c13e
--- a/dev/null
+++ b/alloc_ion.cpp.rej
@@ -0,0 +1,159 @@
+--- alloc_ion.cpp
++++ alloc_ion.cpp
+@@ -35,19 +35,70 @@
+ #include <linux/ion.h>
+ #include <ion/ion.h>
+
+-int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle)
++
++static ion_user_handle_t alloc_from_ion_heap(int ion_fd, size_t size, unsigned int heap_mask,
++ unsigned int flags, int *min_pgsz)
+ {
+- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
+- ion_user_handle_t ion_hnd;
+- unsigned char *cpu_ptr = NULL;
+- int shared_fd;
++ ion_user_handle_t ion_hnd = ION_INVALID_HANDLE;
+ int ret;
++
++ if ((ion_fd < 0) || (size <= 0) || (heap_mask == 0) || (min_pgsz == NULL))
++ return ION_INVALID_HANDLE;
++
++ ret = ion_alloc(ion_fd, size, 0, heap_mask, flags, &ion_hnd);
++ if (ret != 0)
++ {
++ /* If everything else failed try system heap */
++ flags = 0; /* Fallback option flags are not longer valid */
++ ion_alloc(ion_fd, size, 0, ION_HEAP_SYSTEM_MASK, flags, &ion_hnd);
++ }
++
++ if (ion_hnd > ION_INVALID_HANDLE)
++ {
++ switch (heap_mask)
++ {
++ case ION_HEAP_SYSTEM_MASK:
++ *min_pgsz = SZ_4K;
++ break;
++ case ION_HEAP_SYSTEM_CONTIG_MASK:
++ case ION_HEAP_CARVEOUT_MASK:
++#ifdef ION_HEAP_TYPE_DMA_MASK
++ case ION_HEAP_TYPE_DMA_MASK:
++#endif
++ *min_pgsz = size;
++ break;
++#ifdef ION_HEAP_CHUNK_MASK
++ /* NOTE: if have this heap make sure your ION chunk size is 2M*/
++ case ION_HEAP_CHUNK_MASK:
++ *min_pgsz = SZ_2M;
++ break;
++#endif
++#ifdef ION_HEAP_COMPOUND_PAGE_MASK
++ case ION_HEAP_COMPOUND_PAGE_MASK:
++ *min_pgsz = SZ_2M;
++ break;
++#endif
++ /* If have customized heap please set the suitable pg type according to
++ * the customized ION implementation
++ */
++#ifdef ION_HEAP_CUSTOM_MASK
++ case ION_HEAP_CUSTOM_MASK:
++ *min_pgsz = SZ_4K;
++ break;
++#endif
++ default:
++ *min_pgsz = SZ_4K;
++ break;
++ }
++ }
++
++ return ion_hnd;
++}
++
++unsigned int pick_ion_heap(int usage)
++{
+ unsigned int heap_mask;
+- int ion_flags = 0;
+- static int support_protected = 1; /* initially, assume we support protected memory */
+- int lock_state = 0;
+
+- /* Select heap type based on usage hints */
+ if(usage & GRALLOC_USAGE_PROTECTED)
+ {
+ #if defined(ION_HEAP_SECURE_MASK)
+@@ -57,20 +108,71 @@
+ return -1;
+ #endif
+ }
++#if defined(ION_HEAP_TYPE_COMPOUND_PAGE_MASK) && GRALLOC_USE_ION_COMPOUND_PAGE_HEAP
++ else if(usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER))
++ {
++ heap_mask = ION_HEAP_TYPE_COMPOUND_PAGE_MASK;
++ }
++#elif defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
++ else if(usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER))
++ {
++ heap_mask = ION_HEAP_TYPE_DMA_MASK;
++ }
++#endif
+ else
+ {
+ heap_mask = ION_HEAP_SYSTEM_MASK;
+ }
+
+- if ( (usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN )
++ return heap_mask;
++}
++
++void set_ion_flags(unsigned int heap_mask, int usage, unsigned int *priv_heap_flag, int *ion_flags)
++{
++ if (priv_heap_flag)
++ {
++#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
++ if (heap_mask == ION_HEAP_TYPE_DMA_MASK)
++ {
++ *priv_heap_flag = private_handle_t::PRIV_FLAGS_USES_ION_DMA_HEAP;
++ }
++#endif
++ }
++
++ if (ion_flags)
+ {
+- ion_flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
++#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
++ if(heap_mask != ION_HEAP_TYPE_DMA_MASK)
++ {
++#endif
++ if ( (usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN )
++ {
++ *ion_flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
++ }
++#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
++ }
++#endif
+ }
++}
++
++int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle)
++{
++ private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
++ ion_user_handle_t ion_hnd;
++ unsigned char *cpu_ptr = NULL;
++ int shared_fd;
++ int ret;
++ unsigned int heap_mask, priv_heap_flag = 0;
++ int ion_flags = 0;
++ static int support_protected = 1; /* initially, assume we support protected memory */
++ int lock_state = 0;
++ int min_pgsz = 0;
+
+- ret = ion_alloc(m->ion_client, size, 0, heap_mask,
+- ion_flags, &ion_hnd );
++ heap_mask = pick_ion_heap(usage);
++ set_ion_flags(heap_mask, usage, &priv_heap_flag, &ion_flags);
+
+- if ( ret != 0)
++ ion_hnd = alloc_from_ion_heap(m->ion_client, size, heap_mask, ion_flags, &min_pgsz);
++ if (ion_hnd <= ION_INVALID_HANDLE)
+ {
+ AERR("Failed to ion_alloc from ion_client:%d", m->ion_client);
+ return -1;
diff --git a/format_chooser.cpp b/format_chooser.cpp
index c3f9ea0..e6da3e6 100644
--- a/format_chooser.cpp
+++ b/format_chooser.cpp
@@ -20,23 +20,16 @@
#include <hardware/gralloc.h>
#include "format_chooser.h"
-#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)))
+#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)
{
@@ -78,18 +71,40 @@ static inline int find_format_index(int format)
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)
+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;
@@ -100,6 +115,7 @@ uint64_t gralloc_select_format(int req_format, int usage)
int largest_weight_ind=-1;
int16_t accum_weights[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST] = {0};
int afbc_split_mode = 0;
+ bool afbc_allowed;
ALOGV("gralloc_select_format: req_format=0x%x usage=0x%x\n",req_format,usage);
@@ -172,6 +188,7 @@ uint64_t gralloc_select_format(int req_format, int usage)
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;
@@ -181,6 +198,14 @@ uint64_t gralloc_select_format(int req_format, int usage)
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;
@@ -219,6 +244,11 @@ uint64_t gralloc_select_format(int req_format, int usage)
}
#endif
+ /* Implementation defined format set to YCbCr_420_888 interpreted as NV12. */
+ if((req_format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) || (req_format == HAL_PIXEL_FORMAT_YCbCr_420_888))
+ {
+ return HAL_PIXEL_FORMAT_YCbCr_420_888;
+ }
if (0 == (usage & GRALLOC_USAGE_HW_FB)) {
return new_format;
}
@@ -231,6 +261,7 @@ uint64_t gralloc_select_format(int req_format, int usage)
return new_format;
}
+ afbc_allowed = is_afbc_allowed(buffer_size);
while (blklist[n].blk_init != 0)
{
if ( (blklist[n].hwblkconf.usage & usage) != 0 )
@@ -239,7 +270,11 @@ uint64_t gralloc_select_format(int req_format, int usage)
for (m=GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_FIRST; m<GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_LAST; m++)
{
- if ( blklist[n].hwblkconf.weights[intformat_ind][m] != DEFAULT_WEIGHT_UNSUPPORTED )
+ 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];
diff --git a/format_chooser.h b/format_chooser.h
index 909180f..8b99ecd 100644
--- a/format_chooser.h
+++ b/format_chooser.h
@@ -68,6 +68,7 @@ typedef enum
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,
@@ -128,6 +129,7 @@ typedef enum
GRALLOC_ARM_HAL_FORMAT_INDEXED_YV12,
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,
@@ -152,6 +154,24 @@ typedef enum
#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)))
+
typedef struct
{
/* The internal extended format exported outside of gralloc */
@@ -161,7 +181,7 @@ typedef struct
gralloc_arm_hal_index_format comp_format_list[MAX_COMPATIBLE];
} internal_fmt_info;
-uint64_t gralloc_select_format(int req_format, int usage);
+uint64_t gralloc_select_format(int req_format, int usage, int buffer_size);
struct hwblk
{
diff --git a/format_chooser_blockinit.cpp b/format_chooser_blockinit.cpp
index d1b03ac..cd58340 100644
--- a/format_chooser_blockinit.cpp
+++ b/format_chooser_blockinit.cpp
@@ -87,6 +87,7 @@ const internal_fmt_info translate_internal_indexed[GRALLOC_ARM_FORMAT_INTERNAL_I
{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,
diff --git a/formatdef_files/gpu_afbc_wideblk.defs b/formatdef_files/gpu_afbc_wideblk.defs
index b38c09a..665faa2 100755
--- a/formatdef_files/gpu_afbc_wideblk.defs
+++ b/formatdef_files/gpu_afbc_wideblk.defs
@@ -18,7 +18,7 @@
static void gpu_afbc_read_blkinit(struct hwblk *blk,int16_t **array)
{
- /* Initialiaze GPU default weight setup */
+ /* Initialize GPU default weight setup */
gpu_read_blkinit(blk, array);
(*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_RGBA_8888_AFBC] = DEFAULT_WEIGHT_MOST_PREFERRED;
@@ -40,7 +40,9 @@ static void gpu_afbc_read_blkinit(struct hwblk *blk,int16_t **array)
(*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
}
@@ -54,7 +56,6 @@ static void gpu_afbc_write_blkinit(struct hwblk *blk,int16_t **array)
(*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;
@@ -67,5 +68,4 @@ static void gpu_afbc_write_blkinit(struct hwblk *blk,int16_t **array)
(*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;
- (*array)[GRALLOC_ARM_FORMAT_INTERNAL_INDEXED_YUV420_8BIT_AFBC_WIDEBLK] = DEFAULT_WEIGHT_MOST_PREFERRED - 30;
}
diff --git a/formatdef_files/gpu_default.defs b/formatdef_files/gpu_default.defs
index e08e658..f604067 100755
--- a/formatdef_files/gpu_default.defs
+++ b/formatdef_files/gpu_default.defs
@@ -35,6 +35,7 @@ static void gpu_read_blkinit(struct hwblk *blk,int16_t **array)
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;
@@ -58,6 +59,7 @@ static void gpu_write_blkinit(struct hwblk *blk,int16_t **array)
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;
diff --git a/framebuffer_device.cpp b/framebuffer_device.cpp
index 31fc7b6..25f794f 100644
--- a/framebuffer_device.cpp
+++ b/framebuffer_device.cpp
@@ -255,9 +255,20 @@ int framebuffer_device_open(hw_module_t const* module, const char* name, hw_devi
write_sys_int(OSD_AFBCD, 0);
}
#if PLATFORM_SDK_VERSION > 22
- /*
- * later than lollipop
- * */
+ /* malloc is used instead of 'new' to instantiate the struct framebuffer_device_t
+ * C++11 spec specifies that if a class/struct has a const member,default constructor
+ * is deleted. So, if 'new' is used to instantiate the class/struct, it will throw
+ * error complaining about deleted constructor. Even if the struct is wrapped in a class
+ * it will still try to use the base class constructor to initialize the members, resulting
+ * in error 'deleted constructor'.
+ * This leaves two options
+ * Option 1: initialize the const members at the instantiation time. With {value1, value2 ..}
+ * Which relies on the order of the members, and if members are reordered or a new member is introduced
+ * it will end up assiging wrong value to members. Designated assignment as well has been removed in C++11
+ * Option 2: use malloc instead of 'new' to allocate the class/struct and initialize the members in code.
+ * This is the only maintainable option available.
+ */
+
framebuffer_t *fb = (framebuffer_t *)malloc(sizeof(framebuffer_t));//new framebuffer_t();
#else
/*Init the framebuffer data*/
diff --git a/gralloc_buffer_priv.h b/gralloc_buffer_priv.h
index c164dd8..516781c 100644
--- a/gralloc_buffer_priv.h
+++ b/gralloc_buffer_priv.h
@@ -27,10 +27,11 @@
struct attr_region
{
- int crop_bottom;
- int crop_left;
+ /* Rectangle to be cropped from the full frame (Origin in top-left corner!) */
int crop_top;
- int crop_right;
+ int crop_left;
+ int crop_height;
+ int crop_width;
int use_yuv_transform;
int use_sparse_alloc;
} __attribute__ ((packed));
@@ -39,13 +40,13 @@ typedef struct attr_region attr_region;
enum
{
- /* CROP and YUV_TRANS are intended to be
+ /* CROP_RECT and YUV_TRANS are intended to be
* written by producers and read by consumers.
- * Producers should write these parameters before
+ * A producer should write these parameters before
* it queues a buffer to the consumer.
*/
- /* CROP RECT, defined as a uint32_t array of bottom,left,top,right. */
+ /* CROP RECT, defined as an int array of top, left, height, width. Origin in top-left corner */
GRALLOC_ARM_BUFFER_ATTR_CROP_RECT = 1,
/* Set if the AFBC format used a YUV transform before compressing */
@@ -156,7 +157,7 @@ static inline int gralloc_buffer_attr_write( struct private_handle_t *hnd, buf_a
switch( attr )
{
case GRALLOC_ARM_BUFFER_ATTR_CROP_RECT:
- memcpy( &region->crop_bottom, val, sizeof(int)*4 );
+ memcpy( &region->crop_top, val, sizeof(int)*4 );
rval = 0;
break;
@@ -190,7 +191,7 @@ static inline int gralloc_buffer_attr_read( struct private_handle_t *hnd, buf_at
switch( attr )
{
case GRALLOC_ARM_BUFFER_ATTR_CROP_RECT:
- memcpy( val, &region->crop_bottom, sizeof(int)*4 );
+ memcpy( val, &region->crop_top, sizeof(int)*4 );
rval = 0;
break;
diff --git a/gralloc_module.cpp b/gralloc_module.cpp
index 144b59e..a27053b 100644
--- a/gralloc_module.cpp
+++ b/gralloc_module.cpp
@@ -364,6 +364,75 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module,
return 0;
}
+#if 0
+static int gralloc_lock_ycbcr(gralloc_module_t const* module, buffer_handle_t handle, int usage,
+ int l, int t, int w, int h,
+ android_ycbcr *ycbcr)
+{
+ if (private_handle_t::validate(handle) < 0)
+ {
+ AERR("Locking invalid buffer %p, returning error", handle );
+ return -EINVAL;
+ }
+
+ private_handle_t* hnd = (private_handle_t*)handle;
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP || hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
+ }
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ {
+ char* base = (char*)hnd->base;
+ int y_stride = hnd->byte_stride;
+ int y_size = y_stride * hnd->height;
+
+ int u_offset = 0;
+ int v_offset = 0;
+ int c_stride = 0;
+ int step = 0;
+
+ switch (hnd->internal_format & GRALLOC_ARM_INTFMT_FMT_MASK)
+ {
+ case HAL_PIXEL_FORMAT_YCbCr_420_888: /* Internally interpreted as NV12 */
+ c_stride = y_stride;
+ /* Y plane, UV plane */
+ u_offset = y_size;
+ v_offset = y_size + 1;
+ step = 2;
+ break;
+
+ case HAL_PIXEL_FORMAT_YV12:
+ case GRALLOC_ARM_HAL_FORMAT_INDEXED_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);
+ /* Y plane, V plane, U plane */
+ v_offset = y_size;
+ u_offset = y_size + c_size;
+ step = 1;
+ break;
+ }
+
+ default:
+ AERR("Can't lock buffer %p: wrong format %llx", hnd, hnd->internal_format);
+ return -EINVAL;
+ }
+
+ ycbcr->y = base;
+ ycbcr->cb = base + u_offset;
+ ycbcr->cr = base + v_offset;
+ ycbcr->ystride = y_stride;
+ ycbcr->cstride = c_stride;
+ ycbcr->chroma_step = step;
+ }
+ return 0;
+}
+#endif
+
static int gralloc_unlock(gralloc_module_t const* module, buffer_handle_t handle)
{
if (private_handle_t::validate(handle) < 0)
diff --git a/gralloc_module_ion.cpp b/gralloc_module_ion.cpp
index 67d65c3..9950ea2 100644
--- a/gralloc_module_ion.cpp
+++ b/gralloc_module_ion.cpp
@@ -125,8 +125,11 @@ void gralloc_backend_sync(private_handle_t* hnd)
private_module_t *m=NULL;
if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0)
{
- m = reinterpret_cast<private_module_t *>(pmodule);
- ion_sync_fd(m->ion_client, hnd->share_fd);
+ if(!(hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION_DMA_HEAP))
+ {
+ m = reinterpret_cast<private_module_t *>(pmodule);
+ ion_sync_fd(m->ion_client, hnd->share_fd);
+ }
}
else
{
diff --git a/gralloc_priv.h b/gralloc_priv.h
index d39dc90..0908809 100644
--- a/gralloc_priv.h
+++ b/gralloc_priv.h
@@ -103,6 +103,9 @@ struct fb_dmabuf_export
#include <ump/ump.h>
#endif
+#define SZ_4K 0x00001000
+#define SZ_2M 0x00200000
+
typedef enum
{
MALI_YUV_NO_INFO,
@@ -179,6 +182,7 @@ struct private_handle_t
PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
PRIV_FLAGS_USES_UMP = 0x00000002,
PRIV_FLAGS_USES_ION = 0x00000004,
+ PRIV_FLAGS_USES_ION_DMA_HEAP = 0x00000008,
PRIV_FLAGS_VIDEO_OVERLAY = 0x00000010,
PRIV_FLAGS_VIDEO_OMX = 0x00000020,
PRIV_FLAGS_CURSOR = 0x00000040,
@@ -257,7 +261,13 @@ struct private_handle_t
uint64_t padding_1;
uint64_t padding_2;
uint64_t padding_3;
- uint64_t padding_4;
+ int padding_4;
+ /*
+ * min_pgsz denotes minimum phys_page size used by this buffer.
+ * if buffer memory is physical contiguous set min_pgsz to buff->size
+ * if not sure buff's real phys_page size, you can use SZ_4K for safe.
+ */
+ int min_pgsz;
#ifdef __cplusplus
/*