summaryrefslogtreecommitdiffstats
path: root/exynos4
diff options
context:
space:
mode:
authorDominggoes Isakh <drjisakh@gmail.com>2018-12-13 21:41:09 +0100
committerShilin Victor <chrono.monochrome@gmail.com>2019-02-23 16:52:03 +0300
commit03a290ae088561ac5062c9ce52e45faa18471d9c (patch)
tree7771d309cb76213798a7ce67ab5d3ca376544a98 /exynos4
parent7441150656569ef864693527d6c086e56533ad98 (diff)
downloadhardware_samsung-03a290ae088561ac5062c9ce52e45faa18471d9c.tar.gz
hardware_samsung-03a290ae088561ac5062c9ce52e45faa18471d9c.tar.bz2
hardware_samsung-03a290ae088561ac5062c9ce52e45faa18471d9c.zip
gralloc: Fix GraphicBuffer screenshot issues in Pie
Buffer allocation for GraphicBuffer fails because it is released to early. Use ION buffer and add an ump-reference to stall. Change-Id: I077bd7176fff4aa08a46362d80e64ad9b740773a
Diffstat (limited to 'exynos4')
-rw-r--r--exynos4/hal/include/gralloc_priv.h15
-rw-r--r--exynos4/hal/libgralloc_ump/alloc_device.cpp26
-rw-r--r--exynos4/hal/libgralloc_ump/gralloc_module.cpp5
3 files changed, 30 insertions, 16 deletions
diff --git a/exynos4/hal/include/gralloc_priv.h b/exynos4/hal/include/gralloc_priv.h
index 7bb0bb2..8c8df72 100644
--- a/exynos4/hal/include/gralloc_priv.h
+++ b/exynos4/hal/include/gralloc_priv.h
@@ -97,13 +97,14 @@ struct private_handle_t {
struct native_handle nativeHandle;
#endif
enum {
- PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
- PRIV_FLAGS_USES_UMP = 0x00000002,
- PRIV_FLAGS_USES_PMEM = 0x00000004,
- PRIV_FLAGS_USES_IOCTL = 0x00000008,
- PRIV_FLAGS_USES_HDMI = 0x00000010,
- PRIV_FLAGS_USES_ION = 0x00000020,
- PRIV_FLAGS_NONE_CACHED = 0x00000040,
+ PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
+ PRIV_FLAGS_USES_UMP = 0x00000002,
+ PRIV_FLAGS_USES_PMEM = 0x00000004,
+ PRIV_FLAGS_USES_IOCTL = 0x00000008,
+ PRIV_FLAGS_USES_HDMI = 0x00000010,
+ PRIV_FLAGS_USES_ION = 0x00000020,
+ PRIV_FLAGS_NONE_CACHED = 0x00000040,
+ PRIV_FLAGS_GRAPHICBUFFER = 0x00000080
};
enum {
diff --git a/exynos4/hal/libgralloc_ump/alloc_device.cpp b/exynos4/hal/libgralloc_ump/alloc_device.cpp
index e566df6..7796fdb 100644
--- a/exynos4/hal/libgralloc_ump/alloc_device.cpp
+++ b/exynos4/hal/libgralloc_ump/alloc_device.cpp
@@ -99,12 +99,6 @@ extern int get_bpp(int format);
#define EXYNOS4_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1))
-static uint64_t next_backing_store_id()
-{
- static std::atomic<uint64_t> next_id(1);
- return next_id++;
-}
-
int gralloc_alloc_fimc1(size_t size, int usage,
buffer_handle_t* pHandle, int w, int h,
int format, int bpp, int stride_raw, int stride) {
@@ -299,10 +293,16 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, size_t size, int usage,
ret = -1;
if (usage & (GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_ION)) {
+ ALOGV("%s: Allocating for HWC via ION...", __func__);
// the handle is guaranteed to have this usage flag set
// if it is going to be used as an HWC layer (see hwcomposer.h in hardware/libhardware)
ret = gralloc_alloc_ion(dev, size, usage, format, &ion_fd, &ion_paddr, &priv_alloc_flag, &ump_mem_handle);
+ } else if (usage & (GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE)) {
+ ALOGV("%s: Allocating graphicbuffer via ION...", __func__);
+ priv_alloc_flag = priv_alloc_flag | private_handle_t::PRIV_FLAGS_GRAPHICBUFFER;
+ ret = gralloc_alloc_ion(dev, size, usage, format, &ion_fd, &ion_paddr, &priv_alloc_flag, &ump_mem_handle);
}
+
if (ret < 0) {
// may happen if ion carveout is out of memory, or if the
// handle is not needed for HWC
@@ -347,7 +347,7 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, size_t size, int usage,
}
#endif
- hnd->backing_store = next_backing_store_id();
+ hnd->backing_store = ump_id;
hnd->format = format;
hnd->usage = usage;
hnd->width = w;
@@ -361,6 +361,11 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, size_t size, int usage,
hnd->ion_memory = ion_map(ion_fd, size, 0);
ALOGD_IF(debug_level > 0, "%s hnd->format=0x%x hnd->uoffset=%d hnd->voffset=%d hnd->paddr=%x hnd->bpp=%d", __func__, hnd->format, hnd->uoffset, hnd->voffset, hnd->paddr, hnd->bpp);
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_GRAPHICBUFFER) {
+ ALOGD_IF(debug_level > 0, "%s: GraphicBuffer (ump_id:%d): ump_reference_add ump_mem_handle:%08x", __func__, ump_id, ump_mem_handle);
+ ump_reference_add(ump_mem_handle);
+ }
+
return 0;
} else {
ALOGE("%s failed to allocate handle", __func__);
@@ -454,7 +459,7 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, size_t size, in
hnd->width = w;
hnd->height = h;
hnd->bpp = bpp;
- hnd->backing_store = next_backing_store_id();
+ hnd->backing_store = 0;
hnd->paddr = l_paddr;
hnd->stride = stride;
@@ -649,6 +654,9 @@ static int alloc_device_free(alloc_device_t* dev, buffer_handle_t handle)
private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
pthread_mutex_lock(&l_surface);
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_GRAPHICBUFFER) {
+ ALOGD_IF(debug_level > 0, "%s: GraphicBuffer (ump_id:%d): Freeing ump_mem_handle:%08x", __func__, hnd->ump_id, hnd->ump_mem_handle);
+ }
if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) {
/* free this buffer */
@@ -659,7 +667,7 @@ static int alloc_device_free(alloc_device_t* dev, buffer_handle_t handle)
close(hnd->fd);
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) {
- ALOGD_IF(debug_level > 0, "%s hnd->ump_mem_handle=%d hnd->ump_id=%d", __func__, hnd->ump_mem_handle, hnd->ump_id);
+ ALOGD_IF(debug_level > 0, "%s hnd->ump_mem_handle:%08x hnd->ump_id=%d", __func__, hnd->ump_mem_handle, hnd->ump_id);
#ifdef USE_PARTIAL_FLUSH
if (!release_rect((int)hnd->ump_id))
diff --git a/exynos4/hal/libgralloc_ump/gralloc_module.cpp b/exynos4/hal/libgralloc_ump/gralloc_module.cpp
index f8d92c1..41e381f 100644
--- a/exynos4/hal/libgralloc_ump/gralloc_module.cpp
+++ b/exynos4/hal/libgralloc_ump/gralloc_module.cpp
@@ -398,6 +398,11 @@ sd
ALOGE("%s registering non-UMP buffer not supported", __func__);
}
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_GRAPHICBUFFER) {
+ ALOGD_IF(debug_level > 0, "ump_id:%d %s: GraphicBuffer (ump_id:%d): ump_mem_handle:%08x (ump_reference_release)", hnd->ump_id, __func__, hnd->ump_id, hnd->ump_mem_handle);
+ ump_reference_release((ump_handle)hnd->ump_mem_handle);
+ }
+
pthread_mutex_unlock(&s_map_lock);
return retval;
}