diff options
author | Mathias Agopian <mathias@google.com> | 2009-06-19 16:14:09 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-06-19 16:14:09 -0700 |
commit | 31802ca9c030b8f9a137f32826e9c9a76d0d6e17 (patch) | |
tree | de678e4a60f21be17e9c86434ca8079fb1bc6d67 /modules/gralloc/gralloc.cpp | |
parent | ed93e8b392e66e2a822f8b30ee7cefecd1036472 (diff) | |
download | hardware_libhardware-31802ca9c030b8f9a137f32826e9c9a76d0d6e17.zip hardware_libhardware-31802ca9c030b8f9a137f32826e9c9a76d0d6e17.tar.gz hardware_libhardware-31802ca9c030b8f9a137f32826e9c9a76d0d6e17.tar.bz2 |
fallback to ashmem when pmem is not availlable
Diffstat (limited to 'modules/gralloc/gralloc.cpp')
-rw-r--r-- | modules/gralloc/gralloc.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp index 2cf6e02..ccfe40b 100644 --- a/modules/gralloc/gralloc.cpp +++ b/modules/gralloc/gralloc.cpp @@ -217,17 +217,23 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, } if ((flags & private_handle_t::PRIV_FLAGS_USES_PMEM) == 0) { +try_ashmem: fd = ashmem_create_region("Buffer", size); if (fd < 0) { + LOGE("couldn't create ashmem (%s)", strerror(-errno)); err = -errno; } } else { private_module_t* m = reinterpret_cast<private_module_t*>( dev->common.module); - + pthread_mutex_lock(&m->lock); - if (m->pmem_master == -1) + if (m->pmem_master == -1) { err = init_pmem_area(m); + if (err) { + m->pmem_master = err; + } + } pthread_mutex_unlock(&m->lock); if (m->pmem_master >= 0) { @@ -254,6 +260,15 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, } //LOGD_IF(!err, "allocating pmem size=%d, offset=%d", size, offset); } + } else { + if ((usage & GRALLOC_USAGE_HW_2D) == 0) { + // the caller didn't request PMEM, so we can try something else + flags &= ~private_handle_t::PRIV_FLAGS_USES_PMEM; + err = 0; + goto try_ashmem; + } else { + LOGE("couldn't open pmem (%s)", strerror(-errno)); + } } } |