Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | 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. #define udBLOCK_MASK            r5.6    // DWORD 6
  233. #define uwBLOCK_MASK_H          r5.12   // DWORD 6, byte 0-1 :uw, Block horizontal mask used in non-DWord aligned kernels
  234. #define ubBLOCK_MASK_V          r5.26   // DWORD 6, byte 2   :ub, Block vertical mask used in non-DWord aligned kernels
  235. #define ubNUM_BLKS              r5.27   // DWORD 6, byte 3,  :ub, Total Block Count per thread
  236.  
  237. #define fVIDEO_STEP_X           r5.7    // DWORD 7. :f, AVS normalized reciprocal of X Scaling factor
  238.  
  239. // r6
  240. #define fVIDEO_STEP_DELTA       r6.0    // DWORD 0. :f, AVS normalized delta between 2 adjacent scaling steps (used for non-linear scaling)
  241.  
  242.  
  243. //====================== Binding table =========================================
  244.  
  245. #if defined(DNDI)
  246.     // DNDI Surface Binding Table
  247.     //#define nBI_SRC_CURR        0       // Current input frame surface
  248.     //#define nBI_SRC_PRIV        1       // Denoised previous input frame surface
  249.     //#define nBI_SRC_STAT        2       // Statistics input surface (STMM / Noise motion history)
  250.     //#define nBI_DEST_1ST        3       // 1st deinterlaced output frame surface
  251. //    #define nBI_DEST_YUV        3       // Dest frame YUV (for DN only)
  252.     //#define nBI_DEST_Y          3       // Dest frame Y (for DN only)
  253.     //#define nBI_DEST_2ND        4       // 2nd deinterlaced output frame surface
  254.     //#define nBI_DEST_DN_CURR    6       // Denoised current output frame surface
  255.     //#define nBI_DEST_STAT       7       // Statistics output surface (STMM / Noise motion history)
  256. //    #define nBI_DEST_U          8       // Dest frame U (for DN only)
  257. //    #define nBI_DEST_V          9       // Dest frame V (for DN only)
  258. //    #define nBI_SRC_U          10       // Src frame U (for DN only)
  259. //    #define nBI_SRC_V          11       // Src frame V (for DN only)
  260. //    #define nBI_SRC_UV         10       // Current src frame for UV
  261.    
  262. #endif
  263.  
  264. #if defined(INPUT_PL3)
  265.     // PL3 Surface Binding Table
  266. //    #define nBI_SRC_ALPHA       0       // Alpha
  267. //    #define nBI_SRC_Y           1       // Current src frame
  268. //    #define nBI_SRC_U           2       // Current src frame
  269. //    #define nBI_SRC_V           3       // Current src frame
  270. //    #define nBI_DEST_Y         10       // Dest frame
  271. //    #define nBI_DEST_U         11       // Dest frame
  272. //    #define nBI_DEST_V         12       // Dest frame
  273. //    #define nBI_DEST_YUV        7       // Dest frame
  274. //    #define nBI_DEST_RGB        7       // same num as BI_DEST_YUV, never used at the same time
  275. #endif
  276.  
  277. #if defined(INPUT_PL2)
  278.     // PL2 Surface Binding Table
  279. //    #define nBI_SRC_ALPHA       0       // Alpha
  280. //    #define nBI_SRC_Y           1       // Current src frame for Y + offseted UV
  281. //    #define nBI_SRC_YUV         1       // Current src frame for YUV in case of NV12_AVS
  282. //    #define nBI_SRC_UV          2       // Current src frame for UV
  283. //    #define nBI_DEST_YUV        7       // Current dest frame for Y + offseted UV
  284. //    #define nBI_DEST_RGB        7       // same num as BI_DEST_YUV, never used at the same time
  285. //    #define nBI_DEST_Y         10       // Dest frame
  286. //    #define nBI_DEST_U         11       // Dest frame
  287. //    #define nBI_DEST_V         12       // Dest frame
  288. #endif
  289.  
  290. #if defined(INPUT_PA) || defined(COLORFILL)
  291.     // Packed Surface Binding Table
  292. //    #define nBI_SRC_ALPHA       0       // Alpha    
  293. //    #define nBI_SRC_YUV         1       // Current src frame
  294. //    #define nBI_DEST_YUV        3       // Dest frame
  295. //    #define nBI_DEST_RGB        3       // same num as BI_DEST_YUV, never used at the same time
  296. #endif
  297.  
  298.  
  299. //supper binding table
  300. #define nBI_ALPHA_SRC                   0
  301. #define nBI_CURRENT_SRC_YUV             1
  302. #define nBI_FIELD_COPY_SRC_1_YUV        1
  303. #define nBI_CURRENT_SRC_Y               1
  304. #define nBI_FIELD_COPY_SRC_1_Y          1
  305. #define nBI_CURRENT_SRC_RGB             1  
  306. #define nBI_CURRENT_SRC_UV              2
  307. #define nBI_FIELD_COPY_SRC_1_UV         2
  308. #define nBI_CURRENT_SRC_U               2
  309. #define nBI_FIELD_COPY_SRC_1_U          2
  310. #define nBI_CURRENT_SRC_V               3
  311. #define nBI_FIELD_COPY_SRC_1_V          3
  312. #define nBI_TEMPORAL_REFERENCE_YUV      4
  313. #define nBI_FIELD_COPY_SRC_2_YUV        4
  314. #define nBI_TEMPORAL_REFERENCE_Y        4
  315. #define nBI_FIELD_COPY_SRC_2_Y          4
  316. #define nBI_CURRENT_SRC_YUV_HW_DI       4
  317. #define nBI_TEMPORAL_REFERENCE_UV       5
  318. #define nBI_FIELD_COPY_SRC_2_UV         5
  319. #define nBI_TEMPORAL_REFERENCE_U        5
  320. #define nBI_FIELD_COPY_SRC_2_U          5
  321. #define nBI_DENOISED_PREV_HW_DI         5
  322. #define nBI_TEMPORAL_REFERENCE_V        6
  323. #define nBI_FIELD_COPY_SRC_2_V          6
  324. #define nBI_STMM_HISTORY                6
  325. #define nBI_DESTINATION_YUV             7
  326. #define nBI_DESTINATION_RGB             7
  327. #define nBI_DESTINATION_Y               7
  328. #define nBI_DESTINATION_UV              8
  329. #define nBI_DESTINATION_U               8
  330. #define nBI_DESTINATION_V               9
  331. #define nBI_DESTINATION_1_YUV           10
  332. #define nBI_DESTINATION_1_Y             10
  333. #define nBI_DESTINATION_1_UV            11
  334. #define nBI_DESTINATION_1_U             11
  335. #define nBI_DESTINATION_1_V             12
  336. #define nBI_DESTINATION_2_YUV           13
  337. #define nBI_DESTINATION_2_Y             13
  338. #define nBI_DESTINATION_2_UV            14
  339. #define nBI_DESTINATION_2_U             14
  340. #define nBI_DESTINATION_2_V             15
  341. #define nBI_STMM_HISTORY_OUTPUT         20
  342. #define nBI_TEMPORAL_REFERENCE_YUV_PDI  21
  343. #define nBI_TEMPORAL_REFERENCE_Y_PDI    21
  344. #define nBI_TEMPORAL_REFERENCE_UV_PDI   22
  345. #define nBI_TEMPORAL_REFERENCE_U_PDI    22
  346. #define nBI_TEMPORAL_REFERENCE_V_PDI    23
  347. #define nBI_SUBVIDEO_YUV                26
  348. #define nBI_SUBVIDEO_Y                  26
  349. #define nBI_SUBVIDEO_UV                 27
  350. #define nBI_SUBVIDEO_U                  27
  351. #define nBI_SUBVIDEO_V                  28
  352. #define nBI_SUBPICTURE_YUV              29
  353. #define nBI_SUBPICTURE_P8               29
  354. #define nBI_SUBPICTURE_A8               30
  355. #define nBI_GRAPHIC_YUV                 31
  356. #define nBI_GRAPHIC_P8                  31
  357. #define nBI_GRAPHIC_A8                  32
  358.  
  359.  
  360.  
  361. //========== Planar Sampler State Table Index ==========
  362. #define nSI_SRC_ALPHA           0x000   // Sampler State for Alpha
  363.  
  364. //Sampler Index for AVS/IEF messages
  365. #define nSI_SRC_Y               0x400   // Sampler State for Y
  366. #define nSI_SRC_U               0x800   // Sampler State for U
  367. #define nSI_SRC_V               0xC00   // Sampler State for V
  368. #define nSI_SRC_UV              0x800   // For NV12 surfaces
  369. #define nSI_SRC_YUV             0x400   // For Packed surfaces  
  370. #define nSI_SRC_RGB             0x400   // For ARGB surfaces
  371.  
  372. //Sampler Index for SIMD16 sampler messages
  373. #define nSI_SRC_SIMD16_Y        0x100   // Sampler State for Y
  374. #define nSI_SRC_SIMD16_U        0x200   // Sampler State for U
  375. #define nSI_SRC_SIMD16_V        0x300   // Sampler State for V
  376. #define nSI_SRC_SIMD16_UV       0x200   // For NV12 surfaces
  377. #define nSI_SRC_SIMD16_YUV      0x100   // For Packed surfaces  
  378. #define nSI_SRC_SIMD16_RGB      0x100   // For ARGB surfaces
  379.  
  380.  
  381.  
  382. // Common Registers
  383. #define pCF_Y_OFFSET            a0.4    // Address register holding Y offset
  384. #define pCF_U_OFFSET            a0.5    // Address register holding U offset
  385. #define pCF_V_OFFSET            a0.6    // Address register holding V offset
  386.  
  387. // #define YUV_ORI             ORIX    // Used by writing packed data to dport
  388.  
  389.  
  390. //================= Message Payload Header fields ==============================
  391. #define IDP     r0.2:ud     // Interface Descriptor Pointer
  392.  
  393. //================= Common Message Descriptor  TBD add common load and save =====
  394. // Message descriptor for dataport media write
  395. #ifdef GT
  396.         // Message Descriptors
  397.                 //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)        
  398.                 //                  1 (header present 1) 0 0 1010 (media block write) 00000
  399.                 //                  00000000 (binding table index - set later)
  400.                 //                = 0x02094000
  401.         #define nDPMW_MSGDSC      0x02094000
  402.         #define nDPMR_MSGDSC      0x02098000  // Data Port Media Block Read Message Descriptor
  403.         // TBD
  404. #else // ILK
  405.         // Message Descriptors
  406.                 //                = 000 0001 (min message len 1 - add later) 00000 (resp len 0)        
  407.                 //                  1 (header present 1) 000 0 010 (media block write) 0000
  408.                 //                  00000000 (binding table index - set later)
  409.                 //                = 0x02082000
  410.         #define nDPMW_MSGDSC      0x02082000  // Data Port Media Block Write Message Descriptor
  411.         #define nDPMR_MSGDSC      0x0208A000  // Data Port Media Block Read Message Descriptor
  412. #endif
  413.  
  414. // Message Length defines
  415. #define nMSGLEN_1      0x02000000 // Message Length of 1 GRF for Send
  416. #define nMSGLEN_2      0x04000000 // Message Length of 2 GRF for Send
  417. #define nMSGLEN_4      0x08000000 // Message Length of 4 GRF for Send
  418. #define nMSGLEN_8      0x10000000 // Message Length of 8 GRF for Send
  419.  
  420. // Response Length defines
  421. #define nRESLEN_1      0x00100000 // Message Response Length of 1  GRF from Send
  422. #define nRESLEN_2      0x00200000 // Message Response Length of 2  GRF from Send
  423. #define nRESLEN_3      0x00300000 // Message Response Length of 3  GRF from Send
  424. #define nRESLEN_4      0x00400000 // Message Response Length of 4  GRF from Send
  425. #define nRESLEN_5      0x00500000 // Message Response Length of 5  GRF from Send
  426. #define nRESLEN_8      0x00800000 // Message Response Length of 8  GRF from Send
  427. #define nRESLEN_9      0x00900000 // Message Response Length of 9  GRF from Send
  428. #define nRESLEN_11     0x00B00000 // Message Response Length of 11 GRF from Send
  429. #define nRESLEN_12     0x00C00000 // Message Response Length of 12 GRF from Send
  430. #define nRESLEN_16     0x01000000 // Message Response Length of 16 GRF from Send
  431.  
  432. // Block Width and Height Size defines
  433. #define nBLOCK_WIDTH_4   0x00000003      // Block Width  4
  434. #define nBLOCK_WIDTH_5   0x00000004      // Block Width  5
  435. #define nBLOCK_WIDTH_8   0x00000007      // Block Width  8
  436. #define nBLOCK_WIDTH_9   0x00000008      // Block Width  9
  437. #define nBLOCK_WIDTH_12  0x0000000B      // Block Width  12
  438. #define nBLOCK_WIDTH_16  0x0000000F      // Block Width  16
  439. #define nBLOCK_WIDTH_20  0x00000013      // Block Width  20
  440. #define nBLOCK_WIDTH_32  0x0000001F      // Block Width  32
  441. #define nBLOCK_HEIGHT_1  0x00000000      // Block Height 1
  442. #define nBLOCK_HEIGHT_2  0x00010000      // Block Height 2
  443. #define nBLOCK_HEIGHT_4  0x00030000      // Block Height 4
  444. #define nBLOCK_HEIGHT_5  0x00040000      // Block Height 5
  445. #define nBLOCK_HEIGHT_8  0x00070000      // Block Height 8
  446.  
  447. // Extended Message Descriptors
  448. #define nEXTENDED_MATH      0x1
  449. #define nSMPL_ENGINE        0x2
  450. #define nMESSAGE_GATEWAY    0x3
  451. #define nDATAPORT_READ      0x4
  452. #define nDATAPORT_WRITE     0x5
  453. #define nURB                0x6
  454. #define nTS_EOT             0x27    // with End-Of-Thread bit ON
  455.  
  456. // Common message descriptors:
  457. #ifdef GT
  458.         #define nEOT_MSGDSC       0x02000010  // End of Thread Message Descriptor    
  459.         #define IF_NULL                                         null:uw null:uw null:uw         //for different if instructions on ILK and Gen6
  460. #else //ILK
  461.         #define nEOT_MSGDSC       0x02000000  // End of Thread Message Descriptor        
  462.         #define IF_NULL
  463. #endif    
  464.  
  465.  
  466. //===================== Math Function Control ===================================
  467. #define mfcINV                  0x1     // reciprocal
  468. #define mfcLOG                  0x2     // log
  469. #define mfcEXP                  0x3     // exponent
  470. #define mfcSQRT                 0x4     // square root
  471. #define mfcRSQ                  0x5     // reciprocal square root
  472. #define mfcSIN                  0x6     // sine (in radians)
  473. #define mfcCOS                  0x7     // cosine (in radians)
  474. #define mfcSINCOS               0x8     // dst0 = sin of src0, dst1 = cosine of src0 (in radians) - GT+ ONLY
  475. #define mfcPOW                  0xA     // abs(src0) raised to the src1 power    
  476. #define mfcINT_DIV_QR           0xB     // return quotient and remainder
  477. #define mfcINT_DIV_Q            0xC     // return quotient
  478. #define mfcINT_DIV_R            0xD     // return remainder
  479.  
  480.  
  481. //=================== Message related registers =================================
  482.  
  483. #ifdef GT
  484.         #define udDUMMY_NULL
  485. #else   // _ILK
  486.         #define udDUMMY_NULL    null:ud         // Used in send inst as src0
  487. #endif
  488.  
  489.  
  490. //----------- Message Registers ------------
  491. #define mMSGHDR      m1     // Message Payload Header
  492. #define mMSGHDRY     m1     // Message Payload Header register for Y data
  493. #define mMSGHDRU     m2     // Message Payload Header register for U data
  494. #define mMSGHDRV     m3     // Message Payload Header register for V data
  495. #define mMSGHDRYA    m4     // Second Message Payload Header register for Y data
  496. #define mMSGHDRH     m5     // Message Payload Header register for motion history
  497. #define mMSGHDRY1    m1     // Message Payload Header register for first  Y data
  498. #define mMSGHDRY2    m2     // Message Payload Header register for second Y data
  499. #define mMSGHDRY3    m3     // Message Payload Header register for third  Y data
  500. #define mMSGHDRY4    m4     // Message Payload Header register for fourth Y data
  501. #define mMSGHDRY5    m5     // Message Payload Header register for fifth Y data
  502. #define mMSGHDRY6    m6     // Message Payload Header register for sixth Y data
  503. #define mMSGHDR_EOT  m15    // Dummy Message Register for EOT
  504.  
  505. #define rMSGSRC     r8      // Message source register
  506. #define pMSGDSC     a0.0:ud // Message Descriptor register (type DWORD)
  507.  
  508. #define udMH_ORI    rMSGSRC.0   // Data Port Media Block R/W message header block offset
  509. #define udMH_ORIX   rMSGSRC.0   // Data Port Media Block R/W message header X offset
  510. #define udMH_ORIY   rMSGSRC.1   // Data Port Media Block R/W message header Y offset
  511. #define udMH_SIZE   rMSGSRC.2   // Data Port Media Block R/W message header block width & height
  512.  
  513. //  M2 - M9 for message data payload
  514. .declare    mubMSGPAYLOAD  Base=m2 ElementSize=1 SrcRegion=REGION(16,1) Type=ub
  515. .declare    muwMSGPAYLOAD  Base=m2 ElementSize=2 SrcRegion=REGION(16,1) Type=uw
  516. .declare    mudMSGPAYLOAD  Base=m2 ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  517. .declare    mfMSGPAYLOAD   Base=m2 ElementSize=4 SrcRegion=REGION(8,1) Type=f
  518.  
  519. //=================== End of thread instruction ===========================
  520. #ifdef GT
  521.         #define END_THREAD          mov  (8) mMSGHDR_EOT<1>:ud    r0.0<8;8,1>:ud \n\
  522.                                                                 send (1) null<1>:d mMSGHDR_EOT nTS_EOT nEOT_MSGDSC
  523. #else   // ILK                          This should be changed to 1 instruction; I have tested it and it works - vK
  524.         #define END_THREAD          mov  (8) mMSGHDR_EOT<1>:ud    r0.0<8;8,1>:ud \n\
  525.                                 send (1) dNULLREG mMSGHDR_EOT udDUMMY_NULL  nTS_EOT nEOT_MSGDSC:ud
  526. #endif
  527.  
  528.  
  529. //=======================================================================
  530. // Region declarations for SRC and DEST as TOP and BOT
  531.  
  532. // Common I/O regions
  533. #define nREGION_1       1
  534. #define nREGION_2       2
  535.  
  536. //*** These region base GRFs are fixed regardless planar/packed, and data alignment.
  537. //*** Each kernel is responsible to select the correct region declaration below.
  538. //*** YUV regions are not necessarily next to each other.
  539. #define nTOP_Y          10      // r10 - r17  (8 GRFs)
  540. #define nTOP_U          18      // r18 - r25 (8 GRFs)
  541. #define nTOP_V          26      // r26 - r33 (8 GRFs)
  542.  
  543. #define nBOT_Y          56      // r56 - r63 (8 GRFs)
  544. #define nBOT_U          64      // r64 - r71 (8 GRFs)
  545. #define nBOT_V          72      // r72 - r79 (8 GRFs)
  546.  
  547. // Define temp space for any usages
  548. #define nTEMP0          34
  549. #define nTEMP1          35
  550. #define nTEMP2          36
  551. #define nTEMP3          37
  552. #define nTEMP4          38
  553. #define nTEMP5          39
  554. #define nTEMP6          40
  555. #define nTEMP7          41
  556. #define nTEMP8          42
  557. #define nTEMP10         44
  558. #define nTEMP12         46
  559. #define nTEMP14         48
  560. #define nTEMP16         50
  561. #define nTEMP17         51
  562. #define nTEMP18         52
  563.  
  564. #define nTEMP24                 58
  565.  
  566. // Common region 1
  567. .declare ubTOP_Y        Base=REG(r,nTOP_Y) ElementSize=1 SrcRegion=REGION(16,1) DstRegion=<1> Type=ub
  568. .declare ubTOP_U        Base=REG(r,nTOP_U) ElementSize=1 SrcRegion=REGION(8,1) DstRegion=<1> Type=ub
  569. .declare ubTOP_V        Base=REG(r,nTOP_V) ElementSize=1 SrcRegion=REGION(8,1) DstRegion=<1> Type=ub
  570.                        
  571. .declare uwTOP_Y        Base=REG(r,nTOP_Y) ElementSize=2 SrcRegion=REGION(16,1) DstRegion=<1> Type=uw
  572. .declare uwTOP_U        Base=REG(r,nTOP_U) ElementSize=2 SrcRegion=REGION(8,1) DstRegion=<1> Type=uw
  573. .declare uwTOP_V        Base=REG(r,nTOP_V) ElementSize=2 SrcRegion=REGION(8,1) DstRegion=<1> Type=uw
  574. .declare ub2TOP_Y       Base=REG(r,nTOP_Y) ElementSize=1 SrcRegion=REGION(16,2) DstRegion=<1> Type=ub
  575. .declare ub2TOP_U       Base=REG(r,nTOP_U) ElementSize=1 SrcRegion=REGION(8,2) DstRegion=<1> Type=ub
  576. .declare ub2TOP_V       Base=REG(r,nTOP_V) ElementSize=1 SrcRegion=REGION(8,2) DstRegion=<1> Type=ub
  577.  
  578. .declare ub4TOP_Y       Base=REG(r,nTOP_Y) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  579. .declare ub4TOP_U       Base=REG(r,nTOP_U) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  580. .declare ub4TOP_V       Base=REG(r,nTOP_V) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  581.  
  582. .declare ubTOP_ARGB     Base=REG(r,nTOP_Y) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  583.  
  584. // Used by "send" instruction
  585. .declare udTOP_Y_IO     Base=REG(r,nTOP_Y) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  586. .declare udTOP_U_IO     Base=REG(r,nTOP_U) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  587. .declare udTOP_V_IO     Base=REG(r,nTOP_V) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  588.  
  589. // Common region 2
  590. .declare ubBOT_Y        Base=REG(r,nBOT_Y) ElementSize=1 SrcRegion=REGION(16,1) DstRegion=<1> Type=ub
  591. .declare ubBOT_U        Base=REG(r,nBOT_U) ElementSize=1 SrcRegion=REGION(8,1) DstRegion=<1> Type=ub
  592. .declare ubBOT_V        Base=REG(r,nBOT_V) ElementSize=1 SrcRegion=REGION(8,1) DstRegion=<1> Type=ub
  593.                        
  594. .declare uwBOT_Y        Base=REG(r,nBOT_Y) ElementSize=2 SrcRegion=REGION(16,1) DstRegion=<1> Type=uw
  595. .declare uwBOT_U        Base=REG(r,nBOT_U) ElementSize=2 SrcRegion=REGION(8,1) DstRegion=<1> Type=uw
  596. .declare uwBOT_V        Base=REG(r,nBOT_V) ElementSize=2 SrcRegion=REGION(8,1) DstRegion=<1> Type=uw
  597. .declare ub2BOT_Y       Base=REG(r,nBOT_Y) ElementSize=1 SrcRegion=REGION(16,2) DstRegion=<1> Type=ub
  598. .declare ub2BOT_U       Base=REG(r,nBOT_U) ElementSize=1 SrcRegion=REGION(8,2) DstRegion=<1> Type=ub
  599. .declare ub2BOT_V       Base=REG(r,nBOT_V) ElementSize=1 SrcRegion=REGION(8,2) DstRegion=<1> Type=ub
  600.  
  601. .declare ubBOT_ARGB     Base=REG(r,nBOT_Y) ElementSize=1 SrcRegion=REGION(8,4) Type=ub
  602.  
  603. // Used by "send" instruction
  604. .declare udBOT_Y_IO     Base=REG(r,nBOT_Y) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  605. .declare udBOT_U_IO     Base=REG(r,nBOT_U) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  606. .declare udBOT_V_IO     Base=REG(r,nBOT_V) ElementSize=4 SrcRegion=REGION(8,1) Type=ud
  607.  
  608. // End of common.inc
  609.  
  610. #endif    // COMMON_INC
  611.