diff --git a/libgralloc/adreno_utils.h b/libgralloc/adreno_utils.h index 6cb78106..78f49da4 100644 --- a/libgralloc/adreno_utils.h +++ b/libgralloc/adreno_utils.h @@ -36,6 +36,7 @@ typedef enum { ADRENO_PIXELFORMAT_NV12 = 103, ADRENO_PIXELFORMAT_YUY2 = 107, ADRENO_PIXELFORMAT_B4G4R4A4 = 115, + ADRENO_PIXELFORMAT_NV12_EXT = 506, // NV12 with non-std alignment and offsets ADRENO_PIXELFORMAT_R8G8B8 = 508, // GL_RGB8 ADRENO_PIXELFORMAT_A1B5G5R5 = 519, // GL_RGB5_A1 ADRENO_PIXELFORMAT_R8G8B8X8_SRGB = 520, // GL_SRGB8 diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp index fd98154c..f70ead35 100644 --- a/libgralloc/alloc_controller.cpp +++ b/libgralloc/alloc_controller.cpp @@ -308,9 +308,10 @@ ADRENOPIXELFORMAT AdrenoMemInfo::getGpuPixelFormat(int hal_format) case HAL_PIXEL_FORMAT_sRGB_A_8888: return ADRENO_PIXELFORMAT_R8G8B8A8_SRGB; case HAL_PIXEL_FORMAT_NV12_ENCODEABLE: + return ADRENO_PIXELFORMAT_NV12; case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS: case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC: - return ADRENO_PIXELFORMAT_NV12; + return ADRENO_PIXELFORMAT_NV12_EXT; default: ALOGE("%s: No map for format: 0x%x", __FUNCTION__, hal_format); break; diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h index e9b9d9d4..f973b76c 100755 --- a/libgralloc/gralloc_priv.h +++ b/libgralloc/gralloc_priv.h @@ -33,44 +33,42 @@ #define ROUND_UP_PAGESIZE(x) ( (((unsigned long)(x)) + PAGE_SIZE-1) & \ (~(PAGE_SIZE-1)) ) -enum { - /* gralloc usage bits indicating the type - * of allocation that should be used */ +/* Gralloc usage bits indicating the type of allocation that should be used */ +/* SYSTEM heap comes from kernel vmalloc, can never be uncached, + * is not secured */ +#define GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP GRALLOC_USAGE_PRIVATE_0 - /* SYSTEM heap comes from kernel vmalloc, - * can never be uncached, is not secured*/ - GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP = GRALLOC_USAGE_PRIVATE_0, +/* Non linear, Universal Bandwidth Compression */ +#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_1 - /* Non linear, Universal Bandwidth Compression */ - GRALLOC_USAGE_PRIVATE_ALLOC_UBWC = GRALLOC_USAGE_PRIVATE_1, +/* IOMMU heap comes from manually allocated pages, can be cached/uncached, + * is not secured */ +#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP GRALLOC_USAGE_PRIVATE_2 - /* IOMMU heap comes from manually allocated pages, - * can be cached/uncached, is not secured */ - GRALLOC_USAGE_PRIVATE_IOMMU_HEAP = GRALLOC_USAGE_PRIVATE_2, - /* MM heap is a carveout heap for video, can be secured*/ - GRALLOC_USAGE_PRIVATE_MM_HEAP = GRALLOC_USAGE_PRIVATE_3, - /* ADSP heap is a carveout heap, is not secured*/ - GRALLOC_USAGE_PRIVATE_ADSP_HEAP = 0x01000000, +/* MM heap is a carveout heap for video, can be secured */ +#define GRALLOC_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_3 - /* Set this for allocating uncached memory (using O_DSYNC) - * cannot be used with noncontiguous heaps */ - GRALLOC_USAGE_PRIVATE_UNCACHED = 0x02000000, +/* ADSP heap is a carveout heap, is not secured */ +#define GRALLOC_USAGE_PRIVATE_ADSP_HEAP 0x01000000 - /* Buffer content should be displayed on an primary display only */ - GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY = 0x04000000, +/* Set this for allocating uncached memory (using O_DSYNC), + * cannot be used with noncontiguous heaps */ +#define GRALLOC_USAGE_PRIVATE_UNCACHED 0x02000000 - /* Buffer content should be displayed on an external display only */ - GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY = 0x08000000, +/* Buffer content should be displayed on an primary display only */ +#define GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY 0x04000000 - /* This flag is set for WFD usecase */ - GRALLOC_USAGE_PRIVATE_WFD = 0x00200000, +/* Buffer content should be displayed on an external display only */ +#define GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY 0x08000000 - /* CAMERA heap is a carveout heap for camera, is not secured*/ - GRALLOC_USAGE_PRIVATE_CAMERA_HEAP = 0x00400000, +/* This flag is set for WFD usecase */ +#define GRALLOC_USAGE_PRIVATE_WFD 0x00200000 - /* This flag is used for SECURE display usecase */ - GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY = 0x00800000, -}; +/* CAMERA heap is a carveout heap for camera, is not secured */ +#define GRALLOC_USAGE_PRIVATE_CAMERA_HEAP 0x00400000 + +/* This flag is used for SECURE display usecase */ +#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY 0x00800000 /* define Gralloc perform */ #define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1 @@ -84,6 +82,7 @@ enum { #define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6 #define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7 #define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8 +#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9 #define GRALLOC_HEAP_MASK (GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP |\ GRALLOC_USAGE_PRIVATE_IOMMU_HEAP |\ diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp index 44f4fb2b..53823002 100644 --- a/libgralloc/mapper.cpp +++ b/libgralloc/mapper.cpp @@ -447,6 +447,17 @@ int gralloc_perform(struct gralloc_module_t const* module, } } break; + case GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG: + { + private_handle_t* hnd = va_arg(args, private_handle_t*); + int *flag = va_arg(args, int *); + if (private_handle_t::validate(hnd)) { + return res; + } + *flag = hnd->flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED; + res = 0; + } break; + default: break; }