4 * changed by zsteva Aug/Sep 2001, see vo_3dfx.c
6 * Copyright (C) Colin Cross Apr 2000
8 * mpeg2dec is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * mpeg2dec is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with mpeg2dec; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #define VOODOO_IO_REG_OFFSET ((unsigned long int)0x0000000)
25 #define VOODOO_YUV_REG_OFFSET ((unsigned long int)0x0080100)
26 #define VOODOO_AGP_REG_OFFSET ((unsigned long int)0x0080000)
27 #define VOODOO_2D_REG_OFFSET ((unsigned long int)0x0100000)
28 #define VOODOO_YUV_PLANE_OFFSET ((unsigned long int)0x0C00000)
30 #define VOODOO_BLT_FORMAT_YUYV (8<<16)
31 #define VOODOO_BLT_FORMAT_UYVY (9<<16)
32 #define VOODOO_BLT_FORMAT_16 (3<<16)
33 #define VOODOO_BLT_FORMAT_24 (4<<16)
34 #define VOODOO_BLT_FORMAT_32 (5<<16)
36 #define VOODOO_YUV_STRIDE (1024>>2)
38 struct voodoo_yuv_fb_t
{
39 uint32_t Y
[0x0040000];
40 uint32_t U
[0x0040000];
41 uint32_t V
[0x0040000];
44 struct voodoo_yuv_reg_t
{
49 struct voodoo_2d_reg_t
{
56 uint32_t srcColorkeyMin
;
57 uint32_t srcColorkeyMax
;
58 uint32_t dstColorkeyMin
;
59 uint32_t dstColorkeyMax
;
60 signed long bresError0
;
61 signed long bresError1
;
64 uint32_t commandExtra
;
67 uint32_t pattern0Alias
;
68 uint32_t pattern1Alias
;;
82 uint8_t launchArea
[128];
86 struct voodoo_io_reg_t
{
90 uint32_t lfbMemoryConfig
;
111 uint32_t rgbMaxDelta
;
113 uint32_t hwCurPatAddr
;
117 uint32_t vidInFormat
;
118 uint32_t vidInStatus
;
119 uint32_t vidSerialParallelPort
;
120 uint32_t vidInXDecimDeltas
;
121 uint32_t vidInDecimInitErrs
;
122 uint32_t vidInYDecimDeltas
;
123 uint32_t vidPixelBufThold
;
124 uint32_t vidChromaMin
;
125 uint32_t vidChromaMax
;
126 uint32_t vidCurrentLine
;
127 uint32_t vidScreenSize
;
128 uint32_t vidOverlayStartCoords
;
129 uint32_t vidOverlayEndScreenCoord
;
130 uint32_t vidOverlayDudx
;
131 uint32_t vidOverlayDudxOffsetSrcWidth
;
132 uint32_t vidOverlayDvdy
;
134 uint32_t vga_registers_not_mem_mapped
[12];
135 uint32_t vidOverlayDvdyOffset
;
136 uint32_t vidDesktopStartAddr
;
137 uint32_t vidDesktopOverlayStride
;
141 uint32_t vidInStride
;
142 uint32_t vidCurrOverlayStartAddr
;
153 typedef struct pioData_t pioData
;
154 typedef struct voodoo_2d_reg_t voodoo_2d_reg
;
155 typedef struct voodoo_io_reg_t voodoo_io_reg
;
156 typedef struct voodoo_yuv_reg_t voodoo_yuv_reg
;
157 typedef struct voodoo_yuv_fb_t voodoo_yuv_fb
;
160 /* from linux/driver/video/tdfxfb.c, definition for 3dfx registers.
162 * author: Hannu Mallat <hmallat@cc.hut.fi>
165 #ifndef PCI_DEVICE_ID_3DFX_VOODOO5
166 #define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
169 /* membase0 register offsets */
171 #define PCIINIT0 0x04
172 #define SIPMONITOR 0x08
173 #define LFBMEMORYCONFIG 0x0c
174 #define MISCINIT0 0x10
175 #define MISCINIT1 0x14
176 #define DRAMINIT0 0x18
177 #define DRAMINIT1 0x1c
179 #define TMUGBEINIT 0x24
180 #define VGAINIT0 0x28
181 #define VGAINIT1 0x2c
182 #define DRAMCOMMAND 0x30
183 #define DRAMDATA 0x34
186 #define PLLCTRL0 0x40
187 #define PLLCTRL1 0x44
188 #define PLLCTRL2 0x48
192 #define RGBMAXDELTA 0x58
193 #define VIDPROCCFG 0x5c
194 #define HWCURPATADDR 0x60
195 #define HWCURLOC 0x64
198 #define VIDINFORMAT 0x70
199 #define VIDINSTATUS 0x74
200 #define VIDSERPARPORT 0x78
201 #define VIDINXDELTA 0x7c
202 #define VIDININITERR 0x80
203 #define VIDINYDELTA 0x84
204 #define VIDPIXBUFTHOLD 0x88
205 #define VIDCHRMIN 0x8c
206 #define VIDCHRMAX 0x90
207 #define VIDCURLIN 0x94
208 #define VIDSCREENSIZE 0x98
209 #define VIDOVRSTARTCRD 0x9c
210 #define VIDOVRENDCRD 0xa0
211 #define VIDOVRDUDX 0xa4
212 #define VIDOVRDUDXOFF 0xa8
213 #define VIDOVRDVDY 0xac
215 #define VIDOVRDVDYOFF 0xe0
216 #define VIDDESKSTART 0xe4
217 #define VIDDESKSTRIDE 0xe8
218 #define VIDINADDR0 0xec
219 #define VIDINADDR1 0xf0
220 #define VIDINADDR2 0xf4
221 #define VIDINSTRIDE 0xf8
222 #define VIDCUROVRSTART 0xfc
224 #define INTCTRL (0x00100000 + 0x04)
225 #define CLIP0MIN (0x00100000 + 0x08)
226 #define CLIP0MAX (0x00100000 + 0x0c)
227 #define DSTBASE (0x00100000 + 0x10)
228 #define DSTFORMAT (0x00100000 + 0x14)
229 #define SRCCOLORKEYMIN (0x00100000 + 0x18)
230 #define SRCCOLORKEYMAX (0x00100000 + 0x1c)
231 #define DSTCOLORKEYMIN (0x00100000 + 0x20)
232 #define DSTCOLORKEYMAX (0x00100000 + 0x24)
233 #define ROP123 (0x00100000 + 0x30)
234 #define SRCBASE (0x00100000 + 0x34)
235 #define COMMANDEXTRA_2D (0x00100000 + 0x38)
236 #define CLIP1MIN (0x00100000 + 0x4c)
237 #define CLIP1MAX (0x00100000 + 0x50)
238 #define SRCFORMAT (0x00100000 + 0x54)
239 #define SRCSIZE (0x00100000 + 0x58)
240 #define SRCXY (0x00100000 + 0x5c)
241 #define COLORBACK (0x00100000 + 0x60)
242 #define COLORFORE (0x00100000 + 0x64)
243 #define DSTSIZE (0x00100000 + 0x68)
244 #define DSTXY (0x00100000 + 0x6c)
245 #define COMMAND_2D (0x00100000 + 0x70)
246 #define LAUNCH_2D (0x00100000 + 0x80)
248 #define COMMAND_3D (0x00200000 + 0x120)
250 #define SWAPBUFCMD (0x00200000 + 0x128)
251 #define SWAPPENDING (0x00200000 + 0x24C)
252 #define LEFTOVBUF (0x00200000 + 0x250)
253 #define RIGHTOVBUF (0x00200000 + 0x254)
254 #define FBISWAPBUFHIST (0x00200000 + 0x258)
256 /* register bitfields (not all, only as needed) */
258 #define BIT(x) (1UL << (x))
260 /* COMMAND_2D reg. values */
261 #define ROP_COPY 0xcc // src
262 #define ROP_INVERT 0x55 // NOT dst
263 #define ROP_XOR 0x66 // src XOR dst
264 #define ROP_OR (0xee) /* src | dst */
266 #define AUTOINC_DSTX BIT(10)
267 #define AUTOINC_DSTY BIT(11)
270 #define COMMAND_2D_S2S_BITBLT 0x01 // screen to screen
271 #define COMMAND_2D_S2S_STRECH_BLT 0x02 // BLT + Strech
272 #define COMMAND_2D_H2S_BITBLT 0x03 // host to screen
273 #define COMMAND_2D_FILLRECT 0x05
275 #define COMMAND_2D_DO_IMMED BIT(8) // Do it immediatly
279 #define COMMAND_3D_NOP 0x00
280 #define STATUS_RETRACE BIT(6)
281 #define STATUS_BUSY BIT(9)
282 #define MISCINIT1_CLUT_INV BIT(0)
283 #define MISCINIT1_2DBLOCK_DIS BIT(15)
284 #define DRAMINIT0_SGRAM_NUM BIT(26)
285 #define DRAMINIT0_SGRAM_TYPE BIT(27)
286 #define DRAMINIT1_MEM_SDRAM BIT(30)
287 #define VGAINIT0_VGA_DISABLE BIT(0)
288 #define VGAINIT0_EXT_TIMING BIT(1)
289 #define VGAINIT0_8BIT_DAC BIT(2)
290 #define VGAINIT0_EXT_ENABLE BIT(6)
291 #define VGAINIT0_WAKEUP_3C3 BIT(8)
292 #define VGAINIT0_LEGACY_DISABLE BIT(9)
293 #define VGAINIT0_ALT_READBACK BIT(10)
294 #define VGAINIT0_FAST_BLINK BIT(11)
295 #define VGAINIT0_EXTSHIFTOUT BIT(12)
296 #define VGAINIT0_DECODE_3C6 BIT(13)
297 #define VGAINIT0_SGRAM_HBLANK_DISABLE BIT(22)
298 #define VGAINIT1_MASK 0x1fffff
299 #define VIDCFG_VIDPROC_ENABLE BIT(0)
300 #define VIDCFG_CURS_X11 BIT(1)
301 #define VIDCFG_HALF_MODE BIT(4)
302 #define VIDCFG_DESK_ENABLE BIT(7)
303 #define VIDCFG_CLUT_BYPASS BIT(10)
304 #define VIDCFG_2X BIT(26)
305 #define VIDCFG_HWCURSOR_ENABLE BIT(27)
306 #define VIDCFG_PIXFMT_SHIFT 18
307 #define DACMODE_2X BIT(0)
310 #define AGPREQSIZE (0x0080000 + 0x00)
311 #define AGPHOSTADDRESSLOW (0x0080000 + 0x04)
312 #define AGPHOSTADDRESSHIGH (0x0080000 + 0x08)
313 #define AGPGRAPHICSADDRESS (0x0080000 + 0x0C)
314 #define AGPGRAPHICSSTRIDE (0x0080000 + 0x10)
315 #define AGPMOVECMD (0x0080000 + 0x14)
318 #define CMDBASEADDR0 (0x0080000 + 0x20)
319 #define CMDBASESIZE0 (0x0080000 + 0x24)
320 #define CMDBUMP0 (0x0080000 + 0x28)
321 #define CMDRDPTRL0 (0x0080000 + 0x2C)
322 #define CMDRDPTRH0 (0x0080000 + 0x30)
323 #define CMDAMIN0 (0x0080000 + 0x34)
324 #define CMDAMAX0 (0x0080000 + 0x38)
325 #define CMDFIFODEPTH0 (0x0080000 + 0x44)
326 #define CMDHOLECNT0 (0x0080000 + 0x48)
330 #define YUVBASEADDRESS (0x0080000 + 0x100)
331 #define YUVSTRIDE (0x0080000 + 0x104)
333 /* VGA rubbish, need to change this for multihead support */
341 #define RAMDAC_R 0x3c7
342 #define RAMDAC_W 0x3c8
343 #define RAMDAC_D 0x3c9
348 #ifndef FB_ACCEL_3DFX_BANSHEE
349 #define FB_ACCEL_3DFX_BANSHEE 31
352 #define TDFXF_HSYNC_ACT_HIGH 0x01
353 #define TDFXF_HSYNC_ACT_LOW 0x02
354 #define TDFXF_VSYNC_ACT_HIGH 0x04
355 #define TDFXF_VSYNC_ACT_LOW 0x08
356 #define TDFXF_LINE_DOUBLE 0x10
357 #define TDFXF_VIDEO_ENABLE 0x20
359 #define TDFXF_HSYNC_MASK 0x03
360 #define TDFXF_VSYNC_MASK 0x0c
362 #define XYREG(x,y) (((((unsigned long)y) & 0x1FFF) << 16) | (((unsigned long)x) & 0x1FFF))
364 //#define TDFXFB_DEBUG
366 #define DPRINTK(a,b...) printk(KERN_DEBUG "fb: %s: " a, __FUNCTION__ , ## b)
368 #define DPRINTK(a,b...)
371 /* ------------------------------------------------------------------------- */