Mercurial > mplayer.hg
annotate libvo/vo_dga.c @ 7731:1f8961f2b34c
compiler warning fixes
patch by Dominik Mierzejewski <dominik@rangers.eu.org>
author | arpi |
---|---|
date | Sun, 13 Oct 2002 21:58:55 +0000 |
parents | dc789525a89b |
children | a77aff3d7ac0 |
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 * | |
261 | 23 * |
24 * 30/02/2001 | |
13 | 25 * |
261 | 26 * o query_format(): with DGA 2.0 it returns all depths it supports |
27 * (even 16 when running 32 and vice versa) | |
28 * Checks for (hopefully!) compatible RGBmasks in 15/16 bit modes | |
29 * o added some more criterions for resolution switching | |
30 * o cleanup | |
31 * o with DGA2.0 present, ONLY DGA2.0 functions are used | |
32 * o for 15/16 modes ONLY RGB 555 is supported, since the divx-codec | |
33 * happens to map the data this way. If your graphics card supports | |
34 * this, you're well off and may use these modes; for mpeg | |
35 * movies things could be different, but I was too lazy to implement | |
36 * it ... | |
262 | 37 * o you may define VO_DGA_FORCE_DEPTH to the depth you desire |
38 * if you don't like the choice the driver makes | |
39 * Beware: unless you can use DGA2.0 this has to be your X Servers | |
40 * depth!!! | |
41 * 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
|
42 * 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
|
43 * mgraffam@idsi.net |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
44 * |
13 | 45 */ |
46 | |
392 | 47 //#define VO_DGA_DBG 1 |
48 //#undef HAVE_DGA2 | |
49 //#undef HAVE_XF86VM | |
13 | 50 |
51 #include <stdio.h> | |
52 #include <stdlib.h> | |
53 #include <string.h> | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
54 #include <errno.h> |
13 | 55 |
56 #include "config.h" | |
57 #include "video_out.h" | |
58 #include "video_out_internal.h" | |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
59 #include "../postproc/swscale.h" |
2732 | 60 #include "../postproc/rgb2rgb.h" |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
61 #include "aspect.h" |
13 | 62 |
63 LIBVO_EXTERN( dga ) | |
64 | |
65 #include <X11/Xlib.h> | |
66 #include <X11/extensions/xf86dga.h> | |
67 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
68 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
69 #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
|
70 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
71 |
31 | 72 #include "x11_common.h" |
2556 | 73 #include "../postproc/rgb2rgb.h" |
690
2094b195a9bc
- now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents:
680
diff
changeset
|
74 #include "fastmemcpy.h" |
691 | 75 |
6206
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
76 #include "../mp_msg.h" |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
77 |
13 | 78 static vo_info_t vo_info = |
79 { | |
533 | 80 #ifdef HAVE_DGA2 |
81 "DGA ( Direct Graphic Access V2.0 )", | |
82 #else | |
7499 | 83 #ifdef HAVE_XF86VM |
84 "DGA ( Direct Graphic Access V1.0+XF86VidModeExt. )", | |
85 #else | |
86 "DGA ( Direct Graphic Access V1.0 )", | |
87 #endif | |
533 | 88 #endif |
13 | 89 "dga", |
90 "Andreas Ackermann <acki@acki-netz.de>", | |
91 "" | |
92 }; | |
93 | |
392 | 94 |
95 //------------------------------------------------------------------ | |
96 | |
97 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
98 //#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
|
99 //#define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp) |
392 | 100 |
1154
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
101 #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
|
102 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
103 #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
|
104 #define SRC_MODE (vo_dga_modes[vo_dga_src_mode]) |
490 | 105 |
392 | 106 struct vd_modes { |
107 int vdm_mplayer_depth; | |
108 int vdm_supported; | |
109 int vdm_depth; | |
110 int vdm_bitspp; | |
111 int vdm_bytespp; | |
112 int vdm_rmask; | |
113 int vdm_gmask; | |
114 int vdm_bmask; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
115 int vdm_hw_mode; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
116 int vdm_conversion_func; |
392 | 117 }; |
118 | |
119 //------------------------------------------------------------------ | |
120 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
121 #define VDM_CONV_NATIVE 0 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
122 #define VDM_CONV_15TO16 1 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
123 #define VDM_CONV_24TO32 2 |
392 | 124 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
125 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
|
126 // these entries describe HW modes |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
127 // 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
|
128 // 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
|
129 // 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
|
130 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
131 { 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
|
132 { 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
|
133 { 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
|
134 { 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
|
135 { 32, 0, 24, 32, 4, 0x00ff0000, 0x0000ff00, 0x000000ff, 4, VDM_CONV_NATIVE} |
392 | 136 }; |
137 | |
138 static int vo_dga_mode_num = sizeof(vo_dga_modes)/sizeof(struct vd_modes); | |
139 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
140 // enable a HW mode (by description) |
7499 | 141 static int vd_EnableMode( int depth, int bitspp, |
392 | 142 int rmask, int gmask, int bmask){ |
143 int i; | |
144 for(i=1; i<vo_dga_mode_num; i++){ | |
145 if(vo_dga_modes[i].vdm_depth == depth && | |
146 vo_dga_modes[i].vdm_bitspp == bitspp && | |
147 vo_dga_modes[i].vdm_rmask == rmask && | |
148 vo_dga_modes[i].vdm_gmask == gmask && | |
149 vo_dga_modes[i].vdm_bmask == bmask){ | |
150 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
|
151 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
|
152 vo_dga_modes[i].vdm_conversion_func = VDM_CONV_NATIVE; |
392 | 153 return i; |
154 } | |
155 } | |
156 return 0; | |
157 } | |
158 | |
7499 | 159 static int vd_ModeEqual(int depth, int bitspp, |
392 | 160 int rmask, int gmask, int bmask, int index){ |
161 return ( | |
162 (vo_dga_modes[index].vdm_depth == depth && | |
163 vo_dga_modes[index].vdm_bitspp == bitspp && | |
164 vo_dga_modes[index].vdm_rmask == rmask && | |
165 vo_dga_modes[index].vdm_gmask == gmask && | |
166 vo_dga_modes[index].vdm_bmask == bmask) | |
167 ? 1 : 0); | |
168 } | |
169 | |
170 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
171 // enable a HW mode (mplayer_depth decides which) |
7499 | 172 static int vd_ValidateMode( int mplayer_depth){ |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
173 int i; |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
174 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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 return i; |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
181 } |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
182 } |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
183 return 0; |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
184 } |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
185 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
186 // do we support this mode? (not important whether native or conversion) |
7499 | 187 static int vd_ModeValid( int mplayer_depth){ |
392 | 188 int i; |
189 if(mplayer_depth == 0)return 0; | |
190 for(i=1; i<vo_dga_mode_num; i++){ | |
191 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth && | |
192 vo_dga_modes[i].vdm_supported != 0){ | |
193 return i; | |
194 } | |
195 } | |
196 return 0; | |
197 } | |
198 | |
7499 | 199 static int vd_ModeSupportedMethod( int mplayer_depth){ |
6206
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
200 int i; |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
201 if(mplayer_depth == 0)return 0; |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
202 for(i=1; i<vo_dga_mode_num; i++){ |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
203 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth && |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
204 vo_dga_modes[i].vdm_supported != 0){ |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
205 return vo_dga_modes[i].vdm_conversion_func; |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
206 } |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
207 } |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
208 return 0; |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
209 } |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
210 |
7499 | 211 static char *vd_GetModeString(int index){ |
392 | 212 |
213 #define VO_DGA_MAX_STRING_LEN 100 | |
214 static char stringbuf[VO_DGA_MAX_STRING_LEN]; | |
215 stringbuf[VO_DGA_MAX_STRING_LEN-1]=0; | |
216 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
|
217 "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)", |
392 | 218 vo_dga_modes[index].vdm_depth, |
219 vo_dga_modes[index].vdm_bitspp, | |
220 vo_dga_modes[index].vdm_rmask, | |
221 vo_dga_modes[index].vdm_gmask, | |
222 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
|
223 vo_dga_modes[index].vdm_supported ? |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
224 (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
|
225 "native (fast), " : "conversion (slow),") : |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
226 "not supported :-( ", |
392 | 227 vo_dga_modes[index].vdm_mplayer_depth); |
228 return stringbuf; | |
229 } | |
230 | |
231 //----------------------------------------------------------------- | |
232 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
233 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
234 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
|
235 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
236 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
237 |
392 | 238 extern int verbose; |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
239 |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
240 static int vo_dga_src_format; |
31 | 241 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
|
242 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
|
243 // framebuffer |
31 | 244 static int vo_dga_vp_height; // visible lines in framebuffer |
245 static int vo_dga_is_running = 0; | |
246 static int vo_dga_src_width; // width of video in pixels | |
247 static int vo_dga_src_height; // height of video in pixels | |
248 static int vo_dga_src_offset=0; // offset in src | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
249 static int vo_dga_vp_offset=0; // offset in dest |
262 | 250 static int vo_dga_bytes_per_line; // bytes per line to copy |
392 | 251 static int vo_dga_src_skip; // bytes to skip after copying one |
252 // line | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
253 // (not supported yet) in src |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
254 static int vo_dga_vp_skip; // dto. for dest |
392 | 255 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
|
256 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
|
257 // used by framebuffer |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
258 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
|
259 // codec |
392 | 260 static int vo_dga_XServer_mode = 0;// index in mode list for resolution |
261 // XServer is running | |
13 | 262 |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
263 #define MAX_NR_VIDEO_BUFFERS 3 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
264 |
7575
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
265 #define CURRENT_VIDEO_BUFFER \ |
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
266 (vo_dga_video_buffer[vo_dga_current_video_buffer]) |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
267 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
268 static int vo_dga_nr_video_buffers; // Total number of frame buffers. |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
269 static int vo_dga_current_video_buffer; // Buffer available for rendering. |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
270 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
271 static struct video_buffer |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
272 { |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
273 int y; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
274 uint8_t *data; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
275 } vo_dga_video_buffer[MAX_NR_VIDEO_BUFFERS]; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
276 |
31 | 277 static Display *vo_dga_dpy; |
13 | 278 |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
279 /* saved src and dst dimensions for SwScaler */ |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
280 static unsigned int scale_srcW = 0, |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
281 scale_dstW = 0, |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
282 scale_srcH = 0, |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
283 scale_dstH = 0; |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
284 |
490 | 285 //--------------------------------------------------------- |
286 | |
287 static void draw_alpha( int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride ){ | |
288 | |
289 char *d; | |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
290 unsigned int offset; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
291 unsigned int buffer_stride; |
490 | 292 |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
293 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
|
294 buffer_stride = vo_dga_width; |
7575
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
295 d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; |
490 | 296 |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
297 switch( HW_MODE.vdm_mplayer_depth ){ |
490 | 298 |
493
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
299 case 32: |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
300 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
|
301 break; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
302 case 24: |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
303 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
|
304 break; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
305 case 15: |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
306 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
|
307 break; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
308 case 16: |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
309 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
|
310 break; |
b8f1ed2b411b
- now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents:
490
diff
changeset
|
311 } |
392 | 312 } |
313 | |
490 | 314 |
392 | 315 //--------------------------------------------------------- |
316 | |
317 | |
318 | |
13 | 319 |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
320 // quick & dirty - for debugging only |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
321 |
7499 | 322 static void fillblock(char *strt, int yoff, int lines, int val){ |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
323 char *i; |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
324 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
|
325 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
|
326 *i++ = val; |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
327 } |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
328 } |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
329 |
13 | 330 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
331 //--------------------------------------------------------- |
13 | 332 |
333 static uint32_t draw_frame( uint8_t *src[] ){ | |
334 | |
335 int vp_skip = vo_dga_vp_skip; | |
336 int lpl = vo_dga_bytes_per_line >> 2; | |
337 int numlines = vo_dga_lines; | |
338 | |
339 char *s, *d; | |
340 | |
262 | 341 s = *src; |
7575
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
342 d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
343 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
344 switch(SRC_MODE.vdm_conversion_func){ |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
345 case VDM_CONV_NATIVE: |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
346 |
4713 | 347 mem2agpcpy_pic( |
348 d, s, | |
349 vo_dga_bytes_per_line, | |
350 numlines, | |
351 vo_dga_bytes_per_line+vo_dga_vp_skip, | |
352 vo_dga_bytes_per_line); | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
353 |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
354 // DBG-COde |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
355 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
356 #if 0 |
7575
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
357 d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
358 fillblock(d, 0, 10, 0x800000ff); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
359 fillblock(d, 10, 10, 0x8000ff00); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
360 fillblock(d, 20, 10, 0x80ff0000); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
361 fillblock(d, 30, 10, 0xff0000ff); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
362 fillblock(d, 40, 10, 0x800000ff); |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
363 fillblock(d, 50, 10, 0x0f0000ff); |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
364 #endif |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
365 break; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
366 case VDM_CONV_15TO16: |
691 | 367 { |
368 int i; | |
369 char *e; | |
370 for(i=0; i< vo_dga_lines; i++){ | |
2556 | 371 rgb15to16( s, d, vo_dga_bytes_per_line); |
691 | 372 d+=vo_dga_bytes_per_line; |
373 s+=vo_dga_bytes_per_line; | |
374 d+= vo_dga_vp_skip; | |
375 } | |
376 } | |
377 break; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
378 case VDM_CONV_24TO32: |
691 | 379 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
380 { |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
381 int i,k,l,m; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
382 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
|
383 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
|
384 l = *(((uint32_t *)s)++); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
385 m = (l & 0xff000000)>> 24 ; |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
386 *(((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
|
387 m |= *(((uint16_t *)s)++) << 8; |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
388 *(((uint32_t *)d)++) = m; // | 0x80000000 ; |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
389 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
390 d+= vp_skip; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
391 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
392 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
393 //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
|
394 break; |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
395 } |
13 | 396 return 0; |
397 } | |
398 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
399 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
400 |
31 | 401 static void check_events(void) |
402 { | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
403 int e=vo_x11_check_events(vo_dga_dpy); |
31 | 404 } |
405 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
406 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
407 |
616 | 408 #include "sub.h" |
612 | 409 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1336
diff
changeset
|
410 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1336
diff
changeset
|
411 { 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
|
412 |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
413 static void switch_video_buffers(void) |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
414 { |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
415 vo_dga_current_video_buffer = |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
416 (vo_dga_current_video_buffer + 1) % vo_dga_nr_video_buffers; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
417 } |
262 | 418 |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
419 static void flip_page( void ) |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
420 { |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
421 if(1 < vo_dga_nr_video_buffers) |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
422 { |
262 | 423 #ifdef HAVE_DGA2 |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
424 XDGASetViewport(vo_dga_dpy, XDefaultScreen(vo_dga_dpy), |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
425 0, |
7575
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
426 CURRENT_VIDEO_BUFFER.y, |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
427 XDGAFlipRetrace); |
262 | 428 #else |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
429 XF86DGASetViewPort(vo_dga_dpy, XDefaultScreen(vo_dga_dpy), |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
430 0, |
7652
dc789525a89b
DGA1 trivial fix by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7575
diff
changeset
|
431 CURRENT_VIDEO_BUFFER.y); |
262 | 432 #endif |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
433 switch_video_buffers(); |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
434 } |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
435 } |
13 | 436 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
437 //--------------------------------------------------------- |
13 | 438 |
439 static uint32_t draw_slice( uint8_t *src[],int stride[], | |
440 int w,int h,int x,int y ) | |
441 { | |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
442 if (scale_srcW) { |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
443 uint8_t *dst[3] = |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
444 { |
7575
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
445 CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset, |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
446 0, |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
447 0 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
448 }; |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
449 SwScale_YV12slice(src,stride,y,h, |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
450 dst, |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
451 /*scale_dstW*/ vo_dga_width * HW_MODE.vdm_bytespp, HW_MODE.vdm_bitspp, |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
452 scale_srcW, scale_srcH, scale_dstW, scale_dstH); |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
453 } else { |
7575
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
454 yuv2rgb(CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset + |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
455 (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
|
456 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
|
457 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
|
458 stride[0],stride[1] ); |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
459 } |
13 | 460 return 0; |
461 }; | |
462 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
463 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
464 |
13 | 465 static const vo_info_t* get_info( void ) |
466 { return &vo_info; } | |
467 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
468 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
469 |
13 | 470 static uint32_t query_format( uint32_t format ) |
471 { | |
261 | 472 |
473 #ifdef HAVE_DGA2 | |
474 XDGAMode *modelines; | |
475 int modecount; | |
392 | 476 #endif |
261 | 477 Display *qdisp; |
392 | 478 |
479 int i; | |
261 | 480 static int dga_depths_init = 0; |
481 | |
482 if(dga_depths_init == 0){ | |
13 | 483 |
261 | 484 if((qdisp = XOpenDisplay(0))==NULL){ |
7499 | 485 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Can't open display!\n"); |
261 | 486 return 0; |
487 } | |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
488 if( !vo_init() ){ |
7499 | 489 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: vo_init() failed!\n"); |
6206
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
490 return 0; |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
491 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
492 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
|
493 |
392 | 494 if(vo_dga_XServer_mode ==0){ |
495 #ifndef HAVE_DGA2 | |
7499 | 496 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Your X-Server is not running in a "); |
497 mp_msg(MSGT_VO, MSGL_ERR, "resolution supported by DGA driver!\n"); | |
392 | 498 #endif |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
499 }//else{ |
7499 | 500 // mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: X running at: %s\n", |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
501 // vd_GetModeString(vo_dga_XServer_mode)); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
502 //} |
392 | 503 |
504 #ifdef HAVE_DGA2 | |
261 | 505 modelines=XDGAQueryModes(qdisp, XDefaultScreen(qdisp),&modecount); |
392 | 506 if(modelines){ |
507 for(i=0; i< modecount; i++){ | |
7499 | 508 mp_msg(MSGT_VO, MSGL_V, "vo_dga: (%03d) depth=%d, bpp=%d, r=%08x, g=%08x, b=%08x, %d x %d\n", |
392 | 509 i, |
510 modelines[i].depth, | |
511 modelines[i].bitsPerPixel, | |
512 modelines[i].redMask, | |
513 modelines[i].greenMask, | |
514 modelines[i].blueMask, | |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
515 modelines[i].viewportWidth, |
392 | 516 modelines[i].viewportHeight); |
517 vd_EnableMode( | |
518 modelines[i].depth, | |
519 modelines[i].bitsPerPixel, | |
520 modelines[i].redMask, | |
521 modelines[i].greenMask, | |
522 modelines[i].blueMask); | |
523 } | |
524 XFree(modelines); | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
525 |
261 | 526 } |
527 #endif | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
528 dga_depths_init = 1; |
392 | 529 XCloseDisplay(qdisp); |
530 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
531 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
|
532 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
|
533 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
534 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
535 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
|
536 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
|
537 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
538 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
539 for(i=1; i<vo_dga_mode_num; i++){ |
7499 | 540 mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Mode: %s", vd_GetModeString(i)); |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
541 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
|
542 vo_dga_modes[i].vdm_supported = 0; |
7499 | 543 mp_msg(MSGT_VO, MSGL_INFO, " ...disabled by -bpp %d", vo_dbpp ); |
261 | 544 } |
7499 | 545 mp_msg(MSGT_VO, MSGL_INFO, "\n"); |
261 | 546 } |
547 } | |
392 | 548 |
6206
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
549 if( format==IMGFMT_YV12 ) return VFCAP_CSP_SUPPORTED; |
261 | 550 |
392 | 551 if( (format&IMGFMT_BGR_MASK) == IMGFMT_BGR && |
6206
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
552 vd_ModeValid(format&0xff)) |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
553 { |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
554 if (vd_ModeSupportedMethod(format&0xff) == VDM_CONV_NATIVE) |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
555 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
556 else |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
557 return VFCAP_CSP_SUPPORTED|VFCAP_OSD; |
4bffe1ffa86c
revised query_format. added support for native/conversion detection
alex
parents:
4737
diff
changeset
|
558 } |
392 | 559 |
13 | 560 return 0; |
561 } | |
562 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
563 //--------------------------------------------------------- |
13 | 564 |
565 static void | |
566 uninit(void) | |
567 { | |
568 | |
261 | 569 #ifdef HAVE_DGA2 |
570 XDGADevice *dgadevice; | |
571 #endif | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
572 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
573 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
|
574 vo_dga_is_running = 0; |
7499 | 575 mp_msg(MSGT_VO, MSGL_V, "vo_dga: in uninit\n"); |
7539
56ea9db91251
-nograbpointer, based on old patch by Christian Ohm <chr.ohm@gmx.net>
arpi
parents:
7533
diff
changeset
|
576 if(vo_grabpointer) |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
577 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
|
578 XUngrabKeyboard (vo_dga_dpy, CurrentTime); |
261 | 579 #ifdef HAVE_DGA2 |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
580 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
|
581 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
|
582 if(dgadevice != NULL){ |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
583 XFree(dgadevice); |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
584 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
585 #else |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
586 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
|
587 // 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
|
588 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
589 if (vo_dga_vidmodes != NULL ){ |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
590 int screen; screen=XDefaultScreen( vo_dga_dpy ); |
7499 | 591 mp_msg(MSGT_VO, MSGL_V, "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
|
592 // 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
|
593 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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
599 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
600 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
601 XCloseDisplay(vo_dga_dpy); |
261 | 602 } |
13 | 603 } |
604 | |
605 | |
261 | 606 //---------------------------------------------------------- |
392 | 607 // TODO: check for larger maxy value |
608 // (useful for double buffering!!!) | |
261 | 609 |
7499 | 610 static 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
|
611 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
|
612 int *old_x, int *old_y, int *old_vbi, int *old_maxy){ |
261 | 613 |
7499 | 614 mp_msg(MSGT_VO, MSGL_V, "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
|
615 num, new_x, new_y, new_vbi, bpp ); |
7499 | 616 mp_msg(MSGT_VO, MSGL_V, "(old: %dx%d@%d).", *old_x, *old_y, *old_vbi); |
261 | 617 if ( |
618 (new_x >= x) && | |
619 (new_y >= y) && | |
620 ( | |
621 // prefer a better resolution either in X or in Y | |
622 // as long as the other dimension is at least the same | |
623 // | |
624 // hmm ... MAYBE it would be more clever to focus on the | |
625 // x-resolution; I had 712x400 and 640x480 and the movie | |
626 // was 640x360; 640x480 would be the 'right thing' here | |
627 // but since 712x400 was queried first I got this one. | |
628 // I think there should be a cmd-line switch to let the | |
629 // user choose the mode he likes ... (acki2) | |
630 | |
631 ( | |
632 ((new_x < *old_x) && | |
633 !(new_y > *old_y)) || | |
634 ((new_y < *old_y) && | |
635 !(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
|
636 ) |
261 | 637 // but if we get an identical resolution choose |
638 // the one with the lower refreshrate (saves bandwidth !!!) | |
639 // as long as it's above 50 Hz (acki2 on 30/3/2001) | |
640 || | |
641 ( | |
642 (new_x == *old_x) && | |
643 (new_y == *old_y) && | |
644 ( | |
645 ( | |
646 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
|
647 ) |
261 | 648 || |
649 ( | |
650 *old_vbi >= 50 && | |
651 new_vbi < *old_vbi && | |
652 new_vbi >= 50 | |
653 ) | |
654 ) | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
655 || |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
656 // 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
|
657 // stride |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
658 ( |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
659 (new_x == *old_x) && |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
660 (new_y == *old_y) && |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
661 (new_vbi == *old_vbi) && |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
662 (new_maxy > *old_maxy) |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
663 ) |
261 | 664 ) |
266
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
665 ) |
336b1559a447
- added detection of memsize of graphics card to check if double buffering is possible
acki2
parents:
263
diff
changeset
|
666 ) |
261 | 667 { |
668 *old_x = new_x; | |
669 *old_y = new_y; | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
670 *old_maxy = new_maxy; |
261 | 671 *old_vbi = new_vbi; |
7499 | 672 mp_msg(MSGT_VO, MSGL_V, ".ok!!\n"); |
261 | 673 return 1; |
674 }else{ | |
7499 | 675 mp_msg(MSGT_VO, MSGL_V, ".no\n"); |
261 | 676 return 0; |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
677 } |
261 | 678 } |
679 | |
680 | |
681 | |
682 //--------------------------------------------------------- | |
683 | |
7515 | 684 static void init_video_buffers(uint8_t *buffer_base, |
685 int view_port_height, | |
686 int bytes_per_scanline, | |
687 int max_view_port_y, | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
688 int use_multiple_buffers) |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
689 { |
7515 | 690 int bytes_per_buffer = view_port_height * bytes_per_scanline; |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
691 int i; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
692 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
693 if(use_multiple_buffers) |
7515 | 694 vo_dga_nr_video_buffers = max_view_port_y / view_port_height; |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
695 else |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
696 vo_dga_nr_video_buffers = 1; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
697 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
698 vo_dga_current_video_buffer = 0; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
699 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
700 if(MAX_NR_VIDEO_BUFFERS < vo_dga_nr_video_buffers) |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
701 vo_dga_nr_video_buffers = MAX_NR_VIDEO_BUFFERS; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
702 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
703 for(i = 0; i < vo_dga_nr_video_buffers; i++) |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
704 { |
7515 | 705 vo_dga_video_buffer[i].y = i * view_port_height; |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
706 vo_dga_video_buffer[i].data = |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
707 buffer_base + i * bytes_per_buffer; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
708 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
709 // Clear video buffer. |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
710 memset(vo_dga_video_buffer[i].data, 0, bytes_per_buffer); |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
711 } |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
712 } |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
713 |
4433 | 714 static uint32_t config( uint32_t width, uint32_t height, |
261 | 715 uint32_t d_width,uint32_t d_height, |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
6206
diff
changeset
|
716 uint32_t flags,char *title,uint32_t format) |
261 | 717 { |
718 | |
719 int x_off, y_off; | |
392 | 720 int wanted_width, wanted_height; |
261 | 721 |
7533
abc3b12165b7
another dga v1 fix by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7515
diff
changeset
|
722 unsigned char *vo_dga_base; |
261 | 723 #ifdef HAVE_DGA2 |
724 // 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
|
725 int modecount, mX=VO_DGA_INVALID_RES, mY=VO_DGA_INVALID_RES , mVBI=100000, mMaxY=0, i,j=0; |
261 | 726 int dga_modenum; |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
727 XDGAMode *modelines=NULL, *modeline; |
261 | 728 XDGADevice *dgadevice; |
729 #else | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
730 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
731 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
|
732 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
|
733 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
|
734 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
|
735 #endif |
261 | 736 int bank, ram; |
737 #endif | |
738 | |
739 if( vo_dga_is_running )return -1; | |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
740 vo_dga_src_format = format; |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
741 |
392 | 742 wanted_width = d_width; |
743 wanted_height = d_height; | |
261 | 744 |
392 | 745 if(!wanted_height) wanted_height = height; |
746 if(!wanted_width) wanted_width = width; | |
747 | |
261 | 748 if( !vo_init() ){ |
7499 | 749 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: vo_init() failed!\n"); |
392 | 750 return 1; |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
751 } |
392 | 752 |
753 if( !vo_dbpp ){ | |
261 | 754 |
392 | 755 if (format == IMGFMT_YV12){ |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
756 vo_dga_src_mode = vo_dga_XServer_mode; |
392 | 757 }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
|
758 vo_dga_src_mode = vd_ModeValid( format & 0xff ); |
392 | 759 } |
261 | 760 }else{ |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
761 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
|
762 } |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
763 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
|
764 |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
765 if( format == IMGFMT_YV12 && vo_dga_src_mode != vo_dga_hw_mode ){ |
7499 | 766 mp_msg(MSGT_VO, MSGL_ERR, |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
767 "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
|
768 HW_MODE.vdm_mplayer_depth, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
769 SRC_MODE.vdm_mplayer_depth ); |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
770 vo_dga_src_mode = vo_dga_hw_mode; |
392 | 771 } |
261 | 772 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
773 if(!vo_dga_src_mode){ |
7499 | 774 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: unsupported video format!\n"); |
392 | 775 return 1; |
261 | 776 } |
777 | |
392 | 778 if((vo_dga_dpy = XOpenDisplay(0))==NULL){ |
7499 | 779 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Can't open display\n"); |
261 | 780 return 1; |
781 } | |
782 | |
392 | 783 vo_dga_vp_width = DisplayWidth( vo_dga_dpy, DefaultScreen(vo_dga_dpy)); |
784 vo_dga_vp_height = DisplayHeight( vo_dga_dpy, DefaultScreen(vo_dga_dpy)); | |
261 | 785 |
7499 | 786 mp_msg(MSGT_VO, MSGL_V, "vo_dga: XServer res: %dx%d\n", |
392 | 787 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
|
788 |
261 | 789 // choose a suitable mode ... |
790 | |
791 #ifdef HAVE_DGA2 | |
792 // Code to change the video mode added by Michael Graffam | |
793 // mgraffam@idsi.net | |
794 if (modelines==NULL) | |
795 modelines=XDGAQueryModes(vo_dga_dpy, XDefaultScreen(vo_dga_dpy),&modecount); | |
3318 | 796 |
7499 | 797 mp_msg(MSGT_VO, MSGL_V, |
3318 | 798 "vo_dga: modelines=%p, modecount=%d\n", modelines, modecount); |
799 | |
800 if (modelines == NULL) | |
801 { | |
7499 | 802 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: can't get modelines\n"); |
3318 | 803 return 1; |
804 } | |
261 | 805 |
7499 | 806 mp_msg(MSGT_VO, MSGL_INFO, |
392 | 807 "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
|
808 for (i=0; i<modecount; i++) |
261 | 809 { |
392 | 810 if(vd_ModeEqual( modelines[i].depth, |
811 modelines[i].bitsPerPixel, | |
812 modelines[i].redMask, | |
813 modelines[i].greenMask, | |
814 modelines[i].blueMask, | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
815 vo_dga_hw_mode)){ |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
816 |
7499 | 817 mp_msg(MSGT_VO, MSGL_V, "maxy: %4d, depth: %2d, %4dx%4d, ", |
392 | 818 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
|
819 modelines[i].imageWidth, modelines[i].imageHeight ); |
392 | 820 if ( check_res(i, wanted_width, wanted_height, modelines[i].depth, |
261 | 821 modelines[i].viewportWidth, |
822 modelines[i].viewportHeight, | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
823 (unsigned) modelines[i].verticalRefresh, |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
824 modelines[i].maxViewportY, |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
825 &mX, &mY, &mVBI, &mMaxY )) j = i; |
261 | 826 } |
827 } | |
7499 | 828 mp_msg(MSGT_VO, MSGL_INFO, |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
829 "vo_dga: Selected hardware mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d.\n", |
392 | 830 mX, mY, mVBI, |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
831 HW_MODE.vdm_depth, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
832 HW_MODE.vdm_bitspp); |
7499 | 833 mp_msg(MSGT_VO, MSGL_INFO, |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
834 "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
|
835 width, height, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
836 SRC_MODE.vdm_depth, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
837 SRC_MODE.vdm_bitspp); |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
838 vo_dga_vp_width = mX; |
261 | 839 vo_dga_vp_height = mY; |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
840 |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
841 if((flags&0x04)||(flags&0x01)) { /* -zoom or -fs */ |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
842 scale_dstW = (d_width + 7) & ~7; |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
843 scale_dstH = d_height; |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
844 scale_srcW = width; |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
845 scale_srcH = height; |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
846 aspect_save_screenres(mX,mY); |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
847 aspect_save_orig(scale_srcW,scale_srcH); |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
848 aspect_save_prescale(scale_dstW,scale_dstH); |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
849 SwScale_Init(); |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
850 if(flags&0x01) /* -fs */ |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
851 aspect(&scale_dstW,&scale_dstH,A_ZOOM); |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
852 else if(flags&0x04) /* -fs */ |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
853 aspect(&scale_dstW,&scale_dstH,A_NOZOOM); |
7499 | 854 mp_msg(MSGT_VO, MSGL_INFO, |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
855 "vo_dga: Aspect corrected size for SwScaler: %4d x %4d.\n", |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
856 scale_dstW, scale_dstH); |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
857 /* XXX this is a hack, but I'm lazy ;-) :: atmos */ |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
858 width = scale_dstW; |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
859 height = scale_dstH; |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
860 } |
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
861 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
862 vo_dga_width = modelines[j].bytesPerScanline / HW_MODE.vdm_bytespp ; |
261 | 863 dga_modenum = modelines[j].num; |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
864 modeline = modelines + j; |
261 | 865 |
866 XFree(modelines); | |
867 modelines = NULL; | |
868 | |
869 #else | |
870 | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
871 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
872 |
7499 | 873 mp_msg(MSGT_VO, MSGL_INFO, |
392 | 874 "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
|
875 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
876 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
|
877 XF86VidModeQueryVersion(vo_dga_dpy, &vm_ver, &vm_rev); |
7499 | 878 mp_msg(MSGT_VO, MSGL_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
|
879 have_vm=1; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
880 } else { |
7499 | 881 mp_msg(MSGT_VO, MSGL_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
|
882 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
883 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
884 #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
|
885 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
886 if (have_vm) { |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
887 int screen; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
888 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
|
889 XF86VidModeGetAllModeLines(vo_dga_dpy,screen,&modecount,&vo_dga_vidmodes); |
261 | 890 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
891 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
|
892 for (i=0; i<modecount; i++){ |
392 | 893 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
|
894 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
|
895 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
|
896 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
|
897 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
|
898 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
|
899 vo_dga_vidmodes[i]->vtotal), |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
900 0, |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
901 &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
|
902 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
903 |
7499 | 904 mp_msg(MSGT_VO, MSGL_INFO, |
392 | 905 "vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n", |
906 mX, mY, mVBI, | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
907 vo_dga_modes[vo_dga_hw_mode].vdm_depth, |
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
908 vo_dga_modes[vo_dga_hw_mode].vdm_bitspp, |
392 | 909 width, height); |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
910 }else{ |
7499 | 911 mp_msg(MSGT_VO, MSGL_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
|
912 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
913 dga_modenum = j; |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
914 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
|
915 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
|
916 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
917 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
918 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
919 #else |
7499 | 920 mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Only have DGA 1.0 extension and no XF86VidMode :-(\n"); |
921 mp_msg(MSGT_VO, MSGL_INFO, " Thus, resolution switching is NOT possible.\n"); | |
392 | 922 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
923 #endif |
261 | 924 #endif |
925 | |
926 vo_dga_src_width = width; | |
927 vo_dga_src_height = height; | |
928 | |
929 if(vo_dga_src_width > vo_dga_vp_width || | |
930 vo_dga_src_height > vo_dga_vp_height) | |
931 { | |
7499 | 932 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Sorry, video larger than viewport is not yet supported!\n"); |
261 | 933 // 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
|
934 #ifndef HAVE_DGA2 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
935 #ifdef HAVE_XF86VM |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
936 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
|
937 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
|
938 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
|
939 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
940 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
941 #endif |
261 | 942 return 1; |
943 } | |
1154
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
944 |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
945 if(vo_dga_vp_width == VO_DGA_INVALID_RES){ |
7499 | 946 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Something is wrong with your DGA. There doesn't seem to be a\n" |
1158 | 947 " single suitable mode!\n" |
7499 | 948 " Please file a bug report (see DOCS/bugreports.html)\n"); |
1154
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
949 #ifndef HAVE_DGA2 |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
950 #ifdef HAVE_XF86VM |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
951 if(vo_dga_vidmodes){ |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
952 XFree(vo_dga_vidmodes); |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
953 vo_dga_vidmodes = NULL; |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
954 } |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
955 #endif |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
956 #endif |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
957 return 1; |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
958 } |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
959 |
261 | 960 // now lets start the DGA thing |
961 | |
962 #ifdef HAVE_DGA2 | |
963 | |
964 if (!XDGAOpenFramebuffer(vo_dga_dpy, XDefaultScreen(vo_dga_dpy))){ | |
7499 | 965 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Framebuffer mapping failed!!!\n"); |
261 | 966 XCloseDisplay(vo_dga_dpy); |
967 return 1; | |
968 } | |
969 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
|
970 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
|
971 |
261 | 972 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
|
973 XFree(dgadevice); |
261 | 974 |
975 XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0, XDGAFlipRetrace); | |
976 | |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
977 #else |
263
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 #ifdef HAVE_XF86VM |
3852
cd642e995366
use XF86VidMode later in init (at line 1031) only if we've got support (if have_vm==1)
alex
parents:
3318
diff
changeset
|
980 if (have_vm) |
cd642e995366
use XF86VidMode later in init (at line 1031) only if we've got support (if have_vm==1)
alex
parents:
3318
diff
changeset
|
981 { |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
982 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
|
983 // 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
|
984 // 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
|
985 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
|
986 XF86VidModeSwitchToMode(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),vo_dga_vidmodes[dga_modenum]); |
3852
cd642e995366
use XF86VidMode later in init (at line 1031) only if we've got support (if have_vm==1)
alex
parents:
3318
diff
changeset
|
987 } |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
988 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
989 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
990 XF86DGAGetViewPortSize(vo_dga_dpy,XDefaultScreen(vo_dga_dpy), |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
991 &vo_dga_vp_width, |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
992 &vo_dga_vp_height); |
13 | 993 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
994 XF86DGAGetVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
995 (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
|
996 |
261 | 997 XF86DGADirectVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), |
998 XF86DGADirectGraphics | XF86DGADirectMouse | | |
999 XF86DGADirectKeyb); | |
1000 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
1001 XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0); |
261 | 1002 |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
1003 #endif |
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
1004 |
13 | 1005 // do some more checkings here ... |
261 | 1006 |
392 | 1007 if( format==IMGFMT_YV12 ){ |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1008 yuv2rgb_init( vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth , MODE_RGB ); |
7499 | 1009 mp_msg(MSGT_VO, MSGL_V, "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
|
1010 vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth); |
392 | 1011 } |
13 | 1012 |
7499 | 1013 mp_msg(MSGT_VO, MSGL_V, "vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %08x, bpp: %d\n", |
13 | 1014 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
|
1015 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
|
1016 HW_MODE.vdm_bitspp); |
13 | 1017 |
1018 x_off = (vo_dga_vp_width - vo_dga_src_width)>>1; | |
1019 y_off = (vo_dga_vp_height - vo_dga_src_height)>>1; | |
1020 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1021 vo_dga_bytes_per_line = vo_dga_src_width * HW_MODE.vdm_bytespp; |
261 | 1022 vo_dga_lines = vo_dga_src_height; |
13 | 1023 |
1024 vo_dga_src_offset = 0; | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1025 vo_dga_vp_offset = (y_off * vo_dga_width + x_off ) * HW_MODE.vdm_bytespp; |
13 | 1026 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
1027 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * HW_MODE.vdm_bytespp; // todo |
13 | 1028 |
7499 | 1029 mp_msg(MSGT_VO, MSGL_V, "vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n", |
13 | 1030 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line); |
1031 | |
1032 | |
1033 XGrabKeyboard (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True, | |
1034 GrabModeAsync,GrabModeAsync, CurrentTime); | |
7539
56ea9db91251
-nograbpointer, based on old patch by Christian Ohm <chr.ohm@gmx.net>
arpi
parents:
7533
diff
changeset
|
1035 if(vo_grabpointer) |
13 | 1036 XGrabPointer (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True, |
1037 ButtonPressMask,GrabModeAsync, GrabModeAsync, | |
1038 None, None, CurrentTime); | |
262 | 1039 |
7515 | 1040 init_video_buffers(vo_dga_base, |
1041 vo_dga_vp_height, | |
1042 vo_dga_width * HW_MODE.vdm_bytespp, | |
1043 #if HAVE_DGA2 | |
1044 modeline->maxViewportY, | |
1045 #else | |
1046 vo_dga_vp_height, | |
1047 #endif | |
1048 vo_doublebuffering); | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
1049 |
7499 | 1050 mp_msg(MSGT_VO, MSGL_V, "vo_dga: Using %d frame buffer%s.\n", |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
1051 vo_dga_nr_video_buffers, vo_dga_nr_video_buffers == 1 ? "" : "s"); |
262 | 1052 |
13 | 1053 vo_dga_is_running = 1; |
1054 return 0; | |
1055 } | |
1056 | |
4352 | 1057 static uint32_t preinit(const char *arg) |
1058 { | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
1059 if(arg) |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
1060 { |
7499 | 1061 mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Unknown subdevice: %s\n",arg); |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
1062 return ENOSYS; |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
1063 } |
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
1064 return 0; |
4352 | 1065 } |
1066 | |
4596 | 1067 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 1068 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4439
diff
changeset
|
1069 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4439
diff
changeset
|
1070 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4439
diff
changeset
|
1071 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4439
diff
changeset
|
1072 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4439
diff
changeset
|
1073 return VO_NOTIMPL; |
4352 | 1074 } |
1075 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
1076 //--------------------------------------------------------- |