1 /* 2 * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. 3 * Not a Contribution 4 * 5 * Copyright (C) 2008 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 #ifndef __GRALLOC_PRIV_H__ 21 #define __GRALLOC_PRIV_H__ 22 23 #include <unistd.h> 24 #include "gr_priv_handle.h" 25 26 #define ROUND_UP_PAGESIZE(x) roundUpToPageSize(x) 27 inline int roundUpToPageSize(int x) { 28 return (x + (getpagesize()-1)) & ~(getpagesize()-1); 29 } 30 31 /* Gralloc usage bits indicating the type of allocation that should be used */ 32 /* Refer gralloc1_producer_usage_t & gralloc1_consumer_usage-t in gralloc1.h */ 33 34 /* Producer flags */ 35 /* Non linear, Universal Bandwidth Compression */ 36 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_ALLOC_UBWC GRALLOC1_PRODUCER_USAGE_PRIVATE_0 37 38 /* Set this for allocating uncached memory (using O_DSYNC), 39 * cannot be used with noncontiguous heaps */ 40 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED GRALLOC1_PRODUCER_USAGE_PRIVATE_1 41 42 /* CAMERA heap is a carveout heap for camera, is not secured */ 43 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_CAMERA_HEAP GRALLOC1_PRODUCER_USAGE_PRIVATE_2 44 45 /* ADSP heap is a carveout heap, is not secured */ 46 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_ADSP_HEAP GRALLOC1_PRODUCER_USAGE_PRIVATE_3 47 48 /* IOMMU heap comes from manually allocated pages, can be cached/uncached, is not secured */ 49 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_IOMMU_HEAP GRALLOC1_PRODUCER_USAGE_PRIVATE_4 50 51 /* MM heap is a carveout heap for video, can be secured */ 52 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_MM_HEAP GRALLOC1_PRODUCER_USAGE_PRIVATE_5 53 54 /* Use legacy ZSL definition until we know the correct usage on gralloc1 */ 55 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_CAMERA_ZSL GRALLOC_USAGE_HW_CAMERA_ZSL 56 57 58 /* Consumer flags */ 59 /* TODO(user): Fix when producer and consumer flags are actually separated */ 60 /* This flag is set for WFD usecase */ 61 #define GRALLOC1_CONSUMER_USAGE_PRIVATE_WFD 0x00200000 62 63 /* This flag is used for SECURE display usecase */ 64 #define GRALLOC1_CONSUMER_USAGE_PRIVATE_SECURE_DISPLAY 0x00800000 65 66 /* Buffer content should be displayed on a primary display only */ 67 #define GRALLOC1_CONSUMER_USAGE_PRIVATE_INTERNAL_ONLY 0x04000000 68 69 /* Buffer content should be displayed on an external display only */ 70 #define GRALLOC1_CONSUMER_USAGE_PRIVATE_EXTERNAL_ONLY 0x08000000 71 72 73 /* Legacy gralloc0.x definitions */ 74 /* Some clients may still be using the old flags */ 75 #define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC GRALLOC1_PRODUCER_USAGE_PRIVATE_ALLOC_UBWC 76 #define GRALLOC_USAGE_PRIVATE_UNCACHED GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED 77 #define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP GRALLOC1_PRODUCER_USAGE_PRIVATE_IOMMU_HEAP 78 #define GRALLOC_USAGE_PRIVATE_WFD GRALLOC1_CONSUMER_USAGE_PRIVATE_WFD 79 #define GRALLOC_USAGE_PRIVATE_CAMERA_HEAP GRALLOC1_PRODUCER_USAGE_PRIVATE_CAMERA_HEAP 80 #define GRALLOC_USAGE_PRIVATE_MM_HEAP 0x0 81 82 83 84 // for PERFORM API : 85 #define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1 86 #define GRALLOC_MODULE_PERFORM_GET_STRIDE 2 87 #define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3 88 #define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4 89 #define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5 90 #define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6 91 #define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7 92 #define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8 93 #define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9 94 #define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10 95 #define GRALLOC_MODULE_PERFORM_GET_IGC 11 96 #define GRALLOC_MODULE_PERFORM_SET_IGC 12 97 #define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13 98 #define GRALLOC1_MODULE_PERFORM_GET_BUFFER_SIZE_AND_DIMENSIONS 14 99 #define GRALLOC1_MODULE_PERFORM_ALLOCATE_BUFFER 15 100 #define GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG 16 101 102 // OEM specific HAL formats 103 #define HAL_PIXEL_FORMAT_RGBA_5551 6 104 #define HAL_PIXEL_FORMAT_RGBA_4444 7 105 #define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102 106 #define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04 107 #define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03 108 #define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109 109 #define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01 110 #define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B 111 #define HAL_PIXEL_FORMAT_R_8 0x10D 112 #define HAL_PIXEL_FORMAT_RG_88 0x10E 113 #define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F 114 #define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110 115 #define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111 116 #define HAL_PIXEL_FORMAT_BGRX_8888 0x112 117 #define HAL_PIXEL_FORMAT_NV21_ZSL 0x113 118 #define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114 119 #define HAL_PIXEL_FORMAT_BGR_565 0x115 120 #define HAL_PIXEL_FORMAT_RAW8 0x123 121 122 // 10 bit 123 #define HAL_PIXEL_FORMAT_ARGB_2101010 0x117 124 #define HAL_PIXEL_FORMAT_RGBX_1010102 0x118 125 #define HAL_PIXEL_FORMAT_XRGB_2101010 0x119 126 #define HAL_PIXEL_FORMAT_BGRA_1010102 0x11A 127 #define HAL_PIXEL_FORMAT_ABGR_2101010 0x11B 128 #define HAL_PIXEL_FORMAT_BGRX_1010102 0x11C 129 #define HAL_PIXEL_FORMAT_XBGR_2101010 0x11D 130 #define HAL_PIXEL_FORMAT_YCbCr_420_P010 0x11F 131 #define HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC 0x124 132 133 #define HAL_PIXEL_FORMAT_CbYCrY_422_I 0x120 134 #define HAL_PIXEL_FORMAT_BGR_888 0x121 135 136 #define HAL_PIXEL_FORMAT_INTERLACE 0x180 137 138 // v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component 139 #define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559 140 141 // v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed 142 // format reduces the memory access bandwidth 143 #define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259 144 145 // UBWC aligned Venus format 146 #define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06 147 #define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC 0x7FA30C09 148 149 // Khronos ASTC formats 150 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 151 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 152 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 153 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 154 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 155 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 156 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 157 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 158 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 159 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 160 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA 161 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB 162 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC 163 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD 164 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 165 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 166 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 167 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 168 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 169 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 170 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 171 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 172 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 173 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 174 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA 175 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB 176 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC 177 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD 178 179 /* possible values for inverse gamma correction */ 180 #define HAL_IGC_NOT_SPECIFIED 0 181 #define HAL_IGC_s_RGB 1 182 183 /* Color Space: Values maps to ColorSpace_t in qdMetadata.h */ 184 #define HAL_CSC_ITU_R_601 0 185 #define HAL_CSC_ITU_R_601_FR 1 186 #define HAL_CSC_ITU_R_709 2 187 #define HAL_CSC_ITU_R_2020 3 188 #define HAL_CSC_ITU_R_2020_FR 4 189 190 /* possible formats for 3D content*/ 191 enum { 192 HAL_NO_3D = 0x0, 193 HAL_3D_SIDE_BY_SIDE_L_R = 0x1, 194 HAL_3D_SIDE_BY_SIDE_R_L = 0x2, 195 HAL_3D_TOP_BOTTOM = 0x4, 196 HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, // unused legacy format 197 }; 198 199 enum { BUFFER_TYPE_UI = 0, BUFFER_TYPE_VIDEO }; 200 201 #endif // __GRALLOC_PRIV_H__ 202