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