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