1/* $NetBSD: r128_drm.h,v 1.2 2021/12/18 23:45:46 riastradh Exp $ */ 2 3/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*- 4 * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com 5 */ 6/* 7 * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. 8 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 9 * All rights reserved. 10 * 11 * Permission is hereby granted, free of charge, to any person obtaining a 12 * copy of this software and associated documentation files (the "Software"), 13 * to deal in the Software without restriction, including without limitation 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 * and/or sell copies of the Software, and to permit persons to whom the 16 * Software is furnished to do so, subject to the following conditions: 17 * 18 * The above copyright notice and this permission notice (including the next 19 * paragraph) shall be included in all copies or substantial portions of the 20 * Software. 21 * 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 25 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 28 * DEALINGS IN THE SOFTWARE. 29 * 30 * Authors: 31 * Gareth Hughes <gareth@valinux.com> 32 * Kevin E. Martin <martin@valinux.com> 33 */ 34 35#ifndef __R128_DRM_H__ 36#define __R128_DRM_H__ 37 38#include "drm.h" 39 40#if defined(__cplusplus) 41extern "C" { 42#endif 43 44/* WARNING: If you change any of these defines, make sure to change the 45 * defines in the X server file (r128_sarea.h) 46 */ 47#ifndef __R128_SAREA_DEFINES__ 48#define __R128_SAREA_DEFINES__ 49 50/* What needs to be changed for the current vertex buffer? 51 */ 52#define R128_UPLOAD_CONTEXT 0x001 53#define R128_UPLOAD_SETUP 0x002 54#define R128_UPLOAD_TEX0 0x004 55#define R128_UPLOAD_TEX1 0x008 56#define R128_UPLOAD_TEX0IMAGES 0x010 57#define R128_UPLOAD_TEX1IMAGES 0x020 58#define R128_UPLOAD_CORE 0x040 59#define R128_UPLOAD_MASKS 0x080 60#define R128_UPLOAD_WINDOW 0x100 61#define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */ 62#define R128_REQUIRE_QUIESCENCE 0x400 63#define R128_UPLOAD_ALL 0x7ff 64 65#define R128_FRONT 0x1 66#define R128_BACK 0x2 67#define R128_DEPTH 0x4 68 69/* Primitive types 70 */ 71#define R128_POINTS 0x1 72#define R128_LINES 0x2 73#define R128_LINE_STRIP 0x3 74#define R128_TRIANGLES 0x4 75#define R128_TRIANGLE_FAN 0x5 76#define R128_TRIANGLE_STRIP 0x6 77 78/* Vertex/indirect buffer size 79 */ 80#define R128_BUFFER_SIZE 16384 81 82/* Byte offsets for indirect buffer data 83 */ 84#define R128_INDEX_PRIM_OFFSET 20 85#define R128_HOSTDATA_BLIT_OFFSET 32 86 87/* Keep these small for testing. 88 */ 89#define R128_NR_SAREA_CLIPRECTS 12 90 91/* There are 2 heaps (local/AGP). Each region within a heap is a 92 * minimum of 64k, and there are at most 64 of them per heap. 93 */ 94#define R128_LOCAL_TEX_HEAP 0 95#define R128_AGP_TEX_HEAP 1 96#define R128_NR_TEX_HEAPS 2 97#define R128_NR_TEX_REGIONS 64 98#define R128_LOG_TEX_GRANULARITY 16 99 100#define R128_NR_CONTEXT_REGS 12 101 102#define R128_MAX_TEXTURE_LEVELS 11 103#define R128_MAX_TEXTURE_UNITS 2 104 105#endif /* __R128_SAREA_DEFINES__ */ 106 107typedef struct { 108 /* Context state - can be written in one large chunk */ 109 unsigned int dst_pitch_offset_c; 110 unsigned int dp_gui_master_cntl_c; 111 unsigned int sc_top_left_c; 112 unsigned int sc_bottom_right_c; 113 unsigned int z_offset_c; 114 unsigned int z_pitch_c; 115 unsigned int z_sten_cntl_c; 116 unsigned int tex_cntl_c; 117 unsigned int misc_3d_state_cntl_reg; 118 unsigned int texture_clr_cmp_clr_c; 119 unsigned int texture_clr_cmp_msk_c; 120 unsigned int fog_color_c; 121 122 /* Texture state */ 123 unsigned int tex_size_pitch_c; 124 unsigned int constant_color_c; 125 126 /* Setup state */ 127 unsigned int pm4_vc_fpu_setup; 128 unsigned int setup_cntl; 129 130 /* Mask state */ 131 unsigned int dp_write_mask; 132 unsigned int sten_ref_mask_c; 133 unsigned int plane_3d_mask_c; 134 135 /* Window state */ 136 unsigned int window_xy_offset; 137 138 /* Core state */ 139 unsigned int scale_3d_cntl; 140} drm_r128_context_regs_t; 141 142/* Setup registers for each texture unit 143 */ 144typedef struct { 145 unsigned int tex_cntl; 146 unsigned int tex_combine_cntl; 147 unsigned int tex_size_pitch; 148 unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS]; 149 unsigned int tex_border_color; 150} drm_r128_texture_regs_t; 151 152typedef struct drm_r128_sarea { 153 /* The channel for communication of state information to the kernel 154 * on firing a vertex buffer. 155 */ 156 drm_r128_context_regs_t context_state; 157 drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS]; 158 unsigned int dirty; 159 unsigned int vertsize; 160 unsigned int vc_format; 161 162 /* The current cliprects, or a subset thereof. 163 */ 164 struct drm_clip_rect boxes[R128_NR_SAREA_CLIPRECTS]; 165 unsigned int nbox; 166 167 /* Counters for client-side throttling of rendering clients. 168 */ 169 unsigned int last_frame; 170 unsigned int last_dispatch; 171 172 struct drm_tex_region tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS + 1]; 173 unsigned int tex_age[R128_NR_TEX_HEAPS]; 174 int ctx_owner; 175 int pfAllowPageFlip; /* number of 3d windows (0,1,2 or more) */ 176 int pfCurrentPage; /* which buffer is being displayed? */ 177} drm_r128_sarea_t; 178 179/* WARNING: If you change any of these defines, make sure to change the 180 * defines in the Xserver file (xf86drmR128.h) 181 */ 182 183/* Rage 128 specific ioctls 184 * The device specific ioctl range is 0x40 to 0x79. 185 */ 186#define DRM_R128_INIT 0x00 187#define DRM_R128_CCE_START 0x01 188#define DRM_R128_CCE_STOP 0x02 189#define DRM_R128_CCE_RESET 0x03 190#define DRM_R128_CCE_IDLE 0x04 191/* 0x05 not used */ 192#define DRM_R128_RESET 0x06 193#define DRM_R128_SWAP 0x07 194#define DRM_R128_CLEAR 0x08 195#define DRM_R128_VERTEX 0x09 196#define DRM_R128_INDICES 0x0a 197#define DRM_R128_BLIT 0x0b 198#define DRM_R128_DEPTH 0x0c 199#define DRM_R128_STIPPLE 0x0d 200/* 0x0e not used */ 201#define DRM_R128_INDIRECT 0x0f 202#define DRM_R128_FULLSCREEN 0x10 203#define DRM_R128_CLEAR2 0x11 204#define DRM_R128_GETPARAM 0x12 205#define DRM_R128_FLIP 0x13 206 207#define DRM_IOCTL_R128_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INIT, drm_r128_init_t) 208#define DRM_IOCTL_R128_CCE_START DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_START) 209#define DRM_IOCTL_R128_CCE_STOP DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CCE_STOP, drm_r128_cce_stop_t) 210#define DRM_IOCTL_R128_CCE_RESET DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_RESET) 211#define DRM_IOCTL_R128_CCE_IDLE DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_IDLE) 212/* 0x05 not used */ 213#define DRM_IOCTL_R128_RESET DRM_IO( DRM_COMMAND_BASE + DRM_R128_RESET) 214#define DRM_IOCTL_R128_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_R128_SWAP) 215#define DRM_IOCTL_R128_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR, drm_r128_clear_t) 216#define DRM_IOCTL_R128_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_R128_VERTEX, drm_r128_vertex_t) 217#define DRM_IOCTL_R128_INDICES DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INDICES, drm_r128_indices_t) 218#define DRM_IOCTL_R128_BLIT DRM_IOW( DRM_COMMAND_BASE + DRM_R128_BLIT, drm_r128_blit_t) 219#define DRM_IOCTL_R128_DEPTH DRM_IOW( DRM_COMMAND_BASE + DRM_R128_DEPTH, drm_r128_depth_t) 220#define DRM_IOCTL_R128_STIPPLE DRM_IOW( DRM_COMMAND_BASE + DRM_R128_STIPPLE, drm_r128_stipple_t) 221/* 0x0e not used */ 222#define DRM_IOCTL_R128_INDIRECT DRM_IOWR(DRM_COMMAND_BASE + DRM_R128_INDIRECT, drm_r128_indirect_t) 223#define DRM_IOCTL_R128_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + DRM_R128_FULLSCREEN, drm_r128_fullscreen_t) 224#define DRM_IOCTL_R128_CLEAR2 DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR2, drm_r128_clear2_t) 225#define DRM_IOCTL_R128_GETPARAM DRM_IOWR( DRM_COMMAND_BASE + DRM_R128_GETPARAM, drm_r128_getparam_t) 226#define DRM_IOCTL_R128_FLIP DRM_IO( DRM_COMMAND_BASE + DRM_R128_FLIP) 227 228typedef struct drm_r128_init { 229 enum { 230 R128_INIT_CCE = 0x01, 231 R128_CLEANUP_CCE = 0x02 232 } func; 233 unsigned long sarea_priv_offset; 234 int is_pci; 235 int cce_mode; 236 int cce_secure; 237 int ring_size; 238 int usec_timeout; 239 240 unsigned int fb_bpp; 241 unsigned int front_offset, front_pitch; 242 unsigned int back_offset, back_pitch; 243 unsigned int depth_bpp; 244 unsigned int depth_offset, depth_pitch; 245 unsigned int span_offset; 246 247 unsigned long fb_offset; 248 unsigned long mmio_offset; 249 unsigned long ring_offset; 250 unsigned long ring_rptr_offset; 251 unsigned long buffers_offset; 252 unsigned long agp_textures_offset; 253} drm_r128_init_t; 254 255typedef struct drm_r128_cce_stop { 256 int flush; 257 int idle; 258} drm_r128_cce_stop_t; 259 260typedef struct drm_r128_clear { 261 unsigned int flags; 262 unsigned int clear_color; 263 unsigned int clear_depth; 264 unsigned int color_mask; 265 unsigned int depth_mask; 266} drm_r128_clear_t; 267 268typedef struct drm_r128_vertex { 269 int prim; 270 int idx; /* Index of vertex buffer */ 271 int count; /* Number of vertices in buffer */ 272 int discard; /* Client finished with buffer? */ 273} drm_r128_vertex_t; 274 275typedef struct drm_r128_indices { 276 int prim; 277 int idx; 278 int start; 279 int end; 280 int discard; /* Client finished with buffer? */ 281} drm_r128_indices_t; 282 283typedef struct drm_r128_blit { 284 int idx; 285 int pitch; 286 int offset; 287 int format; 288 unsigned short x, y; 289 unsigned short width, height; 290} drm_r128_blit_t; 291 292typedef struct drm_r128_depth { 293 enum { 294 R128_WRITE_SPAN = 0x01, 295 R128_WRITE_PIXELS = 0x02, 296 R128_READ_SPAN = 0x03, 297 R128_READ_PIXELS = 0x04 298 } func; 299 int n; 300 int __user *x; 301 int __user *y; 302 unsigned int __user *buffer; 303 unsigned char __user *mask; 304} drm_r128_depth_t; 305 306typedef struct drm_r128_stipple { 307 unsigned int __user *mask; 308} drm_r128_stipple_t; 309 310typedef struct drm_r128_indirect { 311 int idx; 312 int start; 313 int end; 314 int discard; 315} drm_r128_indirect_t; 316 317typedef struct drm_r128_fullscreen { 318 enum { 319 R128_INIT_FULLSCREEN = 0x01, 320 R128_CLEANUP_FULLSCREEN = 0x02 321 } func; 322} drm_r128_fullscreen_t; 323 324/* 2.3: An ioctl to get parameters that aren't available to the 3d 325 * client any other way. 326 */ 327#define R128_PARAM_IRQ_NR 1 328 329typedef struct drm_r128_getparam { 330 int param; 331 void __user *value; 332} drm_r128_getparam_t; 333 334#if defined(__cplusplus) 335} 336#endif 337 338#endif 339