From 3ae7f5272625cad07f98d1a92aa67d7d054e927f Mon Sep 17 00:00:00 2001 From: Naomi Luis Date: Tue, 28 Jun 2011 13:35:14 -0700 Subject: [PATCH] libgralloc-qsd8k: Support for additional gralloc usage flags. Add support for the GRALLOC_USAGE_EXTERNAL_DISP and the GRALLOC_USAGE_PROTECTED usage bits. If any of the two usage bits are set, we need to send the buffers to the overlay. Since we send the buffers to the overlay, we need to allocate these buffers from the PMEM region. (cherry picked from commit 195345cd63f0e19cfee4cf055587d5fffe76d0ef) Change-Id: I64116b9be07c8ddadbd5a132ef21b19e5326737b --- libgralloc-qsd8k/gpu.cpp | 9 ++++++++- libgralloc-qsd8k/pmemalloc.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libgralloc-qsd8k/gpu.cpp b/libgralloc-qsd8k/gpu.cpp index a4234ab..d0d4fa4 100755 --- a/libgralloc-qsd8k/gpu.cpp +++ b/libgralloc-qsd8k/gpu.cpp @@ -182,7 +182,8 @@ int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage, buffer_handle_t* flags |= private_handle_t::PRIV_FLAGS_USES_PMEM; } #endif - if ((usage & GRALLOC_USAGE_PRIVATE_PMEM_ADSP) || (usage & GRALLOC_USAGE_PRIVATE_PMEM_SMIPOOL)) { + if ((usage & GRALLOC_USAGE_PRIVATE_PMEM_ADSP) || (usage & GRALLOC_USAGE_PRIVATE_PMEM_SMIPOOL) + || (usage & GRALLOC_USAGE_EXTERNAL_DISP) || (usage & GRALLOC_USAGE_PROTECTED)) { flags |= private_handle_t::PRIV_FLAGS_USES_PMEM_ADSP; flags &= ~private_handle_t::PRIV_FLAGS_USES_PMEM; } @@ -341,6 +342,12 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage, size = (bufferSize >= size)? bufferSize : size; + // All buffers marked as protected or for external + // display need to go to overlay + if ((usage & GRALLOC_USAGE_EXTERNAL_DISP) || + (usage & GRALLOC_USAGE_PROTECTED)) { + bufferType = BUFFER_TYPE_VIDEO; + } int err; if (usage & GRALLOC_USAGE_HW_FB) { err = gralloc_alloc_framebuffer(size, usage, pHandle); diff --git a/libgralloc-qsd8k/pmemalloc.cpp b/libgralloc-qsd8k/pmemalloc.cpp index 126004d..fa5fc4b 100755 --- a/libgralloc-qsd8k/pmemalloc.cpp +++ b/libgralloc-qsd8k/pmemalloc.cpp @@ -277,6 +277,15 @@ int PmemKernelAllocator::alloc_pmem_buffer(size_t size, int usage, device = DEVICE_PMEM_ADSP; } else if (usage & GRALLOC_USAGE_PRIVATE_PMEM_SMIPOOL) { device = DEVICE_PMEM_SMIPOOL; + } else if ((usage & GRALLOC_USAGE_EXTERNAL_DISP) || + (usage & GRALLOC_USAGE_PROTECTED)) { + int tempFd = deps.open(DEVICE_PMEM_SMIPOOL, openFlags, 0); + if (tempFd < 0) { + device = DEVICE_PMEM_ADSP; + } else { + close(tempFd); + device = DEVICE_PMEM_SMIPOOL; + } } else { LOGE("Invalid device"); return -EINVAL;