Mercurial > mplayer.hg
annotate libvo/vo_dga.c @ 36215:4eb27365d0b0
Add hack to fix compilation issues on OSX with broken libiconv.
Such a hack is not really a good solution, but since the
issue is relatively common it seems worth it for the moment.
author | reimar |
---|---|
date | Sun, 09 Jun 2013 13:54:47 +0000 |
parents | b291f44d864a |
children | 5d3f93051de9 |
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; |
35050
b291f44d864a
Avoid some code duplication related to drawing the OSD.
reimar
parents:
33305
diff
changeset
|
248 int bpp = pixel_stride(vo_dga_src_format); |
b291f44d864a
Avoid some code duplication related to drawing the OSD.
reimar
parents:
33305
diff
changeset
|
249 vo_draw_alpha_func draw = vo_get_draw_alpha(vo_dga_src_format); |
12582 | 250 |
251 offset = vo_dga_width * y0 + x0; | |
35050
b291f44d864a
Avoid some code duplication related to drawing the OSD.
reimar
parents:
33305
diff
changeset
|
252 buffer_stride = vo_dga_width * bpp; |
12582 | 253 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
|
254 d += bpp * offset; |
490 | 255 |
35050
b291f44d864a
Avoid some code duplication related to drawing the OSD.
reimar
parents:
33305
diff
changeset
|
256 if (draw) draw(w, h, src, srca, stride, d, buffer_stride); |
392 | 257 } |
258 | |
490 | 259 |
392 | 260 //--------------------------------------------------------- |
261 | |
262 | |
263 | |
13 | 264 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
265 // quick & dirty - for debugging only |
10495 | 266 #if 0 |
12582 | 267 static void fillblock(char *strt, int yoff, int lines, int val) |
268 { | |
269 char *i; | |
270 | |
271 for (i = strt + yoff * vo_dga_width * HW_MODE.vdm_bytespp; | |
272 i < strt + (lines + yoff) * vo_dga_width * HW_MODE.vdm_bytespp;) | |
273 { | |
274 *i++ = val; | |
275 } | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
276 } |
10495 | 277 #endif |
13 | 278 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
279 //--------------------------------------------------------- |
13 | 280 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
281 static int draw_frame(uint8_t * src[]) |
12582 | 282 { |
13 | 283 |
12582 | 284 int numlines = vo_dga_lines; |
13 | 285 |
12582 | 286 char *s, *d; |
13 | 287 |
12582 | 288 s = *src; |
289 d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; | |
290 | |
291 mem2agpcpy_pic(d, s, | |
292 vo_dga_bytes_per_line, | |
293 numlines, | |
294 vo_dga_bytes_per_line + vo_dga_vp_skip, | |
295 vo_dga_bytes_per_line); | |
296 | |
297 // DBG-COde | |
720
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
298 |
8146b106816a
- now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents:
691
diff
changeset
|
299 #if 0 |
12582 | 300 d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; |
301 fillblock(d, 0, 10, 0x800000ff); | |
302 fillblock(d, 10, 10, 0x8000ff00); | |
303 fillblock(d, 20, 10, 0x80ff0000); | |
304 fillblock(d, 30, 10, 0xff0000ff); | |
305 fillblock(d, 40, 10, 0x800000ff); | |
306 fillblock(d, 50, 10, 0x0f0000ff); | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
307 #endif |
12582 | 308 return 0; |
13 | 309 } |
310 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
311 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
312 |
31 | 313 static void check_events(void) |
314 { | |
12582 | 315 vo_x11_check_events(mDisplay); |
31 | 316 } |
317 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
318 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
319 |
32467 | 320 #include "sub/sub.h" |
612 | 321 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1336
diff
changeset
|
322 static void draw_osd(void) |
12582 | 323 { |
324 vo_draw_text(vo_dga_src_width, vo_dga_src_height, draw_alpha); | |
325 } | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1336
diff
changeset
|
326 |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
327 static void switch_video_buffers(void) |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
328 { |
12582 | 329 vo_dga_current_video_buffer = |
330 (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
|
331 } |
262 | 332 |
12582 | 333 static void flip_page(void) |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
334 { |
12582 | 335 if (1 < vo_dga_nr_video_buffers) |
336 { | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
337 #ifdef CONFIG_DGA2 |
12582 | 338 XDGASetViewport(mDisplay, mScreen, |
339 0, CURRENT_VIDEO_BUFFER.y, XDGAFlipRetrace); | |
262 | 340 #else |
12582 | 341 XF86DGASetViewPort(mDisplay, mScreen, 0, CURRENT_VIDEO_BUFFER.y); |
262 | 342 #endif |
12582 | 343 switch_video_buffers(); |
344 } | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
345 } |
13 | 346 |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
347 //--------------------------------------------------------- |
13 | 348 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
349 static int draw_slice(uint8_t * src[], int stride[], |
12582 | 350 int w, int h, int x, int y) |
13 | 351 { |
12582 | 352 return 0; |
13 | 353 }; |
354 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
355 //--------------------------------------------------------- |
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
356 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
357 static int query_format(uint32_t format) |
13 | 358 { |
261 | 359 |
12582 | 360 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR && |
361 vd_ModeValid(format & 0xff)) | |
362 { | |
363 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD; | |
364 } | |
365 | |
366 return 0; | |
13 | 367 } |
368 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
369 //--------------------------------------------------------- |
13 | 370 |
12582 | 371 static void uninit(void) |
13 | 372 { |
373 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
374 #ifdef CONFIG_DGA2 |
12582 | 375 XDGADevice *dgadevice; |
261 | 376 #endif |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
377 |
12582 | 378 if (!vo_config_count) |
379 return; | |
8067 | 380 |
12582 | 381 if (vo_dga_is_running) |
382 { | |
383 vo_dga_is_running = 0; | |
384 mp_msg(MSGT_VO, MSGL_V, "vo_dga: in uninit\n"); | |
385 if (vo_grabpointer) | |
386 XUngrabPointer(mDisplay, CurrentTime); | |
387 XUngrabKeyboard(mDisplay, CurrentTime); | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
388 #ifdef CONFIG_DGA2 |
12582 | 389 XDGACloseFramebuffer(mDisplay, mScreen); |
390 dgadevice = XDGASetMode(mDisplay, mScreen, 0); | |
391 if (dgadevice != NULL) | |
392 { | |
393 XFree(dgadevice); | |
394 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
395 #else |
12582 | 396 XF86DGADirectVideo(mDisplay, mScreen, 0); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
397 // first disable DirectVideo and then switch mode back! |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
398 #ifdef CONFIG_XF86VM |
12582 | 399 if (vo_dga_vidmodes != NULL) |
400 { | |
401 int screen; | |
402 | |
403 screen = XDefaultScreen(mDisplay); | |
404 mp_msg(MSGT_VO, MSGL_V, | |
405 "vo_dga: VidModeExt: Switching back..\n"); | |
406 // seems some graphics adaptors need this more than once ... | |
407 XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]); | |
408 XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]); | |
409 XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]); | |
410 XF86VidModeSwitchToMode(mDisplay, screen, vo_dga_vidmodes[0]); | |
411 XFree(vo_dga_vidmodes); | |
412 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
413 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
414 #endif |
12582 | 415 } |
416 vo_x11_uninit(); | |
13 | 417 } |
418 | |
419 | |
261 | 420 //---------------------------------------------------------- |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
421 // TODO: check for larger maxy value |
392 | 422 // (useful for double buffering!!!) |
261 | 423 |
12582 | 424 static int check_res(int num, int x, int y, int bpp, |
425 int new_x, int new_y, int new_vbi, int new_maxy, | |
426 int *old_x, int *old_y, int *old_vbi, int *old_maxy) | |
427 { | |
261 | 428 |
12582 | 429 mp_msg(MSGT_VO, MSGL_V, |
430 "vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ depth %2d ..", num, | |
431 new_x, new_y, new_vbi, bpp); | |
432 mp_msg(MSGT_VO, MSGL_V, "(old: %dx%d@%d).", *old_x, *old_y, *old_vbi); | |
433 if ((new_x >= x) && (new_y >= y) && ( | |
434 // prefer a better resolution either in X or in Y | |
435 // as long as the other dimension is at least the same | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
436 // |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
437 // hmm ... MAYBE it would be more clever to focus on the |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
438 // x-resolution; I had 712x400 and 640x480 and the movie |
12582 | 439 // was 640x360; 640x480 would be the 'right thing' here |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
440 // but since 712x400 was queried first I got this one. |
12582 | 441 // I think there should be a cmd-line switch to let the |
442 // user choose the mode he likes ... (acki2) | |
443 (((new_x < *old_x) && | |
444 !(new_y > *old_y)) || | |
445 ((new_y < *old_y) && | |
446 !(new_x > *old_x))) | |
447 // but if we get an identical resolution choose | |
448 // the one with the lower refreshrate (saves bandwidth !!!) | |
449 // as long as it's above 50 Hz (acki2 on 30/3/2001) | |
450 || | |
451 (((new_x == *old_x) && | |
452 (new_y == *old_y) && | |
453 ((new_vbi >= *old_vbi | |
454 && *old_vbi < 50) | |
455 || (*old_vbi >= 50 | |
456 && new_vbi < *old_vbi | |
457 && new_vbi >= 50))) || | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
458 // if everything is equal, then use the mode with the lower |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
459 // stride |
12582 | 460 ((new_x == *old_x) && |
461 (new_y == *old_y) && | |
462 (new_vbi == *old_vbi) && | |
463 (new_maxy > *old_maxy))))) | |
261 | 464 { |
12582 | 465 *old_x = new_x; |
466 *old_y = new_y; | |
467 *old_maxy = new_maxy; | |
468 *old_vbi = new_vbi; | |
469 mp_msg(MSGT_VO, MSGL_V, ".ok!!\n"); | |
470 return 1; | |
471 } else | |
472 { | |
473 mp_msg(MSGT_VO, MSGL_V, ".no\n"); | |
474 return 0; | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
475 } |
261 | 476 } |
477 | |
478 | |
479 | |
480 //--------------------------------------------------------- | |
481 | |
12582 | 482 static void init_video_buffers(uint8_t * buffer_base, |
483 int view_port_height, | |
484 int bytes_per_scanline, | |
485 int max_view_port_y, | |
486 int use_multiple_buffers) | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
487 { |
12582 | 488 int bytes_per_buffer = view_port_height * bytes_per_scanline; |
489 int i; | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
490 |
12582 | 491 if (use_multiple_buffers) |
492 vo_dga_nr_video_buffers = max_view_port_y / view_port_height; | |
493 else | |
494 vo_dga_nr_video_buffers = 1; | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
495 |
12582 | 496 if (vo_dga_nr_video_buffers > MAX_NR_VIDEO_BUFFERS) |
497 vo_dga_nr_video_buffers = MAX_NR_VIDEO_BUFFERS; | |
498 if (vo_dga_nr_video_buffers <= 0) | |
499 vo_dga_nr_video_buffers = 1; | |
500 | |
501 vo_dga_current_video_buffer = 0; | |
9274 | 502 |
12582 | 503 for (i = 0; i < vo_dga_nr_video_buffers; i++) |
504 { | |
505 vo_dga_video_buffer[i].y = i * view_port_height; | |
506 vo_dga_video_buffer[i].data = buffer_base + i * bytes_per_buffer; | |
507 | |
508 // Clear video buffer. | |
509 memset(vo_dga_video_buffer[i].data, 0, bytes_per_buffer); | |
510 } | |
7498
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
511 } |
2b4190fb8218
Attached patch improves the vertical retrace synchronisation (vsync)
arpi
parents:
7124
diff
changeset
|
512 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
513 static int config(uint32_t width, uint32_t height, |
12582 | 514 uint32_t d_width, uint32_t d_height, |
515 uint32_t flags, char *title, uint32_t format) | |
261 | 516 { |
517 | |
12582 | 518 int x_off, y_off; |
519 int wanted_width, wanted_height; | |
261 | 520 |
12582 | 521 static unsigned char *vo_dga_base; |
522 static int prev_width, prev_height; | |
523 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
524 #ifdef CONFIG_DGA2 |
12582 | 525 // needed to change DGA video mode |
526 int mX = VO_DGA_INVALID_RES, mY = VO_DGA_INVALID_RES, mVBI = | |
527 100000, mMaxY = 0, i, j = 0; | |
528 int dga_modenum; | |
529 XDGAMode *modeline; | |
530 XDGADevice *dgadevice; | |
261 | 531 #else |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
532 #ifdef CONFIG_XF86VM |
12582 | 533 unsigned int vm_event, vm_error; |
534 unsigned int vm_ver, vm_rev; | |
535 int i, j = 0, have_vm = 0; | |
536 int mX = VO_DGA_INVALID_RES, mY = VO_DGA_INVALID_RES, mVBI = | |
537 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
|
538 #endif |
12582 | 539 int bank, ram; |
261 | 540 #endif |
541 | |
12582 | 542 vo_dga_src_format = format; |
543 | |
544 wanted_width = d_width; | |
545 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
|
546 |
12582 | 547 if (!wanted_height) |
548 wanted_height = height; | |
549 if (!wanted_width) | |
550 wanted_width = width; | |
261 | 551 |
12582 | 552 if (!vo_dbpp) |
553 { | |
554 if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR) | |
555 { | |
556 vo_dga_src_mode = vd_ModeValid(format & 0xff); | |
557 } | |
558 } else | |
559 { | |
560 vo_dga_src_mode = vd_ModeValid(vo_dbpp); | |
392 | 561 } |
12582 | 562 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
|
563 |
12582 | 564 if (!vo_dga_src_mode) |
565 { | |
566 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: unsupported video format!\n"); | |
567 return 1; | |
568 } | |
261 | 569 |
12582 | 570 vo_dga_vp_width = vo_screenwidth; |
571 vo_dga_vp_height = vo_screenheight; | |
572 | |
573 mp_msg(MSGT_VO, MSGL_V, "vo_dga: XServer res: %dx%d\n", | |
574 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
|
575 |
261 | 576 // choose a suitable mode ... |
12582 | 577 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
578 #ifdef CONFIG_DGA2 |
261 | 579 // Code to change the video mode added by Michael Graffam |
580 // mgraffam@idsi.net | |
3318 | 581 |
12582 | 582 mp_msg(MSGT_VO, MSGL_V, "vo_dga: vo_modelines=%p, vo_modecount=%d\n", |
583 vo_modelines, vo_modecount); | |
584 | |
585 if (vo_modelines == NULL) | |
586 { | |
587 mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: can't get modelines\n"); | |
588 return 1; | |
589 } | |
3318 | 590 |
12582 | 591 mp_msg(MSGT_VO, MSGL_INFO, |
592 "vo_dga: DGA 2.0 available :-) Can switch resolution AND depth!\n"); | |
593 for (i = 0; i < vo_modecount; i++) | |
594 { | |
595 if (vd_ModeEqual(vo_modelines[i].depth, | |
596 vo_modelines[i].bitsPerPixel, | |
597 vo_modelines[i].redMask, | |
598 vo_modelines[i].greenMask, | |
599 vo_modelines[i].blueMask, vo_dga_hw_mode)) | |
600 { | |
272
8ffe2f459851
- still more debug output to be able to fix 15/16 bpp problem
acki2
parents:
266
diff
changeset
|
601 |
12582 | 602 mp_msg(MSGT_VO, MSGL_V, "maxy: %4d, depth: %2d, %4dx%4d, ", |
603 vo_modelines[i].maxViewportY, vo_modelines[i].depth, | |
604 vo_modelines[i].imageWidth, | |
605 vo_modelines[i].imageHeight); | |
606 if (check_res | |
607 (i, wanted_width, wanted_height, vo_modelines[i].depth, | |
608 vo_modelines[i].viewportWidth, | |
609 vo_modelines[i].viewportHeight, | |
610 (unsigned) vo_modelines[i].verticalRefresh, | |
611 vo_modelines[i].maxViewportY, &mX, &mY, &mVBI, &mMaxY)) | |
612 j = i; | |
613 } | |
614 } | |
615 mp_msg(MSGT_VO, MSGL_INFO, | |
616 "vo_dga: Selected hardware mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d.\n", | |
617 mX, mY, mVBI, HW_MODE.vdm_depth, HW_MODE.vdm_bitspp); | |
618 mp_msg(MSGT_VO, MSGL_INFO, | |
619 "vo_dga: Video parameters by codec: %3d x %3d, depth %2d, bitspp %2d.\n", | |
620 width, height, SRC_MODE.vdm_depth, SRC_MODE.vdm_bitspp); | |
621 vo_dga_vp_width = mX; | |
622 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
|
623 |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14795
diff
changeset
|
624 if ((flags & VOFLAG_SWSCALE) || (flags & VOFLAG_FULLSCREEN)) |
12582 | 625 { /* -zoom or -fs */ |
626 scale_dstW = (d_width + 7) & ~7; | |
627 scale_dstH = d_height; | |
628 scale_srcW = width; | |
629 scale_srcH = height; | |
630 aspect_save_screenres(mX, mY); | |
631 aspect_save_orig(scale_srcW, scale_srcH); | |
632 aspect_save_prescale(scale_dstW, scale_dstH); | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14795
diff
changeset
|
633 if (flags & VOFLAG_FULLSCREEN) /* -fs */ |
12582 | 634 aspect(&scale_dstW, &scale_dstH, A_ZOOM); |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14795
diff
changeset
|
635 else if (flags & VOFLAG_SWSCALE) /* -fs */ |
12582 | 636 aspect(&scale_dstW, &scale_dstH, A_NOZOOM); |
637 mp_msg(MSGT_VO, MSGL_INFO, | |
638 "vo_dga: Aspect corrected size for SwScaler: %4d x %4d.\n", | |
639 scale_dstW, scale_dstH); | |
640 /* XXX this is a hack, but I'm lazy ;-) :: atmos */ | |
641 width = scale_dstW; | |
642 height = scale_dstH; | |
643 } | |
4060
974e028471a4
SwScaler support for vo_png by Kim Minh, SwScale w/aspecz for vo_dga by me
atmos4
parents:
3852
diff
changeset
|
644 |
12582 | 645 vo_dga_width = vo_modelines[j].bytesPerScanline / HW_MODE.vdm_bytespp; |
646 dga_modenum = vo_modelines[j].num; | |
647 modeline = vo_modelines + j; | |
648 | |
261 | 649 #else |
650 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
651 #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
|
652 |
12582 | 653 mp_msg(MSGT_VO, MSGL_INFO, |
654 "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
|
655 |
12582 | 656 if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) |
657 { | |
658 XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev); | |
659 mp_msg(MSGT_VO, MSGL_INFO, | |
660 "vo_dga: XF86VidMode Extension v%i.%i\n", vm_ver, vm_rev); | |
661 have_vm = 1; | |
662 } else | |
663 { | |
664 mp_msg(MSGT_VO, MSGL_ERR, | |
665 "vo_dga: XF86VidMode Extension not available.\n"); | |
666 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
667 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
668 #define GET_VREFRESH(dotclk, x, y)( (((dotclk)/(x))*1000)/(y) ) |
12582 | 669 |
670 if (have_vm) | |
671 { | |
672 int modecount; | |
673 | |
674 XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount, | |
675 &vo_dga_vidmodes); | |
261 | 676 |
12582 | 677 if (vo_dga_vidmodes != NULL) |
678 { | |
679 for (i = 0; i < modecount; i++) | |
680 { | |
681 if (check_res(i, wanted_width, wanted_height, | |
682 vo_dga_modes[vo_dga_hw_mode].vdm_depth, | |
683 vo_dga_vidmodes[i]->hdisplay, | |
684 vo_dga_vidmodes[i]->vdisplay, | |
685 GET_VREFRESH(vo_dga_vidmodes[i]->dotclock, | |
686 vo_dga_vidmodes[i]->htotal, | |
687 vo_dga_vidmodes[i]->vtotal), | |
688 0, &mX, &mY, &mVBI, &mMaxY)) | |
689 j = i; | |
690 } | |
691 | |
692 mp_msg(MSGT_VO, MSGL_INFO, | |
693 "vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n", | |
694 mX, mY, mVBI, | |
695 vo_dga_modes[vo_dga_hw_mode].vdm_depth, | |
696 vo_dga_modes[vo_dga_hw_mode].vdm_bitspp, width, height); | |
697 } else | |
698 { | |
699 mp_msg(MSGT_VO, MSGL_INFO, | |
700 "vo_dga: XF86VidMode returned no screens - using current resolution.\n"); | |
701 } | |
702 dga_modenum = j; | |
703 vo_dga_vp_width = mX; | |
704 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
|
705 } |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
706 |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
707 #else |
12582 | 708 mp_msg(MSGT_VO, MSGL_INFO, |
709 "vo_dga: Only have DGA 1.0 extension and no XF86VidMode :-(\n"); | |
710 mp_msg(MSGT_VO, MSGL_INFO, | |
711 " Thus, resolution switching is NOT possible.\n"); | |
392 | 712 |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
713 #endif |
261 | 714 #endif |
715 | |
12582 | 716 vo_dga_src_width = width; |
717 vo_dga_src_height = height; | |
718 | |
719 if (vo_dga_src_width > vo_dga_vp_width || | |
720 vo_dga_src_height > vo_dga_vp_height) | |
721 { | |
722 mp_msg(MSGT_VO, MSGL_ERR, | |
723 "vo_dga: Sorry, video larger than viewport is not yet supported!\n"); | |
724 // ugly, do something nicer in the future ... | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
725 #ifndef CONFIG_DGA2 |
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
726 #ifdef CONFIG_XF86VM |
12582 | 727 if (vo_dga_vidmodes) |
728 { | |
729 XFree(vo_dga_vidmodes); | |
730 vo_dga_vidmodes = NULL; | |
731 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
732 #endif |
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
733 #endif |
12582 | 734 return 1; |
735 } | |
1154
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
736 |
12582 | 737 if (vo_dga_vp_width == VO_DGA_INVALID_RES) |
738 { | |
739 mp_msg(MSGT_VO, MSGL_ERR, | |
740 "vo_dga: Something is wrong with your DGA. There doesn't seem to be a\n" | |
741 " single suitable mode!\n" | |
742 " 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
|
743 #ifndef CONFIG_DGA2 |
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
744 #ifdef CONFIG_XF86VM |
12582 | 745 if (vo_dga_vidmodes) |
746 { | |
747 XFree(vo_dga_vidmodes); | |
748 vo_dga_vidmodes = NULL; | |
749 } | |
1154
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
750 #endif |
4bf4e057c82e
- if DGA fails to report some valid modes, vo_dga now exits gracefully
acki2
parents:
1150
diff
changeset
|
751 #endif |
12582 | 752 return 1; |
753 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
754 // now let's start the DGA thing |
261 | 755 |
12582 | 756 if (!vo_config_count || width != prev_width || height != prev_height) |
757 { | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
758 #ifdef CONFIG_DGA2 |
8067 | 759 |
12582 | 760 if (!XDGAOpenFramebuffer(mDisplay, mScreen)) |
761 { | |
762 mp_msg(MSGT_VO, MSGL_ERR, | |
763 "vo_dga: Framebuffer mapping failed!!!\n"); | |
764 return 1; | |
765 } | |
8067 | 766 |
12582 | 767 dgadevice = XDGASetMode(mDisplay, mScreen, dga_modenum); |
768 XDGASync(mDisplay, mScreen); | |
221
3daeae4a4aa6
Added support to vo_dga to change the video mode to the lowest resolution
mgraffam
parents:
31
diff
changeset
|
769 |
12582 | 770 vo_dga_base = dgadevice->data; |
771 XFree(dgadevice); | |
261 | 772 |
12582 | 773 XDGASetViewport(mDisplay, mScreen, 0, 0, XDGAFlipRetrace); |
774 | |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
775 #else |
8067 | 776 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
777 #ifdef CONFIG_XF86VM |
12582 | 778 if (have_vm) |
779 { | |
780 XF86VidModeLockModeSwitch(mDisplay, mScreen, 0); | |
781 // Two calls are needed to switch modes on my ATI Rage 128. Why? | |
782 // for riva128 one call is enough! | |
783 XF86VidModeSwitchToMode(mDisplay, mScreen, | |
784 vo_dga_vidmodes[dga_modenum]); | |
785 XF86VidModeSwitchToMode(mDisplay, mScreen, | |
786 vo_dga_vidmodes[dga_modenum]); | |
787 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
788 #endif |
12582 | 789 |
790 XF86DGAGetViewPortSize(mDisplay, mScreen, | |
791 &vo_dga_vp_width, &vo_dga_vp_height); | |
13 | 792 |
12582 | 793 XF86DGAGetVideo(mDisplay, mScreen, |
794 (char **) &vo_dga_base, &vo_dga_width, &bank, | |
795 &ram); | |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
796 |
12582 | 797 XF86DGADirectVideo(mDisplay, mScreen, |
798 XF86DGADirectGraphics | XF86DGADirectMouse | | |
799 XF86DGADirectKeyb); | |
800 | |
801 XF86DGASetViewPort(mDisplay, mScreen, 0, 0); | |
261 | 802 |
233
f62ccacbe1e5
Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents:
221
diff
changeset
|
803 #endif |
12582 | 804 } |
805 // do some more checkings here ... | |
261 | 806 |
12582 | 807 mp_msg(MSGT_VO, MSGL_V, |
17366 | 808 "vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %p, bpp: %d\n", |
12582 | 809 vo_dga_width, vo_dga_vp_width, vo_dga_vp_height, |
810 HW_MODE.vdm_bytespp, vo_dga_base, HW_MODE.vdm_bitspp); | |
811 | |
812 x_off = (vo_dga_vp_width - vo_dga_src_width) >> 1; | |
813 y_off = (vo_dga_vp_height - vo_dga_src_height) >> 1; | |
13 | 814 |
12582 | 815 vo_dga_bytes_per_line = vo_dga_src_width * HW_MODE.vdm_bytespp; |
816 vo_dga_lines = vo_dga_src_height; | |
13 | 817 |
12582 | 818 vo_dga_src_offset = 0; |
819 vo_dga_vp_offset = | |
820 (y_off * vo_dga_width + x_off) * HW_MODE.vdm_bytespp; | |
13 | 821 |
12582 | 822 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * HW_MODE.vdm_bytespp; // todo |
823 | |
824 mp_msg(MSGT_VO, MSGL_V, "vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n", | |
825 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line); | |
826 | |
13 | 827 |
12582 | 828 XGrabKeyboard(mDisplay, DefaultRootWindow(mDisplay), True, |
829 GrabModeAsync, GrabModeAsync, CurrentTime); | |
830 if (vo_grabpointer) | |
831 XGrabPointer(mDisplay, DefaultRootWindow(mDisplay), True, | |
832 ButtonPressMask, GrabModeAsync, GrabModeAsync, | |
833 None, None, CurrentTime); | |
262 | 834 |
12582 | 835 if (!vo_config_count || width != prev_width || height != prev_height) |
836 { | |
837 init_video_buffers(vo_dga_base, | |
838 vo_dga_vp_height, | |
839 vo_dga_width * HW_MODE.vdm_bytespp, | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
840 #ifdef CONFIG_DGA2 |
12582 | 841 modeline->maxViewportY, |
7515 | 842 #else |
12582 | 843 vo_dga_vp_height, |
7515 | 844 #endif |
12582 | 845 vo_doublebuffering); |
846 prev_width = width; | |
847 prev_height = height; | |
848 } | |
263
78e8925fd6b4
- added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents:
262
diff
changeset
|
849 |
12582 | 850 mp_msg(MSGT_VO, MSGL_V, "vo_dga: Using %d frame buffer%s.\n", |
851 vo_dga_nr_video_buffers, | |
852 vo_dga_nr_video_buffers == 1 ? "" : "s"); | |
853 | |
854 vo_dga_is_running = 1; | |
855 return 0; | |
13 | 856 } |
857 | |
7930 | 858 static int dga_depths_init = 0; |
859 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
860 static int preinit(const char *arg) |
4352 | 861 { |
12582 | 862 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
|
863 { |
12582 | 864 mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Unknown subdevice: %s\n", arg); |
865 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
|
866 } |
7930 | 867 |
12582 | 868 if (!vo_init()) |
869 return -1; // Can't open X11 | |
7930 | 870 |
12582 | 871 if (dga_depths_init == 0) |
872 { // FIXME!? | |
873 int i; | |
7930 | 874 |
12582 | 875 vo_dga_XServer_mode = vd_ValidateMode(vo_depthonscreen); |
7930 | 876 |
12582 | 877 if (vo_dga_XServer_mode == 0) |
878 { | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
879 #ifndef CONFIG_DGA2 |
12582 | 880 mp_msg(MSGT_VO, MSGL_ERR, |
881 "vo_dga: Your X-Server is not running in a "); | |
882 mp_msg(MSGT_VO, MSGL_ERR, | |
883 "resolution supported by DGA driver!\n"); | |
884 #endif | |
885 } //else{ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
886 // mp_msg(MSGT_VO, MSGL_V, "vo_dga: X running at: %s\n", |
12582 | 887 // vd_GetModeString(vo_dga_XServer_mode)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27377
diff
changeset
|
888 //} |
12582 | 889 |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
26755
diff
changeset
|
890 #ifdef CONFIG_DGA2 |
12582 | 891 vo_modelines = XDGAQueryModes(mDisplay, mScreen, &vo_modecount); |
892 if (vo_modelines) | |
893 { | |
894 for (i = 0; i < vo_modecount; i++) | |
895 { | |
896 mp_msg(MSGT_VO, MSGL_V, | |
17366 | 897 "vo_dga: (%03d) depth=%d, bpp=%d, r=%08lx, g=%08lx, b=%08lx, %d x %d\n", |
12582 | 898 i, vo_modelines[i].depth, |
899 vo_modelines[i].bitsPerPixel, | |
900 vo_modelines[i].redMask, vo_modelines[i].greenMask, | |
901 vo_modelines[i].blueMask, | |
902 vo_modelines[i].viewportWidth, | |
903 vo_modelines[i].viewportHeight); | |
904 vd_EnableMode(vo_modelines[i].depth, | |
905 vo_modelines[i].bitsPerPixel, | |
906 vo_modelines[i].redMask, | |
907 vo_modelines[i].greenMask, | |
908 vo_modelines[i].blueMask); | |
909 } | |
910 } | |
7930 | 911 #endif |
12582 | 912 dga_depths_init = 1; |
7930 | 913 |
12582 | 914 if (!vo_dga_modes[1].vdm_supported |
915 && vo_dga_modes[2].vdm_supported) | |
916 { | |
917 vo_dga_modes[1].vdm_supported = 1; | |
918 } | |
7930 | 919 |
12582 | 920 if (!vo_dga_modes[3].vdm_supported |
921 && vo_dga_modes[4].vdm_supported) | |
922 { | |
923 vo_dga_modes[3].vdm_supported = 1; | |
924 } | |
7930 | 925 |
12582 | 926 for (i = 1; i < vo_dga_mode_num; i++) |
927 { | |
928 mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Mode: %s", | |
929 vd_GetModeString(i)); | |
930 if (vo_dbpp && vo_dbpp != vo_dga_modes[i].vdm_mplayer_depth) | |
931 { | |
932 vo_dga_modes[i].vdm_supported = 0; | |
933 mp_msg(MSGT_VO, MSGL_INFO, " ...disabled by -bpp %d", | |
934 vo_dbpp); | |
935 } | |
936 mp_msg(MSGT_VO, MSGL_INFO, "\n"); | |
937 } | |
938 } | |
7930 | 939 |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4713
diff
changeset
|
940 return 0; |
4352 | 941 } |
942 | |
12582 | 943 static uint32_t get_image(mp_image_t * mpi) |
8084 | 944 { |
12582 | 945 if (!IMGFMT_IS_BGR(mpi->imgfmt) || |
946 (IMGFMT_BGR_DEPTH(mpi->imgfmt) != | |
947 vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth) | |
948 || (mpi->type == MP_IMGTYPE_STATIC && vo_dga_nr_video_buffers > 1) | |
949 || (mpi->type == MP_IMGTYPE_IP && vo_dga_nr_video_buffers < 2) | |
950 || (mpi->type == MP_IMGTYPE_IPB)) | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26400
diff
changeset
|
951 return VO_FALSE; |
12582 | 952 |
953 if ((mpi->flags & MP_IMGFLAG_ACCEPT_STRIDE) || | |
954 (mpi->flags & MP_IMGFLAG_ACCEPT_WIDTH && | |
955 ((vo_dga_bytes_per_line + vo_dga_vp_skip) % (mpi->bpp / 8)) == 0) | |
956 || (mpi->width * (mpi->bpp / 8) == | |
957 (vo_dga_bytes_per_line + vo_dga_vp_skip))) | |
958 { | |
959 | |
960 mpi->planes[0] = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset; | |
961 mpi->stride[0] = vo_dga_bytes_per_line + vo_dga_vp_skip; | |
962 mpi->width = | |
963 (vo_dga_bytes_per_line + vo_dga_vp_skip) / (mpi->bpp / 8); | |
964 mpi->flags |= MP_IMGFLAG_DIRECT; | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26400
diff
changeset
|
965 return VO_TRUE; |
8084 | 966 } |
967 | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26400
diff
changeset
|
968 return VO_FALSE; |
8084 | 969 } |
970 | |
33305
ddb45e9443ec
Remove the variable arguments from the libvo control() functions.
iive
parents:
32467
diff
changeset
|
971 static int control(uint32_t request, void *data) |
4352 | 972 { |
12582 | 973 switch (request) |
974 { | |
975 case VOCTRL_GET_IMAGE: | |
976 return get_image(data); | |
977 case VOCTRL_QUERY_FORMAT: | |
978 return query_format(*((uint32_t *) data)); | |
979 } | |
980 return VO_NOTIMPL; | |
4352 | 981 } |
982 | |
260
1742ea658d0b
Source cleanup. Improved resolution selection (I think :-)).
acki2
parents:
233
diff
changeset
|
983 //--------------------------------------------------------- |