Mercurial > mplayer.hg
annotate libvo/vo_dga.c @ 34180:61f7925ff295
Clarify that too old binutils is only an issue with x86_64 compilation.
On OSX people sometimes seem to be unaware what they are actually compiling for...
author | reimar |
---|---|
date | Wed, 26 Oct 2011 18:26:51 +0000 |
parents | ddb45e9443ec |
children | b291f44d864a |
rev | line source |
---|---|
13 | 1 /* |
10021
a7ae63354098
Spring cleanup: removed the full yv12 support as it was broken anyway. The BGR/RGB native/non-native case needs some cleanup, too. Currently it works for me (tm)
alex
parents:
9274
diff
changeset
|
2 * X11 DGA Interface |
13 | 3 * |
26400
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
4 * Copyright (C) 2001 Andreas Ackermann <acki@acki-netz.de> |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
5 * Sourceforge username: acki2 |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
6 * |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
7 * This file is part of MPlayer. |
13 | 8 * |
26400
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
9 * MPlayer is free software; you can redistribute it and/or modify |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
10 * it under the terms of the GNU General Public License as published by |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
11 * the Free Software Foundation; either version 2 of the License, or |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
12 * (at your option) any later version. |
13 | 13 * |
26400
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
14 * MPlayer is distributed in the hope that it will be useful, |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
17 * GNU General Public License for more details. |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
18 * |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
19 * You should have received a copy of the GNU General Public License along |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
5af4096b9fec
Replace "all rights reserved" statement with standard GPL license header.
diego
parents:
25220
diff
changeset
|
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
13 | 22 */ |
23 | |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 #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
|
27 #include <errno.h> |
13 | 28 |
29 #include "config.h" | |
30 #include "video_out.h" | |
31 #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
|
32 #include "aspect.h" |
10021
a7ae63354098
Spring cleanup: removed the full yv12 support as it was broken anyway. The BGR/RGB native/non-native case needs some cleanup, too. Currently it works for me (tm)
alex
parents:
9274
diff
changeset
|
33 #include "x11_common.h" |
a7ae63354098
Spring cleanup: removed the full yv12 support as it was broken anyway. The BGR/RGB native/non-native case needs some cleanup, too. Currently it works for me (tm)
alex
parents:
9274
diff
changeset
|
34 #include "fastmemcpy.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12582
diff
changeset
|
35 #include "mp_msg.h" |
13 | 36 |
37 #include <X11/Xlib.h> | |
38 #include <X11/extensions/xf86dga.h> | |
39 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
40 #ifdef CONFIG_XF86VM |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
41 #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
|
42 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
43 |
25216 | 44 static const vo_info_t info = { |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
45 #ifdef CONFIG_DGA2 |
12582 | 46 "DGA ( Direct Graphic Access V2.0 )", |
533 | 47 #else |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
48 #ifdef CONFIG_XF86VM |
12582 | 49 "DGA ( Direct Graphic Access V1.0+XF86VidModeExt. )", |
7499 | 50 #else |
12582 | 51 "DGA ( Direct Graphic Access V1.0 )", |
7499 | 52 #endif |
533 | 53 #endif |
12582 | 54 "dga", |
55 "Andreas Ackermann <acki@acki-netz.de>", | |
56 "" | |
13 | 57 }; |
58 | |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
59 const LIBVO_EXTERN(dga) |
392 | 60 //------------------------------------------------------------------ |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
61 //#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
|
62 //#define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp) |
1154
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
63 #define VO_DGA_INVALID_RES 100000 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
64 #define HW_MODE (vo_dga_modes[vo_dga_hw_mode]) |
12582 | 65 #define SRC_MODE (vo_dga_modes[vo_dga_src_mode]) |
66 struct vd_modes | |
67 { | |
68 int vdm_mplayer_depth; | |
69 int vdm_supported; | |
70 int vdm_depth; | |
71 int vdm_bitspp; | |
72 int vdm_bytespp; | |
73 int vdm_rmask; | |
74 int vdm_gmask; | |
75 int vdm_bmask; | |
76 int vdm_hw_mode; | |
392 | 77 }; |
78 | |
79 //------------------------------------------------------------------ | |
80 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
81 static struct vd_modes vo_dga_modes[] = { |
12582 | 82 // these entries describe HW modes |
83 // however, we use the same entries to tell mplayer what we support | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
84 // so the last two values describe, which HW mode to use and which conversion |
12582 | 85 // function to use for a mode that is not supported by HW |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
86 |
12582 | 87 {0, 0, 0, 0, 0, 0, 0, 0, 0,}, |
88 {15, 0, 15, 16, 2, 0x7c00, 0x03e0, 0x001f, 2,}, | |
89 {16, 0, 16, 16, 2, 0xf800, 0x07e0, 0x001f, 2,}, | |
90 {24, 0, 24, 24, 3, 0xff0000, 0x00ff00, 0x0000ff, 4}, | |
91 {32, 0, 24, 32, 4, 0x00ff0000, 0x0000ff00, 0x000000ff, 4} | |
392 | 92 }; |
93 | |
12582 | 94 static int vo_dga_mode_num = |
95 sizeof(vo_dga_modes) / sizeof(struct vd_modes); | |
392 | 96 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
97 // enable a HW mode (by description) |
12582 | 98 static int vd_EnableMode(int depth, int bitspp, |
99 int rmask, int gmask, int bmask) | |
100 { | |
101 int i; | |
102 | |
103 for (i = 1; i < vo_dga_mode_num; i++) | |
104 { | |
105 if (vo_dga_modes[i].vdm_depth == depth && | |
106 vo_dga_modes[i].vdm_bitspp == bitspp && | |
107 vo_dga_modes[i].vdm_rmask == rmask && | |
108 vo_dga_modes[i].vdm_gmask == gmask && | |
109 vo_dga_modes[i].vdm_bmask == bmask) | |
110 { | |
111 vo_dga_modes[i].vdm_supported = 1; | |
112 vo_dga_modes[i].vdm_hw_mode = i; | |
113 return i; | |
114 } | |
392 | 115 } |
12582 | 116 return 0; |
392 | 117 } |
118 | |
12582 | 119 static int vd_ModeEqual(int depth, int bitspp, |
120 int rmask, int gmask, int bmask, int index) | |
121 { | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26400
diff
changeset
|
122 return (vo_dga_modes[index].vdm_depth == depth && |
12582 | 123 vo_dga_modes[index].vdm_bitspp == bitspp && |
124 vo_dga_modes[index].vdm_rmask == rmask && | |
125 vo_dga_modes[index].vdm_gmask == gmask && | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26400
diff
changeset
|
126 vo_dga_modes[index].vdm_bmask == bmask) ? 1 : 0; |
392 | 127 } |
128 | |
129 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
130 // enable a HW mode (mplayer_depth decides which) |
12582 | 131 static int vd_ValidateMode(int mplayer_depth) |
132 { | |
133 int i; | |
134 | |
135 if (mplayer_depth == 0) | |
136 return 0; | |
137 for (i = 1; i < vo_dga_mode_num; i++) | |
138 { | |
139 if (vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth) | |
140 { | |
141 vo_dga_modes[i].vdm_supported = 1; | |
142 vo_dga_modes[i].vdm_hw_mode = i; | |
143 return i; | |
144 } | |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
145 } |
12582 | 146 return 0; |
395
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
147 } |
01768a027e7d
- fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents:
392
diff
changeset
|
148 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
149 // do we support this mode? (not important whether native or conversion) |
12582 | 150 static int vd_ModeValid(int mplayer_depth) |
151 { | |
152 int i; | |
153 | |
154 if (mplayer_depth == 0) | |
155 return 0; | |
156 for (i = 1; i < vo_dga_mode_num; i++) | |
157 { | |
158 if (vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth && | |
159 vo_dga_modes[i].vdm_supported != 0) | |
160 { | |
161 return i; | |
162 } | |
392 | 163 } |
12582 | 164 return 0; |
392 | 165 } |
166 | |
12582 | 167 static char *vd_GetModeString(int index) |
168 { | |
392 | 169 |
170 #define VO_DGA_MAX_STRING_LEN 100 | |
12582 | 171 static char stringbuf[VO_DGA_MAX_STRING_LEN]; |
172 | |
173 stringbuf[VO_DGA_MAX_STRING_LEN - 1] = 0; | |
174 snprintf(stringbuf, VO_DGA_MAX_STRING_LEN - 2, | |
175 "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)", | |
176 vo_dga_modes[index].vdm_depth, | |
177 vo_dga_modes[index].vdm_bitspp, | |
178 vo_dga_modes[index].vdm_rmask, | |
179 vo_dga_modes[index].vdm_gmask, | |
180 vo_dga_modes[index].vdm_bmask, | |
181 vo_dga_modes[index]. | |
182 vdm_supported ? "native" : "not supported", | |
183 vo_dga_modes[index].vdm_mplayer_depth); | |
184 return stringbuf; | |
392 | 185 } |
186 | |
187 //----------------------------------------------------------------- | |
188 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
189 #if defined(CONFIG_XF86VM) && !defined(CONFIG_DGA2) |
12582 | 190 static XF86VidModeModeInfo **vo_dga_vidmodes = NULL; |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
191 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
192 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
193 |
12582 | 194 static int vo_dga_src_format; |
195 static int vo_dga_width; // bytes per line in framebuffer | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
196 static int vo_dga_vp_width; // visible pixels per line in |
12582 | 197 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
198 // framebuffer |
12582 | 199 static int vo_dga_vp_height; // visible lines in framebuffer |
200 static int vo_dga_is_running = 0; | |
201 static int vo_dga_src_width; // width of video in pixels | |
202 static int vo_dga_src_height; // height of video in pixels | |
203 static int vo_dga_src_offset = 0; // offset in src | |
204 static int vo_dga_vp_offset = 0; // offset in dest | |
205 static int vo_dga_bytes_per_line; // bytes per line to copy | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
206 static int vo_dga_vp_skip; // dto. for dest |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
207 static int vo_dga_lines; // num of lines to copy |
12582 | 208 static int vo_dga_hw_mode = 0; // index in mode list that is actually |
209 | |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
210 // used by framebuffer |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
211 static int vo_dga_src_mode = 0; // index in mode list that is used by |
12582 | 212 |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
213 // codec |
12582 | 214 static int vo_dga_XServer_mode = 0; // index in mode list for resolution |
8067 | 215 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
216 #ifdef CONFIG_DGA2 |
12582 | 217 static XDGAMode *vo_modelines; |
218 static int vo_modecount; | |
8067 | 219 #endif |
13 | 220 |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
221 #define MAX_NR_VIDEO_BUFFERS 3 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
222 |
7575
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
223 #define CURRENT_VIDEO_BUFFER \ |
3a6d7933a6ad
flickering fix, patch by Fredrik Noring <noring@nocrew.org>
arpi
parents:
7539
diff
changeset
|
224 (vo_dga_video_buffer[vo_dga_current_video_buffer]) |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
225 |
12582 | 226 static int vo_dga_nr_video_buffers; // Total number of frame buffers. |
227 static int vo_dga_current_video_buffer; // Buffer available for rendering. | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
228 |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
229 static struct video_buffer |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
230 { |
12582 | 231 int y; |
232 uint8_t *data; | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
233 } vo_dga_video_buffer[MAX_NR_VIDEO_BUFFERS]; |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
234 |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
235 /* 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
|
236 static unsigned int scale_srcW = 0, |
12582 | 237 scale_dstW = 0, scale_srcH = 0, scale_dstH = 0; |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
238 |
490 | 239 //--------------------------------------------------------- |
240 | |
12582 | 241 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
242 unsigned char *srca, int stride) | |
243 { | |
490 | 244 |
12582 | 245 char *d; |
246 unsigned int offset; | |
14795
041a13490497
no effect in practice, but strides should always be signed
rfelker
parents:
13787
diff
changeset
|
247 int buffer_stride; |
12582 | 248 |
249 offset = vo_dga_width * y0 + x0; | |
250 buffer_stride = vo_dga_width; | |
251 d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; | |
252 | |
253 switch (HW_MODE.vdm_mplayer_depth) | |
254 { | |
490 | 255 |
12582 | 256 case 32: |
257 vo_draw_alpha_rgb32(w, h, src, srca, stride, d + 4 * offset, | |
258 4 * buffer_stride); | |
259 break; | |
260 case 24: | |
261 vo_draw_alpha_rgb24(w, h, src, srca, stride, d + 3 * offset, | |
262 3 * buffer_stride); | |
263 break; | |
264 case 15: | |
265 vo_draw_alpha_rgb15(w, h, src, srca, stride, d + 2 * offset, | |
266 2 * buffer_stride); | |
267 break; | |
268 case 16: | |
269 vo_draw_alpha_rgb16(w, h, src, srca, stride, d + 2 * offset, | |
270 2 * buffer_stride); | |
271 break; | |
272 } | |
392 | 273 } |
274 | |
490 | 275 |
392 | 276 //--------------------------------------------------------- |
277 | |
278 | |
279 | |
13 | 280 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
281 // quick & dirty - for debugging only |
10495 | 282 #if 0 |
12582 | 283 static void fillblock(char *strt, int yoff, int lines, int val) |
284 { | |
285 char *i; | |
286 | |
287 for (i = strt + yoff * vo_dga_width * HW_MODE.vdm_bytespp; | |
288 i < strt + (lines + yoff) * vo_dga_width * HW_MODE.vdm_bytespp;) | |
289 { | |
290 *i++ = val; | |
291 } | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
292 } |
10495 | 293 #endif |
13 | 294 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
295 //--------------------------------------------------------- |
13 | 296 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
297 static int draw_frame(uint8_t * src[]) |
12582 | 298 { |
13 | 299 |
12582 | 300 int numlines = vo_dga_lines; |
13 | 301 |
12582 | 302 char *s, *d; |
13 | 303 |
12582 | 304 s = *src; |
305 d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; | |
306 | |
307 mem2agpcpy_pic(d, s, | |
308 vo_dga_bytes_per_line, | |
309 numlines, | |
310 vo_dga_bytes_per_line + vo_dga_vp_skip, | |
311 vo_dga_bytes_per_line); | |
312 | |
313 // DBG-COde | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
314 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
315 #if 0 |
12582 | 316 d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; |
317 fillblock(d, 0, 10, 0x800000ff); | |
318 fillblock(d, 10, 10, 0x8000ff00); | |
319 fillblock(d, 20, 10, 0x80ff0000); | |
320 fillblock(d, 30, 10, 0xff0000ff); | |
321 fillblock(d, 40, 10, 0x800000ff); | |
322 fillblock(d, 50, 10, 0x0f0000ff); | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
323 #endif |
12582 | 324 return 0; |
13 | 325 } |
326 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
327 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
328 |
31 | 329 static void check_events(void) |
330 { | |
12582 | 331 vo_x11_check_events(mDisplay); |
31 | 332 } |
333 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
334 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
335 |
32467 | 336 #include "sub/sub.h" |
612 | 337 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1336
diff
changeset
|
338 static void draw_osd(void) |
12582 | 339 { |
340 vo_draw_text(vo_dga_src_width, vo_dga_src_height, draw_alpha); | |
341 } | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1336
diff
changeset
|
342 |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
343 static void switch_video_buffers(void) |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
344 { |
12582 | 345 vo_dga_current_video_buffer = |
346 (vo_dga_current_video_buffer + 1) % vo_dga_nr_video_buffers; | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
347 } |
262 | 348 |
12582 | 349 static void flip_page(void) |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
350 { |
12582 | 351 if (1 < vo_dga_nr_video_buffers) |
352 { | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
353 #ifdef CONFIG_DGA2 |
12582 | 354 XDGASetViewport(mDisplay, mScreen, |
355 0, CURRENT_VIDEO_BUFFER.y, XDGAFlipRetrace); | |
262 | 356 #else |
12582 | 357 XF86DGASetViewPort(mDisplay, mScreen, 0, CURRENT_VIDEO_BUFFER.y); |
262 | 358 #endif |
12582 | 359 switch_video_buffers(); |
360 } | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
361 } |
13 | 362 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
363 //--------------------------------------------------------- |
13 | 364 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
365 static int draw_slice(uint8_t * src[], int stride[], |
12582 | 366 int w, int h, int x, int y) |
13 | 367 { |
12582 | 368 return 0; |
13 | 369 }; |
370 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
371 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
372 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
373 static int query_format(uint32_t format) |
13 | 374 { |
261 | 375 |
12582 | 376 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR && |
377 vd_ModeValid(format & 0xff)) | |
378 { | |
379 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD; | |
380 } | |
381 | |
382 return 0; | |
13 | 383 } |
384 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
385 //--------------------------------------------------------- |
13 | 386 |
12582 | 387 static void uninit(void) |
13 | 388 { |
389 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
390 #ifdef CONFIG_DGA2 |
12582 | 391 XDGADevice *dgadevice; |
261 | 392 #endif |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
393 |
12582 | 394 if (!vo_config_count) |
395 return; | |
8067 | 396 |
12582 | 397 if (vo_dga_is_running) |
398 { | |
399 vo_dga_is_running = 0; | |
400 mp_msg(MSGT_VO, MSGL_V, "vo_dga: in uninit\n"); | |
401 if (vo_grabpointer) | |
402 XUngrabPointer(mDisplay, CurrentTime); | |
403 XUngrabKeyboard(mDisplay, CurrentTime); | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
404 #ifdef CONFIG_DGA2 |
12582 | 405 XDGACloseFramebuffer(mDisplay, mScreen); |
406 dgadevice = XDGASetMode(mDisplay, mScreen, 0); | |
407 if (dgadevice != NULL) | |
408 { | |
409 XFree(dgadevice); | |
410 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
411 #else |
12582 | 412 XF86DGADirectVideo(mDisplay, mScreen, 0); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
413 // first disable DirectVideo and then switch mode back! |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
414 #ifdef CONFIG_XF86VM |
12582 | 415 if (vo_dga_vidmodes != NULL) |
416 { | |
417 int screen; | |
418 | |
419 screen = XDefaultScreen(mDisplay); | |
420 mp_msg(MSGT_VO, MSGL_V, | |
421 "vo_dga: VidModeExt: Switching back..\n"); | |
422 // seems some graphics adaptors need this more than once ... | |
423 XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]); | |
424 XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]); | |
425 XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]); | |
426 XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]); | |
427 XFree(vo_dga_vidmodes); | |
428 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
429 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
430 #endif |
12582 | 431 } |
432 vo_x11_uninit(); | |
13 | 433 } |
434 | |
435 | |
261 | 436 //---------------------------------------------------------- |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
437 // TODO: check for larger maxy value |
392 | 438 // (useful for double buffering!!!) |
261 | 439 |
12582 | 440 static int check_res(int num, int x, int y, int bpp, |
441 int new_x, int new_y, int new_vbi, int new_maxy, | |
442 int *old_x, int *old_y, int *old_vbi, int *old_maxy) | |
443 { | |
261 | 444 |
12582 | 445 mp_msg(MSGT_VO, MSGL_V, |
446 "vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ depth %2d ..", num, | |
447 new_x, new_y, new_vbi, bpp); | |
448 mp_msg(MSGT_VO, MSGL_V, "(old: %dx%d@%d).", *old_x, *old_y, *old_vbi); | |
449 if ((new_x >= x) && (new_y >= y) && ( | |
450 // prefer a better resolution either in X or in Y | |
451 // as long as the other dimension is at least the same | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
452 // |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
453 // hmm ... MAYBE it would be more clever to focus on the |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
454 // x-resolution; I had 712x400 and 640x480 and the movie |
12582 | 455 // was 640x360; 640x480 would be the 'right thing' here |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
456 // but since 712x400 was queried first I got this one. |
12582 | 457 // I think there should be a cmd-line switch to let the |
458 // user choose the mode he likes ... (acki2) | |
459 (((new_x < *old_x) && | |
460 !(new_y > *old_y)) || | |
461 ((new_y < *old_y) && | |
462 !(new_x > *old_x))) | |
463 // but if we get an identical resolution choose | |
464 // the one with the lower refreshrate (saves bandwidth !!!) | |
465 // as long as it's above 50 Hz (acki2 on 30/3/2001) | |
466 || | |
467 (((new_x == *old_x) && | |
468 (new_y == *old_y) && | |
469 ((new_vbi >= *old_vbi | |
470 && *old_vbi < 50) | |
471 || (*old_vbi >= 50 | |
472 && new_vbi < *old_vbi | |
473 && new_vbi >= 50))) || | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
474 // if everything is equal, then use the mode with the lower |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
475 // stride |
12582 | 476 ((new_x == *old_x) && |
477 (new_y == *old_y) && | |
478 (new_vbi == *old_vbi) && | |
479 (new_maxy > *old_maxy))))) | |
261 | 480 { |
12582 | 481 *old_x = new_x; |
482 *old_y = new_y; | |
483 *old_maxy = new_maxy; | |
484 *old_vbi = new_vbi; | |
485 mp_msg(MSGT_VO, MSGL_V, ".ok!!\n"); | |
486 return 1; | |
487 } else | |
488 { | |
489 mp_msg(MSGT_VO, MSGL_V, ".no\n"); | |
490 return 0; | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
491 } |
261 | 492 } |
493 | |
494 | |
495 | |
496 //--------------------------------------------------------- | |
497 | |
12582 | 498 static void init_video_buffers(uint8_t * buffer_base, |
499 int view_port_height, | |
500 int bytes_per_scanline, | |
501 int max_view_port_y, | |
502 int use_multiple_buffers) | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
503 { |
12582 | 504 int bytes_per_buffer = view_port_height * bytes_per_scanline; |
505 int i; | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
506 |
12582 | 507 if (use_multiple_buffers) |
508 vo_dga_nr_video_buffers = max_view_port_y / view_port_height; | |
509 else | |
510 vo_dga_nr_video_buffers = 1; | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
511 |
12582 | 512 if (vo_dga_nr_video_buffers > MAX_NR_VIDEO_BUFFERS) |
513 vo_dga_nr_video_buffers = MAX_NR_VIDEO_BUFFERS; | |
514 if (vo_dga_nr_video_buffers <= 0) | |
515 vo_dga_nr_video_buffers = 1; | |
516 | |
517 vo_dga_current_video_buffer = 0; | |
9274 | 518 |
12582 | 519 for (i = 0; i < vo_dga_nr_video_buffers; i++) |
520 { | |
521 vo_dga_video_buffer[i].y = i * view_port_height; | |
522 vo_dga_video_buffer[i].data = buffer_base + i * bytes_per_buffer; | |
523 | |
524 // Clear video buffer. | |
525 memset(vo_dga_video_buffer[i].data, 0, bytes_per_buffer); | |
526 } | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
527 } |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
528 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
529 static int config(uint32_t width, uint32_t height, |
12582 | 530 uint32_t d_width, uint32_t d_height, |
531 uint32_t flags, char *title, uint32_t format) | |
261 | 532 { |
533 | |
12582 | 534 int x_off, y_off; |
535 int wanted_width, wanted_height; | |
261 | 536 |
12582 | 537 static unsigned char *vo_dga_base; |
538 static int prev_width, prev_height; | |
539 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
540 #ifdef CONFIG_DGA2 |
12582 | 541 // needed to change DGA video mode |
542 int mX = VO_DGA_INVALID_RES, mY = VO_DGA_INVALID_RES, mVBI = | |
543 100000, mMaxY = 0, i, j = 0; | |
544 int dga_modenum; | |
545 XDGAMode *modeline; | |
546 XDGADevice *dgadevice; | |
261 | 547 #else |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
548 #ifdef CONFIG_XF86VM |
12582 | 549 unsigned int vm_event, vm_error; |
550 unsigned int vm_ver, vm_rev; | |
551 int i, j = 0, have_vm = 0; | |
552 int mX = VO_DGA_INVALID_RES, mY = VO_DGA_INVALID_RES, mVBI = | |
553 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
|
554 #endif |
12582 | 555 int bank, ram; |
261 | 556 #endif |
557 | |
12582 | 558 vo_dga_src_format = format; |
559 | |
560 wanted_width = d_width; | |
561 wanted_height = d_height; | |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
562 |
12582 | 563 if (!wanted_height) |
564 wanted_height = height; | |
565 if (!wanted_width) | |
566 wanted_width = width; | |
261 | 567 |
12582 | 568 if (!vo_dbpp) |
569 { | |
570 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) | |
571 { | |
572 vo_dga_src_mode = vd_ModeValid(format & 0xff); | |
573 } | |
574 } else | |
575 { | |
576 vo_dga_src_mode = vd_ModeValid(vo_dbpp); | |
392 | 577 } |
12582 | 578 vo_dga_hw_mode = SRC_MODE.vdm_hw_mode; |
680
fbd9327b899b
- now features 24->32 conversion (this is actually faster than letting the
acki2
parents:
677
diff
changeset
|
579 |
12582 | 580 if (!vo_dga_src_mode) |
581 { | |
582 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: unsupported video format!\n"); | |
583 return 1; | |
584 } | |
261 | 585 |
12582 | 586 vo_dga_vp_width = vo_screenwidth; |
587 vo_dga_vp_height = vo_screenheight; | |
588 | |
589 mp_msg(MSGT_VO, MSGL_V, "vo_dga: XServer res: %dx%d\n", | |
590 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
|
591 |
261 | 592 // choose a suitable mode ... |
12582 | 593 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
594 #ifdef CONFIG_DGA2 |
261 | 595 // Code to change the video mode added by Michael Graffam |
596 // mgraffam@idsi.net | |
3318 | 597 |
12582 | 598 mp_msg(MSGT_VO, MSGL_V, "vo_dga: vo_modelines=%p, vo_modecount=%d\n", |
599 vo_modelines, vo_modecount); | |
600 | |
601 if (vo_modelines == NULL) | |
602 { | |
603 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: can't get modelines\n"); | |
604 return 1; | |
605 } | |
3318 | 606 |
12582 | 607 mp_msg(MSGT_VO, MSGL_INFO, |
608 "vo_dga: DGA 2.0 available :-) Can switch resolution AND depth!\n"); | |
609 for (i = 0; i < vo_modecount; i++) | |
610 { | |
611 if (vd_ModeEqual(vo_modelines[i].depth, | |
612 vo_modelines[i].bitsPerPixel, | |
613 vo_modelines[i].redMask, | |
614 vo_modelines[i].greenMask, | |
615 vo_modelines[i].blueMask, vo_dga_hw_mode)) | |
616 { | |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
617 |
12582 | 618 mp_msg(MSGT_VO, MSGL_V, "maxy: %4d, depth: %2d, %4dx%4d, ", |
619 vo_modelines[i].maxViewportY, vo_modelines[i].depth, | |
620 vo_modelines[i].imageWidth, | |
621 vo_modelines[i].imageHeight); | |
622 if (check_res | |
623 (i, wanted_width, wanted_height, vo_modelines[i].depth, | |
624 vo_modelines[i].viewportWidth, | |
625 vo_modelines[i].viewportHeight, | |
626 (unsigned) vo_modelines[i].verticalRefresh, | |
627 vo_modelines[i].maxViewportY, &mX, &mY, &mVBI, &mMaxY)) | |
628 j = i; | |
629 } | |
630 } | |
631 mp_msg(MSGT_VO, MSGL_INFO, | |
632 "vo_dga: Selected hardware mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d.\n", | |
633 mX, mY, mVBI, HW_MODE.vdm_depth, HW_MODE.vdm_bitspp); | |
634 mp_msg(MSGT_VO, MSGL_INFO, | |
635 "vo_dga: Video parameters by codec: %3d x %3d, depth %2d, bitspp %2d.\n", | |
636 width, height, SRC_MODE.vdm_depth, SRC_MODE.vdm_bitspp); | |
637 vo_dga_vp_width = mX; | |
638 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
|
639 |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14795
diff
changeset
|
640 if ((flags & VOFLAG_SWSCALE) || (flags & VOFLAG_FULLSCREEN)) |
12582 | 641 { /* -zoom or -fs */ |
642 scale_dstW = (d_width + 7) & ~7; | |
643 scale_dstH = d_height; | |
644 scale_srcW = width; | |
645 scale_srcH = height; | |
646 aspect_save_screenres(mX, mY); | |
647 aspect_save_orig(scale_srcW, scale_srcH); | |
648 aspect_save_prescale(scale_dstW, scale_dstH); | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14795
diff
changeset
|
649 if (flags & VOFLAG_FULLSCREEN) /* -fs */ |
12582 | 650 aspect(&scale_dstW, &scale_dstH, A_ZOOM); |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14795
diff
changeset
|
651 else if (flags & VOFLAG_SWSCALE) /* -fs */ |
12582 | 652 aspect(&scale_dstW, &scale_dstH, A_NOZOOM); |
653 mp_msg(MSGT_VO, MSGL_INFO, | |
654 "vo_dga: Aspect corrected size for SwScaler: %4d x %4d.\n", | |
655 scale_dstW, scale_dstH); | |
656 /* XXX this is a hack, but I'm lazy ;-) :: atmos */ | |
657 width = scale_dstW; | |
658 height = scale_dstH; | |
659 } | |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
660 |
12582 | 661 vo_dga_width = vo_modelines[j].bytesPerScanline / HW_MODE.vdm_bytespp; |
662 dga_modenum = vo_modelines[j].num; | |
663 modeline = vo_modelines + j; | |
664 | |
261 | 665 #else |
666 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
667 #ifdef CONFIG_XF86VM |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
668 |
12582 | 669 mp_msg(MSGT_VO, MSGL_INFO, |
670 "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
|
671 |
12582 | 672 if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) |
673 { | |
674 XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev); | |
675 mp_msg(MSGT_VO, MSGL_INFO, | |
676 "vo_dga: XF86VidMode Extension v%i.%i\n", vm_ver, vm_rev); | |
677 have_vm = 1; | |
678 } else | |
679 { | |
680 mp_msg(MSGT_VO, MSGL_ERR, | |
681 "vo_dga: XF86VidMode Extension not available.\n"); | |
682 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
683 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
684 #define GET_VREFRESH(dotclk, x, y)( (((dotclk)/(x))*1000)/(y) ) |
12582 | 685 |
686 if (have_vm) | |
687 { | |
688 int modecount; | |
689 | |
690 XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, | |
691 &vo_dga_vidmodes); | |
261 | 692 |
12582 | 693 if (vo_dga_vidmodes != NULL) |
694 { | |
695 for (i = 0; i < modecount; i++) | |
696 { | |
697 if (check_res(i, wanted_width, wanted_height, | |
698 vo_dga_modes[vo_dga_hw_mode].vdm_depth, | |
699 vo_dga_vidmodes[i]->hdisplay, | |
700 vo_dga_vidmodes[i]->vdisplay, | |
701 GET_VREFRESH(vo_dga_vidmodes[i]->dotclock, | |
702 vo_dga_vidmodes[i]->htotal, | |
703 vo_dga_vidmodes[i]->vtotal), | |
704 0, &mX, &mY, &mVBI, &mMaxY)) | |
705 j = i; | |
706 } | |
707 | |
708 mp_msg(MSGT_VO, MSGL_INFO, | |
709 "vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n", | |
710 mX, mY, mVBI, | |
711 vo_dga_modes[vo_dga_hw_mode].vdm_depth, | |
712 vo_dga_modes[vo_dga_hw_mode].vdm_bitspp, width, height); | |
713 } else | |
714 { | |
715 mp_msg(MSGT_VO, MSGL_INFO, | |
716 "vo_dga: XF86VidMode returned no screens - using current resolution.\n"); | |
717 } | |
718 dga_modenum = j; | |
719 vo_dga_vp_width = mX; | |
720 vo_dga_vp_height = mY; | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
721 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
722 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
723 #else |
12582 | 724 mp_msg(MSGT_VO, MSGL_INFO, |
725 "vo_dga: Only have DGA 1.0 extension and no XF86VidMode :-(\n"); | |
726 mp_msg(MSGT_VO, MSGL_INFO, | |
727 " Thus, resolution switching is NOT possible.\n"); | |
392 | 728 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
729 #endif |
261 | 730 #endif |
731 | |
12582 | 732 vo_dga_src_width = width; |
733 vo_dga_src_height = height; | |
734 | |
735 if (vo_dga_src_width > vo_dga_vp_width || | |
736 vo_dga_src_height > vo_dga_vp_height) | |
737 { | |
738 mp_msg(MSGT_VO, MSGL_ERR, | |
739 "vo_dga: Sorry, video larger than viewport is not yet supported!\n"); | |
740 // ugly, do something nicer in the future ... | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
741 #ifndef CONFIG_DGA2 |
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
742 #ifdef CONFIG_XF86VM |
12582 | 743 if (vo_dga_vidmodes) |
744 { | |
745 XFree(vo_dga_vidmodes); | |
746 vo_dga_vidmodes = NULL; | |
747 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
748 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
749 #endif |
12582 | 750 return 1; |
751 } | |
1154
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
752 |
12582 | 753 if (vo_dga_vp_width == VO_DGA_INVALID_RES) |
754 { | |
755 mp_msg(MSGT_VO, MSGL_ERR, | |
756 "vo_dga: Something is wrong with your DGA. There doesn't seem to be a\n" | |
757 " single suitable mode!\n" | |
758 " Please file a bug report (see DOCS/HTML/en/bugreports.html)\n"); | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
759 #ifndef CONFIG_DGA2 |
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
760 #ifdef CONFIG_XF86VM |
12582 | 761 if (vo_dga_vidmodes) |
762 { | |
763 XFree(vo_dga_vidmodes); | |
764 vo_dga_vidmodes = NULL; | |
765 } | |
1154
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
766 #endif |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
767 #endif |
12582 | 768 return 1; |
769 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
770 // now let's start the DGA thing |
261 | 771 |
12582 | 772 if (!vo_config_count || width != prev_width || height != prev_height) |
773 { | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
774 #ifdef CONFIG_DGA2 |
8067 | 775 |
12582 | 776 if (!XDGAOpenFramebuffer(mDisplay, mScreen)) |
777 { | |
778 mp_msg(MSGT_VO, MSGL_ERR, | |
779 "vo_dga: Framebuffer mapping failed!!!\n"); | |
780 return 1; | |
781 } | |
8067 | 782 |
12582 | 783 dgadevice = XDGASetMode(mDisplay, mScreen, dga_modenum); |
784 XDGASync(mDisplay, mScreen); | |
221
3daeae4a4aa6
Added support to vo_dga to change the video mode to the lowest resolution
mgraffam
parents:
31
diff
changeset
|
785 |
12582 | 786 vo_dga_base = dgadevice->data; |
787 XFree(dgadevice); | |
261 | 788 |
12582 | 789 XDGASetViewport(mDisplay, mScreen, 0, 0, XDGAFlipRetrace); |
790 | |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
791 #else |
8067 | 792 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
793 #ifdef CONFIG_XF86VM |
12582 | 794 if (have_vm) |
795 { | |
796 XF86VidModeLockModeSwitch(mDisplay, mScreen, 0); | |
797 // Two calls are needed to switch modes on my ATI Rage 128. Why? | |
798 // for riva128 one call is enough! | |
799 XF86VidModeSwitchToMode(mDisplay, mScreen, | |
800 vo_dga_vidmodes[dga_modenum]); | |
801 XF86VidModeSwitchToMode(mDisplay, mScreen, | |
802 vo_dga_vidmodes[dga_modenum]); | |
803 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
804 #endif |
12582 | 805 |
806 XF86DGAGetViewPortSize(mDisplay, mScreen, | |
807 &vo_dga_vp_width, &vo_dga_vp_height); | |
13 | 808 |
12582 | 809 XF86DGAGetVideo(mDisplay, mScreen, |
810 (char **) &vo_dga_base, &vo_dga_width, &bank, | |
811 &ram); | |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
812 |
12582 | 813 XF86DGADirectVideo(mDisplay, mScreen, |
814 XF86DGADirectGraphics | XF86DGADirectMouse | | |
815 XF86DGADirectKeyb); | |
816 | |
817 XF86DGASetViewPort(mDisplay, mScreen, 0, 0); | |
261 | 818 |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
819 #endif |
12582 | 820 } |
821 // do some more checkings here ... | |
261 | 822 |
12582 | 823 mp_msg(MSGT_VO, MSGL_V, |
17366 | 824 "vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %p, bpp: %d\n", |
12582 | 825 vo_dga_width, vo_dga_vp_width, vo_dga_vp_height, |
826 HW_MODE.vdm_bytespp, vo_dga_base, HW_MODE.vdm_bitspp); | |
827 | |
828 x_off = (vo_dga_vp_width - vo_dga_src_width) >> 1; | |
829 y_off = (vo_dga_vp_height - vo_dga_src_height) >> 1; | |
13 | 830 |
12582 | 831 vo_dga_bytes_per_line = vo_dga_src_width * HW_MODE.vdm_bytespp; |
832 vo_dga_lines = vo_dga_src_height; | |
13 | 833 |
12582 | 834 vo_dga_src_offset = 0; |
835 vo_dga_vp_offset = | |
836 (y_off * vo_dga_width + x_off) * HW_MODE.vdm_bytespp; | |
13 | 837 |
12582 | 838 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * HW_MODE.vdm_bytespp; // todo |
839 | |
840 mp_msg(MSGT_VO, MSGL_V, "vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n", | |
841 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line); | |
842 | |
13 | 843 |
12582 | 844 XGrabKeyboard(mDisplay, DefaultRootWindow(mDisplay), True, |
845 GrabModeAsync, GrabModeAsync, CurrentTime); | |
846 if (vo_grabpointer) | |
847 XGrabPointer(mDisplay, DefaultRootWindow(mDisplay), True, | |
848 ButtonPressMask, GrabModeAsync, GrabModeAsync, | |
849 None, None, CurrentTime); | |
262 | 850 |
12582 | 851 if (!vo_config_count || width != prev_width || height != prev_height) |
852 { | |
853 init_video_buffers(vo_dga_base, | |
854 vo_dga_vp_height, | |
855 vo_dga_width * HW_MODE.vdm_bytespp, | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
856 #ifdef CONFIG_DGA2 |
12582 | 857 modeline->maxViewportY, |
7515 | 858 #else |
12582 | 859 vo_dga_vp_height, |
7515 | 860 #endif |
12582 | 861 vo_doublebuffering); |
862 prev_width = width; | |
863 prev_height = height; | |
864 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
865 |
12582 | 866 mp_msg(MSGT_VO, MSGL_V, "vo_dga: Using %d frame buffer%s.\n", |
867 vo_dga_nr_video_buffers, | |
868 vo_dga_nr_video_buffers == 1 ? "" : "s"); | |
869 | |
870 vo_dga_is_running = 1; | |
871 return 0; | |
13 | 872 } |
873 | |
7930 | 874 static int dga_depths_init = 0; |
875 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
876 static int preinit(const char *arg) |
4352 | 877 { |
12582 | 878 if (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
|
879 { |
12582 | 880 mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Unknown subdevice: %s\n", arg); |
881 return ENOSYS; | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
882 } |
7930 | 883 |
12582 | 884 if (!vo_init()) |
885 return -1; // Can't open X11 | |
7930 | 886 |
12582 | 887 if (dga_depths_init == 0) |
888 { // FIXME!? | |
889 int i; | |
7930 | 890 |
12582 | 891 vo_dga_XServer_mode = vd_ValidateMode(vo_depthonscreen); |
7930 | 892 |
12582 | 893 if (vo_dga_XServer_mode == 0) |
894 { | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
895 #ifndef CONFIG_DGA2 |
12582 | 896 mp_msg(MSGT_VO, MSGL_ERR, |
897 "vo_dga: Your X-Server is not running in a "); | |
898 mp_msg(MSGT_VO, MSGL_ERR, | |
899 "resolution supported by DGA driver!\n"); | |
900 #endif | |
901 } //else{ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
902 // mp_msg(MSGT_VO, MSGL_V, "vo_dga: X running at: %s\n", |
12582 | 903 // vd_GetModeString(vo_dga_XServer_mode)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
904 //} |
12582 | 905 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
906 #ifdef CONFIG_DGA2 |
12582 | 907 vo_modelines = XDGAQueryModes(mDisplay, mScreen, &vo_modecount); |
908 if (vo_modelines) | |
909 { | |
910 for (i = 0; i < vo_modecount; i++) | |
911 { | |
912 mp_msg(MSGT_VO, MSGL_V, | |
17366 | 913 "vo_dga: (%03d) depth=%d, bpp=%d, r=%08lx, g=%08lx, b=%08lx, %d x %d\n", |
12582 | 914 i, vo_modelines[i].depth, |
915 vo_modelines[i].bitsPerPixel, | |
916 vo_modelines[i].redMask, vo_modelines[i].greenMask, | |
917 vo_modelines[i].blueMask, | |
918 vo_modelines[i].viewportWidth, | |
919 vo_modelines[i].viewportHeight); | |
920 vd_EnableMode(vo_modelines[i].depth, | |
921 vo_modelines[i].bitsPerPixel, | |
922 vo_modelines[i].redMask, | |
923 vo_modelines[i].greenMask, | |
924 vo_modelines[i].blueMask); | |
925 } | |
926 } | |
7930 | 927 #endif |
12582 | 928 dga_depths_init = 1; |
7930 | 929 |
12582 | 930 if (!vo_dga_modes[1].vdm_supported |
931 && vo_dga_modes[2].vdm_supported) | |
932 { | |
933 vo_dga_modes[1].vdm_supported = 1; | |
934 } | |
7930 | 935 |
12582 | 936 if (!vo_dga_modes[3].vdm_supported |
937 && vo_dga_modes[4].vdm_supported) | |
938 { | |
939 vo_dga_modes[3].vdm_supported = 1; | |
940 } | |
7930 | 941 |
12582 | 942 for (i = 1; i < vo_dga_mode_num; i++) |
943 { | |
944 mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Mode: %s", | |
945 vd_GetModeString(i)); | |
946 if (vo_dbpp && vo_dbpp != vo_dga_modes[i].vdm_mplayer_depth) | |
947 { | |
948 vo_dga_modes[i].vdm_supported = 0; | |
949 mp_msg(MSGT_VO, MSGL_INFO, " ...disabled by -bpp %d", | |
950 vo_dbpp); | |
951 } | |
952 mp_msg(MSGT_VO, MSGL_INFO, "\n"); | |
953 } | |
954 } | |
7930 | 955 |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
956 return 0; |
4352 | 957 } |
958 | |
12582 | 959 static uint32_t get_image(mp_image_t * mpi) |
8084 | 960 { |
12582 | 961 if (!IMGFMT_IS_BGR(mpi->imgfmt) || |
962 (IMGFMT_BGR_DEPTH(mpi->imgfmt) != | |
963 vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth) | |
964 || (mpi->type == MP_IMGTYPE_STATIC && vo_dga_nr_video_buffers > 1) | |
965 || (mpi->type == MP_IMGTYPE_IP && vo_dga_nr_video_buffers < 2) | |
966 || (mpi->type == MP_IMGTYPE_IPB)) | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26400
diff
changeset
|
967 return VO_FALSE; |
12582 | 968 |
969 if ((mpi->flags & MP_IMGFLAG_ACCEPT_STRIDE) || | |
970 (mpi->flags & MP_IMGFLAG_ACCEPT_WIDTH && | |
971 ((vo_dga_bytes_per_line + vo_dga_vp_skip) % (mpi->bpp / 8)) == 0) | |
972 || (mpi->width * (mpi->bpp / 8) == | |
973 (vo_dga_bytes_per_line + vo_dga_vp_skip))) | |
974 { | |
975 | |
976 mpi->planes[0] = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; | |
977 mpi->stride[0] = vo_dga_bytes_per_line + vo_dga_vp_skip; | |
978 mpi->width = | |
979 (vo_dga_bytes_per_line + vo_dga_vp_skip) / (mpi->bpp / 8); | |
980 mpi->flags |= MP_IMGFLAG_DIRECT; | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26400
diff
changeset
|
981 return VO_TRUE; |
8084 | 982 } |
983 | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26400
diff
changeset
|
984 return VO_FALSE; |
8084 | 985 } |
986 | |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
32467
diff
changeset
|
987 static int control(uint32_t request, void *data) |
4352 | 988 { |
12582 | 989 switch (request) |
990 { | |
991 case VOCTRL_GET_IMAGE: | |
992 return get_image(data); | |
993 case VOCTRL_QUERY_FORMAT: | |
994 return query_format(*((uint32_t *) data)); | |
995 } | |
996 return VO_NOTIMPL; | |
4352 | 997 } |
998 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
999 //--------------------------------------------------------- |