Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 1 | #ifndef _INTEL_RINGBUFFER_H_ |
| 2 | #define _INTEL_RINGBUFFER_H_ |
| 3 | |
| 4 | struct intel_hw_status_page { |
| 5 | void *page_addr; |
| 6 | unsigned int gfx_addr; |
| 7 | struct drm_gem_object *obj; |
| 8 | }; |
| 9 | |
| 10 | struct drm_i915_gem_execbuffer2; |
| 11 | struct intel_ring_buffer { |
| 12 | const char *name; |
| 13 | struct ring_regs { |
| 14 | u32 ctl; |
| 15 | u32 head; |
| 16 | u32 tail; |
| 17 | u32 start; |
| 18 | } regs; |
| 19 | unsigned int ring_flag; |
| 20 | unsigned long size; |
| 21 | unsigned int alignment; |
| 22 | void *virtual_start; |
| 23 | struct drm_device *dev; |
| 24 | struct drm_gem_object *gem_object; |
| 25 | |
| 26 | unsigned int head; |
| 27 | unsigned int tail; |
| 28 | unsigned int space; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 29 | struct intel_hw_status_page status_page; |
| 30 | |
| 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 | |
| 41 | int (*init)(struct drm_device *dev, |
| 42 | struct intel_ring_buffer *ring); |
| 43 | |
| 44 | unsigned int (*get_head)(struct drm_device *dev, |
| 45 | struct intel_ring_buffer *ring); |
| 46 | unsigned int (*get_tail)(struct drm_device *dev, |
| 47 | struct intel_ring_buffer *ring); |
| 48 | unsigned int (*get_active_head)(struct drm_device *dev, |
| 49 | struct intel_ring_buffer *ring); |
| 50 | void (*advance_ring)(struct drm_device *dev, |
| 51 | struct intel_ring_buffer *ring); |
| 52 | void (*flush)(struct drm_device *dev, |
| 53 | struct intel_ring_buffer *ring, |
| 54 | u32 invalidate_domains, |
| 55 | u32 flush_domains); |
| 56 | u32 (*add_request)(struct drm_device *dev, |
| 57 | struct intel_ring_buffer *ring, |
| 58 | struct drm_file *file_priv, |
| 59 | u32 flush_domains); |
| 60 | u32 (*get_gem_seqno)(struct drm_device *dev, |
| 61 | struct intel_ring_buffer *ring); |
| 62 | int (*dispatch_gem_execbuffer)(struct drm_device *dev, |
| 63 | struct intel_ring_buffer *ring, |
| 64 | struct drm_i915_gem_execbuffer2 *exec, |
| 65 | struct drm_clip_rect *cliprects, |
| 66 | uint64_t exec_offset); |
| 67 | |
| 68 | /** |
| 69 | * List of objects currently involved in rendering from the |
| 70 | * ringbuffer. |
| 71 | * |
| 72 | * Includes buffers having the contents of their GPU caches |
| 73 | * flushed, not necessarily primitives. last_rendering_seqno |
| 74 | * represents when the rendering involved will be completed. |
| 75 | * |
| 76 | * A reference is held on the buffer while on this list. |
| 77 | */ |
| 78 | struct list_head active_list; |
| 79 | |
| 80 | /** |
| 81 | * List of breadcrumbs associated with GPU requests currently |
| 82 | * outstanding. |
| 83 | */ |
| 84 | struct list_head request_list; |
| 85 | |
Daniel Vetter | a691043 | 2010-02-02 17:08:37 +0100 | [diff] [blame^] | 86 | /** |
| 87 | * Do we have some not yet emitted requests outstanding? |
| 88 | */ |
| 89 | bool outstanding_lazy_request; |
| 90 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 91 | wait_queue_head_t irq_queue; |
| 92 | drm_local_map_t map; |
| 93 | }; |
| 94 | |
| 95 | static inline u32 |
| 96 | intel_read_status_page(struct intel_ring_buffer *ring, |
| 97 | int reg) |
| 98 | { |
| 99 | u32 *regs = ring->status_page.page_addr; |
| 100 | return regs[reg]; |
| 101 | } |
| 102 | |
| 103 | int intel_init_ring_buffer(struct drm_device *dev, |
| 104 | struct intel_ring_buffer *ring); |
| 105 | void intel_cleanup_ring_buffer(struct drm_device *dev, |
| 106 | struct intel_ring_buffer *ring); |
| 107 | int intel_wait_ring_buffer(struct drm_device *dev, |
| 108 | struct intel_ring_buffer *ring, int n); |
| 109 | int intel_wrap_ring_buffer(struct drm_device *dev, |
| 110 | struct intel_ring_buffer *ring); |
| 111 | void intel_ring_begin(struct drm_device *dev, |
| 112 | struct intel_ring_buffer *ring, int n); |
Chris Wilson | e898cd2 | 2010-08-04 15:18:14 +0100 | [diff] [blame] | 113 | |
| 114 | static inline void intel_ring_emit(struct drm_device *dev, |
| 115 | struct intel_ring_buffer *ring, |
| 116 | unsigned int data) |
| 117 | { |
| 118 | unsigned int *virt = ring->virtual_start + ring->tail; |
| 119 | *virt = data; |
| 120 | ring->tail += 4; |
| 121 | } |
| 122 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 123 | void intel_fill_struct(struct drm_device *dev, |
| 124 | struct intel_ring_buffer *ring, |
| 125 | void *data, |
| 126 | unsigned int len); |
| 127 | void intel_ring_advance(struct drm_device *dev, |
| 128 | struct intel_ring_buffer *ring); |
| 129 | |
| 130 | u32 intel_ring_get_seqno(struct drm_device *dev, |
| 131 | struct intel_ring_buffer *ring); |
| 132 | |
| 133 | extern struct intel_ring_buffer render_ring; |
| 134 | extern struct intel_ring_buffer bsd_ring; |
| 135 | |
| 136 | #endif /* _INTEL_RINGBUFFER_H_ */ |