1 /* i810_drv.h -- Private header for the Matrox g200/g400 driver -*- linux-c -*-
2  * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
3  *
4  * Copyright 1999 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: Rickard E. (Rik) Faith <faith@valinux.com>
28  * 	    Jeff Hartmann <jhartmann@valinux.com>
29  *
30  */
31 
32 #ifndef _I810_DRV_H_
33 #define _I810_DRV_H_
34 
35 typedef struct drm_i810_buf_priv {
36    	u32 *in_use;
37    	int my_use_idx;
38 	int currently_mapped;
39 	void *virtual;
40 	void *kernel_virtual;
41 	int map_count;
42    	struct vm_area_struct *vma;
43 } drm_i810_buf_priv_t;
44 
45 typedef struct _drm_i810_ring_buffer{
46 	int tail_mask;
47 	unsigned long Start;
48 	unsigned long End;
49 	unsigned long Size;
50 	u8 *virtual_start;
51 	int head;
52 	int tail;
53 	int space;
54 } drm_i810_ring_buffer_t;
55 
56 typedef struct drm_i810_private {
57    	int ring_map_idx;
58    	int buffer_map_idx;
59 
60    	drm_i810_ring_buffer_t ring;
61 	drm_i810_sarea_t *sarea_priv;
62 
63       	unsigned long hw_status_page;
64    	unsigned long counter;
65 
66    	atomic_t flush_done;
67    	wait_queue_head_t flush_queue;	/* Processes waiting until flush    */
68 	drm_buf_t *mmap_buffer;
69 
70 
71 	u32 front_di1, back_di1, zi1;
72 
73 	int back_offset;
74 	int depth_offset;
75 	int w, h;
76 	int pitch;
77 } drm_i810_private_t;
78 
79 				/* i810_drv.c */
80 extern int  i810_version(struct inode *inode, struct file *filp,
81 			  unsigned int cmd, unsigned long arg);
82 extern int  i810_open(struct inode *inode, struct file *filp);
83 extern int  i810_release(struct inode *inode, struct file *filp);
84 extern int  i810_ioctl(struct inode *inode, struct file *filp,
85 			unsigned int cmd, unsigned long arg);
86 extern int  i810_unlock(struct inode *inode, struct file *filp,
87 			 unsigned int cmd, unsigned long arg);
88 
89 				/* i810_dma.c */
90 extern int  i810_dma_schedule(drm_device_t *dev, int locked);
91 extern int  i810_getbuf(struct inode *inode, struct file *filp,
92 			unsigned int cmd, unsigned long arg);
93 extern int  i810_irq_install(drm_device_t *dev, int irq);
94 extern int  i810_irq_uninstall(drm_device_t *dev);
95 extern int  i810_control(struct inode *inode, struct file *filp,
96 			  unsigned int cmd, unsigned long arg);
97 extern int  i810_lock(struct inode *inode, struct file *filp,
98 		       unsigned int cmd, unsigned long arg);
99 extern int  i810_dma_init(struct inode *inode, struct file *filp,
100 			  unsigned int cmd, unsigned long arg);
101 extern int  i810_flush_ioctl(struct inode *inode, struct file *filp,
102 			     unsigned int cmd, unsigned long arg);
103 extern void i810_reclaim_buffers(drm_device_t *dev, pid_t pid);
104 extern int  i810_getage(struct inode *inode, struct file *filp, unsigned int cmd,
105 			unsigned long arg);
106 extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
107 extern int i810_copybuf(struct inode *inode, struct file *filp,
108 			unsigned int cmd, unsigned long arg);
109 extern int i810_docopy(struct inode *inode, struct file *filp,
110 		       unsigned int cmd, unsigned long arg);
111 
112 				/* i810_bufs.c */
113 extern int  i810_addbufs(struct inode *inode, struct file *filp,
114 			unsigned int cmd, unsigned long arg);
115 extern int  i810_infobufs(struct inode *inode, struct file *filp,
116 			 unsigned int cmd, unsigned long arg);
117 extern int  i810_markbufs(struct inode *inode, struct file *filp,
118 			 unsigned int cmd, unsigned long arg);
119 extern int  i810_freebufs(struct inode *inode, struct file *filp,
120 			 unsigned int cmd, unsigned long arg);
121 extern int  i810_addmap(struct inode *inode, struct file *filp,
122 		       unsigned int cmd, unsigned long arg);
123 
124 				/* i810_context.c */
125 extern int  i810_resctx(struct inode *inode, struct file *filp,
126 		       unsigned int cmd, unsigned long arg);
127 extern int  i810_addctx(struct inode *inode, struct file *filp,
128 		       unsigned int cmd, unsigned long arg);
129 extern int  i810_modctx(struct inode *inode, struct file *filp,
130 		       unsigned int cmd, unsigned long arg);
131 extern int  i810_getctx(struct inode *inode, struct file *filp,
132 		       unsigned int cmd, unsigned long arg);
133 extern int  i810_switchctx(struct inode *inode, struct file *filp,
134 			  unsigned int cmd, unsigned long arg);
135 extern int  i810_newctx(struct inode *inode, struct file *filp,
136 		       unsigned int cmd, unsigned long arg);
137 extern int  i810_rmctx(struct inode *inode, struct file *filp,
138 		      unsigned int cmd, unsigned long arg);
139 
140 extern int  i810_context_switch(drm_device_t *dev, int old, int new);
141 extern int  i810_context_switch_complete(drm_device_t *dev, int new);
142 
143 #define I810_VERBOSE 0
144 
145 
146 int i810_dma_vertex(struct inode *inode, struct file *filp,
147 		    unsigned int cmd, unsigned long arg);
148 
149 int i810_swap_bufs(struct inode *inode, struct file *filp,
150 		   unsigned int cmd, unsigned long arg);
151 
152 int i810_clear_bufs(struct inode *inode, struct file *filp,
153 		    unsigned int cmd, unsigned long arg);
154 
155 #define GFX_OP_USER_INTERRUPT 		((0<<29)|(2<<23))
156 #define GFX_OP_BREAKPOINT_INTERRUPT	((0<<29)|(1<<23))
157 #define CMD_REPORT_HEAD			(7<<23)
158 #define CMD_STORE_DWORD_IDX		((0x21<<23) | 0x1)
159 #define CMD_OP_BATCH_BUFFER  ((0x0<<29)|(0x30<<23)|0x1)
160 
161 #define INST_PARSER_CLIENT   0x00000000
162 #define INST_OP_FLUSH        0x02000000
163 #define INST_FLUSH_MAP_CACHE 0x00000001
164 
165 
166 #define BB1_START_ADDR_MASK   (~0x7)
167 #define BB1_PROTECTED         (1<<0)
168 #define BB1_UNPROTECTED       (0<<0)
169 #define BB2_END_ADDR_MASK     (~0x7)
170 
171 #define I810REG_HWSTAM		0x02098
172 #define I810REG_INT_IDENTITY_R	0x020a4
173 #define I810REG_INT_MASK_R 	0x020a8
174 #define I810REG_INT_ENABLE_R	0x020a0
175 
176 #define LP_RING     		0x2030
177 #define HP_RING     		0x2040
178 #define RING_TAIL      		0x00
179 #define TAIL_ADDR		0x000FFFF8
180 #define RING_HEAD      		0x04
181 #define HEAD_WRAP_COUNT     	0xFFE00000
182 #define HEAD_WRAP_ONE       	0x00200000
183 #define HEAD_ADDR           	0x001FFFFC
184 #define RING_START     		0x08
185 #define START_ADDR          	0x00FFFFF8
186 #define RING_LEN       		0x0C
187 #define RING_NR_PAGES       	0x000FF000
188 #define RING_REPORT_MASK    	0x00000006
189 #define RING_REPORT_64K     	0x00000002
190 #define RING_REPORT_128K    	0x00000004
191 #define RING_NO_REPORT      	0x00000000
192 #define RING_VALID_MASK     	0x00000001
193 #define RING_VALID          	0x00000001
194 #define RING_INVALID        	0x00000000
195 
196 #define GFX_OP_SCISSOR         ((0x3<<29)|(0x1c<<24)|(0x10<<19))
197 #define SC_UPDATE_SCISSOR       (0x1<<1)
198 #define SC_ENABLE_MASK          (0x1<<0)
199 #define SC_ENABLE               (0x1<<0)
200 
201 #define GFX_OP_SCISSOR_INFO    ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
202 #define SCI_YMIN_MASK      (0xffff<<16)
203 #define SCI_XMIN_MASK      (0xffff<<0)
204 #define SCI_YMAX_MASK      (0xffff<<16)
205 #define SCI_XMAX_MASK      (0xffff<<0)
206 
207 #define GFX_OP_COLOR_FACTOR      ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
208 #define GFX_OP_STIPPLE           ((0x3<<29)|(0x1d<<24)|(0x83<<16))
209 #define GFX_OP_MAP_INFO          ((0x3<<29)|(0x1d<<24)|0x2)
210 #define GFX_OP_DESTBUFFER_VARS   ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
211 #define GFX_OP_DRAWRECT_INFO     ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
212 #define GFX_OP_PRIMITIVE         ((0x3<<29)|(0x1f<<24))
213 
214 #define CMD_OP_Z_BUFFER_INFO     ((0x0<<29)|(0x16<<23))
215 #define CMD_OP_DESTBUFFER_INFO   ((0x0<<29)|(0x15<<23))
216 
217 #define BR00_BITBLT_CLIENT   0x40000000
218 #define BR00_OP_COLOR_BLT    0x10000000
219 #define BR00_OP_SRC_COPY_BLT 0x10C00000
220 #define BR13_SOLID_PATTERN   0x80000000
221 
222 
223 
224 #endif
225 
226