From 8864a8d0754783bce91ef3635d0fd9cd140c9944 Mon Sep 17 00:00:00 2001 From: Naseer Ahmed Date: Fri, 28 Jan 2011 18:59:05 +0530 Subject: [PATCH] gralloc: Fix compilation issue with ashmem on 7x27 Change-Id: I02fcbd7bdefd83be4a55a79ccd82c0df4b74f7ae --- libgralloc-qsd8k/gralloc.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libgralloc-qsd8k/gralloc.cpp b/libgralloc-qsd8k/gralloc.cpp index 16f026e..ab574a7 100755 --- a/libgralloc-qsd8k/gralloc.cpp +++ b/libgralloc-qsd8k/gralloc.cpp @@ -64,6 +64,8 @@ extern int gralloc_perform(struct gralloc_module_t const* module, class PmemAllocatorDepsDeviceImpl : public PmemUserspaceAllocator::Deps, public PmemKernelAllocator::Deps { + const private_module_t* module; + virtual size_t getPmemTotalSize(int fd, size_t* size) { int err = 0; #ifndef TARGET_MSM7x27 @@ -74,7 +76,10 @@ class PmemAllocatorDepsDeviceImpl : public PmemUserspaceAllocator::Deps, } #else #ifdef USE_ASHMEM - *size = m->info.xres * m->info.yres * 2 * 2; + if(module != NULL) + *size = module->info.xres * module->info.yres * 2 * 2; + else + return -ENOMEM; #else *size = 23<<20; //23MB for 7x27 #endif @@ -123,6 +128,12 @@ class PmemAllocatorDepsDeviceImpl : public PmemUserspaceAllocator::Deps, virtual int close(int fd) { return ::close(fd); } + +public: + void setModule(const private_module_t* m) { + module = m; + } + }; class GpuContextDepsDeviceImpl : public gpu_context_t::Deps { @@ -199,6 +210,7 @@ int gralloc_device_open(const hw_module_t* module, const char* name, if (!strcmp(name, GRALLOC_HARDWARE_GPU0)) { const private_module_t* m = reinterpret_cast( module); + pmemAllocatorDeviceDepsImpl.setModule(m); gpu_context_t *dev; dev = new gpu_context_t(gpuContextDeviceDepsImpl, pmemAllocator, pmemAdspAllocator, m);