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 | |
Daniel Vetter | 870e86d | 2010-08-02 16:29:44 +0200 | [diff] [blame] | 10 | #define I915_READ_TAIL(ring) I915_READ(RING_TAIL(ring->mmio_base)) |
| 11 | #define I915_WRITE_TAIL(ring, val) I915_WRITE(RING_TAIL(ring->mmio_base), val) |
Daniel Vetter | 6c0e1c5 | 2010-08-02 16:33:33 +0200 | [diff] [blame] | 12 | #define I915_READ_START(ring) I915_READ(RING_START(ring->mmio_base)) |
| 13 | #define I915_WRITE_START(ring, val) I915_WRITE(RING_START(ring->mmio_base), val) |
Daniel Vetter | 570ef60 | 2010-08-02 17:06:23 +0200 | [diff] [blame] | 14 | #define I915_READ_HEAD(ring) I915_READ(RING_HEAD(ring->mmio_base)) |
| 15 | #define I915_WRITE_HEAD(ring, val) I915_WRITE(RING_HEAD(ring->mmio_base), val) |
Daniel Vetter | 7f2ab69 | 2010-08-02 17:06:59 +0200 | [diff] [blame] | 16 | #define I915_READ_CTL(ring) I915_READ(RING_CTL(ring->mmio_base)) |
| 17 | #define I915_WRITE_CTL(ring, val) I915_WRITE(RING_CTL(ring->mmio_base), val) |
Daniel Vetter | 870e86d | 2010-08-02 16:29:44 +0200 | [diff] [blame] | 18 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 19 | struct drm_i915_gem_execbuffer2; |
| 20 | struct intel_ring_buffer { |
| 21 | const char *name; |
Chris Wilson | 9220434 | 2010-09-18 11:02:01 +0100 | [diff] [blame] | 22 | enum intel_ring_id { |
| 23 | RING_RENDER = 0x1, |
| 24 | RING_BSD = 0x2, |
| 25 | } id; |
Daniel Vetter | 333e9fe | 2010-08-02 16:24:01 +0200 | [diff] [blame] | 26 | u32 mmio_base; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 27 | unsigned long size; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 28 | void *virtual_start; |
| 29 | struct drm_device *dev; |
| 30 | struct drm_gem_object *gem_object; |
| 31 | |
| 32 | unsigned int head; |
| 33 | unsigned int tail; |
Chris Wilson | 780f0ca | 2010-09-23 17:45:39 +0100 | [diff] [blame] | 34 | int space; |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 35 | struct intel_hw_status_page status_page; |
| 36 | |
| 37 | u32 irq_gem_seqno; /* last seq seem at irq time */ |
| 38 | u32 waiting_gem_seqno; |
| 39 | int user_irq_refcount; |
| 40 | void (*user_irq_get)(struct drm_device *dev, |
| 41 | struct intel_ring_buffer *ring); |
| 42 | void (*user_irq_put)(struct drm_device *dev, |
| 43 | struct intel_ring_buffer *ring); |
| 44 | void (*setup_status_page)(struct drm_device *dev, |
| 45 | struct intel_ring_buffer *ring); |
| 46 | |
| 47 | int (*init)(struct drm_device *dev, |
| 48 | struct intel_ring_buffer *ring); |
| 49 | |
Xiang, Haihao | d46eefa | 2010-09-16 10:43:12 +0800 | [diff] [blame] | 50 | void (*set_tail)(struct drm_device *dev, |
Daniel Vetter | 870e86d | 2010-08-02 16:29:44 +0200 | [diff] [blame] | 51 | struct intel_ring_buffer *ring, |
| 52 | u32 value); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 53 | unsigned int (*get_active_head)(struct drm_device *dev, |
| 54 | struct intel_ring_buffer *ring); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 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 | |
| 89 | wait_queue_head_t irq_queue; |
| 90 | drm_local_map_t map; |
| 91 | }; |
| 92 | |
| 93 | static inline u32 |
| 94 | intel_read_status_page(struct intel_ring_buffer *ring, |
| 95 | int reg) |
| 96 | { |
| 97 | u32 *regs = ring->status_page.page_addr; |
| 98 | return regs[reg]; |
| 99 | } |
| 100 | |
| 101 | int intel_init_ring_buffer(struct drm_device *dev, |
Chris Wilson | ab6f8e3 | 2010-09-19 17:53:44 +0100 | [diff] [blame] | 102 | struct intel_ring_buffer *ring); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 103 | void intel_cleanup_ring_buffer(struct drm_device *dev, |
Chris Wilson | ab6f8e3 | 2010-09-19 17:53:44 +0100 | [diff] [blame] | 104 | struct intel_ring_buffer *ring); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 105 | int intel_wait_ring_buffer(struct drm_device *dev, |
Chris Wilson | ab6f8e3 | 2010-09-19 17:53:44 +0100 | [diff] [blame] | 106 | struct intel_ring_buffer *ring, int n); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 107 | void intel_ring_begin(struct drm_device *dev, |
Chris Wilson | ab6f8e3 | 2010-09-19 17:53:44 +0100 | [diff] [blame] | 108 | struct intel_ring_buffer *ring, int n); |
Chris Wilson | e898cd2 | 2010-08-04 15:18:14 +0100 | [diff] [blame] | 109 | |
| 110 | static inline void intel_ring_emit(struct drm_device *dev, |
| 111 | struct intel_ring_buffer *ring, |
| 112 | unsigned int data) |
| 113 | { |
| 114 | unsigned int *virt = ring->virtual_start + ring->tail; |
| 115 | *virt = data; |
| 116 | ring->tail += 4; |
| 117 | } |
| 118 | |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 119 | void intel_fill_struct(struct drm_device *dev, |
| 120 | struct intel_ring_buffer *ring, |
| 121 | void *data, |
| 122 | unsigned int len); |
| 123 | void intel_ring_advance(struct drm_device *dev, |
| 124 | struct intel_ring_buffer *ring); |
| 125 | |
| 126 | u32 intel_ring_get_seqno(struct drm_device *dev, |
| 127 | struct intel_ring_buffer *ring); |
| 128 | |
Xiang, Haihao | 5c1143b | 2010-09-16 10:43:11 +0800 | [diff] [blame] | 129 | int intel_init_render_ring_buffer(struct drm_device *dev); |
| 130 | int intel_init_bsd_ring_buffer(struct drm_device *dev); |
Zou Nan hai | 8187a2b | 2010-05-21 09:08:55 +0800 | [diff] [blame] | 131 | |
| 132 | #endif /* _INTEL_RINGBUFFER_H_ */ |