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