summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2017-12-05 16:15:11 -0800
committerJohn Stultz <john.stultz@linaro.org>2018-07-11 15:59:35 -0700
commitf3d868dcbd74d43b754bf168fd5f63bf4c8c4385 (patch)
tree63c62f934ab81bf07d60bb1ec5d7df9913f96ac4
parent30941517aac192a55dc358479e27dc6a6b3bc04e (diff)
downloadhikey-f3d868dcbd74d43b754bf168fd5f63bf4c8c4385.tar.gz
hikey: gralloc: Allow use of CMA heap instead of fbdev
This allows the hikey gralloc to use the ion CMA heap instead of the fbdev device. This is needed to move to the drm_hwcomposer with FBDEV_EMULATION disabled. This enables support for both legacy kernels using older ion interface and 4.12+ and newer kernels with the newer ion interface. Change-Id: I87d86d7d4f21a40e5c64c2473aea5bb4c5947de0 Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r--gralloc/Android.mk7
-rw-r--r--gralloc/alloc_device.cpp35
-rw-r--r--gralloc/gralloc_priv.h1
3 files changed, 32 insertions, 11 deletions
diff --git a/gralloc/Android.mk b/gralloc/Android.mk
index 8c418425..23a5a820 100644
--- a/gralloc/Android.mk
+++ b/gralloc/Android.mk
@@ -29,6 +29,7 @@ LOCAL_VENDOR_MODULE := true
MALI_DDK_TEST_PATH := hardware/arm/
LOCAL_MODULE := gralloc.hikey
+LOCAL_MODULE_RELATIVE_PATH := hw
#LOCAL_MODULE_TAGS := optional
# Mali-200/300/400MP DDK
@@ -49,4 +50,10 @@ LOCAL_SRC_FILES := \
framebuffer_device.cpp
#LOCAL_CFLAGS+= -DMALI_VSYNC_EVENT_REPORT_ENABLE
+
+
+ifeq ($(HIKEY_USE_DRM_HWCOMPOSER), true)
+LOCAL_CFLAGS += -DDISABLE_FRAMEBUFFER_HAL
+endif
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/gralloc/alloc_device.cpp b/gralloc/alloc_device.cpp
index 397f95e4..b6bd69ea 100644
--- a/gralloc/alloc_device.cpp
+++ b/gralloc/alloc_device.cpp
@@ -41,6 +41,10 @@
#if GRALLOC_ARM_DMA_BUF_MODULE
#include <ion/ion.h>
#include "ion_4.12.h"
+
+#define ION_SYSTEM (char*)"ion_system_heap"
+#define ION_CMA (char*)"linux,cma"
+
#endif
#if GRALLOC_SIMULATE_FAILURES
@@ -144,7 +148,10 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
if (m->gralloc_legacy_ion)
{
- ret = ion_alloc(m->ion_client, size, 0, ION_HEAP_SYSTEM_MASK, 0, &(ion_hnd));
+ if (usage & GRALLOC_USAGE_HW_FB)
+ ret = ion_alloc(m->ion_client, size, 0, ION_HEAP_TYPE_DMA_MASK, 0, &(ion_hnd));
+ else
+ ret = ion_alloc(m->ion_client, size, 0, ION_HEAP_SYSTEM_MASK, 0, &(ion_hnd));
if (ret != 0)
{
@@ -175,7 +182,10 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
}
else
{
- ret = ion_alloc_fd(m->ion_client, size, 0, 1 << m->system_heap_id, 0, &(shared_fd));
+ if (usage & GRALLOC_USAGE_HW_FB)
+ ret = ion_alloc_fd(m->ion_client, size, 0, 1 << m->cma_heap_id, 0, &(shared_fd));
+ else
+ ret = ion_alloc_fd(m->ion_client, size, 0, 1 << m->system_heap_id, 0, &(shared_fd));
if (ret != 0)
{
@@ -318,6 +328,7 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
}
+#ifndef DISABLE_FRAMEBUFFER_HAL
static int gralloc_alloc_framebuffer_locked(alloc_device_t *dev, size_t size, int usage, buffer_handle_t *pHandle)
{
private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
@@ -427,6 +438,7 @@ static int gralloc_alloc_framebuffer(alloc_device_t *dev, size_t size, int usage
pthread_mutex_unlock(&m->lock);
return err;
}
+#endif /* DISABLE_FRAMEBUFFER_HAL */
static int alloc_device_alloc(alloc_device_t *dev, int w, int h, int format, int usage, buffer_handle_t *pHandle, int *pStride)
{
@@ -534,7 +546,7 @@ static int alloc_device_alloc(alloc_device_t *dev, int w, int h, int format, int
int err;
-#ifndef MALI_600
+#ifndef DISABLE_FRAMEBUFFER_HAL
if (usage & GRALLOC_USAGE_HW_FB)
{
@@ -681,9 +693,9 @@ static int alloc_device_close(struct hw_device_t *device)
}
#if GRALLOC_ARM_DMA_BUF_MODULE
-static int find_system_heap_id(int ion_client)
+static int find_ion_heap_id(int ion_client, char* name)
{
- int i, ret, cnt, system_heap_id = -1;
+ int i, ret, cnt, heap_id = -1;
struct ion_heap_data *data;
ret = ion_query_heap_cnt(ion_client, &cnt);
@@ -710,8 +722,8 @@ static int find_system_heap_id(int ion_client)
{
for (i = 0; i < cnt; i++) {
struct ion_heap_data *dat = (struct ion_heap_data *)data;
- if (strcmp(dat[i].name, "ion_system_heap") == 0) {
- system_heap_id = dat[i].heap_id;
+ if (strcmp(dat[i].name, name) == 0) {
+ heap_id = dat[i].heap_id;
break;
}
}
@@ -719,12 +731,12 @@ static int find_system_heap_id(int ion_client)
if (i > cnt)
{
AERR("No System Heap Found amongst %d heaps\n", cnt);
- system_heap_id = -1;
+ heap_id = -1;
}
}
free(data);
- return system_heap_id;
+ return heap_id;
}
#endif
@@ -778,8 +790,9 @@ int alloc_device_open(hw_module_t const *module, const char *name, hw_device_t *
if (!m->gralloc_legacy_ion)
{
- m->system_heap_id = find_system_heap_id(m->ion_client);
- if (m->system_heap_id < 0)
+ m->system_heap_id = find_ion_heap_id(m->ion_client, ION_SYSTEM);
+ m->cma_heap_id = find_ion_heap_id(m->ion_client, ION_CMA);
+ if (m->system_heap_id < 0 || m->cma_heap_id < 0)
{
delete dev;
ion_close(m->ion_client);
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index a5f8c8b0..3330eae8 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -113,6 +113,7 @@ struct private_module_t
buffer_handle_t currentBuffer;
int ion_client;
int system_heap_id;
+ int cma_heap_id;
bool gralloc_legacy_ion;
struct fb_var_screeninfo info;