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