summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Strachan <astrachan@google.com>2018-07-13 20:50:21 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-07-13 20:50:21 +0000
commit9820de4a404e28875141f1640dd975ec97a3a758 (patch)
treed0f622da1af6ee5508ca6f8afe657fb22c0ef68e
parent7c2f3413d06bb04e0481cab22f946b7e1d375e5d (diff)
parenta88fbc333e9d7c9723edba45a19dd643d87d1c36 (diff)
downloadhikey-9820de4a404e28875141f1640dd975ec97a3a758.tar.gz
Merge changes from topic "gralloc-drm_hwc-prep"
* changes: hikey960: gralloc960: Tweak allocation so every HWC allocation doesn't come out of cma hikey960: gralloc960: Add support for building w/ drm_hwcomposer hikey960: gralloc960: Add usage field to map to older code hikey: gralloc: Allow use of CMA heap instead of fbdev hikey: gralloc: Add union alias and additional fields to improve interop w/ hikey960 gralloc hikey: gralloc: Change to allow gralloc_priv.h to be shared gralloc/gralloc960: Drop linux/ion.h references as its gone
-rw-r--r--gralloc/Android.mk7
-rw-r--r--gralloc/alloc_device.cpp40
-rw-r--r--gralloc/gralloc_module.cpp1
-rw-r--r--gralloc/gralloc_priv.h10
-rw-r--r--gralloc960/Android.hikey960.mk6
-rw-r--r--gralloc960/gralloc_priv.h1
-rw-r--r--gralloc960/mali_gralloc_buffer.h6
-rw-r--r--gralloc960/mali_gralloc_ion.cpp3
8 files changed, 51 insertions, 23 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 076cb5ce..b6bd69ea 100644
--- a/gralloc/alloc_device.cpp
+++ b/gralloc/alloc_device.cpp
@@ -39,9 +39,12 @@
#endif
#if GRALLOC_ARM_DMA_BUF_MODULE
-#include <linux/ion.h>
#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
@@ -145,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)
{
@@ -176,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)
{
@@ -319,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);
@@ -428,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)
{
@@ -438,6 +449,7 @@ static int alloc_device_alloc(alloc_device_t *dev, int w, int h, int format, int
size_t size;
size_t stride;
+ int bpp = 1;
if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP || format == HAL_PIXEL_FORMAT_YV12
/* HAL_PIXEL_FORMAT_YCbCr_420_SP, HAL_PIXEL_FORMAT_YCbCr_420_P, HAL_PIXEL_FORMAT_YCbCr_422_I are not defined in Android.
@@ -489,7 +501,6 @@ static int alloc_device_alloc(alloc_device_t *dev, int w, int h, int format, int
}
else
{
- int bpp = 0;
switch (format)
{
@@ -535,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)
{
@@ -590,7 +601,7 @@ static int alloc_device_alloc(alloc_device_t *dev, int w, int h, int format, int
hnd->height = h;
hnd->format = format;
hnd->stride = stride;
-
+ hnd->byte_stride = GRALLOC_ALIGN(w*bpp,64);
*pStride = stride;
return 0;
}
@@ -682,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);
@@ -711,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;
}
}
@@ -720,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
@@ -779,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_module.cpp b/gralloc/gralloc_module.cpp
index 84054736..4937b596 100644
--- a/gralloc/gralloc_module.cpp
+++ b/gralloc/gralloc_module.cpp
@@ -37,7 +37,6 @@ static int s_ump_is_open = 0;
#endif
#if GRALLOC_ARM_DMA_BUF_MODULE
-#include <linux/ion.h>
#include <ion/ion.h>
#include <sys/mman.h>
#endif
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index 71920e0b..3330eae8 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -28,7 +28,7 @@
#include <hardware/gralloc.h>
#include <cutils/native_handle.h>
-#include <alloc_device.h>
+#include "alloc_device.h"
#include <utils/Log.h>
#ifdef MALI_600
@@ -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;
@@ -166,7 +167,10 @@ struct private_handle_t
int size;
int width;
int height;
- int format;
+ union {
+ int format;
+ int req_format; /* same name as gralloc960 */
+ };
int stride;
union
{
@@ -193,10 +197,10 @@ struct private_handle_t
void *fb_paddr;
uint64_t fb_paddr_padding;
};
+ int byte_stride;
#if GRALLOC_ARM_DMA_BUF_MODULE
ion_user_handle_t ion_hnd;
#endif
-
#if GRALLOC_ARM_DMA_BUF_MODULE
#define GRALLOC_ARM_NUM_FDS 1
#else
diff --git a/gralloc960/Android.hikey960.mk b/gralloc960/Android.hikey960.mk
index 5a1a9581..8b0b1bea 100644
--- a/gralloc960/Android.hikey960.mk
+++ b/gralloc960/Android.hikey960.mk
@@ -51,3 +51,9 @@ GRALLOC_DISP_W=0
GRALLOC_DISP_H=0
# Vsync backend(not used)
GRALLOC_VSYNC_BACKEND=default
+
+ifeq ($(HIKEY_USE_DRM_HWCOMPOSER), true)
+ GRALLOC_USE_ION_DMA_HEAP=1
+ GRALLOC_DISABLE_FRAMEBUFFER_HAL=1
+endif
+
diff --git a/gralloc960/gralloc_priv.h b/gralloc960/gralloc_priv.h
index 82538bc0..3a54c18e 100644
--- a/gralloc960/gralloc_priv.h
+++ b/gralloc960/gralloc_priv.h
@@ -23,7 +23,6 @@
#include <pthread.h>
#include <errno.h>
#include <linux/fb.h>
-#include <linux/ion.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/mman.h>
diff --git a/gralloc960/mali_gralloc_buffer.h b/gralloc960/mali_gralloc_buffer.h
index 959653f0..7e1c8366 100644
--- a/gralloc960/mali_gralloc_buffer.h
+++ b/gralloc960/mali_gralloc_buffer.h
@@ -21,7 +21,6 @@
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
-#include <linux/ion.h>
#include <sys/mman.h>
#include "mali_gralloc_private_interface_types.h"
@@ -117,7 +116,10 @@ struct private_handle_t
void *base;
uint64_t padding;
};
- uint64_t consumer_usage;
+ union {
+ uint64_t consumer_usage;
+ uint64_t usage;
+ };
uint64_t producer_usage;
uint64_t backing_store_id;
int backing_store_size;
diff --git a/gralloc960/mali_gralloc_ion.cpp b/gralloc960/mali_gralloc_ion.cpp
index 63d9e18f..d0510545 100644
--- a/gralloc960/mali_gralloc_ion.cpp
+++ b/gralloc960/mali_gralloc_ion.cpp
@@ -25,7 +25,6 @@
#include <log/log.h>
#include <cutils/atomic.h>
-#include <linux/ion.h>
#include <ion/ion.h>
#include <sys/ioctl.h>
@@ -275,7 +274,7 @@ unsigned int pick_ion_heap(uint64_t usage)
}
#elif defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
- else if (!(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) && (usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER)))
+ else if (!(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) && (usage & (GRALLOC_USAGE_HW_FB)))
{
heap_mask = ION_HEAP_TYPE_DMA_MASK;
}