Mercurial > mplayer.hg
annotate libvo/vo_dga.c @ 1150:8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
Default in libvo is disabled.
author | acki2 |
---|---|
date | Sun, 17 Jun 2001 20:59:39 +0000 |
parents | 83919c1b9924 |
children | 4bf4e057c82e |
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 * | |
392 | 17 * - covers only common video card formats i.e. |
18 * BGR_16_15_555 | |
19 * BGR_16_16_565 | |
20 * BGR_24_24_888 | |
21 * BGR_32_24_888 | |
22 * | |
23 * - works only on x86 architectures | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
24 * |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
25 * $Log$ |
1150
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
26 * Revision 1.24 2001/06/17 20:59:39 acki2 |
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
27 * - doublebuffering now can be switched on and off with the -(no)double switch. |
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
28 * Default in libvo is disabled. |
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
29 * |
865 | 30 * Revision 1.23 2001/05/24 20:48:45 arpi_esp |
31 * removed redundant osd.h includes | |
32 * | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
33 * Revision 1.22 2001/05/07 19:16:04 acki2 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
34 * - now chooses mode with highest ymax (enables doublebuffering in some cases |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
35 * it didn't work before) |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
36 * - use my own memcopy() on non MMX machines again |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
37 * - do memcpy() in one single block if stride==0 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
38 * |
691 | 39 * Revision 1.21 2001/05/03 22:39:38 acki2 |
40 * - finally: 15to16 conversion included!!! | |
41 * | |
690
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
42 * Revision 1.20 2001/05/02 23:21:27 acki2 |
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
43 * - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+ |
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
44 * |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
45 * Revision 1.19 2001/05/01 22:37:37 acki2 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
46 * - now features 24->32 conversion (this is actually faster than letting the |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
47 * codec produce depth 32 in the first place for avis :-))) ) |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
48 * |
677
ee2dac2cc633
- now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents:
616
diff
changeset
|
49 * Revision 1.18 2001/05/01 20:24:31 acki2 |
ee2dac2cc633
- now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents:
616
diff
changeset
|
50 * - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok? |
ee2dac2cc633
- now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents:
616
diff
changeset
|
51 * |
616 | 52 * Revision 1.17 2001/04/24 11:42:04 pontscho |
53 * clean up | |
54 * | |
612 | 55 * Revision 1.16 2001/04/24 10:21:12 szabii |
56 * some warnings killed | |
57 * | |
533 | 58 * Revision 1.15 2001/04/19 21:39:10 arpi_esp |
59 * driver info now depends on detected DGA version | |
60 * | |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
61 * Revision 1.14 2001/04/17 22:28:09 acki2 |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
62 * - now also supports OSD for YV12 (big speed penalty by having to build image |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
63 * in offscreen memory and then copying; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
64 * - OSD still works just with doublebuffering enabled :-( |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
65 * |
490 | 66 * Revision 1.13 2001/04/17 20:51:58 acki2 |
67 * - query_format() now uses new return value concept | |
68 * - now support for OSD :-))) for RGB modes | |
69 * YV12 is flickering in quite an ugly fashion; have to fix this, but | |
70 * will cost an extra copying of image data ... :-((( | |
71 * | |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
72 * Revision 1.12 2001/04/13 22:11:08 acki2 |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
73 * - fixed bug with depth and mpg when current bpp of XServer was != 32 |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
74 * - when -bpp is selected, I accept only query_modes() for THIS particular depth |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
75 * (if it's supported by hardware) |
392 | 76 * |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
77 * 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
|
78 * - 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
|
79 * |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
80 * 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
|
81 * - 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
|
82 * - 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
|
83 * - 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
|
84 * 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
|
85 * |
261 | 86 * |
87 * 30/02/2001 | |
13 | 88 * |
261 | 89 * o query_format(): with DGA 2.0 it returns all depths it supports |
90 * (even 16 when running 32 and vice versa) | |
91 * Checks for (hopefully!) compatible RGBmasks in 15/16 bit modes | |
92 * o added some more criterions for resolution switching | |
93 * o cleanup | |
94 * o with DGA2.0 present, ONLY DGA2.0 functions are used | |
95 * o for 15/16 modes ONLY RGB 555 is supported, since the divx-codec | |
96 * happens to map the data this way. If your graphics card supports | |
97 * this, you're well off and may use these modes; for mpeg | |
98 * movies things could be different, but I was too lazy to implement | |
99 * it ... | |
262 | 100 * o you may define VO_DGA_FORCE_DEPTH to the depth you desire |
101 * if you don't like the choice the driver makes | |
102 * Beware: unless you can use DGA2.0 this has to be your X Servers | |
103 * depth!!! | |
104 * 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
|
105 * 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
|
106 * mgraffam@idsi.net |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
107 * |
13 | 108 */ |
109 | |
392 | 110 //#define VO_DGA_DBG 1 |
111 //#undef HAVE_DGA2 | |
112 //#undef HAVE_XF86VM | |
13 | 113 |
114 #include <stdio.h> | |
115 #include <stdlib.h> | |
116 #include <string.h> | |
117 | |
118 #include "config.h" | |
119 #include "video_out.h" | |
120 #include "video_out_internal.h" | |
121 #include "yuv2rgb.h" | |
122 | |
123 LIBVO_EXTERN( dga ) | |
124 | |
125 #include <X11/Xlib.h> | |
126 #include <X11/extensions/xf86dga.h> | |
127 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
128 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
129 #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
|
130 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
131 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
132 |
31 | 133 #include "x11_common.h" |
13 | 134 |
690
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
135 #include "fastmemcpy.h" |
691 | 136 |
137 extern void rgb15to16_mmx(char* s0,char* d0,int count); | |
138 | |
13 | 139 static vo_info_t vo_info = |
140 { | |
533 | 141 #ifdef HAVE_DGA2 |
142 "DGA ( Direct Graphic Access V2.0 )", | |
143 #else | |
144 "DGA ( Direct Graphic Access V1.0+XF86VidModeExtension )", | |
145 #endif | |
13 | 146 "dga", |
147 "Andreas Ackermann <acki@acki-netz.de>", | |
148 "" | |
149 }; | |
150 | |
392 | 151 |
152 //------------------------------------------------------------------ | |
153 | |
154 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
155 //#define BITSPP (vo_dga_modes[vo_dga_active_mode].vdm_bitspp) |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
156 //#define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp) |
392 | 157 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
158 #define HW_MODE (vo_dga_modes[vo_dga_hw_mode]) |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
159 #define SRC_MODE (vo_dga_modes[vo_dga_src_mode]) |
490 | 160 |
392 | 161 struct vd_modes { |
162 int vdm_mplayer_depth; | |
163 int vdm_supported; | |
164 int vdm_depth; | |
165 int vdm_bitspp; | |
166 int vdm_bytespp; | |
167 int vdm_rmask; | |
168 int vdm_gmask; | |
169 int vdm_bmask; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
170 int vdm_hw_mode; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
171 int vdm_conversion_func; |
392 | 172 }; |
173 | |
174 //------------------------------------------------------------------ | |
175 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
176 #define VDM_CONV_NATIVE 0 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
177 #define VDM_CONV_15TO16 1 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
178 #define VDM_CONV_24TO32 2 |
392 | 179 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
180 static struct vd_modes vo_dga_modes[] = { |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
181 // these entries describe HW modes |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
182 // however, we use the same entries to tell mplayer what we support |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
183 // so the last two values describe, which HW mode to use and which conversion |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
184 // function to use for a mode that is not supported by HW |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
185 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
186 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
187 { 15, 0, 15, 16, 2, 0x7c00, 0x03e0, 0x001f, 2, VDM_CONV_15TO16 }, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
188 { 16, 0, 16, 16, 2, 0xf800, 0x07e0, 0x001f, 2, VDM_CONV_NATIVE }, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
189 { 24, 0, 24, 24, 3, 0xff0000, 0x00ff00, 0x0000ff, 4, VDM_CONV_24TO32}, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
190 { 32, 0, 24, 32, 4, 0x00ff0000, 0x0000ff00, 0x000000ff, 4, VDM_CONV_NATIVE} |
392 | 191 }; |
192 | |
193 static int vo_dga_mode_num = sizeof(vo_dga_modes)/sizeof(struct vd_modes); | |
194 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
195 // enable a HW mode (by description) |
392 | 196 int vd_EnableMode( int depth, int bitspp, |
197 int rmask, int gmask, int bmask){ | |
198 int i; | |
199 for(i=1; i<vo_dga_mode_num; i++){ | |
200 if(vo_dga_modes[i].vdm_depth == depth && | |
201 vo_dga_modes[i].vdm_bitspp == bitspp && | |
202 vo_dga_modes[i].vdm_rmask == rmask && | |
203 vo_dga_modes[i].vdm_gmask == gmask && | |
204 vo_dga_modes[i].vdm_bmask == bmask){ | |
205 vo_dga_modes[i].vdm_supported = 1; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
206 vo_dga_modes[i].vdm_hw_mode = i; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
207 vo_dga_modes[i].vdm_conversion_func = VDM_CONV_NATIVE; |
392 | 208 return i; |
209 } | |
210 } | |
211 return 0; | |
212 } | |
213 | |
214 int vd_ModeEqual(int depth, int bitspp, | |
215 int rmask, int gmask, int bmask, int index){ | |
216 return ( | |
217 (vo_dga_modes[index].vdm_depth == depth && | |
218 vo_dga_modes[index].vdm_bitspp == bitspp && | |
219 vo_dga_modes[index].vdm_rmask == rmask && | |
220 vo_dga_modes[index].vdm_gmask == gmask && | |
221 vo_dga_modes[index].vdm_bmask == bmask) | |
222 ? 1 : 0); | |
223 } | |
224 | |
225 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
226 // enable a HW mode (mplayer_depth decides which) |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
227 int vd_ValidateMode( int mplayer_depth){ |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
228 int i; |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
229 if(mplayer_depth == 0)return 0; |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
230 for(i=1; i<vo_dga_mode_num; i++){ |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
231 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth ){ |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
232 vo_dga_modes[i].vdm_supported = 1; |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
233 vo_dga_modes[i].vdm_hw_mode = i; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
234 vo_dga_modes[i].vdm_conversion_func = VDM_CONV_NATIVE; |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
235 return i; |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
236 } |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
237 } |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
238 return 0; |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
239 } |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
240 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
241 // do we support this mode? (not important whether native or conversion) |
392 | 242 int vd_ModeValid( int mplayer_depth){ |
243 int i; | |
244 if(mplayer_depth == 0)return 0; | |
245 for(i=1; i<vo_dga_mode_num; i++){ | |
246 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth && | |
247 vo_dga_modes[i].vdm_supported != 0){ | |
248 return i; | |
249 } | |
250 } | |
251 return 0; | |
252 } | |
253 | |
254 char *vd_GetModeString(int index){ | |
255 | |
256 #define VO_DGA_MAX_STRING_LEN 100 | |
257 static char stringbuf[VO_DGA_MAX_STRING_LEN]; | |
258 stringbuf[VO_DGA_MAX_STRING_LEN-1]=0; | |
259 snprintf(stringbuf, VO_DGA_MAX_STRING_LEN-2, | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
260 "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)", |
392 | 261 vo_dga_modes[index].vdm_depth, |
262 vo_dga_modes[index].vdm_bitspp, | |
263 vo_dga_modes[index].vdm_rmask, | |
264 vo_dga_modes[index].vdm_gmask, | |
265 vo_dga_modes[index].vdm_bmask, | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
266 vo_dga_modes[index].vdm_supported ? |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
267 (vo_dga_modes[index].vdm_conversion_func == VDM_CONV_NATIVE ? |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
268 "native (fast), " : "conversion (slow),") : |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
269 "not supported :-( ", |
392 | 270 vo_dga_modes[index].vdm_mplayer_depth); |
271 return stringbuf; | |
272 } | |
273 | |
274 //----------------------------------------------------------------- | |
275 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
276 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
277 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
|
278 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
279 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
280 |
392 | 281 extern int verbose; |
282 extern int vo_dbpp; | |
1150
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
283 extern int vo_doublebuffering; |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
284 |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
285 static int vo_dga_src_format; |
31 | 286 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
|
287 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
|
288 // framebuffer |
31 | 289 static int vo_dga_vp_height; // visible lines in framebuffer |
290 static int vo_dga_is_running = 0; | |
291 static int vo_dga_src_width; // width of video in pixels | |
292 static int vo_dga_src_height; // height of video in pixels | |
293 static int vo_dga_src_offset=0; // offset in src | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
294 static int vo_dga_vp_offset=0; // offset in dest |
262 | 295 static int vo_dga_bytes_per_line; // bytes per line to copy |
392 | 296 static int vo_dga_src_skip; // bytes to skip after copying one |
297 // line | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
298 // (not supported yet) in src |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
299 static int vo_dga_vp_skip; // dto. for dest |
392 | 300 static int vo_dga_lines; // num of lines to copy |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
301 static int vo_dga_hw_mode = 0; // index in mode list that is actually |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
302 // used by framebuffer |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
303 static int vo_dga_src_mode = 0; // index in mode list that is used by |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
304 // codec |
392 | 305 static int vo_dga_XServer_mode = 0;// index in mode list for resolution |
306 // XServer is running | |
13 | 307 |
262 | 308 static int vo_dga_dbf_mem_offset; // offset in bytes for alternative |
309 // framebuffer (0 if dbf is not | |
310 // possible) | |
311 static int vo_dga_dbf_y_offset; // y offset (in scanlines) | |
312 static int | |
313 vo_dga_dbf_current; // current buffer (0 or 1) | |
314 | |
31 | 315 static unsigned char *vo_dga_base; |
316 static Display *vo_dga_dpy; | |
13 | 317 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
318 //--------------------------------------------------------- |
13 | 319 |
392 | 320 #define VD_INFO 0 |
321 #define VD_ERR 0 | |
322 #define VD_DBG 2 | |
323 #define VD_RES 1 | |
324 | |
325 void vd_printf( int level, const char *str, ...){ | |
326 | |
490 | 327 #ifndef VO_DGA_DBG |
392 | 328 // show resolution and DBG-messages only in verbose mode ... |
329 if( !verbose && level)return; | |
330 #endif | |
490 | 331 vprintf( str, (&str)+1 ); |
332 } | |
392 | 333 |
490 | 334 //--------------------------------------------------------- |
335 | |
336 static void draw_alpha( int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride ){ | |
337 | |
338 char *d; | |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
339 unsigned int offset; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
340 unsigned int buffer_stride; |
490 | 341 |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
342 offset = vo_dga_width * y0 +x0; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
343 buffer_stride = vo_dga_width; |
490 | 344 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]); |
345 | |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
346 switch( HW_MODE.vdm_mplayer_depth ){ |
490 | 347 |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
348 case 32: |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
349 vo_draw_alpha_rgb32(w,h,src,srca,stride, d+4*offset , 4*buffer_stride); |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
350 break; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
351 case 24: |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
352 vo_draw_alpha_rgb24(w,h,src,srca,stride, d+3*offset , 3*buffer_stride); |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
353 break; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
354 case 15: |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
355 vo_draw_alpha_rgb15(w,h,src,srca,stride, d+2*offset , 2*buffer_stride); |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
356 break; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
357 case 16: |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
358 vo_draw_alpha_rgb16(w,h,src,srca,stride, d+2*offset , 2*buffer_stride); |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
359 break; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
360 } |
392 | 361 } |
362 | |
490 | 363 |
392 | 364 //--------------------------------------------------------- |
365 | |
366 | |
367 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
368 // I had tried to work with mmx/3dnow copy code but |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
369 // there was not much speed gain and I didn't know |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
370 // how to save the FPU/mmx registers - so the copy |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
371 // code interferred with sound output ... |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
372 // removed the leftovers |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
373 // acki2 on 30/3/2001 |
13 | 374 |
375 | |
376 #define rep_movsl(dest, src, numwords, d_add, count) \ | |
377 __asm__ __volatile__( \ | |
378 " \ | |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
379 1: \n\t\ |
13 | 380 movl %%edx, %%ecx \n\t \ |
381 cld\n\t \ | |
382 rep\n\t \ | |
383 movsl \n\t\ | |
384 add %%eax, %%edi \n\t\ | |
385 dec %%ebx \n\t\ | |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
386 jnz 1b \n\t\ |
13 | 387 " \ |
388 : \ | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
389 : "a" (d_add), "b" (count), "S" (src), "D" (dest), \ |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
390 "d" (numwords) \ |
13 | 391 : "memory" ) |
392 | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
393 // quick & dirty - for debugging only |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
394 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
395 void fillblock(char *strt, int yoff, int lines, int val){ |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
396 char *i; |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
397 for(i = strt + yoff * vo_dga_width *HW_MODE.vdm_bytespp; |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
398 i< strt + (lines+yoff) * vo_dga_width *HW_MODE.vdm_bytespp; ){ |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
399 *i++ = val; |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
400 } |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
401 } |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
402 |
13 | 403 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
404 //--------------------------------------------------------- |
13 | 405 |
406 static uint32_t draw_frame( uint8_t *src[] ){ | |
407 | |
408 int vp_skip = vo_dga_vp_skip; | |
409 int lpl = vo_dga_bytes_per_line >> 2; | |
410 int numlines = vo_dga_lines; | |
411 | |
412 char *s, *d; | |
413 | |
262 | 414 s = *src; |
415 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]); | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
416 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
417 switch(SRC_MODE.vdm_conversion_func){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
418 case VDM_CONV_NATIVE: |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
419 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
420 #ifdef HAVE_MMX |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
421 // use the code from fastmemcpy.h |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
422 if(vo_dga_vp_skip){ |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
423 // use some stride ... |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
424 int i; |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
425 for(i=0; i< vo_dga_lines; i++){ |
690
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
426 memcpy(d, s, vo_dga_bytes_per_line); |
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
427 d+=vo_dga_vp_skip; |
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
428 d+=vo_dga_bytes_per_line; |
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
429 s+=vo_dga_bytes_per_line; |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
430 } |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
431 }else{ |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
432 // no stride, cool + fast ... |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
433 memcpy(d,s, vo_dga_bytes_per_line * vo_dga_lines); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
434 } |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
435 #else |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
436 // use some homebrewn assembly code ... |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
437 rep_movsl(d, s, lpl, vo_dga_vp_skip, numlines ); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
438 #endif |
690
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
439 |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
440 // DBG-COde |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
441 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
442 #if 0 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
443 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
444 fillblock(d, 0, 10, 0x800000ff); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
445 fillblock(d, 10, 10, 0x8000ff00); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
446 fillblock(d, 20, 10, 0x80ff0000); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
447 fillblock(d, 30, 10, 0xff0000ff); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
448 fillblock(d, 40, 10, 0x800000ff); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
449 fillblock(d, 50, 10, 0x0f0000ff); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
450 #endif |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
451 break; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
452 case VDM_CONV_15TO16: |
691 | 453 { |
454 int i; | |
455 char *e; | |
456 for(i=0; i< vo_dga_lines; i++){ | |
457 #ifdef HAVE_MMX | |
458 rgb15to16_mmx( s, d, vo_dga_bytes_per_line); | |
459 d+=vo_dga_bytes_per_line; | |
460 s+=vo_dga_bytes_per_line; | |
461 #else | |
462 e = s+vo_dga_bytes_per_line; | |
463 while( s< e ){ | |
464 register uint16_t x = *(((uint16_t *)s)++); | |
465 *(((uint16_t *)d)++)=( x&0x001F )|( ( x&0x7FE0 )<<1 ); | |
466 } | |
467 | |
468 #endif | |
469 d+= vo_dga_vp_skip; | |
470 } | |
471 } | |
472 break; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
473 case VDM_CONV_24TO32: |
691 | 474 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
475 { |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
476 int i,k,l,m; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
477 for(i = 0; i< vo_dga_lines; i++ ){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
478 for(k = 0; k< vo_dga_src_width; k+=2 ){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
479 l = *(((uint32_t *)s)++); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
480 m = (l & 0xff000000)>> 24 ; |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
481 *(((uint32_t *)d)++) = (l & 0x00ffffff); // | 0x80000000; |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
482 m |= *(((uint16_t *)s)++) << 8; |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
483 *(((uint32_t *)d)++) = m; // | 0x80000000 ; |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
484 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
485 d+= vp_skip; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
486 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
487 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
488 //printf("vo_dga: 24 to 32 not implemented yet!!!\n"); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
489 break; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
490 } |
13 | 491 return 0; |
492 } | |
493 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
494 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
495 |
31 | 496 static void check_events(void) |
497 { | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
498 int e=vo_x11_check_events(vo_dga_dpy); |
31 | 499 } |
500 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
501 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
502 |
616 | 503 #include "sub.h" |
612 | 504 |
13 | 505 static void flip_page( void ){ |
262 | 506 |
507 if(vo_dga_dbf_mem_offset != 0){ | |
1150
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
508 vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha); |
262 | 509 |
510 #ifdef HAVE_DGA2 | |
511 XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), | |
512 0, vo_dga_dbf_current * vo_dga_dbf_y_offset, | |
513 XDGAFlipRetrace); | |
514 #else | |
515 XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), | |
392 | 516 0, vo_dga_dbf_current * vo_dga_dbf_y_offset); |
262 | 517 #endif |
518 vo_dga_dbf_current = 1 - vo_dga_dbf_current; | |
519 } | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
520 check_events(); |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
521 } |
13 | 522 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
523 //--------------------------------------------------------- |
13 | 524 |
525 static uint32_t draw_slice( uint8_t *src[],int stride[], | |
526 int w,int h,int x,int y ) | |
527 { | |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
528 |
677
ee2dac2cc633
- now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents:
616
diff
changeset
|
529 yuv2rgb( vo_dga_base + vo_dga_dbf_current * vo_dga_dbf_mem_offset + vo_dga_vp_offset + |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
530 (vo_dga_width * y +x) * HW_MODE.vdm_bytespp, |
677
ee2dac2cc633
- now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents:
616
diff
changeset
|
531 src[0], src[1], src[2], |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
532 w,h, vo_dga_width * HW_MODE.vdm_bytespp, |
677
ee2dac2cc633
- now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents:
616
diff
changeset
|
533 stride[0],stride[1] ); |
13 | 534 return 0; |
535 }; | |
536 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
537 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
538 |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
539 |
13 | 540 static void Terminate_Display_Process( void ){ |
392 | 541 vd_printf(VD_DBG, "vo_dga: Terminating display process\n"); |
13 | 542 } |
543 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
544 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
545 |
13 | 546 static const vo_info_t* get_info( void ) |
547 { return &vo_info; } | |
548 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
549 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
550 |
13 | 551 static uint32_t query_format( uint32_t format ) |
552 { | |
261 | 553 |
554 #ifdef HAVE_DGA2 | |
555 XDGAMode *modelines; | |
556 int modecount; | |
392 | 557 #endif |
261 | 558 Display *qdisp; |
392 | 559 |
560 int i; | |
261 | 561 static int dga_depths_init = 0; |
562 | |
563 if(dga_depths_init == 0){ | |
13 | 564 |
261 | 565 if((qdisp = XOpenDisplay(0))==NULL){ |
392 | 566 vd_printf(VD_ERR, "vo_dga: Can't open display!\n"); |
261 | 567 return 0; |
568 } | |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
569 if( !vo_init() ){ |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
570 vd_printf(VD_ERR, "vo_dga: vo_init() failed!\n"); |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
571 return 1; |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
572 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
573 vo_dga_XServer_mode = vd_ValidateMode(vo_depthonscreen); |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
574 |
392 | 575 if(vo_dga_XServer_mode ==0){ |
576 #ifndef HAVE_DGA2 | |
577 vd_printf(VD_ERR, "vo_dga: Your X-Server is not running in a "); | |
578 vd_printf(VD_ERR, "resolution supported by DGA driver!\n"); | |
579 #endif | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
580 }//else{ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
581 // vd_printf(VD_INFO, "vo_dga: X running at: %s\n", |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
582 // vd_GetModeString(vo_dga_XServer_mode)); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
583 //} |
392 | 584 |
585 #ifdef HAVE_DGA2 | |
261 | 586 modelines=XDGAQueryModes(qdisp, XDefaultScreen(qdisp),&modecount); |
392 | 587 if(modelines){ |
588 for(i=0; i< modecount; i++){ | |
589 vd_printf(VD_DBG, "vo_dga: (%03d) depth=%d, bpp=%d, r=%08x, g=%08x, b=%08x, %d x %d\n", | |
590 i, | |
591 modelines[i].depth, | |
592 modelines[i].bitsPerPixel, | |
593 modelines[i].redMask, | |
594 modelines[i].greenMask, | |
595 modelines[i].blueMask, | |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
596 modelines[i].viewportWidth, |
392 | 597 modelines[i].viewportHeight); |
598 vd_EnableMode( | |
599 modelines[i].depth, | |
600 modelines[i].bitsPerPixel, | |
601 modelines[i].redMask, | |
602 modelines[i].greenMask, | |
603 modelines[i].blueMask); | |
604 } | |
605 XFree(modelines); | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
606 |
261 | 607 } |
608 #endif | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
609 dga_depths_init = 1; |
392 | 610 XCloseDisplay(qdisp); |
611 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
612 if( !vo_dga_modes[1].vdm_supported && vo_dga_modes[2].vdm_supported ){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
613 vo_dga_modes[1].vdm_supported = 1; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
614 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
615 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
616 if( !vo_dga_modes[3].vdm_supported && vo_dga_modes[4].vdm_supported ){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
617 vo_dga_modes[3].vdm_supported = 1; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
618 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
619 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
620 for(i=1; i<vo_dga_mode_num; i++){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
621 vd_printf(VD_INFO, "vo_dga: Mode: %s", vd_GetModeString(i)); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
622 if(vo_dbpp && vo_dbpp != vo_dga_modes[i].vdm_mplayer_depth){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
623 vo_dga_modes[i].vdm_supported = 0; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
624 vd_printf(VD_INFO, " ...disabled by -bpp %d", vo_dbpp ); |
261 | 625 } |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
626 vd_printf(VD_INFO, "\n"); |
261 | 627 } |
628 } | |
392 | 629 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
630 // TODO: respect bit for native/not native |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
631 if( format==IMGFMT_YV12 ) return 7; |
261 | 632 |
392 | 633 if( (format&IMGFMT_BGR_MASK) == IMGFMT_BGR && |
490 | 634 vd_ModeValid(format&0xff)) return 7; |
392 | 635 |
13 | 636 return 0; |
637 } | |
638 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
639 //--------------------------------------------------------- |
13 | 640 |
641 static void | |
642 uninit(void) | |
643 { | |
644 | |
261 | 645 #ifdef HAVE_DGA2 |
646 XDGADevice *dgadevice; | |
647 #endif | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
648 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
649 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
|
650 vo_dga_is_running = 0; |
392 | 651 vd_printf( VD_DBG, "vo_dga: in uninit\n"); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
652 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
|
653 XUngrabKeyboard (vo_dga_dpy, CurrentTime); |
261 | 654 #ifdef HAVE_DGA2 |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
655 XDGACloseFramebuffer(vo_dga_dpy, XDefaultScreen(vo_dga_dpy)); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
656 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
|
657 if(dgadevice != NULL){ |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
658 XFree(dgadevice); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
659 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
660 #else |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
661 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
|
662 // 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
|
663 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
664 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
|
665 int screen; screen=XDefaultScreen( vo_dga_dpy ); |
392 | 666 vd_printf(VD_DBG, "vo_dga: VidModeExt: Switching back..\n"); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
667 // 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
|
668 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
|
669 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
|
670 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
|
671 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
|
672 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
|
673 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
674 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
675 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
676 XCloseDisplay(vo_dga_dpy); |
261 | 677 } |
13 | 678 } |
679 | |
680 | |
261 | 681 //---------------------------------------------------------- |
392 | 682 // TODO: check for larger maxy value |
683 // (useful for double buffering!!!) | |
261 | 684 |
392 | 685 int check_res( int num, int x, int y, int bpp, |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
686 int new_x, int new_y, int new_vbi, int new_maxy, |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
687 int *old_x, int *old_y, int *old_vbi, int *old_maxy){ |
261 | 688 |
392 | 689 vd_printf(VD_RES, "vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ depth %2d ..", |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
690 num, new_x, new_y, new_vbi, bpp ); |
392 | 691 vd_printf(VD_RES, "(old: %dx%d@%d).", *old_x, *old_y, *old_vbi); |
261 | 692 if ( |
693 (new_x >= x) && | |
694 (new_y >= y) && | |
695 ( | |
696 // prefer a better resolution either in X or in Y | |
697 // as long as the other dimension is at least the same | |
698 // | |
699 // hmm ... MAYBE it would be more clever to focus on the | |
700 // x-resolution; I had 712x400 and 640x480 and the movie | |
701 // was 640x360; 640x480 would be the 'right thing' here | |
702 // but since 712x400 was queried first I got this one. | |
703 // I think there should be a cmd-line switch to let the | |
704 // user choose the mode he likes ... (acki2) | |
705 | |
706 ( | |
707 ((new_x < *old_x) && | |
708 !(new_y > *old_y)) || | |
709 ((new_y < *old_y) && | |
710 !(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
|
711 ) |
261 | 712 // but if we get an identical resolution choose |
713 // the one with the lower refreshrate (saves bandwidth !!!) | |
714 // as long as it's above 50 Hz (acki2 on 30/3/2001) | |
715 || | |
716 ( | |
717 (new_x == *old_x) && | |
718 (new_y == *old_y) && | |
719 ( | |
720 ( | |
721 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
|
722 ) |
261 | 723 || |
724 ( | |
725 *old_vbi >= 50 && | |
726 new_vbi < *old_vbi && | |
727 new_vbi >= 50 | |
728 ) | |
729 ) | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
730 || |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
731 // if everything is equal, then use the mode with the lower |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
732 // stride |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
733 ( |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
734 (new_x == *old_x) && |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
735 (new_y == *old_y) && |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
736 (new_vbi == *old_vbi) && |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
737 (new_maxy > *old_maxy) |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
738 ) |
261 | 739 ) |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
740 ) |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
741 ) |
261 | 742 { |
743 *old_x = new_x; | |
744 *old_y = new_y; | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
745 *old_maxy = new_maxy; |
261 | 746 *old_vbi = new_vbi; |
392 | 747 vd_printf(VD_RES, ".ok!!\n"); |
261 | 748 return 1; |
749 }else{ | |
392 | 750 vd_printf(VD_RES, ".no\n"); |
261 | 751 return 0; |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
752 } |
261 | 753 } |
754 | |
755 | |
756 | |
757 //--------------------------------------------------------- | |
758 | |
759 static uint32_t init( uint32_t width, uint32_t height, | |
760 uint32_t d_width,uint32_t d_height, | |
761 uint32_t fullscreen,char *title,uint32_t format ) | |
762 { | |
763 | |
764 int x_off, y_off; | |
392 | 765 int wanted_width, wanted_height; |
261 | 766 |
767 #ifdef HAVE_DGA2 | |
768 // needed to change DGA video mode | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
769 int modecount, mX=100000, mY=100000 , mVBI=100000, mMaxY=0, i,j=0; |
261 | 770 int dga_modenum; |
771 XDGAMode *modelines=NULL; | |
772 XDGADevice *dgadevice; | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
773 int max_vpy_pos; |
261 | 774 #else |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
775 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
776 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
|
777 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
|
778 int i, j=0, have_vm=0; |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
779 int modecount, mX=100000, mY=100000, mVBI=100000, mMaxY=0, dga_modenum; |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
780 #endif |
261 | 781 int bank, ram; |
782 #endif | |
783 | |
784 if( vo_dga_is_running )return -1; | |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
785 vo_dga_src_format = format; |
392 | 786 wanted_width = d_width; |
787 wanted_height = d_height; | |
261 | 788 |
392 | 789 if(!wanted_height) wanted_height = height; |
790 if(!wanted_width) wanted_width = width; | |
791 | |
261 | 792 if( !vo_init() ){ |
392 | 793 vd_printf(VD_ERR, "vo_dga: vo_init() failed!\n"); |
794 return 1; | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
795 } |
392 | 796 |
797 if( !vo_dbpp ){ | |
261 | 798 |
392 | 799 if (format == IMGFMT_YV12){ |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
800 vo_dga_src_mode = vo_dga_XServer_mode; |
392 | 801 }else if((format & IMGFMT_BGR_MASK) == IMGFMT_BGR){ |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
802 vo_dga_src_mode = vd_ModeValid( format & 0xff ); |
392 | 803 } |
261 | 804 }else{ |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
805 vo_dga_src_mode = vd_ModeValid(vo_dbpp); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
806 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
807 vo_dga_hw_mode = SRC_MODE.vdm_hw_mode; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
808 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
809 if( format == IMGFMT_YV12 && vo_dga_src_mode != vo_dga_hw_mode ){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
810 vd_printf(VD_ERR, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
811 "vo_dga: YV12 supports native modes only. Using %d instead of selected %d.\n", |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
812 HW_MODE.vdm_mplayer_depth, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
813 SRC_MODE.vdm_mplayer_depth ); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
814 vo_dga_src_mode = vo_dga_hw_mode; |
392 | 815 } |
261 | 816 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
817 if(!vo_dga_src_mode){ |
392 | 818 vd_printf(VD_ERR, "vo_dga: unsupported video format!\n"); |
819 return 1; | |
261 | 820 } |
821 | |
392 | 822 if((vo_dga_dpy = XOpenDisplay(0))==NULL){ |
823 vd_printf (VD_ERR, "vo_dga: Can't open display\n"); | |
261 | 824 return 1; |
825 } | |
826 | |
392 | 827 vo_dga_vp_width = DisplayWidth( vo_dga_dpy, DefaultScreen(vo_dga_dpy)); |
828 vo_dga_vp_height = DisplayHeight( vo_dga_dpy, DefaultScreen(vo_dga_dpy)); | |
261 | 829 |
392 | 830 vd_printf(VD_DBG, "vo_dga: XServer res: %dx%d\n", |
831 vo_dga_vp_width, vo_dga_vp_height); | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
832 |
261 | 833 // choose a suitable mode ... |
834 | |
835 #ifdef HAVE_DGA2 | |
836 // Code to change the video mode added by Michael Graffam | |
837 // mgraffam@idsi.net | |
838 if (modelines==NULL) | |
839 modelines=XDGAQueryModes(vo_dga_dpy, XDefaultScreen(vo_dga_dpy),&modecount); | |
840 | |
392 | 841 vd_printf(VD_INFO, |
842 "vo_dga: DGA 2.0 available :-) Can switch resolution AND depth!\n"); | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
843 for (i=0; i<modecount; i++) |
261 | 844 { |
392 | 845 if(vd_ModeEqual( modelines[i].depth, |
846 modelines[i].bitsPerPixel, | |
847 modelines[i].redMask, | |
848 modelines[i].greenMask, | |
849 modelines[i].blueMask, | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
850 vo_dga_hw_mode)){ |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
851 |
392 | 852 vd_printf(VD_DBG, "maxy: %4d, depth: %2d, %4dx%4d, ", |
853 modelines[i].maxViewportY, modelines[i].depth, | |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
854 modelines[i].imageWidth, modelines[i].imageHeight ); |
392 | 855 if ( check_res(i, wanted_width, wanted_height, modelines[i].depth, |
261 | 856 modelines[i].viewportWidth, |
857 modelines[i].viewportHeight, | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
858 (unsigned) modelines[i].verticalRefresh, |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
859 modelines[i].maxViewportY, |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
860 &mX, &mY, &mVBI, &mMaxY )) j = i; |
261 | 861 } |
862 } | |
392 | 863 vd_printf(VD_INFO, |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
864 "vo_dga: Selected hardware mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d.\n", |
392 | 865 mX, mY, mVBI, |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
866 HW_MODE.vdm_depth, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
867 HW_MODE.vdm_bitspp); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
868 vd_printf(VD_INFO, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
869 "vo_dga: Video parameters by codec: %3d x %3d, depth %2d, bitspp %2d.\n", |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
870 width, height, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
871 SRC_MODE.vdm_depth, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
872 SRC_MODE.vdm_bitspp); |
261 | 873 vo_dga_vp_width =mX; |
874 vo_dga_vp_height = mY; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
875 vo_dga_width = modelines[j].bytesPerScanline / HW_MODE.vdm_bytespp ; |
261 | 876 dga_modenum = modelines[j].num; |
392 | 877 max_vpy_pos = modelines[j].maxViewportY; |
261 | 878 |
879 XFree(modelines); | |
880 modelines = NULL; | |
881 | |
882 #else | |
883 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
884 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
885 |
392 | 886 vd_printf( VD_INFO, |
887 "vo_dga: DGA 1.0 compatibility code: Using XF86VidMode for mode switching!\n"); | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
888 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
889 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
|
890 XF86VidModeQueryVersion(vo_dga_dpy, &vm_ver, &vm_rev); |
392 | 891 vd_printf(VD_INFO, "vo_dga: XF86VidMode Extension v%i.%i\n", vm_ver, vm_rev); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
892 have_vm=1; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
893 } else { |
392 | 894 vd_printf(VD_ERR, "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
|
895 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
896 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
897 #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
|
898 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
899 if (have_vm) { |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
900 int screen; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
901 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
|
902 XF86VidModeGetAllModeLines(vo_dga_dpy,screen,&modecount,&vo_dga_vidmodes); |
261 | 903 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
904 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
|
905 for (i=0; i<modecount; i++){ |
392 | 906 if ( check_res(i, wanted_width, wanted_height, |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
907 vo_dga_modes[vo_dga_hw_mode].vdm_depth, |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
908 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
|
909 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
|
910 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
|
911 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
|
912 vo_dga_vidmodes[i]->vtotal), |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
913 0, |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
914 &mX, &mY, &mVBI, &mMaxY )) j = i; |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
915 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
916 |
392 | 917 vd_printf(VD_INFO, |
918 "vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n", | |
919 mX, mY, mVBI, | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
920 vo_dga_modes[vo_dga_hw_mode].vdm_depth, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
921 vo_dga_modes[vo_dga_hw_mode].vdm_bitspp, |
392 | 922 width, height); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
923 }else{ |
392 | 924 vd_printf(VD_INFO, "vo_dga: XF86VidMode returned no screens - using current resolution.\n"); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
925 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
926 dga_modenum = j; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
927 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
|
928 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
|
929 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
930 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
931 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
932 #else |
392 | 933 vd_printf( VD_INFO, "vo_dga: Only have DGA 1.0 extension and no XF86VidMode :-(\n"); |
934 vd_printf( VD_INFO, " Thus, resolution switching is NOT possible.\n"); | |
935 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
936 #endif |
261 | 937 #endif |
938 | |
939 vo_dga_src_width = width; | |
940 vo_dga_src_height = height; | |
941 | |
942 if(vo_dga_src_width > vo_dga_vp_width || | |
943 vo_dga_src_height > vo_dga_vp_height) | |
944 { | |
392 | 945 vd_printf( VD_ERR, "vo_dga: Sorry, video larger than viewport is not yet supported!\n"); |
261 | 946 // 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
|
947 #ifndef HAVE_DGA2 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
948 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
949 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
|
950 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
|
951 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
|
952 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
953 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
954 #endif |
261 | 955 return 1; |
956 } | |
957 | |
958 // now lets start the DGA thing | |
959 | |
960 #ifdef HAVE_DGA2 | |
961 | |
962 if (!XDGAOpenFramebuffer(vo_dga_dpy, XDefaultScreen(vo_dga_dpy))){ | |
392 | 963 vd_printf(VD_ERR, "vo_dga: Framebuffer mapping failed!!!\n"); |
261 | 964 XCloseDisplay(vo_dga_dpy); |
965 return 1; | |
966 } | |
967 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
|
968 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
|
969 |
261 | 970 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
|
971 XFree(dgadevice); |
261 | 972 |
973 XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0, XDGAFlipRetrace); | |
974 | |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
975 #else |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
976 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
977 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
978 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
|
979 // 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
|
980 // 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
|
981 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
|
982 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
|
983 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
984 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
985 XF86DGAGetViewPortSize(vo_dga_dpy,XDefaultScreen(vo_dga_dpy), |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
986 &vo_dga_vp_width, |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
987 &vo_dga_vp_height); |
13 | 988 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
989 XF86DGAGetVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
990 (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
|
991 |
261 | 992 XF86DGADirectVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), |
993 XF86DGADirectGraphics | XF86DGADirectMouse | | |
994 XF86DGADirectKeyb); | |
995 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
996 XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0); |
261 | 997 |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
998 #endif |
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
999 |
13 | 1000 // do some more checkings here ... |
261 | 1001 |
392 | 1002 if( format==IMGFMT_YV12 ){ |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1003 yuv2rgb_init( vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth , MODE_RGB ); |
392 | 1004 vd_printf( VD_DBG, "vo_dga: Using mplayer depth %d for YV12\n", |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1005 vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth); |
392 | 1006 } |
13 | 1007 |
392 | 1008 vd_printf(VD_DBG, "vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %08x, bpp: %d\n", |
13 | 1009 vo_dga_width, vo_dga_vp_width, |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1010 vo_dga_vp_height, HW_MODE.vdm_bytespp, vo_dga_base, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1011 HW_MODE.vdm_bitspp); |
13 | 1012 |
1013 x_off = (vo_dga_vp_width - vo_dga_src_width)>>1; | |
1014 y_off = (vo_dga_vp_height - vo_dga_src_height)>>1; | |
1015 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1016 vo_dga_bytes_per_line = vo_dga_src_width * HW_MODE.vdm_bytespp; |
261 | 1017 vo_dga_lines = vo_dga_src_height; |
13 | 1018 |
1019 vo_dga_src_offset = 0; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1020 vo_dga_vp_offset = (y_off * vo_dga_width + x_off ) * HW_MODE.vdm_bytespp; |
13 | 1021 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1022 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * HW_MODE.vdm_bytespp; // todo |
13 | 1023 |
392 | 1024 vd_printf(VD_DBG, "vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n", |
13 | 1025 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line); |
1026 | |
1027 | |
1028 XGrabKeyboard (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True, | |
1029 GrabModeAsync,GrabModeAsync, CurrentTime); | |
1030 XGrabPointer (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True, | |
1031 ButtonPressMask,GrabModeAsync, GrabModeAsync, | |
1032 None, None, CurrentTime); | |
262 | 1033 // TODO: chekc if mem of graphics adaptor is large enough for dbf |
1034 | |
1035 // 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
|
1036 // note: set vo_dga_dbf_mem_offset to NULL to disable doublebuffering |
262 | 1037 |
1038 vo_dga_dbf_y_offset = y_off + vo_dga_src_height; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1039 vo_dga_dbf_mem_offset = vo_dga_width * HW_MODE.vdm_bytespp * vo_dga_dbf_y_offset; |
262 | 1040 vo_dga_dbf_current = 0; |
1150
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
1041 |
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
1042 |
8682a16321db
- doublebuffering now can be switched on and off with the -(no)double switch.
acki2
parents:
865
diff
changeset
|
1043 if(!vo_doublebuffering) vo_dga_dbf_mem_offset = NULL; |
262 | 1044 |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
1045 // if(format ==IMGFMT_YV12 ) |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
1046 //vo_dga_dbf_mem_offset = 0; |
262 | 1047 // 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
|
1048 |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1049 #ifdef HAVE_DGA2 |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1050 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
|
1051 vo_dga_dbf_mem_offset = 0; |
392 | 1052 vd_printf(VD_INFO, "vo_dga: Not enough memory for double buffering!\n"); |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1053 } |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1054 #endif |
262 | 1055 |
13 | 1056 // 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
|
1057 { |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
1058 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
|
1059 (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
|
1060 (vo_dga_src_height+y_off) : 0)) * |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1061 HW_MODE.vdm_bytespp; |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1062 #ifndef HAVE_DGA2 |
392 | 1063 vd_printf(VD_DBG, "vo_dga: wanted size=%d, fb-size=%d\n", size, ram); |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1064 if(size>ram*1024){ |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1065 vo_dga_dbf_mem_offset = 0; |
392 | 1066 vd_printf(VD_INFO, "vo_dga: Not enough memory for double buffering!\n"); |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1067 size -= (vo_dga_src_height+y_off) * vo_dga_width * HW_MODE.vdm_bytespp; |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1068 } |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1069 #endif |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1070 |
392 | 1071 vd_printf(VD_INFO, "vo_dga: Clearing framebuffer (%d bytes). If mplayer exits", size); |
1072 vd_printf(VD_INFO, " here, you haven't enough memory on your card.\n"); | |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1073 fflush(stdout); |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
1074 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
|
1075 } |
392 | 1076 vd_printf(VD_INFO, "vo_dga: Doublebuffering is %s.\n", vo_dga_dbf_mem_offset ? "enabled" : "disabled"); |
13 | 1077 vo_dga_is_running = 1; |
1078 return 0; | |
1079 } | |
1080 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
1081 //--------------------------------------------------------- |
13 | 1082 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
1083 // 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
|
1084 // since using check_events() |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
1085 // acki2 on 30/3/2001 |
392 | 1086 |
1087 | |
1088 | |
1089 | |
1090 | |
1091 | |
1092 | |
1093 | |
1094 | |
1095 |