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 ,
164     Format_B10G10R10A2 ,
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     // Last Format
189     Format_Count
190 } MOS_FORMAT, *PMOS_FORMAT;
191 C_ASSERT(Format_Count == 103); //!< When adding, update assert & vphal_solo_scenario.cpp::VpFromXml_GetFormat() & hal_kerneldll.c::g_cIsFormatYUV.
192 
193 //!
194 //! \brief Macros for format checking
195 //!
196 #define IS_PAL_FORMAT(format)            \
197             ( (format == Format_AI44) || \
198               (format == Format_IA44) || \
199               (format == Format_P8)   || \
200               (format == Format_A8P8))
201 
202 #define CASE_PAL_FORMAT  \
203     case Format_AI44:    \
204     case Format_IA44:    \
205     case Format_P8:      \
206     case Format_A8P8
207 
208 #define IS_ALPHA4_FORMAT(format)         \
209             ( (format == Format_AI44) || \
210               (format == Format_IA44) )
211 
212 #define IS_ALPHA_FORMAT(format)                   \
213             ( (format == Format_A8R8G8B8)      || \
214               (format == Format_A8B8G8R8)      || \
215               (format == Format_R10G10B10A2)   || \
216               (format == Format_B10G10R10A2)   || \
217               (format == Format_A16B16G16R16)  || \
218               (format == Format_A16R16G16B16)  || \
219               (format == Format_A16B16G16R16F) || \
220               (format == Format_A16R16G16B16F) || \
221               (format == Format_Y410)          || \
222               (format == Format_Y416)          || \
223               (format == Format_AYUV) )
224 
225 #define IS_PL2_FORMAT(format)            \
226             ( (format == Format_PL2)  || \
227               (format == Format_NV12) || \
228               (format == Format_NV21) || \
229               (format == Format_NV11) || \
230               (format == Format_P208) || \
231               (format == Format_P010) || \
232               (format == Format_P016) )
233 
234 #define IS_PL2_FORMAT_UnAligned(format)    \
235             ( (format == Format_PL2_UnAligned)  || \
236               (format == Format_NV12_UnAligned) || \
237               (format == Format_NV11_UnAligned) || \
238               (format == Format_P208_UnAligned) )
239 
240 #define CASE_PL2_FORMAT  \
241     case Format_PL2:     \
242     case Format_NV12:    \
243     case Format_NV21:    \
244     case Format_NV11:    \
245     case Format_P208:    \
246     case Format_P010:    \
247     case Format_P016
248 
249 #define IS_PL3_FORMAT(format)            \
250             ( (format == Format_PL3)  || \
251               (format == Format_IMC1) || \
252               (format == Format_IMC2) || \
253               (format == Format_IMC3) || \
254               (format == Format_IMC4) || \
255               (format == Format_I420) || \
256               (format == Format_IYUV) || \
257               (format == Format_YV12) || \
258               (format == Format_YVU9) || \
259               (format == Format_422H) || \
260               (format == Format_422V) || \
261               (format == Format_411P) || \
262               (format == Format_411R) || \
263               (format == Format_444P) )
264 
265 #define IS_PL3_RGB_FORMAT(format)        \
266             ( (format == Format_RGBP) || \
267               (format == Format_BGRP) )
268 
269 #define CASE_PL3_FORMAT  \
270     case Format_PL3:     \
271     case Format_IMC1:    \
272     case Format_IMC2:    \
273     case Format_IMC3:    \
274     case Format_IMC4:    \
275     case Format_I420:    \
276     case Format_IYUV:    \
277     case Format_YV12:    \
278     case Format_YVU9:    \
279     case Format_422H:    \
280     case Format_422V:    \
281     case Format_411P:    \
282     case Format_411R:    \
283     case Format_444P
284 
285 #define CASE_PL3_RGB_FORMAT  \
286     case Format_RGBP:        \
287     case Format_BGRP
288 
289 #define IS_PA_FORMAT(format)             \
290             ( (format == Format_PA)   || \
291               (format == Format_YUY2) || \
292               (format == Format_YUYV) || \
293               (format == Format_YVYU) || \
294               (format == Format_UYVY) || \
295               (format == Format_VYUY) || \
296               (format == Format_Y210) || \
297               (format == Format_Y216) || \
298               (format == Format_Y410) || \
299               (format == Format_Y416) )
300 
301 #define CASE_PA_FORMAT    \
302     case Format_PA:       \
303     case Format_YUY2:     \
304     case Format_YUYV:     \
305     case Format_YVYU:     \
306     case Format_UYVY:     \
307     case Format_VYUY
308 
309 #define IS_YUV_FORMAT(format)              \
310           ( IS_PL2_FORMAT(format)       || \
311             IS_PL3_FORMAT(format)       || \
312             IS_PA_FORMAT(format)        || \
313             (format == Format_400P) )
314 
315 #define IS_ALPHA_YUV_FORMAT(format)        \
316           ( (format == Format_AYUV)     || \
317             (format == Format_AUYV) )
318 
319 #define CASE_YUV_FORMAT  \
320     CASE_PL2_FORMAT:     \
321     CASE_PL3_FORMAT:     \
322     CASE_PA_FORMAT:      \
323     case Format_400P
324 
325 #define IS_RGB64_FLOAT_FORMAT(format)             \
326             ( (format == Format_A16B16G16R16F) || \
327               (format == Format_A16R16G16B16F) )
328 
329 #define IS_RGB64_FORMAT(format)                  \
330             ( (format == Format_A16B16G16R16) || \
331               (format == Format_A16R16G16B16))
332 
333 #define IS_RGB32_FORMAT(format)                  \
334             ( (format == Format_A8R8G8B8)     || \
335               (format == Format_X8R8G8B8)     || \
336               (format == Format_A8B8G8R8)     || \
337               (format == Format_X8B8G8R8)     || \
338               (format == Format_R10G10B10A2)  || \
339               (format == Format_B10G10R10A2)  || \
340               (format == Format_RGB32) )
341 
342 #define IS_RGB16_FORMAT(format)              \
343             (format == Format_R5G6B5)
344 
345 #define IS_RGB24_FORMAT(format)              \
346             (format == Format_R8G8B8)
347 
348 #define IS_RGB_FORMAT(format)              \
349             ( IS_RGB64_FORMAT(format)   || \
350               IS_RGB32_FORMAT(format)   || \
351               IS_RGB16_FORMAT(format)   || \
352               IS_RGB24_FORMAT(format)   || \
353               IS_PL3_RGB_FORMAT(format) || \
354               (format == Format_RGB)    || \
355               IS_RGB64_FLOAT_FORMAT(format) )
356 
357 #define IS_RGB_NO_SWAP(format)                    \
358             ( (format == Format_A8B8G8R8)      || \
359               (format == Format_X8B8G8R8)      || \
360               (format == Format_A16B16G16R16)  || \
361               (format == Format_A16B16G16R16F) || \
362               (format == Format_R32G32B32A32F) || \
363               (format == Format_R10G10B10A2) )
364 
365 #define IS_RGB_SWAP(format)                  \
366             ( IS_RGB_FORMAT(format)       && \
367               !(IS_RGB_NO_SWAP(format)) )
368 
369 #define IS_RGB128_FORMAT(format)             \
370               (format == Format_R32G32B32A32F)
371 
372 #define CASE_RGB32_FORMAT    \
373     case Format_A8R8G8B8:    \
374     case Format_X8R8G8B8:    \
375     case Format_A8B8G8R8:    \
376     case Format_X8B8G8R8:    \
377     case Format_R10G10B10A2: \
378     case Format_B10G10R10A2: \
379     case Format_RGB32
380 
381 #define CASE_RGB24_FORMAT \
382         case Format_R8G8B8
383 
384 #define CASE_RGB16_FORMAT \
385     case Format_R5G6B5
386 
387 #define CASE_RGB_FORMAT   \
388     CASE_RGB32_FORMAT:    \
389     CASE_RGB24_FORMAT:    \
390     CASE_RGB16_FORMAT:    \
391     CASE_PL3_RGB_FORMAT:  \
392     case Format_RGB
393 
394 #define IS_BT601_CSPACE(format)                     \
395         ( (format == CSpace_BT601)               || \
396           (format == CSpace_xvYCC601)            || \
397           (format == CSpace_BT601Gray)           || \
398           (format == CSpace_BT601_FullRange)     || \
399           (format == CSpace_BT601Gray_FullRange) )
400 
401 #define IS_BT709_CSPACE(format)                     \
402         ( (format == CSpace_BT709)               || \
403           (format == CSpace_xvYCC709)            || \
404           (format == CSpace_BT709_FullRange) )
405 
406 #define IS_YUV_CSPACE_FULLRANGE(format)             \
407         ( (format == CSpace_BT601_FullRange)     || \
408           (format == CSpace_BT601Gray_FullRange) || \
409           (format == CSpace_BT709_FullRange) )
410 
411 #define CASE_YUV_CSPACE_FULLRANGE                   \
412     case CSpace_BT601_FullRange:                    \
413     case CSpace_BT601Gray_FullRange:                \
414     case CSpace_BT709_FullRange
415 
416 #define CASE_YUV_CSPACE_LIMITEDRANGE                \
417     case CSpace_BT601:                              \
418     case CSpace_BT601Gray:                          \
419     case CSpace_xvYCC601:                           \
420     case CSpace_BT709:                              \
421     case CSpace_xvYCC709
422 
423 #define IS_RGB_CSPACE_FULLRANGE(format)             \
424         ( (format == CSpace_sRGB) )
425 
426 #define IS_YUV_CSPACE(format)                       \
427         ( IS_BT601_CSPACE(format)                || \
428           IS_BT709_CSPACE(format) )
429 
430 #define IS_RGB_CSPACE(format)                       \
431         ( (format == CSpace_sRGB)                || \
432           (format == CSpace_stRGB) )
433 
434 #define IS_BAYER16_FORMAT(format)          \
435             ( (format == Format_IRW0)   || \
436               (format == Format_IRW1)   || \
437               (format == Format_IRW2)   || \
438               (format == Format_IRW3) )
439 
440 #define CASE_BAYER16_FORMAT \
441     case Format_IRW0:       \
442     case Format_IRW1:       \
443     case Format_IRW2:       \
444     case Format_IRW3
445 
446 #define IS_BAYER8_FORMAT(format)           \
447             ( (format == Format_IRW4)   || \
448               (format == Format_IRW5)   || \
449               (format == Format_IRW6)   || \
450               (format == Format_IRW7) )
451 
452 #define CASE_BAYER8_FORMAT  \
453     case Format_IRW4:       \
454     case Format_IRW5:       \
455     case Format_IRW6:       \
456     case Format_IRW7
457 
458 #define IS_BAYER_FORMAT(format)            \
459             ( IS_BAYER16_FORMAT(format) || \
460               IS_BAYER8_FORMAT(format) )
461 
462 #define IS_BAYER_GRBG_FORMAT(format)       \
463             ( (format == Format_IRW2)   || \
464               (format == Format_IRW6) )
465 
466 #define IS_BAYER_GBRG_FORMAT(format)       \
467             ( (format == Format_IRW3)   || \
468               (format == Format_IRW7) )
469 
470 //!
471 //! \brief Tiling Enumeration, match GFX3DSTATE_TILEWALK
472 //!
473 #define MOS_YTILE_H_ALIGNMENT  32         // For Tile-Y and Tile-Yf
474 #define MOS_YTILE_W_ALIGNMENT  128
475 #define MOS_XTILE_H_ALIGNMENT  8
476 #define MOS_XTILE_W_ALIGNMENT  512
477 #define MOS_YSTILE_H_ALIGNMENT 256        // For Tile-Ys
478 #define MOS_YSTILE_W_ALIGNMENT 256
479 
480 //!
481 //! \brief Enum for tile type
482 //!
483 typedef enum _MOS_TILE_TYPE
484 {
485     MOS_TILE_X,
486     MOS_TILE_Y,
487     MOS_TILE_YF,            // 4KB tile
488     MOS_TILE_YS,            // 64KB tile
489     MOS_TILE_LINEAR,
490     MOS_TILE_INVALID
491 } MOS_TILE_TYPE;
492 C_ASSERT(MOS_TILE_LINEAR == 4); //!< When adding, update assert
493 
494 //!
495 //! \brief Enum for tile mode from GMM
496 //!
497 typedef enum _MOS_TILE_MODE_GMM : uint8_t
498 {
499     MOS_TILE_LINEAR_GMM = 0,
500     MOS_TILE_64_GMM,
501     MOS_TILE_X_GMM,
502     MOS_TILE_4_GMM,
503     MOS_TILE_UNSET_GMM
504 } MOS_TILE_MODE_GMM;
505 C_ASSERT(MOS_TILE_4_GMM == 3);
506 
507 #define IS_TILE_FORMAT(TileType)              \
508             ( (MOS_TILE_X  == TileType) ||    \
509               (MOS_TILE_Y  == TileType) ||    \
510               (MOS_TILE_YF == TileType) ||    \
511               (MOS_TILE_YS == TileType) )
512 
513 #define IS_Y_MAJOR_TILE_FORMAT(TileType)      \
514             ( (MOS_TILE_Y  == TileType) ||    \
515               (MOS_TILE_YF == TileType) ||    \
516               (MOS_TILE_YS == TileType) )
517 
518 //!
519 //! \brief Structure to resource type
520 //!
521 typedef enum _MOS_GFXRES_TYPE
522 {
523     MOS_GFXRES_INVALID = -1,
524     MOS_GFXRES_BUFFER,  //!< Think malloc. This resource is a series of bytes. Is not 2 dimensional.
525     MOS_GFXRES_2D,      //!< 2 dimensional resource w/ width and height. 1D is a subset of 2D.
526     MOS_GFXRES_VOLUME,  //!< 3 dimensional resource w/ depth.
527     MOS_GFXRES_SCRATCH, //!< scratch space buffer.
528 } MOS_GFXRES_TYPE;
529 
530 //!
531 //! \brief Enum for Memory Compression Mode
532 //!
533 typedef enum _MOS_RESOURCE_MMC_MODE
534 {
535     MOS_MMC_DISABLED,
536     MOS_MMC_HORIZONTAL,
537     MOS_MMC_VERTICAL,
538     MOS_MMC_MC,
539     MOS_MMC_RC
540 } MOS_RESOURCE_MMC_MODE;
541 
542 enum Mos_MemPool
543 {
544     MOS_MEMPOOL_VIDEOMEMORY,            //Default setting, Resource will be in video memory
545     MOS_MEMPOOL_DEVICEMEMORY,           //Resource will be in device video memory
546     MOS_MEMPOOL_SYSTEMMEMORY            //Resource will be in system video memory
547 };
548 
549 #endif //__MOS_RESOURCE_DEFS_H__
550