1 /* 2 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer in the documentation and/or other materials provided 12 * with the distribution. 13 * * Neither the name of The Linux Foundation nor the names of its 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _QDMETADATA_H 31 #define _QDMETADATA_H 32 33 #include <color_metadata.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #define MAX_UBWC_STATS_LENGTH 32 40 41 enum ColorSpace_t{ 42 ITU_R_601, 43 ITU_R_601_FR, 44 ITU_R_709, 45 ITU_R_2020, 46 ITU_R_2020_FR, 47 }; 48 49 enum IGC_t { 50 IGC_NotSpecified, 51 IGC_sRGB, 52 }; 53 54 struct HSICData_t { 55 int32_t hue; 56 float saturation; 57 int32_t intensity; 58 float contrast; 59 }; 60 61 struct BufferDim_t { 62 int32_t sliceWidth; 63 int32_t sliceHeight; 64 }; 65 66 enum UBWC_Version { 67 UBWC_UNUSED = 0, 68 UBWC_1_0 = 0x1, 69 UBWC_2_0 = 0x2, 70 UBWC_MAX_VERSION = 0xFF, 71 }; 72 73 struct UBWC_2_0_Stats { 74 uint32_t nCRStatsTile32; /**< UBWC Stats info for 32 Byte Tile */ 75 uint32_t nCRStatsTile64; /**< UBWC Stats info for 64 Byte Tile */ 76 uint32_t nCRStatsTile96; /**< UBWC Stats info for 96 Byte Tile */ 77 uint32_t nCRStatsTile128; /**< UBWC Stats info for 128 Byte Tile */ 78 uint32_t nCRStatsTile160; /**< UBWC Stats info for 160 Byte Tile */ 79 uint32_t nCRStatsTile192; /**< UBWC Stats info for 192 Byte Tile */ 80 uint32_t nCRStatsTile256; /**< UBWC Stats info for 256 Byte Tile */ 81 }; 82 83 struct UBWCStats { 84 enum UBWC_Version version; /* Union depends on this version. */ 85 uint8_t bDataValid; /* If [non-zero], CR Stats data is valid. 86 * Consumers may use stats data. 87 * If [zero], CR Stats data is invalid. 88 * Consumers *Shall* not use stats data */ 89 union { 90 struct UBWC_2_0_Stats ubwc_stats; 91 uint32_t reserved[MAX_UBWC_STATS_LENGTH]; /* This is for future */ 92 }; 93 }; 94 95 struct S3DGpuComp_t { 96 int32_t displayId; /* on which display S3D is composed by client */ 97 uint32_t s3dMode; /* the S3D format of this layer to be accessed by client */ 98 }; 99 100 struct MetaData_t { 101 int32_t operation; 102 int32_t interlaced; 103 struct BufferDim_t bufferDim; 104 float refreshrate; 105 enum ColorSpace_t colorSpace; 106 enum IGC_t igc; 107 /* Gralloc sets PRIV_SECURE_BUFFER flag to inform that the buffers are from 108 * ION_SECURE. which should not be mapped. However, for GPU post proc 109 * feature, GFX needs to map this buffer, in the client context and in SF 110 * context, it should not. Hence to differentiate, add this metadata field 111 * for clients to set, and GPU will to read and know when to map the 112 * SECURE_BUFFER(ION) */ 113 int32_t mapSecureBuffer; 114 /* The supported formats are defined in gralloc_priv.h to 115 * support legacy code*/ 116 uint32_t s3dFormat; 117 /* VENUS output buffer is linear for UBWC Interlaced video */ 118 uint32_t linearFormat; 119 /* Set by graphics to indicate that this buffer will be written to but not 120 * swapped out */ 121 uint32_t isSingleBufferMode; 122 /* Indicate GPU to draw S3D layer on dedicate display device */ 123 struct S3DGpuComp_t s3dComp; 124 125 /* Set by camera to program the VT Timestamp */ 126 uint64_t vtTimeStamp; 127 /* Color Aspects + HDR info */ 128 ColorMetaData color; 129 /* Consumer should read this data as follows based on 130 * Gralloc flag "interlaced" listed above. 131 * [0] : If it is progressive. 132 * [0] : Top field, if it is interlaced. 133 * [1] : Do not read, if it is progressive. 134 * [1] : Bottom field, if it is interlaced. 135 */ 136 struct UBWCStats ubwcCRStats[2]; 137 }; 138 139 enum DispParamType { 140 SET_VT_TIMESTAMP = 0x0001, 141 COLOR_METADATA = 0x0002, 142 PP_PARAM_INTERLACED = 0x0004, 143 UNUSED2 = 0x0008, 144 UNUSED3 = 0x0010, 145 UNUSED4 = 0x0020, 146 SET_UBWC_CR_STATS_INFO = 0x0040, 147 UPDATE_BUFFER_GEOMETRY = 0x0080, 148 UPDATE_REFRESH_RATE = 0x0100, 149 UPDATE_COLOR_SPACE = 0x0200, 150 MAP_SECURE_BUFFER = 0x0400, 151 S3D_FORMAT = 0x0800, 152 LINEAR_FORMAT = 0x1000, 153 SET_IGC = 0x2000, 154 SET_SINGLE_BUFFER_MODE = 0x4000, 155 SET_S3D_COMP = 0x8000, 156 }; 157 158 enum DispFetchParamType { 159 GET_VT_TIMESTAMP = 0x0001, 160 GET_COLOR_METADATA = 0x0002, 161 GET_PP_PARAM_INTERLACED = 0x0004, 162 GET_UBWC_CR_STATS_INFO = 0x0040, 163 GET_BUFFER_GEOMETRY = 0x0080, 164 GET_REFRESH_RATE = 0x0100, 165 GET_COLOR_SPACE = 0x0200, 166 GET_MAP_SECURE_BUFFER = 0x0400, 167 GET_S3D_FORMAT = 0x0800, 168 GET_LINEAR_FORMAT = 0x1000, 169 GET_IGC = 0x2000, 170 GET_SINGLE_BUFFER_MODE = 0x4000, 171 GET_S3D_COMP = 0x8000, 172 }; 173 174 struct private_handle_t; 175 int setMetaData(struct private_handle_t *handle, enum DispParamType paramType, 176 void *param); 177 int setMetaDataVa(struct MetaData_t* data, enum DispParamType paramType, 178 void *param); 179 180 int getMetaData(struct private_handle_t *handle, 181 enum DispFetchParamType paramType, 182 void *param); 183 int getMetaDataVa(struct MetaData_t* data, enum DispFetchParamType paramType, 184 void *param); 185 186 int copyMetaData(struct private_handle_t *src, struct private_handle_t *dst); 187 int copyMetaDataVaToHandle(struct MetaData_t *src, struct private_handle_t *dst); 188 int copyMetaDataHandleToVa(struct private_handle_t* src, struct MetaData_t *dst); 189 int copyMetaDataVaToVa(struct MetaData_t *src, struct MetaData_t *dst); 190 191 int clearMetaData(struct private_handle_t *handle, enum DispParamType paramType); 192 int clearMetaDataVa(struct MetaData_t *data, enum DispParamType paramType); 193 194 unsigned long getMetaDataSize(); 195 196 #ifdef __cplusplus 197 } 198 #endif 199 200 #endif /* _QDMETADATA_H */ 201 202