Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * All Video Processing kernels
  3.  * Copyright © <2010>, Intel Corporation.
  4.  *
  5.  * This program is licensed under the terms and conditions of the
  6.  * Eclipse Public License (EPL), version 1.0.  The full text of the EPL is at
  7.  * http://www.opensource.org/licenses/eclipse-1.0.php.
  8.  *
  9.  */
  10.  
  11. #ifndef COMMON_INC
  12. #define COMMON_INC
  13.  
  14. // Module name: common.inc
  15. //
  16. // Common header file for all Video-Processing kernels
  17. //
  18.  
  19. .default_execution_size (16)
  20. .default_register_type  :ub
  21.  
  22. .reg_count_total        80
  23. .reg_count_payload      4
  24.  
  25.  
  26. //========== Common constants ==========
  27.  
  28. // Bit position constants
  29. #define BIT0    0x01
  30. #define BIT1    0x02
  31. #define BIT2    0x04
  32. #define BIT3    0x08
  33. #define BIT4    0x10
  34. #define BIT5    0x20
  35. #define BIT6    0x40
  36. #define BIT7    0x80
  37. #define BIT8    0x0100
  38. #define BIT9    0x0200
  39. #define BIT10   0x0400
  40. #define BIT11   0x0800
  41. #define BIT12   0x1000
  42. #define BIT13   0x2000
  43. #define BIT14   0x4000
  44. #define BIT15   0x8000
  45. #define BIT16   0x00010000
  46. #define BIT17   0x00020000
  47. #define BIT18   0x00040000
  48. #define BIT19   0x00080000
  49. #define BIT20   0x00100000
  50. #define BIT21   0x00200000
  51. #define BIT22   0x00400000
  52. #define BIT23   0x00800000
  53. #define BIT24   0x01000000
  54. #define BIT25   0x02000000
  55. #define BIT26   0x04000000
  56. #define BIT27   0x08000000
  57. #define BIT28   0x10000000
  58. #define BIT29   0x20000000
  59. #define BIT30   0x40000000
  60. #define BIT31   0x80000000
  61.  
  62. #define nGRFWIB             32      // GRF register width in byte
  63. #define nGRFWIW             16      // GRF register width in word
  64. #define nGRFWID             8       // GRF register width in dword
  65.  
  66. #define nTOP_FIELD          0
  67. #define nBOTTOM_FIELD       1
  68.  
  69. #define nPREVIOUS_FRAME     0       // Previous frame
  70. #define nCURRENT_FRAME      1       // Current frame
  71. #define nNEXT_FRAME         2       // Next frame
  72.  
  73. #ifdef GT
  74. // GT DI Kernel
  75. #else // ILK
  76. // ILK DI Kernel
  77. #endif
  78.  
  79. //===================================
  80.  
  81. //========== Macros ==========
  82. #define REGION(Width,HStride) <Width*HStride;Width,HStride> // Region definition when ExecSize = Width
  83.  
  84. #define RegFile(a) a
  85. #define REG(r,n) _REG(RegFile(r),n)
  86. #define _REG(r,n) __REG(r,n)
  87. #define __REG(r,n) r##n.0
  88. #define REG2(r,n,s) _REG2(RegFile(r),n,s)
  89. #define _REG2(r,n,s) __REG2(r,n,s)
  90. #define __REG2(r,n,s) r##n.##s
  91.  
  92. #define dNULLREG     null<1>:d
  93. #define wNULLREG     null<1>:w
  94.    
  95. #define KERNEL_ID(kernel_ID)    mov NULLREG kernel_ID:ud
  96.  
  97.  
  98. #define NODDCLR                        
  99. #define NODDCLR_NODDCHK        
  100. #define NODDCHK                    
  101.  
  102. //#define NODDCLR                       { NoDDClr }
  103. //#define NODDCLR_NODDCHK       { NoDDClr, NoDDChk }
  104. //#define NODDCHK                               { NoDDChk }
  105.  
  106.  
  107. //========== Defines ====================
  108.  
  109.  
  110. //========== GRF partition ==========
  111. // r0 header            :   r0          (1 GRF)
  112. // Static parameters    :   r1 - r5     (5 GRFS)
  113. // Inline parameters    :   r6 - r7     (2 GRFs)
  114. // MSGSRC               :   r9          (1 GRF)
  115. // Top IO region        :   r10 - r33   (24 GRFS 8 for each component Y,U,V 16X8:w)
  116. // Free space           :   r34 - r55   (22 GRFS)
  117. // Bottom IO region     :   r56 - r79   (24 GRFS 8 for each component Y,U,V 16X8:w)
  118. //===================================
  119.  
  120.  
  121. //========== Static Parameters ==========
  122. // r1
  123. #define fPROCAMP_C0             r1.0    // DWORD 0, Procamp constant C0 in :f
  124. #define wPROCAMP_C0             r1.0    // DWORD 0, Procamp constant C0 in :w
  125. #define NUMBER_0002                                                     r1.1            // DWORD 0, 0x0002 used in procamp for GT
  126. #define udCP_MessageFormat      r1.0    // DWORD 0, bits 2:3 of DWORD. (CE)
  127. #define udCP_StatePointer       r1.0    // DWORD 0, bits 31:5 of DWORD.(CE)
  128.  
  129. #define ubSRC_CF_OFFSET         r1.4    // DWORD 1, byte 0-2. SRC packed color format YUV offset in :ub
  130.  
  131. #define ubDEST_RGB_FORMAT        r1.8    // DWORD 2, byte 0. Dest RGB color format (0:ARGB FF:XRGB)
  132. #define ubDEST_CF_OFFSET        r1.8    // DWORD 2, byte 0-2. Dest packed color format YUV offset in :ub
  133.  
  134. #define fPROCAMP_C1             r1.3    // DWORD 3, Procamp constant C1 in :f  
  135. #define wPROCAMP_C1             r1.6    // DWORD 3, Procamp constant C1 in :w  
  136. #define NUMBER_0100                                                     r1.7            // DWORD 3, 0x0100 used in procamp for GT
  137.  
  138. #define fPROCAMP_C2             r1.4    // DWORD 4, Procamp constant C2 in :f
  139. #define wPROCAMP_C2             r1.8    // DWORD 4, Procamp constant C2 in :w
  140.  
  141. #define uwSPITCH_DIV2           r1.10   // DWORD 5, byte 0-1. statistics surface pitch divided by 2
  142.  
  143. #define fVIDEO_STEP_Y           r1.6    // DWORD 6, :f, AVS normalized reciprocal of Y Scaling factor
  144. #define ubSTMM_SHIFT            r1.24   // DWORD 6, byte 0. Amount of right shift for the DI blending equation
  145. #define ubSTMM_MIN              r1.25   // DWORD 6, byte 1. Min STMM for DI blending equation
  146. #define ubSTMM_MAX              r1.26   // DWORD 6, byte 2. Max STMM for DI blending equation
  147. #define ubTFLD_FIRST            r1.27   // DWORD 6, byte 3. Field parity order
  148.  
  149. #define fPROCAMP_C5             r1.7    // DWORD 7, Procamp constant C3 in :f
  150. #define wPROCAMP_C5             r1.14   // DWORD 7, Procamp constant C3 in :w
  151.  
  152. // r2
  153. #define fPROCAMP_C3             r2.0    // DWORD 0, Procamp constant C4 in :f
  154. #define wPROCAMP_C3             r2.0    // DWORD 0, Procamp constant C4 in :w
  155.                    
  156. #define fCSC_C5                                 r2.2    // DWORD 2. WG+CSC constant C5
  157. #define wCSC_C5                                 r2.4    // DWORD 2. WG+CSC constant C5
  158.  
  159. #define fPROCAMP_C4             r2.3    // DWORD 3, Procamp constant C5 in :f
  160. #define wPROCAMP_C4             r2.6    // DWORD 3, Procamp constant C5 in :w
  161.  
  162. #define fCSC_C8                                 r2.4    // DWORD 4. WG+CSC constant C8
  163. #define wCSC_C8                                 r2.8    // DWORD 4. WG+CSC constant C8
  164. #define fCSC_C9                                 r2.7    // DWORD 7. WG+CSC constant C9
  165. #define wCSC_C9                                 r2.14   // DWORD 7. WG+CSC constant C9
  166.  
  167. // r3
  168. #define fCSC_C0                                 r3.0    // DWORD 0. WG+CSC constant C0
  169. #define wCSC_C0                                 r3.0    // DWORD 0. WG+CSC constant C0
  170.  
  171. #define fSCALING_STEP_RATIO     r3.1    // DWORD 1, = Alpha_X_Scaling_Step / Video_X_scaling_Step :f (blending)
  172. #define fALPHA_STEP_X           r3.1    // DWORD 1, = 1/Scale X, 0.5 = 2x, in :f (blending)
  173.  
  174. #define fALPHA_STEP_Y           r3.2    // DWORD 2, = 1/Scale Y, in :f
  175.  
  176. #define fCSC_C4                                 r3.3    // DWORD 3. WG+CSC constant C4
  177. #define wCSC_C4                                 r3.6    // DWORD 3. WG+CSC constant C4
  178. #define fCSC_C1                                 r3.4    // DWORD 4. WG+CSC constant C1
  179. #define wCSC_C1                                 r3.8    // DWORD 4. WG+CSC constant C1
  180.  
  181. #define wSRC_H_ORI_OFFSET       r3.10   // DWORD 5, bytes 0,1 :w    
  182. #define wSRC_V_ORI_OFFSET       r3.11   // DWORD 5, bytes 2,3 :w
  183.  
  184. #define dCOLOR_PIXEL            r3.6    // DWORD 6. Color pixel for Colorfill
  185.  
  186. #define fCSC_C2                                 r3.6    // DWORD 6. WG+CSC constant C2
  187. #define wCSC_C2                                 r3.12   // DWORD 6. WG+CSC constant C2
  188. #define fCSC_C3                                 r3.7    // DWORD 7. WG+CSC constant C3
  189. #define wCSC_C3                                 r3.14   // DWORD 7. WG+CSC constant C3
  190.  
  191. // r4
  192. #define fCSC_C6                                 r4.0    // DWORD 0. WG+CSC constant C6
  193. #define wCSC_C6                                 r4.0    // DWORD 0. WG+CSC constant C6
  194.  
  195. #define wFRAME_ENDX             r4.2    // DWORD 1, word 0. Horizontal end = Origin+Width (in pixels)(for multiple blocks)
  196. #define wNUM_BLKS               r4.3    // DWORD 1, word 1. Number of blocks to process (for multiple blocks)
  197.  
  198. #define wCOPY_ORIX              r4.5    // DWORD 2, word 1. A copy of X origin (for multiple blocks)
  199. #define uwNLAS_ENABLE           r4.4    // DWORD 2, bit 15, NLAS enble bit
  200.  
  201. #define fCSC_C7                                 r4.3    // DWORD 3. WG+CSC constant C7
  202. #define wCSC_C7                                 r4.6    // DWORD 3. WG+CSC constant C7
  203. #define fCSC_C10                                r4.4    // DWORD 4. WG+CSC constant C10
  204. #define wCSC_C10                                r4.8    // DWORD 4. WG+CSC constant C10
  205.  
  206. #define fFRAME_VID_ORIX         r4.5    // DWORD 5, Frame horizontal origin normalized for scale kernel
  207.  
  208. #define fFRAME_ALPHA_ORIX       r4.6    // DWORD 6. Normalized alpha horiz origin for the frame
  209.  
  210. #define fCSC_C11                                r4.7    // DWORD 7. WG+CSC constant C11
  211. #define wCSC_C11                                r4.14   // DWORD 7. WG+CSC constant C11
  212.  
  213. //========================================
  214.  
  215. //========== Inline parameters ===========
  216. // r5
  217. #define wORIX                   r5.0    // DWORD 0, byte 0-1. :w, Destination Block Horizontal Origin in pel
  218. #define wORIY                   r5.1    // DWORD 0, byte 2-3. :w, Destination Block Vertical   Origin in pel
  219.  
  220. #define fSRC_VID_H_ORI          r5.1    // DWORD 1, :f, SRC Y horizontal origin normalized for scale kernel
  221.  
  222. #define fSRC_VID_V_ORI          r5.2    // DWORD 2, :f, SRC Y vertical origin normalized for scale kernel
  223.  
  224. #define fSRC_ALPHA_H_ORI        r5.3    // DWORD 3, :f, Normalized alpha horizontal origin
  225.  
  226. #define fSRC_ALPHA_V_ORI        r5.4    // DWORD 4, :f, Normalized alpha vertical origin
  227.  
  228. #define uwALPHA_MASK_X          r5.10   // DWORD 5, byte 0-1 :w, H. alpha mask
  229. #define ubALPHA_MASK_Y          r5.22   // DWORD 5, byte 2.  :ub,V. alpha mask
  230. #define ubBLK_CNT_X             r5.23   // DWORD 5, byte 3,  :ub, Horizontal Block Count per thread
  231.  
  232. // mask is used for each block. it will be reloaded from r6 below for the last block.
  233. #define udBLOCK_MASK            r5.6    // DWORD 6
  234. #define uwBLOCK_MASK_H          r5.12   // DWORD 6, byte 0-1 :uw, Block horizontal mask used in non-DWord aligned kernels
  235. #define ubBLOCK_MASK_V          r5.26   // DWORD 6, byte 2   :ub, Block vertical mask used in non-DWord aligned kernels
  236. #define ubNUM_BLKS              r5.27   // DWORD 6, byte 3,  :ub, Total Block Count per thread
  237.  
  238. #define fVIDEO_STEP_X           r5.7    // DWORD 7. :f, AVS normalized reciprocal of X Scaling factor
  239.  
  240. // r6
  241. #define fVIDEO_STEP_DELTA       r6.0    // DWORD 0. :f, AVS normalized delta between 2 adjacent scaling steps (used for non-linear scaling)
  242.  
  243. // mask is used for the last block (assume only M*1 and 1*N block partation aer supported)
  244. #define udBLOCK_MASK_2            r6.1    // DWORD 1
  245. #define uwBLOCK_MASK_H_RIGHT      r6.2    // DWORD 1, byte 0-1 :uw, Block horizontal mask used in non-DWord aligned kernels (right)
  246. #define ubBLOCK_MASK_V_BOTTOM     r6.6    // DWORD 1, byte 2   :ub, Block vertical mask used in non-DWord aligned kernels
  247. #define uwBLOCK_MASK_H_MIDDLE     r6.4    // DWORD 2, byte 0-1 :uw, Block horizontal mask used in non-DWord aligned kernels (left)
  248.  
  249.  
  250. //====================== Binding table =========================================
  251.  
  252. #if defined(DNDI)
  253.     // DNDI Surface Binding Table
  254.     //#define nBI_SRC_CURR        0       // Current input frame surface
  255.     //#define nBI_SRC_PRIV        1       // Denoised previous input frame surface
  256.     //#define nBI_SRC_STAT        2       // Statistics input surface (STMM / Noise motion history)
  257.     //#define nBI_DEST_1ST        3       // 1st deinterlaced output frame surface
  258. //    #define nBI_DEST_YUV        3       // Dest frame YUV (for DN only)
  259.     //#define nBI_DEST_Y          3       // Dest frame Y (for DN only)
  260.     //#define nBI_DEST_2ND        4       // 2nd deinterlaced output frame surface
  261.     //#define nBI_DEST_DN_CURR    6       // Denoised current output frame surface
  262.     //#define nBI_DEST_STAT       7       // Statistics output surface (STMM / Noise motion history)
  263. //    #define nBI_DEST_U          8       // Dest frame U (for DN only)
  264. //    #define nBI_DEST_V          9       // Dest frame V (for DN only)
  265. //    #define nBI_SRC_U          10       // Src frame U (for DN only)
  266. //    #define nBI_SRC_V          11       // Src frame V (for DN only)
  267. //    #define nBI_SRC_UV         10       // Current src frame for UV
  268.    
  269. #endif
  270.  
  271. #if defined(INPUT_PL3)
  272.     // PL3 Surface Binding Table
  273. //    #define nBI_SRC_ALPHA       0       // Alpha
  274. //    #define nBI_SRC_Y           1       // Current src frame
  275. //    #define nBI_SRC_U           2       // Current src frame
  276. //    #define nBI_SRC_V           3       // Current src frame
  277. //    #define nBI_DEST_Y         10       // Dest frame
  278. //    #define nBI_DEST_U         11       // Dest frame
  279. //    #define nBI_DEST_V         12       // Dest frame
  280. //    #define nBI_DEST_YUV        7       // Dest frame
  281. //    #define nBI_DEST_RGB        7       // same num as BI_DEST_YUV, never used at the same time
  282. #endif
  283.  
  284. #if defined(INPUT_PL2)
  285.     // PL2 Surface Binding Table
  286. //    #define nBI_SRC_ALPHA       0       // Alpha
  287. //    #define nBI_SRC_Y           1       // Current src frame for Y + offseted UV
  288. //    #define nBI_SRC_YUV         1       // Current src frame for YUV in case of NV12_AVS
  289. //    #define nBI_SRC_UV          2       // Current src frame for UV
  290. //    #define nBI_DEST_YUV        7       // Current dest frame for Y + offseted UV
  291. //    #define nBI_DEST_RGB        7       // same num as BI_DEST_YUV, never used at the same time
  292. //    #define nBI_DEST_Y         10       // Dest frame
  293. //    #define nBI_DEST_U         11       // Dest frame
  294. //    #define nBI_DEST_V         12       // Dest frame
  295. #endif
  296.  
  297. #if defined(INPUT_PA) || defined(COLORFILL)
  298.     // Packed Surface Binding Table
  299. //    #define nBI_SRC_ALPHA       0       // Alpha    
  300. //    #define nBI_SRC_YUV         1       // Current src frame
  301. //    #define nBI_DEST_YUV        3       // Dest frame
  302. //    #define nBI_DEST_RGB        3       // same num as BI_DEST_YUV, never used at the same time
  303. #endif
  304.  
  305.  
  306. //supper binding table
  307. #define nBI_ALPHA_SRC                   0
  308. #define nBI_CURRENT_SRC_YUV             1
  309. #define nBI_FIELD_COPY_SRC_1_YUV        1
  310. #define nBI_CURRENT_SRC_Y               1
  311. #define nBI_FIELD_COPY_SRC_1_Y          1
  312. #define nBI_CURRENT_SRC_RGB             1  
  313. #define nBI_CURRENT_SRC_UV              2
  314. #define nBI_FIELD_COPY_SRC_1_UV         2
  315. #define nBI_CURRENT_SRC_U               2
  316. #define nBI_FIELD_COPY_SRC_1_U          2
  317. #define nBI_CURRENT_SRC_V               3
  318. #define nBI_FIELD_COPY_SRC_1_V          3
  319. #define nBI_TEMPORAL_REFERENCE_YUV      4
  320. #define nBI_FIELD_COPY_SRC_2_YUV        4
  321. #define nBI_TEMPORAL_REFERENCE_Y        4
  322. #define nBI_FIELD_COPY_SRC_2_Y          4
  323. #define nBI_CURRENT_SRC_YUV_HW_DI       4
  324. #define nBI_TEMPORAL_REFERENCE_UV       5
  325. #define nBI_FIELD_COPY_SRC_2_UV         5
  326. #define nBI_TEMPORAL_REFERENCE_U        5
  327. #define nBI_FIELD_COPY_SRC_2_U          5
  328. #define nBI_DENOISED_PREV_HW_DI         5
  329. #define nBI_TEMPORAL_REFERENCE_V        6
  330. #define nBI_FIELD_COPY_SRC_2_V          6
  331. #define nBI_STMM_HISTORY                6
  332. #define nBI_DESTINATION_YUV             7
  333. #define nBI_DESTINATION_RGB             7
  334. #define nBI_DESTINATION_Y               7
  335. #define nBI_DESTINATION_UV              8
  336. #define nBI_DESTINATION_U               8
  337. #define nBI_DESTINATION_V               9
  338. #define nBI_DESTINATION_1_YUV           10
  339. #define nBI_DESTINATION_1_Y             10
  340. #define nBI_DESTINATION_1_UV            11
  341. #define nBI_DESTINATION_1_U             11
  342. #define nBI_DESTINATION_1_V             12
  343. #define nBI_DESTINATION_2_YUV           13
  344. #define nBI_DESTINATION_2_Y             13
  345. #define nBI_DESTINATION_2_UV            14
  346. #define nBI_DESTINATION_2_U             14
  347. #define nBI_DESTINATION_2_V             15
  348. #define nBI_STMM_HISTORY_OUTPUT         20
  349. #define nBI_TEMPORAL_REFERENCE_YUV_PDI  21
  350. #define nBI_TEMPORAL_REFERENCE_Y_PDI    21
  351. #define nBI_TEMPORAL_REFERENCE_UV_PDI   22
  352. #define nBI_TEMPORAL_REFERENCE_U_PDI    22
  353. #define nBI_TEMPORAL_REFERENCE_V_PDI    23
  354. #define nBI_SUBVIDEO_YUV                26
  355. #define nBI_SUBVIDEO_Y                  26
  356. #define nBI_SUBVIDEO_UV                 27
  357. #define nBI_SUBVIDEO_U                  27
  358. #define nBI_SUBVIDEO_V                  28
  359. #define nBI_SUBPICTURE_YUV              29
  360. #define nBI_SUBPICTURE_P8               29
  361. #define nBI_SUBPICTURE_A8               30
  362. #define nBI_GRAPHIC_YUV                 31
  363. #define nBI_GRAPHIC_P8                  31
  364. #define nBI_GRAPHIC_A8                  32
  365.  
  366.  
  367.  
  368. //========== Planar Sampler State Table Index ==========
  369. #define nSI_SRC_ALPHA           0x000   // Sampler State for Alpha
  370.  
  371. //Sampler Index for AVS/IEF messages
  372. #define nSI_SRC_Y               0x400   // Sampler State for Y
  373. #define nSI_SRC_U               0x800   // Sampler State for U
  374. #define nSI_SRC_V               0xC00   // Sampler State for V
  375. #define nSI_SRC_UV              0x800   // For NV12 surfaces
  376. #define nSI_SRC_YUV             0x400   // For Packed surfaces  
  377. #define nSI_SRC_RGB             0x400   // For ARGB surfaces
  378.  
  379. //Sampler Index for SIMD16 sampler messages
  380. #define nSI_SRC_SIMD16_Y        0x100   // Sampler State for Y
  381. #define nSI_SRC_SIMD16_U        0x200   // Sampler State for U
  382. #define nSI_SRC_SIMD16_V        0x300   // Sampler State for V
  383. #define nSI_SRC_SIMD16_UV       0x200   // For NV12 surfaces
  384. #define nSI_SRC_SIMD16_YUV      0x100   // For Packed surfaces  
  385. #define nSI_SRC_SIMD16_RGB      0x100   // For ARGB surfaces
  386.  
  387.  
  388.  
  389. // Common Registers
  390. #define pCF_Y_OFFSET            a0.4    // Address register holding Y offset
  391. #define pCF_U_OFFSET            a0.5    // Address register holding U offset
  392. #define pCF_V_OFFSET            a0.6    // Address register holding V offset
  393.  
  394. // #define YUV_ORI             ORIX    // Used by writing packed data to dport
  395.  
  396.  
  397. //================= Message Payload Header fields ==============================
  398. #define IDP     r0.2:ud     // Interface Descriptor Pointer
  399.  
  400. //================= Common Message Descriptor  TBD add common load and save =====
  401. // Message descriptor for dataport media write
  402. #ifdef GT
  403.         // Message Descriptors
  404.                 //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)        
  405.                 //                  1 (header present 1) 0 0 1010 (media block write) 00000
  406.                 //                  00000000 (binding table index - set later)
  407.                 //                = 0x02094000
  408.         #define nDPMW_MSGDSC      0x02094000
  409.         #define nDPMR_MSGDSC      0x02098000  // Data Port Media Block Read Message Descriptor
  410.         // TBD
  411. #else // ILK
  412.         // Message Descriptors
  413.                 //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)        
  414.                 //                  1 (header present 1) 000 0 010 (media block write) 0000
  415.                 //                  00000000 (binding table index - set later)
  416.                 //                = 0x02082000
  417.         #define nDPMW_MSGDSC      0x02082000  // Data Port Media Block Write Message Descriptor
  418.         #define nDPMR_MSGDSC      0x0208A000  // Data Port Media Block Read Message Descriptor
  419. #endif
  420.  
  421. // Message Length defines
  422. #define nMSGLEN_1      0x02000000 // Message Length of 1 GRF for Send
  423. #define nMSGLEN_2      0x04000000 // Message Length of 2 GRF for Send
  424. #define nMSGLEN_4      0x08000000 // Message Length of 4 GRF for Send
  425. #define nMSGLEN_8      0x10000000 // Message Length of 8 GRF for Send
  426.  
  427. // Response Length defines
  428. #define nRESLEN_1      0x00100000 // Message Response Length of 1  GRF from Send
  429. #define nRESLEN_2      0x00200000 // Message Response Length of 2  GRF from Send
  430. #define nRESLEN_3      0x00300000 // Message Response Length of 3  GRF from Send
  431. #define nRESLEN_4      0x00400000 // Message Response Length of 4  GRF from Send
  432. #define nRESLEN_5      0x00500000 // Message Response Length of 5  GRF from Send
  433. #define nRESLEN_8      0x00800000 // Message Response Length of 8  GRF from Send
  434. #define nRESLEN_9      0x00900000 // Message Response Length of 9  GRF from Send
  435. #define nRESLEN_11     0x00B00000 // Message Response Length of 11 GRF from Send
  436. #define nRESLEN_12     0x00C00000 // Message Response Length of 12 GRF from Send
  437. #define nRESLEN_16     0x01000000 // Message Response Length of 16 GRF from Send
  438.  
  439. // Block Width and Height Size defines
  440. #define nBLOCK_WIDTH_4   0x00000003      // Block Width  4
  441. #define nBLOCK_WIDTH_5   0x00000004      // Block Width  5
  442. #define nBLOCK_WIDTH_8   0x00000007      // Block Width  8
  443. #define nBLOCK_WIDTH_9   0x00000008      // Block Width  9
  444. #define nBLOCK_WIDTH_12  0x0000000B      // Block Width  12
  445. #define nBLOCK_WIDTH_16  0x0000000F      // Block Width  16
  446. #define nBLOCK_WIDTH_20  0x00000013      // Block Width  20
  447. #define nBLOCK_WIDTH_32  0x0000001F      // Block Width  32
  448. #define nBLOCK_HEIGHT_1  0x00000000      // Block Height 1
  449. #define nBLOCK_HEIGHT_2  0x00010000      // Block Height 2
  450. #define nBLOCK_HEIGHT_4  0x00030000      // Block Height 4
  451. #define nBLOCK_HEIGHT_5  0x00040000      // Block Height 5
  452. #define nBLOCK_HEIGHT_8  0x00070000      // Block Height 8
  453.  
  454. // Extended Message Descriptors
  455. #define nEXTENDED_MATH      0x1
  456. #define nSMPL_ENGINE        0x2
  457. #define nMESSAGE_GATEWAY    0x3
  458. #define nDATAPORT_READ      0x4
  459. #define nDATAPORT_WRITE     0x5
  460. #define nURB                0x6
  461. #define nTS_EOT             0x27    // with End-Of-Thread bit ON
  462.  
  463. // Common message descriptors:
  464. #ifdef GT
  465.         #define nEOT_MSGDSC       0x02000010  // End of Thread Message Descriptor    
  466.         #define IF_NULL                                         null:uw null:uw null:uw         //for different if instructions on ILK and Gen6
  467. #else //ILK
  468.         #define nEOT_MSGDSC       0x02000000  // End of Thread Message Descriptor        
  469.         #define IF_NULL
  470. #endif    
  471.  
  472.  
  473. //===================== Math Function Control ===================================
  474. #define mfcINV                  0x1     // reciprocal
  475. #define mfcLOG                  0x2     // log
  476. #define mfcEXP                  0x3     // exponent
  477. #define mfcSQRT                 0x4     // square root
  478. #define mfcRSQ                  0x5     // reciprocal square root
  479. #define mfcSIN                  0x6     // sine (in radians)
  480. #define mfcCOS                  0x7     // cosine (in radians)
  481. #define mfcSINCOS               0x8     // dst0 = sin of src0, dst1 = cosine of src0 (in radians) - GT+ ONLY
  482. #define mfcPOW                  0xA     // abs(src0) raised to the src1 power    
  483. #define mfcINT_DIV_QR           0xB     // return quotient and remainder
  484. #define mfcINT_DIV_Q            0xC     // return quotient
  485. #define mfcINT_DIV_R            0xD     // return remainder
  486.  
  487.  
  488. //=================== Message related registers =================================
  489.  
  490. #ifdef GT
  491.         #define udDUMMY_NULL
  492. #else   // _ILK
  493.         #define udDUMMY_NULL    null:ud         // Used in send inst as src0
  494. #endif
  495.  
  496.  
  497. //----------- Message Registers ------------
  498. #define mMSGHDR      m1     // Message Payload Header
  499. #define mMSGHDRY     m1     // Message Payload Header register for Y data
  500. #define mMSGHDRU     m2     // Message Payload Header register for U data
  501. #define mMSGHDRV     m3     // Message Payload Header register for V data
  502. #define mMSGHDRYA    m4     // Second Message Payload Header register for Y data
  503. #define mMSGHDRH     m5     // Message Payload Header register for motion history
  504. #define mMSGHDRY1    m1     // Message Payload Header register for first  Y data
  505. #define mMSGHDRY2    m2     // Message Payload Header register for second Y data
  506. #define mMSGHDRY3    m3     // Message Payload Header register for third  Y data
  507. #define mMSGHDRY4    m4     // Message Payload Header register for fourth Y data
  508. #define mMSGHDRY5    m5     // Message Payload Header register for fifth Y data
  509. #define mMSGHDRY6    m6     // Message Payload Header register for sixth Y data
  510. #define mMSGHDR_EOT  m15    // Dummy Message Register for EOT
  511.  
  512. #define rMSGSRC     r8      // Message source register
  513. #define pMSGDSC     a0.0:ud // Message Descriptor register (type DWORD)
  514.  
  515. #define udMH_ORI    rMSGSRC.0   // Data Port Media Block R/W message header block offset
  516. #define udMH_ORIX   rMSGSRC.0   // Data Port Media Block R/W message header X offset
  517. #define udMH_ORIY   rMSGSRC.1   // Data Port Media Block R/W message header Y offset
  518. #define udMH_SIZE   rMSGSRC.2   // Data Port Media Block R/W message header block width & height
  519.  
  520. //  M2 - M9 for message data payload
  521. .declare    mubMSGPAYLOAD  Base=m2 ElementSize=1 SrcRegion=REGION(16,1) Type=ub
  522. .declare    muwMSGPAYLOAD  Base=m2 ElementSize=2 SrcRegion=REGION(16,1) Type=uw
  523. .declare    mudMSGPAYLOAD  Base=m2 ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  524. .declare    mfMSGPAYLOAD   Base=m2 ElementSize=4 SrcRegion=REGION(8,1) Type=f
  525.  
  526. //=================== End of thread instruction ===========================
  527. #ifdef GT
  528.         #define END_THREAD          mov  (8) mMSGHDR_EOT<1>:ud    r0.0<8;8,1>:ud \n\
  529.                                                                 send (1) null<1>:d mMSGHDR_EOT nTS_EOT nEOT_MSGDSC
  530. #else   // ILK                          This should be changed to 1 instruction; I have tested it and it works - vK
  531.         #define END_THREAD          mov  (8) mMSGHDR_EOT<1>:ud    r0.0<8;8,1>:ud \n\
  532.                                 send (1) dNULLREG mMSGHDR_EOT udDUMMY_NULL  nTS_EOT nEOT_MSGDSC:ud
  533. #endif
  534.  
  535.  
  536. //=======================================================================
  537. // Region declarations for SRC and DEST as TOP and BOT
  538.  
  539. // Common I/O regions
  540. #define nREGION_1       1
  541. #define nREGION_2       2
  542.  
  543. //*** These region base GRFs are fixed regardless planar/packed, and data alignment.
  544. //*** Each kernel is responsible to select the correct region declaration below.
  545. //*** YUV regions are not necessarily next to each other.
  546. #define nTOP_Y          10      // r10 - r17  (8 GRFs)
  547. #define nTOP_U          18      // r18 - r25 (8 GRFs)
  548. #define nTOP_V          26      // r26 - r33 (8 GRFs)
  549.  
  550. #define nBOT_Y          56      // r56 - r63 (8 GRFs)
  551. #define nBOT_U          64      // r64 - r71 (8 GRFs)
  552. #define nBOT_V          72      // r72 - r79 (8 GRFs)
  553.  
  554. // Define temp space for any usages
  555. #define nTEMP0          34
  556. #define nTEMP1          35
  557. #define nTEMP2          36
  558. #define nTEMP3          37
  559. #define nTEMP4          38
  560. #define nTEMP5          39
  561. #define nTEMP6          40
  562. #define nTEMP7          41
  563. #define nTEMP8          42
  564. #define nTEMP10         44
  565. #define nTEMP12         46
  566. #define nTEMP14         48
  567. #define nTEMP16         50
  568. #define nTEMP17         51
  569. #define nTEMP18         52
  570.  
  571. #define nTEMP24                 58
  572.  
  573. // Common region 1
  574. .declare ubTOP_Y        Base=REG(r,nTOP_Y) ElementSize=1 SrcRegion=REGION(16,1) DstRegion=<1> Type=ub
  575. .declare ubTOP_U        Base=REG(r,nTOP_U) ElementSize=1 SrcRegion=REGION(8,1) DstRegion=<1> Type=ub
  576. .declare ubTOP_V        Base=REG(r,nTOP_V) ElementSize=1 SrcRegion=REGION(8,1) DstRegion=<1> Type=ub
  577.                        
  578. .declare uwTOP_Y        Base=REG(r,nTOP_Y) ElementSize=2 SrcRegion=REGION(16,1) DstRegion=<1> Type=uw
  579. .declare uwTOP_U        Base=REG(r,nTOP_U) ElementSize=2 SrcRegion=REGION(8,1) DstRegion=<1> Type=uw
  580. .declare uwTOP_V        Base=REG(r,nTOP_V) ElementSize=2 SrcRegion=REGION(8,1) DstRegion=<1> Type=uw
  581. .declare ub2TOP_Y       Base=REG(r,nTOP_Y) ElementSize=1 SrcRegion=REGION(16,2) DstRegion=<1> Type=ub
  582. .declare ub2TOP_U       Base=REG(r,nTOP_U) ElementSize=1 SrcRegion=REGION(8,2) DstRegion=<1> Type=ub
  583. .declare ub2TOP_V       Base=REG(r,nTOP_V) ElementSize=1 SrcRegion=REGION(8,2) DstRegion=<1> Type=ub
  584.  
  585. .declare ub4TOP_Y       Base=REG(r,nTOP_Y) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  586. .declare ub4TOP_U       Base=REG(r,nTOP_U) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  587. .declare ub4TOP_V       Base=REG(r,nTOP_V) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  588.  
  589. .declare ubTOP_ARGB     Base=REG(r,nTOP_Y) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  590.  
  591. // Used by "send" instruction
  592. .declare udTOP_Y_IO     Base=REG(r,nTOP_Y) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  593. .declare udTOP_U_IO     Base=REG(r,nTOP_U) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  594. .declare udTOP_V_IO     Base=REG(r,nTOP_V) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  595.  
  596. // Common region 2
  597. .declare ubBOT_Y        Base=REG(r,nBOT_Y) ElementSize=1 SrcRegion=REGION(16,1) DstRegion=<1> Type=ub
  598. .declare ubBOT_U        Base=REG(r,nBOT_U) ElementSize=1 SrcRegion=REGION(8,1) DstRegion=<1> Type=ub
  599. .declare ubBOT_V        Base=REG(r,nBOT_V) ElementSize=1 SrcRegion=REGION(8,1) DstRegion=<1> Type=ub
  600.                        
  601. .declare uwBOT_Y        Base=REG(r,nBOT_Y) ElementSize=2 SrcRegion=REGION(16,1) DstRegion=<1> Type=uw
  602. .declare uwBOT_U        Base=REG(r,nBOT_U) ElementSize=2 SrcRegion=REGION(8,1) DstRegion=<1> Type=uw
  603. .declare uwBOT_V        Base=REG(r,nBOT_V) ElementSize=2 SrcRegion=REGION(8,1) DstRegion=<1> Type=uw
  604. .declare ub2BOT_Y       Base=REG(r,nBOT_Y) ElementSize=1 SrcRegion=REGION(16,2) DstRegion=<1> Type=ub
  605. .declare ub2BOT_U       Base=REG(r,nBOT_U) ElementSize=1 SrcRegion=REGION(8,2) DstRegion=<1> Type=ub
  606. .declare ub2BOT_V       Base=REG(r,nBOT_V) ElementSize=1 SrcRegion=REGION(8,2) DstRegion=<1> Type=ub
  607.  
  608. .declare ubBOT_ARGB     Base=REG(r,nBOT_Y) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  609.  
  610. // Used by "send" instruction
  611. .declare udBOT_Y_IO     Base=REG(r,nBOT_Y) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  612. .declare udBOT_U_IO     Base=REG(r,nBOT_U) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  613. .declare udBOT_V_IO     Base=REG(r,nBOT_V) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  614.  
  615. // End of common.inc
  616.  
  617. #endif    // COMMON_INC
  618.