1 /* 2 * Copyright (c) 2009-2020, 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 mos_resource_defs.h 24 //! \brief 25 //! 26 //! 27 //! \file mos_resource_defs.h 28 //! \brief Defines and enums used by os resource 29 //! \details Defines and enums used by os resource 30 //! 31 32 #ifndef __MOS_RESOURCE_DEFS_H__ 33 #define __MOS_RESOURCE_DEFS_H__ 34 35 //! 36 //! \brief Enum for Surface Format (for sampling) 37 //! 38 typedef enum _MOS_FORMAT 39 { 40 Format_Invalid = -14, //!< Invalid format 41 Format_Source = -13, //!< Current source format 42 43 // Generic Formats 44 Format_420O = -12, //!< Generic Render Target Format (NV12, IMC3, 422H, 422V, 411P, 444P, RGBP, BGRP, 400P) 45 Format_RGB_Swap = -11, //!< RGB Formats need HW Channel swap (A8R8G8B8, X8R8G8B8) 46 Format_RGB_No_Swap = -10, //!< RGB Formats don't need HW Channel swap (A8B8G8R8) 47 Format_RGB = -9, //!< Generic RGB input (A8R8G8B, X8R8G8B8, R5G6B5) 48 Format_RGB32 = -8, //!< Generic RGB32 input (A8R8G8B, X8R8G8B8) 49 Format_PA = -7, //!< Generic packed YUV input (YUY2, YUYV, YVYU, UYVY, VYUY) 50 Format_PL2 = -6, //!< Hybrid YUV input (NV12, NV11, P208) 51 Format_PL2_UnAligned = -5, //!< Width or Height is not a multiple of 4 52 Format_PL3 = -4, //!< Planar YUV input (IMC1, IMC2, IMC3, IMC4) 53 Format_PL3_RGB = -3, //!< Planar RGB input (RGBP, BGRP) 54 Format_PAL = -2, //!< Generic Palletized input (AI44, IA44, P8) 55 56 // Auxiliary Formats 57 Format_None = -1, //!< No format (colorfill) 58 Format_Any = 0, //!< Any format 59 60 // RGB formats 61 Format_A8R8G8B8 , //!< ARGB 32bpp (A = 255) 62 Format_X8R8G8B8 , //!< XRGB 32bpp (X = 0) 63 Format_A8B8G8R8 , //!< ABGR 32bpp 64 Format_X8B8G8R8 , //!< XBGR 32bpp 65 Format_A16B16G16R16, //!< ABGR 64bpp 66 Format_A16R16G16B16, //!< ARGB 64bpp 67 Format_R5G6B5 , //!< RGB 16bpp 68 Format_R32U , //!< R32U 32bpp 69 Format_R32F , //!< R32F 32bpp 70 Format_R8G8B8 , //!< RGB 24bpp 71 72 // Planar RGB formats 73 Format_RGBP , //!< R Plane, G Plane, B Plane 74 Format_BGRP , //!< B Plane, G Plane, R Plane 75 76 // YUV packed 4:2:2 formats 77 Format_YUY2 , 78 Format_YUYV , 79 Format_YVYU , 80 Format_UYVY , 81 Format_VYUY , 82 Format_Y216 , //422 16bit 83 Format_Y210 , //422 10bit 84 // YUV packed 4:4:4 formats 85 Format_Y416 , 86 Format_AYUV , 87 Format_AUYV , 88 Format_Y410 , //444 10bit 89 90 // Gray scale image with only Y plane 91 Format_400P , 92 93 // YUV PL2 formats 94 Format_NV12 , 95 Format_NV12_UnAligned , 96 Format_NV21 , 97 Format_NV11 , 98 Format_NV11_UnAligned , 99 Format_P208 , 100 Format_P208_UnAligned , 101 102 // YUV PL3 formats 103 Format_IMC1 , 104 Format_IMC2 , 105 Format_IMC3 , 106 Format_IMC4 , 107 Format_422H , 108 Format_422V , 109 Format_444P , 110 Format_411P , 111 Format_411R , 112 Format_I420 , 113 Format_IYUV , 114 Format_YV12 , 115 Format_YVU9 , 116 117 // Palletized formats (RGB/YUV) 118 Format_AI44 , 119 Format_IA44 , 120 Format_P8 , 121 Format_A8P8 , 122 123 // Alpha + Intensity 124 Format_A8 , 125 Format_L8 , 126 Format_A4L4 , 127 Format_A8L8 , 128 129 // Bayer 130 Format_IRW0 , //!< BGGR 10/12 bit depth [16bit aligned] 131 Format_IRW1 , //!< RGGB 10/12 bit depth [16bit aligned] 132 Format_IRW2 , //!< GRBG 10/12 bit depth [16bit aligned] 133 Format_IRW3 , //!< GBRG 10/12 bit depth [16bit aligned] 134 Format_IRW4 , //!< BGGR 8 bit depth 135 Format_IRW5 , //!< RGGB 8 bit depth 136 Format_IRW6 , //!< GRBG 8 bit depth 137 Format_IRW7 , //!< GBRG 8 bit depth 138 139 Format_STMM, 140 141 Format_Buffer , //!< Used for creating buffer resource (linear) 142 Format_Buffer_2D , //!< Encoder 2D linear buffer. 143 144 Format_V8U8 , 145 146 Format_R32S , //!< R32S 32bpp 147 Format_R8U , //!< R8 Uint 148 Format_R8G8UN , //!< R8G8 UNorm 149 Format_R8G8SN , //!< R8G8 SNorm 150 Format_G8R8_G8B8 , 151 Format_R16U , 152 Format_R16S , 153 Format_R16UN , //!< R16_UNorm 154 Format_RAW , //!< HW RAW format 155 156 Format_Y8 , // R16F 16bpp 157 Format_Y1 , // R16F 16bpp 158 Format_Y16U , // R16F 16bpp 159 Format_Y16S , // R16F 16bpp 160 161 Format_L16 , 162 Format_D16 , 163 Format_R10G10B10A2 , //Memory layout: [A(2) | B(10) | G(10) | R(10)], where A is the highest order bits 164 Format_B10G10R10A2 , //Memory layout: [A(2) | R(10) | G(10) | B(10)], where A is the highest order bits 165 166 Format_P016 , 167 Format_P010 , 168 Format_YV12_Planar , 169 Format_A16B16G16R16F, //!< ABGR 64bpp 170 Format_R16G16UN , 171 Format_R16F , 172 Format_P210 , 173 Format_P216 , 174 Format_A16R16G16B16F, //!< ARGB 64bpp 175 Format_YUY2V , 176 Format_Y216V , 177 Format_D32F , 178 Format_D24S8UN , 179 Format_D32S8X24_FLOAT , 180 181 Format_R16 , 182 Format_R16G16S , 183 Format_R24G8 , 184 Format_R32 , 185 Format_R32G8X24 , 186 Format_R8UN , //!< R8 UNORM 187 Format_R32G32B32A32F, //ARGB 128bpp 188 Format_G32R32F , // G32R32 64 bpp 189 // Last Format 190 Format_Count 191 } MOS_FORMAT, *PMOS_FORMAT; 192 C_ASSERT(Format_Count == 104); //!< When adding, update assert & vphal_solo_scenario.cpp::VpFromXml_GetFormat() & hal_kerneldll.c::g_cIsFormatYUV. 193 194 //! 195 //! \brief Macros for format checking 196 //! 197 #define IS_PAL_FORMAT(format) \ 198 ( (format == Format_AI44) || \ 199 (format == Format_IA44) || \ 200 (format == Format_P8) || \ 201 (format == Format_A8P8)) 202 203 #define CASE_PAL_FORMAT \ 204 case Format_AI44: \ 205 case Format_IA44: \ 206 case Format_P8: \ 207 case Format_A8P8 208 209 #define IS_ALPHA4_FORMAT(format) \ 210 ( (format == Format_AI44) || \ 211 (format == Format_IA44) ) 212 213 #define IS_ALPHA_FORMAT_RGB8(format) \ 214 ( (format == Format_A8R8G8B8) || \ 215 (format == Format_A8B8G8R8) ) 216 217 #define IS_ALPHA_FORMAT_RGB10(format) \ 218 ( (format == Format_R10G10B10A2) || \ 219 (format == Format_B10G10R10A2) ) 220 221 #define IS_ALPHA_FORMAT_RGB16(format) \ 222 ( (format == Format_A16B16G16R16) || \ 223 (format == Format_A16R16G16B16) || \ 224 (format == Format_A16B16G16R16F) || \ 225 (format == Format_A16R16G16B16F) ) 226 227 #define IS_ALPHA_FORMAT_YUV(format) \ 228 ( (format == Format_Y410) || \ 229 (format == Format_Y416) || \ 230 (format == Format_AYUV) ) 231 232 #define IS_ALPHA_FORMAT(format) \ 233 ( IS_ALPHA_FORMAT_RGB8(format) || \ 234 IS_ALPHA_FORMAT_RGB10(format) || \ 235 IS_ALPHA_FORMAT_RGB16(format) || \ 236 IS_ALPHA_FORMAT_YUV(format) ) 237 238 #define IS_PL2_FORMAT(format) \ 239 ( (format == Format_PL2) || \ 240 (format == Format_NV12) || \ 241 (format == Format_NV21) || \ 242 (format == Format_NV11) || \ 243 (format == Format_P208) || \ 244 (format == Format_P010) || \ 245 (format == Format_P016) ) 246 247 #define IS_PL2_FORMAT_UnAligned(format) \ 248 ( (format == Format_PL2_UnAligned) || \ 249 (format == Format_NV12_UnAligned) || \ 250 (format == Format_NV11_UnAligned) || \ 251 (format == Format_P208_UnAligned) ) 252 253 #define CASE_PL2_FORMAT \ 254 case Format_PL2: \ 255 case Format_NV12: \ 256 case Format_NV21: \ 257 case Format_NV11: \ 258 case Format_P208: \ 259 case Format_P010: \ 260 case Format_P016 261 262 #define IS_PL3_FORMAT(format) \ 263 ( (format == Format_PL3) || \ 264 (format == Format_IMC1) || \ 265 (format == Format_IMC2) || \ 266 (format == Format_IMC3) || \ 267 (format == Format_IMC4) || \ 268 (format == Format_I420) || \ 269 (format == Format_IYUV) || \ 270 (format == Format_YV12) || \ 271 (format == Format_YVU9) || \ 272 (format == Format_422H) || \ 273 (format == Format_422V) || \ 274 (format == Format_411P) || \ 275 (format == Format_411R) || \ 276 (format == Format_444P) ) 277 278 #define IS_PL3_RGB_FORMAT(format) \ 279 ( (format == Format_RGBP) || \ 280 (format == Format_BGRP) ) 281 282 #define CASE_PL3_FORMAT \ 283 case Format_PL3: \ 284 case Format_IMC1: \ 285 case Format_IMC2: \ 286 case Format_IMC3: \ 287 case Format_IMC4: \ 288 case Format_I420: \ 289 case Format_IYUV: \ 290 case Format_YV12: \ 291 case Format_YVU9: \ 292 case Format_422H: \ 293 case Format_422V: \ 294 case Format_411P: \ 295 case Format_411R: \ 296 case Format_444P 297 298 #define CASE_PL3_RGB_FORMAT \ 299 case Format_RGBP: \ 300 case Format_BGRP 301 302 #define IS_PA_FORMAT(format) \ 303 ( (format == Format_PA) || \ 304 (format == Format_YUY2) || \ 305 (format == Format_YUYV) || \ 306 (format == Format_YVYU) || \ 307 (format == Format_UYVY) || \ 308 (format == Format_VYUY) || \ 309 (format == Format_Y210) || \ 310 (format == Format_Y216) || \ 311 (format == Format_Y410) || \ 312 (format == Format_Y416) ) 313 314 #define CASE_PA_FORMAT \ 315 case Format_PA: \ 316 case Format_YUY2: \ 317 case Format_YUYV: \ 318 case Format_YVYU: \ 319 case Format_UYVY: \ 320 case Format_VYUY 321 322 #define IS_YUV_FORMAT(format) \ 323 ( IS_PL2_FORMAT(format) || \ 324 IS_PL3_FORMAT(format) || \ 325 IS_PA_FORMAT(format) || \ 326 (format == Format_400P) ) 327 328 #define IS_ALPHA_YUV_FORMAT(format) \ 329 ( (format == Format_AYUV) || \ 330 (format == Format_AUYV) ) 331 332 #define CASE_YUV_FORMAT \ 333 CASE_PL2_FORMAT: \ 334 CASE_PL3_FORMAT: \ 335 CASE_PA_FORMAT: \ 336 case Format_400P 337 338 #define IS_RGB64_FLOAT_FORMAT(format) \ 339 ( (format == Format_A16B16G16R16F) || \ 340 (format == Format_A16R16G16B16F) ) 341 342 #define IS_RGB64_FORMAT(format) \ 343 ( (format == Format_A16B16G16R16) || \ 344 (format == Format_A16R16G16B16)) 345 346 #define IS_RGB32_FORMAT(format) \ 347 ( (format == Format_A8R8G8B8) || \ 348 (format == Format_X8R8G8B8) || \ 349 (format == Format_A8B8G8R8) || \ 350 (format == Format_X8B8G8R8) || \ 351 (format == Format_R10G10B10A2) || \ 352 (format == Format_B10G10R10A2) || \ 353 (format == Format_RGB32) ) 354 355 #define IS_RGB16_FORMAT(format) \ 356 (format == Format_R5G6B5) 357 358 #define IS_RGB24_FORMAT(format) \ 359 (format == Format_R8G8B8) 360 361 #define IS_RGB_FORMAT(format) \ 362 ( IS_RGB64_FORMAT(format) || \ 363 IS_RGB32_FORMAT(format) || \ 364 IS_RGB16_FORMAT(format) || \ 365 IS_RGB24_FORMAT(format) || \ 366 IS_PL3_RGB_FORMAT(format) || \ 367 (format == Format_RGB) || \ 368 IS_RGB64_FLOAT_FORMAT(format) ) 369 370 #define IS_RGB_NO_SWAP(format) \ 371 ( (format == Format_A8B8G8R8) || \ 372 (format == Format_X8B8G8R8) || \ 373 (format == Format_A16B16G16R16) || \ 374 (format == Format_A16B16G16R16F) || \ 375 (format == Format_R32G32B32A32F) || \ 376 (format == Format_R10G10B10A2) ) 377 378 #define IS_RGB_SWAP(format) \ 379 ( IS_RGB_FORMAT(format) && \ 380 !(IS_RGB_NO_SWAP(format)) ) 381 382 #define IS_RGB128_FORMAT(format) \ 383 (format == Format_R32G32B32A32F) 384 385 #define CASE_RGB32_FORMAT \ 386 case Format_A8R8G8B8: \ 387 case Format_X8R8G8B8: \ 388 case Format_A8B8G8R8: \ 389 case Format_X8B8G8R8: \ 390 case Format_R10G10B10A2: \ 391 case Format_B10G10R10A2: \ 392 case Format_RGB32 393 394 #define CASE_RGB24_FORMAT \ 395 case Format_R8G8B8 396 397 #define CASE_RGB16_FORMAT \ 398 case Format_R5G6B5 399 400 #define CASE_RGB_FORMAT \ 401 CASE_RGB32_FORMAT: \ 402 CASE_RGB24_FORMAT: \ 403 CASE_RGB16_FORMAT: \ 404 CASE_PL3_RGB_FORMAT: \ 405 case Format_RGB 406 407 #define IS_BT601_CSPACE(format) \ 408 ( (format == CSpace_BT601) || \ 409 (format == CSpace_xvYCC601) || \ 410 (format == CSpace_BT601Gray) || \ 411 (format == CSpace_BT601_FullRange) || \ 412 (format == CSpace_BT601Gray_FullRange) ) 413 414 #define IS_BT709_CSPACE(format) \ 415 ( (format == CSpace_BT709) || \ 416 (format == CSpace_xvYCC709) || \ 417 (format == CSpace_BT709_FullRange) ) 418 419 #define IS_YUV_CSPACE_FULLRANGE(format) \ 420 ( (format == CSpace_BT601_FullRange) || \ 421 (format == CSpace_BT601Gray_FullRange) || \ 422 (format == CSpace_BT709_FullRange) ) 423 424 #define CASE_YUV_CSPACE_FULLRANGE \ 425 case CSpace_BT601_FullRange: \ 426 case CSpace_BT601Gray_FullRange: \ 427 case CSpace_BT709_FullRange 428 429 #define CASE_YUV_CSPACE_LIMITEDRANGE \ 430 case CSpace_BT601: \ 431 case CSpace_BT601Gray: \ 432 case CSpace_xvYCC601: \ 433 case CSpace_BT709: \ 434 case CSpace_xvYCC709 435 436 #define IS_RGB_CSPACE_FULLRANGE(format) \ 437 ( (format == CSpace_sRGB) ) 438 439 #define IS_YUV_CSPACE(format) \ 440 ( IS_BT601_CSPACE(format) || \ 441 IS_BT709_CSPACE(format) ) 442 443 #define IS_RGB_CSPACE(format) \ 444 ( (format == CSpace_sRGB) || \ 445 (format == CSpace_stRGB) ) 446 447 #define IS_BAYER16_FORMAT(format) \ 448 ( (format == Format_IRW0) || \ 449 (format == Format_IRW1) || \ 450 (format == Format_IRW2) || \ 451 (format == Format_IRW3) ) 452 453 #define CASE_BAYER16_FORMAT \ 454 case Format_IRW0: \ 455 case Format_IRW1: \ 456 case Format_IRW2: \ 457 case Format_IRW3 458 459 #define IS_BAYER8_FORMAT(format) \ 460 ( (format == Format_IRW4) || \ 461 (format == Format_IRW5) || \ 462 (format == Format_IRW6) || \ 463 (format == Format_IRW7) ) 464 465 #define CASE_BAYER8_FORMAT \ 466 case Format_IRW4: \ 467 case Format_IRW5: \ 468 case Format_IRW6: \ 469 case Format_IRW7 470 471 #define IS_BAYER_FORMAT(format) \ 472 ( IS_BAYER16_FORMAT(format) || \ 473 IS_BAYER8_FORMAT(format) ) 474 475 #define IS_BAYER_GRBG_FORMAT(format) \ 476 ( (format == Format_IRW2) || \ 477 (format == Format_IRW6) ) 478 479 #define IS_BAYER_GBRG_FORMAT(format) \ 480 ( (format == Format_IRW3) || \ 481 (format == Format_IRW7) ) 482 483 //! 484 //! \brief Tiling Enumeration, match GFX3DSTATE_TILEWALK 485 //! 486 #define MOS_YTILE_H_ALIGNMENT 32 // For Tile-Y and Tile-Yf 487 #define MOS_YTILE_W_ALIGNMENT 128 488 #define MOS_XTILE_H_ALIGNMENT 8 489 #define MOS_XTILE_W_ALIGNMENT 512 490 #define MOS_YSTILE_H_ALIGNMENT 256 // For Tile-Ys 491 #define MOS_YSTILE_W_ALIGNMENT 256 492 493 //! 494 //! \brief Enum for tile type 495 //! 496 typedef enum _MOS_TILE_TYPE 497 { 498 MOS_TILE_X, 499 MOS_TILE_Y, 500 MOS_TILE_YF, // 4KB tile 501 MOS_TILE_YS, // 64KB tile 502 MOS_TILE_LINEAR, 503 MOS_TILE_INVALID 504 } MOS_TILE_TYPE; 505 C_ASSERT(MOS_TILE_LINEAR == 4); //!< When adding, update assert 506 507 //! 508 //! \brief Enum for tile mode from GMM 509 //! 510 typedef enum _MOS_TILE_MODE_GMM : uint8_t 511 { 512 MOS_TILE_LINEAR_GMM = 0, 513 MOS_TILE_64_GMM, 514 MOS_TILE_X_GMM, 515 MOS_TILE_4_GMM, 516 MOS_TILE_UNSET_GMM 517 } MOS_TILE_MODE_GMM; 518 C_ASSERT(MOS_TILE_4_GMM == 3); 519 520 #define IS_TILE_FORMAT(TileType) \ 521 ( (MOS_TILE_X == TileType) || \ 522 (MOS_TILE_Y == TileType) || \ 523 (MOS_TILE_YF == TileType) || \ 524 (MOS_TILE_YS == TileType) ) 525 526 #define IS_Y_MAJOR_TILE_FORMAT(TileType) \ 527 ( (MOS_TILE_Y == TileType) || \ 528 (MOS_TILE_YF == TileType) || \ 529 (MOS_TILE_YS == TileType) ) 530 531 //! 532 //! \brief Structure to resource type 533 //! 534 typedef enum _MOS_GFXRES_TYPE 535 { 536 MOS_GFXRES_INVALID = -1, 537 MOS_GFXRES_BUFFER, //!< Think malloc. This resource is a series of bytes. Is not 2 dimensional. 538 MOS_GFXRES_2D, //!< 2 dimensional resource w/ width and height. 1D is a subset of 2D. 539 MOS_GFXRES_VOLUME, //!< 3 dimensional resource w/ depth. 540 MOS_GFXRES_SCRATCH, //!< scratch space buffer. 541 } MOS_GFXRES_TYPE; 542 543 //! 544 //! \brief Enum for Memory Compression Mode 545 //! 546 typedef enum _MOS_RESOURCE_MMC_MODE 547 { 548 MOS_MMC_DISABLED, 549 MOS_MMC_HORIZONTAL, 550 MOS_MMC_VERTICAL, 551 MOS_MMC_MC, 552 MOS_MMC_RC 553 } MOS_RESOURCE_MMC_MODE; 554 555 enum Mos_MemPool 556 { 557 MOS_MEMPOOL_VIDEOMEMORY, //Default setting, Resource will be in video memory 558 MOS_MEMPOOL_DEVICEMEMORY, //Resource will be in device video memory 559 MOS_MEMPOOL_SYSTEMMEMORY //Resource will be in system video memory 560 }; 561 562 #endif //__MOS_RESOURCE_DEFS_H__ 563