annotate libvo/vo_dga.c @ 132:642d64c1cc33

translation by Gabucino
author gabucino
date Sun, 18 Mar 2001 13:57:06 +0000
parents 1fc618eba830
children 3daeae4a4aa6
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 /*
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
4 * video_out_dga.c, X11 interface
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
5 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
6 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
7 * Copyright ( C ) 2001, Andreas Ackermann. All Rights Reserved.
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
8 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
9 * <acki@acki-netz.de>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
10 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
11 * note well:
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
12 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
13 * o this is alpha
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
14 * o covers only common video card formats
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
15 * o works only on intel architectures
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
16 *
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
17 */
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
18
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
19
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
20
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
21 #include <stdio.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
22 #include <stdlib.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
23 #include <string.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
24
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
25
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
26 #include "linux/keycodes.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
27 #include "config.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
28 #include "video_out.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
29 #include "video_out_internal.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
30 #include "yuv2rgb.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
31
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
32 LIBVO_EXTERN( dga )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
33
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
34 #include <X11/Xlib.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
35 #include <X11/extensions/xf86dga.h>
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
36
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
37 #include "x11_common.h"
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
38
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
39 static vo_info_t vo_info =
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
40 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
41 "DGA ( Direct Graphic Access )",
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
42 "dga",
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
43 "Andreas Ackermann <acki@acki-netz.de>",
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
44 ""
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
45 };
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
46
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
47 static int vo_dga_width; // bytes per line in framebuffer
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
48 static int vo_dga_vp_width; // visible pixels per line in framebuffer
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
49 static int vo_dga_vp_height; // visible lines in framebuffer
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
50 static int vo_dga_is_running = 0;
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
51 static int vo_dga_src_width; // width of video in pixels
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
52 static int vo_dga_src_height; // height of video in pixels
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
53 static int vo_dga_bpp; // bytes per pixel in framebuffer
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
54 static int vo_dga_src_offset=0; // offset in src
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
55 static int vo_dga_vp_offset=0; // offset in dest
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
56 static int vo_dga_bytes_per_line; // longwords per line to copy
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
57 static int vo_dga_src_skip; // bytes to skip after copying one line
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
58 // (not supported yet) in src
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
59 static int vo_dga_vp_skip; // dto. for dest
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
60 static int vo_dga_lines; // num of lines to copy
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
61 static int vo_dga_src_format;
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
62
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
63 static unsigned char *vo_dga_base;
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
64 static Display *vo_dga_dpy;
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
65
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
66
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
67 #include "mmx.h"
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
68
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
69 #if defined (HAVE_SSE) || defined (HAVE_3DNOW)
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
70 #define movntq "movntq" // use this for processors that have SSE or 3Dnow
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
71 #else
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
72 #define movntq "movq" // for MMX-only processors
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
73 #endif
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
74
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
75
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
76 #define rep_movsl(dest, src, numwords, d_add, count) \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
77 __asm__ __volatile__( \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
78 " \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
79 xfer: \n\t\
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
80 movl %%edx, %%ecx \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
81 cld\n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
82 rep\n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
83 movsl \n\t\
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
84 add %%eax, %%edi \n\t\
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
85 dec %%ebx \n\t\
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
86 jnz xfer \n\t\
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
87 " \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
88 : \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
89 : "a" (d_add), "b" (count), "S" (src), "D" (dest), "d" (numwords) \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
90 : "memory" )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
91
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
92 #if 0
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
93 : "S" (src), "D" (dest), "c" (numwords) \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
94 movq (%%eax), %%mm0 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
95 add $64, %%edx \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
96 movq 8(%%eax), %%mm1 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
97 add $64, %%eax \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
98 movq -48(%%eax), %%mm2 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
99 movq %%mm0, -64(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
100 movq -40(%%eax), %%mm3 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
101 movq %%mm1, -56(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
102 movq -32(%%eax), %%mm4 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
103 movq %%mm2, -48(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
104 movq -24(%%eax), %%mm5 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
105 movq %%mm3, -40(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
106 movq -16(%%eax), %%mm6 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
107 movq %%mm4, -32(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
108 movq -8(%%eax), %%mm7 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
109 movq %%mm5, -24(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
110 movq %%mm6, -16(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
111 dec %%ecx \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
112 movq %%mm7, -8(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
113 jnz xfer \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
114
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
115 #endif
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
116
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
117 #define mmx_movsl(dest, src, numwords) \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
118 __asm__ __volatile__( \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
119 " \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
120 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
121 xfer: \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
122 movq (%%eax), %%mm0 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
123 add $64, %%edx \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
124 movq 8(%%eax), %%mm1 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
125 add $64, %%eax \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
126 movq -48(%%eax), %%mm2 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
127 movq %%mm0, -64(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
128 movq -40(%%eax), %%mm3 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
129 movq %%mm1, -56(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
130 movq -32(%%eax), %%mm4 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
131 movq %%mm2, -48(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
132 movq -24(%%eax), %%mm5 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
133 movq %%mm3, -40(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
134 movq -16(%%eax), %%mm6 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
135 movq %%mm4, -32(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
136 movq -8(%%eax), %%mm7 \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
137 movq %%mm5, -24(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
138 movq %%mm6, -16(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
139 dec %%ecx \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
140 movq %%mm7, -8(%%edx) \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
141 jnz xfer \n\t \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
142 \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
143 " \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
144 : \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
145 : "a" (src), "d" (dest), "c" (numwords) \
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
146 : "memory" )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
147
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
148 // src <= eax
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
149 // dst <= edx
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
150 // num <= ecx
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
151
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
152 static uint32_t draw_frame( uint8_t *src[] ){
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
153
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
154 int vp_skip = vo_dga_vp_skip;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
155 int lpl = vo_dga_bytes_per_line >> 2;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
156 int numlines = vo_dga_lines;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
157
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
158 char *s, *d;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
159
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
160 if( vo_dga_src_format==IMGFMT_YV12 ){
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
161 // We'll never reach this point, because YV12 codecs always calls draw_slice
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
162 printf("vo_dga: draw_frame() doesn't support IMGFMT_YV12 (yet?)\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
163 }else{
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
164 s = *src;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
165 d = (&((char *)vo_dga_base)[vo_dga_vp_offset]);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
166 rep_movsl(d, s, lpl, vo_dga_vp_skip, numlines );
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
167 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
168
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
169 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
170 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
171
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
172 static void check_events(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
173 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
174 int e=vo_x11_check_events(vo_dga_dpy);
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
175 }
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
176
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
177 static void flip_page( void ){
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
178 check_events();
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
179 // printf("vo_dga: In flippage\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
180
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
181 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
182
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
183 static uint32_t draw_slice( uint8_t *src[],int stride[],
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
184 int w,int h,int x,int y )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
185 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
186 // printf("vo_dga: draw_slice() not implemented (yet?)\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
187
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
188 yuv2rgb( vo_dga_base + vo_dga_vp_offset +
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
189 (vo_dga_width * y +x) * vo_dga_bpp,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
190 src[0], src[1], src[2],
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
191 w,h, vo_dga_width * vo_dga_bpp,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
192 stride[0],stride[1] );
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
193 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
194
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
195
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
196 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
197 };
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
198
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
199 static void Terminate_Display_Process( void ){
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
200
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
201 printf("vo_dga: Terminating display process\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
202 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
203
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
204 static const vo_info_t* get_info( void )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
205 { return &vo_info; }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
206
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
207 static uint32_t query_format( uint32_t format )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
208 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
209 printf("vo_dga: query_format\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
210
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
211 if( !vo_init() ) return 0; // Can't open X11
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
212 printf("Format: %lx\n", format);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
213
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
214 if( format==IMGFMT_YV12 ) return 1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
215 if( ( format&IMGFMT_BGR_MASK )==IMGFMT_BGR &&
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
216 ( format&0xFF )==vo_depthonscreen ) return 1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
217 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
218 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
219
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
220
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
221 static void
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
222 uninit(void)
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
223 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
224
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
225 vo_dga_is_running = 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
226 printf("vo_dga: in uninit\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
227 XUngrabPointer (vo_dga_dpy, CurrentTime);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
228 XUngrabKeyboard (vo_dga_dpy, CurrentTime);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
229 XF86DGADirectVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
230 XCloseDisplay(vo_dga_dpy);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
231 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
232
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
233
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
234
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
235
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
236 static uint32_t init( uint32_t width, uint32_t height,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
237 uint32_t d_width,uint32_t d_height,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
238 uint32_t fullscreen,char *title,uint32_t format )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
239 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
240
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
241 int bank, ram;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
242 int x_off, y_off;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
243
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
244 if( vo_dga_is_running )return -1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
245
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
246 if( !vo_init() ){
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
247 printf("vo_dga: vo_init() failed!\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
248 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
249 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
250
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
251 if((vo_dga_dpy = XOpenDisplay(0))==NULL)
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
252 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
253 printf ("vo_dga: Can't open display\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
254 return 1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
255 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
256
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
257 XF86DGAGetVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy),
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
258 (char **)&vo_dga_base, &vo_dga_width, &bank, &ram);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
259 XF86DGAGetViewPortSize (vo_dga_dpy, XDefaultScreen (vo_dga_dpy),
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
260 &vo_dga_vp_width, &vo_dga_vp_height);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
261
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
262
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
263 // do some more checkings here ...
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
264 if( format==IMGFMT_YV12 )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
265 yuv2rgb_init( vo_depthonscreen, MODE_RGB );
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
266
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
267 vo_dga_src_format = format;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
268 vo_dga_src_width = width;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
269 vo_dga_src_height = height;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
270 vo_dga_bpp = (vo_depthonscreen+7) >> 3;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
271
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
272 printf("vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %08x, bpp: %d\n",
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
273 vo_dga_width, vo_dga_vp_width,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
274 vo_dga_vp_height, vo_depthonscreen, vo_dga_base,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
275 vo_dga_bpp);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
276 printf("vo_dga: video res: %dx%d\n", vo_dga_src_width, vo_dga_src_height);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
277
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
278 if(vo_dga_src_width > vo_dga_vp_width ||
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
279 vo_dga_src_height > vo_dga_vp_height){
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
280 printf("vo_dga: Sorry, video larger than viewport is not yet supported!\n");
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
281 // ugly, do something nicer in the future ...
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
282 return 1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
283 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
284
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
285 x_off = (vo_dga_vp_width - vo_dga_src_width)>>1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
286 y_off = (vo_dga_vp_height - vo_dga_src_height)>>1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
287
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
288 vo_dga_bytes_per_line = vo_dga_src_width * vo_dga_bpp; // todo
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
289 vo_dga_lines = vo_dga_src_height; // todo
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
290
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
291
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
292 vo_dga_src_offset = 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
293 vo_dga_vp_offset = (y_off * vo_dga_width + x_off ) * vo_dga_bpp;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
294
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
295 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * vo_dga_bpp; // todo
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
296
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
297 printf("vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n",
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
298 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
299
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
300
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
301
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
302 XF86DGASetViewPort (vo_dga_dpy, XDefaultScreen(vo_dga_dpy), 0, 0);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
303 XF86DGADirectVideo (vo_dga_dpy, XDefaultScreen(vo_dga_dpy),
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
304 XF86DGADirectGraphics | XF86DGADirectMouse |
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
305 XF86DGADirectKeyb);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
306
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
307 XGrabKeyboard (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
308 GrabModeAsync,GrabModeAsync, CurrentTime);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
309 XGrabPointer (vo_dga_dpy, DefaultRootWindow(vo_dga_dpy), True,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
310 ButtonPressMask,GrabModeAsync, GrabModeAsync,
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
311 None, None, CurrentTime);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
312
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
313 // now clear screen
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
314
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
315 memset(vo_dga_base, 0, vo_dga_width * vo_dga_vp_height * vo_dga_bpp);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
316
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
317 vo_dga_is_running = 1;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
318 return 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
319 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
320
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
321 #if 0
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
322 int vo_dga_query_event(void){
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
323
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
324 XEvent myevent;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
325 char text[10];
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
326 KeySym mykey;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
327 int retval = 0;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
328 int i;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
329
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
330 if( vo_dga_is_running ){
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
331 if(XPending(vo_dga_dpy)>0)
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
332 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
333 XNextEvent(vo_dga_dpy, &myevent);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
334 switch (myevent.type)
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
335 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
336 case ButtonPress:
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
337 /* Reaktion auf Knopfdruck ---> Textausgabe an der
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
338 Mauscursorposition */
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
339
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
340 retval = 'q';
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
341 break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
342 case KeyPress:
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
343 /* Reaktion auf Tastendruck --> Testen ob Taste == "q",
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
344 falls ja: Programmende */
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
345 i=XLookupString(&myevent, text, 10, &mykey, 0);
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
346
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
347 if (mykey&0xff00 != 0) mykey=mykey&0x00ff + 256;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
348
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
349 switch ( mykey )
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
350 {
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
351 case wsLeft: retval=KEY_LEFT; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
352 case wsRight: retval=KEY_RIGHT; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
353 case wsUp: retval=KEY_UP; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
354 case wsDown: retval=KEY_DOWN; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
355 case wsSpace: retval=' '; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
356 case wsEscape: retval=KEY_ESC; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
357 case wsEnter: retval=KEY_ENTER; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
358 case wsq:
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
359 case wsQ: retval='q'; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
360 case wsp:
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
361 case wsP: retval='p'; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
362 case wsMinus:
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
363 case wsGrayMinus: retval='-'; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
364 case wsPlus:
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
365 case wsGrayPlus: retval='+'; break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
366 }
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
367 break;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
368 }
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 return retval;
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
372 }
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 13
diff changeset
373 #endif
13
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
374
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
375
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
376
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
377
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
378
36314c7bda8d initial version
arpi_esp
parents:
diff changeset
379