1b7e1c893Smrg/* radeon_drm.h -- Public header for the radeon driver -*- linux-c -*- 2b7e1c893Smrg * 3b7e1c893Smrg * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. 4b7e1c893Smrg * Copyright 2000 VA Linux Systems, Inc., Fremont, California. 5b7e1c893Smrg * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas. 6b7e1c893Smrg * All rights reserved. 7b7e1c893Smrg * 8b7e1c893Smrg * Permission is hereby granted, free of charge, to any person obtaining a 9b7e1c893Smrg * copy of this software and associated documentation files (the "Software"), 10b7e1c893Smrg * to deal in the Software without restriction, including without limitation 11b7e1c893Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12b7e1c893Smrg * and/or sell copies of the Software, and to permit persons to whom the 13b7e1c893Smrg * Software is furnished to do so, subject to the following conditions: 14b7e1c893Smrg * 15b7e1c893Smrg * The above copyright notice and this permission notice (including the next 16b7e1c893Smrg * paragraph) shall be included in all copies or substantial portions of the 17b7e1c893Smrg * Software. 18b7e1c893Smrg * 19b7e1c893Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20b7e1c893Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21b7e1c893Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22b7e1c893Smrg * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 23b7e1c893Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 24b7e1c893Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25b7e1c893Smrg * DEALINGS IN THE SOFTWARE. 26b7e1c893Smrg * 27b7e1c893Smrg * Authors: 28b7e1c893Smrg * Kevin E. Martin <martin@valinux.com> 29b7e1c893Smrg * Gareth Hughes <gareth@valinux.com> 30b7e1c893Smrg * Keith Whitwell <keith@tungstengraphics.com> 31b7e1c893Smrg */ 32b7e1c893Smrg 33b7e1c893Smrg#ifndef __RADEON_DRM_H__ 34b7e1c893Smrg#define __RADEON_DRM_H__ 35b7e1c893Smrg 36b7e1c893Smrg/* WARNING: If you change any of these defines, make sure to change the 37b7e1c893Smrg * defines in the X server file (radeon_sarea.h) 38b7e1c893Smrg */ 39b7e1c893Smrg#ifndef __RADEON_SAREA_DEFINES__ 40b7e1c893Smrg#define __RADEON_SAREA_DEFINES__ 41b7e1c893Smrg 42b7e1c893Smrg/* Old style state flags, required for sarea interface (1.1 and 1.2 43b7e1c893Smrg * clears) and 1.2 drm_vertex2 ioctl. 44b7e1c893Smrg */ 45b7e1c893Smrg#define RADEON_UPLOAD_CONTEXT 0x00000001 46b7e1c893Smrg#define RADEON_UPLOAD_VERTFMT 0x00000002 47b7e1c893Smrg#define RADEON_UPLOAD_LINE 0x00000004 48b7e1c893Smrg#define RADEON_UPLOAD_BUMPMAP 0x00000008 49b7e1c893Smrg#define RADEON_UPLOAD_MASKS 0x00000010 50b7e1c893Smrg#define RADEON_UPLOAD_VIEWPORT 0x00000020 51b7e1c893Smrg#define RADEON_UPLOAD_SETUP 0x00000040 52b7e1c893Smrg#define RADEON_UPLOAD_TCL 0x00000080 53b7e1c893Smrg#define RADEON_UPLOAD_MISC 0x00000100 54b7e1c893Smrg#define RADEON_UPLOAD_TEX0 0x00000200 55b7e1c893Smrg#define RADEON_UPLOAD_TEX1 0x00000400 56b7e1c893Smrg#define RADEON_UPLOAD_TEX2 0x00000800 57b7e1c893Smrg#define RADEON_UPLOAD_TEX0IMAGES 0x00001000 58b7e1c893Smrg#define RADEON_UPLOAD_TEX1IMAGES 0x00002000 59b7e1c893Smrg#define RADEON_UPLOAD_TEX2IMAGES 0x00004000 60b7e1c893Smrg#define RADEON_UPLOAD_CLIPRECTS 0x00008000 /* handled client-side */ 61b7e1c893Smrg#define RADEON_REQUIRE_QUIESCENCE 0x00010000 62b7e1c893Smrg#define RADEON_UPLOAD_ZBIAS 0x00020000 /* version 1.2 and newer */ 63b7e1c893Smrg#define RADEON_UPLOAD_ALL 0x003effff 64b7e1c893Smrg#define RADEON_UPLOAD_CONTEXT_ALL 0x003e01ff 65b7e1c893Smrg 66b7e1c893Smrg/* New style per-packet identifiers for use in cmd_buffer ioctl with 67b7e1c893Smrg * the RADEON_EMIT_PACKET command. Comments relate new packets to old 68b7e1c893Smrg * state bits and the packet size: 69b7e1c893Smrg */ 70b7e1c893Smrg#define RADEON_EMIT_PP_MISC 0 /* context/7 */ 71b7e1c893Smrg#define RADEON_EMIT_PP_CNTL 1 /* context/3 */ 72b7e1c893Smrg#define RADEON_EMIT_RB3D_COLORPITCH 2 /* context/1 */ 73b7e1c893Smrg#define RADEON_EMIT_RE_LINE_PATTERN 3 /* line/2 */ 74b7e1c893Smrg#define RADEON_EMIT_SE_LINE_WIDTH 4 /* line/1 */ 75b7e1c893Smrg#define RADEON_EMIT_PP_LUM_MATRIX 5 /* bumpmap/1 */ 76b7e1c893Smrg#define RADEON_EMIT_PP_ROT_MATRIX_0 6 /* bumpmap/2 */ 77b7e1c893Smrg#define RADEON_EMIT_RB3D_STENCILREFMASK 7 /* masks/3 */ 78b7e1c893Smrg#define RADEON_EMIT_SE_VPORT_XSCALE 8 /* viewport/6 */ 79b7e1c893Smrg#define RADEON_EMIT_SE_CNTL 9 /* setup/2 */ 80b7e1c893Smrg#define RADEON_EMIT_SE_CNTL_STATUS 10 /* setup/1 */ 81b7e1c893Smrg#define RADEON_EMIT_RE_MISC 11 /* misc/1 */ 82b7e1c893Smrg#define RADEON_EMIT_PP_TXFILTER_0 12 /* tex0/6 */ 83b7e1c893Smrg#define RADEON_EMIT_PP_BORDER_COLOR_0 13 /* tex0/1 */ 84b7e1c893Smrg#define RADEON_EMIT_PP_TXFILTER_1 14 /* tex1/6 */ 85b7e1c893Smrg#define RADEON_EMIT_PP_BORDER_COLOR_1 15 /* tex1/1 */ 86b7e1c893Smrg#define RADEON_EMIT_PP_TXFILTER_2 16 /* tex2/6 */ 87b7e1c893Smrg#define RADEON_EMIT_PP_BORDER_COLOR_2 17 /* tex2/1 */ 88b7e1c893Smrg#define RADEON_EMIT_SE_ZBIAS_FACTOR 18 /* zbias/2 */ 89b7e1c893Smrg#define RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT 19 /* tcl/11 */ 90b7e1c893Smrg#define RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED 20 /* material/17 */ 91b7e1c893Smrg#define R200_EMIT_PP_TXCBLEND_0 21 /* tex0/4 */ 92b7e1c893Smrg#define R200_EMIT_PP_TXCBLEND_1 22 /* tex1/4 */ 93b7e1c893Smrg#define R200_EMIT_PP_TXCBLEND_2 23 /* tex2/4 */ 94b7e1c893Smrg#define R200_EMIT_PP_TXCBLEND_3 24 /* tex3/4 */ 95b7e1c893Smrg#define R200_EMIT_PP_TXCBLEND_4 25 /* tex4/4 */ 96b7e1c893Smrg#define R200_EMIT_PP_TXCBLEND_5 26 /* tex5/4 */ 97b7e1c893Smrg#define R200_EMIT_PP_TXCBLEND_6 27 /* /4 */ 98b7e1c893Smrg#define R200_EMIT_PP_TXCBLEND_7 28 /* /4 */ 99b7e1c893Smrg#define R200_EMIT_TCL_LIGHT_MODEL_CTL_0 29 /* tcl/7 */ 100b7e1c893Smrg#define R200_EMIT_TFACTOR_0 30 /* tf/7 */ 101b7e1c893Smrg#define R200_EMIT_VTX_FMT_0 31 /* vtx/5 */ 102b7e1c893Smrg#define R200_EMIT_VAP_CTL 32 /* vap/1 */ 103b7e1c893Smrg#define R200_EMIT_MATRIX_SELECT_0 33 /* msl/5 */ 104b7e1c893Smrg#define R200_EMIT_TEX_PROC_CTL_2 34 /* tcg/5 */ 105b7e1c893Smrg#define R200_EMIT_TCL_UCP_VERT_BLEND_CTL 35 /* tcl/1 */ 106b7e1c893Smrg#define R200_EMIT_PP_TXFILTER_0 36 /* tex0/6 */ 107b7e1c893Smrg#define R200_EMIT_PP_TXFILTER_1 37 /* tex1/6 */ 108b7e1c893Smrg#define R200_EMIT_PP_TXFILTER_2 38 /* tex2/6 */ 109b7e1c893Smrg#define R200_EMIT_PP_TXFILTER_3 39 /* tex3/6 */ 110b7e1c893Smrg#define R200_EMIT_PP_TXFILTER_4 40 /* tex4/6 */ 111b7e1c893Smrg#define R200_EMIT_PP_TXFILTER_5 41 /* tex5/6 */ 112b7e1c893Smrg#define R200_EMIT_PP_TXOFFSET_0 42 /* tex0/1 */ 113b7e1c893Smrg#define R200_EMIT_PP_TXOFFSET_1 43 /* tex1/1 */ 114b7e1c893Smrg#define R200_EMIT_PP_TXOFFSET_2 44 /* tex2/1 */ 115b7e1c893Smrg#define R200_EMIT_PP_TXOFFSET_3 45 /* tex3/1 */ 116b7e1c893Smrg#define R200_EMIT_PP_TXOFFSET_4 46 /* tex4/1 */ 117b7e1c893Smrg#define R200_EMIT_PP_TXOFFSET_5 47 /* tex5/1 */ 118b7e1c893Smrg#define R200_EMIT_VTE_CNTL 48 /* vte/1 */ 119b7e1c893Smrg#define R200_EMIT_OUTPUT_VTX_COMP_SEL 49 /* vtx/1 */ 120b7e1c893Smrg#define R200_EMIT_PP_TAM_DEBUG3 50 /* tam/1 */ 121b7e1c893Smrg#define R200_EMIT_PP_CNTL_X 51 /* cst/1 */ 122b7e1c893Smrg#define R200_EMIT_RB3D_DEPTHXY_OFFSET 52 /* cst/1 */ 123b7e1c893Smrg#define R200_EMIT_RE_AUX_SCISSOR_CNTL 53 /* cst/1 */ 124b7e1c893Smrg#define R200_EMIT_RE_SCISSOR_TL_0 54 /* cst/2 */ 125b7e1c893Smrg#define R200_EMIT_RE_SCISSOR_TL_1 55 /* cst/2 */ 126b7e1c893Smrg#define R200_EMIT_RE_SCISSOR_TL_2 56 /* cst/2 */ 127b7e1c893Smrg#define R200_EMIT_SE_VAP_CNTL_STATUS 57 /* cst/1 */ 128b7e1c893Smrg#define R200_EMIT_SE_VTX_STATE_CNTL 58 /* cst/1 */ 129b7e1c893Smrg#define R200_EMIT_RE_POINTSIZE 59 /* cst/1 */ 130b7e1c893Smrg#define R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0 60 /* cst/4 */ 131b7e1c893Smrg#define R200_EMIT_PP_CUBIC_FACES_0 61 132b7e1c893Smrg#define R200_EMIT_PP_CUBIC_OFFSETS_0 62 133b7e1c893Smrg#define R200_EMIT_PP_CUBIC_FACES_1 63 134b7e1c893Smrg#define R200_EMIT_PP_CUBIC_OFFSETS_1 64 135b7e1c893Smrg#define R200_EMIT_PP_CUBIC_FACES_2 65 136b7e1c893Smrg#define R200_EMIT_PP_CUBIC_OFFSETS_2 66 137b7e1c893Smrg#define R200_EMIT_PP_CUBIC_FACES_3 67 138b7e1c893Smrg#define R200_EMIT_PP_CUBIC_OFFSETS_3 68 139b7e1c893Smrg#define R200_EMIT_PP_CUBIC_FACES_4 69 140b7e1c893Smrg#define R200_EMIT_PP_CUBIC_OFFSETS_4 70 141b7e1c893Smrg#define R200_EMIT_PP_CUBIC_FACES_5 71 142b7e1c893Smrg#define R200_EMIT_PP_CUBIC_OFFSETS_5 72 143b7e1c893Smrg#define RADEON_EMIT_PP_TEX_SIZE_0 73 144b7e1c893Smrg#define RADEON_EMIT_PP_TEX_SIZE_1 74 145b7e1c893Smrg#define RADEON_EMIT_PP_TEX_SIZE_2 75 146b7e1c893Smrg#define R200_EMIT_RB3D_BLENDCOLOR 76 147b7e1c893Smrg#define R200_EMIT_TCL_POINT_SPRITE_CNTL 77 148b7e1c893Smrg#define RADEON_EMIT_PP_CUBIC_FACES_0 78 149b7e1c893Smrg#define RADEON_EMIT_PP_CUBIC_OFFSETS_T0 79 150b7e1c893Smrg#define RADEON_EMIT_PP_CUBIC_FACES_1 80 151b7e1c893Smrg#define RADEON_EMIT_PP_CUBIC_OFFSETS_T1 81 152b7e1c893Smrg#define RADEON_EMIT_PP_CUBIC_FACES_2 82 153b7e1c893Smrg#define RADEON_EMIT_PP_CUBIC_OFFSETS_T2 83 154b7e1c893Smrg#define R200_EMIT_PP_TRI_PERF_CNTL 84 155b7e1c893Smrg#define R200_EMIT_PP_AFS_0 85 156b7e1c893Smrg#define R200_EMIT_PP_AFS_1 86 157b7e1c893Smrg#define R200_EMIT_ATF_TFACTOR 87 158b7e1c893Smrg#define R200_EMIT_PP_TXCTLALL_0 88 159b7e1c893Smrg#define R200_EMIT_PP_TXCTLALL_1 89 160b7e1c893Smrg#define R200_EMIT_PP_TXCTLALL_2 90 161b7e1c893Smrg#define R200_EMIT_PP_TXCTLALL_3 91 162b7e1c893Smrg#define R200_EMIT_PP_TXCTLALL_4 92 163b7e1c893Smrg#define R200_EMIT_PP_TXCTLALL_5 93 164b7e1c893Smrg#define R200_EMIT_VAP_PVS_CNTL 94 165b7e1c893Smrg#define RADEON_MAX_STATE_PACKETS 95 166b7e1c893Smrg 167b7e1c893Smrg/* Commands understood by cmd_buffer ioctl. More can be added but 168b7e1c893Smrg * obviously these can't be removed or changed: 169b7e1c893Smrg */ 170b7e1c893Smrg#define RADEON_CMD_PACKET 1 /* emit one of the register packets above */ 171b7e1c893Smrg#define RADEON_CMD_SCALARS 2 /* emit scalar data */ 172b7e1c893Smrg#define RADEON_CMD_VECTORS 3 /* emit vector data */ 173b7e1c893Smrg#define RADEON_CMD_DMA_DISCARD 4 /* discard current dma buf */ 174b7e1c893Smrg#define RADEON_CMD_PACKET3 5 /* emit hw packet */ 175b7e1c893Smrg#define RADEON_CMD_PACKET3_CLIP 6 /* emit hw packet wrapped in cliprects */ 176b7e1c893Smrg#define RADEON_CMD_SCALARS2 7 /* r200 stopgap */ 177b7e1c893Smrg#define RADEON_CMD_WAIT 8 /* emit hw wait commands -- note: 178b7e1c893Smrg * doesn't make the cpu wait, just 179b7e1c893Smrg * the graphics hardware */ 180b7e1c893Smrg#define RADEON_CMD_VECLINEAR 9 /* another r200 stopgap */ 181b7e1c893Smrg 182b7e1c893Smrgtypedef union { 183b7e1c893Smrg int i; 184b7e1c893Smrg struct { 185b7e1c893Smrg unsigned char cmd_type, pad0, pad1, pad2; 186b7e1c893Smrg } header; 187b7e1c893Smrg struct { 188b7e1c893Smrg unsigned char cmd_type, packet_id, pad0, pad1; 189b7e1c893Smrg } packet; 190b7e1c893Smrg struct { 191b7e1c893Smrg unsigned char cmd_type, offset, stride, count; 192b7e1c893Smrg } scalars; 193b7e1c893Smrg struct { 194b7e1c893Smrg unsigned char cmd_type, offset, stride, count; 195b7e1c893Smrg } vectors; 196b7e1c893Smrg struct { 197b7e1c893Smrg unsigned char cmd_type, addr_lo, addr_hi, count; 198b7e1c893Smrg } veclinear; 199b7e1c893Smrg struct { 200b7e1c893Smrg unsigned char cmd_type, buf_idx, pad0, pad1; 201b7e1c893Smrg } dma; 202b7e1c893Smrg struct { 203b7e1c893Smrg unsigned char cmd_type, flags, pad0, pad1; 204b7e1c893Smrg } wait; 205b7e1c893Smrg} drm_radeon_cmd_header_t; 206b7e1c893Smrg 207b7e1c893Smrg#define RADEON_WAIT_2D 0x1 208b7e1c893Smrg#define RADEON_WAIT_3D 0x2 209b7e1c893Smrg 210b7e1c893Smrg/* Allowed parameters for R300_CMD_PACKET3 211b7e1c893Smrg */ 212b7e1c893Smrg#define R300_CMD_PACKET3_CLEAR 0 213b7e1c893Smrg#define R300_CMD_PACKET3_RAW 1 214b7e1c893Smrg 215b7e1c893Smrg/* Commands understood by cmd_buffer ioctl for R300. 216b7e1c893Smrg * The interface has not been stabilized, so some of these may be removed 217b7e1c893Smrg * and eventually reordered before stabilization. 218b7e1c893Smrg */ 219b7e1c893Smrg#define R300_CMD_PACKET0 1 220b7e1c893Smrg#define R300_CMD_VPU 2 /* emit vertex program upload */ 221b7e1c893Smrg#define R300_CMD_PACKET3 3 /* emit a packet3 */ 222b7e1c893Smrg#define R300_CMD_END3D 4 /* emit sequence ending 3d rendering */ 223b7e1c893Smrg#define R300_CMD_CP_DELAY 5 224b7e1c893Smrg#define R300_CMD_DMA_DISCARD 6 225b7e1c893Smrg#define R300_CMD_WAIT 7 226b7e1c893Smrg# define R300_WAIT_2D 0x1 227b7e1c893Smrg# define R300_WAIT_3D 0x2 228b7e1c893Smrg/* these two defines are DOING IT WRONG - however 229b7e1c893Smrg * we have userspace which relies on using these. 230b7e1c893Smrg * The wait interface is backwards compat new 231b7e1c893Smrg * code should use the NEW_WAIT defines below 232b7e1c893Smrg * THESE ARE NOT BIT FIELDS 233b7e1c893Smrg */ 234b7e1c893Smrg# define R300_WAIT_2D_CLEAN 0x3 235b7e1c893Smrg# define R300_WAIT_3D_CLEAN 0x4 236b7e1c893Smrg 237b7e1c893Smrg# define R300_NEW_WAIT_2D_3D 0x3 238b7e1c893Smrg# define R300_NEW_WAIT_2D_2D_CLEAN 0x4 239b7e1c893Smrg# define R300_NEW_WAIT_3D_3D_CLEAN 0x6 240b7e1c893Smrg# define R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN 0x8 241b7e1c893Smrg 242b7e1c893Smrg#define R300_CMD_SCRATCH 8 243b7e1c893Smrg#define R300_CMD_R500FP 9 244b7e1c893Smrg 245b7e1c893Smrgtypedef union { 246b7e1c893Smrg unsigned int u; 247b7e1c893Smrg struct { 248b7e1c893Smrg unsigned char cmd_type, pad0, pad1, pad2; 249b7e1c893Smrg } header; 250b7e1c893Smrg struct { 251b7e1c893Smrg unsigned char cmd_type, count, reglo, reghi; 252b7e1c893Smrg } packet0; 253b7e1c893Smrg struct { 254b7e1c893Smrg unsigned char cmd_type, count, adrlo, adrhi; 255b7e1c893Smrg } vpu; 256b7e1c893Smrg struct { 257b7e1c893Smrg unsigned char cmd_type, packet, pad0, pad1; 258b7e1c893Smrg } packet3; 259b7e1c893Smrg struct { 260b7e1c893Smrg unsigned char cmd_type, packet; 261b7e1c893Smrg unsigned short count; /* amount of packet2 to emit */ 262b7e1c893Smrg } delay; 263b7e1c893Smrg struct { 264b7e1c893Smrg unsigned char cmd_type, buf_idx, pad0, pad1; 265b7e1c893Smrg } dma; 266b7e1c893Smrg struct { 267b7e1c893Smrg unsigned char cmd_type, flags, pad0, pad1; 268b7e1c893Smrg } wait; 269b7e1c893Smrg struct { 270b7e1c893Smrg unsigned char cmd_type, reg, n_bufs, flags; 271b7e1c893Smrg } scratch; 272b7e1c893Smrg struct { 273b7e1c893Smrg unsigned char cmd_type, count, adrlo, adrhi_flags; 274b7e1c893Smrg } r500fp; 275b7e1c893Smrg} drm_r300_cmd_header_t; 276b7e1c893Smrg 277b7e1c893Smrg#define RADEON_FRONT 0x1 278b7e1c893Smrg#define RADEON_BACK 0x2 279b7e1c893Smrg#define RADEON_DEPTH 0x4 280b7e1c893Smrg#define RADEON_STENCIL 0x8 281b7e1c893Smrg#define RADEON_CLEAR_FASTZ 0x80000000 282b7e1c893Smrg#define RADEON_USE_HIERZ 0x40000000 283b7e1c893Smrg#define RADEON_USE_COMP_ZBUF 0x20000000 284b7e1c893Smrg 285b7e1c893Smrg#define R500FP_CONSTANT_TYPE (1 << 1) 286b7e1c893Smrg#define R500FP_CONSTANT_CLAMP (1 << 2) 287b7e1c893Smrg 288b7e1c893Smrg/* Primitive types 289b7e1c893Smrg */ 290b7e1c893Smrg#define RADEON_POINTS 0x1 291b7e1c893Smrg#define RADEON_LINES 0x2 292b7e1c893Smrg#define RADEON_LINE_STRIP 0x3 293b7e1c893Smrg#define RADEON_TRIANGLES 0x4 294b7e1c893Smrg#define RADEON_TRIANGLE_FAN 0x5 295b7e1c893Smrg#define RADEON_TRIANGLE_STRIP 0x6 296b7e1c893Smrg 297b7e1c893Smrg/* Vertex/indirect buffer size 298b7e1c893Smrg */ 299b7e1c893Smrg#define RADEON_BUFFER_SIZE 65536 300b7e1c893Smrg 301b7e1c893Smrg/* Byte offsets for indirect buffer data 302b7e1c893Smrg */ 303b7e1c893Smrg#define RADEON_INDEX_PRIM_OFFSET 20 304b7e1c893Smrg 305b7e1c893Smrg#define RADEON_SCRATCH_REG_OFFSET 32 306b7e1c893Smrg#define R600_SCRATCH_REG_OFFSET 256 307b7e1c893Smrg 308b7e1c893Smrg#define RADEON_NR_SAREA_CLIPRECTS 12 309b7e1c893Smrg 310b7e1c893Smrg/* There are 2 heaps (local/GART). Each region within a heap is a 311b7e1c893Smrg * minimum of 64k, and there are at most 64 of them per heap. 312b7e1c893Smrg */ 313b7e1c893Smrg#define RADEON_LOCAL_TEX_HEAP 0 314b7e1c893Smrg#define RADEON_GART_TEX_HEAP 1 315b7e1c893Smrg#define RADEON_NR_TEX_HEAPS 2 316b7e1c893Smrg#define RADEON_NR_TEX_REGIONS 64 317b7e1c893Smrg#define RADEON_LOG_TEX_GRANULARITY 16 318b7e1c893Smrg 319b7e1c893Smrg#define RADEON_MAX_TEXTURE_LEVELS 12 320b7e1c893Smrg#define RADEON_MAX_TEXTURE_UNITS 3 321b7e1c893Smrg 322b7e1c893Smrg#define RADEON_MAX_SURFACES 8 323b7e1c893Smrg 324b7e1c893Smrg/* Blits have strict offset rules. All blit offset must be aligned on 325b7e1c893Smrg * a 1K-byte boundary. 326b7e1c893Smrg */ 327b7e1c893Smrg#define RADEON_OFFSET_SHIFT 10 328b7e1c893Smrg#define RADEON_OFFSET_ALIGN (1 << RADEON_OFFSET_SHIFT) 329b7e1c893Smrg#define RADEON_OFFSET_MASK (RADEON_OFFSET_ALIGN - 1) 330b7e1c893Smrg 331b7e1c893Smrg#endif /* __RADEON_SAREA_DEFINES__ */ 332b7e1c893Smrg 333b7e1c893Smrgtypedef struct { 334b7e1c893Smrg unsigned int red; 335b7e1c893Smrg unsigned int green; 336b7e1c893Smrg unsigned int blue; 337b7e1c893Smrg unsigned int alpha; 338b7e1c893Smrg} radeon_color_regs_t; 339b7e1c893Smrg 340b7e1c893Smrgtypedef struct { 341b7e1c893Smrg /* Context state */ 342b7e1c893Smrg unsigned int pp_misc; /* 0x1c14 */ 343b7e1c893Smrg unsigned int pp_fog_color; 344b7e1c893Smrg unsigned int re_solid_color; 345b7e1c893Smrg unsigned int rb3d_blendcntl; 346b7e1c893Smrg unsigned int rb3d_depthoffset; 347b7e1c893Smrg unsigned int rb3d_depthpitch; 348b7e1c893Smrg unsigned int rb3d_zstencilcntl; 349b7e1c893Smrg 350b7e1c893Smrg unsigned int pp_cntl; /* 0x1c38 */ 351b7e1c893Smrg unsigned int rb3d_cntl; 352b7e1c893Smrg unsigned int rb3d_coloroffset; 353b7e1c893Smrg unsigned int re_width_height; 354b7e1c893Smrg unsigned int rb3d_colorpitch; 355b7e1c893Smrg unsigned int se_cntl; 356b7e1c893Smrg 357b7e1c893Smrg /* Vertex format state */ 358b7e1c893Smrg unsigned int se_coord_fmt; /* 0x1c50 */ 359b7e1c893Smrg 360b7e1c893Smrg /* Line state */ 361b7e1c893Smrg unsigned int re_line_pattern; /* 0x1cd0 */ 362b7e1c893Smrg unsigned int re_line_state; 363b7e1c893Smrg 364b7e1c893Smrg unsigned int se_line_width; /* 0x1db8 */ 365b7e1c893Smrg 366b7e1c893Smrg /* Bumpmap state */ 367b7e1c893Smrg unsigned int pp_lum_matrix; /* 0x1d00 */ 368b7e1c893Smrg 369b7e1c893Smrg unsigned int pp_rot_matrix_0; /* 0x1d58 */ 370b7e1c893Smrg unsigned int pp_rot_matrix_1; 371b7e1c893Smrg 372b7e1c893Smrg /* Mask state */ 373b7e1c893Smrg unsigned int rb3d_stencilrefmask; /* 0x1d7c */ 374b7e1c893Smrg unsigned int rb3d_ropcntl; 375b7e1c893Smrg unsigned int rb3d_planemask; 376b7e1c893Smrg 377b7e1c893Smrg /* Viewport state */ 378b7e1c893Smrg unsigned int se_vport_xscale; /* 0x1d98 */ 379b7e1c893Smrg unsigned int se_vport_xoffset; 380b7e1c893Smrg unsigned int se_vport_yscale; 381b7e1c893Smrg unsigned int se_vport_yoffset; 382b7e1c893Smrg unsigned int se_vport_zscale; 383b7e1c893Smrg unsigned int se_vport_zoffset; 384b7e1c893Smrg 385b7e1c893Smrg /* Setup state */ 386b7e1c893Smrg unsigned int se_cntl_status; /* 0x2140 */ 387b7e1c893Smrg 388b7e1c893Smrg /* Misc state */ 389b7e1c893Smrg unsigned int re_top_left; /* 0x26c0 */ 390b7e1c893Smrg unsigned int re_misc; 391b7e1c893Smrg} drm_radeon_context_regs_t; 392b7e1c893Smrg 393b7e1c893Smrgtypedef struct { 394b7e1c893Smrg /* Zbias state */ 395b7e1c893Smrg unsigned int se_zbias_factor; /* 0x1dac */ 396b7e1c893Smrg unsigned int se_zbias_constant; 397b7e1c893Smrg} drm_radeon_context2_regs_t; 398b7e1c893Smrg 399b7e1c893Smrg/* Setup registers for each texture unit 400b7e1c893Smrg */ 401b7e1c893Smrgtypedef struct { 402b7e1c893Smrg unsigned int pp_txfilter; 403b7e1c893Smrg unsigned int pp_txformat; 404b7e1c893Smrg unsigned int pp_txoffset; 405b7e1c893Smrg unsigned int pp_txcblend; 406b7e1c893Smrg unsigned int pp_txablend; 407b7e1c893Smrg unsigned int pp_tfactor; 408b7e1c893Smrg unsigned int pp_border_color; 409b7e1c893Smrg} drm_radeon_texture_regs_t; 410b7e1c893Smrg 411b7e1c893Smrgtypedef struct { 412b7e1c893Smrg unsigned int start; 413b7e1c893Smrg unsigned int finish; 414b7e1c893Smrg unsigned int prim:8; 415b7e1c893Smrg unsigned int stateidx:8; 416b7e1c893Smrg unsigned int numverts:16; /* overloaded as offset/64 for elt prims */ 417b7e1c893Smrg unsigned int vc_format; /* vertex format */ 418b7e1c893Smrg} drm_radeon_prim_t; 419b7e1c893Smrg 420b7e1c893Smrgtypedef struct { 421b7e1c893Smrg drm_radeon_context_regs_t context; 422b7e1c893Smrg drm_radeon_texture_regs_t tex[RADEON_MAX_TEXTURE_UNITS]; 423b7e1c893Smrg drm_radeon_context2_regs_t context2; 424b7e1c893Smrg unsigned int dirty; 425b7e1c893Smrg} drm_radeon_state_t; 426b7e1c893Smrg 427b7e1c893Smrgtypedef struct { 428b7e1c893Smrg /* The channel for communication of state information to the 429b7e1c893Smrg * kernel on firing a vertex buffer with either of the 430b7e1c893Smrg * obsoleted vertex/index ioctls. 431b7e1c893Smrg */ 432b7e1c893Smrg drm_radeon_context_regs_t context_state; 433b7e1c893Smrg drm_radeon_texture_regs_t tex_state[RADEON_MAX_TEXTURE_UNITS]; 434b7e1c893Smrg unsigned int dirty; 435b7e1c893Smrg unsigned int vertsize; 436b7e1c893Smrg unsigned int vc_format; 437b7e1c893Smrg 438b7e1c893Smrg /* The current cliprects, or a subset thereof. 439b7e1c893Smrg */ 440b7e1c893Smrg struct drm_clip_rect boxes[RADEON_NR_SAREA_CLIPRECTS]; 441b7e1c893Smrg unsigned int nbox; 442b7e1c893Smrg 443b7e1c893Smrg /* Counters for client-side throttling of rendering clients. 444b7e1c893Smrg */ 445b7e1c893Smrg unsigned int last_frame; 446b7e1c893Smrg unsigned int last_dispatch; 447b7e1c893Smrg unsigned int last_clear; 448b7e1c893Smrg 449b7e1c893Smrg struct drm_tex_region tex_list[RADEON_NR_TEX_HEAPS][RADEON_NR_TEX_REGIONS + 450b7e1c893Smrg 1]; 451b7e1c893Smrg unsigned int tex_age[RADEON_NR_TEX_HEAPS]; 452b7e1c893Smrg int ctx_owner; 453b7e1c893Smrg int pfState; /* number of 3d windows (0,1,2ormore) */ 454b7e1c893Smrg int pfCurrentPage; /* which buffer is being displayed? */ 455b7e1c893Smrg int crtc2_base; /* CRTC2 frame offset */ 456b7e1c893Smrg int tiling_enabled; /* set by drm, read by 2d + 3d clients */ 457b7e1c893Smrg} drm_radeon_sarea_t; 458b7e1c893Smrg 459b7e1c893Smrg/* WARNING: If you change any of these defines, make sure to change the 460b7e1c893Smrg * defines in the Xserver file (xf86drmRadeon.h) 461b7e1c893Smrg * 462b7e1c893Smrg * KW: actually it's illegal to change any of this (backwards compatibility). 463b7e1c893Smrg */ 464b7e1c893Smrg 465b7e1c893Smrg/* Radeon specific ioctls 466b7e1c893Smrg * The device specific ioctl range is 0x40 to 0x79. 467b7e1c893Smrg */ 468b7e1c893Smrg#define DRM_RADEON_CP_INIT 0x00 469b7e1c893Smrg#define DRM_RADEON_CP_START 0x01 470b7e1c893Smrg#define DRM_RADEON_CP_STOP 0x02 471b7e1c893Smrg#define DRM_RADEON_CP_RESET 0x03 472b7e1c893Smrg#define DRM_RADEON_CP_IDLE 0x04 473b7e1c893Smrg#define DRM_RADEON_RESET 0x05 474b7e1c893Smrg#define DRM_RADEON_FULLSCREEN 0x06 475b7e1c893Smrg#define DRM_RADEON_SWAP 0x07 476b7e1c893Smrg#define DRM_RADEON_CLEAR 0x08 477b7e1c893Smrg#define DRM_RADEON_VERTEX 0x09 478b7e1c893Smrg#define DRM_RADEON_INDICES 0x0A 479b7e1c893Smrg#define DRM_RADEON_NOT_USED 480b7e1c893Smrg#define DRM_RADEON_STIPPLE 0x0C 481b7e1c893Smrg#define DRM_RADEON_INDIRECT 0x0D 482b7e1c893Smrg#define DRM_RADEON_TEXTURE 0x0E 483b7e1c893Smrg#define DRM_RADEON_VERTEX2 0x0F 484b7e1c893Smrg#define DRM_RADEON_CMDBUF 0x10 485b7e1c893Smrg#define DRM_RADEON_GETPARAM 0x11 486b7e1c893Smrg#define DRM_RADEON_FLIP 0x12 487b7e1c893Smrg#define DRM_RADEON_ALLOC 0x13 488b7e1c893Smrg#define DRM_RADEON_FREE 0x14 489b7e1c893Smrg#define DRM_RADEON_INIT_HEAP 0x15 490b7e1c893Smrg#define DRM_RADEON_IRQ_EMIT 0x16 491b7e1c893Smrg#define DRM_RADEON_IRQ_WAIT 0x17 492b7e1c893Smrg#define DRM_RADEON_CP_RESUME 0x18 493b7e1c893Smrg#define DRM_RADEON_SETPARAM 0x19 494b7e1c893Smrg#define DRM_RADEON_SURF_ALLOC 0x1a 495b7e1c893Smrg#define DRM_RADEON_SURF_FREE 0x1b 496ad43ddacSmrg/* KMS ioctl */ 497ad43ddacSmrg#define DRM_RADEON_GEM_INFO 0x1c 498ad43ddacSmrg#define DRM_RADEON_GEM_CREATE 0x1d 499ad43ddacSmrg#define DRM_RADEON_GEM_MMAP 0x1e 500ad43ddacSmrg#define DRM_RADEON_GEM_PREAD 0x21 501ad43ddacSmrg#define DRM_RADEON_GEM_PWRITE 0x22 502ad43ddacSmrg#define DRM_RADEON_GEM_SET_DOMAIN 0x23 503ad43ddacSmrg#define DRM_RADEON_GEM_WAIT_IDLE 0x24 504ad43ddacSmrg#define DRM_RADEON_CS 0x26 505ad43ddacSmrg#define DRM_RADEON_INFO 0x27 506ad43ddacSmrg#define DRM_RADEON_GEM_SET_TILING 0x28 507ad43ddacSmrg#define DRM_RADEON_GEM_GET_TILING 0x29 508b7e1c893Smrg 509b7e1c893Smrg#define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t) 510b7e1c893Smrg#define DRM_IOCTL_RADEON_CP_START DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_START) 511b7e1c893Smrg#define DRM_IOCTL_RADEON_CP_STOP DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_STOP, drm_radeon_cp_stop_t) 512b7e1c893Smrg#define DRM_IOCTL_RADEON_CP_RESET DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_RESET) 513b7e1c893Smrg#define DRM_IOCTL_RADEON_CP_IDLE DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_IDLE) 514b7e1c893Smrg#define DRM_IOCTL_RADEON_RESET DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_RESET) 515b7e1c893Smrg#define DRM_IOCTL_RADEON_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_FULLSCREEN, drm_radeon_fullscreen_t) 516b7e1c893Smrg#define DRM_IOCTL_RADEON_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_SWAP) 517b7e1c893Smrg#define DRM_IOCTL_RADEON_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CLEAR, drm_radeon_clear_t) 518b7e1c893Smrg#define DRM_IOCTL_RADEON_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_VERTEX, drm_radeon_vertex_t) 519b7e1c893Smrg#define DRM_IOCTL_RADEON_INDICES DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_INDICES, drm_radeon_indices_t) 520b7e1c893Smrg#define DRM_IOCTL_RADEON_STIPPLE DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_STIPPLE, drm_radeon_stipple_t) 521b7e1c893Smrg#define DRM_IOCTL_RADEON_INDIRECT DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INDIRECT, drm_radeon_indirect_t) 522b7e1c893Smrg#define DRM_IOCTL_RADEON_TEXTURE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_TEXTURE, drm_radeon_texture_t) 523b7e1c893Smrg#define DRM_IOCTL_RADEON_VERTEX2 DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_VERTEX2, drm_radeon_vertex2_t) 524b7e1c893Smrg#define DRM_IOCTL_RADEON_CMDBUF DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CMDBUF, drm_radeon_cmd_buffer_t) 525b7e1c893Smrg#define DRM_IOCTL_RADEON_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GETPARAM, drm_radeon_getparam_t) 526b7e1c893Smrg#define DRM_IOCTL_RADEON_FLIP DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_FLIP) 527b7e1c893Smrg#define DRM_IOCTL_RADEON_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_ALLOC, drm_radeon_mem_alloc_t) 528b7e1c893Smrg#define DRM_IOCTL_RADEON_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_FREE, drm_radeon_mem_free_t) 529b7e1c893Smrg#define DRM_IOCTL_RADEON_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_INIT_HEAP, drm_radeon_mem_init_heap_t) 530b7e1c893Smrg#define DRM_IOCTL_RADEON_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_IRQ_EMIT, drm_radeon_irq_emit_t) 531b7e1c893Smrg#define DRM_IOCTL_RADEON_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_IRQ_WAIT, drm_radeon_irq_wait_t) 532b7e1c893Smrg#define DRM_IOCTL_RADEON_CP_RESUME DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_RESUME) 533b7e1c893Smrg#define DRM_IOCTL_RADEON_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SETPARAM, drm_radeon_setparam_t) 534b7e1c893Smrg#define DRM_IOCTL_RADEON_SURF_ALLOC DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_ALLOC, drm_radeon_surface_alloc_t) 535b7e1c893Smrg#define DRM_IOCTL_RADEON_SURF_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_SURF_FREE, drm_radeon_surface_free_t) 536ad43ddacSmrg/* KMS */ 537ad43ddacSmrg#define DRM_IOCTL_RADEON_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_INFO, struct drm_radeon_gem_info) 538ad43ddacSmrg#define DRM_IOCTL_RADEON_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_CREATE, struct drm_radeon_gem_create) 539ad43ddacSmrg#define DRM_IOCTL_RADEON_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_MMAP, struct drm_radeon_gem_mmap) 540ad43ddacSmrg#define DRM_IOCTL_RADEON_GEM_PREAD DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_PREAD, struct drm_radeon_gem_pread) 541ad43ddacSmrg#define DRM_IOCTL_RADEON_GEM_PWRITE DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_PWRITE, struct drm_radeon_gem_pwrite) 542ad43ddacSmrg#define DRM_IOCTL_RADEON_GEM_SET_DOMAIN DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_DOMAIN, struct drm_radeon_gem_set_domain) 543ad43ddacSmrg#define DRM_IOCTL_RADEON_GEM_WAIT_IDLE DRM_IOW(DRM_COMMAND_BASE + DRM_RADEON_GEM_WAIT_IDLE, struct drm_radeon_gem_wait_idle) 544ad43ddacSmrg#define DRM_IOCTL_RADEON_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_CS, struct drm_radeon_cs) 545ad43ddacSmrg#define DRM_IOCTL_RADEON_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INFO, struct drm_radeon_info) 546ad43ddacSmrg#define DRM_IOCTL_RADEON_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_TILING, struct drm_radeon_gem_set_tiling) 547ad43ddacSmrg#define DRM_IOCTL_RADEON_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_GET_TILING, struct drm_radeon_gem_get_tiling) 548b7e1c893Smrg 549b7e1c893Smrgtypedef struct drm_radeon_init { 550b7e1c893Smrg enum { 551b7e1c893Smrg RADEON_INIT_CP = 0x01, 552b7e1c893Smrg RADEON_CLEANUP_CP = 0x02, 553b7e1c893Smrg RADEON_INIT_R200_CP = 0x03, 554b7e1c893Smrg RADEON_INIT_R300_CP = 0x04, 555ad43ddacSmrg RADEON_INIT_R600_CP = 0x05 556b7e1c893Smrg } func; 557b7e1c893Smrg unsigned long sarea_priv_offset; 558b7e1c893Smrg int is_pci; /* for overriding only */ 559b7e1c893Smrg int cp_mode; 560b7e1c893Smrg int gart_size; 561b7e1c893Smrg int ring_size; 562b7e1c893Smrg int usec_timeout; 563b7e1c893Smrg 564b7e1c893Smrg unsigned int fb_bpp; 565b7e1c893Smrg unsigned int front_offset, front_pitch; 566b7e1c893Smrg unsigned int back_offset, back_pitch; 567b7e1c893Smrg unsigned int depth_bpp; 568b7e1c893Smrg unsigned int depth_offset, depth_pitch; 569b7e1c893Smrg 570b7e1c893Smrg /* DEPRECATED commented out below to allow for -Werror build */ 571b7e1c893Smrg unsigned long fb_offset; /* deprecated, driver asks hardware */ 572b7e1c893Smrg unsigned long mmio_offset; /* deprecated, driver asks hardware */ 573b7e1c893Smrg unsigned long ring_offset; 574b7e1c893Smrg unsigned long ring_rptr_offset; 575b7e1c893Smrg unsigned long buffers_offset; 576b7e1c893Smrg unsigned long gart_textures_offset; 577b7e1c893Smrg} drm_radeon_init_t; 578b7e1c893Smrg 579b7e1c893Smrgtypedef struct drm_radeon_cp_stop { 580b7e1c893Smrg int flush; 581b7e1c893Smrg int idle; 582b7e1c893Smrg} drm_radeon_cp_stop_t; 583b7e1c893Smrg 584b7e1c893Smrgtypedef struct drm_radeon_fullscreen { 585b7e1c893Smrg enum { 586b7e1c893Smrg RADEON_INIT_FULLSCREEN = 0x01, 587b7e1c893Smrg RADEON_CLEANUP_FULLSCREEN = 0x02 588b7e1c893Smrg } func; 589b7e1c893Smrg} drm_radeon_fullscreen_t; 590b7e1c893Smrg 591b7e1c893Smrg#define CLEAR_X1 0 592b7e1c893Smrg#define CLEAR_Y1 1 593b7e1c893Smrg#define CLEAR_X2 2 594b7e1c893Smrg#define CLEAR_Y2 3 595b7e1c893Smrg#define CLEAR_DEPTH 4 596b7e1c893Smrg 597b7e1c893Smrgtypedef union drm_radeon_clear_rect { 598b7e1c893Smrg float f[5]; 599b7e1c893Smrg unsigned int ui[5]; 600b7e1c893Smrg} drm_radeon_clear_rect_t; 601b7e1c893Smrg 602b7e1c893Smrgtypedef struct drm_radeon_clear { 603b7e1c893Smrg unsigned int flags; 604b7e1c893Smrg unsigned int clear_color; 605b7e1c893Smrg unsigned int clear_depth; 606b7e1c893Smrg unsigned int color_mask; 607b7e1c893Smrg unsigned int depth_mask; /* misnamed field: should be stencil */ 608b7e1c893Smrg drm_radeon_clear_rect_t *depth_boxes; 609b7e1c893Smrg} drm_radeon_clear_t; 610b7e1c893Smrg 611b7e1c893Smrgtypedef struct drm_radeon_vertex { 612b7e1c893Smrg int prim; 613b7e1c893Smrg int idx; /* Index of vertex buffer */ 614b7e1c893Smrg int count; /* Number of vertices in buffer */ 615b7e1c893Smrg int discard; /* Client finished with buffer? */ 616b7e1c893Smrg} drm_radeon_vertex_t; 617b7e1c893Smrg 618b7e1c893Smrgtypedef struct drm_radeon_indices { 619b7e1c893Smrg int prim; 620b7e1c893Smrg int idx; 621b7e1c893Smrg int start; 622b7e1c893Smrg int end; 623b7e1c893Smrg int discard; /* Client finished with buffer? */ 624b7e1c893Smrg} drm_radeon_indices_t; 625b7e1c893Smrg 626b7e1c893Smrg/* v1.2 - obsoletes drm_radeon_vertex and drm_radeon_indices 627b7e1c893Smrg * - allows multiple primitives and state changes in a single ioctl 628b7e1c893Smrg * - supports driver change to emit native primitives 629b7e1c893Smrg */ 630b7e1c893Smrgtypedef struct drm_radeon_vertex2 { 631b7e1c893Smrg int idx; /* Index of vertex buffer */ 632b7e1c893Smrg int discard; /* Client finished with buffer? */ 633b7e1c893Smrg int nr_states; 634b7e1c893Smrg drm_radeon_state_t *state; 635b7e1c893Smrg int nr_prims; 636b7e1c893Smrg drm_radeon_prim_t *prim; 637b7e1c893Smrg} drm_radeon_vertex2_t; 638b7e1c893Smrg 639b7e1c893Smrg/* v1.3 - obsoletes drm_radeon_vertex2 640b7e1c893Smrg * - allows arbitarily large cliprect list 641b7e1c893Smrg * - allows updating of tcl packet, vector and scalar state 642b7e1c893Smrg * - allows memory-efficient description of state updates 643b7e1c893Smrg * - allows state to be emitted without a primitive 644b7e1c893Smrg * (for clears, ctx switches) 645b7e1c893Smrg * - allows more than one dma buffer to be referenced per ioctl 646b7e1c893Smrg * - supports tcl driver 647b7e1c893Smrg * - may be extended in future versions with new cmd types, packets 648b7e1c893Smrg */ 649b7e1c893Smrgtypedef struct drm_radeon_cmd_buffer { 650b7e1c893Smrg int bufsz; 651b7e1c893Smrg char *buf; 652b7e1c893Smrg int nbox; 653b7e1c893Smrg struct drm_clip_rect *boxes; 654b7e1c893Smrg} drm_radeon_cmd_buffer_t; 655b7e1c893Smrg 656b7e1c893Smrgtypedef struct drm_radeon_tex_image { 657b7e1c893Smrg unsigned int x, y; /* Blit coordinates */ 658b7e1c893Smrg unsigned int width, height; 659b7e1c893Smrg const void *data; 660b7e1c893Smrg} drm_radeon_tex_image_t; 661b7e1c893Smrg 662b7e1c893Smrgtypedef struct drm_radeon_texture { 663b7e1c893Smrg unsigned int offset; 664b7e1c893Smrg int pitch; 665b7e1c893Smrg int format; 666b7e1c893Smrg int width; /* Texture image coordinates */ 667b7e1c893Smrg int height; 668b7e1c893Smrg drm_radeon_tex_image_t *image; 669b7e1c893Smrg} drm_radeon_texture_t; 670b7e1c893Smrg 671b7e1c893Smrgtypedef struct drm_radeon_stipple { 672b7e1c893Smrg unsigned int *mask; 673b7e1c893Smrg} drm_radeon_stipple_t; 674b7e1c893Smrg 675b7e1c893Smrgtypedef struct drm_radeon_indirect { 676b7e1c893Smrg int idx; 677b7e1c893Smrg int start; 678b7e1c893Smrg int end; 679b7e1c893Smrg int discard; 680b7e1c893Smrg} drm_radeon_indirect_t; 681b7e1c893Smrg 682b7e1c893Smrg#define RADEON_INDIRECT_DISCARD (1 << 0) 683b7e1c893Smrg#define RADEON_INDIRECT_NOFLUSH (1 << 1) 684b7e1c893Smrg 685b7e1c893Smrg/* enum for card type parameters */ 686b7e1c893Smrg#define RADEON_CARD_PCI 0 687b7e1c893Smrg#define RADEON_CARD_AGP 1 688b7e1c893Smrg#define RADEON_CARD_PCIE 2 689b7e1c893Smrg 690b7e1c893Smrg/* 1.3: An ioctl to get parameters that aren't available to the 3d 691b7e1c893Smrg * client any other way. 692b7e1c893Smrg */ 693b7e1c893Smrg#define RADEON_PARAM_GART_BUFFER_OFFSET 1 /* card offset of 1st GART buffer */ 694b7e1c893Smrg#define RADEON_PARAM_LAST_FRAME 2 695b7e1c893Smrg#define RADEON_PARAM_LAST_DISPATCH 3 696b7e1c893Smrg#define RADEON_PARAM_LAST_CLEAR 4 697b7e1c893Smrg/* Added with DRM version 1.6. */ 698b7e1c893Smrg#define RADEON_PARAM_IRQ_NR 5 699b7e1c893Smrg#define RADEON_PARAM_GART_BASE 6 /* card offset of GART base */ 700b7e1c893Smrg/* Added with DRM version 1.8. */ 701b7e1c893Smrg#define RADEON_PARAM_REGISTER_HANDLE 7 /* for drmMap() */ 702b7e1c893Smrg#define RADEON_PARAM_STATUS_HANDLE 8 703b7e1c893Smrg#define RADEON_PARAM_SAREA_HANDLE 9 704b7e1c893Smrg#define RADEON_PARAM_GART_TEX_HANDLE 10 705b7e1c893Smrg#define RADEON_PARAM_SCRATCH_OFFSET 11 706b7e1c893Smrg#define RADEON_PARAM_CARD_TYPE 12 707b7e1c893Smrg#define RADEON_PARAM_VBLANK_CRTC 13 /* VBLANK CRTC */ 708b7e1c893Smrg#define RADEON_PARAM_FB_LOCATION 14 /* FB location */ 709b7e1c893Smrg#define RADEON_PARAM_NUM_GB_PIPES 15 /* num GB pipes */ 710b7e1c893Smrg 711b7e1c893Smrgtypedef struct drm_radeon_getparam { 712b7e1c893Smrg int param; 713b7e1c893Smrg void *value; 714b7e1c893Smrg} drm_radeon_getparam_t; 715b7e1c893Smrg 716b7e1c893Smrg/* 1.6: Set up a memory manager for regions of shared memory: 717b7e1c893Smrg */ 718b7e1c893Smrg#define RADEON_MEM_REGION_GART 1 719b7e1c893Smrg#define RADEON_MEM_REGION_FB 2 720b7e1c893Smrg 721b7e1c893Smrgtypedef struct drm_radeon_mem_alloc { 722b7e1c893Smrg int region; 723b7e1c893Smrg int alignment; 724b7e1c893Smrg int size; 725b7e1c893Smrg int *region_offset; /* offset from start of fb or GART */ 726b7e1c893Smrg} drm_radeon_mem_alloc_t; 727b7e1c893Smrg 728b7e1c893Smrgtypedef struct drm_radeon_mem_free { 729b7e1c893Smrg int region; 730b7e1c893Smrg int region_offset; 731b7e1c893Smrg} drm_radeon_mem_free_t; 732b7e1c893Smrg 733b7e1c893Smrgtypedef struct drm_radeon_mem_init_heap { 734b7e1c893Smrg int region; 735b7e1c893Smrg int size; 736b7e1c893Smrg int start; 737b7e1c893Smrg} drm_radeon_mem_init_heap_t; 738b7e1c893Smrg 739b7e1c893Smrg/* 1.6: Userspace can request & wait on irq's: 740b7e1c893Smrg */ 741b7e1c893Smrgtypedef struct drm_radeon_irq_emit { 742b7e1c893Smrg int *irq_seq; 743b7e1c893Smrg} drm_radeon_irq_emit_t; 744b7e1c893Smrg 745b7e1c893Smrgtypedef struct drm_radeon_irq_wait { 746b7e1c893Smrg int irq_seq; 747b7e1c893Smrg} drm_radeon_irq_wait_t; 748b7e1c893Smrg 749b7e1c893Smrg/* 1.10: Clients tell the DRM where they think the framebuffer is located in 750b7e1c893Smrg * the card's address space, via a new generic ioctl to set parameters 751b7e1c893Smrg */ 752b7e1c893Smrg 753b7e1c893Smrgtypedef struct drm_radeon_setparam { 754b7e1c893Smrg unsigned int param; 755b7e1c893Smrg int64_t value; 756b7e1c893Smrg} drm_radeon_setparam_t; 757b7e1c893Smrg 758b7e1c893Smrg#define RADEON_SETPARAM_FB_LOCATION 1 /* determined framebuffer location */ 759b7e1c893Smrg#define RADEON_SETPARAM_SWITCH_TILING 2 /* enable/disable color tiling */ 760b7e1c893Smrg#define RADEON_SETPARAM_PCIGART_LOCATION 3 /* PCI Gart Location */ 761b7e1c893Smrg 762b7e1c893Smrg#define RADEON_SETPARAM_NEW_MEMMAP 4 /* Use new memory map */ 763b7e1c893Smrg#define RADEON_SETPARAM_PCIGART_TABLE_SIZE 5 /* PCI GART Table Size */ 764b7e1c893Smrg#define RADEON_SETPARAM_VBLANK_CRTC 6 /* VBLANK CRTC */ 765b7e1c893Smrg/* 1.14: Clients can allocate/free a surface 766b7e1c893Smrg */ 767b7e1c893Smrgtypedef struct drm_radeon_surface_alloc { 768b7e1c893Smrg unsigned int address; 769b7e1c893Smrg unsigned int size; 770b7e1c893Smrg unsigned int flags; 771b7e1c893Smrg} drm_radeon_surface_alloc_t; 772b7e1c893Smrg 773b7e1c893Smrgtypedef struct drm_radeon_surface_free { 774b7e1c893Smrg unsigned int address; 775b7e1c893Smrg} drm_radeon_surface_free_t; 776b7e1c893Smrg 777b7e1c893Smrg#define DRM_RADEON_VBLANK_CRTC1 1 778b7e1c893Smrg#define DRM_RADEON_VBLANK_CRTC2 2 779b7e1c893Smrg 780ad43ddacSmrg/* 781ad43ddacSmrg * Kernel modesetting world below. 782ad43ddacSmrg */ 783ad43ddacSmrg#define RADEON_GEM_DOMAIN_CPU 0x1 784ad43ddacSmrg#define RADEON_GEM_DOMAIN_GTT 0x2 785ad43ddacSmrg#define RADEON_GEM_DOMAIN_VRAM 0x4 786ad43ddacSmrg 787ad43ddacSmrgstruct drm_radeon_gem_info { 788ad43ddacSmrg uint64_t gart_size; 789ad43ddacSmrg uint64_t vram_size; 790ad43ddacSmrg uint64_t vram_visible; 791ad43ddacSmrg}; 792ad43ddacSmrg 793ad43ddacSmrg#define RADEON_GEM_NO_BACKING_STORE 1 794ad43ddacSmrg 795ad43ddacSmrgstruct drm_radeon_gem_create { 796ad43ddacSmrg uint64_t size; 797ad43ddacSmrg uint64_t alignment; 798ad43ddacSmrg uint32_t handle; 799ad43ddacSmrg uint32_t initial_domain; 800ad43ddacSmrg uint32_t flags; 801ad43ddacSmrg}; 802ad43ddacSmrg 80340732134Srjs#define RADEON_TILING_MACRO 0x1 80440732134Srjs#define RADEON_TILING_MICRO 0x2 80540732134Srjs#define RADEON_TILING_SWAP_16BIT 0x4 80640732134Srjs#define RADEON_TILING_SWAP_32BIT 0x8 80740732134Srjs/* this object requires a surface when mapped - i.e. front buffer */ 80840732134Srjs#define RADEON_TILING_SURFACE 0x10 80940732134Srjs#define RADEON_TILING_MICRO_SQUARE 0x20 81040732134Srjs#define RADEON_TILING_EG_BANKW_SHIFT 8 81140732134Srjs#define RADEON_TILING_EG_BANKW_MASK 0xf 81240732134Srjs#define RADEON_TILING_EG_BANKH_SHIFT 12 81340732134Srjs#define RADEON_TILING_EG_BANKH_MASK 0xf 81440732134Srjs#define RADEON_TILING_EG_MACRO_TILE_ASPECT_SHIFT 16 81540732134Srjs#define RADEON_TILING_EG_MACRO_TILE_ASPECT_MASK 0xf 81640732134Srjs#define RADEON_TILING_EG_TILE_SPLIT_SHIFT 24 81740732134Srjs#define RADEON_TILING_EG_TILE_SPLIT_MASK 0xf 81840732134Srjs#define RADEON_TILING_EG_STENCIL_TILE_SPLIT_SHIFT 28 81940732134Srjs#define RADEON_TILING_EG_STENCIL_TILE_SPLIT_MASK 0xf 820ad43ddacSmrg 821ad43ddacSmrgstruct drm_radeon_gem_set_tiling { 822ad43ddacSmrg uint32_t handle; 823ad43ddacSmrg uint32_t tiling_flags; 824ad43ddacSmrg uint32_t pitch; 825ad43ddacSmrg}; 826ad43ddacSmrg 827ad43ddacSmrgstruct drm_radeon_gem_get_tiling { 828ad43ddacSmrg uint32_t handle; 829ad43ddacSmrg uint32_t tiling_flags; 830ad43ddacSmrg uint32_t pitch; 831ad43ddacSmrg}; 832ad43ddacSmrg 833ad43ddacSmrgstruct drm_radeon_gem_mmap { 834ad43ddacSmrg uint32_t handle; 835ad43ddacSmrg uint32_t pad; 836ad43ddacSmrg uint64_t offset; 837ad43ddacSmrg uint64_t size; 838ad43ddacSmrg uint64_t addr_ptr; 839ad43ddacSmrg}; 840ad43ddacSmrg 841ad43ddacSmrgstruct drm_radeon_gem_set_domain { 842ad43ddacSmrg uint32_t handle; 843ad43ddacSmrg uint32_t read_domains; 844ad43ddacSmrg uint32_t write_domain; 845ad43ddacSmrg}; 846ad43ddacSmrg 847ad43ddacSmrgstruct drm_radeon_gem_wait_idle { 848ad43ddacSmrg uint32_t handle; 849ad43ddacSmrg uint32_t pad; 850ad43ddacSmrg}; 851ad43ddacSmrg 852ad43ddacSmrgstruct drm_radeon_gem_busy { 853ad43ddacSmrg uint32_t handle; 854ad43ddacSmrg uint32_t busy; 855ad43ddacSmrg}; 856ad43ddacSmrg 857ad43ddacSmrgstruct drm_radeon_gem_pread { 858ad43ddacSmrg /** Handle for the object being read. */ 859ad43ddacSmrg uint32_t handle; 860ad43ddacSmrg uint32_t pad; 861ad43ddacSmrg /** Offset into the object to read from */ 862ad43ddacSmrg uint64_t offset; 863ad43ddacSmrg /** Length of data to read */ 864ad43ddacSmrg uint64_t size; 865ad43ddacSmrg /** Pointer to write the data into. */ 866ad43ddacSmrg /* void *, but pointers are not 32/64 compatible */ 867ad43ddacSmrg uint64_t data_ptr; 868ad43ddacSmrg}; 869ad43ddacSmrg 870ad43ddacSmrgstruct drm_radeon_gem_pwrite { 871ad43ddacSmrg /** Handle for the object being written to. */ 872ad43ddacSmrg uint32_t handle; 873ad43ddacSmrg uint32_t pad; 874ad43ddacSmrg /** Offset into the object to write to */ 875ad43ddacSmrg uint64_t offset; 876ad43ddacSmrg /** Length of data to write */ 877ad43ddacSmrg uint64_t size; 878ad43ddacSmrg /** Pointer to read the data from. */ 879ad43ddacSmrg /* void *, but pointers are not 32/64 compatible */ 880ad43ddacSmrg uint64_t data_ptr; 881ad43ddacSmrg}; 882ad43ddacSmrg 883ad43ddacSmrg#define RADEON_CHUNK_ID_RELOCS 0x01 884ad43ddacSmrg#define RADEON_CHUNK_ID_IB 0x02 885ad43ddacSmrg 886ad43ddacSmrgstruct drm_radeon_cs_chunk { 887ad43ddacSmrg uint32_t chunk_id; 888ad43ddacSmrg uint32_t length_dw; 889ad43ddacSmrg uint64_t chunk_data; 890ad43ddacSmrg}; 891ad43ddacSmrg 892ad43ddacSmrgstruct drm_radeon_cs_reloc { 893ad43ddacSmrg uint32_t handle; 894ad43ddacSmrg uint32_t read_domains; 895ad43ddacSmrg uint32_t write_domain; 896ad43ddacSmrg uint32_t flags; 897ad43ddacSmrg}; 898ad43ddacSmrg 899ad43ddacSmrgstruct drm_radeon_cs { 900ad43ddacSmrg uint32_t num_chunks; 901ad43ddacSmrg uint32_t cs_id; 902ad43ddacSmrg /* this points to uint64_t * which point to cs chunks */ 903ad43ddacSmrg uint64_t chunks; 904ad43ddacSmrg /* updates to the limits after this CS ioctl */ 905ad43ddacSmrg uint64_t gart_limit; 906ad43ddacSmrg uint64_t vram_limit; 907ad43ddacSmrg}; 908ad43ddacSmrg 909ad43ddacSmrg#define RADEON_INFO_DEVICE_ID 0x00 910ad43ddacSmrg#define RADEON_INFO_NUM_GB_PIPES 0x01 911ad43ddacSmrg 912ad43ddacSmrgstruct drm_radeon_info { 913ad43ddacSmrg uint32_t request; 914ad43ddacSmrg uint32_t pad; 915ad43ddacSmrg uint64_t value; 916ad43ddacSmrg}; 917ad43ddacSmrg 918b7e1c893Smrg#endif 919