exynos4: gralloc: improve allocation logic

A buffer that needs to be allocated in ION will either have
GRALLOC_USAGE_HW_COMPOSER, or GRALLOC_USAGE_HW_ION. See
https://android.googlesource.com/platform/hardware/libhardware/+/android-7.1.2_r33/include/hardware/hwcomposer.h#136
for more information.

Change-Id: Ie75d369e40ce1758920d194dd1f0dafcaeb4d140
This commit is contained in:
Simon Shields 2017-10-28 00:04:16 +11:00 committed by Shilin Victor
parent 1535f0a3dc
commit 70f13df35c
1 changed files with 9 additions and 3 deletions

View File

@ -297,10 +297,16 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, size_t size, int usage,
return gralloc_alloc_fimc1(size, usage, pHandle, w, h, format, bpp, stride_raw, stride);
}
ret = gralloc_alloc_ion(dev, size, usage, format, &ion_fd, &ion_paddr, &priv_alloc_flag, &ump_mem_handle);
ret = -1;
if (usage & (GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_ION)) {
// 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);
}
if (ret < 0) {
// may happen if ion carveout is out of memory
ALOGI("Falling back to UMP-only allocation...");
// may happen if ion carveout is out of memory, or if the
// handle is not needed for HWC
ALOGV("Falling back to UMP-only allocation...");
priv_alloc_flag = private_handle_t::PRIV_FLAGS_USES_UMP;
#ifdef SAMSUNG_EXYNOS_CACHE_UMP
if ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN) {