annotate libvo/vo_3dfx.c @ 1611:c15f0cd6d051

they've been moved to html
author gabucino
date Tue, 21 Aug 2001 20:59:23 +0000
parents d40f2b686846
children 6e798c58d457
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * video_out_3dfx.c
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * Copyright (C) Colin Cross Apr 2000
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 * This file heavily based off of video_out_mga.c of Aaron Holtzman's
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * mpeg2dec
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * the Free Software Foundation; either version 2, or (at your option)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 * along with GNU Make; see the file COPYING. If not, write to
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 LIBVO_EXTERN(3dfx)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 #include <sys/ioctl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 #include <sys/mman.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 #include <wchar.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 #include <signal.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 #include <X11/extensions/xf86dga.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 //#define LOG(x) syslog(LOG_USER | LOG_DEBUG,x)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 #define LOG(x)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 #include "drivers/3dfx.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51
354
7de9e48c83a5 memcpy() moved mmx.h -> fastmemcpy.h
arpi_esp
parents: 350
diff changeset
52 #include "fastmemcpy.h"
350
601822cc8c52 applied MMX2 memcpy() patch by Nick Kurshev
arpi_esp
parents: 31
diff changeset
53
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 static vo_info_t vo_info =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 "3dfx (/dev/3dfx)",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 "3dfx",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 "Colin Cross <colin@MIT.EDU>",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 static uint32_t is_fullscreen = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 static uint32_t vidwidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 static uint32_t vidheight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 static uint32_t screenwidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 static uint32_t screenheight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 static uint32_t screendepth = 2; //Only 16bpp supported right now
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 static uint32_t dispwidth = 1280; // You can change these to whatever you want
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 static uint32_t dispheight = 720; // 16:9 screen ratio??
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 static uint32_t dispx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 static uint32_t dispy;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 static uint32_t *vidpage0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 static uint32_t *vidpage1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 static uint32_t *vidpage2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 static uint32_t vidpage0offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 static uint32_t vidpage1offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 static uint32_t vidpage2offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 // Current pointer into framebuffer where display is located
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 static uint32_t targetoffset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 static uint32_t page_space;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 static voodoo_io_reg *reg_IO;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 static voodoo_2d_reg *reg_2d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 static voodoo_yuv_reg *reg_YUV;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 static voodoo_yuv_fb *fb_YUV;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 static uint32_t *memBase0, *memBase1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 static uint32_t baseAddr0, baseAddr1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 /* X11 related variables */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 static Display *display;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 static Window mywindow;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 static int bpp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 static XWindowAttributes attribs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 static int X_already_started = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 restore(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 //reg_IO->vidDesktopStartAddr = vidpage0offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 XF86DGADirectVideo(display,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 sighup(int foo)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 //reg_IO->vidDesktopStartAddr = vidpage0offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 XF86DGADirectVideo(display,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 exit(0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 restore_regs(voodoo_2d_reg *regs)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 reg_2d->commandExtra = regs->commandExtra;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 reg_2d->clip0Min = regs->clip0Min;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 reg_2d->clip0Max = regs->clip0Max;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 reg_2d->srcBaseAddr = regs->srcBaseAddr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 reg_2d->srcXY = regs->srcXY;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 reg_2d->srcFormat = regs->srcFormat;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 reg_2d->srcSize = regs->srcSize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 reg_2d->dstBaseAddr = regs->dstBaseAddr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 reg_2d->dstXY = regs->dstXY;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 reg_2d->dstFormat = regs->dstFormat;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 reg_2d->dstSize = regs->dstSize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 reg_2d->command = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 create_window(Display *display)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 int screen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 unsigned int fg, bg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 char *hello = "I hate X11";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 XSizeHints hint;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 XVisualInfo vinfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 XEvent xev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 Colormap theCmap;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 XSetWindowAttributes xswa;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 unsigned long xswamask;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 if (X_already_started)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 screen = DefaultScreen(display);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 hint.x = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 hint.y = 10;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 hint.width = dispwidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 hint.height = dispheight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 hint.flags = PPosition | PSize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 bg = WhitePixel(display, screen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 fg = BlackPixel(display, screen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 XGetWindowAttributes(display, DefaultRootWindow(display), &attribs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 bpp = attribs.depth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 if (bpp != 16)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 {
614
f83ec60bce49 fprintf(stderr converted to printf(
szabii
parents: 354
diff changeset
173 printf("Only 16bpp supported!");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 exit(-1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 XMatchVisualInfo(display,screen,bpp,TrueColor,&vinfo);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 printf("visual id is %lx\n",vinfo.visualid);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 theCmap = XCreateColormap(display, RootWindow(display,screen),
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 vinfo.visual, AllocNone);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 xswa.background_pixel = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 xswa.border_pixel = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 xswa.colormap = theCmap;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 xswamask = CWBackPixel | CWBorderPixel |CWColormap;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 mywindow = XCreateWindow(display, RootWindow(display,screen),
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 hint.x, hint.y, hint.width, hint.height, 4, bpp,CopyFromParent,vinfo.visual,xswamask,&xswa);
1137
4c7b219e126c patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents: 614
diff changeset
191 vo_x11_classhint( display,mywindow,"3dfx" );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 XSelectInput(display, mywindow, StructureNotifyMask);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 /* Tell other applications about this window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 XSetStandardProperties(display, mywindow, hello, hello, None, NULL, 0, &hint);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 /* Map window. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 XMapWindow(display, mywindow);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 /* Wait for map. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 do
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 XNextEvent(display, &xev);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 while (xev.type != MapNotify || xev.xmap.event != mywindow);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 XSelectInput(display, mywindow, NoEventMask);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 XFlush(display);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 XSync(display, False);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 X_already_started++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 dump_yuv_planar(uint32_t *y, uint32_t *u, uint32_t *v, uint32_t to, uint32_t width, uint32_t height)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 // YUV conversion works like this:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 //
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 // We write the Y, U, and V planes separately into 3dfx YUV Planar memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 // region. The nice chip then takes these and packs them into the YUYV
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 // format in the regular frame buffer, starting at yuvBaseAddr, page 2 here.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 // Then we tell the 3dfx to do a Screen to Screen Stretch BLT to copy all
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 // of the data on page 2 onto page 1, converting it to 16 bpp RGB as it goes.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 // The result is a nice image on page 1 ready for display.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 uint32_t j;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 uint32_t y_imax, uv_imax, jmax;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 reg_YUV->yuvBaseAddr = to;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 reg_YUV->yuvStride = screenwidth*2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 LOG("video_out_3dfx: starting planar dump\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 jmax = height>>1; // vidheight/2, height of U and V planes
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 y_imax = width; // Y plane is twice as wide as U and V planes
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 uv_imax = width>>1; // vidwidth/2/4, width of U and V planes in 32-bit words
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 for (j=0;j<jmax;j++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 //XXX this should be hand-rolled 32 bit memcpy for safeness.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 memcpy(fb_YUV->U + (uint32_t) VOODOO_YUV_STRIDE* j ,((uint8_t*) u) + uv_imax* j , uv_imax);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 memcpy(fb_YUV->V + (uint32_t) VOODOO_YUV_STRIDE* j ,((uint8_t*) v) + uv_imax* j , uv_imax);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 memcpy(fb_YUV->Y + (uint32_t) VOODOO_YUV_STRIDE* (j<<1) ,((uint8_t*) y) + y_imax * (j<<1) , y_imax);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 memcpy(fb_YUV->Y + (uint32_t) VOODOO_YUV_STRIDE*((j<<1)+1),((uint8_t*) y) + y_imax *((j<<1)+1), y_imax);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 LOG("video_out_3dfx: done planar dump\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 screen_to_screen_stretch_blt(uint32_t to, uint32_t from, uint32_t width, uint32_t height)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 //FIXME - this function should be called by a show_frame function that
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 // uses a series of blts to show only those areas not covered
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 // by another window
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 voodoo_2d_reg saved_regs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 LOG("video_out_3dfx: saving registers\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 // Save VGA regs (so X kinda works when we're done)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 saved_regs = *reg_2d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 /* The following lines set up the screen to screen stretch blt from page2 to
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 page 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 LOG("video_out_3dfx: setting blt registers\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 reg_2d->commandExtra = 4; //disable colorkeying, enable wait for v-refresh (0100b)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 reg_2d->clip0Min = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 reg_2d->clip0Max = 0xFFFFFFFF; //no clipping
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 reg_2d->srcBaseAddr = from;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 reg_2d->srcXY = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 reg_2d->srcFormat = screenwidth*2 | VOODOO_BLT_FORMAT_YUYV; // | 1<<21;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 reg_2d->srcSize = vidwidth | (vidheight << 16);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 reg_2d->dstBaseAddr = to;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 reg_2d->dstXY = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 reg_2d->dstFormat = screenwidth*2 | VOODOO_BLT_FORMAT_16;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 reg_2d->dstSize = width | (height << 16);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 LOG("video_out_3dfx: starting blt\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 // Executes screen to screen stretch blt
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 reg_2d->command = 2 | 1<<8 | 0xCC<<24;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 LOG("video_out_3dfx: restoring regs\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 restore_regs(&saved_regs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 LOG("video_out_3dfx: done blt\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 update_target(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 uint32_t xp, yp, w, h, b, d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 Window root;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 XGetGeometry(display,mywindow,&root,&xp,&yp,&w,&h,&b,&d);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 XTranslateCoordinates(display,mywindow,root,0,0,&xp,&yp,&root);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 dispx = (uint32_t) xp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 dispy = (uint32_t) yp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 dispwidth = (uint32_t) w;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 dispheight = (uint32_t) h;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 if (is_fullscreen)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 targetoffset = vidpage0offset + (screenheight - dispheight)/2*screenwidth*screendepth + (screenwidth-dispwidth)/2*screendepth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311 targetoffset = vidpage0offset + (dispy*screenwidth + dispx)*screendepth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 int fd;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 char *name = ":0.0";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 pioData data;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 uint32_t retval;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 if(getenv("DISPLAY"))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 name = getenv("DISPLAY");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 display = XOpenDisplay(name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 screenwidth = XDisplayWidth(display,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 screenheight = XDisplayHeight(display,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 page_space = screenwidth*screenheight*screendepth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 vidpage0offset = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 vidpage1offset = page_space; // Use third and fourth pages
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 vidpage2offset = page_space*2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 signal(SIGALRM,sighup);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 //alarm(120);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 // Open driver device
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 if ( (fd = open("/dev/3dfx",O_RDWR) ) == -1)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 {
614
f83ec60bce49 fprintf(stderr converted to printf(
szabii
parents: 354
diff changeset
340 printf("Couldn't open /dev/3dfx\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 exit(1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 // Store sizes for later
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 vidwidth = width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 vidheight = height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 is_fullscreen = fullscreen = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 if (!is_fullscreen)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 create_window(display);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 // Ask 3dfx driver for base memory address 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 data.port = 0x10; // PCI_BASE_ADDRESS_0_LINUX;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 data.size = 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 data.value = &baseAddr0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 data.device = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 printf("Error: %d\n",retval);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 //return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 // Ask 3dfx driver for base memory address 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 data.port = 0x14; // PCI_BASE_ADDRESS_1_LINUX;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 data.size = 4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 data.value = &baseAddr1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 data.device = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 printf("Error: %d\n",retval);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 //return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 // Map all 3dfx memory areas
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 memBase0 = mmap(0,0x1000000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,baseAddr0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 memBase1 = mmap(0,3*page_space,PROT_READ | PROT_WRITE,MAP_SHARED,fd,baseAddr1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 if (memBase0 == (uint32_t *) 0xFFFFFFFF || memBase1 == (uint32_t *) 0xFFFFFFFF)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 printf("Couldn't map 3dfx memory areas: %p,%p,%d\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 memBase0,memBase1,errno);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 // Set up global pointers
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 reg_2d = (void *)memBase0 + VOODOO_2D_REG_OFFSET;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 reg_YUV = (void *)memBase0 + VOODOO_YUV_REG_OFFSET;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 fb_YUV = (void *)memBase0 + VOODOO_YUV_PLANE_OFFSET;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 vidpage0 = (void *)memBase1 + (unsigned long int)vidpage0offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 vidpage1 = (void *)memBase1 + (unsigned long int)vidpage1offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 vidpage2 = (void *)memBase1 + (unsigned long int)vidpage2offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 // Clear pages 1,2,3
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 // leave page 0, that belongs to X.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 // So does part of 1. Oops.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 memset(vidpage1,0x00,page_space);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 memset(vidpage2,0x00,page_space);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 if (is_fullscreen)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 memset(vidpage0,0x00,page_space);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 #ifndef VOODOO_DEBUG
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 // Show page 0 (unblanked)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 reg_IO->vidDesktopStartAddr = vidpage0offset;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 /* Stop X from messing with my video registers!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 Find a better way to do this?
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 Currently I use DGA to tell XF86 to not screw with registers, but I can't really use it
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 to do FB stuff because I need to know the absolute FB position and offset FB position
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 to feed to BLT command
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 //XF86DGADirectVideo(display,0,XF86DGADirectGraphics); //| XF86DGADirectMouse | XF86DGADirectKeyb);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 /* fd is deliberately not closed - if it were, mmaps might be released??? */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 atexit(restore);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 printf("(display) 3dfx initialized %p\n",memBase1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 static const vo_info_t*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 get_info(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 return &vo_info;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431 draw_frame(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 LOG("video_out_3dfx: starting display_frame\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435 // Put packed data onto page 2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436 dump_yuv_planar((uint32_t *)src[0],(uint32_t *)src[1],(uint32_t *)src[2],
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 vidpage2offset,vidwidth,vidheight);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 LOG("video_out_3dfx: done display_frame\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 draw_slice(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
445 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
446 uint32_t target;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
447
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448 target = vidpage2offset + (screenwidth*2 * 16*slice_num);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 dump_yuv_planar((uint32_t *)src[0],(uint32_t *)src[1],(uint32_t *)src[2],target,vidwidth,16);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1137
diff changeset
453 static void draw_osd(void)
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1137
diff changeset
454 {
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1137
diff changeset
455 }
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1137
diff changeset
456
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 flip_page(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 //FIXME - update_target() should be called by event handler when window
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 // is resized or moved
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462 update_target();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 LOG("video_out_3dfx: calling blt function\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 screen_to_screen_stretch_blt(targetoffset, vidpage2offset, dispwidth, dispheight);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
465 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
466
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
468 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
469 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471 case IMGFMT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
472 // case IMGFMT_YUY2:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
473 // case IMGFMT_RGB|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
474 // case IMGFMT_BGR|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
475 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
476 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
477 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
478 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
479
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
480 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
481 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
482 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
483 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
484
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
485
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
486 static void check_events(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
487 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
488 }
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
489
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
490