Mercurial > mplayer.hg
annotate libvo/vo_xmga.c @ 8013:bd100a3d486f
Here's a new vo plugin that uses DirectFB. It's meant for Matrox G400
cards and TV out. It's works like DVDMax in Windows.
Instructions on how to make it work are at:
http://www.sci.fi/~syrjala/directfb/readme.txt
patch by Ville Syrj¸«£l¸«£ <syrjala@sci.fi>
author | arpi |
---|---|
date | Thu, 31 Oct 2002 23:54:26 +0000 |
parents | ed7b05575aab |
children | a57aac3a927a |
rev | line source |
---|---|
100 | 1 |
2 //#define SHOW_TIME | |
1 | 3 |
4 /* | |
7680 | 5 * vo_xmga.c |
1 | 6 * |
7 * Copyright (C) Zoltan Ponekker - Jan 2001 | |
8 * | |
9 */ | |
10 | |
11 #include <stdio.h> | |
12 #include <stdlib.h> | |
13 #include <string.h> | |
14 | |
15 #include "config.h" | |
6296 | 16 #include "mp_msg.h" |
17 | |
1 | 18 #include "video_out.h" |
19 #include "video_out_internal.h" | |
20 | |
21 LIBVO_EXTERN( xmga ) | |
22 | |
23 #include <sys/ioctl.h> | |
24 #include <unistd.h> | |
25 #include <fcntl.h> | |
26 #include <sys/mman.h> | |
27 | |
28 #include "drivers/mga_vid.h" | |
29 | |
30 #include <X11/Xlib.h> | |
31 #include <X11/Xutil.h> | |
32 #include <errno.h> | |
33 | |
4017 | 34 #ifdef HAVE_XINERAMA |
35 #include <X11/extensions/Xinerama.h> | |
36 #endif | |
37 | |
31 | 38 #include "x11_common.h" |
616 | 39 #include "sub.h" |
2057 | 40 #include "aspect.h" |
31 | 41 |
182 | 42 #ifdef SHOW_TIME |
100 | 43 #include "../linux/timer.h" |
44 static unsigned int timer=0; | |
45 static unsigned int timerd=0; | |
46 #endif | |
47 | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
48 #ifdef HAVE_NEW_GUI |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
49 #include "../Gui/interface.h" |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
50 #endif |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
51 |
1 | 52 static vo_info_t vo_info = |
53 { | |
7680 | 54 "Matrox G200/G4x0/G550 overlay in X11 window (using /dev/mga_vid)", |
1 | 55 "xmga", |
56 "Zoltan Ponekker <pontscho@makacs.poliod.hu>", | |
57 "" | |
58 }; | |
59 | |
60 static XGCValues wGCV; | |
61 | |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7124
diff
changeset
|
62 static uint32_t mDepth; |
1 | 63 static XWindowAttributes attribs; |
64 static uint32_t fgColor; | |
65 | |
66 static uint32_t mvHeight; | |
67 static uint32_t mvWidth; | |
68 | |
69 static Window mRoot; | |
70 static uint32_t drwX,drwY,drwWidth,drwHeight,drwBorderWidth,drwDepth; | |
4981 | 71 static uint32_t drwcX,drwcY,dwidth,dheight; |
1 | 72 |
73 static XSetWindowAttributes xWAttribs; | |
74 | |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
75 static int inited=0; |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
76 |
4981 | 77 #define VO_XMGA |
1 | 78 #include "mga_common.c" |
4981 | 79 #undef VO_XMGA |
1 | 80 |
81 static void mDrawColorKey( void ) | |
82 { | |
4795 | 83 XSetBackground( mDisplay,vo_gc,0 ); |
84 XClearWindow( mDisplay,vo_window ); | |
85 XSetForeground( mDisplay,vo_gc,fgColor ); | |
4981 | 86 XFillRectangle( mDisplay,vo_window,vo_gc,drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight) ); |
1 | 87 XFlush( mDisplay ); |
88 } | |
89 | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
90 static void set_window( void ){ |
120 | 91 |
6043 | 92 if ( WinID ) |
93 { | |
94 XGetGeometry( mDisplay,vo_window,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); | |
6296 | 95 mp_msg(MSGT_VO,MSGL_V,"[xmga] x: %d y: %d w: %d h: %d\n",drwX,drwY,drwWidth,drwHeight ); |
6043 | 96 drwX=0; drwY=0; |
97 XTranslateCoordinates( mDisplay,vo_window,mRoot,0,0,&drwcX,&drwcY,&mRoot ); | |
6296 | 98 mp_msg(MSGT_VO,MSGL_V,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
6043 | 99 } |
100 else { drwX=drwcX=vo_dx; drwY=drwcY=vo_dy; drwWidth=vo_dwidth; drwHeight=vo_dheight; } | |
1852 | 101 |
3558 | 102 aspect(&dwidth,&dheight,A_NOZOOM); |
4981 | 103 if ( vo_fs ) |
120 | 104 { |
3558 | 105 aspect(&dwidth,&dheight,A_ZOOM); |
120 | 106 drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; |
107 drwcX+=drwX; | |
108 drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; | |
109 drwcY+=drwY; | |
110 drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); | |
111 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); | |
6296 | 112 mp_msg(MSGT_VO,MSGL_V,"[xmga-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
120 | 113 } |
6307 | 114 vo_dwidth=drwWidth; vo_dheight=drwHeight; |
120 | 115 |
4017 | 116 #ifdef HAVE_XINERAMA |
117 if(XineramaIsActive(mDisplay)) | |
118 { | |
119 XineramaScreenInfo *screens; | |
120 int num_screens; | |
121 int i; | |
122 | |
123 screens = XineramaQueryScreens(mDisplay,&num_screens); | |
124 | |
125 /* find the screen we are on */ | |
126 i = 0; | |
127 while(!(screens[i].x_org <= drwcX && screens[i].y_org <= drwcY && | |
128 screens[i].x_org + screens[i].width >= drwcX && | |
129 screens[i].y_org + screens[i].height >= drwcY )) | |
130 { | |
131 i++; | |
132 } | |
133 | |
134 /* set drwcX and drwcY to the right values */ | |
135 drwcX = drwcX - screens[i].x_org; | |
136 drwcY = drwcY - screens[i].y_org; | |
137 XFree(screens); | |
138 } | |
139 | |
140 #endif | |
6307 | 141 |
142 mDrawColorKey(); | |
143 | |
120 | 144 mga_vid_config.x_org=drwcX; |
145 mga_vid_config.y_org=drwcY; | |
146 mga_vid_config.dest_width=drwWidth; | |
147 mga_vid_config.dest_height=drwHeight; | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
148 if ( vo_panscan > 0.0f && vo_fs ) |
6307 | 149 { |
150 drwX-=vo_panscan_x>>1; | |
151 drwY-=vo_panscan_y>>1; | |
152 drwWidth+=vo_panscan_x; | |
153 drwHeight+=vo_panscan_y; | |
154 | |
155 mga_vid_config.x_org-=vo_panscan_x>>1; | |
156 mga_vid_config.y_org-=vo_panscan_y>>1; | |
157 mga_vid_config.dest_width=drwWidth; | |
158 mga_vid_config.dest_height=drwHeight; | |
159 mDrawColorKey(); | |
160 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) mp_msg(MSGT_VO,MSGL_WARN,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); | |
161 } | |
120 | 162 } |
163 | |
31 | 164 static void check_events(void) |
1 | 165 { |
4303 | 166 int e=vo_x11_check_events(mDisplay); |
167 if ( !(e&VO_EVENT_RESIZE) && !(e&VO_EVENT_EXPOSE) ) return; | |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
168 set_window(); |
6043 | 169 mDrawColorKey(); |
6296 | 170 if ( ioctl( f,MGA_VID_CONFIG,&mga_vid_config ) ) mp_msg(MSGT_VO,MSGL_WARN,"Error in mga_vid_config ioctl (wrong mga_vid.o version?)" ); |
1 | 171 } |
172 | |
31 | 173 static void flip_page(void){ |
182 | 174 #ifdef SHOW_TIME |
100 | 175 unsigned int t; |
176 t=GetTimer(); | |
6296 | 177 mp_msg(MSGT_VO,MSGL_STATUS," [timer: %08X diff: %6d dd: %6d ] \n",t,t-timer,(t-timer)-timerd); |
100 | 178 timerd=t-timer; |
179 timer=t; | |
182 | 180 #endif |
100 | 181 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1210
diff
changeset
|
182 vo_mga_flip_page(); |
31 | 183 } |
1 | 184 |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
6953
diff
changeset
|
185 static uint32_t config( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
1 | 186 { |
187 char * mTitle=(title == NULL) ? "XMGA render" : title; | |
188 XVisualInfo vinfo; | |
189 unsigned long xswamask; | |
190 | |
7679 | 191 if(mga_init(width,height,format)) return -1; // ioctl errors? |
1 | 192 |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
193 aspect_save_orig(width,height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
194 aspect_save_prescale(d_width,d_height); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
195 aspect_save_screenres(vo_screenwidth,vo_screenheight); |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
196 |
1 | 197 mvWidth=width; mvHeight=height; |
198 | |
6307 | 199 vo_panscan_x=vo_panscan_y=vo_panscan_amount=0; |
200 | |
7679 | 201 vo_dx=( vo_screenwidth - d_width ) / 2; |
202 vo_dy=( vo_screenheight - d_height ) / 2; | |
4981 | 203 vo_dwidth=d_width; vo_dheight=d_height; |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
204 vo_mouse_autohide=1; |
1 | 205 |
206 switch ( vo_depthonscreen ) | |
207 { | |
208 case 32: | |
209 case 24: fgColor=0x00ff00ffL; break; | |
210 case 16: fgColor=0xf81fL; break; | |
211 case 15: fgColor=0x7c1fL; break; | |
6296 | 212 default: mp_msg(MSGT_VO,MSGL_ERR,"Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1; |
1 | 213 } |
214 | |
5158 | 215 inited=1; |
216 | |
6016 | 217 aspect(&vo_dwidth,&vo_dheight,A_NOZOOM); |
5985 | 218 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1637
diff
changeset
|
219 #ifdef HAVE_NEW_GUI |
5985 | 220 if(use_gui) |
221 guiGetEvent( guiSetShVideo,0 ); // the GUI will set up / resize the window | |
222 else | |
223 #endif | |
723 | 224 { |
6043 | 225 if ( flags&1 ) aspect(&dwidth,&dheight,A_ZOOM); |
723 | 226 |
6043 | 227 XGetWindowAttributes( mDisplay,mRootWin,&attribs ); |
723 | 228 mDepth=attribs.depth; |
229 if ( mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32 ) mDepth=24; | |
230 XMatchVisualInfo( mDisplay,mScreen,mDepth,TrueColor,&vinfo ); | |
6043 | 231 xWAttribs.colormap=XCreateColormap( mDisplay,mRootWin,vinfo.visual,AllocNone ); |
723 | 232 xWAttribs.background_pixel=0; |
233 xWAttribs.border_pixel=0; | |
6043 | 234 xWAttribs.event_mask=StructureNotifyMask | ExposureMask | KeyPressMask | |
235 ((WinID==0)?0:(ButtonPressMask | ButtonReleaseMask | PointerMotionMask | PropertyChangeMask)); | |
723 | 236 xswamask=CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; |
1 | 237 |
3847 | 238 if ( WinID>=0 ){ |
6043 | 239 |
240 vo_window = WinID ? ((Window)WinID) : mRootWin; | |
241 if ( WinID ) | |
242 { | |
243 XUnmapWindow( mDisplay,vo_window ); | |
244 XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xWAttribs); | |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6755
diff
changeset
|
245 vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask ); |
6043 | 246 } else XSelectInput( mDisplay,vo_window,ExposureMask ); |
247 | |
7679 | 248 } else { |
249 | |
7777 | 250 if ( vo_window == None ) |
251 { | |
252 vo_window=XCreateWindow( mDisplay,mRootWin, | |
6043 | 253 vo_dx,vo_dy, |
254 vo_dwidth,vo_dheight, | |
255 xWAttribs.border_pixel, | |
256 mDepth, | |
257 InputOutput, | |
258 vinfo.visual,xswamask,&xWAttribs ); | |
259 | |
7777 | 260 vo_x11_classhint( mDisplay,vo_window,"xmga" ); |
261 vo_hidecursor(mDisplay,vo_window); | |
262 vo_x11_sizehint( vo_dx,vo_dy,vo_dwidth,vo_dheight,0 ); | |
723 | 263 |
7777 | 264 XStoreName( mDisplay,vo_window,mTitle ); |
265 XMapWindow( mDisplay,vo_window ); | |
6043 | 266 |
7777 | 267 if ( flags&1 ) vo_x11_fullscreen(); |
5999 | 268 |
3990 | 269 #ifdef HAVE_XINERAMA |
7777 | 270 vo_x11_xinerama_move(mDisplay,vo_window); |
3990 | 271 #endif |
7777 | 272 } else if ( !(flags&1) ) XMoveResizeWindow( mDisplay,vo_window,vo_dx,vo_dy,vo_dwidth,vo_dheight ); |
6043 | 273 } |
7679 | 274 |
7777 | 275 if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc ); |
6043 | 276 vo_gc=XCreateGC( mDisplay,vo_window,GCForeground,&wGCV ); |
7679 | 277 |
278 } // !GUI | |
1 | 279 |
6043 | 280 if ( ( flags&1 )&&( !WinID ) ) { vo_dx=0; vo_dy=0; vo_dwidth=vo_screenwidth; vo_dheight=vo_screenheight; vo_fs=1; } |
6382
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
281 |
86d5fc5b54e2
fix panscan support and add Jesper Svennevid's <mplayer@svennevid.net> patch
pontscho
parents:
6311
diff
changeset
|
282 panscan_calc(); |
7679 | 283 |
284 mga_vid_config.colkey_on=1; | |
285 mga_vid_config.colkey_red=255; | |
286 mga_vid_config.colkey_green=0; | |
287 mga_vid_config.colkey_blue=255; | |
288 | |
289 set_window(); // set up mga_vid_config.dest_width etc | |
1 | 290 |
6755 | 291 saver_off(mDisplay); |
292 | |
293 XFlush( mDisplay ); | |
294 XSync( mDisplay,False ); | |
7777 | 295 |
296 ioctl(f,MGA_VID_ON,0); | |
6755 | 297 |
7679 | 298 return 0; |
1 | 299 } |
300 | |
7679 | 301 static const vo_info_t* get_info( void ){ return &vo_info; } |
1 | 302 |
7679 | 303 static void uninit(void){ |
304 mp_msg(MSGT_VO,MSGL_V,"vo: uninit!\n"); | |
305 mga_uninit(); | |
306 if(!inited) return; // no window? | |
5158 | 307 inited=0; |
4316 | 308 saver_on(mDisplay); |
7679 | 309 vo_x11_uninit(); // destroy the window |
1 | 310 } |
4352 | 311 |