intel_ringbuffer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. enum intel_ring_id {
  12. RING_RENDER = 0x1,
  13. RING_BSD = 0x2,
  14. } id;
  15. struct ring_regs {
  16. u32 ctl;
  17. u32 head;
  18. u32 tail;
  19. u32 start;
  20. } regs;
  21. u32 mmio_base;
  22. unsigned long size;
  23. unsigned int alignment;
  24. void *virtual_start;
  25. struct drm_device *dev;
  26. struct drm_gem_object *gem_object;
  27. unsigned int head;
  28. unsigned int tail;
  29. unsigned int space;
  30. struct intel_hw_status_page status_page;
  31. u32 irq_gem_seqno; /* last seq seem at irq time */
  32. u32 waiting_gem_seqno;
  33. int user_irq_refcount;
  34. void (*user_irq_get)(struct drm_device *dev,
  35. struct intel_ring_buffer *ring);
  36. void (*user_irq_put)(struct drm_device *dev,
  37. struct intel_ring_buffer *ring);
  38. void (*setup_status_page)(struct drm_device *dev,
  39. struct intel_ring_buffer *ring);
  40. int (*init)(struct drm_device *dev,
  41. struct intel_ring_buffer *ring);
  42. unsigned int (*get_head)(struct drm_device *dev,
  43. struct intel_ring_buffer *ring);
  44. unsigned int (*get_tail)(struct drm_device *dev,
  45. struct intel_ring_buffer *ring);
  46. void (*set_tail)(struct drm_device *dev,
  47. u32 value);
  48. unsigned int (*get_active_head)(struct drm_device *dev,
  49. struct intel_ring_buffer *ring);
  50. void (*flush)(struct drm_device *dev,
  51. struct intel_ring_buffer *ring,
  52. u32 invalidate_domains,
  53. u32 flush_domains);
  54. u32 (*add_request)(struct drm_device *dev,
  55. struct intel_ring_buffer *ring,
  56. struct drm_file *file_priv,
  57. u32 flush_domains);
  58. u32 (*get_gem_seqno)(struct drm_device *dev,
  59. struct intel_ring_buffer *ring);
  60. int (*dispatch_gem_execbuffer)(struct drm_device *dev,
  61. struct intel_ring_buffer *ring,
  62. struct drm_i915_gem_execbuffer2 *exec,
  63. struct drm_clip_rect *cliprects,
  64. uint64_t exec_offset);
  65. /**
  66. * List of objects currently involved in rendering from the
  67. * ringbuffer.
  68. *
  69. * Includes buffers having the contents of their GPU caches
  70. * flushed, not necessarily primitives. last_rendering_seqno
  71. * represents when the rendering involved will be completed.
  72. *
  73. * A reference is held on the buffer while on this list.
  74. */
  75. struct list_head active_list;
  76. /**
  77. * List of breadcrumbs associated with GPU requests currently
  78. * outstanding.
  79. */
  80. struct list_head request_list;
  81. /**
  82. * Do we have some not yet emitted requests outstanding?
  83. */
  84. bool outstanding_lazy_request;
  85. wait_queue_head_t irq_queue;
  86. drm_local_map_t map;
  87. };
  88. static inline u32
  89. intel_read_status_page(struct intel_ring_buffer *ring,
  90. int reg)
  91. {
  92. u32 *regs = ring->status_page.page_addr;
  93. return regs[reg];
  94. }
  95. int intel_init_ring_buffer(struct drm_device *dev,
  96. struct intel_ring_buffer *ring);
  97. void intel_cleanup_ring_buffer(struct drm_device *dev,
  98. struct intel_ring_buffer *ring);
  99. int intel_wait_ring_buffer(struct drm_device *dev,
  100. struct intel_ring_buffer *ring, int n);
  101. int intel_wrap_ring_buffer(struct drm_device *dev,
  102. struct intel_ring_buffer *ring);
  103. void intel_ring_begin(struct drm_device *dev,
  104. struct intel_ring_buffer *ring, int n);
  105. static inline void intel_ring_emit(struct drm_device *dev,
  106. struct intel_ring_buffer *ring,
  107. unsigned int data)
  108. {
  109. unsigned int *virt = ring->virtual_start + ring->tail;
  110. *virt = data;
  111. ring->tail += 4;
  112. }
  113. void intel_fill_struct(struct drm_device *dev,
  114. struct intel_ring_buffer *ring,
  115. void *data,
  116. unsigned int len);
  117. void intel_ring_advance(struct drm_device *dev,
  118. struct intel_ring_buffer *ring);
  119. u32 intel_ring_get_seqno(struct drm_device *dev,
  120. struct intel_ring_buffer *ring);
  121. int intel_init_render_ring_buffer(struct drm_device *dev);
  122. int intel_init_bsd_ring_buffer(struct drm_device *dev);
  123. #endif /* _INTEL_RINGBUFFER_H_ */