1e57b9183Scg149915 /* 2*0f7bfed6Smiao chen - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 3e57b9183Scg149915 * Use is subject to license terms. 4e57b9183Scg149915 */ 5e57b9183Scg149915 /* 6e57b9183Scg149915 * radeon_drv.h -- Private header for radeon driver -*- linux-c -*- 7e57b9183Scg149915 * 8e57b9183Scg149915 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 9e57b9183Scg149915 * Copyright 2000 VA Linux Systems, Inc., Fremont, California. 10e57b9183Scg149915 * All rights reserved. 11e57b9183Scg149915 * 12e57b9183Scg149915 * Permission is hereby granted, free of charge, to any person obtaining a 13e57b9183Scg149915 * copy of this software and associated documentation files (the "Software"), 14e57b9183Scg149915 * to deal in the Software without restriction, including without limitation 15e57b9183Scg149915 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16e57b9183Scg149915 * and/or sell copies of the Software, and to permit persons to whom the 17e57b9183Scg149915 * Software is furnished to do so, subject to the following conditions: 18e57b9183Scg149915 * 19e57b9183Scg149915 * The above copyright notice and this permission notice (including the next 20e57b9183Scg149915 * paragraph) shall be included in all copies or substantial portions of the 21e57b9183Scg149915 * Software. 22e57b9183Scg149915 * 23e57b9183Scg149915 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24e57b9183Scg149915 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25e57b9183Scg149915 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26e57b9183Scg149915 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 27e57b9183Scg149915 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 28e57b9183Scg149915 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29e57b9183Scg149915 * DEALINGS IN THE SOFTWARE. 30e57b9183Scg149915 * 31e57b9183Scg149915 * Authors: 32e57b9183Scg149915 * Kevin E. Martin <martin@valinux.com> 33e57b9183Scg149915 * Gareth Hughes <gareth@valinux.com> 34e57b9183Scg149915 */ 35e57b9183Scg149915 36e57b9183Scg149915 #ifndef __RADEON_DRV_H__ 37e57b9183Scg149915 #define __RADEON_DRV_H__ 38e57b9183Scg149915 39e57b9183Scg149915 /* 40e57b9183Scg149915 * Enable debugging information outputs. Need to recompile 41e57b9183Scg149915 * 42e57b9183Scg149915 * #define RADEON_FIFO_DEBUG 1 43e57b9183Scg149915 */ 44e57b9183Scg149915 45e57b9183Scg149915 /* General customization: */ 46e57b9183Scg149915 47e57b9183Scg149915 #define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others." 48e57b9183Scg149915 49e57b9183Scg149915 #define DRIVER_NAME "radeon" 50e57b9183Scg149915 #define DRIVER_DESC "ATI Radeon" 51e57b9183Scg149915 #define DRIVER_DATE "20060524" 52e57b9183Scg149915 53e57b9183Scg149915 /* 54e57b9183Scg149915 * Interface history: 55e57b9183Scg149915 * 56e57b9183Scg149915 * 1.1 - ?? 57e57b9183Scg149915 * 1.2 - Add vertex2 ioctl (keith) 58e57b9183Scg149915 * - Add stencil capability to clear ioctl (gareth, keith) 59e57b9183Scg149915 * - Increase MAX_TEXTURE_LEVELS (brian) 60e57b9183Scg149915 * 1.3 - Add cmdbuf ioctl (keith) 61e57b9183Scg149915 * - Add support for new radeon packets (keith) 62e57b9183Scg149915 * - Add getparam ioctl (keith) 63e57b9183Scg149915 * - Add flip-buffers ioctl, deprecate fullscreen foo (keith). 64e57b9183Scg149915 * 1.4 - Add scratch registers to get_param ioctl. 65e57b9183Scg149915 * 1.5 - Add r200 packets to cmdbuf ioctl 66e57b9183Scg149915 * - Add r200 function to init ioctl 67e57b9183Scg149915 * - Add 'scalar2' instruction to cmdbuf 68e57b9183Scg149915 * 1.6 - Add static GART memory manager 69e57b9183Scg149915 * Add irq handler (won't be turned on unless X server knows to) 70e57b9183Scg149915 * Add irq ioctls and irq_active getparam. 71e57b9183Scg149915 * Add wait command for cmdbuf ioctl 72e57b9183Scg149915 * Add GART offset query for getparam 73e57b9183Scg149915 * 1.7 - Add support for cube map registers: R200_PP_CUBIC_FACES_[0..5] 74e57b9183Scg149915 * and R200_PP_CUBIC_OFFSET_F1_[0..5]. 75e57b9183Scg149915 * Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and 76e57b9183Scg149915 * R200_EMIT_PP_CUBIC_OFFSETS_[0..5]. (brian) 77e57b9183Scg149915 * 1.8 - Remove need to call cleanup ioctls on last client exit (keith) 78e57b9183Scg149915 * Add 'GET' queries for starting additional clients on different 79e57b9183Scg149915 * VT's. 80e57b9183Scg149915 * 1.9 - Add DRM_IOCTL_RADEON_CP_RESUME ioctl. 81e57b9183Scg149915 * Add texture rectangle support for r100. 82e57b9183Scg149915 * 1.10- Add SETPARAM ioctl; first parameter to set is FB_LOCATION, which 83e57b9183Scg149915 * clients use to tell the DRM where they think the framebuffer is 84e57b9183Scg149915 * located in the card's address space 85e57b9183Scg149915 * 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color 86e57b9183Scg149915 * and GL_EXT_blend_[func|equation]_separate on r200 87e57b9183Scg149915 * 1.12- Add R300 CP microcode support - this just loads the CP on r300 88e57b9183Scg149915 * (No 3D support yet - just microcode loading). 89e57b9183Scg149915 * 1.13- Add packet R200_EMIT_TCL_POINT_SPRITE_CNTL for ARB_point_parameters 90e57b9183Scg149915 * - Add hyperz support, add hyperz flags to clear ioctl. 91e57b9183Scg149915 * 1.14- Add support for color tiling 92e57b9183Scg149915 * - Add R100/R200 surface allocation/free support 93e57b9183Scg149915 * 1.15- Add support for texture micro tiling 94e57b9183Scg149915 * - Add support for r100 cube maps 95e57b9183Scg149915 * 1.16- Add R200_EMIT_PP_TRI_PERF_CNTL packet to support brilinear 96e57b9183Scg149915 * texture filtering on r200 97e57b9183Scg149915 * 1.17- Add initial support for R300 (3D). 98e57b9183Scg149915 * 1.18- Add support for GL_ATI_fragment_shader, new packets 99e57b9183Scg149915 * R200_EMIT_PP_AFS_0/1, R200_EMIT_PP_TXCTLALL_0-5 (replaces 100e57b9183Scg149915 * R200_EMIT_PP_TXFILTER_0-5, 2 more regs) and 101e57b9183Scg149915 * R200_EMIT_ATF_TFACTOR 102e57b9183Scg149915 * (replaces R200_EMIT_TFACTOR_0 (8 consts instead of 6) 103e57b9183Scg149915 * 1.19- Add support for gart table in FB memory and PCIE r300 104e57b9183Scg149915 * 1.20- Add support for r300 texrect 105e57b9183Scg149915 * 1.21- Add support for card type getparam 106e57b9183Scg149915 * 1.22- Add support for texture cache flushes (R300_TX_CNTL) 107e57b9183Scg149915 * 1.23- Add new radeon memory map work from benh 108e57b9183Scg149915 * 1.24- Add general-purpose packet for manipulating scratch registers (r300) 109e57b9183Scg149915 * 1.25- Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL, 110e57b9183Scg149915 * new packet type) 111e57b9183Scg149915 */ 112e57b9183Scg149915 113e57b9183Scg149915 #define DRIVER_MAJOR 1 114e57b9183Scg149915 #define DRIVER_MINOR 25 115e57b9183Scg149915 #define DRIVER_PATCHLEVEL 0 116e57b9183Scg149915 117e57b9183Scg149915 /* 118e57b9183Scg149915 * Radeon chip families 119e57b9183Scg149915 */ 120e57b9183Scg149915 enum radeon_family { 121e57b9183Scg149915 CHIP_R100, 122e57b9183Scg149915 CHIP_RV100, 123e57b9183Scg149915 CHIP_RS100, 124e57b9183Scg149915 CHIP_RV200, 125e57b9183Scg149915 CHIP_RS200, 126e57b9183Scg149915 CHIP_R200, 127e57b9183Scg149915 CHIP_RV250, 128e57b9183Scg149915 CHIP_RS300, 129e57b9183Scg149915 CHIP_RV280, 130e57b9183Scg149915 CHIP_R300, 131e57b9183Scg149915 CHIP_R350, 132e57b9183Scg149915 CHIP_RV350, 133e57b9183Scg149915 CHIP_RV380, 134e57b9183Scg149915 CHIP_R420, 135e57b9183Scg149915 CHIP_RV410, 136e57b9183Scg149915 CHIP_RS400, 137e57b9183Scg149915 CHIP_LAST, 138e57b9183Scg149915 }; 139e57b9183Scg149915 140e57b9183Scg149915 enum radeon_cp_microcode_version { 141e57b9183Scg149915 UCODE_R100, 142e57b9183Scg149915 UCODE_R200, 143e57b9183Scg149915 UCODE_R300, 144e57b9183Scg149915 }; 145e57b9183Scg149915 146e57b9183Scg149915 /* 147e57b9183Scg149915 * Chip flags 148e57b9183Scg149915 */ 149e57b9183Scg149915 #define RADEON_FAMILY_MASK 0x0000ffffUL 150e57b9183Scg149915 #define RADEON_FLAGS_MASK 0xffff0000UL 151e57b9183Scg149915 #define RADEON_IS_MOBILITY 0x00010000UL 152e57b9183Scg149915 #define RADEON_IS_IGP 0x00020000UL 153e57b9183Scg149915 #define RADEON_SINGLE_CRTC 0x00040000UL 154e57b9183Scg149915 #define RADEON_IS_AGP 0x00080000UL 155e57b9183Scg149915 #define RADEON_HAS_HIERZ 0x00100000UL 156e57b9183Scg149915 #define RADEON_IS_PCIE 0x00200000UL 157e57b9183Scg149915 #define RADEON_NEW_MEMMAP 0x00400000UL 158e57b9183Scg149915 #define RADEON_IS_PCI 0x00800000UL 159e57b9183Scg149915 160e57b9183Scg149915 #define GET_RING_HEAD(dev_priv) \ 161e57b9183Scg149915 (dev_priv->writeback_works ? \ 162e57b9183Scg149915 DRM_READ32((dev_priv)->ring_rptr, 0) : \ 163e57b9183Scg149915 RADEON_READ(RADEON_CP_RB_RPTR)) 164e57b9183Scg149915 165e57b9183Scg149915 #define SET_RING_HEAD(dev_priv, val) \ 166e57b9183Scg149915 DRM_WRITE32((dev_priv)->ring_rptr, 0, (val)) 167e57b9183Scg149915 168e57b9183Scg149915 typedef struct drm_radeon_freelist { 169e57b9183Scg149915 unsigned int age; 170e57b9183Scg149915 drm_buf_t *buf; 171e57b9183Scg149915 struct drm_radeon_freelist *next; 172e57b9183Scg149915 struct drm_radeon_freelist *prev; 173e57b9183Scg149915 } drm_radeon_freelist_t; 174e57b9183Scg149915 175e57b9183Scg149915 typedef struct drm_radeon_ring_buffer { 176e57b9183Scg149915 u32 *start; 177e57b9183Scg149915 u32 *end; 178e57b9183Scg149915 int size; 179e57b9183Scg149915 int size_l2qw; 180e57b9183Scg149915 181e57b9183Scg149915 u32 tail; 182e57b9183Scg149915 u32 tail_mask; 183e57b9183Scg149915 int space; 184e57b9183Scg149915 185e57b9183Scg149915 int high_mark; 186e57b9183Scg149915 } drm_radeon_ring_buffer_t; 187e57b9183Scg149915 188e57b9183Scg149915 typedef struct drm_radeon_depth_clear_t { 189e57b9183Scg149915 u32 rb3d_cntl; 190e57b9183Scg149915 u32 rb3d_zstencilcntl; 191e57b9183Scg149915 u32 se_cntl; 192e57b9183Scg149915 } drm_radeon_depth_clear_t; 193e57b9183Scg149915 194e57b9183Scg149915 struct drm_radeon_driver_file_fields { 195e57b9183Scg149915 int64_t radeon_fb_delta; 196e57b9183Scg149915 }; 197e57b9183Scg149915 198e57b9183Scg149915 struct mem_block { 199e57b9183Scg149915 struct mem_block *next; 200e57b9183Scg149915 struct mem_block *prev; 201e57b9183Scg149915 int start; 202e57b9183Scg149915 int size; 203e57b9183Scg149915 drm_file_t *filp; /* 0: free, -1: heap, other: real files */ 204e57b9183Scg149915 }; 205e57b9183Scg149915 206e57b9183Scg149915 struct radeon_surface { 207e57b9183Scg149915 int refcount; 208e57b9183Scg149915 u32 lower; 209e57b9183Scg149915 u32 upper; 210e57b9183Scg149915 u32 flags; 211e57b9183Scg149915 }; 212e57b9183Scg149915 213e57b9183Scg149915 struct radeon_virt_surface { 214e57b9183Scg149915 int surface_index; 215e57b9183Scg149915 u32 lower; 216e57b9183Scg149915 u32 upper; 217e57b9183Scg149915 u32 flags; 218e57b9183Scg149915 drm_file_t *filp; 219e57b9183Scg149915 }; 220e57b9183Scg149915 221e57b9183Scg149915 typedef struct drm_radeon_private { 222e57b9183Scg149915 223e57b9183Scg149915 drm_radeon_ring_buffer_t ring; 224e57b9183Scg149915 drm_radeon_sarea_t *sarea_priv; 225e57b9183Scg149915 226e57b9183Scg149915 u32 fb_location; 227e57b9183Scg149915 u32 fb_size; 228e57b9183Scg149915 int new_memmap; 229e57b9183Scg149915 230e57b9183Scg149915 int gart_size; 231e57b9183Scg149915 u32 gart_vm_start; 232e57b9183Scg149915 unsigned long gart_buffers_offset; 233e57b9183Scg149915 234e57b9183Scg149915 int cp_mode; 235e57b9183Scg149915 int cp_running; 236e57b9183Scg149915 237e57b9183Scg149915 drm_radeon_freelist_t *head; 238e57b9183Scg149915 drm_radeon_freelist_t *tail; 239e57b9183Scg149915 int last_buf; 240e57b9183Scg149915 volatile u32 *scratch; 241e57b9183Scg149915 int writeback_works; 242e57b9183Scg149915 243e57b9183Scg149915 int usec_timeout; 244e57b9183Scg149915 245e57b9183Scg149915 int microcode_version; 246e57b9183Scg149915 247e57b9183Scg149915 struct { 248e57b9183Scg149915 u32 boxes; 249e57b9183Scg149915 int freelist_timeouts; 250e57b9183Scg149915 int freelist_loops; 251e57b9183Scg149915 int requested_bufs; 252e57b9183Scg149915 int last_frame_reads; 253e57b9183Scg149915 int last_clear_reads; 254e57b9183Scg149915 int clears; 255e57b9183Scg149915 int texture_uploads; 256e57b9183Scg149915 } stats; 257e57b9183Scg149915 258e57b9183Scg149915 int do_boxes; 259e57b9183Scg149915 int page_flipping; 260e57b9183Scg149915 int current_page; 261e57b9183Scg149915 262e57b9183Scg149915 u32 color_fmt; 263e57b9183Scg149915 unsigned int front_offset; 264e57b9183Scg149915 unsigned int front_pitch; 265e57b9183Scg149915 unsigned int back_offset; 266e57b9183Scg149915 unsigned int back_pitch; 267e57b9183Scg149915 268e57b9183Scg149915 u32 depth_fmt; 269e57b9183Scg149915 unsigned int depth_offset; 270e57b9183Scg149915 unsigned int depth_pitch; 271e57b9183Scg149915 272e57b9183Scg149915 u32 front_pitch_offset; 273e57b9183Scg149915 u32 back_pitch_offset; 274e57b9183Scg149915 u32 depth_pitch_offset; 275e57b9183Scg149915 276e57b9183Scg149915 drm_radeon_depth_clear_t depth_clear; 277e57b9183Scg149915 278e57b9183Scg149915 unsigned long ring_offset; 279e57b9183Scg149915 unsigned long ring_rptr_offset; 280e57b9183Scg149915 unsigned long buffers_offset; 281e57b9183Scg149915 unsigned long gart_textures_offset; 282e57b9183Scg149915 283e57b9183Scg149915 drm_local_map_t *sarea; 284e57b9183Scg149915 drm_local_map_t *mmio; 285e57b9183Scg149915 drm_local_map_t *cp_ring; 286e57b9183Scg149915 drm_local_map_t *ring_rptr; 287e57b9183Scg149915 drm_local_map_t *gart_textures; 288e57b9183Scg149915 289e57b9183Scg149915 struct mem_block *gart_heap; 290e57b9183Scg149915 struct mem_block *fb_heap; 291e57b9183Scg149915 292e57b9183Scg149915 /* SW interrupt */ 293e57b9183Scg149915 wait_queue_head_t swi_queue; 294e57b9183Scg149915 atomic_t swi_emitted; 295e57b9183Scg149915 int vblank_crtc; 296e57b9183Scg149915 uint32_t irq_enable_reg; 297e57b9183Scg149915 int irq_enabled; 298e57b9183Scg149915 299e57b9183Scg149915 300e57b9183Scg149915 struct radeon_surface surfaces[RADEON_MAX_SURFACES]; 301e57b9183Scg149915 struct radeon_virt_surface virt_surfaces[2*RADEON_MAX_SURFACES]; 302e57b9183Scg149915 303e57b9183Scg149915 unsigned long pcigart_offset; 304e57b9183Scg149915 drm_ati_pcigart_info gart_info; 305e57b9183Scg149915 306e57b9183Scg149915 u32 scratch_ages[5]; 307e57b9183Scg149915 308e57b9183Scg149915 /* starting from here on, data is preserved accross an open */ 309e57b9183Scg149915 uint32_t flags; /* see radeon_chip_flags */ 310e57b9183Scg149915 311e57b9183Scg149915 } drm_radeon_private_t; 312e57b9183Scg149915 313e57b9183Scg149915 typedef struct drm_radeon_buf_priv { 314e57b9183Scg149915 u32 age; 315e57b9183Scg149915 } drm_radeon_buf_priv_t; 316e57b9183Scg149915 317e57b9183Scg149915 typedef struct drm_radeon_kcmd_buffer { 318e57b9183Scg149915 int bufsz; 319e57b9183Scg149915 char *buf; 320e57b9183Scg149915 int nbox; 321e57b9183Scg149915 drm_clip_rect_t __user *boxes; 322e57b9183Scg149915 } drm_radeon_kcmd_buffer_t; 323e57b9183Scg149915 324e57b9183Scg149915 extern int radeon_no_wb; 325e57b9183Scg149915 extern drm_ioctl_desc_t radeon_ioctls[]; 326e57b9183Scg149915 extern int radeon_max_ioctl; 327e57b9183Scg149915 328e57b9183Scg149915 329e57b9183Scg149915 /* 330e57b9183Scg149915 * Check whether the given hardware address is inside the framebuffer or the 331e57b9183Scg149915 * GART area. 332e57b9183Scg149915 */ 3330bdffa0fShh224818 #define RADEON_CHECK_OFFSET(dev_priv, off) \ 3340bdffa0fShh224818 (((off >= dev_priv->fb_location) && \ 3350bdffa0fShh224818 (off <= (dev_priv->fb_location + dev_priv->fb_size - 1))) || \ 3360bdffa0fShh224818 ((off >= dev_priv->gart_vm_start) && \ 3370bdffa0fShh224818 (off <= (dev_priv->gart_vm_start + dev_priv->gart_size - 1)))) 338e57b9183Scg149915 339e57b9183Scg149915 /* radeon_cp.c */ 340e57b9183Scg149915 extern int radeon_cp_init(DRM_IOCTL_ARGS); 341e57b9183Scg149915 extern int radeon_cp_start(DRM_IOCTL_ARGS); 342e57b9183Scg149915 extern int radeon_cp_stop(DRM_IOCTL_ARGS); 343e57b9183Scg149915 extern int radeon_cp_reset(DRM_IOCTL_ARGS); 344e57b9183Scg149915 extern int radeon_cp_idle(DRM_IOCTL_ARGS); 345e57b9183Scg149915 extern int radeon_cp_resume(DRM_IOCTL_ARGS); 346e57b9183Scg149915 extern int radeon_engine_reset(DRM_IOCTL_ARGS); 347e57b9183Scg149915 extern int radeon_fullscreen(DRM_IOCTL_ARGS); 348e57b9183Scg149915 extern int radeon_cp_buffers(DRM_IOCTL_ARGS); 349e57b9183Scg149915 350e57b9183Scg149915 extern void radeon_freelist_reset(drm_device_t *dev); 351e57b9183Scg149915 extern drm_buf_t *radeon_freelist_get(drm_device_t *dev); 352e57b9183Scg149915 353e57b9183Scg149915 extern int radeon_wait_ring(drm_radeon_private_t *dev_priv, int n); 354e57b9183Scg149915 355e57b9183Scg149915 extern int radeon_do_cp_idle(drm_radeon_private_t *dev_priv); 356e57b9183Scg149915 357e57b9183Scg149915 extern int radeon_mem_alloc(DRM_IOCTL_ARGS); 358e57b9183Scg149915 extern int radeon_mem_free(DRM_IOCTL_ARGS); 359e57b9183Scg149915 extern int radeon_mem_init_heap(DRM_IOCTL_ARGS); 360e57b9183Scg149915 extern void radeon_mem_takedown(struct mem_block **heap); 361e57b9183Scg149915 extern void radeon_mem_release(drm_file_t *filp, struct mem_block *heap); 362e57b9183Scg149915 363e57b9183Scg149915 /* radeon_irq.c */ 364e57b9183Scg149915 extern int radeon_irq_emit(DRM_IOCTL_ARGS); 365e57b9183Scg149915 extern int radeon_irq_wait(DRM_IOCTL_ARGS); 366e57b9183Scg149915 367e57b9183Scg149915 extern void radeon_do_release(drm_device_t *dev); 368e57b9183Scg149915 extern int radeon_driver_vblank_wait(drm_device_t *dev, 369e57b9183Scg149915 unsigned int *sequence); 370e57b9183Scg149915 extern int radeon_driver_vblank_wait2(drm_device_t *dev, 371e57b9183Scg149915 unsigned int *sequence); 372e57b9183Scg149915 extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS); 373*0f7bfed6Smiao chen - Sun Microsystems - Beijing China extern int radeon_driver_irq_preinstall(drm_device_t *dev); 374e57b9183Scg149915 extern void radeon_driver_irq_postinstall(drm_device_t *dev); 375e57b9183Scg149915 extern void radeon_driver_irq_uninstall(drm_device_t *dev); 376e57b9183Scg149915 extern int radeon_vblank_crtc_get(struct drm_device *dev); 377e57b9183Scg149915 extern int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value); 378e57b9183Scg149915 379e57b9183Scg149915 extern int radeon_driver_load(struct drm_device *dev, unsigned long flags); 380e57b9183Scg149915 extern int radeon_driver_unload(struct drm_device *dev); 381e57b9183Scg149915 extern int radeon_driver_firstopen(struct drm_device *dev); 382e57b9183Scg149915 extern void radeon_driver_preclose(drm_device_t *dev, drm_file_t *filp); 383e57b9183Scg149915 extern void radeon_driver_postclose(drm_device_t *dev, drm_file_t *filp); 384e57b9183Scg149915 extern void radeon_driver_lastclose(drm_device_t *dev); 385e57b9183Scg149915 extern int radeon_driver_open(drm_device_t *dev, drm_file_t *filp_priv); 386e57b9183Scg149915 extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd, 387e57b9183Scg149915 unsigned long arg); 388e57b9183Scg149915 389e57b9183Scg149915 /* r300_cmdbuf.c */ 390e57b9183Scg149915 extern void r300_init_reg_flags(void); 391e57b9183Scg149915 392e57b9183Scg149915 extern int r300_do_cp_cmdbuf(drm_device_t *dev, 393e57b9183Scg149915 drm_file_t *fpriv, drm_radeon_kcmd_buffer_t *cmdbuf); 394e57b9183Scg149915 395e57b9183Scg149915 /* Flags for stats.boxes */ 396e57b9183Scg149915 #define RADEON_BOX_DMA_IDLE 0x1 397e57b9183Scg149915 #define RADEON_BOX_RING_FULL 0x2 398e57b9183Scg149915 #define RADEON_BOX_FLIP 0x4 399e57b9183Scg149915 #define RADEON_BOX_WAIT_IDLE 0x8 400e57b9183Scg149915 #define RADEON_BOX_TEXTURE_LOAD 0x10 401e57b9183Scg149915 402e57b9183Scg149915 /* 403e57b9183Scg149915 * Register definitions, register access macros and drmAddMap constants 404e57b9183Scg149915 * for Radeon kernel driver. 405e57b9183Scg149915 */ 406e57b9183Scg149915 #define RADEON_AGP_COMMAND 0x0f60 407e57b9183Scg149915 #define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config */ 408e57b9183Scg149915 #define RADEON_AGP_ENABLE (1<<8) 409e57b9183Scg149915 #define RADEON_AUX_SCISSOR_CNTL 0x26f0 410e57b9183Scg149915 #define RADEON_EXCLUSIVE_SCISSOR_0 (1 << 24) 411e57b9183Scg149915 #define RADEON_EXCLUSIVE_SCISSOR_1 (1 << 25) 412e57b9183Scg149915 #define RADEON_EXCLUSIVE_SCISSOR_2 (1 << 26) 413e57b9183Scg149915 #define RADEON_SCISSOR_0_ENABLE (1 << 28) 414e57b9183Scg149915 #define RADEON_SCISSOR_1_ENABLE (1 << 29) 415e57b9183Scg149915 #define RADEON_SCISSOR_2_ENABLE (1 << 30) 416e57b9183Scg149915 417e57b9183Scg149915 #define RADEON_BUS_CNTL 0x0030 418e57b9183Scg149915 #define RADEON_BUS_MASTER_DIS (1 << 6) 419e57b9183Scg149915 420e57b9183Scg149915 #define RADEON_CLOCK_CNTL_DATA 0x000c 421e57b9183Scg149915 #define RADEON_PLL_WR_EN (1 << 7) 422e57b9183Scg149915 #define RADEON_CLOCK_CNTL_INDEX 0x0008 423e57b9183Scg149915 #define RADEON_CONFIG_APER_SIZE 0x0108 424e57b9183Scg149915 #define RADEON_CONFIG_MEMSIZE 0x00f8 425e57b9183Scg149915 #define RADEON_CRTC_OFFSET 0x0224 426e57b9183Scg149915 #define RADEON_CRTC_OFFSET_CNTL 0x0228 427e57b9183Scg149915 #define RADEON_CRTC_TILE_EN (1 << 15) 428e57b9183Scg149915 #define RADEON_CRTC_OFFSET_FLIP_CNTL (1 << 16) 429e57b9183Scg149915 #define RADEON_CRTC2_OFFSET 0x0324 430e57b9183Scg149915 #define RADEON_CRTC2_OFFSET_CNTL 0x0328 431e57b9183Scg149915 432e57b9183Scg149915 #define RADEON_PCIE_INDEX 0x0030 433e57b9183Scg149915 #define RADEON_PCIE_DATA 0x0034 434e57b9183Scg149915 #define RADEON_PCIE_TX_GART_CNTL 0x10 435e57b9183Scg149915 #define RADEON_PCIE_TX_GART_EN (1 << 0) 436e57b9183Scg149915 #define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_PASS_THRU (0<<1) 437e57b9183Scg149915 #define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_CLAMP_LO (1<<1) 438e57b9183Scg149915 #define RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD (3<<1) 439e57b9183Scg149915 #define RADEON_PCIE_TX_GART_MODE_32_128_CACHE (0<<3) 440e57b9183Scg149915 #define RADEON_PCIE_TX_GART_MODE_8_4_128_CACHE (1<<3) 441e57b9183Scg149915 #define RADEON_PCIE_TX_GART_CHK_RW_VALID_EN (1<<5) 442e57b9183Scg149915 #define RADEON_PCIE_TX_GART_INVALIDATE_TLB (1<<8) 443e57b9183Scg149915 #define RADEON_PCIE_TX_DISCARD_RD_ADDR_LO 0x11 444e57b9183Scg149915 #define RADEON_PCIE_TX_DISCARD_RD_ADDR_HI 0x12 445e57b9183Scg149915 #define RADEON_PCIE_TX_GART_BASE 0x13 446e57b9183Scg149915 #define RADEON_PCIE_TX_GART_START_LO 0x14 447e57b9183Scg149915 #define RADEON_PCIE_TX_GART_START_HI 0x15 448e57b9183Scg149915 #define RADEON_PCIE_TX_GART_END_LO 0x16 449e57b9183Scg149915 #define RADEON_PCIE_TX_GART_END_HI 0x17 450e57b9183Scg149915 451e57b9183Scg149915 #define RADEON_MPP_TB_CONFIG 0x01c0 452e57b9183Scg149915 #define RADEON_MEM_CNTL 0x0140 453e57b9183Scg149915 #define RADEON_MEM_SDRAM_MODE_REG 0x0158 454e57b9183Scg149915 #define RADEON_AGP_BASE 0x0170 455e57b9183Scg149915 456e57b9183Scg149915 #define RADEON_RB3D_COLOROFFSET 0x1c40 457e57b9183Scg149915 #define RADEON_RB3D_COLORPITCH 0x1c48 458e57b9183Scg149915 459e57b9183Scg149915 #define RADEON_SRC_X_Y 0x1590 460e57b9183Scg149915 461e57b9183Scg149915 #define RADEON_DP_GUI_MASTER_CNTL 0x146c 462e57b9183Scg149915 #define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) 463e57b9183Scg149915 #define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) 464e57b9183Scg149915 #define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4) 465e57b9183Scg149915 #define RADEON_GMC_BRUSH_NONE (15 << 4) 466e57b9183Scg149915 #define RADEON_GMC_DST_16BPP (4 << 8) 467e57b9183Scg149915 #define RADEON_GMC_DST_24BPP (5 << 8) 468e57b9183Scg149915 #define RADEON_GMC_DST_32BPP (6 << 8) 469e57b9183Scg149915 #define RADEON_GMC_DST_DATATYPE_SHIFT 8 470e57b9183Scg149915 #define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12) 471e57b9183Scg149915 #define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24) 472e57b9183Scg149915 #define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24) 473e57b9183Scg149915 #define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28) 474e57b9183Scg149915 #define RADEON_GMC_WR_MSK_DIS (1 << 30) 475e57b9183Scg149915 #define RADEON_ROP3_S 0x00cc0000 476e57b9183Scg149915 #define RADEON_ROP3_P 0x00f00000 477e57b9183Scg149915 #define RADEON_DP_WRITE_MASK 0x16cc 478e57b9183Scg149915 #define RADEON_SRC_PITCH_OFFSET 0x1428 479e57b9183Scg149915 #define RADEON_DST_PITCH_OFFSET 0x142c 480e57b9183Scg149915 #define RADEON_DST_PITCH_OFFSET_C 0x1c80 481e57b9183Scg149915 #define RADEON_DST_TILE_LINEAR (0 << 30) 482e57b9183Scg149915 #define RADEON_DST_TILE_MACRO (1 << 30) 483e57b9183Scg149915 #define RADEON_DST_TILE_MICRO ((uint_t)2 << 30) 484e57b9183Scg149915 #define RADEON_DST_TILE_BOTH ((uint_t)3 << 30) 485e57b9183Scg149915 486e57b9183Scg149915 #define RADEON_SCRATCH_REG0 0x15e0 487e57b9183Scg149915 #define RADEON_SCRATCH_REG1 0x15e4 488e57b9183Scg149915 #define RADEON_SCRATCH_REG2 0x15e8 489e57b9183Scg149915 #define RADEON_SCRATCH_REG3 0x15ec 490e57b9183Scg149915 #define RADEON_SCRATCH_REG4 0x15f0 491e57b9183Scg149915 #define RADEON_SCRATCH_REG5 0x15f4 492e57b9183Scg149915 #define RADEON_SCRATCH_UMSK 0x0770 493e57b9183Scg149915 #define RADEON_SCRATCH_ADDR 0x0774 494e57b9183Scg149915 495e57b9183Scg149915 #define RADEON_SCRATCHOFF(x) (RADEON_SCRATCH_REG_OFFSET + 4*(x)) 496e57b9183Scg149915 497e57b9183Scg149915 #define GET_SCRATCH(x) (dev_priv->writeback_works ? \ 498e57b9183Scg149915 DRM_READ32(dev_priv->ring_rptr, RADEON_SCRATCHOFF(x)) : \ 499e57b9183Scg149915 RADEON_READ(RADEON_SCRATCH_REG0 + 4*(x))) 500e57b9183Scg149915 501e57b9183Scg149915 #define RADEON_GEN_INT_CNTL 0x0040 502e57b9183Scg149915 #define RADEON_CRTC_VBLANK_MASK (1 << 0) 503e57b9183Scg149915 #define RADEON_CRTC2_VBLANK_MASK (1 << 9) 504e57b9183Scg149915 #define RADEON_GUI_IDLE_INT_ENABLE (1 << 19) 505e57b9183Scg149915 #define RADEON_SW_INT_ENABLE (1 << 25) 506e57b9183Scg149915 507e57b9183Scg149915 #define RADEON_GEN_INT_STATUS 0x0044 508e57b9183Scg149915 #define RADEON_CRTC_VBLANK_STAT (1 << 0) 509e57b9183Scg149915 #define RADEON_CRTC_VBLANK_STAT_ACK (1 << 0) 510e57b9183Scg149915 #define RADEON_CRTC2_VBLANK_STAT (1 << 9) 511e57b9183Scg149915 #define RADEON_CRTC2_VBLANK_STAT_ACK (1 << 9) 512e57b9183Scg149915 #define RADEON_GUI_IDLE_INT_TEST_ACK (1 << 19) 513e57b9183Scg149915 #define RADEON_SW_INT_TEST (1 << 25) 514e57b9183Scg149915 #define RADEON_SW_INT_TEST_ACK (1 << 25) 515e57b9183Scg149915 #define RADEON_SW_INT_FIRE (1 << 26) 516e57b9183Scg149915 517e57b9183Scg149915 #define RADEON_HOST_PATH_CNTL 0x0130 518e57b9183Scg149915 #define RADEON_HDP_SOFT_RESET (1 << 26) 519e57b9183Scg149915 #define RADEON_HDP_WC_TIMEOUT_MASK (7 << 28) 520e57b9183Scg149915 #define RADEON_HDP_WC_TIMEOUT_28BCLK (7 << 28) 521e57b9183Scg149915 522e57b9183Scg149915 #define RADEON_ISYNC_CNTL 0x1724 523e57b9183Scg149915 #define RADEON_ISYNC_ANY2D_IDLE3D (1 << 0) 524e57b9183Scg149915 #define RADEON_ISYNC_ANY3D_IDLE2D (1 << 1) 525e57b9183Scg149915 #define RADEON_ISYNC_TRIG2D_IDLE3D (1 << 2) 526e57b9183Scg149915 #define RADEON_ISYNC_TRIG3D_IDLE2D (1 << 3) 527e57b9183Scg149915 #define RADEON_ISYNC_WAIT_IDLEGUI (1 << 4) 528e57b9183Scg149915 #define RADEON_ISYNC_CPSCRATCH_IDLEGUI (1 << 5) 529e57b9183Scg149915 530e57b9183Scg149915 #define RADEON_RBBM_GUICNTL 0x172c 531e57b9183Scg149915 #define RADEON_HOST_DATA_SWAP_NONE (0 << 0) 532e57b9183Scg149915 #define RADEON_HOST_DATA_SWAP_16BIT (1 << 0) 533e57b9183Scg149915 #define RADEON_HOST_DATA_SWAP_32BIT (2 << 0) 534e57b9183Scg149915 #define RADEON_HOST_DATA_SWAP_HDW (3 << 0) 535e57b9183Scg149915 536e57b9183Scg149915 #define RADEON_MC_AGP_LOCATION 0x014c 537e57b9183Scg149915 #define RADEON_MC_FB_LOCATION 0x0148 538e57b9183Scg149915 #define RADEON_MCLK_CNTL 0x0012 539e57b9183Scg149915 #define RADEON_FORCEON_MCLKA (1 << 16) 540e57b9183Scg149915 #define RADEON_FORCEON_MCLKB (1 << 17) 541e57b9183Scg149915 #define RADEON_FORCEON_YCLKA (1 << 18) 542e57b9183Scg149915 #define RADEON_FORCEON_YCLKB (1 << 19) 543e57b9183Scg149915 #define RADEON_FORCEON_MC (1 << 20) 544e57b9183Scg149915 #define RADEON_FORCEON_AIC (1 << 21) 545e57b9183Scg149915 546e57b9183Scg149915 #define RADEON_PP_BORDER_COLOR_0 0x1d40 547e57b9183Scg149915 #define RADEON_PP_BORDER_COLOR_1 0x1d44 548e57b9183Scg149915 #define RADEON_PP_BORDER_COLOR_2 0x1d48 549e57b9183Scg149915 #define RADEON_PP_CNTL 0x1c38 550e57b9183Scg149915 #define RADEON_SCISSOR_ENABLE (1 << 1) 551e57b9183Scg149915 #define RADEON_PP_LUM_MATRIX 0x1d00 552e57b9183Scg149915 #define RADEON_PP_MISC 0x1c14 553e57b9183Scg149915 #define RADEON_PP_ROT_MATRIX_0 0x1d58 554e57b9183Scg149915 #define RADEON_PP_TXFILTER_0 0x1c54 555e57b9183Scg149915 #define RADEON_PP_TXOFFSET_0 0x1c5c 556e57b9183Scg149915 #define RADEON_PP_TXFILTER_1 0x1c6c 557e57b9183Scg149915 #define RADEON_PP_TXFILTER_2 0x1c84 558e57b9183Scg149915 559e57b9183Scg149915 #define RADEON_RB2D_DSTCACHE_CTLSTAT 0x342c 560e57b9183Scg149915 #define RADEON_RB2D_DC_FLUSH (3 << 0) 561e57b9183Scg149915 #define RADEON_RB2D_DC_FREE (3 << 2) 562e57b9183Scg149915 #define RADEON_RB2D_DC_FLUSH_ALL 0xf 563e57b9183Scg149915 #define RADEON_RB2D_DC_BUSY 0x80000000 564e57b9183Scg149915 #define RADEON_RB3D_CNTL 0x1c3c 565e57b9183Scg149915 #define RADEON_ALPHA_BLEND_ENABLE (1 << 0) 566e57b9183Scg149915 #define RADEON_PLANE_MASK_ENABLE (1 << 1) 567e57b9183Scg149915 #define RADEON_DITHER_ENABLE (1 << 2) 568e57b9183Scg149915 #define RADEON_ROUND_ENABLE (1 << 3) 569e57b9183Scg149915 #define RADEON_SCALE_DITHER_ENABLE (1 << 4) 570e57b9183Scg149915 #define RADEON_DITHER_INIT (1 << 5) 571e57b9183Scg149915 #define RADEON_ROP_ENABLE (1 << 6) 572e57b9183Scg149915 #define RADEON_STENCIL_ENABLE (1 << 7) 573e57b9183Scg149915 #define RADEON_Z_ENABLE (1 << 8) 574e57b9183Scg149915 #define RADEON_ZBLOCK16 (1 << 15) 575e57b9183Scg149915 #define RADEON_RB3D_DEPTHOFFSET 0x1c24 576e57b9183Scg149915 #define RADEON_RB3D_DEPTHCLEARVALUE 0x3230 577e57b9183Scg149915 #define RADEON_RB3D_DEPTHPITCH 0x1c28 578e57b9183Scg149915 #define RADEON_RB3D_PLANEMASK 0x1d84 579e57b9183Scg149915 #define RADEON_RB3D_STENCILREFMASK 0x1d7c 580e57b9183Scg149915 #define RADEON_RB3D_ZCACHE_MODE 0x3250 581e57b9183Scg149915 #define RADEON_RB3D_ZCACHE_CTLSTAT 0x3254 582e57b9183Scg149915 #define RADEON_RB3D_ZC_FLUSH (1 << 0) 583e57b9183Scg149915 #define RADEON_RB3D_ZC_FREE (1 << 2) 584e57b9183Scg149915 #define RADEON_RB3D_ZC_FLUSH_ALL 0x5 585e57b9183Scg149915 #define RADEON_RB3D_ZC_BUSY 0x80000000UL 586e57b9183Scg149915 #define RADEON_RB3D_DSTCACHE_CTLSTAT 0x325c 587e57b9183Scg149915 #define RADEON_RB3D_DC_FLUSH (3 << 0) 588e57b9183Scg149915 #define RADEON_RB3D_DC_FREE (3 << 2) 589e57b9183Scg149915 #define RADEON_RB3D_DC_FLUSH_ALL 0xf 590e57b9183Scg149915 #define RADEON_RB3D_DC_BUSY 0x80000000UL 591e57b9183Scg149915 #define RADEON_RB3D_ZSTENCILCNTL 0x1c2c 592e57b9183Scg149915 #define RADEON_Z_TEST_MASK (7 << 4) 593e57b9183Scg149915 #define RADEON_Z_TEST_ALWAYS (7 << 4) 594e57b9183Scg149915 #define RADEON_Z_HIERARCHY_ENABLE (1 << 8) 595e57b9183Scg149915 #define RADEON_STENCIL_TEST_ALWAYS (7 << 12) 596e57b9183Scg149915 #define RADEON_STENCIL_S_FAIL_REPLACE (2 << 16) 597e57b9183Scg149915 #define RADEON_STENCIL_ZPASS_REPLACE (2 << 20) 598e57b9183Scg149915 #define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24) 599e57b9183Scg149915 #define RADEON_Z_COMPRESSION_ENABLE (1 << 28) 600e57b9183Scg149915 #define RADEON_FORCE_Z_DIRTY (1 << 29) 601e57b9183Scg149915 #define RADEON_Z_WRITE_ENABLE (1 << 30) 602e57b9183Scg149915 #define RADEON_Z_DECOMPRESSION_ENABLE 0x80000000UL 603e57b9183Scg149915 #define RADEON_RBBM_SOFT_RESET 0x00f0 604e57b9183Scg149915 #define RADEON_SOFT_RESET_CP (1 << 0) 605e57b9183Scg149915 #define RADEON_SOFT_RESET_HI (1 << 1) 606e57b9183Scg149915 #define RADEON_SOFT_RESET_SE (1 << 2) 607e57b9183Scg149915 #define RADEON_SOFT_RESET_RE (1 << 3) 608e57b9183Scg149915 #define RADEON_SOFT_RESET_PP (1 << 4) 609e57b9183Scg149915 #define RADEON_SOFT_RESET_E2 (1 << 5) 610e57b9183Scg149915 #define RADEON_SOFT_RESET_RB (1 << 6) 611e57b9183Scg149915 #define RADEON_SOFT_RESET_HDP (1 << 7) 612e57b9183Scg149915 #define RADEON_RBBM_STATUS 0x0e40 613e57b9183Scg149915 #define RADEON_RBBM_FIFOCNT_MASK 0x007f 614e57b9183Scg149915 #define RADEON_RBBM_ACTIVE 0X80000000UL 615e57b9183Scg149915 #define RADEON_RE_LINE_PATTERN 0x1cd0 616e57b9183Scg149915 #define RADEON_RE_MISC 0x26c4 617e57b9183Scg149915 #define RADEON_RE_TOP_LEFT 0x26c0 618e57b9183Scg149915 #define RADEON_RE_WIDTH_HEIGHT 0x1c44 619e57b9183Scg149915 #define RADEON_RE_STIPPLE_ADDR 0x1cc8 620e57b9183Scg149915 #define RADEON_RE_STIPPLE_DATA 0x1ccc 621e57b9183Scg149915 622e57b9183Scg149915 #define RADEON_SCISSOR_TL_0 0x1cd8 623e57b9183Scg149915 #define RADEON_SCISSOR_BR_0 0x1cdc 624e57b9183Scg149915 #define RADEON_SCISSOR_TL_1 0x1ce0 625e57b9183Scg149915 #define RADEON_SCISSOR_BR_1 0x1ce4 626e57b9183Scg149915 #define RADEON_SCISSOR_TL_2 0x1ce8 627e57b9183Scg149915 #define RADEON_SCISSOR_BR_2 0x1cec 628e57b9183Scg149915 #define RADEON_SE_COORD_FMT 0x1c50 629e57b9183Scg149915 #define RADEON_SE_CNTL 0x1c4c 630e57b9183Scg149915 #define RADEON_FFACE_CULL_CW (0 << 0) 631e57b9183Scg149915 #define RADEON_BFACE_SOLID (3 << 1) 632e57b9183Scg149915 #define RADEON_FFACE_SOLID (3 << 3) 633e57b9183Scg149915 #define RADEON_FLAT_SHADE_VTX_LAST (3 << 6) 634e57b9183Scg149915 #define RADEON_DIFFUSE_SHADE_FLAT (1 << 8) 635e57b9183Scg149915 #define RADEON_DIFFUSE_SHADE_GOURAUD (2 << 8) 636e57b9183Scg149915 #define RADEON_ALPHA_SHADE_FLAT (1 << 10) 637e57b9183Scg149915 #define RADEON_ALPHA_SHADE_GOURAUD (2 << 10) 638e57b9183Scg149915 #define RADEON_SPECULAR_SHADE_FLAT (1 << 12) 639e57b9183Scg149915 #define RADEON_SPECULAR_SHADE_GOURAUD (2 << 12) 640e57b9183Scg149915 #define RADEON_FOG_SHADE_FLAT (1 << 14) 641e57b9183Scg149915 #define RADEON_FOG_SHADE_GOURAUD (2 << 14) 642e57b9183Scg149915 #define RADEON_VPORT_XY_XFORM_ENABLE (1 << 24) 643e57b9183Scg149915 #define RADEON_VPORT_Z_XFORM_ENABLE (1 << 25) 644e57b9183Scg149915 #define RADEON_VTX_PIX_CENTER_OGL (1 << 27) 645e57b9183Scg149915 #define RADEON_ROUND_MODE_TRUNC (0 << 28) 646e57b9183Scg149915 #define RADEON_ROUND_PREC_8TH_PIX (1 << 30) 647e57b9183Scg149915 #define RADEON_SE_CNTL_STATUS 0x2140 648e57b9183Scg149915 #define RADEON_SE_LINE_WIDTH 0x1db8 649e57b9183Scg149915 #define RADEON_SE_VPORT_XSCALE 0x1d98 650e57b9183Scg149915 #define RADEON_SE_ZBIAS_FACTOR 0x1db0 651e57b9183Scg149915 #define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210 652e57b9183Scg149915 #define RADEON_SE_TCL_OUTPUT_VTX_FMT 0x2254 653e57b9183Scg149915 #define RADEON_SE_TCL_VECTOR_INDX_REG 0x2200 654e57b9183Scg149915 #define RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT 16 655e57b9183Scg149915 #define RADEON_VEC_INDX_DWORD_COUNT_SHIFT 28 656e57b9183Scg149915 #define RADEON_SE_TCL_VECTOR_DATA_REG 0x2204 657e57b9183Scg149915 #define RADEON_SE_TCL_SCALAR_INDX_REG 0x2208 658e57b9183Scg149915 #define RADEON_SCAL_INDX_DWORD_STRIDE_SHIFT 16 659e57b9183Scg149915 #define RADEON_SE_TCL_SCALAR_DATA_REG 0x220C 660e57b9183Scg149915 #define RADEON_SURFACE_ACCESS_FLAGS 0x0bf8 661e57b9183Scg149915 #define RADEON_SURFACE_ACCESS_CLR 0x0bfc 662e57b9183Scg149915 #define RADEON_SURFACE_CNTL 0x0b00 663e57b9183Scg149915 #define RADEON_SURF_TRANSLATION_DIS (1 << 8) 664e57b9183Scg149915 #define RADEON_NONSURF_AP0_SWP_MASK (3 << 20) 665e57b9183Scg149915 #define RADEON_NONSURF_AP0_SWP_LITTLE (0 << 20) 666e57b9183Scg149915 #define RADEON_NONSURF_AP0_SWP_BIG16 (1 << 20) 667e57b9183Scg149915 #define RADEON_NONSURF_AP0_SWP_BIG32 (2 << 20) 668e57b9183Scg149915 #define RADEON_NONSURF_AP1_SWP_MASK (3 << 22) 669e57b9183Scg149915 #define RADEON_NONSURF_AP1_SWP_LITTLE (0 << 22) 670e57b9183Scg149915 #define RADEON_NONSURF_AP1_SWP_BIG16 (1 << 22) 671e57b9183Scg149915 #define RADEON_NONSURF_AP1_SWP_BIG32 (2 << 22) 672e57b9183Scg149915 #define RADEON_SURFACE0_INFO 0x0b0c 673e57b9183Scg149915 #define RADEON_SURF_PITCHSEL_MASK (0x1ff << 0) 674e57b9183Scg149915 #define RADEON_SURF_TILE_MODE_MASK (3 << 16) 675e57b9183Scg149915 #define RADEON_SURF_TILE_MODE_MACRO (0 << 16) 676e57b9183Scg149915 #define RADEON_SURF_TILE_MODE_MICRO (1 << 16) 677e57b9183Scg149915 #define RADEON_SURF_TILE_MODE_32BIT_Z (2 << 16) 678e57b9183Scg149915 #define RADEON_SURF_TILE_MODE_16BIT_Z (3 << 16) 679e57b9183Scg149915 #define RADEON_SURFACE0_LOWER_BOUND 0x0b04 680e57b9183Scg149915 #define RADEON_SURFACE0_UPPER_BOUND 0x0b08 681e57b9183Scg149915 #define RADEON_SURF_ADDRESS_FIXED_MASK (0x3ff << 0) 682e57b9183Scg149915 #define RADEON_SURFACE1_INFO 0x0b1c 683e57b9183Scg149915 #define RADEON_SURFACE1_LOWER_BOUND 0x0b14 684e57b9183Scg149915 #define RADEON_SURFACE1_UPPER_BOUND 0x0b18 685e57b9183Scg149915 #define RADEON_SURFACE2_INFO 0x0b2c 686e57b9183Scg149915 #define RADEON_SURFACE2_LOWER_BOUND 0x0b24 687e57b9183Scg149915 #define RADEON_SURFACE2_UPPER_BOUND 0x0b28 688e57b9183Scg149915 #define RADEON_SURFACE3_INFO 0x0b3c 689e57b9183Scg149915 #define RADEON_SURFACE3_LOWER_BOUND 0x0b34 690e57b9183Scg149915 #define RADEON_SURFACE3_UPPER_BOUND 0x0b38 691e57b9183Scg149915 #define RADEON_SURFACE4_INFO 0x0b4c 692e57b9183Scg149915 #define RADEON_SURFACE4_LOWER_BOUND 0x0b44 693e57b9183Scg149915 #define RADEON_SURFACE4_UPPER_BOUND 0x0b48 694e57b9183Scg149915 #define RADEON_SURFACE5_INFO 0x0b5c 695e57b9183Scg149915 #define RADEON_SURFACE5_LOWER_BOUND 0x0b54 696e57b9183Scg149915 #define RADEON_SURFACE5_UPPER_BOUND 0x0b58 697e57b9183Scg149915 #define RADEON_SURFACE6_INFO 0x0b6c 698e57b9183Scg149915 #define RADEON_SURFACE6_LOWER_BOUND 0x0b64 699e57b9183Scg149915 #define RADEON_SURFACE6_UPPER_BOUND 0x0b68 700e57b9183Scg149915 #define RADEON_SURFACE7_INFO 0x0b7c 701e57b9183Scg149915 #define RADEON_SURFACE7_LOWER_BOUND 0x0b74 702e57b9183Scg149915 #define RADEON_SURFACE7_UPPER_BOUND 0x0b78 703e57b9183Scg149915 #define RADEON_SW_SEMAPHORE 0x013c 704e57b9183Scg149915 705e57b9183Scg149915 #define RADEON_WAIT_UNTIL 0x1720 706e57b9183Scg149915 #define RADEON_WAIT_CRTC_PFLIP (1 << 0) 707e57b9183Scg149915 #define RADEON_WAIT_2D_IDLE (1 << 14) 708e57b9183Scg149915 #define RADEON_WAIT_3D_IDLE (1 << 15) 709e57b9183Scg149915 #define RADEON_WAIT_2D_IDLECLEAN (1 << 16) 710e57b9183Scg149915 #define RADEON_WAIT_3D_IDLECLEAN (1 << 17) 711e57b9183Scg149915 #define RADEON_WAIT_HOST_IDLECLEAN (1 << 18) 712e57b9183Scg149915 713e57b9183Scg149915 #define RADEON_RB3D_ZMASKOFFSET 0x3234 714e57b9183Scg149915 #define RADEON_RB3D_ZSTENCILCNTL 0x1c2c 715e57b9183Scg149915 #define RADEON_DEPTH_FORMAT_16BIT_INT_Z (0 << 0) 716e57b9183Scg149915 #define RADEON_DEPTH_FORMAT_24BIT_INT_Z (2 << 0) 717e57b9183Scg149915 718e57b9183Scg149915 /* CP registers */ 719e57b9183Scg149915 #define RADEON_CP_ME_RAM_ADDR 0x07d4 720e57b9183Scg149915 #define RADEON_CP_ME_RAM_RADDR 0x07d8 721e57b9183Scg149915 #define RADEON_CP_ME_RAM_DATAH 0x07dc 722e57b9183Scg149915 #define RADEON_CP_ME_RAM_DATAL 0x07e0 723e57b9183Scg149915 724e57b9183Scg149915 #define RADEON_CP_RB_BASE 0x0700 725e57b9183Scg149915 #define RADEON_CP_RB_CNTL 0x0704 726e57b9183Scg149915 #define RADEON_BUF_SWAP_32BIT (2 << 16) 727e57b9183Scg149915 #define RADEON_RB_NO_UPDATE (1 << 27) 728e57b9183Scg149915 729e57b9183Scg149915 #define RADEON_CP_RB_RPTR_ADDR 0x070c 730e57b9183Scg149915 #define RADEON_CP_RB_RPTR 0x0710 731e57b9183Scg149915 #define RADEON_CP_RB_WPTR 0x0714 732e57b9183Scg149915 733e57b9183Scg149915 #define RADEON_CP_RB_WPTR_DELAY 0x0718 734e57b9183Scg149915 #define RADEON_PRE_WRITE_TIMER_SHIFT 0 735e57b9183Scg149915 #define RADEON_PRE_WRITE_LIMIT_SHIFT 23 736e57b9183Scg149915 737e57b9183Scg149915 #define RADEON_CP_IB_BASE 0x0738 738e57b9183Scg149915 739e57b9183Scg149915 #define RADEON_CP_CSQ_CNTL 0x0740 740e57b9183Scg149915 #define RADEON_CSQ_CNT_PRIMARY_MASK (0xff << 0) 741e57b9183Scg149915 #define RADEON_CSQ_PRIDIS_INDDIS (0 << 28) 742e57b9183Scg149915 #define RADEON_CSQ_PRIPIO_INDDIS (1 << 28) 743e57b9183Scg149915 #define RADEON_CSQ_PRIBM_INDDIS (2 << 28) 744e57b9183Scg149915 #define RADEON_CSQ_PRIPIO_INDBM (3 << 28) 745e57b9183Scg149915 #define RADEON_CSQ_PRIBM_INDBM (4 << 28) 746e57b9183Scg149915 #define RADEON_CSQ_PRIPIO_INDPIO (15 << 28) 747e57b9183Scg149915 748e57b9183Scg149915 #define RADEON_AIC_CNTL 0x01d0 749e57b9183Scg149915 #define RADEON_PCIGART_TRANSLATE_EN (1 << 0) 750e57b9183Scg149915 #define RADEON_AIC_STAT 0x01d4 751e57b9183Scg149915 #define RADEON_AIC_PT_BASE 0x01d8 752e57b9183Scg149915 #define RADEON_AIC_LO_ADDR 0x01dc 753e57b9183Scg149915 #define RADEON_AIC_HI_ADDR 0x01e0 754e57b9183Scg149915 #define RADEON_AIC_TLB_ADDR 0x01e4 755e57b9183Scg149915 #define RADEON_AIC_TLB_DATA 0x01e8 756e57b9183Scg149915 757e57b9183Scg149915 /* CP command packets */ 758e57b9183Scg149915 #define RADEON_CP_PACKET0 0x00000000 759e57b9183Scg149915 #define RADEON_ONE_REG_WR (1 << 15) 760e57b9183Scg149915 #define RADEON_CP_PACKET1 0x40000000 761e57b9183Scg149915 #define RADEON_CP_PACKET2 0x80000000 762e57b9183Scg149915 #define RADEON_CP_PACKET3 0xC0000000 763e57b9183Scg149915 #define RADEON_CP_NOP 0x00001000 764e57b9183Scg149915 #define RADEON_CP_NEXT_CHAR 0x00001900 765e57b9183Scg149915 #define RADEON_CP_PLY_NEXTSCAN 0x00001D00 766e57b9183Scg149915 #define RADEON_CP_SET_SCISSORS 0x00001E00 767e57b9183Scg149915 768e57b9183Scg149915 /* GEN_INDX_PRIM is unsupported starting with R300 */ 769e57b9183Scg149915 #define RADEON_3D_RNDR_GEN_INDX_PRIM 0x00002300 770e57b9183Scg149915 #define RADEON_WAIT_FOR_IDLE 0x00002600 771e57b9183Scg149915 #define RADEON_3D_DRAW_VBUF 0x00002800 772e57b9183Scg149915 #define RADEON_3D_DRAW_IMMD 0x00002900 773e57b9183Scg149915 #define RADEON_3D_DRAW_INDX 0x00002A00 774e57b9183Scg149915 #define RADEON_CP_LOAD_PALETTE 0x00002C00 775e57b9183Scg149915 #define RADEON_3D_LOAD_VBPNTR 0x00002F00 776e57b9183Scg149915 #define RADEON_MPEG_IDCT_MACROBLOCK 0x00003000 777e57b9183Scg149915 #define RADEON_MPEG_IDCT_MACROBLOCK_REV 0x00003100 778e57b9183Scg149915 #define RADEON_3D_CLEAR_ZMASK 0x00003200 779e57b9183Scg149915 #define RADEON_CP_INDX_BUFFER 0x00003300 780e57b9183Scg149915 #define RADEON_CP_3D_DRAW_VBUF_2 0x00003400 781e57b9183Scg149915 #define RADEON_CP_3D_DRAW_IMMD_2 0x00003500 782e57b9183Scg149915 #define RADEON_CP_3D_DRAW_INDX_2 0x00003600 783e57b9183Scg149915 #define RADEON_3D_CLEAR_HIZ 0x00003700 784e57b9183Scg149915 #define RADEON_CP_3D_CLEAR_CMASK 0x00003802 785e57b9183Scg149915 #define RADEON_CNTL_HOSTDATA_BLT 0x00009400 786e57b9183Scg149915 #define RADEON_CNTL_PAINT_MULTI 0x00009A00 787e57b9183Scg149915 #define RADEON_CNTL_BITBLT_MULTI 0x00009B00 788e57b9183Scg149915 #define RADEON_CNTL_SET_SCISSORS 0xC0001E00 789e57b9183Scg149915 790e57b9183Scg149915 #define RADEON_CP_PACKET_MASK 0xC0000000 791e57b9183Scg149915 #define RADEON_CP_PACKET_COUNT_MASK 0x3fff0000 792e57b9183Scg149915 #define RADEON_CP_PACKET0_REG_MASK 0x000007ff 793e57b9183Scg149915 #define RADEON_CP_PACKET1_REG0_MASK 0x000007ff 794e57b9183Scg149915 #define RADEON_CP_PACKET1_REG1_MASK 0x003ff800 795e57b9183Scg149915 796e57b9183Scg149915 #define RADEON_VTX_Z_PRESENT 0x80000000 797e57b9183Scg149915 #define RADEON_VTX_PKCOLOR_PRESENT (1 << 3) 798e57b9183Scg149915 799e57b9183Scg149915 #define RADEON_PRIM_TYPE_NONE (0 << 0) 800e57b9183Scg149915 #define RADEON_PRIM_TYPE_POINT (1 << 0) 801e57b9183Scg149915 #define RADEON_PRIM_TYPE_LINE (2 << 0) 802e57b9183Scg149915 #define RADEON_PRIM_TYPE_LINE_STRIP (3 << 0) 803e57b9183Scg149915 #define RADEON_PRIM_TYPE_TRI_LIST (4 << 0) 804e57b9183Scg149915 #define RADEON_PRIM_TYPE_TRI_FAN (5 << 0) 805e57b9183Scg149915 #define RADEON_PRIM_TYPE_TRI_STRIP (6 << 0) 806e57b9183Scg149915 #define RADEON_PRIM_TYPE_TRI_TYPE2 (7 << 0) 807e57b9183Scg149915 #define RADEON_PRIM_TYPE_RECT_LIST (8 << 0) 808e57b9183Scg149915 #define RADEON_PRIM_TYPE_3VRT_POINT_LIST (9 << 0) 809e57b9183Scg149915 #define RADEON_PRIM_TYPE_3VRT_LINE_LIST (10 << 0) 810e57b9183Scg149915 #define RADEON_PRIM_TYPE_MASK 0xf 811e57b9183Scg149915 #define RADEON_PRIM_WALK_IND (1 << 4) 812e57b9183Scg149915 #define RADEON_PRIM_WALK_LIST (2 << 4) 813e57b9183Scg149915 #define RADEON_PRIM_WALK_RING (3 << 4) 814e57b9183Scg149915 #define RADEON_COLOR_ORDER_BGRA (0 << 6) 815e57b9183Scg149915 #define RADEON_COLOR_ORDER_RGBA (1 << 6) 816e57b9183Scg149915 #define RADEON_MAOS_ENABLE (1 << 7) 817e57b9183Scg149915 #define RADEON_VTX_FMT_R128_MODE (0 << 8) 818e57b9183Scg149915 #define RADEON_VTX_FMT_RADEON_MODE (1 << 8) 819e57b9183Scg149915 #define RADEON_NUM_VERTICES_SHIFT 16 820e57b9183Scg149915 821e57b9183Scg149915 #define RADEON_COLOR_FORMAT_CI8 2 822e57b9183Scg149915 #define RADEON_COLOR_FORMAT_ARGB1555 3 823e57b9183Scg149915 #define RADEON_COLOR_FORMAT_RGB565 4 824e57b9183Scg149915 #define RADEON_COLOR_FORMAT_ARGB8888 6 825e57b9183Scg149915 #define RADEON_COLOR_FORMAT_RGB332 7 826e57b9183Scg149915 #define RADEON_COLOR_FORMAT_RGB8 9 827e57b9183Scg149915 #define RADEON_COLOR_FORMAT_ARGB4444 15 828e57b9183Scg149915 829e57b9183Scg149915 #define RADEON_TXFORMAT_I8 0 830e57b9183Scg149915 #define RADEON_TXFORMAT_AI88 1 831e57b9183Scg149915 #define RADEON_TXFORMAT_RGB332 2 832e57b9183Scg149915 #define RADEON_TXFORMAT_ARGB1555 3 833e57b9183Scg149915 #define RADEON_TXFORMAT_RGB565 4 834e57b9183Scg149915 #define RADEON_TXFORMAT_ARGB4444 5 835e57b9183Scg149915 #define RADEON_TXFORMAT_ARGB8888 6 836e57b9183Scg149915 #define RADEON_TXFORMAT_RGBA8888 7 837e57b9183Scg149915 #define RADEON_TXFORMAT_Y8 8 838e57b9183Scg149915 #define RADEON_TXFORMAT_VYUY422 10 839e57b9183Scg149915 #define RADEON_TXFORMAT_YVYU422 11 840e57b9183Scg149915 #define RADEON_TXFORMAT_DXT1 12 841e57b9183Scg149915 #define RADEON_TXFORMAT_DXT23 14 842e57b9183Scg149915 #define RADEON_TXFORMAT_DXT45 15 843e57b9183Scg149915 844e57b9183Scg149915 #define R200_PP_TXCBLEND_0 0x2f00 845e57b9183Scg149915 #define R200_PP_TXCBLEND_1 0x2f10 846e57b9183Scg149915 #define R200_PP_TXCBLEND_2 0x2f20 847e57b9183Scg149915 #define R200_PP_TXCBLEND_3 0x2f30 848e57b9183Scg149915 #define R200_PP_TXCBLEND_4 0x2f40 849e57b9183Scg149915 #define R200_PP_TXCBLEND_5 0x2f50 850e57b9183Scg149915 #define R200_PP_TXCBLEND_6 0x2f60 851e57b9183Scg149915 #define R200_PP_TXCBLEND_7 0x2f70 852e57b9183Scg149915 #define R200_SE_TCL_LIGHT_MODEL_CTL_0 0x2268 853e57b9183Scg149915 #define R200_PP_TFACTOR_0 0x2ee0 854e57b9183Scg149915 #define R200_SE_VTX_FMT_0 0x2088 855e57b9183Scg149915 #define R200_SE_VAP_CNTL 0x2080 856e57b9183Scg149915 #define R200_SE_TCL_MATRIX_SEL_0 0x2230 857e57b9183Scg149915 #define R200_SE_TCL_TEX_PROC_CTL_2 0x22a8 858e57b9183Scg149915 #define R200_SE_TCL_UCP_VERT_BLEND_CTL 0x22c0 859e57b9183Scg149915 #define R200_PP_TXFILTER_5 0x2ca0 860e57b9183Scg149915 #define R200_PP_TXFILTER_4 0x2c80 861e57b9183Scg149915 #define R200_PP_TXFILTER_3 0x2c60 862e57b9183Scg149915 #define R200_PP_TXFILTER_2 0x2c40 863e57b9183Scg149915 #define R200_PP_TXFILTER_1 0x2c20 864e57b9183Scg149915 #define R200_PP_TXFILTER_0 0x2c00 865e57b9183Scg149915 #define R200_PP_TXOFFSET_5 0x2d78 866e57b9183Scg149915 #define R200_PP_TXOFFSET_4 0x2d60 867e57b9183Scg149915 #define R200_PP_TXOFFSET_3 0x2d48 868e57b9183Scg149915 #define R200_PP_TXOFFSET_2 0x2d30 869e57b9183Scg149915 #define R200_PP_TXOFFSET_1 0x2d18 870e57b9183Scg149915 #define R200_PP_TXOFFSET_0 0x2d00 871e57b9183Scg149915 872e57b9183Scg149915 #define R200_PP_CUBIC_FACES_0 0x2c18 873e57b9183Scg149915 #define R200_PP_CUBIC_FACES_1 0x2c38 874e57b9183Scg149915 #define R200_PP_CUBIC_FACES_2 0x2c58 875e57b9183Scg149915 #define R200_PP_CUBIC_FACES_3 0x2c78 876e57b9183Scg149915 #define R200_PP_CUBIC_FACES_4 0x2c98 877e57b9183Scg149915 #define R200_PP_CUBIC_FACES_5 0x2cb8 878e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F1_0 0x2d04 879e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F2_0 0x2d08 880e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F3_0 0x2d0c 881e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F4_0 0x2d10 882e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F5_0 0x2d14 883e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F1_1 0x2d1c 884e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F2_1 0x2d20 885e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F3_1 0x2d24 886e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F4_1 0x2d28 887e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F5_1 0x2d2c 888e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F1_2 0x2d34 889e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F2_2 0x2d38 890e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F3_2 0x2d3c 891e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F4_2 0x2d40 892e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F5_2 0x2d44 893e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F1_3 0x2d4c 894e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F2_3 0x2d50 895e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F3_3 0x2d54 896e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F4_3 0x2d58 897e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F5_3 0x2d5c 898e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F1_4 0x2d64 899e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F2_4 0x2d68 900e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F3_4 0x2d6c 901e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F4_4 0x2d70 902e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F5_4 0x2d74 903e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F1_5 0x2d7c 904e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F2_5 0x2d80 905e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F3_5 0x2d84 906e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F4_5 0x2d88 907e57b9183Scg149915 #define R200_PP_CUBIC_OFFSET_F5_5 0x2d8c 908e57b9183Scg149915 909e57b9183Scg149915 #define R200_RE_AUX_SCISSOR_CNTL 0x26f0 910e57b9183Scg149915 #define R200_SE_VTE_CNTL 0x20b0 911e57b9183Scg149915 #define R200_SE_TCL_OUTPUT_VTX_COMP_SEL 0x2250 912e57b9183Scg149915 #define R200_PP_TAM_DEBUG3 0x2d9c 913e57b9183Scg149915 #define R200_PP_CNTL_X 0x2cc4 914e57b9183Scg149915 #define R200_SE_VAP_CNTL_STATUS 0x2140 915e57b9183Scg149915 #define R200_RE_SCISSOR_TL_0 0x1cd8 916e57b9183Scg149915 #define R200_RE_SCISSOR_TL_1 0x1ce0 917e57b9183Scg149915 #define R200_RE_SCISSOR_TL_2 0x1ce8 918e57b9183Scg149915 #define R200_RB3D_DEPTHXY_OFFSET 0x1d60 919e57b9183Scg149915 #define R200_RE_AUX_SCISSOR_CNTL 0x26f0 920e57b9183Scg149915 #define R200_SE_VTX_STATE_CNTL 0x2180 921e57b9183Scg149915 #define R200_RE_POINTSIZE 0x2648 922e57b9183Scg149915 #define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0 0x2254 923e57b9183Scg149915 924e57b9183Scg149915 #define RADEON_PP_TEX_SIZE_0 0x1d04 /* NPOT */ 925e57b9183Scg149915 #define RADEON_PP_TEX_SIZE_1 0x1d0c 926e57b9183Scg149915 #define RADEON_PP_TEX_SIZE_2 0x1d14 927e57b9183Scg149915 928e57b9183Scg149915 #define RADEON_PP_CUBIC_FACES_0 0x1d24 929e57b9183Scg149915 #define RADEON_PP_CUBIC_FACES_1 0x1d28 930e57b9183Scg149915 #define RADEON_PP_CUBIC_FACES_2 0x1d2c 931e57b9183Scg149915 #define RADEON_PP_CUBIC_OFFSET_T0_0 0x1dd0 /* bits [31:5] */ 932e57b9183Scg149915 #define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00 933e57b9183Scg149915 #define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14 934e57b9183Scg149915 935e57b9183Scg149915 #define RADEON_SE_TCL_STATE_FLUSH 0x2284 936e57b9183Scg149915 937e57b9183Scg149915 #define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001 938e57b9183Scg149915 #define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK 0x00010000 939e57b9183Scg149915 #define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 0x00000012 940e57b9183Scg149915 #define SE_VTE_CNTL__VTX_XY_FMT_MASK 0x00000100 941e57b9183Scg149915 #define SE_VTE_CNTL__VTX_Z_FMT_MASK 0x00000200 942e57b9183Scg149915 #define SE_VTX_FMT_0__VTX_Z0_PRESENT_MASK 0x00000001 943e57b9183Scg149915 #define SE_VTX_FMT_0__VTX_W0_PRESENT_MASK 0x00000002 944e57b9183Scg149915 #define SE_VTX_FMT_0__VTX_COLOR_0_FMT__SHIFT 0x0000000b 945e57b9183Scg149915 #define R200_3D_DRAW_IMMD_2 0xC0003500 946e57b9183Scg149915 #define R200_SE_VTX_FMT_1 0x208c 947e57b9183Scg149915 #define R200_RE_CNTL 0x1c50 948e57b9183Scg149915 949e57b9183Scg149915 #define R200_RB3D_BLENDCOLOR 0x3218 950e57b9183Scg149915 951e57b9183Scg149915 #define R200_SE_TCL_POINT_SPRITE_CNTL 0x22c4 952e57b9183Scg149915 953e57b9183Scg149915 #define R200_PP_TRI_PERF 0x2cf8 954e57b9183Scg149915 955e57b9183Scg149915 #define R200_PP_AFS_0 0x2f80 956e57b9183Scg149915 #define R200_PP_AFS_1 0x2f00 /* same as txcblend_0 */ 957e57b9183Scg149915 958e57b9183Scg149915 #define R200_VAP_PVS_CNTL_1 0x22D0 959e57b9183Scg149915 960e57b9183Scg149915 /* MPEG settings from VHA code */ 961e57b9183Scg149915 #define RADEON_VHA_SETTO16_1 0x2694 962e57b9183Scg149915 #define RADEON_VHA_SETTO16_2 0x2680 963e57b9183Scg149915 #define RADEON_VHA_SETTO0_1 0x1840 964e57b9183Scg149915 #define RADEON_VHA_FB_OFFSET 0x19e4 965e57b9183Scg149915 #define RADEON_VHA_SETTO1AND70S 0x19d8 966e57b9183Scg149915 #define RADEON_VHA_DST_PITCH 0x1408 967e57b9183Scg149915 968e57b9183Scg149915 // set as reference header 969e57b9183Scg149915 #define RADEON_VHA_BACKFRAME0_OFF_Y 0x1840 970e57b9183Scg149915 #define RADEON_VHA_BACKFRAME1_OFF_PITCH_Y 0x1844 971e57b9183Scg149915 #define RADEON_VHA_BACKFRAME0_OFF_U 0x1848 972e57b9183Scg149915 #define RADEON_VHA_BACKFRAME1_OFF_PITCH_U 0x184c 973e57b9183Scg149915 #define RADOEN_VHA_BACKFRAME0_OFF_V 0x1850 974e57b9183Scg149915 #define RADEON_VHA_BACKFRAME1_OFF_PITCH_V 0x1854 975e57b9183Scg149915 #define RADEON_VHA_FORWFRAME0_OFF_Y 0x1858 976e57b9183Scg149915 #define RADEON_VHA_FORWFRAME1_OFF_PITCH_Y 0x185c 977e57b9183Scg149915 #define RADEON_VHA_FORWFRAME0_OFF_U 0x1860 978e57b9183Scg149915 #define RADEON_VHA_FORWFRAME1_OFF_PITCH_U 0x1864 979e57b9183Scg149915 #define RADEON_VHA_FORWFRAME0_OFF_V 0x1868 980e57b9183Scg149915 #define RADEON_VHA_FORWFRAME0_OFF_PITCH_V 0x1880 981e57b9183Scg149915 #define RADEON_VHA_BACKFRAME0_OFF_Y_2 0x1884 982e57b9183Scg149915 #define RADEON_VHA_BACKFRAME1_OFF_PITCH_Y_2 0x1888 983e57b9183Scg149915 #define RADEON_VHA_BACKFRAME0_OFF_U_2 0x188c 984e57b9183Scg149915 #define RADEON_VHA_BACKFRAME1_OFF_PITCH_U_2 0x1890 985e57b9183Scg149915 #define RADEON_VHA_BACKFRAME0_OFF_V_2 0x1894 986e57b9183Scg149915 #define RADEON_VHA_BACKFRAME1_OFF_PITCH_V_2 0x1898 987e57b9183Scg149915 988e57b9183Scg149915 989e57b9183Scg149915 990e57b9183Scg149915 /* Constants */ 991e57b9183Scg149915 #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ 992e57b9183Scg149915 993e57b9183Scg149915 #define RADEON_LAST_FRAME_REG RADEON_SCRATCH_REG0 994e57b9183Scg149915 #define RADEON_LAST_DISPATCH_REG RADEON_SCRATCH_REG1 995e57b9183Scg149915 #define RADEON_LAST_CLEAR_REG RADEON_SCRATCH_REG2 996e57b9183Scg149915 #define RADEON_LAST_SWI_REG RADEON_SCRATCH_REG3 997e57b9183Scg149915 #define RADEON_LAST_DISPATCH 1 998e57b9183Scg149915 999e57b9183Scg149915 #define RADEON_MAX_VB_AGE 0x7fffffff 1000e57b9183Scg149915 #define RADEON_MAX_VB_VERTS (0xffff) 1001e57b9183Scg149915 1002e57b9183Scg149915 #define RADEON_RING_HIGH_MARK 128 1003e57b9183Scg149915 1004e57b9183Scg149915 #define RADEON_PCIGART_TABLE_SIZE (32*1024) 1005e57b9183Scg149915 1006e57b9183Scg149915 #define RADEON_READ(reg) \ 1007e57b9183Scg149915 DRM_READ32(dev_priv->mmio, (reg)) 1008e57b9183Scg149915 #define RADEON_WRITE(reg, val) \ 1009e57b9183Scg149915 DRM_WRITE32(dev_priv->mmio, (reg), (val)) 1010e57b9183Scg149915 #define RADEON_READ8(reg) \ 1011e57b9183Scg149915 DRM_READ8(dev_priv->mmio, (reg)) 1012e57b9183Scg149915 #define RADEON_WRITE8(reg, val) \ 1013e57b9183Scg149915 DRM_WRITE8(dev_priv->mmio, (reg), (val)) 1014e57b9183Scg149915 1015e57b9183Scg149915 #define RADEON_WRITE_PLL(addr, val) \ 1016e57b9183Scg149915 do { \ 1017e57b9183Scg149915 RADEON_WRITE8(RADEON_CLOCK_CNTL_INDEX, \ 1018e57b9183Scg149915 ((addr) & 0x1f) | RADEON_PLL_WR_EN); \ 1019e57b9183Scg149915 RADEON_WRITE(RADEON_CLOCK_CNTL_DATA, (val)); \ 1020e57b9183Scg149915 } while (*"\0") 1021e57b9183Scg149915 1022e57b9183Scg149915 #define RADEON_WRITE_PCIE(addr, val) \ 1023e57b9183Scg149915 do { \ 1024e57b9183Scg149915 RADEON_WRITE8(RADEON_PCIE_INDEX, \ 1025e57b9183Scg149915 ((addr) & 0xff)); \ 1026e57b9183Scg149915 RADEON_WRITE(RADEON_PCIE_DATA, (val)); \ 1027e57b9183Scg149915 } while (*"\0") 1028e57b9183Scg149915 1029e57b9183Scg149915 #define CP_PACKET0(reg, n) \ 1030e57b9183Scg149915 (RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2)) 1031e57b9183Scg149915 #define CP_PACKET0_TABLE(reg, n) \ 1032e57b9183Scg149915 (RADEON_CP_PACKET0 | RADEON_ONE_REG_WR | ((n) << 16) | ((reg) >> 2)) 1033e57b9183Scg149915 #define CP_PACKET1(reg0, reg1) \ 1034e57b9183Scg149915 (RADEON_CP_PACKET1 | (((reg1) >> 2) << 15) | ((reg0) >> 2)) 1035e57b9183Scg149915 #define CP_PACKET2() \ 1036e57b9183Scg149915 (RADEON_CP_PACKET2) 1037e57b9183Scg149915 #define CP_PACKET3(pkt, n) \ 1038e57b9183Scg149915 (RADEON_CP_PACKET3 | (pkt) | ((n) << 16)) 1039e57b9183Scg149915 1040e57b9183Scg149915 /* 1041e57b9183Scg149915 * Engine control helper macros 1042e57b9183Scg149915 */ 1043e57b9183Scg149915 1044e57b9183Scg149915 #define RADEON_WAIT_UNTIL_2D_IDLE() do { \ 1045e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \ 1046e57b9183Scg149915 OUT_RING((RADEON_WAIT_2D_IDLECLEAN | \ 1047e57b9183Scg149915 RADEON_WAIT_HOST_IDLECLEAN)); \ 1048e57b9183Scg149915 } while (*"\0") 1049e57b9183Scg149915 1050e57b9183Scg149915 #define RADEON_WAIT_UNTIL_3D_IDLE() do { \ 1051e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \ 1052e57b9183Scg149915 OUT_RING((RADEON_WAIT_3D_IDLECLEAN | \ 1053e57b9183Scg149915 RADEON_WAIT_HOST_IDLECLEAN)); \ 1054e57b9183Scg149915 } while (*"\0") 1055e57b9183Scg149915 1056e57b9183Scg149915 #define RADEON_WAIT_UNTIL_IDLE() do { \ 1057e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \ 1058e57b9183Scg149915 OUT_RING((RADEON_WAIT_2D_IDLECLEAN | \ 1059e57b9183Scg149915 RADEON_WAIT_3D_IDLECLEAN | \ 1060e57b9183Scg149915 RADEON_WAIT_HOST_IDLECLEAN)); \ 1061e57b9183Scg149915 } while (*"\0") 1062e57b9183Scg149915 1063e57b9183Scg149915 #define RADEON_WAIT_UNTIL_PAGE_FLIPPED() do { \ 1064e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); \ 1065e57b9183Scg149915 OUT_RING(RADEON_WAIT_CRTC_PFLIP); \ 1066e57b9183Scg149915 } while (*"\0") 1067e57b9183Scg149915 1068e57b9183Scg149915 #define RADEON_FLUSH_CACHE() do { \ 1069e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \ 1070e57b9183Scg149915 OUT_RING(RADEON_RB3D_DC_FLUSH); \ 1071e57b9183Scg149915 } while (*"\0") 1072e57b9183Scg149915 1073e57b9183Scg149915 #define RADEON_PURGE_CACHE() do { \ 1074e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \ 1075e57b9183Scg149915 OUT_RING(RADEON_RB3D_DC_FLUSH_ALL); \ 1076e57b9183Scg149915 } while (*"\0") 1077e57b9183Scg149915 1078e57b9183Scg149915 #define RADEON_FLUSH_ZCACHE() do { \ 1079e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \ 1080e57b9183Scg149915 OUT_RING(RADEON_RB3D_ZC_FLUSH); \ 1081e57b9183Scg149915 } while (*"\0") 1082e57b9183Scg149915 1083e57b9183Scg149915 #define RADEON_PURGE_ZCACHE() do { \ 1084e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \ 1085e57b9183Scg149915 OUT_RING(RADEON_RB3D_ZC_FLUSH_ALL); \ 1086e57b9183Scg149915 } while (*"\0") 1087e57b9183Scg149915 1088e57b9183Scg149915 /* 1089e57b9183Scg149915 * Misc helper macros 1090e57b9183Scg149915 */ 1091e57b9183Scg149915 1092e57b9183Scg149915 /* Perfbox functionality only. */ 1093e57b9183Scg149915 #define RING_SPACE_TEST_WITH_RETURN(dev_priv) \ 1094e57b9183Scg149915 do { \ 1095e57b9183Scg149915 if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) { \ 1096e57b9183Scg149915 u32 head = GET_RING_HEAD(dev_priv); \ 1097e57b9183Scg149915 if (head == dev_priv->ring.tail) \ 1098e57b9183Scg149915 dev_priv->stats.boxes |= RADEON_BOX_DMA_IDLE; \ 1099e57b9183Scg149915 } \ 1100e57b9183Scg149915 } while (*"\0") 1101e57b9183Scg149915 1102e57b9183Scg149915 #define VB_AGE_TEST_WITH_RETURN(dev_priv) \ 1103e57b9183Scg149915 do { \ 1104e57b9183Scg149915 drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv; \ 1105e57b9183Scg149915 if (sarea_priv->last_dispatch >= RADEON_MAX_VB_AGE) { \ 1106e57b9183Scg149915 int __ret = radeon_do_cp_idle(dev_priv); \ 1107e57b9183Scg149915 if (__ret) \ 1108e57b9183Scg149915 return (__ret); \ 1109e57b9183Scg149915 sarea_priv->last_dispatch = 0; \ 1110e57b9183Scg149915 radeon_freelist_reset(dev); \ 1111e57b9183Scg149915 } \ 1112e57b9183Scg149915 } while (*"\0") 1113e57b9183Scg149915 1114e57b9183Scg149915 #define RADEON_DISPATCH_AGE(age) do { \ 1115e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_LAST_DISPATCH_REG, 0)); \ 1116e57b9183Scg149915 OUT_RING(age); \ 1117e57b9183Scg149915 } while (*"\0") 1118e57b9183Scg149915 1119e57b9183Scg149915 #define RADEON_FRAME_AGE(age) do { \ 1120e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_LAST_FRAME_REG, 0)); \ 1121e57b9183Scg149915 OUT_RING(age); \ 1122e57b9183Scg149915 } while (*"\0") 1123e57b9183Scg149915 1124e57b9183Scg149915 #define RADEON_CLEAR_AGE(age) do { \ 1125e57b9183Scg149915 OUT_RING(CP_PACKET0(RADEON_LAST_CLEAR_REG, 0)); \ 1126e57b9183Scg149915 OUT_RING(age); \ 1127e57b9183Scg149915 } while (*"\0") 1128e57b9183Scg149915 1129e57b9183Scg149915 /* 1130e57b9183Scg149915 * Ring control 1131e57b9183Scg149915 */ 1132e57b9183Scg149915 #define RING_LOCALS int write, _nr; unsigned int mask; u32 *ring; 1133e57b9183Scg149915 1134e57b9183Scg149915 #define BEGIN_RING(n) do { \ 1135e57b9183Scg149915 if (dev_priv->ring.space <= (n) * sizeof (u32)) { \ 1136e57b9183Scg149915 COMMIT_RING(); \ 1137e57b9183Scg149915 (void) radeon_wait_ring(dev_priv, (n) * sizeof (u32)); \ 1138e57b9183Scg149915 } \ 1139e57b9183Scg149915 _nr = n; dev_priv->ring.space -= (n) * sizeof (u32); \ 1140e57b9183Scg149915 ring = dev_priv->ring.start; \ 1141e57b9183Scg149915 write = dev_priv->ring.tail; \ 1142e57b9183Scg149915 mask = dev_priv->ring.tail_mask; \ 1143e57b9183Scg149915 } while (*"\0") 1144e57b9183Scg149915 1145e57b9183Scg149915 #define ADVANCE_RING() do { \ 1146e57b9183Scg149915 if (((dev_priv->ring.tail + _nr) & mask) != write) { \ 1147e57b9183Scg149915 DRM_ERROR( \ 1148e57b9183Scg149915 "ADVANCE_RING(): mismatch: nr: " \ 1149e57b9183Scg149915 "%x write: %x line: %d\n", \ 1150e57b9183Scg149915 ((dev_priv->ring.tail + _nr) & mask), \ 1151e57b9183Scg149915 write, __LINE__); \ 1152e57b9183Scg149915 } else \ 1153e57b9183Scg149915 dev_priv->ring.tail = write; \ 1154e57b9183Scg149915 } while (*"\0") 1155e57b9183Scg149915 1156e57b9183Scg149915 1157e57b9183Scg149915 #if defined(lint) || defined(__lint) 1158e57b9183Scg149915 #define COMMIT_RING() /* For lint clean */ 1159e57b9183Scg149915 #else 1160e57b9183Scg149915 #define COMMIT_RING() do { \ 1161e57b9183Scg149915 /* Flush writes to ring */ \ 1162e57b9183Scg149915 DRM_MEMORYBARRIER(); \ 1163e57b9183Scg149915 GET_RING_HEAD(dev_priv); \ 1164e57b9183Scg149915 RADEON_WRITE(RADEON_CP_RB_WPTR, dev_priv->ring.tail); \ 1165e57b9183Scg149915 /* read from PCI bus to ensure correct posting */ \ 1166e57b9183Scg149915 RADEON_READ(RADEON_CP_RB_RPTR); \ 1167e57b9183Scg149915 } while (*"\0") 1168e57b9183Scg149915 #endif 1169e57b9183Scg149915 1170e57b9183Scg149915 #define OUT_RING(x) do { \ 1171e57b9183Scg149915 ring[write++] = (x); \ 1172e57b9183Scg149915 write &= mask; \ 1173e57b9183Scg149915 } while (*"\0") 1174e57b9183Scg149915 1175e57b9183Scg149915 #define OUT_RING_REG(reg, val) do { \ 1176e57b9183Scg149915 OUT_RING(CP_PACKET0(reg, 0)); \ 1177e57b9183Scg149915 OUT_RING(val); \ 1178e57b9183Scg149915 } while (*"\0") 1179e57b9183Scg149915 1180e57b9183Scg149915 #define OUT_RING_TABLE(tab, sz) do { \ 1181e57b9183Scg149915 int _size = (sz); \ 1182e57b9183Scg149915 int *_tab = (int *)(uintptr_t)(tab); \ 1183e57b9183Scg149915 \ 1184e57b9183Scg149915 if (write + _size > mask) { \ 1185e57b9183Scg149915 int _i = (mask+1) - write; \ 1186e57b9183Scg149915 _size -= _i; \ 1187e57b9183Scg149915 while (_i > 0) { \ 1188e57b9183Scg149915 *(int *)(ring + write) = *_tab++; \ 1189e57b9183Scg149915 write++; \ 1190e57b9183Scg149915 _i--; \ 1191e57b9183Scg149915 } \ 1192e57b9183Scg149915 write = 0; \ 1193e57b9183Scg149915 _tab += _i; \ 1194e57b9183Scg149915 } \ 1195e57b9183Scg149915 while (_size > 0) { \ 1196e57b9183Scg149915 *(ring + write) = *_tab++; \ 1197e57b9183Scg149915 write++; \ 1198e57b9183Scg149915 _size--; \ 1199e57b9183Scg149915 } \ 1200e57b9183Scg149915 write &= mask; \ 1201e57b9183Scg149915 } while (*"\0") 1202e57b9183Scg149915 1203e57b9183Scg149915 #endif /* __RADEON_DRV_H__ */ 1204