1 /* radeon_drv.h -- Private header for radeon driver -*- linux-c -*-
3 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
4 * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
27 * Kevin E. Martin <martin@valinux.com>
28 * Gareth Hughes <gareth@valinux.com>
31 #ifndef __RADEON_DRV_H__
32 #define __RADEON_DRV_H__
34 /* General customization:
37 #define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others."
39 #define DRIVER_NAME "radeon"
40 #define DRIVER_DESC "ATI Radeon"
41 #define DRIVER_DATE "20060524"
46 * 1.2 - Add vertex2 ioctl (keith)
47 * - Add stencil capability to clear ioctl (gareth, keith)
48 * - Increase MAX_TEXTURE_LEVELS (brian)
49 * 1.3 - Add cmdbuf ioctl (keith)
50 * - Add support for new radeon packets (keith)
51 * - Add getparam ioctl (keith)
52 * - Add flip-buffers ioctl, deprecate fullscreen foo (keith).
53 * 1.4 - Add scratch registers to get_param ioctl.
54 * 1.5 - Add r200 packets to cmdbuf ioctl
55 * - Add r200 function to init ioctl
56 * - Add 'scalar2' instruction to cmdbuf
57 * 1.6 - Add static GART memory manager
58 * Add irq handler (won't be turned on unless X server knows to)
59 * Add irq ioctls and irq_active getparam.
60 * Add wait command for cmdbuf ioctl
61 * Add GART offset query for getparam
62 * 1.7 - Add support for cube map registers: R200_PP_CUBIC_FACES_[0..5]
63 * and R200_PP_CUBIC_OFFSET_F1_[0..5].
64 * Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and
65 * R200_EMIT_PP_CUBIC_OFFSETS_[0..5]. (brian)
66 * 1.8 - Remove need to call cleanup ioctls on last client exit (keith)
67 * Add 'GET' queries for starting additional clients on different VT's.
68 * 1.9 - Add DRM_IOCTL_RADEON_CP_RESUME ioctl.
69 * Add texture rectangle support for r100.
70 * 1.10- Add SETPARAM ioctl; first parameter to set is FB_LOCATION, which
71 * clients use to tell the DRM where they think the framebuffer is
72 * located in the card's address space
73 * 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color
74 * and GL_EXT_blend_[func|equation]_separate on r200
75 * 1.12- Add R300 CP microcode support - this just loads the CP on r300
76 * (No 3D support yet - just microcode loading).
77 * 1.13- Add packet R200_EMIT_TCL_POINT_SPRITE_CNTL for ARB_point_parameters
78 * - Add hyperz support, add hyperz flags to clear ioctl.
79 * 1.14- Add support for color tiling
80 * - Add R100/R200 surface allocation/free support
81 * 1.15- Add support for texture micro tiling
82 * - Add support for r100 cube maps
83 * 1.16- Add R200_EMIT_PP_TRI_PERF_CNTL packet to support brilinear
84 * texture filtering on r200
85 * 1.17- Add initial support for R300 (3D).
86 * 1.18- Add support for GL_ATI_fragment_shader, new packets
87 * R200_EMIT_PP_AFS_0/1, R200_EMIT_PP_TXCTLALL_0-5 (replaces
88 * R200_EMIT_PP_TXFILTER_0-5, 2 more regs) and R200_EMIT_ATF_TFACTOR
89 * (replaces R200_EMIT_TFACTOR_0 (8 consts instead of 6)
90 * 1.19- Add support for gart table in FB memory and PCIE r300
91 * 1.20- Add support for r300 texrect
92 * 1.21- Add support for card type getparam
93 * 1.22- Add support for texture cache flushes (R300_TX_CNTL)
94 * 1.23- Add new radeon memory map work from benh
95 * 1.24- Add general-purpose packet for manipulating scratch registers (r300)
96 * 1.25- Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL,
98 * 1.26- Add support for variable size PCI(E) gart aperture
99 * 1.27- Add support for IGP GART
100 * 1.28- Add support for VBL on CRTC2
102 #define DRIVER_MAJOR 1
103 #define DRIVER_MINOR 28
104 #define DRIVER_PATCHLEVEL 0
107 * Radeon chip families
136 enum radeon_cp_microcode_version {
145 enum radeon_chip_flags {
146 RADEON_FAMILY_MASK = 0x0000ffffUL,
147 RADEON_FLAGS_MASK = 0xffff0000UL,
148 RADEON_IS_MOBILITY = 0x00010000UL,
149 RADEON_IS_IGP = 0x00020000UL,
150 RADEON_SINGLE_CRTC = 0x00040000UL,
151 RADEON_IS_AGP = 0x00080000UL,
152 RADEON_HAS_HIERZ = 0x00100000UL,
153 RADEON_IS_PCIE = 0x00200000UL,
154 RADEON_NEW_MEMMAP = 0x00400000UL,
155 RADEON_IS_PCI = 0x00800000UL,
156 RADEON_IS_IGPGART = 0x01000000UL,
159 #define GET_RING_HEAD(dev_priv) (dev_priv->writeback_works ? \
160 DRM_READ32( (dev_priv)->ring_rptr, 0 ) : RADEON_READ(RADEON_CP_RB_RPTR))
161 #define SET_RING_HEAD(dev_priv,val) DRM_WRITE32( (dev_priv)->ring_rptr, 0, (val) )
163 typedef struct drm_radeon_freelist {
166 struct drm_radeon_freelist *next;
167 struct drm_radeon_freelist *prev;
168 } drm_radeon_freelist_t;
170 typedef struct drm_radeon_ring_buffer {
176 int rptr_update; /* Double Words */
177 int rptr_update_l2qw; /* log2 Quad Words */
179 int fetch_size; /* Double Words */
180 int fetch_size_l2ow; /* log2 Oct Words */
187 } drm_radeon_ring_buffer_t;
189 typedef struct drm_radeon_depth_clear_t {
191 u32 rb3d_zstencilcntl;
193 } drm_radeon_depth_clear_t;
195 struct drm_radeon_driver_file_fields {
196 int64_t radeon_fb_delta;
200 struct mem_block *next;
201 struct mem_block *prev;
204 struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
207 struct radeon_surface {
214 struct radeon_virt_surface {
219 struct drm_file *file_priv;
222 typedef struct drm_radeon_private {
223 drm_radeon_ring_buffer_t ring;
224 drm_radeon_sarea_t *sarea_priv;
232 unsigned long gart_buffers_offset;
237 drm_radeon_freelist_t *head;
238 drm_radeon_freelist_t *tail;
240 volatile u32 *scratch;
245 int microcode_version;
249 int freelist_timeouts;
252 int last_frame_reads;
253 int last_clear_reads;
262 unsigned int front_offset;
263 unsigned int front_pitch;
264 unsigned int back_offset;
265 unsigned int back_pitch;
268 unsigned int depth_offset;
269 unsigned int depth_pitch;
271 u32 front_pitch_offset;
272 u32 back_pitch_offset;
273 u32 depth_pitch_offset;
275 drm_radeon_depth_clear_t depth_clear;
277 unsigned long ring_offset;
278 unsigned long ring_rptr_offset;
279 unsigned long buffers_offset;
280 unsigned long gart_textures_offset;
282 drm_local_map_t *sarea;
283 drm_local_map_t *mmio;
284 drm_local_map_t *cp_ring;
285 drm_local_map_t *ring_rptr;
286 drm_local_map_t *gart_textures;
288 struct mem_block *gart_heap;
289 struct mem_block *fb_heap;
292 wait_queue_head_t swi_queue;
293 atomic_t swi_emitted;
295 uint32_t irq_enable_reg;
298 struct radeon_surface surfaces[RADEON_MAX_SURFACES];
299 struct radeon_virt_surface virt_surfaces[2 * RADEON_MAX_SURFACES];
301 unsigned long pcigart_offset;
302 unsigned int pcigart_offset_set;
303 struct drm_ati_pcigart_info gart_info;
307 /* starting from here on, data is preserved accross an open */
308 uint32_t flags; /* see radeon_chip_flags */
309 unsigned long fb_aper_offset;
312 } drm_radeon_private_t;
314 typedef struct drm_radeon_buf_priv {
316 } drm_radeon_buf_priv_t;
318 typedef struct drm_radeon_kcmd_buffer {
322 struct drm_clip_rect __user *boxes;
323 } drm_radeon_kcmd_buffer_t;
325 extern int radeon_no_wb;
326 extern struct drm_ioctl_desc radeon_ioctls[];
327 extern int radeon_max_ioctl;
329 /* Check whether the given hardware address is inside the framebuffer or the
332 static __inline__ int radeon_check_offset(drm_radeon_private_t *dev_priv,
335 u32 fb_start = dev_priv->fb_location;
336 u32 fb_end = fb_start + dev_priv->fb_size - 1;
337 u32 gart_start = dev_priv->gart_vm_start;
338 u32 gart_end = gart_start + dev_priv->gart_size - 1;
340 return ((off >= fb_start && off <= fb_end) ||
341 (off >= gart_start && off <= gart_end));
345 extern int radeon_cp_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
346 extern int radeon_cp_start(struct drm_device *dev, void *data, struct drm_file *file_priv);
347 extern int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *file_priv);
348 extern int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
349 extern int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv);
350 extern int radeon_cp_resume(struct drm_device *dev, void *data, struct drm_file *file_priv);
351 extern int radeon_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv);
352 extern int radeon_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv);
353 extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv);
354 extern u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv);
356 extern void radeon_freelist_reset(struct drm_device * dev);
357 extern struct drm_buf *radeon_freelist_get(struct drm_device * dev);
359 extern int radeon_wait_ring(drm_radeon_private_t * dev_priv, int n);
361 extern int radeon_do_cp_idle(drm_radeon_private_t * dev_priv);
363 extern int radeon_driver_preinit(struct drm_device *dev, unsigned long flags);
364 extern int radeon_presetup(struct drm_device *dev);
365 extern int radeon_driver_postcleanup(struct drm_device *dev);
367 extern int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
368 extern int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
369 extern int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv);
370 extern void radeon_mem_takedown(struct mem_block **heap);
371 extern void radeon_mem_release(struct drm_file *file_priv,
372 struct mem_block *heap);
375 extern int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv);
376 extern int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv);
378 extern void radeon_do_release(struct drm_device * dev);
379 extern int radeon_driver_vblank_wait(struct drm_device * dev,
380 unsigned int *sequence);
381 extern int radeon_driver_vblank_wait2(struct drm_device * dev,
382 unsigned int *sequence);
383 extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS);
384 extern void radeon_driver_irq_preinstall(struct drm_device * dev);
385 extern void radeon_driver_irq_postinstall(struct drm_device * dev);
386 extern void radeon_driver_irq_uninstall(struct drm_device * dev);
387 extern int radeon_vblank_crtc_get(struct drm_device *dev);
388 extern int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value);
390 extern int radeon_driver_load(struct drm_device *dev, unsigned long flags);
391 extern int radeon_driver_unload(struct drm_device *dev);
392 extern int radeon_driver_firstopen(struct drm_device *dev);
393 extern void radeon_driver_preclose(struct drm_device * dev, struct drm_file *file_priv);
394 extern void radeon_driver_postclose(struct drm_device * dev, struct drm_file * filp);
395 extern void radeon_driver_lastclose(struct drm_device * dev);
396 extern int radeon_driver_open(struct drm_device * dev, struct drm_file * filp_priv);
397 extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
401 extern void r300_init_reg_flags(struct drm_device *dev);
403 extern int r300_do_cp_cmdbuf(struct drm_device * dev,
404 struct drm_file *file_priv,
405 drm_radeon_kcmd_buffer_t * cmdbuf);
407 /* Flags for stats.boxes
409 #define RADEON_BOX_DMA_IDLE 0x1
410 #define RADEON_BOX_RING_FULL 0x2
411 #define RADEON_BOX_FLIP 0x4
412 #define RADEON_BOX_WAIT_IDLE 0x8
413 #define RADEON_BOX_TEXTURE_LOAD 0x10
415 /* Register definitions, register access macros and drmAddMap constants
416 * for Radeon kernel driver.
419 #define RADEON_AGP_COMMAND 0x0f60
420 #define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config */
421 # define RADEON_AGP_ENABLE (1<<8)
422 #define RADEON_AUX_SCISSOR_CNTL 0x26f0
423 # define RADEON_EXCLUSIVE_SCISSOR_0 (1 << 24)
424 # define RADEON_EXCLUSIVE_SCISSOR_1 (1 << 25)
425 # define RADEON_EXCLUSIVE_SCISSOR_2 (1 << 26)
426 # define RADEON_SCISSOR_0_ENABLE (1 << 28)
427 # define RADEON_SCISSOR_1_ENABLE (1 << 29)
428 # define RADEON_SCISSOR_2_ENABLE (1 << 30)
430 #define RADEON_BUS_CNTL 0x0030
431 # define RADEON_BUS_MASTER_DIS (1 << 6)
433 #define RADEON_CLOCK_CNTL_DATA 0x000c
434 # define RADEON_PLL_WR_EN (1 << 7)
435 #define RADEON_CLOCK_CNTL_INDEX 0x0008
436 #define RADEON_CONFIG_APER_SIZE 0x0108
437 #define RADEON_CONFIG_MEMSIZE 0x00f8
438 #define RADEON_CRTC_OFFSET 0x0224
439 #define RADEON_CRTC_OFFSET_CNTL 0x0228
440 # define RADEON_CRTC_TILE_EN (1 << 15)
441 # define RADEON_CRTC_OFFSET_FLIP_CNTL (1 << 16)
442 #define RADEON_CRTC2_OFFSET 0x0324
443 #define RADEON_CRTC2_OFFSET_CNTL 0x0328
445 #define RADEON_PCIE_INDEX 0x0030
446 #define RADEON_PCIE_DATA 0x0034
447 #define RADEON_PCIE_TX_GART_CNTL 0x10
448 # define RADEON_PCIE_TX_GART_EN (1 << 0)
449 # define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0 << 1)
450 # define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO (1 << 1)
451 # define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD (3 << 1)
452 # define RADEON_PCIE_TX_GART_MODE_32_128_CACHE (0 << 3)
453 # define RADEON_PCIE_TX_GART_MODE_8_4_128_CACHE (1 << 3)
454 # define RADEON_PCIE_TX_GART_CHK_RW_VALID_EN (1 << 5)
455 # define RADEON_PCIE_TX_GART_INVALIDATE_TLB (1 << 8)
456 #define RADEON_PCIE_TX_DISCARD_RD_ADDR_LO 0x11
457 #define RADEON_PCIE_TX_DISCARD_RD_ADDR_HI 0x12
458 #define RADEON_PCIE_TX_GART_BASE 0x13
459 #define RADEON_PCIE_TX_GART_START_LO 0x14
460 #define RADEON_PCIE_TX_GART_START_HI 0x15
461 #define RADEON_PCIE_TX_GART_END_LO 0x16
462 #define RADEON_PCIE_TX_GART_END_HI 0x17
464 #define RS480_NB_MC_INDEX 0x168
465 # define RS480_NB_MC_IND_WR_EN (1 << 8)
466 #define RS480_NB_MC_DATA 0x16c
468 #define RS690_MC_INDEX 0x78
469 # define RS690_MC_INDEX_MASK 0x1ff
470 # define RS690_MC_INDEX_WR_EN (1 << 9)
471 # define RS690_MC_INDEX_WR_ACK 0x7f
472 #define RS690_MC_DATA 0x7c
474 /* MC indirect registers */
475 #define RS480_MC_MISC_CNTL 0x18
476 # define RS480_DISABLE_GTW (1 << 1)
477 /* switch between MCIND GART and MM GART registers. 0 = mmgart, 1 = mcind gart */
478 # define RS480_GART_INDEX_REG_EN (1 << 12)
479 # define RS690_BLOCK_GFX_D3_EN (1 << 14)
480 #define RS480_K8_FB_LOCATION 0x1e
481 #define RS480_GART_FEATURE_ID 0x2b
482 # define RS480_HANG_EN (1 << 11)
483 # define RS480_TLB_ENABLE (1 << 18)
484 # define RS480_P2P_ENABLE (1 << 19)
485 # define RS480_GTW_LAC_EN (1 << 25)
486 # define RS480_2LEVEL_GART (0 << 30)
487 # define RS480_1LEVEL_GART (1 << 30)
488 # define RS480_PDC_EN (1 << 31)
489 #define RS480_GART_BASE 0x2c
490 #define RS480_GART_CACHE_CNTRL 0x2e
491 # define RS480_GART_CACHE_INVALIDATE (1 << 0) /* wait for it to clear */
492 #define RS480_AGP_ADDRESS_SPACE_SIZE 0x38
493 # define RS480_GART_EN (1 << 0)
494 # define RS480_VA_SIZE_32MB (0 << 1)
495 # define RS480_VA_SIZE_64MB (1 << 1)
496 # define RS480_VA_SIZE_128MB (2 << 1)
497 # define RS480_VA_SIZE_256MB (3 << 1)
498 # define RS480_VA_SIZE_512MB (4 << 1)
499 # define RS480_VA_SIZE_1GB (5 << 1)
500 # define RS480_VA_SIZE_2GB (6 << 1)
501 #define RS480_AGP_MODE_CNTL 0x39
502 # define RS480_POST_GART_Q_SIZE (1 << 18)
503 # define RS480_NONGART_SNOOP (1 << 19)
504 # define RS480_AGP_RD_BUF_SIZE (1 << 20)
505 # define RS480_REQ_TYPE_SNOOP_SHIFT 22
506 # define RS480_REQ_TYPE_SNOOP_MASK 0x3
507 # define RS480_REQ_TYPE_SNOOP_DIS (1 << 24)
508 #define RS480_MC_MISC_UMA_CNTL 0x5f
509 #define RS480_MC_MCLK_CNTL 0x7a
510 #define RS480_MC_UMA_DUALCH_CNTL 0x86
512 #define RS690_MC_FB_LOCATION 0x100
513 #define RS690_MC_AGP_LOCATION 0x101
514 #define RS690_MC_AGP_BASE 0x102
515 #define RS690_MC_AGP_BASE_2 0x103
517 #define R520_MC_IND_INDEX 0x70
518 #define R520_MC_IND_WR_EN (1 << 24)
519 #define R520_MC_IND_DATA 0x74
521 #define RV515_MC_FB_LOCATION 0x01
522 #define RV515_MC_AGP_LOCATION 0x02
524 #define R520_MC_FB_LOCATION 0x04
525 #define R520_MC_AGP_LOCATION 0x05
527 #define RADEON_MPP_TB_CONFIG 0x01c0
528 #define RADEON_MEM_CNTL 0x0140
529 #define RADEON_MEM_SDRAM_MODE_REG 0x0158
530 #define RADEON_AGP_BASE_2 0x015c /* r200+ only */
531 #define RS480_AGP_BASE_2 0x0164
532 #define RADEON_AGP_BASE 0x0170
534 /* pipe config regs */
535 #define R400_GB_PIPE_SELECT 0x402c
536 #define R500_DYN_SCLK_PWMEM_PIPE 0x000d /* PLL */
537 #define R500_SU_REG_DEST 0x42c8
538 #define R300_GB_TILE_CONFIG 0x4018
539 # define R300_ENABLE_TILING (1 << 0)
540 # define R300_PIPE_COUNT_RV350 (0 << 1)
541 # define R300_PIPE_COUNT_R300 (3 << 1)
542 # define R300_PIPE_COUNT_R420_3P (6 << 1)
543 # define R300_PIPE_COUNT_R420 (7 << 1)
544 # define R300_TILE_SIZE_8 (0 << 4)
545 # define R300_TILE_SIZE_16 (1 << 4)
546 # define R300_TILE_SIZE_32 (2 << 4)
547 # define R300_SUBPIXEL_1_12 (0 << 16)
548 # define R300_SUBPIXEL_1_16 (1 << 16)
549 #define R300_DST_PIPE_CONFIG 0x170c
550 # define R300_PIPE_AUTO_CONFIG (1 << 31)
551 #define R300_RB2D_DSTCACHE_MODE 0x3428
552 # define R300_DC_AUTOFLUSH_ENABLE (1 << 8)
553 # define R300_DC_DC_DISABLE_IGNORE_PE (1 << 17)
555 #define RADEON_RB3D_COLOROFFSET 0x1c40
556 #define RADEON_RB3D_COLORPITCH 0x1c48
558 #define RADEON_SRC_X_Y 0x1590
560 #define RADEON_DP_GUI_MASTER_CNTL 0x146c
561 # define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
562 # define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
563 # define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4)
564 # define RADEON_GMC_BRUSH_NONE (15 << 4)
565 # define RADEON_GMC_DST_16BPP (4 << 8)
566 # define RADEON_GMC_DST_24BPP (5 << 8)
567 # define RADEON_GMC_DST_32BPP (6 << 8)
568 # define RADEON_GMC_DST_DATATYPE_SHIFT 8
569 # define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12)
570 # define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24)
571 # define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24)
572 # define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28)
573 # define RADEON_GMC_WR_MSK_DIS (1 << 30)
574 # define RADEON_ROP3_S 0x00cc0000
575 # define RADEON_ROP3_P 0x00f00000
576 #define RADEON_DP_WRITE_MASK 0x16cc
577 #define RADEON_SRC_PITCH_OFFSET 0x1428
578 #define RADEON_DST_PITCH_OFFSET 0x142c
579 #define RADEON_DST_PITCH_OFFSET_C 0x1c80
580 # define RADEON_DST_TILE_LINEAR (0 << 30)
581 # define RADEON_DST_TILE_MACRO (1 << 30)
582 # define RADEON_DST_TILE_MICRO (2 << 30)
583 # define RADEON_DST_TILE_BOTH (3 << 30)
585 #define RADEON_SCRATCH_REG0 0x15e0
586 #define RADEON_SCRATCH_REG1 0x15e4
587 #define RADEON_SCRATCH_REG2 0x15e8
588 #define RADEON_SCRATCH_REG3 0x15ec
589 #define RADEON_SCRATCH_REG4 0x15f0
590 #define RADEON_SCRATCH_REG5 0x15f4
591 #define RADEON_SCRATCH_UMSK 0x0770
592 #define RADEON_SCRATCH_ADDR 0x0774
594 #define RADEON_SCRATCHOFF( x ) (RADEON_SCRATCH_REG_OFFSET + 4*(x))
596 #define GET_SCRATCH( x ) (dev_priv->writeback_works \
597 ? DRM_READ32( dev_priv->ring_rptr, RADEON_SCRATCHOFF(x) ) \
598 : RADEON_READ( RADEON_SCRATCH_REG0 + 4*(x) ) )
600 #define RADEON_GEN_INT_CNTL 0x0040
601 # define RADEON_CRTC_VBLANK_MASK (1 << 0)
602 # define RADEON_CRTC2_VBLANK_MASK (1 << 9)
603 # define RADEON_GUI_IDLE_INT_ENABLE (1 << 19)
604 # define RADEON_SW_INT_ENABLE (1 << 25)
606 #define RADEON_GEN_INT_STATUS 0x0044
607 # define RADEON_CRTC_VBLANK_STAT (1 << 0)
608 # define RADEON_CRTC_VBLANK_STAT_ACK (1 << 0)
609 # define RADEON_CRTC2_VBLANK_STAT (1 << 9)
610 # define RADEON_CRTC2_VBLANK_STAT_ACK (1 << 9)
611 # define RADEON_GUI_IDLE_INT_TEST_ACK (1 << 19)
612 # define RADEON_SW_INT_TEST (1 << 25)
613 # define RADEON_SW_INT_TEST_ACK (1 << 25)
614 # define RADEON_SW_INT_FIRE (1 << 26)
616 #define RADEON_HOST_PATH_CNTL 0x0130
617 # define RADEON_HDP_SOFT_RESET (1 << 26)
618 # define RADEON_HDP_WC_TIMEOUT_MASK (7 << 28)
619 # define RADEON_HDP_WC_TIMEOUT_28BCLK (7 << 28)
621 #define RADEON_ISYNC_CNTL 0x1724
622 # define RADEON_ISYNC_ANY2D_IDLE3D (1 << 0)
623 # define RADEON_ISYNC_ANY3D_IDLE2D (1 << 1)
624 # define RADEON_ISYNC_TRIG2D_IDLE3D (1 << 2)
625 # define RADEON_ISYNC_TRIG3D_IDLE2D (1 << 3)
626 # define RADEON_ISYNC_WAIT_IDLEGUI (1 << 4)
627 # define RADEON_ISYNC_CPSCRATCH_IDLEGUI (1 << 5)
629 #define RADEON_RBBM_GUICNTL 0x172c
630 # define RADEON_HOST_DATA_SWAP_NONE (0 << 0)
631 # define RADEON_HOST_DATA_SWAP_16BIT (1 << 0)
632 # define RADEON_HOST_DATA_SWAP_32BIT (2 << 0)
633 # define RADEON_HOST_DATA_SWAP_HDW (3 << 0)
635 #define RADEON_MC_AGP_LOCATION 0x014c
636 #define RADEON_MC_FB_LOCATION 0x0148
637 #define RADEON_MCLK_CNTL 0x0012
638 # define RADEON_FORCEON_MCLKA (1 << 16)
639 # define RADEON_FORCEON_MCLKB (1 << 17)
640 # define RADEON_FORCEON_YCLKA (1 << 18)
641 # define RADEON_FORCEON_YCLKB (1 << 19)
642 # define RADEON_FORCEON_MC (1 << 20)
643 # define RADEON_FORCEON_AIC (1 << 21)
645 #define RADEON_PP_BORDER_COLOR_0 0x1d40
646 #define RADEON_PP_BORDER_COLOR_1 0x1d44
647 #define RADEON_PP_BORDER_COLOR_2 0x1d48
648 #define RADEON_PP_CNTL 0x1c38
649 # define RADEON_SCISSOR_ENABLE (1 << 1)
650 #define RADEON_PP_LUM_MATRIX 0x1d00
651 #define RADEON_PP_MISC 0x1c14
652 #define RADEON_PP_ROT_MATRIX_0 0x1d58
653 #define RADEON_PP_TXFILTER_0 0x1c54
654 #define RADEON_PP_TXOFFSET_0 0x1c5c
655 #define RADEON_PP_TXFILTER_1 0x1c6c
656 #define RADEON_PP_TXFILTER_2 0x1c84
658 #define RADEON_RB2D_DSTCACHE_CTLSTAT 0x342c
659 # define RADEON_RB2D_DC_FLUSH (3 << 0)
660 # define RADEON_RB2D_DC_FREE (3 << 2)
661 # define RADEON_RB2D_DC_FLUSH_ALL 0xf
662 # define RADEON_RB2D_DC_BUSY (1 << 31)
663 #define RADEON_RB3D_CNTL 0x1c3c
664 # define RADEON_ALPHA_BLEND_ENABLE (1 << 0)
665 # define RADEON_PLANE_MASK_ENABLE (1 << 1)
666 # define RADEON_DITHER_ENABLE (1 << 2)
667 # define RADEON_ROUND_ENABLE (1 << 3)
668 # define RADEON_SCALE_DITHER_ENABLE (1 << 4)
669 # define RADEON_DITHER_INIT (1 << 5)
670 # define RADEON_ROP_ENABLE (1 << 6)
671 # define RADEON_STENCIL_ENABLE (1 << 7)
672 # define RADEON_Z_ENABLE (1 << 8)
673 # define RADEON_ZBLOCK16 (1 << 15)
674 #define RADEON_RB3D_DEPTHOFFSET 0x1c24
675 #define RADEON_RB3D_DEPTHCLEARVALUE 0x3230
676 #define RADEON_RB3D_DEPTHPITCH 0x1c28
677 #define RADEON_RB3D_PLANEMASK 0x1d84
678 #define RADEON_RB3D_STENCILREFMASK 0x1d7c
679 #define RADEON_RB3D_ZCACHE_MODE 0x3250
680 #define RADEON_RB3D_ZCACHE_CTLSTAT 0x3254
681 # define RADEON_RB3D_ZC_FLUSH (1 << 0)
682 # define RADEON_RB3D_ZC_FREE (1 << 2)
683 # define RADEON_RB3D_ZC_FLUSH_ALL 0x5
684 # define RADEON_RB3D_ZC_BUSY (1 << 31)
685 #define R300_ZB_ZCACHE_CTLSTAT 0x4f18
686 # define R300_ZC_FLUSH (1 << 0)
687 # define R300_ZC_FREE (1 << 1)
688 # define R300_ZC_FLUSH_ALL 0x3
689 # define R300_ZC_BUSY (1 << 31)
690 #define RADEON_RB3D_DSTCACHE_CTLSTAT 0x325c
691 # define RADEON_RB3D_DC_FLUSH (3 << 0)
692 # define RADEON_RB3D_DC_FREE (3 << 2)
693 # define RADEON_RB3D_DC_FLUSH_ALL 0xf
694 # define RADEON_RB3D_DC_BUSY (1 << 31)
695 #define R300_RB3D_DSTCACHE_CTLSTAT 0x4e4c
696 # define R300_RB3D_DC_FINISH (1 << 4)
697 #define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
698 # define RADEON_Z_TEST_MASK (7 << 4)
699 # define RADEON_Z_TEST_ALWAYS (7 << 4)
700 # define RADEON_Z_HIERARCHY_ENABLE (1 << 8)
701 # define RADEON_STENCIL_TEST_ALWAYS (7 << 12)
702 # define RADEON_STENCIL_S_FAIL_REPLACE (2 << 16)
703 # define RADEON_STENCIL_ZPASS_REPLACE (2 << 20)
704 # define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24)
705 # define RADEON_Z_COMPRESSION_ENABLE (1 << 28)
706 # define RADEON_FORCE_Z_DIRTY (1 << 29)
707 # define RADEON_Z_WRITE_ENABLE (1 << 30)
708 # define RADEON_Z_DECOMPRESSION_ENABLE (1 << 31)
709 #define RADEON_RBBM_SOFT_RESET 0x00f0
710 # define RADEON_SOFT_RESET_CP (1 << 0)
711 # define RADEON_SOFT_RESET_HI (1 << 1)
712 # define RADEON_SOFT_RESET_SE (1 << 2)
713 # define RADEON_SOFT_RESET_RE (1 << 3)
714 # define RADEON_SOFT_RESET_PP (1 << 4)
715 # define RADEON_SOFT_RESET_E2 (1 << 5)
716 # define RADEON_SOFT_RESET_RB (1 << 6)
717 # define RADEON_SOFT_RESET_HDP (1 << 7)
719 * 6:0 Available slots in the FIFO
720 * 8 Host Interface active
721 * 9 CP request active
722 * 10 FIFO request active
723 * 11 Host Interface retry active
725 * 13 FIFO retry active
726 * 14 FIFO pipeline busy
727 * 15 Event engine busy
728 * 16 CP command stream busy
730 * 18 2D portion of render backend busy
731 * 20 3D setup engine busy
733 * 27 CBA 2D engine busy
734 * 31 2D engine busy or 3D engine busy or FIFO not empty or CP busy or
735 * command stream queue not empty or Ring Buffer not empty
737 #define RADEON_RBBM_STATUS 0x0e40
738 /* Same as the previous RADEON_RBBM_STATUS; this is a mirror of that register. */
739 /* #define RADEON_RBBM_STATUS 0x1740 */
740 /* bits 6:0 are dword slots available in the cmd fifo */
741 # define RADEON_RBBM_FIFOCNT_MASK 0x007f
742 # define RADEON_HIRQ_ON_RBB (1 << 8)
743 # define RADEON_CPRQ_ON_RBB (1 << 9)
744 # define RADEON_CFRQ_ON_RBB (1 << 10)
745 # define RADEON_HIRQ_IN_RTBUF (1 << 11)
746 # define RADEON_CPRQ_IN_RTBUF (1 << 12)
747 # define RADEON_CFRQ_IN_RTBUF (1 << 13)
748 # define RADEON_PIPE_BUSY (1 << 14)
749 # define RADEON_ENG_EV_BUSY (1 << 15)
750 # define RADEON_CP_CMDSTRM_BUSY (1 << 16)
751 # define RADEON_E2_BUSY (1 << 17)
752 # define RADEON_RB2D_BUSY (1 << 18)
753 # define RADEON_RB3D_BUSY (1 << 19) /* not used on r300 */
754 # define RADEON_VAP_BUSY (1 << 20)
755 # define RADEON_RE_BUSY (1 << 21) /* not used on r300 */
756 # define RADEON_TAM_BUSY (1 << 22) /* not used on r300 */
757 # define RADEON_TDM_BUSY (1 << 23) /* not used on r300 */
758 # define RADEON_PB_BUSY (1 << 24) /* not used on r300 */
759 # define RADEON_TIM_BUSY (1 << 25) /* not used on r300 */
760 # define RADEON_GA_BUSY (1 << 26)
761 # define RADEON_CBA2D_BUSY (1 << 27)
762 # define RADEON_RBBM_ACTIVE (1 << 31)
763 #define RADEON_RE_LINE_PATTERN 0x1cd0
764 #define RADEON_RE_MISC 0x26c4
765 #define RADEON_RE_TOP_LEFT 0x26c0
766 #define RADEON_RE_WIDTH_HEIGHT 0x1c44
767 #define RADEON_RE_STIPPLE_ADDR 0x1cc8
768 #define RADEON_RE_STIPPLE_DATA 0x1ccc
770 #define RADEON_SCISSOR_TL_0 0x1cd8
771 #define RADEON_SCISSOR_BR_0 0x1cdc
772 #define RADEON_SCISSOR_TL_1 0x1ce0
773 #define RADEON_SCISSOR_BR_1 0x1ce4
774 #define RADEON_SCISSOR_TL_2 0x1ce8
775 #define RADEON_SCISSOR_BR_2 0x1cec
776 #define RADEON_SE_COORD_FMT 0x1c50
777 #define RADEON_SE_CNTL 0x1c4c
778 # define RADEON_FFACE_CULL_CW (0 << 0)
779 # define RADEON_BFACE_SOLID (3 << 1)
780 # define RADEON_FFACE_SOLID (3 << 3)
781 # define RADEON_FLAT_SHADE_VTX_LAST (3 << 6)
782 # define RADEON_DIFFUSE_SHADE_FLAT (1 << 8)
783 # define RADEON_DIFFUSE_SHADE_GOURAUD (2 << 8)
784 # define RADEON_ALPHA_SHADE_FLAT (1 << 10)
785 # define RADEON_ALPHA_SHADE_GOURAUD (2 << 10)
786 # define RADEON_SPECULAR_SHADE_FLAT (1 << 12)
787 # define RADEON_SPECULAR_SHADE_GOURAUD (2 << 12)
788 # define RADEON_FOG_SHADE_FLAT (1 << 14)
789 # define RADEON_FOG_SHADE_GOURAUD (2 << 14)
790 # define RADEON_VPORT_XY_XFORM_ENABLE (1 << 24)
791 # define RADEON_VPORT_Z_XFORM_ENABLE (1 << 25)
792 # define RADEON_VTX_PIX_CENTER_OGL (1 << 27)
793 # define RADEON_ROUND_MODE_TRUNC (0 << 28)
794 # define RADEON_ROUND_PREC_8TH_PIX (1 << 30)
795 #define RADEON_SE_CNTL_STATUS 0x2140
796 #define RADEON_SE_LINE_WIDTH 0x1db8
797 #define RADEON_SE_VPORT_XSCALE 0x1d98
798 #define RADEON_SE_ZBIAS_FACTOR 0x1db0
799 #define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
800 #define RADEON_SE_TCL_OUTPUT_VTX_FMT 0x2254
801 #define RADEON_SE_TCL_VECTOR_INDX_REG 0x2200
802 # define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT 16
803 # define RADEON_VEC_INDX_DWORD_COUNT_SHIFT 28
804 #define RADEON_SE_TCL_VECTOR_DATA_REG 0x2204
805 #define RADEON_SE_TCL_SCALAR_INDX_REG 0x2208
806 # define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT 16
807 #define RADEON_SE_TCL_SCALAR_DATA_REG 0x220C
808 #define RADEON_SURFACE_ACCESS_FLAGS 0x0bf8
809 #define RADEON_SURFACE_ACCESS_CLR 0x0bfc
810 #define RADEON_SURFACE_CNTL 0x0b00
811 # define RADEON_SURF_TRANSLATION_DIS (1 << 8)
812 # define RADEON_NONSURF_AP0_SWP_MASK (3 << 20)
813 # define RADEON_NONSURF_AP0_SWP_LITTLE (0 << 20)
814 # define RADEON_NONSURF_AP0_SWP_BIG16 (1 << 20)
815 # define RADEON_NONSURF_AP0_SWP_BIG32 (2 << 20)
816 # define RADEON_NONSURF_AP1_SWP_MASK (3 << 22)
817 # define RADEON_NONSURF_AP1_SWP_LITTLE (0 << 22)
818 # define RADEON_NONSURF_AP1_SWP_BIG16 (1 << 22)
819 # define RADEON_NONSURF_AP1_SWP_BIG32 (2 << 22)
820 #define RADEON_SURFACE0_INFO 0x0b0c
821 # define RADEON_SURF_PITCHSEL_MASK (0x1ff << 0)
822 # define RADEON_SURF_TILE_MODE_MASK (3 << 16)
823 # define RADEON_SURF_TILE_MODE_MACRO (0 << 16)
824 # define RADEON_SURF_TILE_MODE_MICRO (1 << 16)
825 # define RADEON_SURF_TILE_MODE_32BIT_Z (2 << 16)
826 # define RADEON_SURF_TILE_MODE_16BIT_Z (3 << 16)
827 #define RADEON_SURFACE0_LOWER_BOUND 0x0b04
828 #define RADEON_SURFACE0_UPPER_BOUND 0x0b08
829 # define RADEON_SURF_ADDRESS_FIXED_MASK (0x3ff << 0)
830 #define RADEON_SURFACE1_INFO 0x0b1c
831 #define RADEON_SURFACE1_LOWER_BOUND 0x0b14
832 #define RADEON_SURFACE1_UPPER_BOUND 0x0b18
833 #define RADEON_SURFACE2_INFO 0x0b2c
834 #define RADEON_SURFACE2_LOWER_BOUND 0x0b24
835 #define RADEON_SURFACE2_UPPER_BOUND 0x0b28
836 #define RADEON_SURFACE3_INFO 0x0b3c
837 #define RADEON_SURFACE3_LOWER_BOUND 0x0b34
838 #define RADEON_SURFACE3_UPPER_BOUND 0x0b38
839 #define RADEON_SURFACE4_INFO 0x0b4c
840 #define RADEON_SURFACE4_LOWER_BOUND 0x0b44
841 #define RADEON_SURFACE4_UPPER_BOUND 0x0b48
842 #define RADEON_SURFACE5_INFO 0x0b5c
843 #define RADEON_SURFACE5_LOWER_BOUND 0x0b54
844 #define RADEON_SURFACE5_UPPER_BOUND 0x0b58
845 #define RADEON_SURFACE6_INFO 0x0b6c
846 #define RADEON_SURFACE6_LOWER_BOUND 0x0b64
847 #define RADEON_SURFACE6_UPPER_BOUND 0x0b68
848 #define RADEON_SURFACE7_INFO 0x0b7c
849 #define RADEON_SURFACE7_LOWER_BOUND 0x0b74
850 #define RADEON_SURFACE7_UPPER_BOUND 0x0b78
851 #define RADEON_SW_SEMAPHORE 0x013c
853 #define RADEON_WAIT_UNTIL 0x1720
854 # define RADEON_WAIT_CRTC_PFLIP (1 << 0)
855 # define RADEON_WAIT_2D_IDLE (1 << 14)
856 # define RADEON_WAIT_3D_IDLE (1 << 15)
857 # define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
858 # define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
859 # define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
861 #define RADEON_RB3D_ZMASKOFFSET 0x3234
862 #define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
863 # define RADEON_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
864 # define RADEON_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
867 #define RADEON_CP_ME_RAM_ADDR 0x07d4
868 #define RADEON_CP_ME_RAM_RADDR 0x07d8
869 #define RADEON_CP_ME_RAM_DATAH 0x07dc
870 #define RADEON_CP_ME_RAM_DATAL 0x07e0
872 #define RADEON_CP_RB_BASE 0x0700
873 #define RADEON_CP_RB_CNTL 0x0704
874 # define RADEON_BUF_SWAP_32BIT (2 << 16)
875 # define RADEON_RB_NO_UPDATE (1 << 27)
876 #define RADEON_CP_RB_RPTR_ADDR 0x070c
877 #define RADEON_CP_RB_RPTR 0x0710
878 #define RADEON_CP_RB_WPTR 0x0714
880 #define RADEON_CP_RB_WPTR_DELAY 0x0718
881 # define RADEON_PRE_WRITE_TIMER_SHIFT 0
882 # define RADEON_PRE_WRITE_LIMIT_SHIFT 23
884 #define RADEON_CP_IB_BASE 0x0738
886 #define RADEON_CP_CSQ_CNTL 0x0740
887 # define RADEON_CSQ_CNT_PRIMARY_MASK (0xff << 0)
888 # define RADEON_CSQ_PRIDIS_INDDIS (0 << 28)
889 # define RADEON_CSQ_PRIPIO_INDDIS (1 << 28)
890 # define RADEON_CSQ_PRIBM_INDDIS (2 << 28)
891 # define RADEON_CSQ_PRIPIO_INDBM (3 << 28)
892 # define RADEON_CSQ_PRIBM_INDBM (4 << 28)
893 # define RADEON_CSQ_PRIPIO_INDPIO (15 << 28)
895 #define RADEON_AIC_CNTL 0x01d0
896 # define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
897 #define RADEON_AIC_STAT 0x01d4
898 #define RADEON_AIC_PT_BASE 0x01d8
899 #define RADEON_AIC_LO_ADDR 0x01dc
900 #define RADEON_AIC_HI_ADDR 0x01e0
901 #define RADEON_AIC_TLB_ADDR 0x01e4
902 #define RADEON_AIC_TLB_DATA 0x01e8
904 /* CP command packets */
905 #define RADEON_CP_PACKET0 0x00000000
906 # define RADEON_ONE_REG_WR (1 << 15)
907 #define RADEON_CP_PACKET1 0x40000000
908 #define RADEON_CP_PACKET2 0x80000000
909 #define RADEON_CP_PACKET3 0xC0000000
910 # define RADEON_CP_NOP 0x00001000
911 # define RADEON_CP_NEXT_CHAR 0x00001900
912 # define RADEON_CP_PLY_NEXTSCAN 0x00001D00
913 # define RADEON_CP_SET_SCISSORS 0x00001E00
914 /* GEN_INDX_PRIM is unsupported starting with R300 */
915 # define RADEON_3D_RNDR_GEN_INDX_PRIM 0x00002300
916 # define RADEON_WAIT_FOR_IDLE 0x00002600
917 # define RADEON_3D_DRAW_VBUF 0x00002800
918 # define RADEON_3D_DRAW_IMMD 0x00002900
919 # define RADEON_3D_DRAW_INDX 0x00002A00
920 # define RADEON_CP_LOAD_PALETTE 0x00002C00
921 # define RADEON_3D_LOAD_VBPNTR 0x00002F00
922 # define RADEON_MPEG_IDCT_MACROBLOCK 0x00003000
923 # define RADEON_MPEG_IDCT_MACROBLOCK_REV 0x00003100
924 # define RADEON_3D_CLEAR_ZMASK 0x00003200
925 # define RADEON_CP_INDX_BUFFER 0x00003300
926 # define RADEON_CP_3D_DRAW_VBUF_2 0x00003400
927 # define RADEON_CP_3D_DRAW_IMMD_2 0x00003500
928 # define RADEON_CP_3D_DRAW_INDX_2 0x00003600
929 # define RADEON_3D_CLEAR_HIZ 0x00003700
930 # define RADEON_CP_3D_CLEAR_CMASK 0x00003802
931 # define RADEON_CNTL_HOSTDATA_BLT 0x00009400
932 # define RADEON_CNTL_PAINT_MULTI 0x00009A00
933 # define RADEON_CNTL_BITBLT_MULTI 0x00009B00
934 # define RADEON_CNTL_SET_SCISSORS 0xC0001E00
936 #define RADEON_CP_PACKET_MASK 0xC0000000
937 #define RADEON_CP_PACKET_COUNT_MASK 0x3fff0000
938 #define RADEON_CP_PACKET0_REG_MASK 0x000007ff
939 #define RADEON_CP_PACKET1_REG0_MASK 0x000007ff
940 #define RADEON_CP_PACKET1_REG1_MASK 0x003ff800
942 #define RADEON_VTX_Z_PRESENT (1 << 31)
943 #define RADEON_VTX_PKCOLOR_PRESENT (1 << 3)
945 #define RADEON_PRIM_TYPE_NONE (0 << 0)
946 #define RADEON_PRIM_TYPE_POINT (1 << 0)
947 #define RADEON_PRIM_TYPE_LINE (2 << 0)
948 #define RADEON_PRIM_TYPE_LINE_STRIP (3 << 0)
949 #define RADEON_PRIM_TYPE_TRI_LIST (4 << 0)
950 #define RADEON_PRIM_TYPE_TRI_FAN (5 << 0)
951 #define RADEON_PRIM_TYPE_TRI_STRIP (6 << 0)
952 #define RADEON_PRIM_TYPE_TRI_TYPE2 (7 << 0)
953 #define RADEON_PRIM_TYPE_RECT_LIST (8 << 0)
954 #define RADEON_PRIM_TYPE_3VRT_POINT_LIST (9 << 0)
955 #define RADEON_PRIM_TYPE_3VRT_LINE_LIST (10 << 0)
956 #define RADEON_PRIM_TYPE_MASK 0xf
957 #define RADEON_PRIM_WALK_IND (1 << 4)
958 #define RADEON_PRIM_WALK_LIST (2 << 4)
959 #define RADEON_PRIM_WALK_RING (3 << 4)
960 #define RADEON_COLOR_ORDER_BGRA (0 << 6)
961 #define RADEON_COLOR_ORDER_RGBA (1 << 6)
962 #define RADEON_MAOS_ENABLE (1 << 7)
963 #define RADEON_VTX_FMT_R128_MODE (0 << 8)
964 #define RADEON_VTX_FMT_RADEON_MODE (1 << 8)
965 #define RADEON_NUM_VERTICES_SHIFT 16
967 #define RADEON_COLOR_FORMAT_CI8 2
968 #define RADEON_COLOR_FORMAT_ARGB1555 3
969 #define RADEON_COLOR_FORMAT_RGB565 4
970 #define RADEON_COLOR_FORMAT_ARGB8888 6
971 #define RADEON_COLOR_FORMAT_RGB332 7
972 #define RADEON_COLOR_FORMAT_RGB8 9
973 #define RADEON_COLOR_FORMAT_ARGB4444 15
975 #define RADEON_TXFORMAT_I8 0
976 #define RADEON_TXFORMAT_AI88 1
977 #define RADEON_TXFORMAT_RGB332 2
978 #define RADEON_TXFORMAT_ARGB1555 3
979 #define RADEON_TXFORMAT_RGB565 4
980 #define RADEON_TXFORMAT_ARGB4444 5
981 #define RADEON_TXFORMAT_ARGB8888 6
982 #define RADEON_TXFORMAT_RGBA8888 7
983 #define RADEON_TXFORMAT_Y8 8
984 #define RADEON_TXFORMAT_VYUY422 10
985 #define RADEON_TXFORMAT_YVYU422 11
986 #define RADEON_TXFORMAT_DXT1 12
987 #define RADEON_TXFORMAT_DXT23 14
988 #define RADEON_TXFORMAT_DXT45 15
990 #define R200_PP_TXCBLEND_0 0x2f00
991 #define R200_PP_TXCBLEND_1 0x2f10
992 #define R200_PP_TXCBLEND_2 0x2f20
993 #define R200_PP_TXCBLEND_3 0x2f30
994 #define R200_PP_TXCBLEND_4 0x2f40
995 #define R200_PP_TXCBLEND_5 0x2f50
996 #define R200_PP_TXCBLEND_6 0x2f60
997 #define R200_PP_TXCBLEND_7 0x2f70
998 #define R200_SE_TCL_LIGHT_MODEL_CTL_0 0x2268
999 #define R200_PP_TFACTOR_0 0x2ee0
1000 #define R200_SE_VTX_FMT_0 0x2088
1001 #define R200_SE_VAP_CNTL 0x2080
1002 #define R200_SE_TCL_MATRIX_SEL_0 0x2230
1003 #define R200_SE_TCL_TEX_PROC_CTL_2 0x22a8
1004 #define R200_SE_TCL_UCP_VERT_BLEND_CTL 0x22c0
1005 #define R200_PP_TXFILTER_5 0x2ca0
1006 #define R200_PP_TXFILTER_4 0x2c80
1007 #define R200_PP_TXFILTER_3 0x2c60
1008 #define R200_PP_TXFILTER_2 0x2c40
1009 #define R200_PP_TXFILTER_1 0x2c20
1010 #define R200_PP_TXFILTER_0 0x2c00
1011 #define R200_PP_TXOFFSET_5 0x2d78
1012 #define R200_PP_TXOFFSET_4 0x2d60
1013 #define R200_PP_TXOFFSET_3 0x2d48
1014 #define R200_PP_TXOFFSET_2 0x2d30
1015 #define R200_PP_TXOFFSET_1 0x2d18
1016 #define R200_PP_TXOFFSET_0 0x2d00
1018 #define R200_PP_CUBIC_FACES_0 0x2c18
1019 #define R200_PP_CUBIC_FACES_1 0x2c38
1020 #define R200_PP_CUBIC_FACES_2 0x2c58
1021 #define R200_PP_CUBIC_FACES_3 0x2c78
1022 #define R200_PP_CUBIC_FACES_4 0x2c98
1023 #define R200_PP_CUBIC_FACES_5 0x2cb8
1024 #define R200_PP_CUBIC_OFFSET_F1_0 0x2d04
1025 #define R200_PP_CUBIC_OFFSET_F2_0 0x2d08
1026 #define R200_PP_CUBIC_OFFSET_F3_0 0x2d0c
1027 #define R200_PP_CUBIC_OFFSET_F4_0 0x2d10
1028 #define R200_PP_CUBIC_OFFSET_F5_0 0x2d14
1029 #define R200_PP_CUBIC_OFFSET_F1_1 0x2d1c
1030 #define R200_PP_CUBIC_OFFSET_F2_1 0x2d20
1031 #define R200_PP_CUBIC_OFFSET_F3_1 0x2d24
1032 #define R200_PP_CUBIC_OFFSET_F4_1 0x2d28
1033 #define R200_PP_CUBIC_OFFSET_F5_1 0x2d2c
1034 #define R200_PP_CUBIC_OFFSET_F1_2 0x2d34
1035 #define R200_PP_CUBIC_OFFSET_F2_2 0x2d38
1036 #define R200_PP_CUBIC_OFFSET_F3_2 0x2d3c
1037 #define R200_PP_CUBIC_OFFSET_F4_2 0x2d40
1038 #define R200_PP_CUBIC_OFFSET_F5_2 0x2d44
1039 #define R200_PP_CUBIC_OFFSET_F1_3 0x2d4c
1040 #define R200_PP_CUBIC_OFFSET_F2_3 0x2d50
1041 #define R200_PP_CUBIC_OFFSET_F3_3 0x2d54
1042 #define R200_PP_CUBIC_OFFSET_F4_3 0x2d58
1043 #define R200_PP_CUBIC_OFFSET_F5_3 0x2d5c
1044 #define R200_PP_CUBIC_OFFSET_F1_4 0x2d64
1045 #define R200_PP_CUBIC_OFFSET_F2_4 0x2d68
1046 #define R200_PP_CUBIC_OFFSET_F3_4 0x2d6c
1047 #define R200_PP_CUBIC_OFFSET_F4_4 0x2d70
1048 #define R200_PP_CUBIC_OFFSET_F5_4 0x2d74
1049 #define R200_PP_CUBIC_OFFSET_F1_5 0x2d7c
1050 #define R200_PP_CUBIC_OFFSET_F2_5 0x2d80
1051 #define R200_PP_CUBIC_OFFSET_F3_5 0x2d84
1052 #define R200_PP_CUBIC_OFFSET_F4_5 0x2d88
1053 #define R200_PP_CUBIC_OFFSET_F5_5 0x2d8c
1055 #define R200_RE_AUX_SCISSOR_CNTL 0x26f0
1056 #define R200_SE_VTE_CNTL 0x20b0
1057 #define R200_SE_TCL_OUTPUT_VTX_COMP_SEL 0x2250
1058 #define R200_PP_TAM_DEBUG3 0x2d9c
1059 #define R200_PP_CNTL_X 0x2cc4
1060 #define R200_SE_VAP_CNTL_STATUS 0x2140
1061 #define R200_RE_SCISSOR_TL_0 0x1cd8
1062 #define R200_RE_SCISSOR_TL_1 0x1ce0
1063 #define R200_RE_SCISSOR_TL_2 0x1ce8
1064 #define R200_RB3D_DEPTHXY_OFFSET 0x1d60
1065 #define R200_RE_AUX_SCISSOR_CNTL 0x26f0
1066 #define R200_SE_VTX_STATE_CNTL 0x2180
1067 #define R200_RE_POINTSIZE 0x2648
1068 #define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0 0x2254
1070 #define RADEON_PP_TEX_SIZE_0 0x1d04 /* NPOT */
1071 #define RADEON_PP_TEX_SIZE_1 0x1d0c
1072 #define RADEON_PP_TEX_SIZE_2 0x1d14
1074 #define RADEON_PP_CUBIC_FACES_0 0x1d24
1075 #define RADEON_PP_CUBIC_FACES_1 0x1d28
1076 #define RADEON_PP_CUBIC_FACES_2 0x1d2c
1077 #define RADEON_PP_CUBIC_OFFSET_T0_0 0x1dd0 /* bits [31:5] */
1078 #define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00
1079 #define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14
1081 #define RADEON_SE_TCL_STATE_FLUSH 0x2284
1083 #define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001
1084 #define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK 0x00010000
1085 #define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 0x00000012
1086 #define SE_VTE_CNTL__VTX_XY_FMT_MASK 0x00000100
1087 #define SE_VTE_CNTL__VTX_Z_FMT_MASK 0x00000200
1088 #define SE_VTX_FMT_0__VTX_Z0_PRESENT_MASK 0x00000001
1089 #define SE_VTX_FMT_0__VTX_W0_PRESENT_MASK 0x00000002
1090 #define SE_VTX_FMT_0__VTX_COLOR_0_FMT__SHIFT 0x0000000b
1091 #define R200_3D_DRAW_IMMD_2 0xC0003500
1092 #define R200_SE_VTX_FMT_1 0x208c
1093 #define R200_RE_CNTL 0x1c50
1095 #define R200_RB3D_BLENDCOLOR 0x3218
1097 #define R200_SE_TCL_POINT_SPRITE_CNTL 0x22c4
1099 #define R200_PP_TRI_PERF 0x2cf8
1101 #define R200_PP_AFS_0 0x2f80
1102 #define R200_PP_AFS_1 0x2f00 /* same as txcblend_0 */
1104 #define R200_VAP_PVS_CNTL_1 0x22D0
1107 #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
1109 #define RADEON_LAST_FRAME_REG RADEON_SCRATCH_REG0
1110 #define RADEON_LAST_DISPATCH_REG RADEON_SCRATCH_REG1
1111 #define RADEON_LAST_CLEAR_REG RADEON_SCRATCH_REG2
1112 #define RADEON_LAST_SWI_REG RADEON_SCRATCH_REG3
1113 #define RADEON_LAST_DISPATCH 1
1115 #define RADEON_MAX_VB_AGE 0x7fffffff
1116 #define RADEON_MAX_VB_VERTS (0xffff)
1118 #define RADEON_RING_HIGH_MARK 128
1120 #define RADEON_PCIGART_TABLE_SIZE (32*1024)
1122 #define RADEON_READ(reg) DRM_READ32( dev_priv->mmio, (reg) )
1123 #define RADEON_WRITE(reg,val) DRM_WRITE32( dev_priv->mmio, (reg), (val) )
1124 #define RADEON_READ8(reg) DRM_READ8( dev_priv->mmio, (reg) )
1125 #define RADEON_WRITE8(reg,val) DRM_WRITE8( dev_priv->mmio, (reg), (val) )
1127 #define RADEON_WRITE_PLL(addr, val) \
1129 RADEON_WRITE8(RADEON_CLOCK_CNTL_INDEX, \
1130 ((addr) & 0x1f) | RADEON_PLL_WR_EN ); \
1131 RADEON_WRITE(RADEON_CLOCK_CNTL_DATA, (val)); \
1134 #define RADEON_WRITE_PCIE(addr, val) \
1136 RADEON_WRITE8(RADEON_PCIE_INDEX, \
1138 RADEON_WRITE(RADEON_PCIE_DATA, (val)); \
1141 #define R500_WRITE_MCIND(addr, val) \
1143 RADEON_WRITE(R520_MC_IND_INDEX, 0xff0000 | ((addr) & 0xff)); \
1144 RADEON_WRITE(R520_MC_IND_DATA, (val)); \
1145 RADEON_WRITE(R520_MC_IND_INDEX, 0); \
1148 #define RS480_WRITE_MCIND(addr, val) \
1150 RADEON_WRITE(RS480_NB_MC_INDEX, \
1151 ((addr) & 0xff) | RS480_NB_MC_IND_WR_EN); \
1152 RADEON_WRITE(RS480_NB_MC_DATA, (val)); \
1153 RADEON_WRITE(RS480_NB_MC_INDEX, 0xff); \
1156 #define RS690_WRITE_MCIND(addr, val) \
1158 RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_EN | ((addr) & RS690_MC_INDEX_MASK)); \
1159 RADEON_WRITE(RS690_MC_DATA, val); \
1160 RADEON_WRITE(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK); \
1163 #define IGP_WRITE_MCIND(addr, val) \
1165 if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) \
1166 RS690_WRITE_MCIND(addr, val); \
1168 RS480_WRITE_MCIND(addr, val); \
1171 #define CP_PACKET0( reg, n ) \
1172 (RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
1173 #define CP_PACKET0_TABLE( reg, n ) \
1174 (RADEON_CP_PACKET0 | RADEON_ONE_REG_WR | ((n) << 16) | ((reg) >> 2))
1175 #define CP_PACKET1( reg0, reg1 ) \
1176 (RADEON_CP_PACKET1 | (((reg1) >> 2) << 15) | ((reg0) >> 2))
1177 #define CP_PACKET2() \
1179 #define CP_PACKET3( pkt, n ) \
1180 (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
1182 /* ================================================================
1183 * Engine control helper macros
1186 #define RADEON_WAIT_UNTIL_2D_IDLE() do { \
1187 OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
1188 OUT_RING( (RADEON_WAIT_2D_IDLECLEAN | \
1189 RADEON_WAIT_HOST_IDLECLEAN) ); \
1192 #define RADEON_WAIT_UNTIL_3D_IDLE() do { \
1193 OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
1194 OUT_RING( (RADEON_WAIT_3D_IDLECLEAN | \
1195 RADEON_WAIT_HOST_IDLECLEAN) ); \
1198 #define RADEON_WAIT_UNTIL_IDLE() do { \
1199 OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
1200 OUT_RING( (RADEON_WAIT_2D_IDLECLEAN | \
1201 RADEON_WAIT_3D_IDLECLEAN | \
1202 RADEON_WAIT_HOST_IDLECLEAN) ); \
1205 #define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do { \
1206 OUT_RING( CP_PACKET0( RADEON_WAIT_UNTIL, 0 ) ); \
1207 OUT_RING( RADEON_WAIT_CRTC_PFLIP ); \
1210 #define RADEON_FLUSH_CACHE() do { \
1211 if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
1212 OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \
1213 OUT_RING(RADEON_RB3D_DC_FLUSH); \
1215 OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \
1216 OUT_RING(RADEON_RB3D_DC_FLUSH); \
1220 #define RADEON_PURGE_CACHE() do { \
1221 if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
1222 OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \
1223 OUT_RING(RADEON_RB3D_DC_FLUSH_ALL); \
1225 OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \
1226 OUT_RING(RADEON_RB3D_DC_FLUSH_ALL); \
1230 #define RADEON_FLUSH_ZCACHE() do { \
1231 if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
1232 OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \
1233 OUT_RING(RADEON_RB3D_ZC_FLUSH); \
1235 OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0)); \
1236 OUT_RING(R300_ZC_FLUSH); \
1240 #define RADEON_PURGE_ZCACHE() do { \
1241 if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \
1242 OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \
1243 OUT_RING(RADEON_RB3D_ZC_FLUSH_ALL); \
1245 OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \
1246 OUT_RING(R300_ZC_FLUSH_ALL); \
1250 /* ================================================================
1251 * Misc helper macros
1254 /* Perfbox functionality only.
1256 #define RING_SPACE_TEST_WITH_RETURN( dev_priv ) \
1258 if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) { \
1259 u32 head = GET_RING_HEAD( dev_priv ); \
1260 if (head == dev_priv->ring.tail) \
1261 dev_priv->stats.boxes |= RADEON_BOX_DMA_IDLE; \
1265 #define VB_AGE_TEST_WITH_RETURN( dev_priv ) \
1267 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; \
1268 if ( sarea_priv->last_dispatch >= RADEON_MAX_VB_AGE ) { \
1269 int __ret = radeon_do_cp_idle( dev_priv ); \
1270 if ( __ret ) return __ret; \
1271 sarea_priv->last_dispatch = 0; \
1272 radeon_freelist_reset( dev ); \
1276 #define RADEON_DISPATCH_AGE( age ) do { \
1277 OUT_RING( CP_PACKET0( RADEON_LAST_DISPATCH_REG, 0 ) ); \
1281 #define RADEON_FRAME_AGE( age ) do { \
1282 OUT_RING( CP_PACKET0( RADEON_LAST_FRAME_REG, 0 ) ); \
1286 #define RADEON_CLEAR_AGE( age ) do { \
1287 OUT_RING( CP_PACKET0( RADEON_LAST_CLEAR_REG, 0 ) ); \
1291 /* ================================================================
1295 #define RADEON_VERBOSE 0
1297 #define RING_LOCALS int write, _nr; unsigned int mask; u32 *ring;
1299 #define BEGIN_RING( n ) do { \
1300 if ( RADEON_VERBOSE ) { \
1301 DRM_INFO( "BEGIN_RING( %d )\n", (n)); \
1303 if ( dev_priv->ring.space <= (n) * sizeof(u32) ) { \
1305 radeon_wait_ring( dev_priv, (n) * sizeof(u32) ); \
1307 _nr = n; dev_priv->ring.space -= (n) * sizeof(u32); \
1308 ring = dev_priv->ring.start; \
1309 write = dev_priv->ring.tail; \
1310 mask = dev_priv->ring.tail_mask; \
1313 #define ADVANCE_RING() do { \
1314 if ( RADEON_VERBOSE ) { \
1315 DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n", \
1316 write, dev_priv->ring.tail ); \
1318 if (((dev_priv->ring.tail + _nr) & mask) != write) { \
1320 "ADVANCE_RING(): mismatch: nr: %x write: %x line: %d\n", \
1321 ((dev_priv->ring.tail + _nr) & mask), \
1324 dev_priv->ring.tail = write; \
1327 #define COMMIT_RING() do { \
1328 /* Flush writes to ring */ \
1329 DRM_MEMORYBARRIER(); \
1330 GET_RING_HEAD( dev_priv ); \
1331 RADEON_WRITE( RADEON_CP_RB_WPTR, dev_priv->ring.tail ); \
1332 /* read from PCI bus to ensure correct posting */ \
1333 RADEON_READ( RADEON_CP_RB_RPTR ); \
1336 #define OUT_RING( x ) do { \
1337 if ( RADEON_VERBOSE ) { \
1338 DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \
1339 (unsigned int)(x), write ); \
1341 ring[write++] = (x); \
1345 #define OUT_RING_REG( reg, val ) do { \
1346 OUT_RING( CP_PACKET0( reg, 0 ) ); \
1350 #define OUT_RING_TABLE( tab, sz ) do { \
1352 int *_tab = (int *)(tab); \
1354 if (write + _size > mask) { \
1355 int _i = (mask+1) - write; \
1358 *(int *)(ring + write) = *_tab++; \
1365 while (_size > 0) { \
1366 *(ring + write) = *_tab++; \
1373 #endif /* __RADEON_DRV_H__ */