gralloc: Do not map framebuffer memory unless needed
The SurfaceFlinger opens the framebuffer module even when it
isn't necessary. It does this for some legacy hals.
Due to this we unnecessarily mmap the fb memory in gralloc.
Do not map this unless the property to use the framebuffer
memory is set.
Change-Id: Ib4ebfdf9a63af0dabb53170342181bac0360baeb
diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp
index 3828680..1851196 100644
--- a/libgralloc/framebuffer.cpp
+++ b/libgralloc/framebuffer.cpp
@@ -336,9 +336,15 @@
static int mapFrameBuffer(struct private_module_t* module)
{
- pthread_mutex_lock(&module->lock);
- int err = mapFrameBufferLocked(module);
- pthread_mutex_unlock(&module->lock);
+ int err = 0;
+ char property[PROPERTY_VALUE_MAX];
+ if((property_get("debug.gralloc.map_fb_memory", property, NULL) > 0) &&
+ (!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
+ (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
+ pthread_mutex_lock(&module->lock);
+ err = mapFrameBufferLocked(module);
+ pthread_mutex_unlock(&module->lock);
+ }
return err;
}