Merge change 7784
* changes:
Remove redundant defines, these were only necessary while changes were being staged to another repo
diff --git a/hardware.c b/hardware.c
index 786e142..dff5ac3 100644
--- a/hardware.c
+++ b/hardware.c
@@ -68,8 +68,6 @@
/* Construct the path. */
snprintf(path, sizeof(path), "%s/%s.%s.so", HAL_LIBRARY_PATH, id, variant);
- LOGV("load: E id=%s path=%s", id, path);
-
/*
* load the symbols resolving undefined symbols before
* dlopen returns. Since RTLD_GLOBAL is not or'd in with
@@ -112,12 +110,13 @@
dlclose(handle);
handle = NULL;
}
+ } else {
+ LOGV("loaded HAL id=%s path=%s hmi=%p handle=%p",
+ id, path, *pHmi, handle);
}
*pHmi = hmi;
- LOGV("load: X id=%s path=%s hmi=%p handle=%p status=%d",
- id, path, *pHmi, handle, status);
return status;
}
@@ -135,8 +134,6 @@
* We also assume that dlopen() is thread-safe.
*/
- LOGV("hal_module_info_get: Load module id=%s", id);
-
status = -EINVAL;
/* Loop through the configuration variants looking for a module */
@@ -153,7 +150,5 @@
}
*module = hmi;
- LOGV("hal_module_info_get: X id=%s hmi=%p status=%d", id, hmi, status);
-
return status;
}
diff --git a/modules/gralloc/allocator.cpp b/modules/gralloc/allocator.cpp
index f901741..4dad6a1 100644
--- a/modules/gralloc/allocator.cpp
+++ b/modules/gralloc/allocator.cpp
@@ -22,13 +22,15 @@
// align all the memory blocks on a cache-line boundary
const int SimpleBestFitAllocator::kMemoryAlign = 32;
-SimpleBestFitAllocator::SimpleBestFitAllocator(size_t size)
+SimpleBestFitAllocator::SimpleBestFitAllocator()
+ : mHeapSize(0)
{
- size_t pagesize = getpagesize();
- mHeapSize = ((size + pagesize-1) & ~(pagesize-1));
+}
- chunk_t* node = new chunk_t(0, mHeapSize / kMemoryAlign);
- mList.insertHead(node);
+SimpleBestFitAllocator::SimpleBestFitAllocator(size_t size)
+ : mHeapSize(0)
+{
+ setSize(size);
}
SimpleBestFitAllocator::~SimpleBestFitAllocator()
@@ -38,14 +40,27 @@
}
}
+ssize_t SimpleBestFitAllocator::setSize(size_t size)
+{
+ Locker::Autolock _l(mLock);
+ if (mHeapSize != 0) return -EINVAL;
+ size_t pagesize = getpagesize();
+ mHeapSize = ((size + pagesize-1) & ~(pagesize-1));
+ chunk_t* node = new chunk_t(0, mHeapSize / kMemoryAlign);
+ mList.insertHead(node);
+ return size;
+}
+
+
size_t SimpleBestFitAllocator::size() const
{
return mHeapSize;
}
-size_t SimpleBestFitAllocator::allocate(size_t size, uint32_t flags)
+ssize_t SimpleBestFitAllocator::allocate(size_t size, uint32_t flags)
{
Locker::Autolock _l(mLock);
+ if (mHeapSize == 0) return -EINVAL;
ssize_t offset = alloc(size, flags);
return offset;
}
@@ -53,6 +68,7 @@
ssize_t SimpleBestFitAllocator::deallocate(size_t offset)
{
Locker::Autolock _l(mLock);
+ if (mHeapSize == 0) return -EINVAL;
chunk_t const * const freed = dealloc(offset);
if (freed) {
return 0;
diff --git a/modules/gralloc/allocator.h b/modules/gralloc/allocator.h
index dfb06f6..6823982 100644
--- a/modules/gralloc/allocator.h
+++ b/modules/gralloc/allocator.h
@@ -95,12 +95,15 @@
{
public:
- SimpleBestFitAllocator(size_t size);
- virtual ~SimpleBestFitAllocator();
+ SimpleBestFitAllocator();
+ SimpleBestFitAllocator(size_t size);
+ ~SimpleBestFitAllocator();
- virtual size_t allocate(size_t size, uint32_t flags = 0);
- virtual ssize_t deallocate(size_t offset);
- virtual size_t size() const;
+ ssize_t setSize(size_t size);
+
+ ssize_t allocate(size_t size, uint32_t flags = 0);
+ ssize_t deallocate(size_t offset);
+ size_t size() const;
private:
struct chunk_t {
@@ -123,5 +126,4 @@
size_t mHeapSize;
};
-
#endif /* GRALLOC_ALLOCATOR_H_ */
diff --git a/modules/gralloc/framebuffer.cpp b/modules/gralloc/framebuffer.cpp
index 0aaa9da..5f97032 100644
--- a/modules/gralloc/framebuffer.cpp
+++ b/modules/gralloc/framebuffer.cpp
@@ -41,9 +41,6 @@
/*****************************************************************************/
-// should be a build option
-#define SUPPORTS_UPDATE_ON_DEMAND 1
-
// numbers of buffers for page flipping
#define NUM_BUFFERS 2
@@ -334,7 +331,6 @@
{
int status = -EINVAL;
if (!strcmp(name, GRALLOC_HARDWARE_FB0)) {
-
alloc_device_t* gralloc_device;
status = gralloc_open(module, &gralloc_device);
if (status < 0)
@@ -367,15 +363,6 @@
const_cast<float&>(dev->device.fps) = m->fps;
const_cast<int&>(dev->device.minSwapInterval) = 1;
const_cast<int&>(dev->device.maxSwapInterval) = 1;
-
-#if SUPPORTS_UPDATE_ON_DEMAND
- if (m->finfo.reserved[0] == 0x5444 &&
- m->finfo.reserved[1] == 0x5055) {
- dev->device.setUpdateRect = fb_setUpdateRect;
- LOGD("UPDATE_ON_DEMAND supported");
- }
-#endif
-
*device = &dev->device.common;
}
}
diff --git a/modules/gralloc/gralloc.cpp b/modules/gralloc/gralloc.cpp
index 8c496dc..4eb9317 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,24 @@
return err;
}
-static SimpleBestFitAllocator sAllocator(8*1024*1024);
-
static int init_pmem_area_locked(private_module_t* m)
{
int err = 0;
+#if HAVE_ANDROID_OS // should probably define HAVE_PMEM somewhere
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, ®ion) < 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;
@@ -193,6 +207,9 @@
err = -errno;
}
return err;
+#else
+ return -1;
+#endif
}
static int init_pmem_area(private_module_t* m)