Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef _INTEL_DRIVER_H_
  2. #define _INTEL_DRIVER_H_
  3.  
  4. #include <stddef.h>
  5. #include <pthread.h>
  6. #include <signal.h>
  7.  
  8. #include <drm.h>
  9. #include <i915_drm.h>
  10. #include <intel_bufmgr.h>
  11.  
  12. #include <va/va_backend.h>
  13. #include "va_backend_compat.h"
  14.  
  15. #include "intel_compiler.h"
  16.  
  17. #define BATCH_SIZE      0x80000
  18. #define BATCH_RESERVED  0x10
  19.  
  20. #define CMD_MI                                  (0x0 << 29)
  21. #define CMD_2D                                  (0x2 << 29)
  22. #define CMD_3D                                  (0x3 << 29)
  23.  
  24. #define MI_NOOP                                 (CMD_MI | 0)
  25.  
  26. #define MI_BATCH_BUFFER_END                     (CMD_MI | (0xA << 23))
  27. #define MI_BATCH_BUFFER_START                   (CMD_MI | (0x31 << 23))
  28.  
  29. #define MI_FLUSH                                (CMD_MI | (0x4 << 23))
  30. #define   MI_FLUSH_STATE_INSTRUCTION_CACHE_INVALIDATE   (0x1 << 0)
  31.  
  32. #define MI_FLUSH_DW                             (CMD_MI | (0x26 << 23) | 0x2)
  33. #define   MI_FLUSH_DW_VIDEO_PIPELINE_CACHE_INVALIDATE   (0x1 << 7)
  34.  
  35. #define XY_COLOR_BLT_CMD                        (CMD_2D | (0x50 << 22) | 0x04)
  36. #define XY_COLOR_BLT_WRITE_ALPHA                (1 << 21)
  37. #define XY_COLOR_BLT_WRITE_RGB                  (1 << 20)
  38. #define XY_COLOR_BLT_DST_TILED                  (1 << 11)
  39.  
  40. /* BR13 */
  41. #define BR13_8                                  (0x0 << 24)
  42. #define BR13_565                                (0x1 << 24)
  43. #define BR13_1555                               (0x2 << 24)
  44. #define BR13_8888                               (0x3 << 24)
  45.  
  46. #define CMD_PIPE_CONTROL                        (CMD_3D | (3 << 27) | (2 << 24) | (0 << 16))
  47. #define CMD_PIPE_CONTROL_NOWRITE                (0 << 14)
  48. #define CMD_PIPE_CONTROL_WRITE_QWORD            (1 << 14)
  49. #define CMD_PIPE_CONTROL_WRITE_DEPTH            (2 << 14)
  50. #define CMD_PIPE_CONTROL_WRITE_TIME             (3 << 14)
  51. #define CMD_PIPE_CONTROL_DEPTH_STALL            (1 << 13)
  52. #define CMD_PIPE_CONTROL_WC_FLUSH               (1 << 12)
  53. #define CMD_PIPE_CONTROL_IS_FLUSH               (1 << 11)
  54. #define CMD_PIPE_CONTROL_TC_FLUSH               (1 << 10)
  55. #define CMD_PIPE_CONTROL_NOTIFY_ENABLE          (1 << 8)
  56. #define CMD_PIPE_CONTROL_DC_FLUSH               (1 << 5)
  57. #define CMD_PIPE_CONTROL_GLOBAL_GTT             (1 << 2)
  58. #define CMD_PIPE_CONTROL_LOCAL_PGTT             (0 << 2)
  59. #define CMD_PIPE_CONTROL_DEPTH_CACHE_FLUSH      (1 << 0)
  60.  
  61.  
  62. struct intel_batchbuffer;
  63.  
  64. #define ALIGN(i, n)    (((i) + (n) - 1) & ~((n) - 1))
  65. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  66. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  67. #define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
  68.  
  69. #define Bool int
  70. #define True 1
  71. #define False 0
  72.  
  73. #define SET_BLOCKED_SIGSET()   do {     \
  74.         sigset_t bl_mask;               \
  75.         sigfillset(&bl_mask);           \
  76.         sigdelset(&bl_mask, SIGFPE);    \
  77.         sigdelset(&bl_mask, SIGILL);    \
  78.         sigdelset(&bl_mask, SIGSEGV);   \
  79.         sigdelset(&bl_mask, SIGBUS);    \
  80.         sigdelset(&bl_mask, SIGKILL);   \
  81.         pthread_sigmask(SIG_SETMASK, &bl_mask, &intel->sa_mask); \
  82.     } while (0)
  83.  
  84. #define RESTORE_BLOCKED_SIGSET() do {    \
  85.         pthread_sigmask(SIG_SETMASK, &intel->sa_mask, NULL); \
  86.     } while (0)
  87.  
  88. #define PPTHREAD_MUTEX_LOCK() do {             \
  89.         SET_BLOCKED_SIGSET();                  \
  90.         pthread_mutex_lock(&intel->ctxmutex);       \
  91.     } while (0)
  92.  
  93. #define PPTHREAD_MUTEX_UNLOCK() do {           \
  94.         pthread_mutex_unlock(&intel->ctxmutex);     \
  95.         RESTORE_BLOCKED_SIGSET();              \
  96.     } while (0)
  97.  
  98. #define WARN_ONCE(...) do {                     \
  99.         static int g_once = 1;                  \
  100.         if (g_once) {                           \
  101.             g_once = 0;                         \
  102.             printf("WARNING: " __VA_ARGS__);    \
  103.         }                                       \
  104.     } while (0)
  105.  
  106. struct intel_driver_data
  107. {
  108.     int fd;
  109.     int device_id;
  110.     int revision;
  111.  
  112.     int dri2Enabled;
  113.  
  114.     sigset_t sa_mask;
  115. //    pthread_mutex_t ctxmutex;
  116.     int locked;
  117.  
  118.     dri_bufmgr *bufmgr;
  119.  
  120.     unsigned int has_exec2  : 1; /* Flag: has execbuffer2? */
  121.     unsigned int has_bsd    : 1; /* Flag: has bitstream decoder for H.264? */
  122.     unsigned int has_blt    : 1; /* Flag: has BLT unit? */
  123. };
  124.  
  125. Bool intel_driver_init(VADriverContextP ctx);
  126. Bool intel_driver_terminate(VADriverContextP ctx);
  127.  
  128. static INLINE struct intel_driver_data *
  129. intel_driver_data(VADriverContextP ctx)
  130. {
  131.     return (struct intel_driver_data *)ctx->pDriverData;
  132. }
  133.  
  134. struct intel_region
  135. {
  136.     int x;
  137.     int y;
  138.     unsigned int width;
  139.     unsigned int height;
  140.     unsigned int cpp;
  141.     unsigned int pitch;
  142.     unsigned int tiling;
  143.     unsigned int swizzle;
  144.     dri_bo *bo;
  145. };
  146.  
  147. #define PCI_CHIP_GM45_GM                0x2A42
  148. #define PCI_CHIP_IGD_E_G                0x2E02
  149. #define PCI_CHIP_Q45_G                  0x2E12
  150. #define PCI_CHIP_G45_G                  0x2E22
  151. #define PCI_CHIP_G41_G                  0x2E32
  152. #define PCI_CHIP_B43_G                  0x2E42
  153. #define PCI_CHIP_B43_G1                 0x2E92
  154.  
  155. #define PCI_CHIP_IRONLAKE_D_G           0x0042
  156. #define PCI_CHIP_IRONLAKE_M_G           0x0046
  157.  
  158. #ifndef PCI_CHIP_SANDYBRIDGE_GT1
  159. #define PCI_CHIP_SANDYBRIDGE_GT1        0x0102  /* Desktop */
  160. #define PCI_CHIP_SANDYBRIDGE_GT2        0x0112
  161. #define PCI_CHIP_SANDYBRIDGE_GT2_PLUS   0x0122
  162. #define PCI_CHIP_SANDYBRIDGE_M_GT1      0x0106  /* Mobile */
  163. #define PCI_CHIP_SANDYBRIDGE_M_GT2      0x0116
  164. #define PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS 0x0126
  165. #define PCI_CHIP_SANDYBRIDGE_S_GT       0x010A  /* Server */
  166. #endif
  167.  
  168. #define PCI_CHIP_IVYBRIDGE_GT1          0x0152  /* Desktop */
  169. #define PCI_CHIP_IVYBRIDGE_GT2          0x0162
  170. #define PCI_CHIP_IVYBRIDGE_M_GT1        0x0156  /* Mobile */
  171. #define PCI_CHIP_IVYBRIDGE_M_GT2        0x0166
  172. #define PCI_CHIP_IVYBRIDGE_S_GT1        0x015a  /* Server */
  173. #define PCI_CHIP_IVYBRIDGE_S_GT2        0x016a
  174.  
  175. #define PCI_CHIP_HASWELL_GT1            0x0402 /* Desktop */
  176. #define PCI_CHIP_HASWELL_GT2            0x0412
  177. #define PCI_CHIP_HASWELL_GT2_PLUS       0x0422
  178. #define PCI_CHIP_HASWELL_M_GT1          0x0406 /* Mobile */
  179. #define PCI_CHIP_HASWELL_M_GT2          0x0416
  180. #define PCI_CHIP_HASWELL_M_GT2_PLUS     0x0426
  181. #define PCI_CHIP_HASWELL_S_GT1          0x040a /* Server */
  182. #define PCI_CHIP_HASWELL_S_GT2          0x041a
  183. #define PCI_CHIP_HASWELL_S_GT2_PLUS     0x042a
  184.  
  185. #define PCI_CHIP_HASWELL_SDV_GT1                0x0c02 /* Desktop */
  186. #define PCI_CHIP_HASWELL_SDV_GT2                0x0c12
  187. #define PCI_CHIP_HASWELL_SDV_GT2_PLUS           0x0c22
  188. #define PCI_CHIP_HASWELL_SDV_M_GT1              0x0c06 /* Mobile */
  189. #define PCI_CHIP_HASWELL_SDV_M_GT2              0x0c16
  190. #define PCI_CHIP_HASWELL_SDV_M_GT2_PLUS         0x0c26
  191. #define PCI_CHIP_HASWELL_SDV_S_GT1              0x0c0a /* Server */
  192. #define PCI_CHIP_HASWELL_SDV_S_GT2              0x0c1a
  193. #define PCI_CHIP_HASWELL_SDV_S_GT2_PLUS         0x0c2a
  194.  
  195. #define PCI_CHIP_HASWELL_ULT_GT1                0x0A02 /* Desktop */
  196. #define PCI_CHIP_HASWELL_ULT_GT2                0x0A12
  197. #define PCI_CHIP_HASWELL_ULT_GT2_PLUS           0x0A22
  198. #define PCI_CHIP_HASWELL_ULT_M_GT1              0x0A06 /* Mobile */
  199. #define PCI_CHIP_HASWELL_ULT_M_GT2              0x0A16
  200. #define PCI_CHIP_HASWELL_ULT_M_GT2_PLUS         0x0A26
  201. #define PCI_CHIP_HASWELL_ULT_S_GT1              0x0A0A /* Server */
  202. #define PCI_CHIP_HASWELL_ULT_S_GT2              0x0A1A
  203. #define PCI_CHIP_HASWELL_ULT_S_GT2_PLUS         0x0A2A
  204.  
  205. #define PCI_CHIP_HASWELL_CRW_GT1                0x0D12 /* Desktop */
  206. #define PCI_CHIP_HASWELL_CRW_GT2                0x0D22
  207. #define PCI_CHIP_HASWELL_CRW_GT2_PLUS           0x0D32
  208. #define PCI_CHIP_HASWELL_CRW_M_GT1              0x0D16 /* Mobile */
  209. #define PCI_CHIP_HASWELL_CRW_M_GT2              0x0D26
  210. #define PCI_CHIP_HASWELL_CRW_M_GT2_PLUS         0x0D36
  211. #define PCI_CHIP_HASWELL_CRW_S_GT1              0x0D1A /* Server */
  212. #define PCI_CHIP_HASWELL_CRW_S_GT2              0x0D2A
  213. #define PCI_CHIP_HASWELL_CRW_S_GT2_PLUS         0x0D3A
  214.  
  215. #define IS_G45(devid)           (devid == PCI_CHIP_IGD_E_G ||   \
  216.                                  devid == PCI_CHIP_Q45_G ||     \
  217.                                  devid == PCI_CHIP_G45_G ||     \
  218.                                  devid == PCI_CHIP_G41_G ||     \
  219.                                  devid == PCI_CHIP_B43_G ||     \
  220.                                  devid == PCI_CHIP_B43_G1)
  221.  
  222. #define IS_GM45(devid)          (devid == PCI_CHIP_GM45_GM)
  223. #define IS_G4X(devid)           (IS_G45(devid) || IS_GM45(devid))
  224.  
  225. #define IS_IRONLAKE_D(devid)    (devid == PCI_CHIP_IRONLAKE_D_G)
  226. #define IS_IRONLAKE_M(devid)    (devid == PCI_CHIP_IRONLAKE_M_G)
  227. #define IS_IRONLAKE(devid)      (IS_IRONLAKE_D(devid) || IS_IRONLAKE_M(devid))
  228.  
  229. #define IS_SNB_GT1(devid)       (devid == PCI_CHIP_SANDYBRIDGE_GT1 ||   \
  230.                                  devid == PCI_CHIP_SANDYBRIDGE_M_GT1 || \
  231.                                  devid == PCI_CHIP_SANDYBRIDGE_S_GT)
  232.  
  233. #define IS_SNB_GT2(devid)       (devid == PCI_CHIP_SANDYBRIDGE_GT2 ||   \
  234.                                  devid == PCI_CHIP_SANDYBRIDGE_GT2_PLUS || \
  235.                                  devid == PCI_CHIP_SANDYBRIDGE_M_GT2 || \
  236.                                  devid == PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS)
  237.  
  238. #define IS_GEN6(devid)          (IS_SNB_GT1(devid) ||   \
  239.                                  IS_SNB_GT2(devid))
  240.  
  241. #define IS_IVB_GT1(devid)       (devid == PCI_CHIP_IVYBRIDGE_GT1 ||     \
  242.                                  devid == PCI_CHIP_IVYBRIDGE_M_GT1 ||   \
  243.                                  devid == PCI_CHIP_IVYBRIDGE_S_GT1)
  244.  
  245. #define IS_IVB_GT2(devid)       (devid == PCI_CHIP_IVYBRIDGE_GT2 ||     \
  246.                                  devid == PCI_CHIP_IVYBRIDGE_M_GT2 ||   \
  247.                                  devid == PCI_CHIP_IVYBRIDGE_S_GT2)
  248.  
  249. #define IS_IVYBRIDGE(devid)     (IS_IVB_GT1(devid) ||   \
  250.                                  IS_IVB_GT2(devid))
  251.  
  252. #define IS_HSW_GT1(devid)       (devid == PCI_CHIP_HASWELL_GT1          || \
  253.                                  devid == PCI_CHIP_HASWELL_M_GT1        || \
  254.                                  devid == PCI_CHIP_HASWELL_S_GT1        || \
  255.                                  devid == PCI_CHIP_HASWELL_SDV_GT1      || \
  256.                                  devid == PCI_CHIP_HASWELL_SDV_M_GT1    || \
  257.                                  devid == PCI_CHIP_HASWELL_SDV_S_GT1    || \
  258.                                  devid == PCI_CHIP_HASWELL_CRW_GT1      || \
  259.                                  devid == PCI_CHIP_HASWELL_CRW_M_GT1    || \
  260.                                  devid == PCI_CHIP_HASWELL_CRW_S_GT1    || \
  261.                                  devid == PCI_CHIP_HASWELL_ULT_GT1      || \
  262.                                  devid == PCI_CHIP_HASWELL_ULT_M_GT1    || \
  263.                                  devid == PCI_CHIP_HASWELL_ULT_S_GT1)
  264.  
  265. #define IS_HSW_GT2(devid)       (devid == PCI_CHIP_HASWELL_GT2||        \
  266.                                  devid == PCI_CHIP_HASWELL_M_GT2||      \
  267.                                  devid == PCI_CHIP_HASWELL_S_GT2||      \
  268.                                  devid == PCI_CHIP_HASWELL_SDV_GT2||    \
  269.                                  devid == PCI_CHIP_HASWELL_SDV_M_GT2||  \
  270.                                  devid == PCI_CHIP_HASWELL_SDV_S_GT2||  \
  271.                                  devid == PCI_CHIP_HASWELL_CRW_GT2||    \
  272.                                  devid == PCI_CHIP_HASWELL_CRW_M_GT2||  \
  273.                                  devid == PCI_CHIP_HASWELL_CRW_S_GT2||  \
  274.                                  devid == PCI_CHIP_HASWELL_ULT_GT2||    \
  275.                                  devid == PCI_CHIP_HASWELL_ULT_GT2_PLUS|| \
  276.                                  devid == PCI_CHIP_HASWELL_ULT_M_GT2||  \
  277.                                  devid == PCI_CHIP_HASWELL_ULT_M_GT2_PLUS|| \
  278.                                  devid == PCI_CHIP_HASWELL_ULT_S_GT2    || \
  279.                                  devid == PCI_CHIP_HASWELL_ULT_S_GT2_PLUS || \
  280.                                  devid == PCI_CHIP_HASWELL_GT2_PLUS||   \
  281.                                  devid == PCI_CHIP_HASWELL_M_GT2_PLUS    || \
  282.                                  devid == PCI_CHIP_HASWELL_S_GT2_PLUS           || \
  283.                                  devid == PCI_CHIP_HASWELL_SDV_GT2_PLUS|| \
  284.                                  devid == PCI_CHIP_HASWELL_SDV_M_GT2_PLUS|| \
  285.                                  devid == PCI_CHIP_HASWELL_SDV_S_GT2_PLUS|| \
  286.                                  devid == PCI_CHIP_HASWELL_CRW_GT2_PLUS|| \
  287.                                  devid == PCI_CHIP_HASWELL_CRW_M_GT2_PLUS|| \
  288.                                  devid == PCI_CHIP_HASWELL_CRW_S_GT2_PLUS)
  289.  
  290. #define IS_HASWELL(devid)       (IS_HSW_GT1(devid) || \
  291.                                  IS_HSW_GT2(devid))
  292.  
  293. #define IS_GEN7(devid)          (IS_IVYBRIDGE(devid) || \
  294.                                  IS_HASWELL(devid))
  295.  
  296. #ifndef I915_EXEC_VEBOX
  297. #define I915_EXEC_VEBOX         4
  298. #endif
  299.  
  300. #endif /* _INTEL_DRIVER_H_ */
  301.