gralloc: Use dedicated heaps for sensors direct report mode
Use systemheap for SMMU enabled targets and use adspheap
for non SMMU enabled targets for fastrpc communication.
Change-Id: Ib13cf669377d489b1da7b00f29a49567d75db7fa
diff --git a/gralloc/gr_allocator.cpp b/gralloc/gr_allocator.cpp
index d0f2e86..4c16b62 100644
--- a/gralloc/gr_allocator.cpp
+++ b/gralloc/gr_allocator.cpp
@@ -28,6 +28,7 @@
*/
#include <log/log.h>
+#include <cutils/properties.h>
#include <algorithm>
#include <vector>
@@ -83,6 +84,12 @@
bool Allocator::Init() {
ion_allocator_ = new IonAlloc();
+ char property[PROPERTY_VALUE_MAX];
+ property_get(USE_SYSTEM_HEAP_FOR_SENSORS, property, "1");
+ if (!(strncmp(property, "0", PROPERTY_VALUE_MAX))) {
+ use_system_heap_for_sensors_ = false;
+ }
+
if (!ion_allocator_->Init()) {
return false;
}
@@ -211,7 +218,13 @@
}
if (usage & BufferUsage::SENSOR_DIRECT_DATA) {
- heap_id |= ION_HEAP(ION_ADSP_HEAP_ID);
+ if (use_system_heap_for_sensors_) {
+ ALOGI("gralloc::sns_direct_data with system_heap");
+ heap_id |= ION_HEAP(ION_SYSTEM_HEAP_ID);
+ } else {
+ ALOGI("gralloc::sns_direct_data with adsp_heap");
+ heap_id |= ION_HEAP(ION_ADSP_HEAP_ID);
+ }
}
if (flags & UINT(ION_SECURE)) {
diff --git a/gralloc/gr_allocator.h b/gralloc/gr_allocator.h
index 36732c6..630151a 100644
--- a/gralloc/gr_allocator.h
+++ b/gralloc/gr_allocator.h
@@ -58,6 +58,8 @@
unsigned int *ion_flags);
IonAlloc *ion_allocator_ = NULL;
+
+ bool use_system_heap_for_sensors_ = true;
};
} // namespace gralloc
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index 8f8c0c4..2043824 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -30,6 +30,7 @@
#define DISABLE_UBWC_PROP GRALLOC_PROP("disable_ubwc")
#define ENABLE_FB_UBWC_PROP GRALLOC_PROP("enable_fb_ubwc")
#define MAP_FB_MEMORY_PROP GRALLOC_PROP("map_fb_memory")
+#define USE_SYSTEM_HEAP_FOR_SENSORS GRALLOC_PROP("use_system_heap_for_sensors")
#define ROUND_UP_PAGESIZE(x) roundUpToPageSize(x)
inline int roundUpToPageSize(int x) {