summaryrefslogtreecommitdiffstats
path: root/modules/gralloc/gralloc.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-07-16 18:04:54 -0700
committerMathias Agopian <mathias@google.com>2009-07-16 18:06:19 -0700
commit3e1f89bcca78fb5175043c76ff5a9310fae91829 (patch)
treef3648385835929a3b6181df6b4397f60f411a4ba /modules/gralloc/gralloc.cpp
parent6d125da5d28369df62dc5c186b43fcd40a3d33e8 (diff)
downloadhardware_libhardware-3e1f89bcca78fb5175043c76ff5a9310fae91829.zip
hardware_libhardware-3e1f89bcca78fb5175043c76ff5a9310fae91829.tar.gz
hardware_libhardware-3e1f89bcca78fb5175043c76ff5a9310fae91829.tar.bz2
fix [1980202] Surfaceflinger crash with transparent rollo on firestone
we now automatically size the pmem region isntead of using hardcoded values
Diffstat (limited to 'modules/gralloc/gralloc.cpp')
-rw-r--r--modules/gralloc/gralloc.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp
index 8c496dc..9928a75 100644
--- a/modules/gralloc/gralloc.cpp
+++ b/modules/gralloc/gralloc.cpp
@@ -43,6 +43,10 @@
/*****************************************************************************/
+static SimpleBestFitAllocator sAllocator;
+
+/*****************************************************************************/
+
struct gralloc_context_t {
alloc_device_t device;
/* our private data here */
@@ -172,14 +176,23 @@ static int gralloc_alloc_framebuffer(alloc_device_t* dev,
return err;
}
-static SimpleBestFitAllocator sAllocator(8*1024*1024);
-
static int init_pmem_area_locked(private_module_t* m)
{
int err = 0;
int master_fd = open("/dev/pmem", O_RDWR, 0);
if (master_fd >= 0) {
- void* base = mmap(0, sAllocator.size(),
+
+ size_t size;
+ pmem_region region;
+ if (ioctl(master_fd, PMEM_GET_TOTAL_SIZE, &region) < 0) {
+ LOGE("PMEM_GET_TOTAL_SIZE failed, limp mode");
+ size = 8<<20; // 8 MiB
+ } else {
+ size = region.len;
+ }
+ sAllocator.setSize(size);
+
+ void* base = mmap(0, size,
PROT_READ|PROT_WRITE, MAP_SHARED, master_fd, 0);
if (base == MAP_FAILED) {
err = -errno;