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