qcom/display: Update HALs
- Update the display HAL from Code Aurora Forum
- Add updated overlay library
- Enable HWC with basic video going through overlay
- Cleanup some files
Change-Id: I65c687c51be458cee71213c79e03eeda962d9086
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 47cdc68..1356b2f 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -34,24 +34,26 @@
#include "alloc_controller.h"
#include "memalloc.h"
#include "ionalloc.h"
+#include "pmemalloc.h"
#include "ashmemalloc.h"
#include "gr.h"
+#include "qcomutils/comptype.h"
using namespace gralloc;
using android::sp;
-const int GRALLOC_HEAP_MASK = GRALLOC_USAGE_PRIVATE_ADSP_HEAP |
- GRALLOC_USAGE_PRIVATE_UI_CONTIG_HEAP |
- GRALLOC_USAGE_PRIVATE_SMI_HEAP |
- GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP |
- GRALLOC_USAGE_PRIVATE_IOMMU_HEAP |
- GRALLOC_USAGE_PRIVATE_MM_HEAP |
- GRALLOC_USAGE_PRIVATE_WRITEBACK_HEAP |
- GRALLOC_USAGE_PRIVATE_CAMERA_HEAP;
+const int GRALLOC_HEAP_MASK = GRALLOC_USAGE_PRIVATE_ADSP_HEAP |
+ GRALLOC_USAGE_PRIVATE_UI_CONTIG_HEAP |
+ GRALLOC_USAGE_PRIVATE_SMI_HEAP |
+ GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP |
+ GRALLOC_USAGE_PRIVATE_IOMMU_HEAP |
+ GRALLOC_USAGE_PRIVATE_MM_HEAP |
+ GRALLOC_USAGE_PRIVATE_WRITEBACK_HEAP |
+ GRALLOC_USAGE_PRIVATE_CAMERA_HEAP;
//Common functions
-static bool canFallback(int compositionType, int usage, bool triedSystem)
+static bool canFallback(int usage, bool triedSystem)
{
// Fallback to system heap when alloc fails unless
// 1. Composition type is MDP
@@ -60,11 +62,12 @@
// 4. The heap type is protected
// 5. The buffer is meant for external display only
- if(compositionType == MDP_COMPOSITION)
+ if(QCCompositionType::getInstance().getCompositionType() & COMPOSITION_TYPE_MDP)
return false;
if(triedSystem)
return false;
- if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_PROTECTED))
+ if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_PROTECTED |
+ GRALLOC_USAGE_PRIVATE_CP_BUFFER))
return false;
if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_EXTERNAL_ONLY))
return false;
@@ -107,13 +110,15 @@
}
int IonController::allocate(alloc_data& data, int usage,
- int compositionType)
+ int compositionType)
{
int ionFlags = 0;
int ret;
bool noncontig = false;
data.uncached = useUncached(usage);
+ data.allocType = 0;
+
if(usage & GRALLOC_USAGE_PRIVATE_UI_CONTIG_HEAP)
ionFlags |= ION_HEAP(ION_SF_HEAP_ID);
@@ -134,11 +139,13 @@
if(usage & GRALLOC_USAGE_PRIVATE_CAMERA_HEAP)
ionFlags |= ION_HEAP(ION_CAMERA_HEAP_ID);
- if(usage & GRALLOC_USAGE_PROTECTED)
+ if(usage & GRALLOC_USAGE_PRIVATE_CP_BUFFER)
ionFlags |= ION_SECURE;
if(usage & GRALLOC_USAGE_PRIVATE_DO_NOT_MAP)
- data.allocType = private_handle_t::PRIV_FLAGS_NOT_MAPPED;
+ data.allocType |= private_handle_t::PRIV_FLAGS_NOT_MAPPED;
+ else
+ data.allocType &= ~(private_handle_t::PRIV_FLAGS_NOT_MAPPED);
// if no flags are set, default to
// SF + IOMMU heaps, so that bypass can work
@@ -149,9 +156,9 @@
data.flags = ionFlags;
ret = mIonAlloc->alloc_buffer(data);
+
// Fallback
- if(ret < 0 && canFallback(compositionType,
- usage,
+ if(ret < 0 && canFallback(usage,
(ionFlags & ION_SYSTEM_HEAP_ID)))
{
ALOGW("Falling back to system heap");
@@ -161,7 +168,7 @@
}
if(ret >= 0 ) {
- data.allocType = private_handle_t::PRIV_FLAGS_USES_ION;
+ data.allocType |= private_handle_t::PRIV_FLAGS_USES_ION;
if(noncontig)
data.allocType |= private_handle_t::PRIV_FLAGS_NONCONTIGUOUS_MEM;
if(ionFlags & ION_SECURE)
@@ -183,14 +190,14 @@
return memalloc;
}
-#if 0
//-------------- PmemKernelController-----------------------//
-
+//XXX: Remove - we're not using pmem anymore
+#if 0
PmemKernelController::PmemKernelController()
{
- mPmemAdspAlloc = new PmemKernelAlloc(DEVICE_PMEM_ADSP);
- // XXX: Right now, there is no need to maintain an instance
- // of the SMI allocator as we need it only in a few cases
+ mPmemAdspAlloc = new PmemKernelAlloc(DEVICE_PMEM_ADSP);
+ // XXX: Right now, there is no need to maintain an instance
+ // of the SMI allocator as we need it only in a few cases
}
PmemKernelController::~PmemKernelController()
@@ -198,7 +205,7 @@
}
int PmemKernelController::allocate(alloc_data& data, int usage,
- int compositionType)
+ int compositionType)
{
int ret = 0;
bool adspFallback = false;
@@ -258,12 +265,13 @@
}
int PmemAshmemController::allocate(alloc_data& data, int usage,
- int compositionType)
+ int compositionType)
{
int ret = 0;
+ data.allocType = 0;
// Make buffers cacheable by default
- data.uncached = false;
+ data.uncached = false;
// Override if we explicitly need uncached buffers
if (usage & GRALLOC_USAGE_PRIVATE_UNCACHED)
@@ -298,7 +306,7 @@
// Fallback
if(ret >= 0 ) {
data.allocType = private_handle_t::PRIV_FLAGS_USES_PMEM;
- } else if(ret < 0 && canFallback(compositionType, usage, false)) {
+ } else if(ret < 0 && canFallback(usage, false)) {
ALOGW("Falling back to ashmem");
ret = mAshmemAlloc->alloc_buffer(data);
if(ret >= 0) {
@@ -327,9 +335,8 @@
return memalloc;
}
#endif
-
size_t getBufferSizeAndDimensions(int width, int height, int format,
- int& alignedw, int &alignedh)
+ int& alignedw, int &alignedh)
{
size_t size;
@@ -376,16 +383,25 @@
if (HAL_PIXEL_FORMAT_NV12_ENCODEABLE == format) {
// The encoder requires a 2K aligned chroma offset.
size = ALIGN(alignedw*alignedh, 2048) +
- (ALIGN(alignedw/2, 16) * (alignedh/2))*2;
+ (ALIGN(alignedw/2, 16) * (alignedh/2))*2;
} else {
size = alignedw*alignedh +
(ALIGN(alignedw/2, 16) * (alignedh/2))*2;
}
size = ALIGN(size, 4096);
break;
-
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ if(width & 1) {
+ ALOGE("width is odd for the YUV422_SP format");
+ return -EINVAL;
+ }
+ alignedw = ALIGN(width, 16);
+ alignedh = height;
+ size = ALIGN(alignedw * alignedh * 2, 4096);
+ break;
default:
- ALOGE("unrecognized pixel format: %d", format);
+ ALOGE("unrecognized pixel format: 0x%x", format);
return -EINVAL;
}
@@ -397,31 +413,31 @@
// to free the buffer using the free_buffer function
int alloc_buffer(private_handle_t **pHnd, int w, int h, int format, int usage)
{
- alloc_data data;
- int alignedw, alignedh;
- android::sp<gralloc::IAllocController> sAlloc =
- gralloc::IAllocController::getInstance(false);
- data.base = 0;
- data.fd = -1;
- data.offset = 0;
- data.size = getBufferSizeAndDimensions(w, h, format, alignedw, alignedh);
- data.align = getpagesize();
- data.uncached = useUncached(usage);
- int allocFlags = usage;
+ alloc_data data;
+ int alignedw, alignedh;
+ android::sp<gralloc::IAllocController> sAlloc =
+ gralloc::IAllocController::getInstance(false);
+ data.base = 0;
+ data.fd = -1;
+ data.offset = 0;
+ data.size = getBufferSizeAndDimensions(w, h, format, alignedw, alignedh);
+ data.align = getpagesize();
+ data.uncached = useUncached(usage);
+ int allocFlags = usage;
- int err = sAlloc->allocate(data, allocFlags, 0);
- if (0 != err) {
- ALOGE("%s: allocate failed", __FUNCTION__);
- return -ENOMEM;
- }
+ int err = sAlloc->allocate(data, allocFlags, 0);
+ if (0 != err) {
+ ALOGE("%s: allocate failed", __FUNCTION__);
+ return -ENOMEM;
+ }
- private_handle_t* hnd = new private_handle_t(data.fd, data.size,
- data.allocType, 0, format, alignedw, alignedh);
- hnd->base = (int) data.base;
- hnd->offset = data.offset;
- hnd->gpuaddr = 0;
- *pHnd = hnd;
- return 0;
+ private_handle_t* hnd = new private_handle_t(data.fd, data.size,
+ data.allocType, 0, format, alignedw, alignedh);
+ hnd->base = (int) data.base;
+ hnd->offset = data.offset;
+ hnd->gpuaddr = 0;
+ *pHnd = hnd;
+ return 0;
}
void free_buffer(private_handle_t *hnd)