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