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