1 /* 2 * Copyright (c) 2022, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file media_copy_common.h 24 //! \brief Common defination and structure used in media copy 25 //! \details Common defination and structure used in media copy, header file only. 26 27 #ifndef __MEDIA_COPY_COMMON_H__ 28 #define __MEDIA_COPY_COMMON_H__ 29 30 #define RENDERCOPY_SRC_INDEX 0 31 #define RENDERCOPY_DST_INDEX 3 32 #define RENDER_COPY_THREADS_MAX 0 33 #define RENDER_COPY_NUM 9 34 35 #define MCPY_CHK_STATUS(_stmt) MOS_CHK_STATUS(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_SELF, _stmt) 36 #define MCPY_CHK_STATUS_RETURN(_stmt) MOS_CHK_STATUS_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_SELF, _stmt) 37 #define MCPY_CHK_NULL(_ptr) MOS_CHK_NULL(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_SELF, _ptr) 38 #define MCPY_CHK_NULL_RETURN(_ptr) MOS_CHK_NULL_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_SELF, _ptr) 39 #define MCPY_ASSERTMESSAGE(_message, ...) MOS_ASSERTMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_SELF, _message, ##__VA_ARGS__) 40 #define MCPY_NORMALMESSAGE(_message, ...) MOS_NORMALMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_SELF, _message, ##__VA_ARGS__) 41 42 #define BLT_CHK_STATUS(_stmt) MOS_CHK_STATUS(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _stmt) 43 #define BLT_CHK_STATUS_RETURN(_stmt) MOS_CHK_STATUS_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _stmt) 44 #define BLT_CHK_NULL(_ptr) MOS_CHK_NULL(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _ptr) 45 #define BLT_CHK_NULL_RETURN(_ptr) MOS_CHK_NULL_RETURN(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _ptr) 46 #define BLT_ASSERTMESSAGE(_message, ...) MOS_ASSERTMESSAGE(MOS_COMPONENT_MCPY, MOS_MCPY_SUBCOMP_BLT, _message, ##__VA_ARGS__) 47 #define BLT_BITS_PER_BYTE 8 48 49 #define VEBOX_COPY 0x700 50 #define RENDER_COPY 0x701 51 #define BLT_COPY 0x702 52 53 #define SINGLE_PLANE 0x1 54 #define TWO_PLANES 0x2 55 #define THREE_PLANES 0x3 56 57 typedef enum YUVANDRGB_PLANE_INDEX_ENUM 58 { 59 MCPY_PLANE_Y = 0, 60 MCPY_PLANE_U = 1, 61 MCPY_PLANE_V = 2, 62 } YUVANDRGB_PLANE_INDEX; 63 64 //! 65 //! \brief Enum for CCS read/write flag 66 //! 67 enum CCS_FLAG 68 { 69 CCS_READ = 0, 70 CCS_WRITE, 71 }; 72 73 //! 74 //! \brief Structure for BLT parameter 75 //! 76 typedef struct _BLT_STATE_PARAM 77 { 78 bool bCopyMainSurface; 79 PMOS_RESOURCE pSrcSurface; 80 PMOS_RESOURCE pDstSurface; 81 bool bCopyCCS; 82 CCS_FLAG ccsFlag; 83 PMOS_SURFACE pSrcCCS; 84 PMOS_SURFACE pDstCCS; 85 }BLT_STATE_PARAM, * PBLT_STATE_PARAM; 86 87 //! 88 //! \brief Kernel IDs 89 //! 90 typedef enum _RENDERCOPY_KERNELID 91 { 92 KERNEL_CopyKernel_1D_to_2D_NV12 = 0, 93 KERNEL_CopyKernel_2D_to_1D_NV12, 94 KERNEL_CopyKernel_2D_to_2D_NV12, 95 KERNEL_CopyKernel_1D_to_2D_Planar, 96 KERNEL_CopyKernel_2D_to_1D_Planar, 97 KERNEL_CopyKernel_2D_to_2D_Planar, 98 KERNEL_CopyKernel_1D_to_2D_Packed, 99 KERNEL_CopyKernel_2D_to_1D_Packed, 100 KERNEL_CopyKernel_2D_to_2D_Packed, 101 KERNEL_CopyKernel_MAX 102 } RENDERCOPY_KERNELID, * PRENDERCOPY_KERNELID; 103 104 typedef struct _DP_RENDERCOPY_NV12_STATIC_DATA 105 { 106 // DWORD 0 - GRF R1.0 107 union 108 { 109 uint32_t Inputsurfaceindex; // Input buffer surface index 110 } DW0; 111 112 // DWORD 1 - GRF R1.1 113 union 114 { 115 uint32_t Outputsurfaceindex; // Output buffer surface Index 116 } DW1; 117 118 // DWORD 2 - GRF R1.2 119 union 120 { 121 uint32_t Widthdword; // Image width in pxels divided by 4 122 } DW2; 123 124 // DWORD 3 - GRF R1.3 125 union 126 { 127 uint32_t Height; // Image height in pixels 128 } DW3; 129 130 // DWORD 4 - GRF R1.4 131 union 132 { 133 uint32_t ShiftLeftOffsetInBytes; // Byte offset of first pixel in input buffer 134 } DW4; 135 136 // DWORD 5 - GRF R1.5 137 union 138 { 139 uint32_t Widthstride; // Stride of 1 line of pixels in input buffer 140 } DW5; 141 142 // DWORD 6 - GRF R1.6 143 union 144 { 145 uint32_t Heightstride; // Stride of number of lines of Y pixels before start of UV pixels 146 } DW6; 147 148 }DP_RENDERCOPY_NV12_STATIC_DATA, *PDP_RENDERCOPY_NV12_STATIC_DATA; 149 150 typedef struct _DP_RENDERCOPY_RGBP_STATIC_DATA 151 { 152 // DWORD 0 - GRF R1.0 153 union 154 { 155 uint32_t InputsurfaceRindex; // Input buffer surface R plane index 156 } DW0; 157 158 // DWORD 1 - GRF R1.1 159 union 160 { 161 uint32_t InputsurfaceGindex; // Input buffer surface G plane index 162 } DW1; 163 164 // DWORD 2 - GRF R1.2 165 union 166 { 167 uint32_t InputsurfaceBindex; // Input buffer surface B plane index 168 } DW2; 169 170 // DWORD 3 - GRF R1.3 171 union 172 { 173 uint32_t OutputsurfaceRindex; // Output buffer surface R plane index 174 } DW3; 175 176 // DWORD 4 - GRF R1.4 177 union 178 { 179 uint32_t OutputsurfaceGindex; // Output buffer surface G plane index 180 } DW4; 181 182 // DWORD 5 - GRF R1.5 183 union 184 { 185 uint32_t OutputsurfaceBindex; // Output buffer surface B plane Index 186 } DW5; 187 188 // DWORD 6 - GRF R1.6 189 union 190 { 191 uint32_t Widthdword; // Image width in pxels divided by 4 192 } DW6; 193 194 // DWORD 7 - GRF R1.7 195 union 196 { 197 uint32_t Height; // Image height in pixels 198 } DW7; 199 200 // DWORD 8 - GRF R2.0 201 union 202 { 203 uint32_t ShiftLeftOffsetInBytes; // Byte offset of first pixel in input buffer 204 } DW8; 205 206 // DWORD 9 - GRF R2.1 207 union 208 { 209 uint32_t WidthdwordNoPadding; // excluding output padding 210 } DW9; 211 212 // DWORD 10 - GRF R2.2 213 union 214 { 215 uint32_t Dst2DStartX; // X-coordinate of top-left pixel in output 2D surface 216 } DW10; 217 218 // DWORD 12 - GRF R2.3 219 union 220 { 221 uint32_t Dst2DStartY; //Y-coordinate of top-left pixel in output 2D surface 222 } DW11; 223 224 }DP_RENDERCOPY_RGBP_STATIC_DATA, *PDP_RENDERCOPY_RGBP_STATIC_DATA; 225 226 typedef struct _DP_RENDERCOPY_PACKED_STATIC_DATA 227 { 228 // DWORD 0 - GRF R1.0 229 union 230 { 231 uint32_t InputSurfaceIndex; // Input buffer surface index 232 } DW0; 233 234 // DWORD 1 - GRF R1.1 235 union 236 { 237 uint32_t OutputSurfaceIndex; // Output buffer surface Index 238 } DW1; 239 240 // DWORD 2 - GRF R1.2 241 union 242 { 243 uint32_t WidthDWord; // Image width in pixels * bytes_per_pixel / 4 244 } DW2; 245 246 // DWORD 3 - GRF R1.3 247 union 248 { 249 uint32_t Height; // Image height in pixels 250 } DW3; 251 252 // DWORD 4 - GRF R1.4 253 union 254 { 255 uint32_t ShiftLeftOffsetInBytes; // Byte offset of first pixel in input buffer 256 } DW4; 257 258 // DWORD 5 - GRF R1.5 259 union 260 { 261 uint32_t ThreadHeight; // Height in pixels / 32 262 } DW5; 263 264 // DWORD 6 - GRF R1.6 265 union 266 { 267 uint32_t WidthdwordNoPadding; // Input image width in pixels divided by 4 268 } DW6; 269 270 // DWORD 6 - GRF R1.7 271 union 272 { 273 uint32_t Dst2DStartX; // X-coordinate of top-left pixel in output 2D surface 274 } DW7; 275 276 // DWORD 6 - GRF R2.0 277 union 278 { 279 uint32_t Dst2DStartY; // Y-coordinate of top-left pixel in output 2D surface 280 } DW8; 281 282 }DP_RENDERCOPY_PACKED_STATIC_DATA, *PDP_RENDERCOPY_PACKED_STATIC_DATA; 283 284 #endif 285