intel_ringbuffer.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef _INTEL_RINGBUFFER_H_
  2. #define _INTEL_RINGBUFFER_H_
  3. struct intel_hw_status_page {
  4. void *page_addr;
  5. unsigned int gfx_addr;
  6. struct drm_gem_object *obj;
  7. };
  8. struct drm_i915_gem_execbuffer2;
  9. struct intel_ring_buffer {
  10. const char *name;
  11. struct ring_regs {
  12. u32 ctl;
  13. u32 head;
  14. u32 tail;
  15. u32 start;
  16. } regs;
  17. unsigned int ring_flag;
  18. unsigned long size;
  19. unsigned int alignment;
  20. void *virtual_start;
  21. struct drm_device *dev;
  22. struct drm_gem_object *gem_object;
  23. unsigned int head;
  24. unsigned int tail;
  25. unsigned int space;
  26. u32 next_seqno;
  27. struct intel_hw_status_page status_page;
  28. u32 irq_gem_seqno; /* last seq seem at irq time */
  29. u32 waiting_gem_seqno;
  30. int user_irq_refcount;
  31. void (*user_irq_get)(struct drm_device *dev,
  32. struct intel_ring_buffer *ring);
  33. void (*user_irq_put)(struct drm_device *dev,
  34. struct intel_ring_buffer *ring);
  35. void (*setup_status_page)(struct drm_device *dev,
  36. struct intel_ring_buffer *ring);
  37. int (*init)(struct drm_device *dev,
  38. struct intel_ring_buffer *ring);
  39. unsigned int (*get_head)(struct drm_device *dev,
  40. struct intel_ring_buffer *ring);
  41. unsigned int (*get_tail)(struct drm_device *dev,
  42. struct intel_ring_buffer *ring);
  43. unsigned int (*get_active_head)(struct drm_device *dev,
  44. struct intel_ring_buffer *ring);
  45. void (*advance_ring)(struct drm_device *dev,
  46. struct intel_ring_buffer *ring);
  47. void (*flush)(struct drm_device *dev,
  48. struct intel_ring_buffer *ring,
  49. u32 invalidate_domains,
  50. u32 flush_domains);
  51. u32 (*add_request)(struct drm_device *dev,
  52. struct intel_ring_buffer *ring,
  53. struct drm_file *file_priv,
  54. u32 flush_domains);
  55. u32 (*get_gem_seqno)(struct drm_device *dev,
  56. struct intel_ring_buffer *ring);
  57. int (*dispatch_gem_execbuffer)(struct drm_device *dev,
  58. struct intel_ring_buffer *ring,
  59. struct drm_i915_gem_execbuffer2 *exec,
  60. struct drm_clip_rect *cliprects,
  61. uint64_t exec_offset);
  62. /**
  63. * List of objects currently involved in rendering from the
  64. * ringbuffer.
  65. *
  66. * Includes buffers having the contents of their GPU caches
  67. * flushed, not necessarily primitives. last_rendering_seqno
  68. * represents when the rendering involved will be completed.
  69. *
  70. * A reference is held on the buffer while on this list.
  71. */
  72. struct list_head active_list;
  73. /**
  74. * List of breadcrumbs associated with GPU requests currently
  75. * outstanding.
  76. */
  77. struct list_head request_list;
  78. wait_queue_head_t irq_queue;
  79. drm_local_map_t map;
  80. };
  81. static inline u32
  82. intel_read_status_page(struct intel_ring_buffer *ring,
  83. int reg)
  84. {
  85. u32 *regs = ring->status_page.page_addr;
  86. return regs[reg];
  87. }
  88. int intel_init_ring_buffer(struct drm_device *dev,
  89. struct intel_ring_buffer *ring);
  90. void intel_cleanup_ring_buffer(struct drm_device *dev,
  91. struct intel_ring_buffer *ring);
  92. int intel_wait_ring_buffer(struct drm_device *dev,
  93. struct intel_ring_buffer *ring, int n);
  94. int intel_wrap_ring_buffer(struct drm_device *dev,
  95. struct intel_ring_buffer *ring);
  96. void intel_ring_begin(struct drm_device *dev,
  97. struct intel_ring_buffer *ring, int n);
  98. void intel_ring_emit(struct drm_device *dev,
  99. struct intel_ring_buffer *ring, u32 data);
  100. void intel_fill_struct(struct drm_device *dev,
  101. struct intel_ring_buffer *ring,
  102. void *data,
  103. unsigned int len);
  104. void intel_ring_advance(struct drm_device *dev,
  105. struct intel_ring_buffer *ring);
  106. u32 intel_ring_get_seqno(struct drm_device *dev,
  107. struct intel_ring_buffer *ring);
  108. extern struct intel_ring_buffer render_ring;
  109. extern struct intel_ring_buffer bsd_ring;
  110. #endif /* _INTEL_RINGBUFFER_H_ */