libgralloc-qsd8k: Dynamic ASHMEM
When USE_ASHMEM is set, ASHMEM will be used only for non-MDP composition. This implementation will force to use PMEM for MDP composition case. This will allow using ASHMEM or PMEM at run time, depending on the composition type. USE_ASHMEM would mean that use ASHMEM where possible. This will also make sure that video works properly when dynamic ASHMEM feature is enabled on 7x27 / 7x27a / 7x25a targets. Change-Id: I5860311aad20d33e2d078cd6f0d05e041ff3364a
This commit is contained in:
committed by
Linux Build Service Account
parent
16722a86d7
commit
950ab4c045
16
gpu.cpp
16
gpu.cpp
@ -17,6 +17,7 @@
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
@ -27,7 +28,8 @@ gpu_context_t::gpu_context_t(Deps& deps, PmemAllocator& pmemAllocator,
|
||||
PmemAllocator& pmemAdspAllocator, const private_module_t* module) :
|
||||
deps(deps),
|
||||
pmemAllocator(pmemAllocator),
|
||||
pmemAdspAllocator(pmemAdspAllocator)
|
||||
pmemAdspAllocator(pmemAdspAllocator),
|
||||
isMDPComposition(false)
|
||||
{
|
||||
// Zero out the alloc_device_t
|
||||
memset(static_cast<alloc_device_t*>(this), 0, sizeof(alloc_device_t));
|
||||
@ -39,6 +41,11 @@ gpu_context_t::gpu_context_t(Deps& deps, PmemAllocator& pmemAllocator,
|
||||
common.close = gralloc_close;
|
||||
alloc = gralloc_alloc;
|
||||
free = gralloc_free;
|
||||
|
||||
char property[PROPERTY_VALUE_MAX];
|
||||
if((property_get("debug.composition.type", property, NULL) > 0) &&
|
||||
(strncmp(property, "mdp", 3) == 0))
|
||||
isMDPComposition = true;
|
||||
}
|
||||
|
||||
int gpu_context_t::gralloc_alloc_framebuffer_locked(size_t size, int usage,
|
||||
@ -177,6 +184,13 @@ int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage, buffer_handle_t*
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_PMEM){
|
||||
flags |= private_handle_t::PRIV_FLAGS_USES_PMEM;
|
||||
}
|
||||
|
||||
// Enable use of PMEM only when MDP composition is used (and other conditions apply).
|
||||
// Else fall back on using ASHMEM
|
||||
if (isMDPComposition &&
|
||||
((usage & GRALLOC_USAGE_HW_TEXTURE) || (usage & GRALLOC_USAGE_HW_2D)) ) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_USES_PMEM;
|
||||
}
|
||||
#endif
|
||||
if (usage & GRALLOC_USAGE_PRIVATE_PMEM_ADSP) {
|
||||
flags |= private_handle_t::PRIV_FLAGS_USES_PMEM_ADSP;
|
||||
|
1
gpu.h
1
gpu.h
@ -71,6 +71,7 @@ class gpu_context_t : public alloc_device_t {
|
||||
Deps& deps;
|
||||
PmemAllocator& pmemAllocator;
|
||||
PmemAllocator& pmemAdspAllocator;
|
||||
bool isMDPComposition;
|
||||
int alloc_ashmem_buffer(size_t size, unsigned int postfix, void** pBase,
|
||||
int* pOffset, int* pFd);
|
||||
};
|
||||
|
19
gralloc.cpp
19
gralloc.cpp
@ -21,6 +21,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#include <linux/android_pmem.h>
|
||||
|
||||
@ -76,10 +77,20 @@ class PmemAllocatorDepsDeviceImpl : public PmemUserspaceAllocator::Deps,
|
||||
}
|
||||
#else
|
||||
#ifdef USE_ASHMEM
|
||||
if(module != NULL)
|
||||
*size = module->info.xres * module->info.yres * 2 * 2;
|
||||
else
|
||||
return -ENOMEM;
|
||||
char property[PROPERTY_VALUE_MAX];
|
||||
bool isMDPComposition = false;
|
||||
if((property_get("debug.composition.type", property, NULL) > 0) &&
|
||||
(strncmp(property, "mdp", 3) == 0))
|
||||
isMDPComposition = true;
|
||||
|
||||
if (isMDPComposition) {
|
||||
*size = 23<<20; //23MB for 7x27
|
||||
} else {
|
||||
if(module != NULL)
|
||||
*size = module->info.xres * module->info.yres * 2 * 2;
|
||||
else
|
||||
return -ENOMEM;
|
||||
}
|
||||
#else
|
||||
*size = 23<<20; //23MB for 7x27
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user