Mercurial > mplayer.hg
annotate libvo/vo_dga.c @ 362:463699f15eb4
static removed from verbose definition
author | szabii |
---|---|
date | Wed, 11 Apr 2001 20:58:15 +0000 |
parents | 8ffe2f459851 |
children | 50214d6c1826 |
rev | line source |
---|---|
13 | 1 #define DISP |
2 | |
3 /* | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
4 * $Id$ |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
5 * |
13 | 6 * video_out_dga.c, X11 interface |
7 * | |
8 * | |
9 * Copyright ( C ) 2001, Andreas Ackermann. All Rights Reserved. | |
10 * | |
11 * <acki@acki-netz.de> | |
12 * | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
13 * Sourceforge username: acki2 |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
14 * |
13 | 15 * note well: |
16 * | |
17 * o this is alpha | |
18 * o covers only common video card formats | |
19 * o works only on intel architectures | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
20 * |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
21 * $Log$ |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
22 * Revision 1.10 2001/04/01 22:01:28 acki2 |
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
23 * - still more debug output to be able to fix 15/16 bpp problem |
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
24 * |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
25 * Revision 1.9 2001/04/01 08:07:14 acki2 |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
26 * - added detection of memsize of graphics card to check if double buffering is possible |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
27 * - fixed resolution switching a little and added more debug output |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
28 * - resolution switching is still according to d_width and d_height which |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
29 * is not always a good idea ... |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
30 * |
261 | 31 * |
32 * 30/02/2001 | |
13 | 33 * |
261 | 34 * o query_format(): with DGA 2.0 it returns all depths it supports |
35 * (even 16 when running 32 and vice versa) | |
36 * Checks for (hopefully!) compatible RGBmasks in 15/16 bit modes | |
37 * o added some more criterions for resolution switching | |
38 * o cleanup | |
39 * o with DGA2.0 present, ONLY DGA2.0 functions are used | |
40 * o for 15/16 modes ONLY RGB 555 is supported, since the divx-codec | |
41 * happens to map the data this way. If your graphics card supports | |
42 * this, you're well off and may use these modes; for mpeg | |
43 * movies things could be different, but I was too lazy to implement | |
44 * it ... | |
262 | 45 * o you may define VO_DGA_FORCE_DEPTH to the depth you desire |
46 * if you don't like the choice the driver makes | |
47 * Beware: unless you can use DGA2.0 this has to be your X Servers | |
48 * depth!!! | |
49 * o Added double buffering :-)) | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
50 * o included VidMode switching support for DGA1.0, written by Michael Graffam |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
51 * mgraffam@idsi.net |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
52 * |
13 | 53 */ |
54 | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
55 //#define VO_DGA_FORCE_DEPTH 32 |
13 | 56 |
57 #include <stdio.h> | |
58 #include <stdlib.h> | |
59 #include <string.h> | |
60 | |
61 #include "config.h" | |
62 #include "video_out.h" | |
63 #include "video_out_internal.h" | |
64 #include "yuv2rgb.h" | |
65 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
66 |
262 | 67 //#undef HAVE_DGA2 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
68 //#undef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
69 |
261 | 70 |
13 | 71 LIBVO_EXTERN( dga ) |
72 | |
73 #include <X11/Xlib.h> | |
74 #include <X11/extensions/xf86dga.h> | |
75 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
76 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
77 #include <X11/extensions/xf86vmode.h> |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
78 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
79 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
80 |
31 | 81 #include "x11_common.h" |
13 | 82 |
83 static vo_info_t vo_info = | |
84 { | |
85 "DGA ( Direct Graphic Access )", | |
86 "dga", | |
87 "Andreas Ackermann <acki@acki-netz.de>", | |
88 "" | |
89 }; | |
90 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
91 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
92 static XF86VidModeModeInfo **vo_dga_vidmodes=NULL; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
93 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
94 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
95 |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
96 //extern int verbose; // shouldn't someone remove the static from |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
97 // its definition in mplayer.c ??? |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
98 |
31 | 99 static int vo_dga_width; // bytes per line in framebuffer |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
100 static int vo_dga_vp_width; // visible pixels per line in |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
101 // framebuffer |
31 | 102 static int vo_dga_vp_height; // visible lines in framebuffer |
103 static int vo_dga_is_running = 0; | |
104 static int vo_dga_src_width; // width of video in pixels | |
105 static int vo_dga_src_height; // height of video in pixels | |
106 static int vo_dga_bpp; // bytes per pixel in framebuffer | |
107 static int vo_dga_src_offset=0; // offset in src | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
108 static int vo_dga_vp_offset=0; // offset in dest |
262 | 109 static int vo_dga_bytes_per_line; // bytes per line to copy |
31 | 110 static int vo_dga_src_skip; // bytes to skip after copying one line |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
111 // (not supported yet) in src |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
112 static int vo_dga_vp_skip; // dto. for dest |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
113 static int vo_dga_lines; // num of lines to copy |
31 | 114 static int vo_dga_src_format; |
261 | 115 static int vo_dga_planes; // bits per pixel on screen |
13 | 116 |
262 | 117 static int vo_dga_dbf_mem_offset; // offset in bytes for alternative |
118 // framebuffer (0 if dbf is not | |
119 // possible) | |
120 static int vo_dga_dbf_y_offset; // y offset (in scanlines) | |
121 static int | |
122 vo_dga_dbf_current; // current buffer (0 or 1) | |
123 | |
31 | 124 static unsigned char *vo_dga_base; |
125 static Display *vo_dga_dpy; | |
13 | 126 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
127 //--------------------------------------------------------- |
13 | 128 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
129 // I had tried to work with mmx/3dnow copy code but |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
130 // there was not much speed gain and I didn't know |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
131 // how to save the FPU/mmx registers - so the copy |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
132 // code interferred with sound output ... |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
133 // removed the leftovers |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
134 // acki2 on 30/3/2001 |
13 | 135 |
136 | |
137 #define rep_movsl(dest, src, numwords, d_add, count) \ | |
138 __asm__ __volatile__( \ | |
139 " \ | |
140 xfer: \n\t\ | |
141 movl %%edx, %%ecx \n\t \ | |
142 cld\n\t \ | |
143 rep\n\t \ | |
144 movsl \n\t\ | |
145 add %%eax, %%edi \n\t\ | |
146 dec %%ebx \n\t\ | |
147 jnz xfer \n\t\ | |
148 " \ | |
149 : \ | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
150 : "a" (d_add), "b" (count), "S" (src), "D" (dest), \ |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
151 "d" (numwords) \ |
13 | 152 : "memory" ) |
153 | |
154 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
155 //--------------------------------------------------------- |
13 | 156 |
157 static uint32_t draw_frame( uint8_t *src[] ){ | |
158 | |
159 int vp_skip = vo_dga_vp_skip; | |
160 int lpl = vo_dga_bytes_per_line >> 2; | |
161 int numlines = vo_dga_lines; | |
162 | |
163 char *s, *d; | |
164 | |
262 | 165 s = *src; |
166 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]); | |
167 rep_movsl(d, s, lpl, vo_dga_vp_skip, numlines ); | |
13 | 168 |
169 return 0; | |
170 } | |
171 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
172 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
173 |
31 | 174 static void check_events(void) |
175 { | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
176 int e=vo_x11_check_events(vo_dga_dpy); |
31 | 177 } |
178 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
179 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
180 |
13 | 181 static void flip_page( void ){ |
262 | 182 |
183 | |
184 if(vo_dga_dbf_mem_offset != 0){ | |
185 | |
186 #ifdef HAVE_DGA2 | |
187 XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), | |
188 0, vo_dga_dbf_current * vo_dga_dbf_y_offset, | |
189 XDGAFlipRetrace); | |
190 #else | |
191 XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), | |
192 0, vo_dga_dbf_current * vo_dga_dbf_y_offset); | |
193 #endif | |
194 vo_dga_dbf_current = 1 - vo_dga_dbf_current; | |
195 } | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
196 check_events(); |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
197 } |
13 | 198 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
199 //--------------------------------------------------------- |
13 | 200 |
201 static uint32_t draw_slice( uint8_t *src[],int stride[], | |
202 int w,int h,int x,int y ) | |
203 { | |
204 yuv2rgb( vo_dga_base + vo_dga_vp_offset + | |
205 (vo_dga_width * y +x) * vo_dga_bpp, | |
206 src[0], src[1], src[2], | |
207 w,h, vo_dga_width * vo_dga_bpp, | |
208 stride[0],stride[1] ); | |
209 return 0; | |
210 }; | |
211 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
212 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
213 |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
214 |
13 | 215 static void Terminate_Display_Process( void ){ |
216 printf("vo_dga: Terminating display process\n"); | |
217 } | |
218 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
219 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
220 |
13 | 221 static const vo_info_t* get_info( void ) |
222 { return &vo_info; } | |
223 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
224 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
225 |
13 | 226 static uint32_t query_format( uint32_t format ) |
227 { | |
261 | 228 |
229 #ifdef HAVE_DGA2 | |
230 XDGAMode *modelines; | |
231 int modecount; | |
232 Display *qdisp; | |
233 #endif | |
234 | |
235 int i,k,dummy; | |
236 static int dga_depths_init = 0; | |
237 static int dga_depths = 0; // each bit that is set represents | |
238 // a depth the X-Server is capable | |
239 // of displaying | |
240 | |
241 | |
242 if( !vo_init() ) return 0; // Can't open X11 | |
243 | |
244 if(dga_depths_init == 0){ | |
13 | 245 |
261 | 246 #ifdef HAVE_DGA2 |
247 | |
248 if((qdisp = XOpenDisplay(0))==NULL){ | |
249 printf("vo_dga: Can't open display!\n"); | |
250 return 0; | |
251 } | |
252 modelines=XDGAQueryModes(qdisp, XDefaultScreen(qdisp),&modecount); | |
253 for(i=0; i< modecount; i++){ | |
254 if( ( (modelines[i].bitsPerPixel == 15 || | |
255 modelines[i].bitsPerPixel == 16) && | |
256 modelines[i].redMask == 0x7c00 && | |
257 modelines[i].greenMask == 0x03e0 && | |
258 modelines[i].blueMask == 0x001f | |
259 ) || | |
260 ( modelines[i].bitsPerPixel != 15 && | |
261 modelines[i].bitsPerPixel != 16 | |
262 ) | |
263 ) | |
264 { | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
265 // this only for debug reasons ... |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
266 if(modelines[i].bitsPerPixel == 15 || modelines[i].bitsPerPixel == 16){ |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
267 printf("vo_dga: num: %d, depth: %d, bpp: %d, %08x, %08x, %08x, %dx%d\n", |
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
268 i, |
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
269 modelines[i].depth, |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
270 modelines[i].bitsPerPixel, |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
271 modelines[i].redMask, |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
272 modelines[i].greenMask, |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
273 modelines[i].blueMask, |
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
274 modelines[i].viewportWidth, |
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
275 modelines[i].viewportHeight); |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
276 } |
261 | 277 for(k=0, dummy=1; k<modelines[i].bitsPerPixel-1; k++)dummy <<=1; |
278 dga_depths |= dummy; | |
279 } | |
280 | |
281 } | |
282 XCloseDisplay(qdisp); | |
283 | |
284 #else | |
13 | 285 |
261 | 286 for(k=0, dummy=1; k<vo_depthonscreen-1; k++)dummy <<=1; |
287 dga_depths |= dummy; | |
288 // hope this shift is ok; heard that on some systems only up to 8 digits | |
289 // may be shifted at a time. SIGH! It IS so. | |
290 // test for RGB masks !!!! (if depthonscreen != 24 or 32 !!!) | |
291 if( !(vo_depthonscreen == 24 || vo_depthonscreen == 32 ) ){ | |
292 printf("vo_dga: You're running 15/16 bit X Server; your hardware might use unsuitable RGB-mask!\n"); | |
293 } | |
294 #endif | |
262 | 295 #ifdef VO_DGA_FORCE_DEPTH |
296 dga_depths = 1<<(VO_DGA_FORCE_DEPTH-1); | |
297 #endif | |
298 | |
261 | 299 dga_depths_init = 1; |
300 | |
301 if( dga_depths == 0){ | |
302 printf("vo_dga: Sorry, there seems to be no suitable depth available!\n"); | |
303 printf(" Try running X in 24 or 32 bit mode!!!\n"); | |
304 return 0; | |
305 }else{ | |
306 for(i=0, dummy=1; i< 32; i++){ | |
307 if(dummy& dga_depths){ | |
308 printf("vo_dga: may use %2d bits per pixel\n", i+1); | |
309 } | |
310 dummy <<= 1; | |
311 } | |
312 } | |
313 } | |
13 | 314 if( format==IMGFMT_YV12 ) return 1; |
261 | 315 for(k=0, dummy=1; k<(format&0xFF)-1; k++)dummy<<=1; |
316 | |
13 | 317 if( ( format&IMGFMT_BGR_MASK )==IMGFMT_BGR && |
261 | 318 ( dummy & dga_depths )) return 1; |
319 | |
13 | 320 return 0; |
321 } | |
322 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
323 //--------------------------------------------------------- |
13 | 324 |
325 static void | |
326 uninit(void) | |
327 { | |
328 | |
261 | 329 #ifdef HAVE_DGA2 |
330 XDGADevice *dgadevice; | |
331 #endif | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
332 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
333 if(vo_dga_is_running){ |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
334 vo_dga_is_running = 0; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
335 printf("vo_dga: in uninit\n"); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
336 XUngrabPointer (vo_dga_dpy, CurrentTime); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
337 XUngrabKeyboard (vo_dga_dpy, CurrentTime); |
261 | 338 #ifdef HAVE_DGA2 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
339 dgadevice = XDGASetMode(vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
340 if(dgadevice != NULL){ |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
341 XFree(dgadevice); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
342 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
343 XDGACloseFramebuffer(vo_dga_dpy, XDefaultScreen(vo_dga_dpy)); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
344 #else |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
345 XF86DGADirectVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
346 // first disable DirectVideo and then switch mode back! |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
347 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
348 if (vo_dga_vidmodes != NULL ){ |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
349 int screen; screen=XDefaultScreen( vo_dga_dpy ); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
350 printf("vo_dga: VidModeExt: Switching back..\n"); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
351 // seems some graphics adaptors need this more than once ... |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
352 XF86VidModeSwitchToMode(vo_dga_dpy,screen,vo_dga_vidmodes[0]); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
353 XF86VidModeSwitchToMode(vo_dga_dpy,screen,vo_dga_vidmodes[0]); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
354 XF86VidModeSwitchToMode(vo_dga_dpy,screen,vo_dga_vidmodes[0]); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
355 XF86VidModeSwitchToMode(vo_dga_dpy,screen,vo_dga_vidmodes[0]); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
356 XFree(vo_dga_vidmodes); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
357 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
358 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
359 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
360 XCloseDisplay(vo_dga_dpy); |
261 | 361 } |
13 | 362 } |
363 | |
364 | |
261 | 365 //---------------------------------------------------------- |
366 | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
367 int check_mode( int num, int x, int y, int bpp, |
261 | 368 int new_x, int new_y, int new_vbi, |
369 int *old_x, int *old_y, int *old_vbi){ | |
370 | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
371 printf("vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ %2d bpp ..", |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
372 num, new_x, new_y, new_vbi, bpp ); |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
373 printf("(old: %dx%d@%d).", *old_x, *old_y, *old_vbi); |
261 | 374 if ( |
375 (new_x >= x) && | |
376 (new_y >= y) && | |
377 ( | |
378 // prefer a better resolution either in X or in Y | |
379 // as long as the other dimension is at least the same | |
380 // | |
381 // hmm ... MAYBE it would be more clever to focus on the | |
382 // x-resolution; I had 712x400 and 640x480 and the movie | |
383 // was 640x360; 640x480 would be the 'right thing' here | |
384 // but since 712x400 was queried first I got this one. | |
385 // I think there should be a cmd-line switch to let the | |
386 // user choose the mode he likes ... (acki2) | |
387 | |
388 ( | |
389 ((new_x < *old_x) && | |
390 !(new_y > *old_y)) || | |
391 ((new_y < *old_y) && | |
392 !(new_x > *old_x)) | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
393 ) |
261 | 394 // but if we get an identical resolution choose |
395 // the one with the lower refreshrate (saves bandwidth !!!) | |
396 // as long as it's above 50 Hz (acki2 on 30/3/2001) | |
397 || | |
398 ( | |
399 (new_x == *old_x) && | |
400 (new_y == *old_y) && | |
401 ( | |
402 ( | |
403 new_vbi >= *old_vbi && *old_vbi < 50 | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
404 ) |
261 | 405 || |
406 ( | |
407 *old_vbi >= 50 && | |
408 new_vbi < *old_vbi && | |
409 new_vbi >= 50 | |
410 ) | |
411 ) | |
412 ) | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
413 ) |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
414 ) |
261 | 415 { |
416 *old_x = new_x; | |
417 *old_y = new_y; | |
418 *old_vbi = new_vbi; | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
419 printf(".ok!!\n"); |
261 | 420 return 1; |
421 }else{ | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
422 printf(".no\n"); |
261 | 423 return 0; |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
424 } |
261 | 425 } |
426 | |
427 | |
428 | |
429 //--------------------------------------------------------- | |
430 | |
431 static uint32_t init( uint32_t width, uint32_t height, | |
432 uint32_t d_width,uint32_t d_height, | |
433 uint32_t fullscreen,char *title,uint32_t format ) | |
434 { | |
435 | |
436 int x_off, y_off; | |
437 | |
438 #ifdef HAVE_DGA2 | |
439 // needed to change DGA video mode | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
440 int modecount, mX=100000, mY=100000 , mVBI=100000, i,j=0; |
261 | 441 int dga_modenum; |
442 XDGAMode *modelines=NULL; | |
443 XDGADevice *dgadevice; | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
444 int max_vpy_pos; |
261 | 445 #else |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
446 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
447 unsigned int vm_event, vm_error; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
448 unsigned int vm_ver, vm_rev; |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
449 int i, j=0, have_vm=0; |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
450 int modecount, mX=100000, mY=100000, mVBI=100000, dga_modenum; |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
451 #endif |
261 | 452 int bank, ram; |
453 #endif | |
454 | |
455 if( vo_dga_is_running )return -1; | |
456 | |
457 | |
458 if( !vo_init() ){ | |
459 printf("vo_dga: vo_init() failed!\n"); | |
460 return 0; | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
461 } |
261 | 462 |
463 if (format == IMGFMT_YV12 ){ | |
464 vo_dga_planes = vo_depthonscreen; | |
465 vo_dga_planes = vo_dga_planes == 15 ? 16 : vo_dga_planes; | |
466 }else{ | |
467 vo_dga_planes = (format & 0xff); | |
468 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
469 // hack!!! here we should only get what we told we can handle in |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
470 // query_format() but mplayer is somewhat generous about |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
471 // 15/16bit depth ... |
261 | 472 |
473 vo_dga_planes = vo_dga_planes == 15 ? 16 : vo_dga_planes; | |
474 } | |
475 | |
476 if((vo_dga_dpy = XOpenDisplay(0))==NULL) | |
477 { | |
478 printf ("vo_dga: Can't open display\n"); | |
479 return 1; | |
480 } | |
481 | |
482 vo_dga_bpp = (vo_dga_planes+7) >> 3; | |
483 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
484 // TODO: find out screen resolution of X-Server here and |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
485 // provide them as default values (used only in case |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
486 // DGA1.0 and no VidMode Ext or VidModeExt doesn't return |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
487 // any screens to check if video is larger than current screen) |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
488 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
489 vo_dga_vp_width = 1280; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
490 vo_dga_vp_height = 1024; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
491 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
492 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
493 |
261 | 494 // choose a suitable mode ... |
495 | |
496 #ifdef HAVE_DGA2 | |
497 // Code to change the video mode added by Michael Graffam | |
498 // mgraffam@idsi.net | |
499 if (modelines==NULL) | |
500 modelines=XDGAQueryModes(vo_dga_dpy, XDefaultScreen(vo_dga_dpy),&modecount); | |
501 | |
502 printf("vo_dga: Using DGA 2.0 mode changing support\n"); | |
503 // offbyone-error !!! i<=modecount is WRONG !!! | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
504 for (i=0; i<modecount; i++) |
261 | 505 { |
506 if( modelines[i].bitsPerPixel == vo_dga_planes) | |
507 { | |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
508 |
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
509 printf("maxy: %4d, depth: %2d, %4dx%4d, ", modelines[i].maxViewportY, modelines[i].depth, |
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
510 modelines[i].imageWidth, modelines[i].imageHeight ); |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
511 if ( check_mode(i, d_width, d_height, modelines[i].bitsPerPixel, |
261 | 512 modelines[i].viewportWidth, |
513 modelines[i].viewportHeight, | |
514 (unsigned) modelines[i].verticalRefresh, | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
515 &mX, &mY, &mVBI )) j = i; |
261 | 516 } |
517 } | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
518 printf("vo_dga: Selected video mode %4d x %4d @ %3d Hz for image size %3d x %3d.\n", |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
519 mX, mY, mVBI, width, height); |
221
3daeae4a4aa6
Added support to vo_dga to change the video mode to the lowest resolution
mgraffam
parents:
31
diff
changeset
|
520 |
261 | 521 vo_dga_vp_width =mX; |
522 vo_dga_vp_height = mY; | |
523 vo_dga_width = modelines[j].bytesPerScanline / vo_dga_bpp; | |
524 dga_modenum = modelines[j].num; | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
525 max_vpy_pos = modelines[j].maxViewportY; |
261 | 526 |
527 XFree(modelines); | |
528 modelines = NULL; | |
529 | |
530 #else | |
531 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
532 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
533 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
534 printf("vo_dga: DGA 1.0 compatibility code: Using XF86VidMode for mode switching!\n"); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
535 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
536 if (XF86VidModeQueryExtension(vo_dga_dpy, &vm_event, &vm_error)) { |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
537 XF86VidModeQueryVersion(vo_dga_dpy, &vm_ver, &vm_rev); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
538 printf("vo_dga: XF86VidMode Extension v%i.%i\n", vm_ver, vm_rev); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
539 have_vm=1; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
540 } else { |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
541 printf("vo_dga: XF86VidMode Extension not available.\n"); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
542 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
543 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
544 #define GET_VREFRESH(dotclk, x, y)( (((dotclk)/(x))*1000)/(y) ) |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
545 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
546 if (have_vm) { |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
547 int screen; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
548 screen=XDefaultScreen(vo_dga_dpy); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
549 XF86VidModeGetAllModeLines(vo_dga_dpy,screen,&modecount,&vo_dga_vidmodes); |
261 | 550 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
551 if(vo_dga_vidmodes != NULL ){ |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
552 for (i=0; i<modecount; i++){ |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
553 if ( check_mode(i, d_width, d_height, vo_dga_planes, |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
554 vo_dga_vidmodes[i]->hdisplay, |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
555 vo_dga_vidmodes[i]->vdisplay, |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
556 GET_VREFRESH(vo_dga_vidmodes[i]->dotclock, |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
557 vo_dga_vidmodes[i]->htotal, |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
558 vo_dga_vidmodes[i]->vtotal), |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
559 &mX, &mY, &mVBI )) j = i; |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
560 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
561 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
562 printf("vo_dga: Selected video mode %4d x %4d @ %3d Hz for image size %3d x %3d.\n", |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
563 mX, mY, mVBI, width, height); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
564 }else{ |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
565 printf("vo_dga: XF86VidMode returned no screens - using current resolution.\n"); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
566 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
567 dga_modenum = j; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
568 vo_dga_vp_width = mX; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
569 vo_dga_vp_height = mY; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
570 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
571 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
572 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
573 #else |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
574 printf("vo_dga: Only have DGA 1.0 extension and no XF86VidMode :-(\n"); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
575 #endif |
261 | 576 #endif |
577 | |
578 vo_dga_src_format = format; | |
579 vo_dga_src_width = width; | |
580 vo_dga_src_height = height; | |
581 | |
582 if(vo_dga_src_width > vo_dga_vp_width || | |
583 vo_dga_src_height > vo_dga_vp_height) | |
584 { | |
585 printf("vo_dga: Sorry, video larger than viewport is not yet supported!\n"); | |
586 // ugly, do something nicer in the future ... | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
587 #ifndef HAVE_DGA2 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
588 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
589 if(vo_dga_vidmodes){ |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
590 XFree(vo_dga_vidmodes); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
591 vo_dga_vidmodes = NULL; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
592 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
593 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
594 #endif |
261 | 595 return 1; |
596 } | |
597 | |
598 // now lets start the DGA thing | |
599 | |
600 #ifdef HAVE_DGA2 | |
601 | |
602 if (!XDGAOpenFramebuffer(vo_dga_dpy, XDefaultScreen(vo_dga_dpy))){ | |
603 printf("vo_dga: Framebuffer mapping failed!!!\n"); | |
604 XCloseDisplay(vo_dga_dpy); | |
605 return 1; | |
606 } | |
607 dgadevice=XDGASetMode(vo_dga_dpy, XDefaultScreen(vo_dga_dpy), dga_modenum); | |
221
3daeae4a4aa6
Added support to vo_dga to change the video mode to the lowest resolution
mgraffam
parents:
31
diff
changeset
|
608 XDGASync(vo_dga_dpy, XDefaultScreen(vo_dga_dpy)); |
3daeae4a4aa6
Added support to vo_dga to change the video mode to the lowest resolution
mgraffam
parents:
31
diff
changeset
|
609 |
261 | 610 vo_dga_base = dgadevice->data; |
221
3daeae4a4aa6
Added support to vo_dga to change the video mode to the lowest resolution
mgraffam
parents:
31
diff
changeset
|
611 XFree(dgadevice); |
261 | 612 |
613 XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0, XDGAFlipRetrace); | |
614 | |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
615 #else |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
616 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
617 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
618 XF86VidModeLockModeSwitch(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),0); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
619 // Two calls are needed to switch modes on my ATI Rage 128. Why? |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
620 // for riva128 one call is enough! |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
621 XF86VidModeSwitchToMode(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),vo_dga_vidmodes[dga_modenum]); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
622 XF86VidModeSwitchToMode(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),vo_dga_vidmodes[dga_modenum]); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
623 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
624 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
625 XF86DGAGetViewPortSize(vo_dga_dpy,XDefaultScreen(vo_dga_dpy), |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
626 &vo_dga_vp_width, |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
627 &vo_dga_vp_height); |
13 | 628 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
629 XF86DGAGetVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
630 (char **)&vo_dga_base, &vo_dga_width, &bank, &ram); |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
631 |
261 | 632 XF86DGADirectVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), |
633 XF86DGADirectGraphics | XF86DGADirectMouse | | |
634 XF86DGADirectKeyb); | |
635 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
636 XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0); |
261 | 637 |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
638 #endif |
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
639 |
13 | 640 // do some more checkings here ... |
261 | 641 |
13 | 642 if( format==IMGFMT_YV12 ) |
261 | 643 yuv2rgb_init( vo_dga_planes == 16 ? 15 : vo_dga_planes , MODE_RGB ); |
13 | 644 |
645 printf("vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %08x, bpp: %d\n", | |
646 vo_dga_width, vo_dga_vp_width, | |
261 | 647 vo_dga_vp_height, vo_dga_planes, vo_dga_base, |
13 | 648 vo_dga_bpp); |
649 | |
650 x_off = (vo_dga_vp_width - vo_dga_src_width)>>1; | |
651 y_off = (vo_dga_vp_height - vo_dga_src_height)>>1; | |
652 | |
261 | 653 vo_dga_bytes_per_line = vo_dga_src_width * vo_dga_bpp; |
654 vo_dga_lines = vo_dga_src_height; | |
13 | 655 |
656 vo_dga_src_offset = 0; | |
657 vo_dga_vp_offset = (y_off * vo_dga_width + x_off ) * vo_dga_bpp; | |
658 | |
659 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * vo_dga_bpp; // todo | |
660 | |
661 printf("vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n", | |
662 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line); | |
663 | |
664 | |
665 XGrabKeyboard (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True, | |
666 GrabModeAsync,GrabModeAsync, CurrentTime); | |
667 XGrabPointer (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True, | |
668 ButtonPressMask,GrabModeAsync, GrabModeAsync, | |
669 None, None, CurrentTime); | |
262 | 670 // TODO: chekc if mem of graphics adaptor is large enough for dbf |
671 | |
672 // set up variables for double buffering ... | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
673 // note: set vo_dga_dbf_mem_offset to NULL to disable doublebuffering |
262 | 674 |
675 vo_dga_dbf_y_offset = y_off + vo_dga_src_height; | |
676 vo_dga_dbf_mem_offset = vo_dga_width * vo_dga_bpp * vo_dga_dbf_y_offset; | |
677 vo_dga_dbf_current = 0; | |
678 | |
679 if(format ==IMGFMT_YV12 )vo_dga_dbf_mem_offset = 0; | |
680 // disable doublebuffering for YV12 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
681 |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
682 #ifdef HAVE_DGA2 |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
683 if(vo_dga_vp_height>max_vpy_pos){ |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
684 vo_dga_dbf_mem_offset = 0; |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
685 printf("vo_dga: Not enough memory for double buffering!\n"); |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
686 } |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
687 #endif |
262 | 688 |
13 | 689 // now clear screen |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
690 { |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
691 int size = vo_dga_width * |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
692 (vo_dga_vp_height + (vo_dga_dbf_mem_offset != 0 ? |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
693 (vo_dga_src_height+y_off) : 0)) * |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
694 vo_dga_bpp; |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
695 #ifndef HAVE_DGA2 |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
696 printf("%d, %d\n", size, ram); |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
697 if(size>ram*1024){ |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
698 vo_dga_dbf_mem_offset = 0; |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
699 printf("vo_dga: Not enough memory for double buffering!\n"); |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
700 size -= (vo_dga_src_height+y_off) * vo_dga_width * vo_dga_bpp; |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
701 } |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
702 #endif |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
703 |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
704 printf("vo_dga: Clearing framebuffer (%d bytes). If mplayer exits", size); |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
705 printf(" here, you haven't enough memory on your card.\n"); |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
706 fflush(stdout); |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
707 memset(vo_dga_base, 0, size); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
708 } |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
709 printf("vo_dga: Doublebuffering %s.\n", vo_dga_dbf_mem_offset ? "enabled" : "disabled"); |
13 | 710 vo_dga_is_running = 1; |
711 return 0; | |
712 } | |
713 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
714 //--------------------------------------------------------- |
13 | 715 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
716 // deleted the old vo_dga_query_event() routine 'cause it is obsolete |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
717 // since using check_events() |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
718 // acki2 on 30/3/2001 |