xref: /linux/drivers/gpu/drm/radeon/radeon_drv.h (revision 78538bf14995a136c2d9a22159ada49937359119)
1c0e09200SDave Airlie /* radeon_drv.h -- Private header for radeon driver -*- linux-c -*-
2c0e09200SDave Airlie  *
3c0e09200SDave Airlie  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
4c0e09200SDave Airlie  * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
5c0e09200SDave Airlie  * All rights reserved.
6c0e09200SDave Airlie  *
7c0e09200SDave Airlie  * Permission is hereby granted, free of charge, to any person obtaining a
8c0e09200SDave Airlie  * copy of this software and associated documentation files (the "Software"),
9c0e09200SDave Airlie  * to deal in the Software without restriction, including without limitation
10c0e09200SDave Airlie  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11c0e09200SDave Airlie  * and/or sell copies of the Software, and to permit persons to whom the
12c0e09200SDave Airlie  * Software is furnished to do so, subject to the following conditions:
13c0e09200SDave Airlie  *
14c0e09200SDave Airlie  * The above copyright notice and this permission notice (including the next
15c0e09200SDave Airlie  * paragraph) shall be included in all copies or substantial portions of the
16c0e09200SDave Airlie  * Software.
17c0e09200SDave Airlie  *
18c0e09200SDave Airlie  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19c0e09200SDave Airlie  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20c0e09200SDave Airlie  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21c0e09200SDave Airlie  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22c0e09200SDave Airlie  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23c0e09200SDave Airlie  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24c0e09200SDave Airlie  * DEALINGS IN THE SOFTWARE.
25c0e09200SDave Airlie  *
26c0e09200SDave Airlie  * Authors:
27c0e09200SDave Airlie  *    Kevin E. Martin <martin@valinux.com>
28c0e09200SDave Airlie  *    Gareth Hughes <gareth@valinux.com>
29c0e09200SDave Airlie  */
30c0e09200SDave Airlie 
31c0e09200SDave Airlie #ifndef __RADEON_DRV_H__
32c0e09200SDave Airlie #define __RADEON_DRV_H__
33c0e09200SDave Airlie 
34c0e09200SDave Airlie /* General customization:
35c0e09200SDave Airlie  */
36c0e09200SDave Airlie 
37c0e09200SDave Airlie #define DRIVER_AUTHOR		"Gareth Hughes, Keith Whitwell, others."
38c0e09200SDave Airlie 
39c0e09200SDave Airlie #define DRIVER_NAME		"radeon"
40c0e09200SDave Airlie #define DRIVER_DESC		"ATI Radeon"
41c0e09200SDave Airlie #define DRIVER_DATE		"20080528"
42c0e09200SDave Airlie 
43c0e09200SDave Airlie /* Interface history:
44c0e09200SDave Airlie  *
45c0e09200SDave Airlie  * 1.1 - ??
46c0e09200SDave Airlie  * 1.2 - Add vertex2 ioctl (keith)
47c0e09200SDave Airlie  *     - Add stencil capability to clear ioctl (gareth, keith)
48c0e09200SDave Airlie  *     - Increase MAX_TEXTURE_LEVELS (brian)
49c0e09200SDave Airlie  * 1.3 - Add cmdbuf ioctl (keith)
50c0e09200SDave Airlie  *     - Add support for new radeon packets (keith)
51c0e09200SDave Airlie  *     - Add getparam ioctl (keith)
52c0e09200SDave Airlie  *     - Add flip-buffers ioctl, deprecate fullscreen foo (keith).
53c0e09200SDave Airlie  * 1.4 - Add scratch registers to get_param ioctl.
54c0e09200SDave Airlie  * 1.5 - Add r200 packets to cmdbuf ioctl
55c0e09200SDave Airlie  *     - Add r200 function to init ioctl
56c0e09200SDave Airlie  *     - Add 'scalar2' instruction to cmdbuf
57c0e09200SDave Airlie  * 1.6 - Add static GART memory manager
58c0e09200SDave Airlie  *       Add irq handler (won't be turned on unless X server knows to)
59c0e09200SDave Airlie  *       Add irq ioctls and irq_active getparam.
60c0e09200SDave Airlie  *       Add wait command for cmdbuf ioctl
61c0e09200SDave Airlie  *       Add GART offset query for getparam
62c0e09200SDave Airlie  * 1.7 - Add support for cube map registers: R200_PP_CUBIC_FACES_[0..5]
63c0e09200SDave Airlie  *       and R200_PP_CUBIC_OFFSET_F1_[0..5].
64c0e09200SDave Airlie  *       Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and
65c0e09200SDave Airlie  *       R200_EMIT_PP_CUBIC_OFFSETS_[0..5].  (brian)
66c0e09200SDave Airlie  * 1.8 - Remove need to call cleanup ioctls on last client exit (keith)
67c0e09200SDave Airlie  *       Add 'GET' queries for starting additional clients on different VT's.
68c0e09200SDave Airlie  * 1.9 - Add DRM_IOCTL_RADEON_CP_RESUME ioctl.
69c0e09200SDave Airlie  *       Add texture rectangle support for r100.
70c0e09200SDave Airlie  * 1.10- Add SETPARAM ioctl; first parameter to set is FB_LOCATION, which
71c0e09200SDave Airlie  *       clients use to tell the DRM where they think the framebuffer is
72c0e09200SDave Airlie  *       located in the card's address space
73c0e09200SDave Airlie  * 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color
74c0e09200SDave Airlie  *       and GL_EXT_blend_[func|equation]_separate on r200
75c0e09200SDave Airlie  * 1.12- Add R300 CP microcode support - this just loads the CP on r300
76c0e09200SDave Airlie  *       (No 3D support yet - just microcode loading).
77c0e09200SDave Airlie  * 1.13- Add packet R200_EMIT_TCL_POINT_SPRITE_CNTL for ARB_point_parameters
78c0e09200SDave Airlie  *     - Add hyperz support, add hyperz flags to clear ioctl.
79c0e09200SDave Airlie  * 1.14- Add support for color tiling
80c0e09200SDave Airlie  *     - Add R100/R200 surface allocation/free support
81c0e09200SDave Airlie  * 1.15- Add support for texture micro tiling
82c0e09200SDave Airlie  *     - Add support for r100 cube maps
83c0e09200SDave Airlie  * 1.16- Add R200_EMIT_PP_TRI_PERF_CNTL packet to support brilinear
84c0e09200SDave Airlie  *       texture filtering on r200
85c0e09200SDave Airlie  * 1.17- Add initial support for R300 (3D).
86c0e09200SDave Airlie  * 1.18- Add support for GL_ATI_fragment_shader, new packets
87c0e09200SDave Airlie  *       R200_EMIT_PP_AFS_0/1, R200_EMIT_PP_TXCTLALL_0-5 (replaces
88c0e09200SDave Airlie  *       R200_EMIT_PP_TXFILTER_0-5, 2 more regs) and R200_EMIT_ATF_TFACTOR
89c0e09200SDave Airlie  *       (replaces R200_EMIT_TFACTOR_0 (8 consts instead of 6)
90c0e09200SDave Airlie  * 1.19- Add support for gart table in FB memory and PCIE r300
91c0e09200SDave Airlie  * 1.20- Add support for r300 texrect
92c0e09200SDave Airlie  * 1.21- Add support for card type getparam
93c0e09200SDave Airlie  * 1.22- Add support for texture cache flushes (R300_TX_CNTL)
94c0e09200SDave Airlie  * 1.23- Add new radeon memory map work from benh
95c0e09200SDave Airlie  * 1.24- Add general-purpose packet for manipulating scratch registers (r300)
96c0e09200SDave Airlie  * 1.25- Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL,
97c0e09200SDave Airlie  *       new packet type)
98c0e09200SDave Airlie  * 1.26- Add support for variable size PCI(E) gart aperture
99c0e09200SDave Airlie  * 1.27- Add support for IGP GART
100c0e09200SDave Airlie  * 1.28- Add support for VBL on CRTC2
101c0e09200SDave Airlie  * 1.29- R500 3D cmd buffer support
102c0e09200SDave Airlie  */
103c0e09200SDave Airlie #define DRIVER_MAJOR		1
104c0e09200SDave Airlie #define DRIVER_MINOR		29
105c0e09200SDave Airlie #define DRIVER_PATCHLEVEL	0
106c0e09200SDave Airlie 
107c0e09200SDave Airlie /*
108c0e09200SDave Airlie  * Radeon chip families
109c0e09200SDave Airlie  */
110c0e09200SDave Airlie enum radeon_family {
111c0e09200SDave Airlie 	CHIP_R100,
112c0e09200SDave Airlie 	CHIP_RV100,
113c0e09200SDave Airlie 	CHIP_RS100,
114c0e09200SDave Airlie 	CHIP_RV200,
115c0e09200SDave Airlie 	CHIP_RS200,
116c0e09200SDave Airlie 	CHIP_R200,
117c0e09200SDave Airlie 	CHIP_RV250,
118c0e09200SDave Airlie 	CHIP_RS300,
119c0e09200SDave Airlie 	CHIP_RV280,
120c0e09200SDave Airlie 	CHIP_R300,
121c0e09200SDave Airlie 	CHIP_R350,
122c0e09200SDave Airlie 	CHIP_RV350,
123c0e09200SDave Airlie 	CHIP_RV380,
124c0e09200SDave Airlie 	CHIP_R420,
125edc6f389SAlex Deucher 	CHIP_R423,
126c0e09200SDave Airlie 	CHIP_RV410,
127b2ceddfaSAlex Deucher 	CHIP_RS400,
128c0e09200SDave Airlie 	CHIP_RS480,
129c0e09200SDave Airlie 	CHIP_RS690,
130f0738e92SAlex Deucher 	CHIP_RS740,
131c0e09200SDave Airlie 	CHIP_RV515,
132c0e09200SDave Airlie 	CHIP_R520,
133c0e09200SDave Airlie 	CHIP_RV530,
134c0e09200SDave Airlie 	CHIP_RV560,
135c0e09200SDave Airlie 	CHIP_RV570,
136c0e09200SDave Airlie 	CHIP_R580,
137c0e09200SDave Airlie 	CHIP_LAST,
138c0e09200SDave Airlie };
139c0e09200SDave Airlie 
140c0e09200SDave Airlie enum radeon_cp_microcode_version {
141c0e09200SDave Airlie 	UCODE_R100,
142c0e09200SDave Airlie 	UCODE_R200,
143c0e09200SDave Airlie 	UCODE_R300,
144c0e09200SDave Airlie };
145c0e09200SDave Airlie 
146c0e09200SDave Airlie /*
147c0e09200SDave Airlie  * Chip flags
148c0e09200SDave Airlie  */
149c0e09200SDave Airlie enum radeon_chip_flags {
150c0e09200SDave Airlie 	RADEON_FAMILY_MASK = 0x0000ffffUL,
151c0e09200SDave Airlie 	RADEON_FLAGS_MASK = 0xffff0000UL,
152c0e09200SDave Airlie 	RADEON_IS_MOBILITY = 0x00010000UL,
153c0e09200SDave Airlie 	RADEON_IS_IGP = 0x00020000UL,
154c0e09200SDave Airlie 	RADEON_SINGLE_CRTC = 0x00040000UL,
155c0e09200SDave Airlie 	RADEON_IS_AGP = 0x00080000UL,
156c0e09200SDave Airlie 	RADEON_HAS_HIERZ = 0x00100000UL,
157c0e09200SDave Airlie 	RADEON_IS_PCIE = 0x00200000UL,
158c0e09200SDave Airlie 	RADEON_NEW_MEMMAP = 0x00400000UL,
159c0e09200SDave Airlie 	RADEON_IS_PCI = 0x00800000UL,
160c0e09200SDave Airlie 	RADEON_IS_IGPGART = 0x01000000UL,
161c0e09200SDave Airlie };
162c0e09200SDave Airlie 
163c0e09200SDave Airlie #define GET_RING_HEAD(dev_priv)	(dev_priv->writeback_works ? \
164c0e09200SDave Airlie         DRM_READ32(  (dev_priv)->ring_rptr, 0 ) : RADEON_READ(RADEON_CP_RB_RPTR))
165c0e09200SDave Airlie #define SET_RING_HEAD(dev_priv,val)	DRM_WRITE32( (dev_priv)->ring_rptr, 0, (val) )
166c0e09200SDave Airlie 
167c0e09200SDave Airlie typedef struct drm_radeon_freelist {
168c0e09200SDave Airlie 	unsigned int age;
169c0e09200SDave Airlie 	struct drm_buf *buf;
170c0e09200SDave Airlie 	struct drm_radeon_freelist *next;
171c0e09200SDave Airlie 	struct drm_radeon_freelist *prev;
172c0e09200SDave Airlie } drm_radeon_freelist_t;
173c0e09200SDave Airlie 
174c0e09200SDave Airlie typedef struct drm_radeon_ring_buffer {
175c0e09200SDave Airlie 	u32 *start;
176c0e09200SDave Airlie 	u32 *end;
177c0e09200SDave Airlie 	int size;
178c0e09200SDave Airlie 	int size_l2qw;
179c0e09200SDave Airlie 
180c0e09200SDave Airlie 	int rptr_update; /* Double Words */
181c0e09200SDave Airlie 	int rptr_update_l2qw; /* log2 Quad Words */
182c0e09200SDave Airlie 
183c0e09200SDave Airlie 	int fetch_size; /* Double Words */
184c0e09200SDave Airlie 	int fetch_size_l2ow; /* log2 Oct Words */
185c0e09200SDave Airlie 
186c0e09200SDave Airlie 	u32 tail;
187c0e09200SDave Airlie 	u32 tail_mask;
188c0e09200SDave Airlie 	int space;
189c0e09200SDave Airlie 
190c0e09200SDave Airlie 	int high_mark;
191c0e09200SDave Airlie } drm_radeon_ring_buffer_t;
192c0e09200SDave Airlie 
193c0e09200SDave Airlie typedef struct drm_radeon_depth_clear_t {
194c0e09200SDave Airlie 	u32 rb3d_cntl;
195c0e09200SDave Airlie 	u32 rb3d_zstencilcntl;
196c0e09200SDave Airlie 	u32 se_cntl;
197c0e09200SDave Airlie } drm_radeon_depth_clear_t;
198c0e09200SDave Airlie 
199c0e09200SDave Airlie struct drm_radeon_driver_file_fields {
200c0e09200SDave Airlie 	int64_t radeon_fb_delta;
201c0e09200SDave Airlie };
202c0e09200SDave Airlie 
203c0e09200SDave Airlie struct mem_block {
204c0e09200SDave Airlie 	struct mem_block *next;
205c0e09200SDave Airlie 	struct mem_block *prev;
206c0e09200SDave Airlie 	int start;
207c0e09200SDave Airlie 	int size;
208c0e09200SDave Airlie 	struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
209c0e09200SDave Airlie };
210c0e09200SDave Airlie 
211c0e09200SDave Airlie struct radeon_surface {
212c0e09200SDave Airlie 	int refcount;
213c0e09200SDave Airlie 	u32 lower;
214c0e09200SDave Airlie 	u32 upper;
215c0e09200SDave Airlie 	u32 flags;
216c0e09200SDave Airlie };
217c0e09200SDave Airlie 
218c0e09200SDave Airlie struct radeon_virt_surface {
219c0e09200SDave Airlie 	int surface_index;
220c0e09200SDave Airlie 	u32 lower;
221c0e09200SDave Airlie 	u32 upper;
222c0e09200SDave Airlie 	u32 flags;
223c0e09200SDave Airlie 	struct drm_file *file_priv;
224c0e09200SDave Airlie };
225c0e09200SDave Airlie 
22654f961a6SJerome Glisse #define RADEON_FLUSH_EMITED	(1 < 0)
22754f961a6SJerome Glisse #define RADEON_PURGE_EMITED	(1 < 1)
22854f961a6SJerome Glisse 
229c0e09200SDave Airlie typedef struct drm_radeon_private {
230c0e09200SDave Airlie 	drm_radeon_ring_buffer_t ring;
231c0e09200SDave Airlie 	drm_radeon_sarea_t *sarea_priv;
232c0e09200SDave Airlie 
233c0e09200SDave Airlie 	u32 fb_location;
234c0e09200SDave Airlie 	u32 fb_size;
235c0e09200SDave Airlie 	int new_memmap;
236c0e09200SDave Airlie 
237c0e09200SDave Airlie 	int gart_size;
238c0e09200SDave Airlie 	u32 gart_vm_start;
239c0e09200SDave Airlie 	unsigned long gart_buffers_offset;
240c0e09200SDave Airlie 
241c0e09200SDave Airlie 	int cp_mode;
242c0e09200SDave Airlie 	int cp_running;
243c0e09200SDave Airlie 
244c0e09200SDave Airlie 	drm_radeon_freelist_t *head;
245c0e09200SDave Airlie 	drm_radeon_freelist_t *tail;
246c0e09200SDave Airlie 	int last_buf;
247c0e09200SDave Airlie 	volatile u32 *scratch;
248c0e09200SDave Airlie 	int writeback_works;
249c0e09200SDave Airlie 
250c0e09200SDave Airlie 	int usec_timeout;
251c0e09200SDave Airlie 
252c0e09200SDave Airlie 	int microcode_version;
253c0e09200SDave Airlie 
254c0e09200SDave Airlie 	struct {
255c0e09200SDave Airlie 		u32 boxes;
256c0e09200SDave Airlie 		int freelist_timeouts;
257c0e09200SDave Airlie 		int freelist_loops;
258c0e09200SDave Airlie 		int requested_bufs;
259c0e09200SDave Airlie 		int last_frame_reads;
260c0e09200SDave Airlie 		int last_clear_reads;
261c0e09200SDave Airlie 		int clears;
262c0e09200SDave Airlie 		int texture_uploads;
263c0e09200SDave Airlie 	} stats;
264c0e09200SDave Airlie 
265c0e09200SDave Airlie 	int do_boxes;
266c0e09200SDave Airlie 	int page_flipping;
267c0e09200SDave Airlie 
268c0e09200SDave Airlie 	u32 color_fmt;
269c0e09200SDave Airlie 	unsigned int front_offset;
270c0e09200SDave Airlie 	unsigned int front_pitch;
271c0e09200SDave Airlie 	unsigned int back_offset;
272c0e09200SDave Airlie 	unsigned int back_pitch;
273c0e09200SDave Airlie 
274c0e09200SDave Airlie 	u32 depth_fmt;
275c0e09200SDave Airlie 	unsigned int depth_offset;
276c0e09200SDave Airlie 	unsigned int depth_pitch;
277c0e09200SDave Airlie 
278c0e09200SDave Airlie 	u32 front_pitch_offset;
279c0e09200SDave Airlie 	u32 back_pitch_offset;
280c0e09200SDave Airlie 	u32 depth_pitch_offset;
281c0e09200SDave Airlie 
282c0e09200SDave Airlie 	drm_radeon_depth_clear_t depth_clear;
283c0e09200SDave Airlie 
284c0e09200SDave Airlie 	unsigned long ring_offset;
285c0e09200SDave Airlie 	unsigned long ring_rptr_offset;
286c0e09200SDave Airlie 	unsigned long buffers_offset;
287c0e09200SDave Airlie 	unsigned long gart_textures_offset;
288c0e09200SDave Airlie 
289c0e09200SDave Airlie 	drm_local_map_t *sarea;
290c0e09200SDave Airlie 	drm_local_map_t *cp_ring;
291c0e09200SDave Airlie 	drm_local_map_t *ring_rptr;
292c0e09200SDave Airlie 	drm_local_map_t *gart_textures;
293c0e09200SDave Airlie 
294c0e09200SDave Airlie 	struct mem_block *gart_heap;
295c0e09200SDave Airlie 	struct mem_block *fb_heap;
296c0e09200SDave Airlie 
297c0e09200SDave Airlie 	/* SW interrupt */
298c0e09200SDave Airlie 	wait_queue_head_t swi_queue;
299c0e09200SDave Airlie 	atomic_t swi_emitted;
300c0e09200SDave Airlie 	int vblank_crtc;
301c0e09200SDave Airlie 	uint32_t irq_enable_reg;
302c0e09200SDave Airlie 	int irq_enabled;
303c0e09200SDave Airlie 	uint32_t r500_disp_irq_reg;
304c0e09200SDave Airlie 
305c0e09200SDave Airlie 	struct radeon_surface surfaces[RADEON_MAX_SURFACES];
306c0e09200SDave Airlie 	struct radeon_virt_surface virt_surfaces[2 * RADEON_MAX_SURFACES];
307c0e09200SDave Airlie 
308c0e09200SDave Airlie 	unsigned long pcigart_offset;
309c0e09200SDave Airlie 	unsigned int pcigart_offset_set;
310c0e09200SDave Airlie 	struct drm_ati_pcigart_info gart_info;
311c0e09200SDave Airlie 
312c0e09200SDave Airlie 	u32 scratch_ages[5];
313c0e09200SDave Airlie 
314c0e09200SDave Airlie 	/* starting from here on, data is preserved accross an open */
315c0e09200SDave Airlie 	uint32_t flags;		/* see radeon_chip_flags */
316c0e09200SDave Airlie 	unsigned long fb_aper_offset;
317c0e09200SDave Airlie 
318c0e09200SDave Airlie 	int num_gb_pipes;
31954f961a6SJerome Glisse 	int track_flush;
320*78538bf1SDave Airlie 	drm_local_map_t *mmio;
321c0e09200SDave Airlie } drm_radeon_private_t;
322c0e09200SDave Airlie 
323c0e09200SDave Airlie typedef struct drm_radeon_buf_priv {
324c0e09200SDave Airlie 	u32 age;
325c0e09200SDave Airlie } drm_radeon_buf_priv_t;
326c0e09200SDave Airlie 
327c0e09200SDave Airlie typedef struct drm_radeon_kcmd_buffer {
328c0e09200SDave Airlie 	int bufsz;
329c0e09200SDave Airlie 	char *buf;
330c0e09200SDave Airlie 	int nbox;
331c0e09200SDave Airlie 	struct drm_clip_rect __user *boxes;
332c0e09200SDave Airlie } drm_radeon_kcmd_buffer_t;
333c0e09200SDave Airlie 
334c0e09200SDave Airlie extern int radeon_no_wb;
335c0e09200SDave Airlie extern struct drm_ioctl_desc radeon_ioctls[];
336c0e09200SDave Airlie extern int radeon_max_ioctl;
337c0e09200SDave Airlie 
338c0e09200SDave Airlie /* Check whether the given hardware address is inside the framebuffer or the
339c0e09200SDave Airlie  * GART area.
340c0e09200SDave Airlie  */
341c0e09200SDave Airlie static __inline__ int radeon_check_offset(drm_radeon_private_t *dev_priv,
342c0e09200SDave Airlie 					  u64 off)
343c0e09200SDave Airlie {
344c0e09200SDave Airlie 	u32 fb_start = dev_priv->fb_location;
345c0e09200SDave Airlie 	u32 fb_end = fb_start + dev_priv->fb_size - 1;
346c0e09200SDave Airlie 	u32 gart_start = dev_priv->gart_vm_start;
347c0e09200SDave Airlie 	u32 gart_end = gart_start + dev_priv->gart_size - 1;
348c0e09200SDave Airlie 
349c0e09200SDave Airlie 	return ((off >= fb_start && off <= fb_end) ||
350c0e09200SDave Airlie 		(off >= gart_start && off <= gart_end));
351c0e09200SDave Airlie }
352c0e09200SDave Airlie 
353c0e09200SDave Airlie 				/* radeon_cp.c */
354c0e09200SDave Airlie extern int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
355c0e09200SDave Airlie extern int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_priv);
356c0e09200SDave Airlie extern int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *file_priv);
357c0e09200SDave Airlie extern int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
358c0e09200SDave Airlie extern int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv);
359c0e09200SDave Airlie extern int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv);
360c0e09200SDave Airlie extern int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
361c0e09200SDave Airlie extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv);
362c0e09200SDave Airlie extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv);
363c0e09200SDave Airlie extern u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv);
364c0e09200SDave Airlie 
365c0e09200SDave Airlie extern void radeon_freelist_reset(struct drm_device * dev);
366c0e09200SDave Airlie extern struct drm_buf *radeon_freelist_get(struct drm_device * dev);
367c0e09200SDave Airlie 
368c0e09200SDave Airlie extern int radeon_wait_ring(drm_radeon_private_t * dev_priv, int n);
369c0e09200SDave Airlie 
370c0e09200SDave Airlie extern int radeon_do_cp_idle(drm_radeon_private_t * dev_priv);
371c0e09200SDave Airlie 
372c0e09200SDave Airlie extern int radeon_driver_preinit(struct drm_device *dev, unsigned long flags);
373c0e09200SDave Airlie extern int radeon_presetup(struct drm_device *dev);
374c0e09200SDave Airlie extern int radeon_driver_postcleanup(struct drm_device *dev);
375c0e09200SDave Airlie 
376c0e09200SDave Airlie extern int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
377c0e09200SDave Airlie extern int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
378c0e09200SDave Airlie extern int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv);
379c0e09200SDave Airlie extern void radeon_mem_takedown(struct mem_block **heap);
380c0e09200SDave Airlie extern void radeon_mem_release(struct drm_file *file_priv,
381c0e09200SDave Airlie 			       struct mem_block *heap);
382c0e09200SDave Airlie 
383c0e09200SDave Airlie 				/* radeon_irq.c */
3840a3e67a4SJesse Barnes extern void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state);
385c0e09200SDave Airlie extern int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv);
386c0e09200SDave Airlie extern int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv);
387c0e09200SDave Airlie 
388c0e09200SDave Airlie extern void radeon_do_release(struct drm_device * dev);
3890a3e67a4SJesse Barnes extern u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc);
3900a3e67a4SJesse Barnes extern int radeon_enable_vblank(struct drm_device *dev, int crtc);
3910a3e67a4SJesse Barnes extern void radeon_disable_vblank(struct drm_device *dev, int crtc);
392c0e09200SDave Airlie extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS);
393c0e09200SDave Airlie extern void radeon_driver_irq_preinstall(struct drm_device * dev);
3940a3e67a4SJesse Barnes extern int radeon_driver_irq_postinstall(struct drm_device *dev);
395c0e09200SDave Airlie extern void radeon_driver_irq_uninstall(struct drm_device * dev);
396c0e09200SDave Airlie extern void radeon_enable_interrupt(struct drm_device *dev);
397c0e09200SDave Airlie extern int radeon_vblank_crtc_get(struct drm_device *dev);
398c0e09200SDave Airlie extern int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value);
399c0e09200SDave Airlie 
400c0e09200SDave Airlie extern int radeon_driver_load(struct drm_device *dev, unsigned long flags);
401c0e09200SDave Airlie extern int radeon_driver_unload(struct drm_device *dev);
402c0e09200SDave Airlie extern int radeon_driver_firstopen(struct drm_device *dev);
4030a3e67a4SJesse Barnes extern void radeon_driver_preclose(struct drm_device *dev,
4040a3e67a4SJesse Barnes 				   struct drm_file *file_priv);
4050a3e67a4SJesse Barnes extern void radeon_driver_postclose(struct drm_device *dev,
4060a3e67a4SJesse Barnes 				    struct drm_file *file_priv);
407c0e09200SDave Airlie extern void radeon_driver_lastclose(struct drm_device * dev);
4080a3e67a4SJesse Barnes extern int radeon_driver_open(struct drm_device *dev,
4090a3e67a4SJesse Barnes 			      struct drm_file *file_priv);
410c0e09200SDave Airlie extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
411c0e09200SDave Airlie 				unsigned long arg);
412c0e09200SDave Airlie 
413c0e09200SDave Airlie /* r300_cmdbuf.c */
414c0e09200SDave Airlie extern void r300_init_reg_flags(struct drm_device *dev);
415c0e09200SDave Airlie 
416c0e09200SDave Airlie extern int r300_do_cp_cmdbuf(struct drm_device *dev,
417c0e09200SDave Airlie 			     struct drm_file *file_priv,
418c0e09200SDave Airlie 			     drm_radeon_kcmd_buffer_t *cmdbuf);
419c0e09200SDave Airlie 
420c0e09200SDave Airlie /* Flags for stats.boxes
421c0e09200SDave Airlie  */
422c0e09200SDave Airlie #define RADEON_BOX_DMA_IDLE      0x1
423c0e09200SDave Airlie #define RADEON_BOX_RING_FULL     0x2
424c0e09200SDave Airlie #define RADEON_BOX_FLIP          0x4
425c0e09200SDave Airlie #define RADEON_BOX_WAIT_IDLE     0x8
426c0e09200SDave Airlie #define RADEON_BOX_TEXTURE_LOAD  0x10
427c0e09200SDave Airlie 
428c0e09200SDave Airlie /* Register definitions, register access macros and drmAddMap constants
429c0e09200SDave Airlie  * for Radeon kernel driver.
430c0e09200SDave Airlie  */
431c0e09200SDave Airlie 
432c0e09200SDave Airlie #define RADEON_AGP_COMMAND		0x0f60
433c0e09200SDave Airlie #define RADEON_AGP_COMMAND_PCI_CONFIG   0x0060	/* offset in PCI config */
434c0e09200SDave Airlie #	define RADEON_AGP_ENABLE	(1<<8)
435c0e09200SDave Airlie #define RADEON_AUX_SCISSOR_CNTL		0x26f0
436c0e09200SDave Airlie #	define RADEON_EXCLUSIVE_SCISSOR_0	(1 << 24)
437c0e09200SDave Airlie #	define RADEON_EXCLUSIVE_SCISSOR_1	(1 << 25)
438c0e09200SDave Airlie #	define RADEON_EXCLUSIVE_SCISSOR_2	(1 << 26)
439c0e09200SDave Airlie #	define RADEON_SCISSOR_0_ENABLE		(1 << 28)
440c0e09200SDave Airlie #	define RADEON_SCISSOR_1_ENABLE		(1 << 29)
441c0e09200SDave Airlie #	define RADEON_SCISSOR_2_ENABLE		(1 << 30)
442c0e09200SDave Airlie 
443edc6f389SAlex Deucher /*
444edc6f389SAlex Deucher  * PCIE radeons (rv370/rv380, rv410, r423/r430/r480, r5xx)
445edc6f389SAlex Deucher  * don't have an explicit bus mastering disable bit.  It's handled
446edc6f389SAlex Deucher  * by the PCI D-states.  PMI_BM_DIS disables D-state bus master
447edc6f389SAlex Deucher  * handling, not bus mastering itself.
448edc6f389SAlex Deucher  */
449c0e09200SDave Airlie #define RADEON_BUS_CNTL			0x0030
4504e270e9bSAlex Deucher /* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */
451c0e09200SDave Airlie #	define RADEON_BUS_MASTER_DIS		(1 << 6)
4524e270e9bSAlex Deucher /* rs600/rs690/rs740 */
4534e270e9bSAlex Deucher #	define RS600_BUS_MASTER_DIS		(1 << 14)
4544e270e9bSAlex Deucher #	define RS600_MSI_REARM		        (1 << 20)
4554e270e9bSAlex Deucher /* see RS400_MSI_REARM in AIC_CNTL for rs480 */
456edc6f389SAlex Deucher 
457edc6f389SAlex Deucher #define RADEON_BUS_CNTL1		0x0034
458edc6f389SAlex Deucher #	define RADEON_PMI_BM_DIS		(1 << 2)
459edc6f389SAlex Deucher #	define RADEON_PMI_INT_DIS		(1 << 3)
460edc6f389SAlex Deucher 
461edc6f389SAlex Deucher #define RV370_BUS_CNTL			0x004c
462edc6f389SAlex Deucher #	define RV370_PMI_BM_DIS		        (1 << 5)
463edc6f389SAlex Deucher #	define RV370_PMI_INT_DIS		(1 << 6)
464edc6f389SAlex Deucher 
465edc6f389SAlex Deucher #define RADEON_MSI_REARM_EN		0x0160
466edc6f389SAlex Deucher /* rv370/rv380, rv410, r423/r430/r480, r5xx */
467edc6f389SAlex Deucher #	define RV370_MSI_REARM_EN		(1 << 0)
468c0e09200SDave Airlie 
469c0e09200SDave Airlie #define RADEON_CLOCK_CNTL_DATA		0x000c
470c0e09200SDave Airlie #	define RADEON_PLL_WR_EN			(1 << 7)
471c0e09200SDave Airlie #define RADEON_CLOCK_CNTL_INDEX		0x0008
472c0e09200SDave Airlie #define RADEON_CONFIG_APER_SIZE		0x0108
473c0e09200SDave Airlie #define RADEON_CONFIG_MEMSIZE		0x00f8
474c0e09200SDave Airlie #define RADEON_CRTC_OFFSET		0x0224
475c0e09200SDave Airlie #define RADEON_CRTC_OFFSET_CNTL		0x0228
476c0e09200SDave Airlie #	define RADEON_CRTC_TILE_EN		(1 << 15)
477c0e09200SDave Airlie #	define RADEON_CRTC_OFFSET_FLIP_CNTL	(1 << 16)
478c0e09200SDave Airlie #define RADEON_CRTC2_OFFSET		0x0324
479c0e09200SDave Airlie #define RADEON_CRTC2_OFFSET_CNTL	0x0328
480c0e09200SDave Airlie 
481c0e09200SDave Airlie #define RADEON_PCIE_INDEX               0x0030
482c0e09200SDave Airlie #define RADEON_PCIE_DATA                0x0034
483c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_CNTL	0x10
484c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_EN		(1 << 0)
485c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0 << 1)
486c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO  (1 << 1)
487c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD   (3 << 1)
488c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_MODE_32_128_CACHE	(0 << 3)
489c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_MODE_8_4_128_CACHE	(1 << 3)
490c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_CHK_RW_VALID_EN      (1 << 5)
491c0e09200SDave Airlie #	define RADEON_PCIE_TX_GART_INVALIDATE_TLB	(1 << 8)
492c0e09200SDave Airlie #define RADEON_PCIE_TX_DISCARD_RD_ADDR_LO 0x11
493c0e09200SDave Airlie #define RADEON_PCIE_TX_DISCARD_RD_ADDR_HI 0x12
494c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_BASE	0x13
495c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_START_LO	0x14
496c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_START_HI	0x15
497c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_END_LO	0x16
498c0e09200SDave Airlie #define RADEON_PCIE_TX_GART_END_HI	0x17
499c0e09200SDave Airlie 
500c0e09200SDave Airlie #define RS480_NB_MC_INDEX               0x168
501c0e09200SDave Airlie #	define RS480_NB_MC_IND_WR_EN	(1 << 8)
502c0e09200SDave Airlie #define RS480_NB_MC_DATA                0x16c
503c0e09200SDave Airlie 
504c0e09200SDave Airlie #define RS690_MC_INDEX                  0x78
505c0e09200SDave Airlie #   define RS690_MC_INDEX_MASK          0x1ff
506c0e09200SDave Airlie #   define RS690_MC_INDEX_WR_EN         (1 << 9)
507c0e09200SDave Airlie #   define RS690_MC_INDEX_WR_ACK        0x7f
508c0e09200SDave Airlie #define RS690_MC_DATA                   0x7c
509c0e09200SDave Airlie 
510c0e09200SDave Airlie /* MC indirect registers */
511c0e09200SDave Airlie #define RS480_MC_MISC_CNTL              0x18
512c0e09200SDave Airlie #	define RS480_DISABLE_GTW	(1 << 1)
513c0e09200SDave Airlie /* switch between MCIND GART and MM GART registers. 0 = mmgart, 1 = mcind gart */
514c0e09200SDave Airlie #	define RS480_GART_INDEX_REG_EN	(1 << 12)
515c0e09200SDave Airlie #	define RS690_BLOCK_GFX_D3_EN	(1 << 14)
516c0e09200SDave Airlie #define RS480_K8_FB_LOCATION            0x1e
517c0e09200SDave Airlie #define RS480_GART_FEATURE_ID           0x2b
518c0e09200SDave Airlie #	define RS480_HANG_EN	        (1 << 11)
519c0e09200SDave Airlie #	define RS480_TLB_ENABLE	        (1 << 18)
520c0e09200SDave Airlie #	define RS480_P2P_ENABLE	        (1 << 19)
521c0e09200SDave Airlie #	define RS480_GTW_LAC_EN	        (1 << 25)
522c0e09200SDave Airlie #	define RS480_2LEVEL_GART	(0 << 30)
523c0e09200SDave Airlie #	define RS480_1LEVEL_GART	(1 << 30)
524c0e09200SDave Airlie #	define RS480_PDC_EN	        (1 << 31)
525c0e09200SDave Airlie #define RS480_GART_BASE                 0x2c
526c0e09200SDave Airlie #define RS480_GART_CACHE_CNTRL          0x2e
527c0e09200SDave Airlie #	define RS480_GART_CACHE_INVALIDATE (1 << 0) /* wait for it to clear */
528c0e09200SDave Airlie #define RS480_AGP_ADDRESS_SPACE_SIZE    0x38
529c0e09200SDave Airlie #	define RS480_GART_EN	        (1 << 0)
530c0e09200SDave Airlie #	define RS480_VA_SIZE_32MB	(0 << 1)
531c0e09200SDave Airlie #	define RS480_VA_SIZE_64MB	(1 << 1)
532c0e09200SDave Airlie #	define RS480_VA_SIZE_128MB	(2 << 1)
533c0e09200SDave Airlie #	define RS480_VA_SIZE_256MB	(3 << 1)
534c0e09200SDave Airlie #	define RS480_VA_SIZE_512MB	(4 << 1)
535c0e09200SDave Airlie #	define RS480_VA_SIZE_1GB	(5 << 1)
536c0e09200SDave Airlie #	define RS480_VA_SIZE_2GB	(6 << 1)
537c0e09200SDave Airlie #define RS480_AGP_MODE_CNTL             0x39
538c0e09200SDave Airlie #	define RS480_POST_GART_Q_SIZE	(1 << 18)
539c0e09200SDave Airlie #	define RS480_NONGART_SNOOP	(1 << 19)
540c0e09200SDave Airlie #	define RS480_AGP_RD_BUF_SIZE	(1 << 20)
541c0e09200SDave Airlie #	define RS480_REQ_TYPE_SNOOP_SHIFT 22
542c0e09200SDave Airlie #	define RS480_REQ_TYPE_SNOOP_MASK  0x3
543c0e09200SDave Airlie #	define RS480_REQ_TYPE_SNOOP_DIS	(1 << 24)
544c0e09200SDave Airlie #define RS480_MC_MISC_UMA_CNTL          0x5f
545c0e09200SDave Airlie #define RS480_MC_MCLK_CNTL              0x7a
546c0e09200SDave Airlie #define RS480_MC_UMA_DUALCH_CNTL        0x86
547c0e09200SDave Airlie 
548c0e09200SDave Airlie #define RS690_MC_FB_LOCATION            0x100
549c0e09200SDave Airlie #define RS690_MC_AGP_LOCATION           0x101
550c0e09200SDave Airlie #define RS690_MC_AGP_BASE               0x102
551c0e09200SDave Airlie #define RS690_MC_AGP_BASE_2             0x103
552c0e09200SDave Airlie 
553c0e09200SDave Airlie #define R520_MC_IND_INDEX 0x70
554c0e09200SDave Airlie #define R520_MC_IND_WR_EN (1 << 24)
555c0e09200SDave Airlie #define R520_MC_IND_DATA  0x74
556c0e09200SDave Airlie 
557c0e09200SDave Airlie #define RV515_MC_FB_LOCATION 0x01
558c0e09200SDave Airlie #define RV515_MC_AGP_LOCATION 0x02
559c0e09200SDave Airlie #define RV515_MC_AGP_BASE     0x03
560c0e09200SDave Airlie #define RV515_MC_AGP_BASE_2   0x04
561c0e09200SDave Airlie 
562c0e09200SDave Airlie #define R520_MC_FB_LOCATION 0x04
563c0e09200SDave Airlie #define R520_MC_AGP_LOCATION 0x05
564c0e09200SDave Airlie #define R520_MC_AGP_BASE     0x06
565c0e09200SDave Airlie #define R520_MC_AGP_BASE_2   0x07
566c0e09200SDave Airlie 
567c0e09200SDave Airlie #define RADEON_MPP_TB_CONFIG		0x01c0
568c0e09200SDave Airlie #define RADEON_MEM_CNTL			0x0140
569c0e09200SDave Airlie #define RADEON_MEM_SDRAM_MODE_REG	0x0158
570c0e09200SDave Airlie #define RADEON_AGP_BASE_2		0x015c /* r200+ only */
571c0e09200SDave Airlie #define RS480_AGP_BASE_2		0x0164
572c0e09200SDave Airlie #define RADEON_AGP_BASE			0x0170
573c0e09200SDave Airlie 
574c0e09200SDave Airlie /* pipe config regs */
575c0e09200SDave Airlie #define R400_GB_PIPE_SELECT             0x402c
576c0e09200SDave Airlie #define R500_DYN_SCLK_PWMEM_PIPE        0x000d /* PLL */
577c0e09200SDave Airlie #define R500_SU_REG_DEST                0x42c8
578c0e09200SDave Airlie #define R300_GB_TILE_CONFIG             0x4018
579c0e09200SDave Airlie #       define R300_ENABLE_TILING       (1 << 0)
580c0e09200SDave Airlie #       define R300_PIPE_COUNT_RV350    (0 << 1)
581c0e09200SDave Airlie #       define R300_PIPE_COUNT_R300     (3 << 1)
582c0e09200SDave Airlie #       define R300_PIPE_COUNT_R420_3P  (6 << 1)
583c0e09200SDave Airlie #       define R300_PIPE_COUNT_R420     (7 << 1)
584c0e09200SDave Airlie #       define R300_TILE_SIZE_8         (0 << 4)
585c0e09200SDave Airlie #       define R300_TILE_SIZE_16        (1 << 4)
586c0e09200SDave Airlie #       define R300_TILE_SIZE_32        (2 << 4)
587c0e09200SDave Airlie #       define R300_SUBPIXEL_1_12       (0 << 16)
588c0e09200SDave Airlie #       define R300_SUBPIXEL_1_16       (1 << 16)
589c0e09200SDave Airlie #define R300_DST_PIPE_CONFIG            0x170c
590c0e09200SDave Airlie #       define R300_PIPE_AUTO_CONFIG    (1 << 31)
591c0e09200SDave Airlie #define R300_RB2D_DSTCACHE_MODE         0x3428
592c0e09200SDave Airlie #       define R300_DC_AUTOFLUSH_ENABLE (1 << 8)
593c0e09200SDave Airlie #       define R300_DC_DC_DISABLE_IGNORE_PE (1 << 17)
594c0e09200SDave Airlie 
595c0e09200SDave Airlie #define RADEON_RB3D_COLOROFFSET		0x1c40
596c0e09200SDave Airlie #define RADEON_RB3D_COLORPITCH		0x1c48
597c0e09200SDave Airlie 
598c0e09200SDave Airlie #define	RADEON_SRC_X_Y			0x1590
599c0e09200SDave Airlie 
600c0e09200SDave Airlie #define RADEON_DP_GUI_MASTER_CNTL	0x146c
601c0e09200SDave Airlie #	define RADEON_GMC_SRC_PITCH_OFFSET_CNTL	(1 << 0)
602c0e09200SDave Airlie #	define RADEON_GMC_DST_PITCH_OFFSET_CNTL	(1 << 1)
603c0e09200SDave Airlie #	define RADEON_GMC_BRUSH_SOLID_COLOR	(13 << 4)
604c0e09200SDave Airlie #	define RADEON_GMC_BRUSH_NONE		(15 << 4)
605c0e09200SDave Airlie #	define RADEON_GMC_DST_16BPP		(4 << 8)
606c0e09200SDave Airlie #	define RADEON_GMC_DST_24BPP		(5 << 8)
607c0e09200SDave Airlie #	define RADEON_GMC_DST_32BPP		(6 << 8)
608c0e09200SDave Airlie #	define RADEON_GMC_DST_DATATYPE_SHIFT	8
609c0e09200SDave Airlie #	define RADEON_GMC_SRC_DATATYPE_COLOR	(3 << 12)
610c0e09200SDave Airlie #	define RADEON_DP_SRC_SOURCE_MEMORY	(2 << 24)
611c0e09200SDave Airlie #	define RADEON_DP_SRC_SOURCE_HOST_DATA	(3 << 24)
612c0e09200SDave Airlie #	define RADEON_GMC_CLR_CMP_CNTL_DIS	(1 << 28)
613c0e09200SDave Airlie #	define RADEON_GMC_WR_MSK_DIS		(1 << 30)
614c0e09200SDave Airlie #	define RADEON_ROP3_S			0x00cc0000
615c0e09200SDave Airlie #	define RADEON_ROP3_P			0x00f00000
616c0e09200SDave Airlie #define RADEON_DP_WRITE_MASK		0x16cc
617c0e09200SDave Airlie #define RADEON_SRC_PITCH_OFFSET		0x1428
618c0e09200SDave Airlie #define RADEON_DST_PITCH_OFFSET		0x142c
619c0e09200SDave Airlie #define RADEON_DST_PITCH_OFFSET_C	0x1c80
620c0e09200SDave Airlie #	define RADEON_DST_TILE_LINEAR		(0 << 30)
621c0e09200SDave Airlie #	define RADEON_DST_TILE_MACRO		(1 << 30)
622c0e09200SDave Airlie #	define RADEON_DST_TILE_MICRO		(2 << 30)
623c0e09200SDave Airlie #	define RADEON_DST_TILE_BOTH		(3 << 30)
624c0e09200SDave Airlie 
625c0e09200SDave Airlie #define RADEON_SCRATCH_REG0		0x15e0
626c0e09200SDave Airlie #define RADEON_SCRATCH_REG1		0x15e4
627c0e09200SDave Airlie #define RADEON_SCRATCH_REG2		0x15e8
628c0e09200SDave Airlie #define RADEON_SCRATCH_REG3		0x15ec
629c0e09200SDave Airlie #define RADEON_SCRATCH_REG4		0x15f0
630c0e09200SDave Airlie #define RADEON_SCRATCH_REG5		0x15f4
631c0e09200SDave Airlie #define RADEON_SCRATCH_UMSK		0x0770
632c0e09200SDave Airlie #define RADEON_SCRATCH_ADDR		0x0774
633c0e09200SDave Airlie 
634c0e09200SDave Airlie #define RADEON_SCRATCHOFF( x )		(RADEON_SCRATCH_REG_OFFSET + 4*(x))
635c0e09200SDave Airlie 
636c0e09200SDave Airlie #define GET_SCRATCH( x )	(dev_priv->writeback_works			\
637c0e09200SDave Airlie 				? DRM_READ32( dev_priv->ring_rptr, RADEON_SCRATCHOFF(x) ) \
638c0e09200SDave Airlie 				: RADEON_READ( RADEON_SCRATCH_REG0 + 4*(x) ) )
639c0e09200SDave Airlie 
640c0e09200SDave Airlie #define RADEON_GEN_INT_CNTL		0x0040
641c0e09200SDave Airlie #	define RADEON_CRTC_VBLANK_MASK		(1 << 0)
642c0e09200SDave Airlie #	define RADEON_CRTC2_VBLANK_MASK		(1 << 9)
643c0e09200SDave Airlie #	define RADEON_GUI_IDLE_INT_ENABLE	(1 << 19)
644c0e09200SDave Airlie #	define RADEON_SW_INT_ENABLE		(1 << 25)
645c0e09200SDave Airlie 
646c0e09200SDave Airlie #define RADEON_GEN_INT_STATUS		0x0044
647c0e09200SDave Airlie #	define RADEON_CRTC_VBLANK_STAT		(1 << 0)
648c0e09200SDave Airlie #	define RADEON_CRTC_VBLANK_STAT_ACK	(1 << 0)
649c0e09200SDave Airlie #	define RADEON_CRTC2_VBLANK_STAT		(1 << 9)
650c0e09200SDave Airlie #	define RADEON_CRTC2_VBLANK_STAT_ACK	(1 << 9)
651c0e09200SDave Airlie #	define RADEON_GUI_IDLE_INT_TEST_ACK     (1 << 19)
652c0e09200SDave Airlie #	define RADEON_SW_INT_TEST		(1 << 25)
653c0e09200SDave Airlie #	define RADEON_SW_INT_TEST_ACK		(1 << 25)
654c0e09200SDave Airlie #	define RADEON_SW_INT_FIRE		(1 << 26)
6550a3e67a4SJesse Barnes #       define R500_DISPLAY_INT_STATUS          (1 << 0)
656c0e09200SDave Airlie 
657c0e09200SDave Airlie #define RADEON_HOST_PATH_CNTL		0x0130
658c0e09200SDave Airlie #	define RADEON_HDP_SOFT_RESET		(1 << 26)
659c0e09200SDave Airlie #	define RADEON_HDP_WC_TIMEOUT_MASK	(7 << 28)
660c0e09200SDave Airlie #	define RADEON_HDP_WC_TIMEOUT_28BCLK	(7 << 28)
661c0e09200SDave Airlie 
662c0e09200SDave Airlie #define RADEON_ISYNC_CNTL		0x1724
663c0e09200SDave Airlie #	define RADEON_ISYNC_ANY2D_IDLE3D	(1 << 0)
664c0e09200SDave Airlie #	define RADEON_ISYNC_ANY3D_IDLE2D	(1 << 1)
665c0e09200SDave Airlie #	define RADEON_ISYNC_TRIG2D_IDLE3D	(1 << 2)
666c0e09200SDave Airlie #	define RADEON_ISYNC_TRIG3D_IDLE2D	(1 << 3)
667c0e09200SDave Airlie #	define RADEON_ISYNC_WAIT_IDLEGUI	(1 << 4)
668c0e09200SDave Airlie #	define RADEON_ISYNC_CPSCRATCH_IDLEGUI	(1 << 5)
669c0e09200SDave Airlie 
670c0e09200SDave Airlie #define RADEON_RBBM_GUICNTL		0x172c
671c0e09200SDave Airlie #	define RADEON_HOST_DATA_SWAP_NONE	(0 << 0)
672c0e09200SDave Airlie #	define RADEON_HOST_DATA_SWAP_16BIT	(1 << 0)
673c0e09200SDave Airlie #	define RADEON_HOST_DATA_SWAP_32BIT	(2 << 0)
674c0e09200SDave Airlie #	define RADEON_HOST_DATA_SWAP_HDW	(3 << 0)
675c0e09200SDave Airlie 
676c0e09200SDave Airlie #define RADEON_MC_AGP_LOCATION		0x014c
677c0e09200SDave Airlie #define RADEON_MC_FB_LOCATION		0x0148
678c0e09200SDave Airlie #define RADEON_MCLK_CNTL		0x0012
679c0e09200SDave Airlie #	define RADEON_FORCEON_MCLKA		(1 << 16)
680c0e09200SDave Airlie #	define RADEON_FORCEON_MCLKB		(1 << 17)
681c0e09200SDave Airlie #	define RADEON_FORCEON_YCLKA		(1 << 18)
682c0e09200SDave Airlie #	define RADEON_FORCEON_YCLKB		(1 << 19)
683c0e09200SDave Airlie #	define RADEON_FORCEON_MC		(1 << 20)
684c0e09200SDave Airlie #	define RADEON_FORCEON_AIC		(1 << 21)
685c0e09200SDave Airlie 
686c0e09200SDave Airlie #define RADEON_PP_BORDER_COLOR_0	0x1d40
687c0e09200SDave Airlie #define RADEON_PP_BORDER_COLOR_1	0x1d44
688c0e09200SDave Airlie #define RADEON_PP_BORDER_COLOR_2	0x1d48
689c0e09200SDave Airlie #define RADEON_PP_CNTL			0x1c38
690c0e09200SDave Airlie #	define RADEON_SCISSOR_ENABLE		(1 <<  1)
691c0e09200SDave Airlie #define RADEON_PP_LUM_MATRIX		0x1d00
692c0e09200SDave Airlie #define RADEON_PP_MISC			0x1c14
693c0e09200SDave Airlie #define RADEON_PP_ROT_MATRIX_0		0x1d58
694c0e09200SDave Airlie #define RADEON_PP_TXFILTER_0		0x1c54
695c0e09200SDave Airlie #define RADEON_PP_TXOFFSET_0		0x1c5c
696c0e09200SDave Airlie #define RADEON_PP_TXFILTER_1		0x1c6c
697c0e09200SDave Airlie #define RADEON_PP_TXFILTER_2		0x1c84
698c0e09200SDave Airlie 
699c0e09200SDave Airlie #define R300_RB2D_DSTCACHE_CTLSTAT	0x342c /* use R300_DSTCACHE_CTLSTAT */
700c0e09200SDave Airlie #define R300_DSTCACHE_CTLSTAT		0x1714
701c0e09200SDave Airlie #	define R300_RB2D_DC_FLUSH		(3 << 0)
702c0e09200SDave Airlie #	define R300_RB2D_DC_FREE		(3 << 2)
703c0e09200SDave Airlie #	define R300_RB2D_DC_FLUSH_ALL		0xf
704c0e09200SDave Airlie #	define R300_RB2D_DC_BUSY		(1 << 31)
705c0e09200SDave Airlie #define RADEON_RB3D_CNTL		0x1c3c
706c0e09200SDave Airlie #	define RADEON_ALPHA_BLEND_ENABLE	(1 << 0)
707c0e09200SDave Airlie #	define RADEON_PLANE_MASK_ENABLE		(1 << 1)
708c0e09200SDave Airlie #	define RADEON_DITHER_ENABLE		(1 << 2)
709c0e09200SDave Airlie #	define RADEON_ROUND_ENABLE		(1 << 3)
710c0e09200SDave Airlie #	define RADEON_SCALE_DITHER_ENABLE	(1 << 4)
711c0e09200SDave Airlie #	define RADEON_DITHER_INIT		(1 << 5)
712c0e09200SDave Airlie #	define RADEON_ROP_ENABLE		(1 << 6)
713c0e09200SDave Airlie #	define RADEON_STENCIL_ENABLE		(1 << 7)
714c0e09200SDave Airlie #	define RADEON_Z_ENABLE			(1 << 8)
715c0e09200SDave Airlie #	define RADEON_ZBLOCK16			(1 << 15)
716c0e09200SDave Airlie #define RADEON_RB3D_DEPTHOFFSET		0x1c24
717c0e09200SDave Airlie #define RADEON_RB3D_DEPTHCLEARVALUE	0x3230
718c0e09200SDave Airlie #define RADEON_RB3D_DEPTHPITCH		0x1c28
719c0e09200SDave Airlie #define RADEON_RB3D_PLANEMASK		0x1d84
720c0e09200SDave Airlie #define RADEON_RB3D_STENCILREFMASK	0x1d7c
721c0e09200SDave Airlie #define RADEON_RB3D_ZCACHE_MODE		0x3250
722c0e09200SDave Airlie #define RADEON_RB3D_ZCACHE_CTLSTAT	0x3254
723c0e09200SDave Airlie #	define RADEON_RB3D_ZC_FLUSH		(1 << 0)
724c0e09200SDave Airlie #	define RADEON_RB3D_ZC_FREE		(1 << 2)
725c0e09200SDave Airlie #	define RADEON_RB3D_ZC_FLUSH_ALL		0x5
726c0e09200SDave Airlie #	define RADEON_RB3D_ZC_BUSY		(1 << 31)
727c0e09200SDave Airlie #define R300_ZB_ZCACHE_CTLSTAT                  0x4f18
728c0e09200SDave Airlie #	define R300_ZC_FLUSH		        (1 << 0)
729c0e09200SDave Airlie #	define R300_ZC_FREE		        (1 << 1)
730c0e09200SDave Airlie #	define R300_ZC_BUSY		        (1 << 31)
731c0e09200SDave Airlie #define RADEON_RB3D_DSTCACHE_CTLSTAT	0x325c
732c0e09200SDave Airlie #	define RADEON_RB3D_DC_FLUSH		(3 << 0)
733c0e09200SDave Airlie #	define RADEON_RB3D_DC_FREE		(3 << 2)
734c0e09200SDave Airlie #	define RADEON_RB3D_DC_FLUSH_ALL		0xf
735c0e09200SDave Airlie #	define RADEON_RB3D_DC_BUSY		(1 << 31)
736c0e09200SDave Airlie #define R300_RB3D_DSTCACHE_CTLSTAT              0x4e4c
73754f961a6SJerome Glisse #	define R300_RB3D_DC_FLUSH		(2 << 0)
73854f961a6SJerome Glisse #	define R300_RB3D_DC_FREE		(2 << 2)
739c0e09200SDave Airlie #	define R300_RB3D_DC_FINISH		(1 << 4)
740c0e09200SDave Airlie #define RADEON_RB3D_ZSTENCILCNTL	0x1c2c
741c0e09200SDave Airlie #	define RADEON_Z_TEST_MASK		(7 << 4)
742c0e09200SDave Airlie #	define RADEON_Z_TEST_ALWAYS		(7 << 4)
743c0e09200SDave Airlie #	define RADEON_Z_HIERARCHY_ENABLE	(1 << 8)
744c0e09200SDave Airlie #	define RADEON_STENCIL_TEST_ALWAYS	(7 << 12)
745c0e09200SDave Airlie #	define RADEON_STENCIL_S_FAIL_REPLACE	(2 << 16)
746c0e09200SDave Airlie #	define RADEON_STENCIL_ZPASS_REPLACE	(2 << 20)
747c0e09200SDave Airlie #	define RADEON_STENCIL_ZFAIL_REPLACE	(2 << 24)
748c0e09200SDave Airlie #	define RADEON_Z_COMPRESSION_ENABLE	(1 << 28)
749c0e09200SDave Airlie #	define RADEON_FORCE_Z_DIRTY		(1 << 29)
750c0e09200SDave Airlie #	define RADEON_Z_WRITE_ENABLE		(1 << 30)
751c0e09200SDave Airlie #	define RADEON_Z_DECOMPRESSION_ENABLE	(1 << 31)
752c0e09200SDave Airlie #define RADEON_RBBM_SOFT_RESET		0x00f0
753c0e09200SDave Airlie #	define RADEON_SOFT_RESET_CP		(1 <<  0)
754c0e09200SDave Airlie #	define RADEON_SOFT_RESET_HI		(1 <<  1)
755c0e09200SDave Airlie #	define RADEON_SOFT_RESET_SE		(1 <<  2)
756c0e09200SDave Airlie #	define RADEON_SOFT_RESET_RE		(1 <<  3)
757c0e09200SDave Airlie #	define RADEON_SOFT_RESET_PP		(1 <<  4)
758c0e09200SDave Airlie #	define RADEON_SOFT_RESET_E2		(1 <<  5)
759c0e09200SDave Airlie #	define RADEON_SOFT_RESET_RB		(1 <<  6)
760c0e09200SDave Airlie #	define RADEON_SOFT_RESET_HDP		(1 <<  7)
761c0e09200SDave Airlie /*
762c0e09200SDave Airlie  *   6:0  Available slots in the FIFO
763c0e09200SDave Airlie  *   8    Host Interface active
764c0e09200SDave Airlie  *   9    CP request active
765c0e09200SDave Airlie  *   10   FIFO request active
766c0e09200SDave Airlie  *   11   Host Interface retry active
767c0e09200SDave Airlie  *   12   CP retry active
768c0e09200SDave Airlie  *   13   FIFO retry active
769c0e09200SDave Airlie  *   14   FIFO pipeline busy
770c0e09200SDave Airlie  *   15   Event engine busy
771c0e09200SDave Airlie  *   16   CP command stream busy
772c0e09200SDave Airlie  *   17   2D engine busy
773c0e09200SDave Airlie  *   18   2D portion of render backend busy
774c0e09200SDave Airlie  *   20   3D setup engine busy
775c0e09200SDave Airlie  *   26   GA engine busy
776c0e09200SDave Airlie  *   27   CBA 2D engine busy
777c0e09200SDave Airlie  *   31   2D engine busy or 3D engine busy or FIFO not empty or CP busy or
778c0e09200SDave Airlie  *           command stream queue not empty or Ring Buffer not empty
779c0e09200SDave Airlie  */
780c0e09200SDave Airlie #define RADEON_RBBM_STATUS		0x0e40
781c0e09200SDave Airlie /* Same as the previous RADEON_RBBM_STATUS; this is a mirror of that register.  */
782c0e09200SDave Airlie /* #define RADEON_RBBM_STATUS		0x1740 */
783c0e09200SDave Airlie /* bits 6:0 are dword slots available in the cmd fifo */
784c0e09200SDave Airlie #	define RADEON_RBBM_FIFOCNT_MASK		0x007f
785c0e09200SDave Airlie #	define RADEON_HIRQ_ON_RBB	(1 <<  8)
786c0e09200SDave Airlie #	define RADEON_CPRQ_ON_RBB	(1 <<  9)
787c0e09200SDave Airlie #	define RADEON_CFRQ_ON_RBB	(1 << 10)
788c0e09200SDave Airlie #	define RADEON_HIRQ_IN_RTBUF	(1 << 11)
789c0e09200SDave Airlie #	define RADEON_CPRQ_IN_RTBUF	(1 << 12)
790c0e09200SDave Airlie #	define RADEON_CFRQ_IN_RTBUF	(1 << 13)
791c0e09200SDave Airlie #	define RADEON_PIPE_BUSY		(1 << 14)
792c0e09200SDave Airlie #	define RADEON_ENG_EV_BUSY	(1 << 15)
793c0e09200SDave Airlie #	define RADEON_CP_CMDSTRM_BUSY	(1 << 16)
794c0e09200SDave Airlie #	define RADEON_E2_BUSY		(1 << 17)
795c0e09200SDave Airlie #	define RADEON_RB2D_BUSY		(1 << 18)
796c0e09200SDave Airlie #	define RADEON_RB3D_BUSY		(1 << 19) /* not used on r300 */
797c0e09200SDave Airlie #	define RADEON_VAP_BUSY		(1 << 20)
798c0e09200SDave Airlie #	define RADEON_RE_BUSY		(1 << 21) /* not used on r300 */
799c0e09200SDave Airlie #	define RADEON_TAM_BUSY		(1 << 22) /* not used on r300 */
800c0e09200SDave Airlie #	define RADEON_TDM_BUSY		(1 << 23) /* not used on r300 */
801c0e09200SDave Airlie #	define RADEON_PB_BUSY		(1 << 24) /* not used on r300 */
802c0e09200SDave Airlie #	define RADEON_TIM_BUSY		(1 << 25) /* not used on r300 */
803c0e09200SDave Airlie #	define RADEON_GA_BUSY		(1 << 26)
804c0e09200SDave Airlie #	define RADEON_CBA2D_BUSY	(1 << 27)
805c0e09200SDave Airlie #	define RADEON_RBBM_ACTIVE	(1 << 31)
806c0e09200SDave Airlie #define RADEON_RE_LINE_PATTERN		0x1cd0
807c0e09200SDave Airlie #define RADEON_RE_MISC			0x26c4
808c0e09200SDave Airlie #define RADEON_RE_TOP_LEFT		0x26c0
809c0e09200SDave Airlie #define RADEON_RE_WIDTH_HEIGHT		0x1c44
810c0e09200SDave Airlie #define RADEON_RE_STIPPLE_ADDR		0x1cc8
811c0e09200SDave Airlie #define RADEON_RE_STIPPLE_DATA		0x1ccc
812c0e09200SDave Airlie 
813c0e09200SDave Airlie #define RADEON_SCISSOR_TL_0		0x1cd8
814c0e09200SDave Airlie #define RADEON_SCISSOR_BR_0		0x1cdc
815c0e09200SDave Airlie #define RADEON_SCISSOR_TL_1		0x1ce0
816c0e09200SDave Airlie #define RADEON_SCISSOR_BR_1		0x1ce4
817c0e09200SDave Airlie #define RADEON_SCISSOR_TL_2		0x1ce8
818c0e09200SDave Airlie #define RADEON_SCISSOR_BR_2		0x1cec
819c0e09200SDave Airlie #define RADEON_SE_COORD_FMT		0x1c50
820c0e09200SDave Airlie #define RADEON_SE_CNTL			0x1c4c
821c0e09200SDave Airlie #	define RADEON_FFACE_CULL_CW		(0 << 0)
822c0e09200SDave Airlie #	define RADEON_BFACE_SOLID		(3 << 1)
823c0e09200SDave Airlie #	define RADEON_FFACE_SOLID		(3 << 3)
824c0e09200SDave Airlie #	define RADEON_FLAT_SHADE_VTX_LAST	(3 << 6)
825c0e09200SDave Airlie #	define RADEON_DIFFUSE_SHADE_FLAT	(1 << 8)
826c0e09200SDave Airlie #	define RADEON_DIFFUSE_SHADE_GOURAUD	(2 << 8)
827c0e09200SDave Airlie #	define RADEON_ALPHA_SHADE_FLAT		(1 << 10)
828c0e09200SDave Airlie #	define RADEON_ALPHA_SHADE_GOURAUD	(2 << 10)
829c0e09200SDave Airlie #	define RADEON_SPECULAR_SHADE_FLAT	(1 << 12)
830c0e09200SDave Airlie #	define RADEON_SPECULAR_SHADE_GOURAUD	(2 << 12)
831c0e09200SDave Airlie #	define RADEON_FOG_SHADE_FLAT		(1 << 14)
832c0e09200SDave Airlie #	define RADEON_FOG_SHADE_GOURAUD		(2 << 14)
833c0e09200SDave Airlie #	define RADEON_VPORT_XY_XFORM_ENABLE	(1 << 24)
834c0e09200SDave Airlie #	define RADEON_VPORT_Z_XFORM_ENABLE	(1 << 25)
835c0e09200SDave Airlie #	define RADEON_VTX_PIX_CENTER_OGL	(1 << 27)
836c0e09200SDave Airlie #	define RADEON_ROUND_MODE_TRUNC		(0 << 28)
837c0e09200SDave Airlie #	define RADEON_ROUND_PREC_8TH_PIX	(1 << 30)
838c0e09200SDave Airlie #define RADEON_SE_CNTL_STATUS		0x2140
839c0e09200SDave Airlie #define RADEON_SE_LINE_WIDTH		0x1db8
840c0e09200SDave Airlie #define RADEON_SE_VPORT_XSCALE		0x1d98
841c0e09200SDave Airlie #define RADEON_SE_ZBIAS_FACTOR		0x1db0
842c0e09200SDave Airlie #define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
843c0e09200SDave Airlie #define RADEON_SE_TCL_OUTPUT_VTX_FMT         0x2254
844c0e09200SDave Airlie #define RADEON_SE_TCL_VECTOR_INDX_REG        0x2200
845c0e09200SDave Airlie #       define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT  16
846c0e09200SDave Airlie #       define RADEON_VEC_INDX_DWORD_COUNT_SHIFT     28
847c0e09200SDave Airlie #define RADEON_SE_TCL_VECTOR_DATA_REG       0x2204
848c0e09200SDave Airlie #define RADEON_SE_TCL_SCALAR_INDX_REG       0x2208
849c0e09200SDave Airlie #       define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT  16
850c0e09200SDave Airlie #define RADEON_SE_TCL_SCALAR_DATA_REG       0x220C
851c0e09200SDave Airlie #define RADEON_SURFACE_ACCESS_FLAGS	0x0bf8
852c0e09200SDave Airlie #define RADEON_SURFACE_ACCESS_CLR	0x0bfc
853c0e09200SDave Airlie #define RADEON_SURFACE_CNTL		0x0b00
854c0e09200SDave Airlie #	define RADEON_SURF_TRANSLATION_DIS	(1 << 8)
855c0e09200SDave Airlie #	define RADEON_NONSURF_AP0_SWP_MASK	(3 << 20)
856c0e09200SDave Airlie #	define RADEON_NONSURF_AP0_SWP_LITTLE	(0 << 20)
857c0e09200SDave Airlie #	define RADEON_NONSURF_AP0_SWP_BIG16	(1 << 20)
858c0e09200SDave Airlie #	define RADEON_NONSURF_AP0_SWP_BIG32	(2 << 20)
859c0e09200SDave Airlie #	define RADEON_NONSURF_AP1_SWP_MASK	(3 << 22)
860c0e09200SDave Airlie #	define RADEON_NONSURF_AP1_SWP_LITTLE	(0 << 22)
861c0e09200SDave Airlie #	define RADEON_NONSURF_AP1_SWP_BIG16	(1 << 22)
862c0e09200SDave Airlie #	define RADEON_NONSURF_AP1_SWP_BIG32	(2 << 22)
863c0e09200SDave Airlie #define RADEON_SURFACE0_INFO		0x0b0c
864c0e09200SDave Airlie #	define RADEON_SURF_PITCHSEL_MASK	(0x1ff << 0)
865c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_MASK	(3 << 16)
866c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_MACRO	(0 << 16)
867c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_MICRO	(1 << 16)
868c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_32BIT_Z	(2 << 16)
869c0e09200SDave Airlie #	define RADEON_SURF_TILE_MODE_16BIT_Z	(3 << 16)
870c0e09200SDave Airlie #define RADEON_SURFACE0_LOWER_BOUND	0x0b04
871c0e09200SDave Airlie #define RADEON_SURFACE0_UPPER_BOUND	0x0b08
872c0e09200SDave Airlie #	define RADEON_SURF_ADDRESS_FIXED_MASK	(0x3ff << 0)
873c0e09200SDave Airlie #define RADEON_SURFACE1_INFO		0x0b1c
874c0e09200SDave Airlie #define RADEON_SURFACE1_LOWER_BOUND	0x0b14
875c0e09200SDave Airlie #define RADEON_SURFACE1_UPPER_BOUND	0x0b18
876c0e09200SDave Airlie #define RADEON_SURFACE2_INFO		0x0b2c
877c0e09200SDave Airlie #define RADEON_SURFACE2_LOWER_BOUND	0x0b24
878c0e09200SDave Airlie #define RADEON_SURFACE2_UPPER_BOUND	0x0b28
879c0e09200SDave Airlie #define RADEON_SURFACE3_INFO		0x0b3c
880c0e09200SDave Airlie #define RADEON_SURFACE3_LOWER_BOUND	0x0b34
881c0e09200SDave Airlie #define RADEON_SURFACE3_UPPER_BOUND	0x0b38
882c0e09200SDave Airlie #define RADEON_SURFACE4_INFO		0x0b4c
883c0e09200SDave Airlie #define RADEON_SURFACE4_LOWER_BOUND	0x0b44
884c0e09200SDave Airlie #define RADEON_SURFACE4_UPPER_BOUND	0x0b48
885c0e09200SDave Airlie #define RADEON_SURFACE5_INFO		0x0b5c
886c0e09200SDave Airlie #define RADEON_SURFACE5_LOWER_BOUND	0x0b54
887c0e09200SDave Airlie #define RADEON_SURFACE5_UPPER_BOUND	0x0b58
888c0e09200SDave Airlie #define RADEON_SURFACE6_INFO		0x0b6c
889c0e09200SDave Airlie #define RADEON_SURFACE6_LOWER_BOUND	0x0b64
890c0e09200SDave Airlie #define RADEON_SURFACE6_UPPER_BOUND	0x0b68
891c0e09200SDave Airlie #define RADEON_SURFACE7_INFO		0x0b7c
892c0e09200SDave Airlie #define RADEON_SURFACE7_LOWER_BOUND	0x0b74
893c0e09200SDave Airlie #define RADEON_SURFACE7_UPPER_BOUND	0x0b78
894c0e09200SDave Airlie #define RADEON_SW_SEMAPHORE		0x013c
895c0e09200SDave Airlie 
896c0e09200SDave Airlie #define RADEON_WAIT_UNTIL		0x1720
897c0e09200SDave Airlie #	define RADEON_WAIT_CRTC_PFLIP		(1 << 0)
898c0e09200SDave Airlie #	define RADEON_WAIT_2D_IDLE		(1 << 14)
899c0e09200SDave Airlie #	define RADEON_WAIT_3D_IDLE		(1 << 15)
900c0e09200SDave Airlie #	define RADEON_WAIT_2D_IDLECLEAN		(1 << 16)
901c0e09200SDave Airlie #	define RADEON_WAIT_3D_IDLECLEAN		(1 << 17)
902c0e09200SDave Airlie #	define RADEON_WAIT_HOST_IDLECLEAN	(1 << 18)
903c0e09200SDave Airlie 
904c0e09200SDave Airlie #define RADEON_RB3D_ZMASKOFFSET		0x3234
905c0e09200SDave Airlie #define RADEON_RB3D_ZSTENCILCNTL	0x1c2c
906c0e09200SDave Airlie #	define RADEON_DEPTH_FORMAT_16BIT_INT_Z	(0 << 0)
907c0e09200SDave Airlie #	define RADEON_DEPTH_FORMAT_24BIT_INT_Z	(2 << 0)
908c0e09200SDave Airlie 
909c0e09200SDave Airlie /* CP registers */
910c0e09200SDave Airlie #define RADEON_CP_ME_RAM_ADDR		0x07d4
911c0e09200SDave Airlie #define RADEON_CP_ME_RAM_RADDR		0x07d8
912c0e09200SDave Airlie #define RADEON_CP_ME_RAM_DATAH		0x07dc
913c0e09200SDave Airlie #define RADEON_CP_ME_RAM_DATAL		0x07e0
914c0e09200SDave Airlie 
915c0e09200SDave Airlie #define RADEON_CP_RB_BASE		0x0700
916c0e09200SDave Airlie #define RADEON_CP_RB_CNTL		0x0704
917c0e09200SDave Airlie #	define RADEON_BUF_SWAP_32BIT		(2 << 16)
918c0e09200SDave Airlie #	define RADEON_RB_NO_UPDATE		(1 << 27)
919c0e09200SDave Airlie #define RADEON_CP_RB_RPTR_ADDR		0x070c
920c0e09200SDave Airlie #define RADEON_CP_RB_RPTR		0x0710
921c0e09200SDave Airlie #define RADEON_CP_RB_WPTR		0x0714
922c0e09200SDave Airlie 
923c0e09200SDave Airlie #define RADEON_CP_RB_WPTR_DELAY		0x0718
924c0e09200SDave Airlie #	define RADEON_PRE_WRITE_TIMER_SHIFT	0
925c0e09200SDave Airlie #	define RADEON_PRE_WRITE_LIMIT_SHIFT	23
926c0e09200SDave Airlie 
927c0e09200SDave Airlie #define RADEON_CP_IB_BASE		0x0738
928c0e09200SDave Airlie 
929c0e09200SDave Airlie #define RADEON_CP_CSQ_CNTL		0x0740
930c0e09200SDave Airlie #	define RADEON_CSQ_CNT_PRIMARY_MASK	(0xff << 0)
931c0e09200SDave Airlie #	define RADEON_CSQ_PRIDIS_INDDIS		(0 << 28)
932c0e09200SDave Airlie #	define RADEON_CSQ_PRIPIO_INDDIS		(1 << 28)
933c0e09200SDave Airlie #	define RADEON_CSQ_PRIBM_INDDIS		(2 << 28)
934c0e09200SDave Airlie #	define RADEON_CSQ_PRIPIO_INDBM		(3 << 28)
935c0e09200SDave Airlie #	define RADEON_CSQ_PRIBM_INDBM		(4 << 28)
936c0e09200SDave Airlie #	define RADEON_CSQ_PRIPIO_INDPIO		(15 << 28)
937c0e09200SDave Airlie 
938c0e09200SDave Airlie #define RADEON_AIC_CNTL			0x01d0
939c0e09200SDave Airlie #	define RADEON_PCIGART_TRANSLATE_EN	(1 << 0)
9404e270e9bSAlex Deucher #	define RS400_MSI_REARM	                (1 << 3)
941c0e09200SDave Airlie #define RADEON_AIC_STAT			0x01d4
942c0e09200SDave Airlie #define RADEON_AIC_PT_BASE		0x01d8
943c0e09200SDave Airlie #define RADEON_AIC_LO_ADDR		0x01dc
944c0e09200SDave Airlie #define RADEON_AIC_HI_ADDR		0x01e0
945c0e09200SDave Airlie #define RADEON_AIC_TLB_ADDR		0x01e4
946c0e09200SDave Airlie #define RADEON_AIC_TLB_DATA		0x01e8
947c0e09200SDave Airlie 
948c0e09200SDave Airlie /* CP command packets */
949c0e09200SDave Airlie #define RADEON_CP_PACKET0		0x00000000
950c0e09200SDave Airlie #	define RADEON_ONE_REG_WR		(1 << 15)
951c0e09200SDave Airlie #define RADEON_CP_PACKET1		0x40000000
952c0e09200SDave Airlie #define RADEON_CP_PACKET2		0x80000000
953c0e09200SDave Airlie #define RADEON_CP_PACKET3		0xC0000000
954c0e09200SDave Airlie #       define RADEON_CP_NOP                    0x00001000
955c0e09200SDave Airlie #       define RADEON_CP_NEXT_CHAR              0x00001900
956c0e09200SDave Airlie #       define RADEON_CP_PLY_NEXTSCAN           0x00001D00
957c0e09200SDave Airlie #       define RADEON_CP_SET_SCISSORS           0x00001E00
958c0e09200SDave Airlie 	     /* GEN_INDX_PRIM is unsupported starting with R300 */
959c0e09200SDave Airlie #	define RADEON_3D_RNDR_GEN_INDX_PRIM	0x00002300
960c0e09200SDave Airlie #	define RADEON_WAIT_FOR_IDLE		0x00002600
961c0e09200SDave Airlie #	define RADEON_3D_DRAW_VBUF		0x00002800
962c0e09200SDave Airlie #	define RADEON_3D_DRAW_IMMD		0x00002900
963c0e09200SDave Airlie #	define RADEON_3D_DRAW_INDX		0x00002A00
964c0e09200SDave Airlie #       define RADEON_CP_LOAD_PALETTE           0x00002C00
965c0e09200SDave Airlie #	define RADEON_3D_LOAD_VBPNTR		0x00002F00
966c0e09200SDave Airlie #	define RADEON_MPEG_IDCT_MACROBLOCK	0x00003000
967c0e09200SDave Airlie #	define RADEON_MPEG_IDCT_MACROBLOCK_REV	0x00003100
968c0e09200SDave Airlie #	define RADEON_3D_CLEAR_ZMASK		0x00003200
969c0e09200SDave Airlie #	define RADEON_CP_INDX_BUFFER		0x00003300
970c0e09200SDave Airlie #       define RADEON_CP_3D_DRAW_VBUF_2         0x00003400
971c0e09200SDave Airlie #       define RADEON_CP_3D_DRAW_IMMD_2         0x00003500
972c0e09200SDave Airlie #       define RADEON_CP_3D_DRAW_INDX_2         0x00003600
973c0e09200SDave Airlie #	define RADEON_3D_CLEAR_HIZ		0x00003700
974c0e09200SDave Airlie #       define RADEON_CP_3D_CLEAR_CMASK         0x00003802
975c0e09200SDave Airlie #	define RADEON_CNTL_HOSTDATA_BLT		0x00009400
976c0e09200SDave Airlie #	define RADEON_CNTL_PAINT_MULTI		0x00009A00
977c0e09200SDave Airlie #	define RADEON_CNTL_BITBLT_MULTI		0x00009B00
978c0e09200SDave Airlie #	define RADEON_CNTL_SET_SCISSORS		0xC0001E00
979c0e09200SDave Airlie 
980c0e09200SDave Airlie #define RADEON_CP_PACKET_MASK		0xC0000000
981c0e09200SDave Airlie #define RADEON_CP_PACKET_COUNT_MASK	0x3fff0000
982c0e09200SDave Airlie #define RADEON_CP_PACKET0_REG_MASK	0x000007ff
983c0e09200SDave Airlie #define RADEON_CP_PACKET1_REG0_MASK	0x000007ff
984c0e09200SDave Airlie #define RADEON_CP_PACKET1_REG1_MASK	0x003ff800
985c0e09200SDave Airlie 
986c0e09200SDave Airlie #define RADEON_VTX_Z_PRESENT			(1 << 31)
987c0e09200SDave Airlie #define RADEON_VTX_PKCOLOR_PRESENT		(1 << 3)
988c0e09200SDave Airlie 
989c0e09200SDave Airlie #define RADEON_PRIM_TYPE_NONE			(0 << 0)
990c0e09200SDave Airlie #define RADEON_PRIM_TYPE_POINT			(1 << 0)
991c0e09200SDave Airlie #define RADEON_PRIM_TYPE_LINE			(2 << 0)
992c0e09200SDave Airlie #define RADEON_PRIM_TYPE_LINE_STRIP		(3 << 0)
993c0e09200SDave Airlie #define RADEON_PRIM_TYPE_TRI_LIST		(4 << 0)
994c0e09200SDave Airlie #define RADEON_PRIM_TYPE_TRI_FAN		(5 << 0)
995c0e09200SDave Airlie #define RADEON_PRIM_TYPE_TRI_STRIP		(6 << 0)
996c0e09200SDave Airlie #define RADEON_PRIM_TYPE_TRI_TYPE2		(7 << 0)
997c0e09200SDave Airlie #define RADEON_PRIM_TYPE_RECT_LIST		(8 << 0)
998c0e09200SDave Airlie #define RADEON_PRIM_TYPE_3VRT_POINT_LIST	(9 << 0)
999c0e09200SDave Airlie #define RADEON_PRIM_TYPE_3VRT_LINE_LIST		(10 << 0)
1000c0e09200SDave Airlie #define RADEON_PRIM_TYPE_MASK                   0xf
1001c0e09200SDave Airlie #define RADEON_PRIM_WALK_IND			(1 << 4)
1002c0e09200SDave Airlie #define RADEON_PRIM_WALK_LIST			(2 << 4)
1003c0e09200SDave Airlie #define RADEON_PRIM_WALK_RING			(3 << 4)
1004c0e09200SDave Airlie #define RADEON_COLOR_ORDER_BGRA			(0 << 6)
1005c0e09200SDave Airlie #define RADEON_COLOR_ORDER_RGBA			(1 << 6)
1006c0e09200SDave Airlie #define RADEON_MAOS_ENABLE			(1 << 7)
1007c0e09200SDave Airlie #define RADEON_VTX_FMT_R128_MODE		(0 << 8)
1008c0e09200SDave Airlie #define RADEON_VTX_FMT_RADEON_MODE		(1 << 8)
1009c0e09200SDave Airlie #define RADEON_NUM_VERTICES_SHIFT		16
1010c0e09200SDave Airlie 
1011c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_CI8		2
1012c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_ARGB1555	3
1013c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_RGB565	4
1014c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_ARGB8888	6
1015c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_RGB332	7
1016c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_RGB8	9
1017c0e09200SDave Airlie #define RADEON_COLOR_FORMAT_ARGB4444	15
1018c0e09200SDave Airlie 
1019c0e09200SDave Airlie #define RADEON_TXFORMAT_I8		0
1020c0e09200SDave Airlie #define RADEON_TXFORMAT_AI88		1
1021c0e09200SDave Airlie #define RADEON_TXFORMAT_RGB332		2
1022c0e09200SDave Airlie #define RADEON_TXFORMAT_ARGB1555	3
1023c0e09200SDave Airlie #define RADEON_TXFORMAT_RGB565		4
1024c0e09200SDave Airlie #define RADEON_TXFORMAT_ARGB4444	5
1025c0e09200SDave Airlie #define RADEON_TXFORMAT_ARGB8888	6
1026c0e09200SDave Airlie #define RADEON_TXFORMAT_RGBA8888	7
1027c0e09200SDave Airlie #define RADEON_TXFORMAT_Y8		8
1028c0e09200SDave Airlie #define RADEON_TXFORMAT_VYUY422         10
1029c0e09200SDave Airlie #define RADEON_TXFORMAT_YVYU422         11
1030c0e09200SDave Airlie #define RADEON_TXFORMAT_DXT1            12
1031c0e09200SDave Airlie #define RADEON_TXFORMAT_DXT23           14
1032c0e09200SDave Airlie #define RADEON_TXFORMAT_DXT45           15
1033c0e09200SDave Airlie 
1034c0e09200SDave Airlie #define R200_PP_TXCBLEND_0                0x2f00
1035c0e09200SDave Airlie #define R200_PP_TXCBLEND_1                0x2f10
1036c0e09200SDave Airlie #define R200_PP_TXCBLEND_2                0x2f20
1037c0e09200SDave Airlie #define R200_PP_TXCBLEND_3                0x2f30
1038c0e09200SDave Airlie #define R200_PP_TXCBLEND_4                0x2f40
1039c0e09200SDave Airlie #define R200_PP_TXCBLEND_5                0x2f50
1040c0e09200SDave Airlie #define R200_PP_TXCBLEND_6                0x2f60
1041c0e09200SDave Airlie #define R200_PP_TXCBLEND_7                0x2f70
1042c0e09200SDave Airlie #define R200_SE_TCL_LIGHT_MODEL_CTL_0     0x2268
1043c0e09200SDave Airlie #define R200_PP_TFACTOR_0                 0x2ee0
1044c0e09200SDave Airlie #define R200_SE_VTX_FMT_0                 0x2088
1045c0e09200SDave Airlie #define R200_SE_VAP_CNTL                  0x2080
1046c0e09200SDave Airlie #define R200_SE_TCL_MATRIX_SEL_0          0x2230
1047c0e09200SDave Airlie #define R200_SE_TCL_TEX_PROC_CTL_2        0x22a8
1048c0e09200SDave Airlie #define R200_SE_TCL_UCP_VERT_BLEND_CTL    0x22c0
1049c0e09200SDave Airlie #define R200_PP_TXFILTER_5                0x2ca0
1050c0e09200SDave Airlie #define R200_PP_TXFILTER_4                0x2c80
1051c0e09200SDave Airlie #define R200_PP_TXFILTER_3                0x2c60
1052c0e09200SDave Airlie #define R200_PP_TXFILTER_2                0x2c40
1053c0e09200SDave Airlie #define R200_PP_TXFILTER_1                0x2c20
1054c0e09200SDave Airlie #define R200_PP_TXFILTER_0                0x2c00
1055c0e09200SDave Airlie #define R200_PP_TXOFFSET_5                0x2d78
1056c0e09200SDave Airlie #define R200_PP_TXOFFSET_4                0x2d60
1057c0e09200SDave Airlie #define R200_PP_TXOFFSET_3                0x2d48
1058c0e09200SDave Airlie #define R200_PP_TXOFFSET_2                0x2d30
1059c0e09200SDave Airlie #define R200_PP_TXOFFSET_1                0x2d18
1060c0e09200SDave Airlie #define R200_PP_TXOFFSET_0                0x2d00
1061c0e09200SDave Airlie 
1062c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_0             0x2c18
1063c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_1             0x2c38
1064c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_2             0x2c58
1065c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_3             0x2c78
1066c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_4             0x2c98
1067c0e09200SDave Airlie #define R200_PP_CUBIC_FACES_5             0x2cb8
1068c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_0         0x2d04
1069c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_0         0x2d08
1070c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_0         0x2d0c
1071c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_0         0x2d10
1072c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_0         0x2d14
1073c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_1         0x2d1c
1074c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_1         0x2d20
1075c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_1         0x2d24
1076c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_1         0x2d28
1077c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_1         0x2d2c
1078c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_2         0x2d34
1079c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_2         0x2d38
1080c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_2         0x2d3c
1081c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_2         0x2d40
1082c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_2         0x2d44
1083c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_3         0x2d4c
1084c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_3         0x2d50
1085c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_3         0x2d54
1086c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_3         0x2d58
1087c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_3         0x2d5c
1088c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_4         0x2d64
1089c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_4         0x2d68
1090c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_4         0x2d6c
1091c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_4         0x2d70
1092c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_4         0x2d74
1093c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F1_5         0x2d7c
1094c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F2_5         0x2d80
1095c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F3_5         0x2d84
1096c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F4_5         0x2d88
1097c0e09200SDave Airlie #define R200_PP_CUBIC_OFFSET_F5_5         0x2d8c
1098c0e09200SDave Airlie 
1099c0e09200SDave Airlie #define R200_RE_AUX_SCISSOR_CNTL          0x26f0
1100c0e09200SDave Airlie #define R200_SE_VTE_CNTL                  0x20b0
1101c0e09200SDave Airlie #define R200_SE_TCL_OUTPUT_VTX_COMP_SEL   0x2250
1102c0e09200SDave Airlie #define R200_PP_TAM_DEBUG3                0x2d9c
1103c0e09200SDave Airlie #define R200_PP_CNTL_X                    0x2cc4
1104c0e09200SDave Airlie #define R200_SE_VAP_CNTL_STATUS           0x2140
1105c0e09200SDave Airlie #define R200_RE_SCISSOR_TL_0              0x1cd8
1106c0e09200SDave Airlie #define R200_RE_SCISSOR_TL_1              0x1ce0
1107c0e09200SDave Airlie #define R200_RE_SCISSOR_TL_2              0x1ce8
1108c0e09200SDave Airlie #define R200_RB3D_DEPTHXY_OFFSET          0x1d60
1109c0e09200SDave Airlie #define R200_RE_AUX_SCISSOR_CNTL          0x26f0
1110c0e09200SDave Airlie #define R200_SE_VTX_STATE_CNTL            0x2180
1111c0e09200SDave Airlie #define R200_RE_POINTSIZE                 0x2648
1112c0e09200SDave Airlie #define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0 0x2254
1113c0e09200SDave Airlie 
1114c0e09200SDave Airlie #define RADEON_PP_TEX_SIZE_0                0x1d04	/* NPOT */
1115c0e09200SDave Airlie #define RADEON_PP_TEX_SIZE_1                0x1d0c
1116c0e09200SDave Airlie #define RADEON_PP_TEX_SIZE_2                0x1d14
1117c0e09200SDave Airlie 
1118c0e09200SDave Airlie #define RADEON_PP_CUBIC_FACES_0             0x1d24
1119c0e09200SDave Airlie #define RADEON_PP_CUBIC_FACES_1             0x1d28
1120c0e09200SDave Airlie #define RADEON_PP_CUBIC_FACES_2             0x1d2c
1121c0e09200SDave Airlie #define RADEON_PP_CUBIC_OFFSET_T0_0         0x1dd0	/* bits [31:5] */
1122c0e09200SDave Airlie #define RADEON_PP_CUBIC_OFFSET_T1_0         0x1e00
1123c0e09200SDave Airlie #define RADEON_PP_CUBIC_OFFSET_T2_0         0x1e14
1124c0e09200SDave Airlie 
1125c0e09200SDave Airlie #define RADEON_SE_TCL_STATE_FLUSH           0x2284
1126c0e09200SDave Airlie 
1127c0e09200SDave Airlie #define SE_VAP_CNTL__TCL_ENA_MASK                          0x00000001
1128c0e09200SDave Airlie #define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK                   0x00010000
1129c0e09200SDave Airlie #define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT                 0x00000012
1130c0e09200SDave Airlie #define SE_VTE_CNTL__VTX_XY_FMT_MASK                       0x00000100
1131c0e09200SDave Airlie #define SE_VTE_CNTL__VTX_Z_FMT_MASK                        0x00000200
1132c0e09200SDave Airlie #define SE_VTX_FMT_0__VTX_Z0_PRESENT_MASK                  0x00000001
1133c0e09200SDave Airlie #define SE_VTX_FMT_0__VTX_W0_PRESENT_MASK                  0x00000002
1134c0e09200SDave Airlie #define SE_VTX_FMT_0__VTX_COLOR_0_FMT__SHIFT               0x0000000b
1135c0e09200SDave Airlie #define R200_3D_DRAW_IMMD_2      0xC0003500
1136c0e09200SDave Airlie #define R200_SE_VTX_FMT_1                 0x208c
1137c0e09200SDave Airlie #define R200_RE_CNTL                      0x1c50
1138c0e09200SDave Airlie 
1139c0e09200SDave Airlie #define R200_RB3D_BLENDCOLOR              0x3218
1140c0e09200SDave Airlie 
1141c0e09200SDave Airlie #define R200_SE_TCL_POINT_SPRITE_CNTL     0x22c4
1142c0e09200SDave Airlie 
1143c0e09200SDave Airlie #define R200_PP_TRI_PERF 0x2cf8
1144c0e09200SDave Airlie 
1145c0e09200SDave Airlie #define R200_PP_AFS_0                     0x2f80
1146c0e09200SDave Airlie #define R200_PP_AFS_1                     0x2f00	/* same as txcblend_0 */
1147c0e09200SDave Airlie 
1148c0e09200SDave Airlie #define R200_VAP_PVS_CNTL_1               0x22D0
1149c0e09200SDave Airlie 
11500a3e67a4SJesse Barnes #define RADEON_CRTC_CRNT_FRAME 0x0214
11510a3e67a4SJesse Barnes #define RADEON_CRTC2_CRNT_FRAME 0x0314
11520a3e67a4SJesse Barnes 
1153c0e09200SDave Airlie #define R500_D1CRTC_STATUS 0x609c
1154c0e09200SDave Airlie #define R500_D2CRTC_STATUS 0x689c
1155c0e09200SDave Airlie #define R500_CRTC_V_BLANK (1<<0)
1156c0e09200SDave Airlie 
1157c0e09200SDave Airlie #define R500_D1CRTC_FRAME_COUNT 0x60a4
1158c0e09200SDave Airlie #define R500_D2CRTC_FRAME_COUNT 0x68a4
1159c0e09200SDave Airlie 
1160c0e09200SDave Airlie #define R500_D1MODE_V_COUNTER 0x6530
1161c0e09200SDave Airlie #define R500_D2MODE_V_COUNTER 0x6d30
1162c0e09200SDave Airlie 
1163c0e09200SDave Airlie #define R500_D1MODE_VBLANK_STATUS 0x6534
1164c0e09200SDave Airlie #define R500_D2MODE_VBLANK_STATUS 0x6d34
1165c0e09200SDave Airlie #define R500_VBLANK_OCCURED (1<<0)
1166c0e09200SDave Airlie #define R500_VBLANK_ACK     (1<<4)
1167c0e09200SDave Airlie #define R500_VBLANK_STAT    (1<<12)
1168c0e09200SDave Airlie #define R500_VBLANK_INT     (1<<16)
1169c0e09200SDave Airlie 
1170c0e09200SDave Airlie #define R500_DxMODE_INT_MASK 0x6540
1171c0e09200SDave Airlie #define R500_D1MODE_INT_MASK (1<<0)
1172c0e09200SDave Airlie #define R500_D2MODE_INT_MASK (1<<8)
1173c0e09200SDave Airlie 
1174c0e09200SDave Airlie #define R500_DISP_INTERRUPT_STATUS 0x7edc
1175c0e09200SDave Airlie #define R500_D1_VBLANK_INTERRUPT (1 << 4)
1176c0e09200SDave Airlie #define R500_D2_VBLANK_INTERRUPT (1 << 5)
1177c0e09200SDave Airlie 
1178c0e09200SDave Airlie /* Constants */
1179c0e09200SDave Airlie #define RADEON_MAX_USEC_TIMEOUT		100000	/* 100 ms */
1180c0e09200SDave Airlie 
1181c0e09200SDave Airlie #define RADEON_LAST_FRAME_REG		RADEON_SCRATCH_REG0
1182c0e09200SDave Airlie #define RADEON_LAST_DISPATCH_REG	RADEON_SCRATCH_REG1
1183c0e09200SDave Airlie #define RADEON_LAST_CLEAR_REG		RADEON_SCRATCH_REG2
1184c0e09200SDave Airlie #define RADEON_LAST_SWI_REG		RADEON_SCRATCH_REG3
1185c0e09200SDave Airlie #define RADEON_LAST_DISPATCH		1
1186c0e09200SDave Airlie 
1187c0e09200SDave Airlie #define RADEON_MAX_VB_AGE		0x7fffffff
1188c0e09200SDave Airlie #define RADEON_MAX_VB_VERTS		(0xffff)
1189c0e09200SDave Airlie 
1190c0e09200SDave Airlie #define RADEON_RING_HIGH_MARK		128
1191c0e09200SDave Airlie 
1192c0e09200SDave Airlie #define RADEON_PCIGART_TABLE_SIZE      (32*1024)
1193c0e09200SDave Airlie 
1194c0e09200SDave Airlie #define RADEON_READ(reg)	DRM_READ32(  dev_priv->mmio, (reg) )
1195c0e09200SDave Airlie #define RADEON_WRITE(reg,val)	DRM_WRITE32( dev_priv->mmio, (reg), (val) )
1196c0e09200SDave Airlie #define RADEON_READ8(reg)	DRM_READ8(  dev_priv->mmio, (reg) )
1197c0e09200SDave Airlie #define RADEON_WRITE8(reg,val)	DRM_WRITE8( dev_priv->mmio, (reg), (val) )
1198c0e09200SDave Airlie 
1199c0e09200SDave Airlie #define RADEON_WRITE_PLL(addr, val)					\
1200c0e09200SDave Airlie do {									\
1201c0e09200SDave Airlie 	RADEON_WRITE8(RADEON_CLOCK_CNTL_INDEX,				\
1202c0e09200SDave Airlie 		       ((addr) & 0x1f) | RADEON_PLL_WR_EN );		\
1203c0e09200SDave Airlie 	RADEON_WRITE(RADEON_CLOCK_CNTL_DATA, (val));			\
1204c0e09200SDave Airlie } while (0)
1205c0e09200SDave Airlie 
1206c0e09200SDave Airlie #define RADEON_WRITE_PCIE(addr, val)					\
1207c0e09200SDave Airlie do {									\
1208c0e09200SDave Airlie 	RADEON_WRITE8(RADEON_PCIE_INDEX,				\
1209c0e09200SDave Airlie 			((addr) & 0xff));				\
1210c0e09200SDave Airlie 	RADEON_WRITE(RADEON_PCIE_DATA, (val));			\
1211c0e09200SDave Airlie } while (0)
1212c0e09200SDave Airlie 
1213c0e09200SDave Airlie #define R500_WRITE_MCIND(addr, val)					\
1214c0e09200SDave Airlie do {								\
1215c0e09200SDave Airlie 	RADEON_WRITE(R520_MC_IND_INDEX, 0xff0000 | ((addr) & 0xff));	\
1216c0e09200SDave Airlie 	RADEON_WRITE(R520_MC_IND_DATA, (val));			\
1217c0e09200SDave Airlie 	RADEON_WRITE(R520_MC_IND_INDEX, 0);	\
1218c0e09200SDave Airlie } while (0)
1219c0e09200SDave Airlie 
1220c0e09200SDave Airlie #define RS480_WRITE_MCIND(addr, val)				\
1221c0e09200SDave Airlie do {									\
1222c0e09200SDave Airlie 	RADEON_WRITE(RS480_NB_MC_INDEX,				\
1223c0e09200SDave Airlie 			((addr) & 0xff) | RS480_NB_MC_IND_WR_EN);	\
1224c0e09200SDave Airlie 	RADEON_WRITE(RS480_NB_MC_DATA, (val));			\
1225c0e09200SDave Airlie 	RADEON_WRITE(RS480_NB_MC_INDEX, 0xff);			\
1226c0e09200SDave Airlie } while (0)
1227c0e09200SDave Airlie 
1228c0e09200SDave Airlie #define RS690_WRITE_MCIND(addr, val)					\
1229c0e09200SDave Airlie do {								\
1230c0e09200SDave Airlie 	RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_EN | ((addr) & RS690_MC_INDEX_MASK));	\
1231c0e09200SDave Airlie 	RADEON_WRITE(RS690_MC_DATA, val);			\
1232c0e09200SDave Airlie 	RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK);	\
1233c0e09200SDave Airlie } while (0)
1234c0e09200SDave Airlie 
1235c0e09200SDave Airlie #define IGP_WRITE_MCIND(addr, val)				\
1236c0e09200SDave Airlie do {									\
1237f0738e92SAlex Deucher 	if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||   \
1238f0738e92SAlex Deucher 	    ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740))      \
1239c0e09200SDave Airlie 		RS690_WRITE_MCIND(addr, val);				\
1240c0e09200SDave Airlie 	else								\
1241c0e09200SDave Airlie 		RS480_WRITE_MCIND(addr, val);				\
1242c0e09200SDave Airlie } while (0)
1243c0e09200SDave Airlie 
1244c0e09200SDave Airlie #define CP_PACKET0( reg, n )						\
1245c0e09200SDave Airlie 	(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
1246c0e09200SDave Airlie #define CP_PACKET0_TABLE( reg, n )					\
1247c0e09200SDave Airlie 	(RADEON_CP_PACKET0 | RADEON_ONE_REG_WR | ((n) << 16) | ((reg) >> 2))
1248c0e09200SDave Airlie #define CP_PACKET1( reg0, reg1 )					\
1249c0e09200SDave Airlie 	(RADEON_CP_PACKET1 | (((reg1) >> 2) << 15) | ((reg0) >> 2))
1250c0e09200SDave Airlie #define CP_PACKET2()							\
1251c0e09200SDave Airlie 	(RADEON_CP_PACKET2)
1252c0e09200SDave Airlie #define CP_PACKET3( pkt, n )						\
1253c0e09200SDave Airlie 	(RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
1254c0e09200SDave Airlie 
1255c0e09200SDave Airlie /* ================================================================
1256c0e09200SDave Airlie  * Engine control helper macros
1257c0e09200SDave Airlie  */
1258c0e09200SDave Airlie 
1259c0e09200SDave Airlie #define RADEON_WAIT_UNTIL_2D_IDLE() do {				\
1260c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
1261c0e09200SDave Airlie 	OUT_RING( (RADEON_WAIT_2D_IDLECLEAN |				\
1262c0e09200SDave Airlie 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
1263c0e09200SDave Airlie } while (0)
1264c0e09200SDave Airlie 
1265c0e09200SDave Airlie #define RADEON_WAIT_UNTIL_3D_IDLE() do {				\
1266c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
1267c0e09200SDave Airlie 	OUT_RING( (RADEON_WAIT_3D_IDLECLEAN |				\
1268c0e09200SDave Airlie 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
1269c0e09200SDave Airlie } while (0)
1270c0e09200SDave Airlie 
1271c0e09200SDave Airlie #define RADEON_WAIT_UNTIL_IDLE() do {					\
1272c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
1273c0e09200SDave Airlie 	OUT_RING( (RADEON_WAIT_2D_IDLECLEAN |				\
1274c0e09200SDave Airlie 		   RADEON_WAIT_3D_IDLECLEAN |				\
1275c0e09200SDave Airlie 		   RADEON_WAIT_HOST_IDLECLEAN) );			\
1276c0e09200SDave Airlie } while (0)
1277c0e09200SDave Airlie 
1278c0e09200SDave Airlie #define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do {				\
1279c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) );			\
1280c0e09200SDave Airlie 	OUT_RING( RADEON_WAIT_CRTC_PFLIP );				\
1281c0e09200SDave Airlie } while (0)
1282c0e09200SDave Airlie 
1283c0e09200SDave Airlie #define RADEON_FLUSH_CACHE() do {					\
1284c0e09200SDave Airlie 	if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) {	\
1285c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0));	\
1286c0e09200SDave Airlie 		OUT_RING(RADEON_RB3D_DC_FLUSH);				\
1287c0e09200SDave Airlie 	} else {                                                        \
1288c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));	\
128954f961a6SJerome Glisse 		OUT_RING(R300_RB3D_DC_FLUSH);				\
1290c0e09200SDave Airlie 	}                                                               \
1291c0e09200SDave Airlie } while (0)
1292c0e09200SDave Airlie 
1293c0e09200SDave Airlie #define RADEON_PURGE_CACHE() do {					\
1294c0e09200SDave Airlie 	if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) {	\
1295c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0));	\
129654f961a6SJerome Glisse 		OUT_RING(RADEON_RB3D_DC_FLUSH | RADEON_RB3D_DC_FREE);	\
1297c0e09200SDave Airlie 	} else {                                                        \
1298c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));	\
129954f961a6SJerome Glisse 		OUT_RING(R300_RB3D_DC_FLUSH | R300_RB3D_DC_FREE);	\
1300c0e09200SDave Airlie 	}                                                               \
1301c0e09200SDave Airlie } while (0)
1302c0e09200SDave Airlie 
1303c0e09200SDave Airlie #define RADEON_FLUSH_ZCACHE() do {					\
1304c0e09200SDave Airlie 	if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) {	\
1305c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0));	\
1306c0e09200SDave Airlie 		OUT_RING(RADEON_RB3D_ZC_FLUSH);				\
1307c0e09200SDave Airlie 	} else {                                                        \
1308c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0));	\
1309c0e09200SDave Airlie 		OUT_RING(R300_ZC_FLUSH);				\
1310c0e09200SDave Airlie 	}                                                               \
1311c0e09200SDave Airlie } while (0)
1312c0e09200SDave Airlie 
1313c0e09200SDave Airlie #define RADEON_PURGE_ZCACHE() do {					\
1314c0e09200SDave Airlie 	if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) {	\
1315c0e09200SDave Airlie 		OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0));	\
131654f961a6SJerome Glisse 		OUT_RING(RADEON_RB3D_ZC_FLUSH | RADEON_RB3D_ZC_FREE);			\
1317c0e09200SDave Airlie 	} else {                                                        \
131854f961a6SJerome Glisse 		OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0));	\
131954f961a6SJerome Glisse 		OUT_RING(R300_ZC_FLUSH | R300_ZC_FREE);				\
1320c0e09200SDave Airlie 	}                                                               \
1321c0e09200SDave Airlie } while (0)
1322c0e09200SDave Airlie 
1323c0e09200SDave Airlie /* ================================================================
1324c0e09200SDave Airlie  * Misc helper macros
1325c0e09200SDave Airlie  */
1326c0e09200SDave Airlie 
1327c0e09200SDave Airlie /* Perfbox functionality only.
1328c0e09200SDave Airlie  */
1329c0e09200SDave Airlie #define RING_SPACE_TEST_WITH_RETURN( dev_priv )				\
1330c0e09200SDave Airlie do {									\
1331c0e09200SDave Airlie 	if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) {		\
1332c0e09200SDave Airlie 		u32 head = GET_RING_HEAD( dev_priv );			\
1333c0e09200SDave Airlie 		if (head == dev_priv->ring.tail)			\
1334c0e09200SDave Airlie 			dev_priv->stats.boxes |= RADEON_BOX_DMA_IDLE;	\
1335c0e09200SDave Airlie 	}								\
1336c0e09200SDave Airlie } while (0)
1337c0e09200SDave Airlie 
1338c0e09200SDave Airlie #define VB_AGE_TEST_WITH_RETURN( dev_priv )				\
1339c0e09200SDave Airlie do {									\
1340c0e09200SDave Airlie 	drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;		\
1341c0e09200SDave Airlie 	if ( sarea_priv->last_dispatch >= RADEON_MAX_VB_AGE ) {		\
1342c0e09200SDave Airlie 		int __ret = radeon_do_cp_idle( dev_priv );		\
1343c0e09200SDave Airlie 		if ( __ret ) return __ret;				\
1344c0e09200SDave Airlie 		sarea_priv->last_dispatch = 0;				\
1345c0e09200SDave Airlie 		radeon_freelist_reset( dev );				\
1346c0e09200SDave Airlie 	}								\
1347c0e09200SDave Airlie } while (0)
1348c0e09200SDave Airlie 
1349c0e09200SDave Airlie #define RADEON_DISPATCH_AGE( age ) do {					\
1350c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_LAST_DISPATCH_REG, 0 ) );		\
1351c0e09200SDave Airlie 	OUT_RING( age );						\
1352c0e09200SDave Airlie } while (0)
1353c0e09200SDave Airlie 
1354c0e09200SDave Airlie #define RADEON_FRAME_AGE( age ) do {					\
1355c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_LAST_FRAME_REG, 0 ) );		\
1356c0e09200SDave Airlie 	OUT_RING( age );						\
1357c0e09200SDave Airlie } while (0)
1358c0e09200SDave Airlie 
1359c0e09200SDave Airlie #define RADEON_CLEAR_AGE( age ) do {					\
1360c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( RADEON_LAST_CLEAR_REG, 0 ) );		\
1361c0e09200SDave Airlie 	OUT_RING( age );						\
1362c0e09200SDave Airlie } while (0)
1363c0e09200SDave Airlie 
1364c0e09200SDave Airlie /* ================================================================
1365c0e09200SDave Airlie  * Ring control
1366c0e09200SDave Airlie  */
1367c0e09200SDave Airlie 
1368c0e09200SDave Airlie #define RADEON_VERBOSE	0
1369c0e09200SDave Airlie 
1370c0e09200SDave Airlie #define RING_LOCALS	int write, _nr; unsigned int mask; u32 *ring;
1371c0e09200SDave Airlie 
1372c0e09200SDave Airlie #define BEGIN_RING( n ) do {						\
1373c0e09200SDave Airlie 	if ( RADEON_VERBOSE ) {						\
1374c0e09200SDave Airlie 		DRM_INFO( "BEGIN_RING( %d )\n", (n));			\
1375c0e09200SDave Airlie 	}								\
1376c0e09200SDave Airlie 	if ( dev_priv->ring.space <= (n) * sizeof(u32) ) {		\
1377c0e09200SDave Airlie                 COMMIT_RING();						\
1378c0e09200SDave Airlie 		radeon_wait_ring( dev_priv, (n) * sizeof(u32) );	\
1379c0e09200SDave Airlie 	}								\
1380c0e09200SDave Airlie 	_nr = n; dev_priv->ring.space -= (n) * sizeof(u32);		\
1381c0e09200SDave Airlie 	ring = dev_priv->ring.start;					\
1382c0e09200SDave Airlie 	write = dev_priv->ring.tail;					\
1383c0e09200SDave Airlie 	mask = dev_priv->ring.tail_mask;				\
1384c0e09200SDave Airlie } while (0)
1385c0e09200SDave Airlie 
1386c0e09200SDave Airlie #define ADVANCE_RING() do {						\
1387c0e09200SDave Airlie 	if ( RADEON_VERBOSE ) {						\
1388c0e09200SDave Airlie 		DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n",	\
1389c0e09200SDave Airlie 			  write, dev_priv->ring.tail );			\
1390c0e09200SDave Airlie 	}								\
1391c0e09200SDave Airlie 	if (((dev_priv->ring.tail + _nr) & mask) != write) {		\
1392c0e09200SDave Airlie 		DRM_ERROR(						\
1393c0e09200SDave Airlie 			"ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n",	\
1394c0e09200SDave Airlie 			((dev_priv->ring.tail + _nr) & mask),		\
1395c0e09200SDave Airlie 			write, __LINE__);						\
1396c0e09200SDave Airlie 	} else								\
1397c0e09200SDave Airlie 		dev_priv->ring.tail = write;				\
1398c0e09200SDave Airlie } while (0)
1399c0e09200SDave Airlie 
1400c0e09200SDave Airlie #define COMMIT_RING() do {						\
1401c0e09200SDave Airlie 	/* Flush writes to ring */					\
1402c0e09200SDave Airlie 	DRM_MEMORYBARRIER();						\
1403c0e09200SDave Airlie 	GET_RING_HEAD( dev_priv );					\
1404c0e09200SDave Airlie 	RADEON_WRITE( RADEON_CP_RB_WPTR, dev_priv->ring.tail );		\
1405c0e09200SDave Airlie 	/* read from PCI bus to ensure correct posting */		\
1406c0e09200SDave Airlie 	RADEON_READ( RADEON_CP_RB_RPTR );				\
1407c0e09200SDave Airlie } while (0)
1408c0e09200SDave Airlie 
1409c0e09200SDave Airlie #define OUT_RING( x ) do {						\
1410c0e09200SDave Airlie 	if ( RADEON_VERBOSE ) {						\
1411c0e09200SDave Airlie 		DRM_INFO( "   OUT_RING( 0x%08x ) at 0x%x\n",		\
1412c0e09200SDave Airlie 			   (unsigned int)(x), write );			\
1413c0e09200SDave Airlie 	}								\
1414c0e09200SDave Airlie 	ring[write++] = (x);						\
1415c0e09200SDave Airlie 	write &= mask;							\
1416c0e09200SDave Airlie } while (0)
1417c0e09200SDave Airlie 
1418c0e09200SDave Airlie #define OUT_RING_REG( reg, val ) do {					\
1419c0e09200SDave Airlie 	OUT_RING( CP_PACKET0( reg, 0 ) );				\
1420c0e09200SDave Airlie 	OUT_RING( val );						\
1421c0e09200SDave Airlie } while (0)
1422c0e09200SDave Airlie 
1423c0e09200SDave Airlie #define OUT_RING_TABLE( tab, sz ) do {					\
1424c0e09200SDave Airlie 	int _size = (sz);					\
1425c0e09200SDave Airlie 	int *_tab = (int *)(tab);				\
1426c0e09200SDave Airlie 								\
1427c0e09200SDave Airlie 	if (write + _size > mask) {				\
1428c0e09200SDave Airlie 		int _i = (mask+1) - write;			\
1429c0e09200SDave Airlie 		_size -= _i;					\
1430c0e09200SDave Airlie 		while (_i > 0 ) {				\
1431c0e09200SDave Airlie 			*(int *)(ring + write) = *_tab++;	\
1432c0e09200SDave Airlie 			write++;				\
1433c0e09200SDave Airlie 			_i--;					\
1434c0e09200SDave Airlie 		}						\
1435c0e09200SDave Airlie 		write = 0;					\
1436c0e09200SDave Airlie 		_tab += _i;					\
1437c0e09200SDave Airlie 	}							\
1438c0e09200SDave Airlie 	while (_size > 0) {					\
1439c0e09200SDave Airlie 		*(ring + write) = *_tab++;			\
1440c0e09200SDave Airlie 		write++;					\
1441c0e09200SDave Airlie 		_size--;					\
1442c0e09200SDave Airlie 	}							\
1443c0e09200SDave Airlie 	write &= mask;						\
1444c0e09200SDave Airlie } while (0)
1445c0e09200SDave Airlie 
1446c0e09200SDave Airlie #endif				/* __RADEON_DRV_H__ */
1447