author | sky zhou <sky.zhou@amlogic.com> | 2017-09-04 14:46:02 (GMT) |
---|---|---|
committer | Jiyu Yang <Jiyu.Yang@amlogic.com> | 2017-09-11 07:03:32 (GMT) |
commit | f55d426568cdd49890e271d989c81d74fd0403c4 (patch) | |
tree | f8674b84e72fcc4e912de64bb51d3e4d71ccec1a | |
parent | 1b6f74774409c9fac0dd9a3c9010e00cc616d6ab (diff) | |
download | gralloc-f55d426568cdd49890e271d989c81d74fd0403c4.zip gralloc-f55d426568cdd49890e271d989c81d74fd0403c4.tar.gz gralloc-f55d426568cdd49890e271d989c81d74fd0403c4.tar.bz2 |
gralloc: alloc framebuffer from ion heap. [2/3]
PD#148907
On android o, gralloc only take care of allocating, so
osd can't manage the buffer in buffer idx.
Now we allocate the framebuffer from ion heap, manage
it by file handle.
Change-Id: I151e603cf39bbac5835357c3abd8fe3576a67de2
-rw-r--r-- | Android.mk | 4 | ||||
-rw-r--r-- | alloc_device.cpp | 2 | ||||
-rw-r--r-- | alloc_ion.cpp | 7 | ||||
-rw-r--r-- | framebuffer.cpp | 9 |
4 files changed, 21 insertions, 1 deletions
@@ -166,6 +166,10 @@ ifeq ($(TARGET_SUPPORT_SECURE_LAYER),true) LOCAL_CFLAGS += -DGRALLOC_ENABLE_SECURE_LAYER endif +ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26 && echo OK),OK) +LOCAL_CFLAGS += -DGRALLOC_ALLOC_FB_FROM_ION=1 +endif + ifneq ($(TARGET_2ND_ARCH),) LOCAL_MODULE_RELATIVE_PATH := hw else diff --git a/alloc_device.cpp b/alloc_device.cpp index 6e363c6..4427457 100644 --- a/alloc_device.cpp +++ b/alloc_device.cpp @@ -1061,7 +1061,7 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int } int err; -#if DISABLE_FRAMEBUFFER_HAL != 1 +#if DISABLE_FRAMEBUFFER_HAL != 1 && GRALLOC_ALLOC_FB_FROM_ION != 1 if (usage & GRALLOC_USAGE_HW_FB) { err = gralloc_alloc_framebuffer(dev, size, usage, pHandle, &pixel_stride, &byte_stride); diff --git a/alloc_ion.cpp b/alloc_ion.cpp index 3bd7bba..456844d 100644 --- a/alloc_ion.cpp +++ b/alloc_ion.cpp @@ -116,6 +116,13 @@ int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_hand } #endif } +#if GRALLOC_ALLOC_FB_FROM_ION == 1 + else if (usage & GRALLOC_USAGE_HW_FB) { + ALOGE("alloc framebuffer %d", size); + ret = ion_alloc(m->ion_client, size, 0, 1<<ION_HEAP_TYPE_DMA, + ion_flags, &ion_hnd); + } +#endif #ifdef GRALLOC_APP_ALLOC_CONTINUOUS_BUF else if (usage & GRALLOC_USAGE_HW_COMPOSER && !(usage & GRALLOC_USAGE_AML_VIDEO_OVERLAY diff --git a/framebuffer.cpp b/framebuffer.cpp index 5afed0f..b6b61f1 100644 --- a/framebuffer.cpp +++ b/framebuffer.cpp @@ -555,10 +555,19 @@ int hwc_fb_post_with_fence_locked( private_handle_t const* buffer = reinterpret_cast<private_handle_t const*>(hnd); switch (sync_req->type) { case GLES_COMPOSE_MODE: + #if PLATFORM_SDK_VERSION >= 26 + ALOGD("gles pass to direct compose mode."); + sync_req->type = DIRECT_COMPOSE_MODE; + sync_req->xoffset = sync_req->dst_x = 0; + sync_req->yoffset = sync_req->dst_y = 0; + sync_req->width = sync_req->dst_w = buffer->width; + sync_req->height = sync_req->dst_h = buffer->height; + #else sync_req->xoffset = fbinfo->info.xoffset; sync_req->yoffset = buffer->offset / fbinfo->finfo.line_length; ALOGV( "hwc GLES, req offset: %d",sync_req->yoffset); break; + #endif case DIRECT_COMPOSE_MODE: sync_req->format = buffer->format; sync_req->shared_fd = buffer->share_fd; |