rgx_common.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*************************************************************************/ /*!
  2. @File
  3. @Title RGX Common Types and Defines Header
  4. @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  5. @Description Common types and definitions for RGX software
  6. @License Dual MIT/GPLv2
  7. The contents of this file are subject to the MIT license as set out below.
  8. Permission is hereby granted, free of charge, to any person obtaining a copy
  9. of this software and associated documentation files (the "Software"), to deal
  10. in the Software without restriction, including without limitation the rights
  11. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. copies of the Software, and to permit persons to whom the Software is
  13. furnished to do so, subject to the following conditions:
  14. The above copyright notice and this permission notice shall be included in
  15. all copies or substantial portions of the Software.
  16. Alternatively, the contents of this file may be used under the terms of
  17. the GNU General Public License Version 2 ("GPL") in which case the provisions
  18. of GPL are applicable instead of those above.
  19. If you wish to allow use of your version of this file only under the terms of
  20. GPL, and not to allow others to use your version of this file under the terms
  21. of the MIT license, indicate your decision by deleting the provisions above
  22. and replace them with the notice and other provisions required by GPL as set
  23. out in the file called "GPL-COPYING" included in this distribution. If you do
  24. not delete the provisions above, a recipient may use your version of this file
  25. under the terms of either the MIT license or GPL.
  26. This License is also included in this distribution in the file called
  27. "MIT-COPYING".
  28. EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
  29. PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  30. BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  31. PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
  32. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  33. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  34. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  35. */ /**************************************************************************/
  36. #ifndef RGX_COMMON_H
  37. #define RGX_COMMON_H
  38. #if defined(__cplusplus)
  39. extern "C" {
  40. #endif
  41. #include "img_defs.h"
  42. /* Included to get the BVNC_KM_N defined and other feature defs */
  43. #include "km/rgxdefs_km.h"
  44. /*! This macro represents a mask of LSBs that must be zero on data structure
  45. * sizes and offsets to ensure they are 8-byte granular on types shared between
  46. * the FW and host driver */
  47. #define RGX_FW_ALIGNMENT_LSB (7U)
  48. /*! Macro to test structure size alignment */
  49. #define RGX_FW_STRUCT_SIZE_ASSERT(_a) \
  50. static_assert((sizeof(_a) & RGX_FW_ALIGNMENT_LSB) == 0U, \
  51. "Size of " #_a " is not properly aligned")
  52. /*! Macro to test structure member alignment */
  53. #define RGX_FW_STRUCT_OFFSET_ASSERT(_a, _b) \
  54. static_assert((offsetof(_a, _b) & RGX_FW_ALIGNMENT_LSB) == 0U, \
  55. "Offset of " #_a "." #_b " is not properly aligned")
  56. /* Virtualisation validation builds are meant to test the VZ-related hardware without a fully virtualised platform.
  57. * As such a driver can support either the vz-validation code or real virtualisation.
  58. * Note: PVRSRV_VZ_NUM_OSID is the external build option, while RGX_NUM_OS_SUPPORTED is the internal symbol used in the DDK */
  59. #if defined(SUPPORT_GPUVIRT_VALIDATION) && (defined(RGX_NUM_OS_SUPPORTED) && (RGX_NUM_OS_SUPPORTED > 1))
  60. #error "Invalid build configuration: Virtualisation support (PVRSRV_VZ_NUM_OSID > 1) and virtualisation validation code (SUPPORT_GPUVIRT_VALIDATION) are mutually exclusive."
  61. #endif
  62. /* The RGXFWIF_DM defines assume only one of RGX_FEATURE_TLA or
  63. * RGX_FEATURE_FASTRENDER_DM is present. Ensure this with a compile-time check.
  64. */
  65. #if defined(RGX_FEATURE_TLA) && defined(RGX_FEATURE_FASTRENDER_DM)
  66. #error "Both RGX_FEATURE_TLA and RGX_FEATURE_FASTRENDER_DM defined. Fix code to handle this!"
  67. #endif
  68. /*! The master definition for data masters known to the firmware of RGX.
  69. * When a new DM is added to this list, relevant entry should be added to
  70. * RGX_HWPERF_DM enum list.
  71. * The DM in a V1 HWPerf packet uses this definition. */
  72. typedef IMG_UINT32 RGXFWIF_DM;
  73. #define RGXFWIF_DM_GP IMG_UINT32_C(0)
  74. /* Either TDM or 2D DM is present. The above build time error is present to verify this */
  75. #define RGXFWIF_DM_2D IMG_UINT32_C(1) /* when RGX_FEATURE_TLA defined */
  76. #define RGXFWIF_DM_TDM IMG_UINT32_C(1) /* when RGX_FEATURE_FASTRENDER_DM defined */
  77. #define RGXFWIF_DM_GEOM IMG_UINT32_C(2)
  78. #define RGXFWIF_DM_3D IMG_UINT32_C(3)
  79. #define RGXFWIF_DM_CDM IMG_UINT32_C(4)
  80. #define RGXFWIF_DM_RAY IMG_UINT32_C(5)
  81. #define RGXFWIF_DM_GEOM2 IMG_UINT32_C(6)
  82. #define RGXFWIF_DM_LAST RGXFWIF_DM_GEOM2
  83. typedef enum _RGX_KICK_TYPE_DM_
  84. {
  85. RGX_KICK_TYPE_DM_GP = 0x001,
  86. RGX_KICK_TYPE_DM_TDM_2D = 0x002,
  87. RGX_KICK_TYPE_DM_TA = 0x004,
  88. RGX_KICK_TYPE_DM_3D = 0x008,
  89. RGX_KICK_TYPE_DM_CDM = 0x010,
  90. RGX_KICK_TYPE_DM_RTU = 0x020,
  91. RGX_KICK_TYPE_DM_SHG = 0x040,
  92. RGX_KICK_TYPE_DM_TQ2D = 0x080,
  93. RGX_KICK_TYPE_DM_TQ3D = 0x100,
  94. RGX_KICK_TYPE_DM_RAY = 0x200,
  95. RGX_KICK_TYPE_DM_LAST = 0x400
  96. } RGX_KICK_TYPE_DM;
  97. /* Maximum number of DM in use: GP, 2D/TDM, GEOM, 3D, CDM, RDM, GEOM2 */
  98. #define RGXFWIF_DM_MAX (RGXFWIF_DM_LAST + 1U)
  99. /*
  100. * Data Master Tags to be appended to resources created on behalf of each RGX
  101. * Context.
  102. */
  103. #define RGX_RI_DM_TAG_KS 'K'
  104. #define RGX_RI_DM_TAG_CDM 'C'
  105. #define RGX_RI_DM_TAG_RC 'R' /* To be removed once TA/3D Timelines are split */
  106. #define RGX_RI_DM_TAG_TA 'V'
  107. #define RGX_RI_DM_TAG_GEOM 'V'
  108. #define RGX_RI_DM_TAG_3D 'P'
  109. #define RGX_RI_DM_TAG_TDM 'T'
  110. #define RGX_RI_DM_TAG_TQ2D '2'
  111. #define RGX_RI_DM_TAG_TQ3D 'Q'
  112. #define RGX_RI_DM_TAG_RAY 'r'
  113. /*
  114. * Client API Tags to be appended to resources created on behalf of each
  115. * Client API.
  116. */
  117. #define RGX_RI_CLIENT_API_GLES1 '1'
  118. #define RGX_RI_CLIENT_API_GLES3 '3'
  119. #define RGX_RI_CLIENT_API_VULKAN 'V'
  120. #define RGX_RI_CLIENT_API_EGL 'E'
  121. #define RGX_RI_CLIENT_API_OPENCL 'C'
  122. #define RGX_RI_CLIENT_API_OPENGL 'G'
  123. #define RGX_RI_CLIENT_API_SERVICES 'S'
  124. #define RGX_RI_CLIENT_API_WSEGL 'W'
  125. #define RGX_RI_CLIENT_API_ANDROID 'A'
  126. #define RGX_RI_CLIENT_API_LWS 'L'
  127. /*
  128. * Format a RI annotation for a given RGX Data Master context
  129. */
  130. #define RGX_RI_FORMAT_DM_ANNOTATION(annotation, dmTag, clientAPI) do \
  131. { \
  132. (annotation)[0] = (dmTag); \
  133. (annotation)[1] = (clientAPI); \
  134. (annotation)[2] = '\0'; \
  135. } while (false)
  136. /*!
  137. ******************************************************************************
  138. * RGXFW Compiler alignment definitions
  139. *****************************************************************************/
  140. #if defined(__GNUC__) || defined(HAS_GNUC_ATTRIBUTES) || defined(INTEGRITY_OS)
  141. #define RGXFW_ALIGN __attribute__ ((aligned (8)))
  142. #define RGXFW_ALIGN_DCACHEL __attribute__((aligned (64)))
  143. #elif defined(_MSC_VER)
  144. #define RGXFW_ALIGN __declspec(align(8))
  145. #define RGXFW_ALIGN_DCACHEL __declspec(align(64))
  146. #pragma warning (disable : 4324)
  147. #else
  148. #error "Align MACROS need to be defined for this compiler"
  149. #endif
  150. /*!
  151. ******************************************************************************
  152. * Force 8-byte alignment for structures allocated uncached.
  153. *****************************************************************************/
  154. #define UNCACHED_ALIGN RGXFW_ALIGN
  155. /*!
  156. ******************************************************************************
  157. * GPU Utilisation states
  158. *****************************************************************************/
  159. #define RGXFWIF_GPU_UTIL_STATE_IDLE (0U)
  160. #define RGXFWIF_GPU_UTIL_STATE_ACTIVE (1U)
  161. #define RGXFWIF_GPU_UTIL_STATE_BLOCKED (2U)
  162. #define RGXFWIF_GPU_UTIL_STATE_NUM (3U)
  163. #define RGXFWIF_GPU_UTIL_STATE_MASK IMG_UINT64_C(0x0000000000000003)
  164. /*
  165. * Maximum amount of register writes that can be done by the register
  166. * programmer (FW or META DMA). This is not a HW limitation, it is only
  167. * a protection against malformed inputs to the register programmer.
  168. */
  169. #define RGX_MAX_NUM_REGISTER_PROGRAMMER_WRITES (128U)
  170. /* FW common context priority. */
  171. #define RGX_CTX_PRIORITY_REALTIME (UINT32_MAX)
  172. #define RGX_CTX_PRIORITY_HIGH (2U)
  173. #define RGX_CTX_PRIORITY_MEDIUM (1U)
  174. #define RGX_CTX_PRIORITY_LOW (0)
  175. /*
  176. * Use of the 32-bit context property flags mask
  177. * ( X = taken/in use, - = available/unused )
  178. *
  179. * 0
  180. * |
  181. * -------------------------------x
  182. */
  183. /*
  184. * Context creation flags
  185. * (specify a context's properties at creation time)
  186. */
  187. #define RGX_CONTEXT_FLAG_DISABLESLR (1UL << 0) /*!< Disable SLR */
  188. /* List of attributes that may be set for a context */
  189. typedef enum _RGX_CONTEXT_PROPERTY_
  190. {
  191. RGX_CONTEXT_PROPERTY_FLAGS = 0, /*!< Context flags */
  192. } RGX_CONTEXT_PROPERTY;
  193. #if defined(__cplusplus)
  194. }
  195. #endif
  196. #endif /* RGX_COMMON_H */
  197. /******************************************************************************
  198. End of file
  199. ******************************************************************************/