annotate libvo/vo_dga.c @ 1110:71b8911ec3da

-Wall like cleanup
author al3x
date Tue, 12 Jun 2001 14:09:25 +0000
parents 83919c1b9924
children 8682a16321db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1 #define DISP
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
2
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
3 /*
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
4 * $Id$
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
5 *
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
6 * video_out_dga.c, X11 interface
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
7 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
8 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
9 * Copyright ( C ) 2001, Andreas Ackermann. All Rights Reserved.
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
10 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
11 * <acki@acki-netz.de>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
12 *
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
13 * Sourceforge username: acki2
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
14 *
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
15 * note well:
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
16 *
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
17 * - covers only common video card formats i.e.
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
18 * BGR_16_15_555
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
19 * BGR_16_16_565
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
20 * BGR_24_24_888
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
21 * BGR_32_24_888
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
22 *
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
23 * - works only on x86 architectures
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
24 *
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
25 * $Log$
865
83919c1b9924 removed redundant osd.h includes
arpi_esp
parents: 720
diff changeset
26 * Revision 1.23 2001/05/24 20:48:45 arpi_esp
83919c1b9924 removed redundant osd.h includes
arpi_esp
parents: 720
diff changeset
27 * removed redundant osd.h includes
83919c1b9924 removed redundant osd.h includes
arpi_esp
parents: 720
diff changeset
28 *
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
29 * Revision 1.22 2001/05/07 19:16:04 acki2
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
30 * - now chooses mode with highest ymax (enables doublebuffering in some cases
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
31 * it didn't work before)
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
32 * - use my own memcopy() on non MMX machines again
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
33 * - do memcpy() in one single block if stride==0
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
34 *
691
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
35 * Revision 1.21 2001/05/03 22:39:38 acki2
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
36 * - finally: 15to16 conversion included!!!
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
37 *
690
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
38 * Revision 1.20 2001/05/02 23:21:27 acki2
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
39 * - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
40 *
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
41 * Revision 1.19 2001/05/01 22:37:37 acki2
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
42 * - now features 24->32 conversion (this is actually faster than letting the
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
43 * codec produce depth 32 in the first place for avis :-))) )
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
44 *
677
ee2dac2cc633 - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents: 616
diff changeset
45 * Revision 1.18 2001/05/01 20:24:31 acki2
ee2dac2cc633 - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents: 616
diff changeset
46 * - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
ee2dac2cc633 - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents: 616
diff changeset
47 *
616
41d6eec69b60 clean up
pontscho
parents: 612
diff changeset
48 * Revision 1.17 2001/04/24 11:42:04 pontscho
41d6eec69b60 clean up
pontscho
parents: 612
diff changeset
49 * clean up
41d6eec69b60 clean up
pontscho
parents: 612
diff changeset
50 *
612
77e0094f0cce some warnings killed
szabii
parents: 533
diff changeset
51 * Revision 1.16 2001/04/24 10:21:12 szabii
77e0094f0cce some warnings killed
szabii
parents: 533
diff changeset
52 * some warnings killed
77e0094f0cce some warnings killed
szabii
parents: 533
diff changeset
53 *
533
ca59ef4ce54d driver info now depends on detected DGA version
arpi_esp
parents: 493
diff changeset
54 * Revision 1.15 2001/04/19 21:39:10 arpi_esp
ca59ef4ce54d driver info now depends on detected DGA version
arpi_esp
parents: 493
diff changeset
55 * driver info now depends on detected DGA version
ca59ef4ce54d driver info now depends on detected DGA version
arpi_esp
parents: 493
diff changeset
56 *
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
57 * Revision 1.14 2001/04/17 22:28:09 acki2
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
58 * - now also supports OSD for YV12 (big speed penalty by having to build image
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
59 * in offscreen memory and then copying;
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
60 * - OSD still works just with doublebuffering enabled :-(
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
61 *
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
62 * Revision 1.13 2001/04/17 20:51:58 acki2
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
63 * - query_format() now uses new return value concept
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
64 * - now support for OSD :-))) for RGB modes
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
65 * YV12 is flickering in quite an ugly fashion; have to fix this, but
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
66 * will cost an extra copying of image data ... :-(((
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
67 *
395
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
68 * Revision 1.12 2001/04/13 22:11:08 acki2
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
69 * - fixed bug with depth and mpg when current bpp of XServer was != 32
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
70 * - when -bpp is selected, I accept only query_modes() for THIS particular depth
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
71 * (if it's supported by hardware)
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
72 *
272
8ffe2f459851 - still more debug output to be able to fix 15/16 bpp problem
acki2
parents: 266
diff changeset
73 * Revision 1.10 2001/04/01 22:01:28 acki2
8ffe2f459851 - still more debug output to be able to fix 15/16 bpp problem
acki2
parents: 266
diff changeset
74 * - still more debug output to be able to fix 15/16 bpp problem
8ffe2f459851 - still more debug output to be able to fix 15/16 bpp problem
acki2
parents: 266
diff changeset
75 *
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
76 * Revision 1.9 2001/04/01 08:07:14 acki2
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
77 * - added detection of memsize of graphics card to check if double buffering is possible
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
78 * - fixed resolution switching a little and added more debug output
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
79 * - resolution switching is still according to d_width and d_height which
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
80 * is not always a good idea ...
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
81 *
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
82 *
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
83 * 30/02/2001
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
84 *
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
85 * o query_format(): with DGA 2.0 it returns all depths it supports
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
86 * (even 16 when running 32 and vice versa)
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
87 * Checks for (hopefully!) compatible RGBmasks in 15/16 bit modes
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
88 * o added some more criterions for resolution switching
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
89 * o cleanup
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
90 * o with DGA2.0 present, ONLY DGA2.0 functions are used
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
91 * o for 15/16 modes ONLY RGB 555 is supported, since the divx-codec
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
92 * happens to map the data this way. If your graphics card supports
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
93 * this, you're well off and may use these modes; for mpeg
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
94 * movies things could be different, but I was too lazy to implement
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
95 * it ...
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
96 * o you may define VO_DGA_FORCE_DEPTH to the depth you desire
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
97 * if you don't like the choice the driver makes
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
98 * Beware: unless you can use DGA2.0 this has to be your X Servers
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
99 * depth!!!
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
100 * o Added double buffering :-))
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
101 * o included VidMode switching support for DGA1.0, written by Michael Graffam
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
102 * mgraffam@idsi.net
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
103 *
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
104 */
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
105
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
106 //#define VO_DGA_DBG 1
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
107 //#undef HAVE_DGA2
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
108 //#undef HAVE_XF86VM
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
109
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
110 #include <stdio.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
111 #include <stdlib.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
112 #include <string.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
113
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
114 #include "config.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
115 #include "video_out.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
116 #include "video_out_internal.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
117 #include "yuv2rgb.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
118
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
119 LIBVO_EXTERN( dga )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
120
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
121 #include <X11/Xlib.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
122 #include <X11/extensions/xf86dga.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
123
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
124 #ifdef HAVE_XF86VM
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
125 #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
126 #endif
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
127
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
128
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
129 #include "x11_common.h"
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
130
690
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
131 #include "fastmemcpy.h"
691
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
132
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
133 extern void rgb15to16_mmx(char* s0,char* d0,int count);
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
134
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
135 static vo_info_t vo_info =
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
136 {
533
ca59ef4ce54d driver info now depends on detected DGA version
arpi_esp
parents: 493
diff changeset
137 #ifdef HAVE_DGA2
ca59ef4ce54d driver info now depends on detected DGA version
arpi_esp
parents: 493
diff changeset
138 "DGA ( Direct Graphic Access V2.0 )",
ca59ef4ce54d driver info now depends on detected DGA version
arpi_esp
parents: 493
diff changeset
139 #else
ca59ef4ce54d driver info now depends on detected DGA version
arpi_esp
parents: 493
diff changeset
140 "DGA ( Direct Graphic Access V1.0+XF86VidModeExtension )",
ca59ef4ce54d driver info now depends on detected DGA version
arpi_esp
parents: 493
diff changeset
141 #endif
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
142 "dga",
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
143 "Andreas Ackermann <acki@acki-netz.de>",
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
144 ""
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
145 };
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
146
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
147
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
148 //------------------------------------------------------------------
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
149
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
150
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
151 //#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
152 //#define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp)
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
153
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
154 #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
155 #define SRC_MODE (vo_dga_modes[vo_dga_src_mode])
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
156
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
157 struct vd_modes {
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
158 int vdm_mplayer_depth;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
159 int vdm_supported;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
160 int vdm_depth;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
161 int vdm_bitspp;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
162 int vdm_bytespp;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
163 int vdm_rmask;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
164 int vdm_gmask;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
165 int vdm_bmask;
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
166 int vdm_hw_mode;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
167 int vdm_conversion_func;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
168 };
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
169
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
170 //------------------------------------------------------------------
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
171
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
172 #define VDM_CONV_NATIVE 0
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
173 #define VDM_CONV_15TO16 1
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
174 #define VDM_CONV_24TO32 2
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
175
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
176 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
177 // these entries describe HW modes
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
178 // 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
179 // 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
180 // 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
181
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
182 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
183 { 15, 0, 15, 16, 2, 0x7c00, 0x03e0, 0x001f, 2, VDM_CONV_15TO16 },
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
184 { 16, 0, 16, 16, 2, 0xf800, 0x07e0, 0x001f, 2, VDM_CONV_NATIVE },
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
185 { 24, 0, 24, 24, 3, 0xff0000, 0x00ff00, 0x0000ff, 4, VDM_CONV_24TO32},
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
186 { 32, 0, 24, 32, 4, 0x00ff0000, 0x0000ff00, 0x000000ff, 4, VDM_CONV_NATIVE}
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
187 };
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
188
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
189 static int vo_dga_mode_num = sizeof(vo_dga_modes)/sizeof(struct vd_modes);
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
190
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
191 // enable a HW mode (by description)
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
192 int vd_EnableMode( int depth, int bitspp,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
193 int rmask, int gmask, int bmask){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
194 int i;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
195 for(i=1; i<vo_dga_mode_num; i++){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
196 if(vo_dga_modes[i].vdm_depth == depth &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
197 vo_dga_modes[i].vdm_bitspp == bitspp &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
198 vo_dga_modes[i].vdm_rmask == rmask &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
199 vo_dga_modes[i].vdm_gmask == gmask &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
200 vo_dga_modes[i].vdm_bmask == bmask){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
201 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
202 vo_dga_modes[i].vdm_hw_mode = i;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
203 vo_dga_modes[i].vdm_conversion_func = VDM_CONV_NATIVE;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
204 return i;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
205 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
206 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
207 return 0;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
208 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
209
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
210 int vd_ModeEqual(int depth, int bitspp,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
211 int rmask, int gmask, int bmask, int index){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
212 return (
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
213 (vo_dga_modes[index].vdm_depth == depth &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
214 vo_dga_modes[index].vdm_bitspp == bitspp &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
215 vo_dga_modes[index].vdm_rmask == rmask &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
216 vo_dga_modes[index].vdm_gmask == gmask &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
217 vo_dga_modes[index].vdm_bmask == bmask)
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
218 ? 1 : 0);
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
219 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
220
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
221
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
222 // enable a HW mode (mplayer_depth decides which)
395
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
223 int vd_ValidateMode( int mplayer_depth){
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
224 int i;
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
225 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
226 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
227 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
228 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
229 vo_dga_modes[i].vdm_hw_mode = i;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
230 vo_dga_modes[i].vdm_conversion_func = VDM_CONV_NATIVE;
395
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
231 return i;
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
232 }
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
233 }
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
234 return 0;
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
235 }
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
236
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
237 // do we support this mode? (not important whether native or conversion)
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
238 int vd_ModeValid( int mplayer_depth){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
239 int i;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
240 if(mplayer_depth == 0)return 0;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
241 for(i=1; i<vo_dga_mode_num; i++){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
242 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth &&
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
243 vo_dga_modes[i].vdm_supported != 0){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
244 return i;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
245 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
246 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
247 return 0;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
248 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
249
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
250 char *vd_GetModeString(int index){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
251
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
252 #define VO_DGA_MAX_STRING_LEN 100
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
253 static char stringbuf[VO_DGA_MAX_STRING_LEN];
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
254 stringbuf[VO_DGA_MAX_STRING_LEN-1]=0;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
255 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
256 "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)",
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
257 vo_dga_modes[index].vdm_depth,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
258 vo_dga_modes[index].vdm_bitspp,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
259 vo_dga_modes[index].vdm_rmask,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
260 vo_dga_modes[index].vdm_gmask,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
261 vo_dga_modes[index].vdm_bmask,
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
262 vo_dga_modes[index].vdm_supported ?
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
263 (vo_dga_modes[index].vdm_conversion_func == VDM_CONV_NATIVE ?
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
264 "native (fast), " : "conversion (slow),") :
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
265 "not supported :-( ",
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
266 vo_dga_modes[index].vdm_mplayer_depth);
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
267 return stringbuf;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
268 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
269
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
270 //-----------------------------------------------------------------
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
271
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
272 #ifdef HAVE_XF86VM
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
273 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
274 #endif
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
275
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
276
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
277 extern int verbose;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
278 extern int vo_dbpp;
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
279
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
280 static int vo_dga_src_format;
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
281 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
282 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
283 // framebuffer
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
284 static int vo_dga_vp_height; // visible lines in framebuffer
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
285 static int vo_dga_is_running = 0;
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
286 static int vo_dga_src_width; // width of video in pixels
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
287 static int vo_dga_src_height; // height of video in pixels
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
288 static int vo_dga_src_offset=0; // offset in src
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
289 static int vo_dga_vp_offset=0; // offset in dest
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
290 static int vo_dga_bytes_per_line; // bytes per line to copy
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
291 static int vo_dga_src_skip; // bytes to skip after copying one
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
292 // line
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
293 // (not supported yet) in src
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
294 static int vo_dga_vp_skip; // dto. for dest
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
295 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
296 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
297 // used by framebuffer
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
298 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
299 // codec
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
300 static int vo_dga_XServer_mode = 0;// index in mode list for resolution
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
301 // XServer is running
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
302
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
303 static int vo_dga_dbf_mem_offset; // offset in bytes for alternative
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
304 // framebuffer (0 if dbf is not
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
305 // possible)
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
306 static int vo_dga_dbf_y_offset; // y offset (in scanlines)
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
307 static int
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
308 vo_dga_dbf_current; // current buffer (0 or 1)
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
309
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
310 static unsigned char *vo_dga_base;
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
311 static Display *vo_dga_dpy;
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
312
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
313 //---------------------------------------------------------
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
314
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
315 #define VD_INFO 0
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
316 #define VD_ERR 0
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
317 #define VD_DBG 2
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
318 #define VD_RES 1
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
319
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
320 void vd_printf( int level, const char *str, ...){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
321
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
322 #ifndef VO_DGA_DBG
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
323 // show resolution and DBG-messages only in verbose mode ...
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
324 if( !verbose && level)return;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
325 #endif
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
326 vprintf( str, (&str)+1 );
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
327 }
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
328
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
329 //---------------------------------------------------------
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
330
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
331 static void draw_alpha( int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride ){
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
332
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
333 char *d;
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
334 unsigned int offset;
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
335 unsigned int buffer_stride;
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
336
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
337 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
338 buffer_stride = vo_dga_width;
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
339 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]);
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
340
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
341 switch( HW_MODE.vdm_mplayer_depth ){
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
342
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
343 case 32:
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
344 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
345 break;
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
346 case 24:
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
347 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
348 break;
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
349 case 15:
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
350 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
351 break;
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
352 case 16:
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
353 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
354 break;
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
355 }
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
356 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
357
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
358
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
359 //---------------------------------------------------------
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
360
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
361
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
362
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
363 // I had tried to work with mmx/3dnow copy code but
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
364 // there was not much speed gain and I didn't know
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
365 // how to save the FPU/mmx registers - so the copy
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
366 // code interferred with sound output ...
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
367 // removed the leftovers
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
368 // acki2 on 30/3/2001
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
369
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
370
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
371 #define rep_movsl(dest, src, numwords, d_add, count) \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
372 __asm__ __volatile__( \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
373 " \
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
374 1: \n\t\
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
375 movl %%edx, %%ecx \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
376 cld\n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
377 rep\n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
378 movsl \n\t\
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
379 add %%eax, %%edi \n\t\
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
380 dec %%ebx \n\t\
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
381 jnz 1b \n\t\
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
382 " \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
383 : \
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
384 : "a" (d_add), "b" (count), "S" (src), "D" (dest), \
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
385 "d" (numwords) \
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
386 : "memory" )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
387
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
388 // quick & dirty - for debugging only
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
389
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
390 void fillblock(char *strt, int yoff, int lines, int val){
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
391 char *i;
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
392 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
393 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
394 *i++ = val;
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
395 }
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
396 }
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
397
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
398
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
399 //---------------------------------------------------------
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
400
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
401 static uint32_t draw_frame( uint8_t *src[] ){
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
402
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
403 int vp_skip = vo_dga_vp_skip;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
404 int lpl = vo_dga_bytes_per_line >> 2;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
405 int numlines = vo_dga_lines;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
406
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
407 char *s, *d;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
408
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
409 s = *src;
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
410 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]);
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
411
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
412 switch(SRC_MODE.vdm_conversion_func){
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
413 case VDM_CONV_NATIVE:
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
414
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
415 #ifdef HAVE_MMX
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
416 // use the code from fastmemcpy.h
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
417 if(vo_dga_vp_skip){
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
418 // use some stride ...
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
419 int i;
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
420 for(i=0; i< vo_dga_lines; i++){
690
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
421 memcpy(d, s, vo_dga_bytes_per_line);
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
422 d+=vo_dga_vp_skip;
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
423 d+=vo_dga_bytes_per_line;
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
424 s+=vo_dga_bytes_per_line;
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
425 }
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
426 }else{
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
427 // no stride, cool + fast ...
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
428 memcpy(d,s, vo_dga_bytes_per_line * vo_dga_lines);
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
429 }
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
430 #else
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
431 // use some homebrewn assembly code ...
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
432 rep_movsl(d, s, lpl, vo_dga_vp_skip, numlines );
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
433 #endif
690
2094b195a9bc - now we use fastmemcpy() for copying. Saves about 25% of copying time on K6-2+
acki2
parents: 680
diff changeset
434
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
435 // DBG-COde
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
436
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
437 #if 0
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
438 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]);
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
439 fillblock(d, 0, 10, 0x800000ff);
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
440 fillblock(d, 10, 10, 0x8000ff00);
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
441 fillblock(d, 20, 10, 0x80ff0000);
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
442 fillblock(d, 30, 10, 0xff0000ff);
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
443 fillblock(d, 40, 10, 0x800000ff);
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
444 fillblock(d, 50, 10, 0x0f0000ff);
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
445 #endif
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
446 break;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
447 case VDM_CONV_15TO16:
691
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
448 {
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
449 int i;
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
450 char *e;
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
451 for(i=0; i< vo_dga_lines; i++){
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
452 #ifdef HAVE_MMX
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
453 rgb15to16_mmx( s, d, vo_dga_bytes_per_line);
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
454 d+=vo_dga_bytes_per_line;
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
455 s+=vo_dga_bytes_per_line;
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
456 #else
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
457 e = s+vo_dga_bytes_per_line;
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
458 while( s< e ){
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
459 register uint16_t x = *(((uint16_t *)s)++);
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
460 *(((uint16_t *)d)++)=( x&0x001F )|( ( x&0x7FE0 )<<1 );
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
461 }
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
462
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
463 #endif
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
464 d+= vo_dga_vp_skip;
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
465 }
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
466 }
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
467 break;
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
468 case VDM_CONV_24TO32:
691
3693fd4c4ec2 - finally: 15to16 conversion included!!!
acki2
parents: 690
diff changeset
469
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
470 {
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
471 int i,k,l,m;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
472 for(i = 0; i< vo_dga_lines; i++ ){
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
473 for(k = 0; k< vo_dga_src_width; k+=2 ){
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
474 l = *(((uint32_t *)s)++);
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
475 m = (l & 0xff000000)>> 24 ;
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
476 *(((uint32_t *)d)++) = (l & 0x00ffffff); // | 0x80000000;
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
477 m |= *(((uint16_t *)s)++) << 8;
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
478 *(((uint32_t *)d)++) = m; // | 0x80000000 ;
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
479 }
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
480 d+= vp_skip;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
481 }
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
482 }
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
483 //printf("vo_dga: 24 to 32 not implemented yet!!!\n");
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
484 break;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
485 }
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
486 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
487 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
488
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
489 //---------------------------------------------------------
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
490
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
491 static void check_events(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
492 {
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
493 int e=vo_x11_check_events(vo_dga_dpy);
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
494 }
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
495
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
496 //---------------------------------------------------------
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
497
616
41d6eec69b60 clean up
pontscho
parents: 612
diff changeset
498 #include "sub.h"
612
77e0094f0cce some warnings killed
szabii
parents: 533
diff changeset
499
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
500 static void flip_page( void ){
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
501
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
502 vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha);
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
503
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
504 if(vo_dga_dbf_mem_offset != 0){
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
505
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
506 #ifdef HAVE_DGA2
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
507 XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy),
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
508 0, vo_dga_dbf_current * vo_dga_dbf_y_offset,
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
509 XDGAFlipRetrace);
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
510 #else
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
511 XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy),
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
512 0, vo_dga_dbf_current * vo_dga_dbf_y_offset);
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
513 #endif
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
514 vo_dga_dbf_current = 1 - vo_dga_dbf_current;
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
515 }
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
516 check_events();
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
517 }
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
518
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
519 //---------------------------------------------------------
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
520
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
521 static uint32_t draw_slice( uint8_t *src[],int stride[],
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
522 int w,int h,int x,int y )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
523 {
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
524
677
ee2dac2cc633 - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents: 616
diff changeset
525 yuv2rgb( vo_dga_base + vo_dga_dbf_current * vo_dga_dbf_mem_offset + vo_dga_vp_offset +
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
526 (vo_dga_width * y +x) * HW_MODE.vdm_bytespp,
677
ee2dac2cc633 - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents: 616
diff changeset
527 src[0], src[1], src[2],
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
528 w,h, vo_dga_width * HW_MODE.vdm_bytespp,
677
ee2dac2cc633 - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
acki2
parents: 616
diff changeset
529 stride[0],stride[1] );
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
530 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
531 };
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
532
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
533 //---------------------------------------------------------
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
534
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
535
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
536 static void Terminate_Display_Process( void ){
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
537 vd_printf(VD_DBG, "vo_dga: Terminating display process\n");
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
538 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
539
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
540 //---------------------------------------------------------
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
541
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
542 static const vo_info_t* get_info( void )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
543 { return &vo_info; }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
544
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
545 //---------------------------------------------------------
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
546
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
547 static uint32_t query_format( uint32_t format )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
548 {
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
549
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
550 #ifdef HAVE_DGA2
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
551 XDGAMode *modelines;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
552 int modecount;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
553 #endif
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
554 Display *qdisp;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
555
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
556 int i;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
557 static int dga_depths_init = 0;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
558
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
559 if(dga_depths_init == 0){
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
560
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
561 if((qdisp = XOpenDisplay(0))==NULL){
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
562 vd_printf(VD_ERR, "vo_dga: Can't open display!\n");
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
563 return 0;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
564 }
395
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
565 if( !vo_init() ){
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
566 vd_printf(VD_ERR, "vo_dga: vo_init() failed!\n");
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
567 return 1;
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
568 }
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
569 vo_dga_XServer_mode = vd_ValidateMode(vo_depthonscreen);
395
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
570
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
571 if(vo_dga_XServer_mode ==0){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
572 #ifndef HAVE_DGA2
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
573 vd_printf(VD_ERR, "vo_dga: Your X-Server is not running in a ");
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
574 vd_printf(VD_ERR, "resolution supported by DGA driver!\n");
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
575 #endif
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
576 }//else{
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
577 // vd_printf(VD_INFO, "vo_dga: X running at: %s\n",
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
578 // vd_GetModeString(vo_dga_XServer_mode));
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
579 //}
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
580
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
581 #ifdef HAVE_DGA2
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
582 modelines=XDGAQueryModes(qdisp, XDefaultScreen(qdisp),&modecount);
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
583 if(modelines){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
584 for(i=0; i< modecount; i++){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
585 vd_printf(VD_DBG, "vo_dga: (%03d) depth=%d, bpp=%d, r=%08x, g=%08x, b=%08x, %d x %d\n",
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
586 i,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
587 modelines[i].depth,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
588 modelines[i].bitsPerPixel,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
589 modelines[i].redMask,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
590 modelines[i].greenMask,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
591 modelines[i].blueMask,
395
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
592 modelines[i].viewportWidth,
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
593 modelines[i].viewportHeight);
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
594 vd_EnableMode(
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
595 modelines[i].depth,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
596 modelines[i].bitsPerPixel,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
597 modelines[i].redMask,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
598 modelines[i].greenMask,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
599 modelines[i].blueMask);
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
600 }
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
601 XFree(modelines);
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
602
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
603 }
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
604 #endif
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
605 dga_depths_init = 1;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
606 XCloseDisplay(qdisp);
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
607
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
608 if( !vo_dga_modes[1].vdm_supported && vo_dga_modes[2].vdm_supported ){
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
609 vo_dga_modes[1].vdm_supported = 1;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
610 }
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
611
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
612 if( !vo_dga_modes[3].vdm_supported && vo_dga_modes[4].vdm_supported ){
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
613 vo_dga_modes[3].vdm_supported = 1;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
614 }
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
615
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
616 for(i=1; i<vo_dga_mode_num; i++){
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
617 vd_printf(VD_INFO, "vo_dga: Mode: %s", vd_GetModeString(i));
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
618 if(vo_dbpp && vo_dbpp != vo_dga_modes[i].vdm_mplayer_depth){
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
619 vo_dga_modes[i].vdm_supported = 0;
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
620 vd_printf(VD_INFO, " ...disabled by -bpp %d", vo_dbpp );
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
621 }
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
622 vd_printf(VD_INFO, "\n");
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
623 }
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
624 }
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
625
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
626 // TODO: respect bit for native/not native
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
627 if( format==IMGFMT_YV12 ) return 7;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
628
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
629 if( (format&IMGFMT_BGR_MASK) == IMGFMT_BGR &&
490
caf5ddb0d19a - query_format() now uses new return value concept
acki2
parents: 395
diff changeset
630 vd_ModeValid(format&0xff)) return 7;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
631
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
632 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
633 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
634
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
635 //---------------------------------------------------------
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
636
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
637 static void
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
638 uninit(void)
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
639 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
640
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
641 #ifdef HAVE_DGA2
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
642 XDGADevice *dgadevice;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
643 #endif
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
644
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
645 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
646 vo_dga_is_running = 0;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
647 vd_printf( VD_DBG, "vo_dga: in uninit\n");
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
648 XUngrabPointer (vo_dga_dpy, CurrentTime);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
649 XUngrabKeyboard (vo_dga_dpy, CurrentTime);
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
650 #ifdef HAVE_DGA2
395
01768a027e7d - fixed bug with depth and mpg when current bpp of XServer was != 32
acki2
parents: 392
diff changeset
651 XDGACloseFramebuffer(vo_dga_dpy, XDefaultScreen(vo_dga_dpy));
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
652 dgadevice = XDGASetMode(vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
653 if(dgadevice != NULL){
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
654 XFree(dgadevice);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
655 }
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
656 #else
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
657 XF86DGADirectVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
658 // 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
659 #ifdef HAVE_XF86VM
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
660 if (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
661 int screen; screen=XDefaultScreen( vo_dga_dpy );
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
662 vd_printf(VD_DBG, "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
663 // seems some graphics adaptors need this more than once ...
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
664 XF86VidModeSwitchToMode(vo_dga_dpy,screen,vo_dga_vidmodes[0]);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
665 XF86VidModeSwitchToMode(vo_dga_dpy,screen,vo_dga_vidmodes[0]);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
666 XF86VidModeSwitchToMode(vo_dga_dpy,screen,vo_dga_vidmodes[0]);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
667 XF86VidModeSwitchToMode(vo_dga_dpy,screen,vo_dga_vidmodes[0]);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
668 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
669 }
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
670 #endif
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
671 #endif
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
672 XCloseDisplay(vo_dga_dpy);
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
673 }
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
674 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
675
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
676
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
677 //----------------------------------------------------------
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
678 // TODO: check for larger maxy value
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
679 // (useful for double buffering!!!)
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
680
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
681 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
682 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
683 int *old_x, int *old_y, int *old_vbi, int *old_maxy){
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
684
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
685 vd_printf(VD_RES, "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
686 num, new_x, new_y, new_vbi, bpp );
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
687 vd_printf(VD_RES, "(old: %dx%d@%d).", *old_x, *old_y, *old_vbi);
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
688 if (
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
689 (new_x >= x) &&
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
690 (new_y >= y) &&
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
691 (
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
692 // prefer a better resolution either in X or in Y
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
693 // as long as the other dimension is at least the same
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
694 //
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
695 // hmm ... MAYBE it would be more clever to focus on the
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
696 // x-resolution; I had 712x400 and 640x480 and the movie
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
697 // was 640x360; 640x480 would be the 'right thing' here
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
698 // but since 712x400 was queried first I got this one.
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
699 // I think there should be a cmd-line switch to let the
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
700 // user choose the mode he likes ... (acki2)
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
701
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
702 (
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
703 ((new_x < *old_x) &&
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
704 !(new_y > *old_y)) ||
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
705 ((new_y < *old_y) &&
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
706 !(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
707 )
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
708 // but if we get an identical resolution choose
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
709 // the one with the lower refreshrate (saves bandwidth !!!)
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
710 // as long as it's above 50 Hz (acki2 on 30/3/2001)
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
711 ||
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
712 (
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
713 (new_x == *old_x) &&
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
714 (new_y == *old_y) &&
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
715 (
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
716 (
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
717 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
718 )
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
719 ||
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
720 (
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
721 *old_vbi >= 50 &&
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
722 new_vbi < *old_vbi &&
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
723 new_vbi >= 50
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
724 )
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
725 )
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
726 ||
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
727 // 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
728 // stride
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
729 (
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
730 (new_x == *old_x) &&
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
731 (new_y == *old_y) &&
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
732 (new_vbi == *old_vbi) &&
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
733 (new_maxy > *old_maxy)
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
734 )
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
735 )
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
736 )
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
737 )
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
738 {
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
739 *old_x = new_x;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
740 *old_y = new_y;
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
741 *old_maxy = new_maxy;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
742 *old_vbi = new_vbi;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
743 vd_printf(VD_RES, ".ok!!\n");
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
744 return 1;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
745 }else{
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
746 vd_printf(VD_RES, ".no\n");
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
747 return 0;
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
748 }
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
749 }
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
750
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
751
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
752
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
753 //---------------------------------------------------------
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
754
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
755 static uint32_t init( uint32_t width, uint32_t height,
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
756 uint32_t d_width,uint32_t d_height,
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
757 uint32_t fullscreen,char *title,uint32_t format )
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
758 {
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
759
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
760 int x_off, y_off;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
761 int wanted_width, wanted_height;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
762
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
763 #ifdef HAVE_DGA2
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
764 // needed to change DGA video mode
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
765 int modecount, mX=100000, mY=100000 , mVBI=100000, mMaxY=0, i,j=0;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
766 int dga_modenum;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
767 XDGAMode *modelines=NULL;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
768 XDGADevice *dgadevice;
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
769 int max_vpy_pos;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
770 #else
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
771 #ifdef HAVE_XF86VM
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
772 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
773 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
774 int i, j=0, have_vm=0;
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
775 int modecount, mX=100000, mY=100000, 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
776 #endif
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
777 int bank, ram;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
778 #endif
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
779
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
780 if( vo_dga_is_running )return -1;
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
781 vo_dga_src_format = format;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
782 wanted_width = d_width;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
783 wanted_height = d_height;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
784
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
785 if(!wanted_height) wanted_height = height;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
786 if(!wanted_width) wanted_width = width;
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
787
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
788 if( !vo_init() ){
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
789 vd_printf(VD_ERR, "vo_dga: vo_init() failed!\n");
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
790 return 1;
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
791 }
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
792
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
793 if( !vo_dbpp ){
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
794
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
795 if (format == IMGFMT_YV12){
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
796 vo_dga_src_mode = vo_dga_XServer_mode;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
797 }else 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
798 vo_dga_src_mode = vd_ModeValid( format & 0xff );
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
799 }
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
800 }else{
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
801 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
802 }
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
803 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
804
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
805 if( format == IMGFMT_YV12 && vo_dga_src_mode != vo_dga_hw_mode ){
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
806 vd_printf(VD_ERR,
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
807 "vo_dga: YV12 supports native modes only. Using %d instead of selected %d.\n",
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
808 HW_MODE.vdm_mplayer_depth,
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
809 SRC_MODE.vdm_mplayer_depth );
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
810 vo_dga_src_mode = vo_dga_hw_mode;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
811 }
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
812
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
813 if(!vo_dga_src_mode){
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
814 vd_printf(VD_ERR, "vo_dga: unsupported video format!\n");
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
815 return 1;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
816 }
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
817
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
818 if((vo_dga_dpy = XOpenDisplay(0))==NULL){
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
819 vd_printf (VD_ERR, "vo_dga: Can't open display\n");
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
820 return 1;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
821 }
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
822
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
823 vo_dga_vp_width = DisplayWidth( vo_dga_dpy, DefaultScreen(vo_dga_dpy));
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
824 vo_dga_vp_height = DisplayHeight( vo_dga_dpy, DefaultScreen(vo_dga_dpy));
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
825
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
826 vd_printf(VD_DBG, "vo_dga: XServer res: %dx%d\n",
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
827 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
828
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
829 // choose a suitable mode ...
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
830
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
831 #ifdef HAVE_DGA2
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
832 // Code to change the video mode added by Michael Graffam
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
833 // mgraffam@idsi.net
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
834 if (modelines==NULL)
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
835 modelines=XDGAQueryModes(vo_dga_dpy, XDefaultScreen(vo_dga_dpy),&modecount);
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
836
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
837 vd_printf(VD_INFO,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
838 "vo_dga: DGA 2.0 available :-) Can switch resolution AND depth!\n");
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
839 for (i=0; i<modecount; i++)
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
840 {
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
841 if(vd_ModeEqual( modelines[i].depth,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
842 modelines[i].bitsPerPixel,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
843 modelines[i].redMask,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
844 modelines[i].greenMask,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
845 modelines[i].blueMask,
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
846 vo_dga_hw_mode)){
272
8ffe2f459851 - still more debug output to be able to fix 15/16 bpp problem
acki2
parents: 266
diff changeset
847
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
848 vd_printf(VD_DBG, "maxy: %4d, depth: %2d, %4dx%4d, ",
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
849 modelines[i].maxViewportY, modelines[i].depth,
272
8ffe2f459851 - still more debug output to be able to fix 15/16 bpp problem
acki2
parents: 266
diff changeset
850 modelines[i].imageWidth, modelines[i].imageHeight );
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
851 if ( check_res(i, wanted_width, wanted_height, modelines[i].depth,
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
852 modelines[i].viewportWidth,
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
853 modelines[i].viewportHeight,
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
854 (unsigned) modelines[i].verticalRefresh,
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
855 modelines[i].maxViewportY,
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
856 &mX, &mY, &mVBI, &mMaxY )) j = i;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
857 }
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
858 }
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
859 vd_printf(VD_INFO,
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
860 "vo_dga: Selected hardware mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d.\n",
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
861 mX, mY, mVBI,
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
862 HW_MODE.vdm_depth,
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
863 HW_MODE.vdm_bitspp);
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
864 vd_printf(VD_INFO,
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
865 "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
866 width, height,
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
867 SRC_MODE.vdm_depth,
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
868 SRC_MODE.vdm_bitspp);
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
869 vo_dga_vp_width =mX;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
870 vo_dga_vp_height = mY;
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
871 vo_dga_width = modelines[j].bytesPerScanline / HW_MODE.vdm_bytespp ;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
872 dga_modenum = modelines[j].num;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
873 max_vpy_pos = modelines[j].maxViewportY;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
874
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
875 XFree(modelines);
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
876 modelines = NULL;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
877
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
878 #else
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
879
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
880 #ifdef HAVE_XF86VM
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
881
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
882 vd_printf( VD_INFO,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
883 "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
884
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
885 if (XF86VidModeQueryExtension(vo_dga_dpy, &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
886 XF86VidModeQueryVersion(vo_dga_dpy, &vm_ver, &vm_rev);
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
887 vd_printf(VD_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
888 have_vm=1;
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
889 } else {
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
890 vd_printf(VD_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
891 }
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
892
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
893 #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
894
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
895 if (have_vm) {
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
896 int screen;
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
897 screen=XDefaultScreen(vo_dga_dpy);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
898 XF86VidModeGetAllModeLines(vo_dga_dpy,screen,&modecount,&vo_dga_vidmodes);
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
899
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
900 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
901 for (i=0; i<modecount; i++){
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
902 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
903 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
904 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
905 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
906 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
907 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
908 vo_dga_vidmodes[i]->vtotal),
720
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
909 0,
8146b106816a - now chooses mode with highest ymax (enables doublebuffering in some cases
acki2
parents: 691
diff changeset
910 &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
911 }
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
912
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
913 vd_printf(VD_INFO,
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
914 "vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n",
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
915 mX, mY, mVBI,
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
916 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
917 vo_dga_modes[vo_dga_hw_mode].vdm_bitspp,
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
918 width, height);
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
919 }else{
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
920 vd_printf(VD_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
921 }
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
922 dga_modenum = j;
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
923 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
924 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
925 }
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
926
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
927
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
928 #else
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
929 vd_printf( VD_INFO, "vo_dga: Only have DGA 1.0 extension and no XF86VidMode :-(\n");
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
930 vd_printf( VD_INFO, " Thus, resolution switching is NOT possible.\n");
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
931
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
932 #endif
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
933 #endif
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
934
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
935 vo_dga_src_width = width;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
936 vo_dga_src_height = height;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
937
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
938 if(vo_dga_src_width > vo_dga_vp_width ||
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
939 vo_dga_src_height > vo_dga_vp_height)
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
940 {
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
941 vd_printf( VD_ERR, "vo_dga: Sorry, video larger than viewport is not yet supported!\n");
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
942 // 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
943 #ifndef HAVE_DGA2
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
944 #ifdef HAVE_XF86VM
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
945 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
946 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
947 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
948 }
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
949 #endif
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
950 #endif
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
951 return 1;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
952 }
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
953
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
954 // now lets start the DGA thing
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
955
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
956 #ifdef HAVE_DGA2
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
957
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
958 if (!XDGAOpenFramebuffer(vo_dga_dpy, XDefaultScreen(vo_dga_dpy))){
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
959 vd_printf(VD_ERR, "vo_dga: Framebuffer mapping failed!!!\n");
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
960 XCloseDisplay(vo_dga_dpy);
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
961 return 1;
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
962 }
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
963 dgadevice=XDGASetMode(vo_dga_dpy, XDefaultScreen(vo_dga_dpy), dga_modenum);
221
3daeae4a4aa6 Added support to vo_dga to change the video mode to the lowest resolution
mgraffam
parents: 31
diff changeset
964 XDGASync(vo_dga_dpy, XDefaultScreen(vo_dga_dpy));
3daeae4a4aa6 Added support to vo_dga to change the video mode to the lowest resolution
mgraffam
parents: 31
diff changeset
965
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
966 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
967 XFree(dgadevice);
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
968
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
969 XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0, XDGAFlipRetrace);
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
970
233
f62ccacbe1e5 Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents: 221
diff changeset
971 #else
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
972
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
973 #ifdef HAVE_XF86VM
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
974 XF86VidModeLockModeSwitch(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),0);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
975 // 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
976 // for riva128 one call is enough!
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
977 XF86VidModeSwitchToMode(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),vo_dga_vidmodes[dga_modenum]);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
978 XF86VidModeSwitchToMode(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),vo_dga_vidmodes[dga_modenum]);
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
979 #endif
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
980
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
981 XF86DGAGetViewPortSize(vo_dga_dpy,XDefaultScreen(vo_dga_dpy),
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
982 &vo_dga_vp_width,
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
983 &vo_dga_vp_height);
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
984
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
985 XF86DGAGetVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy),
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
986 (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
987
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
988 XF86DGADirectVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy),
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
989 XF86DGADirectGraphics | XF86DGADirectMouse |
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
990 XF86DGADirectKeyb);
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
991
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
992 XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0);
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
993
233
f62ccacbe1e5 Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents: 221
diff changeset
994 #endif
f62ccacbe1e5 Changes to configure to autodetect DGA 2.0 functionality, and to only use
mgraffam
parents: 221
diff changeset
995
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
996 // do some more checkings here ...
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
997
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
998 if( format==IMGFMT_YV12 ){
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
999 yuv2rgb_init( vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth , MODE_RGB );
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1000 vd_printf( VD_DBG, "vo_dga: Using mplayer depth %d for YV12\n",
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
1001 vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth);
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1002 }
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1003
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1004 vd_printf(VD_DBG, "vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %08x, bpp: %d\n",
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1005 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
1006 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
1007 HW_MODE.vdm_bitspp);
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1008
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1009 x_off = (vo_dga_vp_width - vo_dga_src_width)>>1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1010 y_off = (vo_dga_vp_height - vo_dga_src_height)>>1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1011
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
1012 vo_dga_bytes_per_line = vo_dga_src_width * HW_MODE.vdm_bytespp;
261
3b7e4bf7c7ed - 32/16 bit mode swtiching with DGA2.0
acki2
parents: 260
diff changeset
1013 vo_dga_lines = vo_dga_src_height;
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1014
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1015 vo_dga_src_offset = 0;
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
1016 vo_dga_vp_offset = (y_off * vo_dga_width + x_off ) * HW_MODE.vdm_bytespp;
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1017
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
1018 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * HW_MODE.vdm_bytespp; // todo
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1019
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1020 vd_printf(VD_DBG, "vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n",
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1021 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1022
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1023
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1024 XGrabKeyboard (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1025 GrabModeAsync,GrabModeAsync, CurrentTime);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1026 XGrabPointer (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1027 ButtonPressMask,GrabModeAsync, GrabModeAsync,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1028 None, None, CurrentTime);
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1029 // TODO: chekc if mem of graphics adaptor is large enough for dbf
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1030
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1031 // set up variables for double buffering ...
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
1032 // note: set vo_dga_dbf_mem_offset to NULL to disable doublebuffering
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1033
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1034 vo_dga_dbf_y_offset = y_off + vo_dga_src_height;
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
1035 vo_dga_dbf_mem_offset = vo_dga_width * HW_MODE.vdm_bytespp * vo_dga_dbf_y_offset;
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1036 vo_dga_dbf_current = 0;
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1037
493
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
1038 // if(format ==IMGFMT_YV12 )
b8f1ed2b411b - now also supports OSD for YV12 (big speed penalty by having to build image
acki2
parents: 490
diff changeset
1039 //vo_dga_dbf_mem_offset = 0;
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1040 // disable doublebuffering for YV12
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
1041
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1042 #ifdef HAVE_DGA2
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1043 if(vo_dga_vp_height>max_vpy_pos){
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1044 vo_dga_dbf_mem_offset = 0;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1045 vd_printf(VD_INFO, "vo_dga: Not enough memory for double buffering!\n");
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1046 }
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1047 #endif
262
2c7c77d793df - added double buffering :-)
acki2
parents: 261
diff changeset
1048
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1049 // now clear screen
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
1050 {
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
1051 int size = vo_dga_width *
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
1052 (vo_dga_vp_height + (vo_dga_dbf_mem_offset != 0 ?
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
1053 (vo_dga_src_height+y_off) : 0)) *
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
1054 HW_MODE.vdm_bytespp;
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1055 #ifndef HAVE_DGA2
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1056 vd_printf(VD_DBG, "vo_dga: wanted size=%d, fb-size=%d\n", size, ram);
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1057 if(size>ram*1024){
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1058 vo_dga_dbf_mem_offset = 0;
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1059 vd_printf(VD_INFO, "vo_dga: Not enough memory for double buffering!\n");
680
fbd9327b899b - now features 24->32 conversion (this is actually faster than letting the
acki2
parents: 677
diff changeset
1060 size -= (vo_dga_src_height+y_off) * vo_dga_width * HW_MODE.vdm_bytespp;
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1061 }
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1062 #endif
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1063
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1064 vd_printf(VD_INFO, "vo_dga: Clearing framebuffer (%d bytes). If mplayer exits", size);
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1065 vd_printf(VD_INFO, " here, you haven't enough memory on your card.\n");
266
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1066 fflush(stdout);
336b1559a447 - added detection of memsize of graphics card to check if double buffering is possible
acki2
parents: 263
diff changeset
1067 memset(vo_dga_base, 0, size);
263
78e8925fd6b4 - added VidMode changing support for DGA1.0 (used code from Michael Graffam (mgraffam@idsi.net))
acki2
parents: 262
diff changeset
1068 }
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1069 vd_printf(VD_INFO, "vo_dga: Doublebuffering is %s.\n", vo_dga_dbf_mem_offset ? "enabled" : "disabled");
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1070 vo_dga_is_running = 1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1071 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1072 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1073
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
1074 //---------------------------------------------------------
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
1075
260
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
1076 // deleted the old vo_dga_query_event() routine 'cause it is obsolete
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
1077 // since using check_events()
1742ea658d0b Source cleanup. Improved resolution selection (I think :-)).
acki2
parents: 233
diff changeset
1078 // acki2 on 30/3/2001
392
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1079
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1080
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1081
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1082
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1083
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1084
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1085
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1086
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1087
50214d6c1826 - completely rewrote depth switching
acki2
parents: 272
diff changeset
1088