file mga_drm.h was initially added on branch mga-0-0-2-branch.
[platform/upstream/libdrm.git] / linux / mga_drm_public.h
1 /* mga_drm_public.h -- Public header for the Matrox g200/g400 driver -*- linux-c -*-
2  * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
3  *
4  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5  * All rights reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  * 
14  * The above copyright notice and this permission notice (including the next
15  * paragraph) shall be included in all copies or substantial portions of the
16  * Software.
17  * 
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  *
26  * Authors: Jeff Hartmann <jhartmann@precisioninsight.com>
27  *          Keith Whitwell <keithw@precisioninsight.com>
28  *
29  * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm_public.h,v 1.1 2000/02/11 17:26:07 dawes Exp $
30  */
31
32 #ifndef _MGA_DRM_PUBLIC_H_
33 #define _MGA_DRM_PUBLIC_H_
34
35 #define MGA_F  0x1              /* fog */
36 #define MGA_A  0x2              /* alpha */
37 #define MGA_S  0x4              /* specular */
38 #define MGA_T2 0x8              /* multitexture */
39
40 #define MGA_WARP_TGZ            0
41 #define MGA_WARP_TGZF           (MGA_F)
42 #define MGA_WARP_TGZA           (MGA_A)
43 #define MGA_WARP_TGZAF          (MGA_F|MGA_A)
44 #define MGA_WARP_TGZS           (MGA_S)
45 #define MGA_WARP_TGZSF          (MGA_S|MGA_F)
46 #define MGA_WARP_TGZSA          (MGA_S|MGA_A)
47 #define MGA_WARP_TGZSAF         (MGA_S|MGA_F|MGA_A)
48 #define MGA_WARP_T2GZ           (MGA_T2)
49 #define MGA_WARP_T2GZF          (MGA_T2|MGA_F)
50 #define MGA_WARP_T2GZA          (MGA_T2|MGA_A)
51 #define MGA_WARP_T2GZAF         (MGA_T2|MGA_A|MGA_F)
52 #define MGA_WARP_T2GZS          (MGA_T2|MGA_S)
53 #define MGA_WARP_T2GZSF         (MGA_T2|MGA_S|MGA_F)
54 #define MGA_WARP_T2GZSA         (MGA_T2|MGA_S|MGA_A)
55 #define MGA_WARP_T2GZSAF        (MGA_T2|MGA_S|MGA_F|MGA_A)
56
57
58 #define MGA_MAX_G400_PIPES 16
59 #define MGA_MAX_G200_PIPES  8   /* no multitex */
60
61
62 #define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
63
64 #define MGA_CARD_TYPE_G200 1
65 #define MGA_CARD_TYPE_G400 2
66
67
68 typedef struct _drm_mga_warp_index {
69         int installed;
70         unsigned long phys_addr;
71         int size;
72 } mgaWarpIndex;
73
74 typedef struct drm_mga_init {
75         enum { 
76                 MGA_INIT_DMA = 0x01,
77                 MGA_CLEANUP_DMA = 0x02
78         } func;
79         int reserved_map_agpstart;
80         int reserved_map_idx;
81         int buffer_map_idx;
82         int sarea_priv_offset;
83         int primary_size;
84         int warp_ucode_size;
85         int fbOffset;
86         int backOffset;
87         int depthOffset;
88         int textureOffset;
89         int textureSize;
90         int cpp;
91         int stride;
92         int sgram;
93         int chipset;
94         mgaWarpIndex WarpIndex[MGA_MAX_WARP_PIPES];
95
96         /* Redundant?
97          */
98         int frontOrg;
99         int backOrg;
100         int depthOrg;
101         int mAccess;
102 } drm_mga_init_t;
103
104 typedef struct _xf86drmClipRectRec {
105         unsigned short x1;
106         unsigned short y1;
107         unsigned short x2;
108         unsigned short y2;
109 } xf86drmClipRectRec;
110
111 #define MGA_CLEAR_FRONT 0x1
112 #define MGA_CLEAR_BACK  0x2
113 #define MGA_CLEAR_DEPTH 0x4
114
115
116 /* Each context has a state:
117  */
118 #define MGA_CTXREG_DSTORG   0   /* validated */
119 #define MGA_CTXREG_MACCESS  1   
120 #define MGA_CTXREG_PLNWT    2   
121 #define MGA_CTXREG_DWGCTL    3  
122 #define MGA_CTXREG_ALPHACTRL 4
123 #define MGA_CTXREG_FOGCOLOR  5
124 #define MGA_CTXREG_WFLAG     6
125 #define MGA_CTXREG_TDUAL0    7
126 #define MGA_CTXREG_TDUAL1    8
127 #define MGA_CTX_SETUP_SIZE   9
128
129 /* 2d state
130  */
131 #define MGA_2DREG_PITCH         0
132 #define MGA_2D_SETUP_SIZE       1
133
134 /* Each texture unit has a state:
135  */
136 #define MGA_TEXREG_CTL        0
137 #define MGA_TEXREG_CTL2       1
138 #define MGA_TEXREG_FILTER     2
139 #define MGA_TEXREG_BORDERCOL  3
140 #define MGA_TEXREG_ORG        4 /* validated */
141 #define MGA_TEXREG_ORG1       5
142 #define MGA_TEXREG_ORG2       6
143 #define MGA_TEXREG_ORG3       7
144 #define MGA_TEXREG_ORG4       8
145 #define MGA_TEXREG_WIDTH      9
146 #define MGA_TEXREG_HEIGHT     10
147 #define MGA_TEX_SETUP_SIZE    11
148
149
150 /* What needs to be changed for the current vertex dma buffer?
151  */
152 #define MGASAREA_NEW_CONTEXT    0x1
153 #define MGASAREA_NEW_TEX0       0x2
154 #define MGASAREA_NEW_TEX1       0x4
155 #define MGASAREA_NEW_PIPE       0x8
156 #define MGASAREA_NEW_2D         0x10
157
158
159 /* Keep this small for testing
160  */
161 #define MGA_NR_SAREA_CLIPRECTS 2
162
163 /* Upto 128 regions.  Minimum region size of 256k.
164  */
165 #define MGA_NR_TEX_REGIONS 128
166 #define MGA_MIN_LOG_TEX_GRANULARITY 18
167
168 typedef struct {
169    unsigned char next, prev;    
170    unsigned char in_use;        
171    int age;                     
172 } mgaTexRegion;
173
174 typedef struct 
175 {
176         unsigned int ContextState[MGA_CTX_SETUP_SIZE];
177         unsigned int ServerState[MGA_2D_SETUP_SIZE];
178         unsigned int TexState[2][MGA_TEX_SETUP_SIZE];
179         unsigned int WarpPipe;
180         unsigned int dirty;
181
182         unsigned int nbox;
183         xf86drmClipRectRec boxes[MGA_NR_SAREA_CLIPRECTS];
184
185         /* kernel doesn't touch from here down */
186         int ctxOwner;           
187         mgaTexRegion texList[MGA_NR_TEX_REGIONS+1];
188         int texAge;                                 
189 } drm_mga_sarea_t;      
190
191
192 /* Device specific ioctls:
193  */
194 typedef struct {
195         int clear_color;
196         int clear_depth;
197         int flags;
198 } drm_mga_clear_t;
199
200
201 typedef struct {
202         int flags;              /* not actually used? */
203 } drm_mga_swap_t;
204
205 typedef struct {
206         unsigned int destOrg;
207         unsigned int mAccess;
208         unsigned int pitch;
209         xf86drmClipRectRec texture;
210         int idx;
211 } drm_mga_iload_t;
212
213
214 #define DRM_IOCTL_MGA_INIT    DRM_IOW( 0x40, drm_mga_init_t)
215 #define DRM_IOCTL_MGA_SWAP    DRM_IOW( 0x41, drm_mga_swap_t)
216 #define DRM_IOCTL_MGA_CLEAR   DRM_IOW( 0x42, drm_mga_clear_t)
217 #define DRM_IOCTL_MGA_ILOAD   DRM_IOW( 0x43, drm_mga_iload_t)
218 #endif