mirror of
https://github.com/team-infusion-developers/android_hardware_samsung.git
synced 2024-11-06 21:55:41 +00:00
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:
parent
1535f0a3dc
commit
70f13df35c
1 changed files with 9 additions and 3 deletions
|
@ -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);
|
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) {
|
if (ret < 0) {
|
||||||
// may happen if ion carveout is out of memory
|
// may happen if ion carveout is out of memory, or if the
|
||||||
ALOGI("Falling back to UMP-only allocation...");
|
// handle is not needed for HWC
|
||||||
|
ALOGV("Falling back to UMP-only allocation...");
|
||||||
priv_alloc_flag = private_handle_t::PRIV_FLAGS_USES_UMP;
|
priv_alloc_flag = private_handle_t::PRIV_FLAGS_USES_UMP;
|
||||||
#ifdef SAMSUNG_EXYNOS_CACHE_UMP
|
#ifdef SAMSUNG_EXYNOS_CACHE_UMP
|
||||||
if ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN) {
|
if ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN) {
|
||||||
|
|
Loading…
Reference in a new issue