]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/drm/r128_drm.h
Remove drm_linux.h, move the two useful defines into drm_drv.h. Use fd locking
[FreeBSD/FreeBSD.git] / sys / dev / drm / 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$
32  */
33
34 #ifndef __R128_DRM_H__
35 #define __R128_DRM_H__
36
37 /* WARNING: If you change any of these defines, make sure to change the
38  * defines in the X server file (r128_sarea.h)
39  */
40 #ifndef __R128_SAREA_DEFINES__
41 #define __R128_SAREA_DEFINES__
42
43 /* What needs to be changed for the current vertex buffer?
44  */
45 #define R128_UPLOAD_CONTEXT             0x001
46 #define R128_UPLOAD_SETUP               0x002
47 #define R128_UPLOAD_TEX0                0x004
48 #define R128_UPLOAD_TEX1                0x008
49 #define R128_UPLOAD_TEX0IMAGES          0x010
50 #define R128_UPLOAD_TEX1IMAGES          0x020
51 #define R128_UPLOAD_CORE                0x040
52 #define R128_UPLOAD_MASKS               0x080
53 #define R128_UPLOAD_WINDOW              0x100
54 #define R128_UPLOAD_CLIPRECTS           0x200   /* handled client-side */
55 #define R128_REQUIRE_QUIESCENCE         0x400
56 #define R128_UPLOAD_ALL                 0x7ff
57
58 #define R128_FRONT                      0x1
59 #define R128_BACK                       0x2
60 #define R128_DEPTH                      0x4
61
62 /* Primitive types
63  */
64 #define R128_POINTS                     0x1
65 #define R128_LINES                      0x2
66 #define R128_LINE_STRIP                 0x3
67 #define R128_TRIANGLES                  0x4
68 #define R128_TRIANGLE_FAN               0x5
69 #define R128_TRIANGLE_STRIP             0x6
70
71 /* Vertex/indirect buffer size
72  */
73 #define R128_BUFFER_SIZE                16384
74
75 /* Byte offsets for indirect buffer data
76  */
77 #define R128_INDEX_PRIM_OFFSET          20
78 #define R128_HOSTDATA_BLIT_OFFSET       32
79
80 /* Keep these small for testing.
81  */
82 #define R128_NR_SAREA_CLIPRECTS         12
83
84 /* There are 2 heaps (local/AGP).  Each region within a heap is a
85  *  minimum of 64k, and there are at most 64 of them per heap.
86  */
87 #define R128_LOCAL_TEX_HEAP             0
88 #define R128_AGP_TEX_HEAP               1
89 #define R128_NR_TEX_HEAPS               2
90 #define R128_NR_TEX_REGIONS             64
91 #define R128_LOG_TEX_GRANULARITY        16
92
93 #define R128_NR_CONTEXT_REGS            12
94
95 #define R128_MAX_TEXTURE_LEVELS         11
96 #define R128_MAX_TEXTURE_UNITS          2
97
98 #endif /* __R128_SAREA_DEFINES__ */
99
100 typedef struct {
101         /* Context state - can be written in one large chunk */
102         unsigned int dst_pitch_offset_c;
103         unsigned int dp_gui_master_cntl_c;
104         unsigned int sc_top_left_c;
105         unsigned int sc_bottom_right_c;
106         unsigned int z_offset_c;
107         unsigned int z_pitch_c;
108         unsigned int z_sten_cntl_c;
109         unsigned int tex_cntl_c;
110         unsigned int misc_3d_state_cntl_reg;
111         unsigned int texture_clr_cmp_clr_c;
112         unsigned int texture_clr_cmp_msk_c;
113         unsigned int fog_color_c;
114
115         /* Texture state */
116         unsigned int tex_size_pitch_c;
117         unsigned int constant_color_c;
118
119         /* Setup state */
120         unsigned int pm4_vc_fpu_setup;
121         unsigned int setup_cntl;
122
123         /* Mask state */
124         unsigned int dp_write_mask;
125         unsigned int sten_ref_mask_c;
126         unsigned int plane_3d_mask_c;
127
128         /* Window state */
129         unsigned int window_xy_offset;
130
131         /* Core state */
132         unsigned int scale_3d_cntl;
133 } drm_r128_context_regs_t;
134
135 /* Setup registers for each texture unit
136  */
137 typedef struct {
138         unsigned int tex_cntl;
139         unsigned int tex_combine_cntl;
140         unsigned int tex_size_pitch;
141         unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
142         unsigned int tex_border_color;
143 } drm_r128_texture_regs_t;
144
145
146 typedef struct drm_r128_sarea {
147         /* The channel for communication of state information to the kernel
148          * on firing a vertex buffer.
149          */
150         drm_r128_context_regs_t context_state;
151         drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS];
152         unsigned int dirty;
153         unsigned int vertsize;
154         unsigned int vc_format;
155
156         /* The current cliprects, or a subset thereof.
157          */
158         drm_clip_rect_t boxes[R128_NR_SAREA_CLIPRECTS];
159         unsigned int nbox;
160
161         /* Counters for client-side throttling of rendering clients.
162          */
163         unsigned int last_frame;
164         unsigned int last_dispatch;
165
166         drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
167         int tex_age[R128_NR_TEX_HEAPS];
168         int ctx_owner;
169 } drm_r128_sarea_t;
170
171
172 /* WARNING: If you change any of these defines, make sure to change the
173  * defines in the Xserver file (xf86drmR128.h)
174  */
175
176 /* Rage 128 specific ioctls */
177 #define DRM_IOCTL_R128_INIT             DRM_IOW( 0x40, drm_r128_init_t)
178 #define DRM_IOCTL_R128_CCE_START        DRM_IO(  0x41)
179 #define DRM_IOCTL_R128_CCE_STOP         DRM_IOW( 0x42, drm_r128_cce_stop_t)
180 #define DRM_IOCTL_R128_CCE_RESET        DRM_IO(  0x43)
181 #define DRM_IOCTL_R128_CCE_IDLE         DRM_IO(  0x44)
182 #define DRM_IOCTL_R128_RESET            DRM_IO(  0x46)
183 #define DRM_IOCTL_R128_SWAP             DRM_IO(  0x47)
184 #define DRM_IOCTL_R128_CLEAR            DRM_IOW( 0x48, drm_r128_clear_t)
185 #define DRM_IOCTL_R128_VERTEX           DRM_IOW( 0x49, drm_r128_vertex_t)
186 #define DRM_IOCTL_R128_INDICES          DRM_IOW( 0x4a, drm_r128_indices_t)
187 #define DRM_IOCTL_R128_BLIT             DRM_IOW( 0x4b, drm_r128_blit_t)
188 #define DRM_IOCTL_R128_DEPTH            DRM_IOW( 0x4c, drm_r128_depth_t)
189 #define DRM_IOCTL_R128_STIPPLE          DRM_IOW( 0x4d, drm_r128_stipple_t)
190 #define DRM_IOCTL_R128_INDIRECT         DRM_IOWR(0x4f, drm_r128_indirect_t)
191 #define DRM_IOCTL_R128_FULLSCREEN       DRM_IOW( 0x50, drm_r128_fullscreen_t)
192
193 typedef struct drm_r128_init {
194         enum {
195                 R128_INIT_CCE    = 0x01,
196                 R128_CLEANUP_CCE = 0x02
197         } func;
198 #if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
199         int sarea_priv_offset;
200 #else
201         unsigned long sarea_priv_offset;
202 #endif
203         int is_pci;
204         int cce_mode;
205         int cce_secure;
206         int ring_size;
207         int usec_timeout;
208
209         unsigned int fb_bpp;
210         unsigned int front_offset, front_pitch;
211         unsigned int back_offset, back_pitch;
212         unsigned int depth_bpp;
213         unsigned int depth_offset, depth_pitch;
214         unsigned int span_offset;
215
216 #if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
217         unsigned int fb_offset;
218         unsigned int mmio_offset;
219         unsigned int ring_offset;
220         unsigned int ring_rptr_offset;
221         unsigned int buffers_offset;
222         unsigned int agp_textures_offset;
223 #else
224         unsigned long fb_offset;
225         unsigned long mmio_offset;
226         unsigned long ring_offset;
227         unsigned long ring_rptr_offset;
228         unsigned long buffers_offset;
229         unsigned long agp_textures_offset;
230 #endif
231 } drm_r128_init_t;
232
233 typedef struct drm_r128_cce_stop {
234         int flush;
235         int idle;
236 } drm_r128_cce_stop_t;
237
238 typedef struct drm_r128_clear {
239         unsigned int flags;
240 #if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4,1,0,0)
241         int x, y, w, h;
242 #endif
243         unsigned int clear_color;
244         unsigned int clear_depth;
245 #if CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4,1,0,0)
246         unsigned int color_mask;
247         unsigned int depth_mask;
248 #endif
249 } drm_r128_clear_t;
250
251 typedef struct drm_r128_vertex {
252         int prim;
253         int idx;                        /* Index of vertex buffer */
254         int count;                      /* Number of vertices in buffer */
255         int discard;                    /* Client finished with buffer? */
256 } drm_r128_vertex_t;
257
258 typedef struct drm_r128_indices {
259         int prim;
260         int idx;
261         int start;
262         int end;
263         int discard;                    /* Client finished with buffer? */
264 } drm_r128_indices_t;
265
266 typedef struct drm_r128_blit {
267         int idx;
268         int pitch;
269         int offset;
270         int format;
271         unsigned short x, y;
272         unsigned short width, height;
273 } drm_r128_blit_t;
274
275 typedef struct drm_r128_depth {
276         enum {
277                 R128_WRITE_SPAN         = 0x01,
278                 R128_WRITE_PIXELS       = 0x02,
279                 R128_READ_SPAN          = 0x03,
280                 R128_READ_PIXELS        = 0x04
281         } func;
282         int n;
283         int *x;
284         int *y;
285         unsigned int *buffer;
286         unsigned char *mask;
287 } drm_r128_depth_t;
288
289 typedef struct drm_r128_stipple {
290         unsigned int *mask;
291 } drm_r128_stipple_t;
292
293 typedef struct drm_r128_indirect {
294         int idx;
295         int start;
296         int end;
297         int discard;
298 } drm_r128_indirect_t;
299
300 typedef struct drm_r128_fullscreen {
301         enum {
302                 R128_INIT_FULLSCREEN    = 0x01,
303                 R128_CLEANUP_FULLSCREEN = 0x02
304         } func;
305 } drm_r128_fullscreen_t;
306
307 #endif