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)) {