2 * copyright (C) 2001 Zoltan Ponekker
4 * This file is part of MPlayer.
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "video_out.h"
30 #include "video_out_internal.h"
33 #include <sys/ioctl.h>
38 #include "drivers/mga_vid.h"
41 #include <X11/Xutil.h>
44 #ifdef CONFIG_XINERAMA
45 #include <X11/extensions/Xinerama.h>
48 #include "x11_common.h"
53 #include "osdep/timer.h"
54 static unsigned int timer
= 0;
55 static unsigned int timerd
= 0;
58 static const vo_info_t info
= {
59 "Matrox G200/G4x0/G550 overlay in X11 window (using /dev/mga_vid)",
61 "Zoltan Ponekker <pontscho@makacs.poliod.hu>",
65 const LIBVO_EXTERN(xmga
)
67 static uint32_t mDepth
;
68 static XWindowAttributes attribs
;
71 static uint32_t mvHeight
;
72 static uint32_t mvWidth
;
74 static XSetWindowAttributes xWAttribs
;
76 static int initialized
= 0;
79 #include "mga_template.c"
82 static void mDrawColorKey(void)
84 XSetBackground(mDisplay
, vo_gc
, 0);
85 XClearWindow(mDisplay
, vo_window
);
86 XSetForeground(mDisplay
, vo_gc
, colorkey
);
87 XFillRectangle(mDisplay
, vo_window
, vo_gc
, drwX
, drwY
, drwWidth
,
88 (vo_fs
? drwHeight
- 1 : drwHeight
));
92 static void check_events(void)
94 int e
= vo_x11_check_events(mDisplay
);
96 if (e
& (VO_EVENT_RESIZE
| VO_EVENT_MOVE
))
98 if (e
& (VO_EVENT_RESIZE
| VO_EVENT_EXPOSE
))
102 static void flip_page(void)
108 mp_msg(MSGT_VO
, MSGL_STATUS
,
109 " [timer: %08X diff: %6d dd: %6d ] \n", t
, t
- timer
,
110 (t
- timer
) - timerd
);
118 static int config(uint32_t width
, uint32_t height
, uint32_t d_width
,
119 uint32_t d_height
, uint32_t flags
, char *title
,
123 unsigned long xswamask
;
126 if (mga_init(width
, height
, format
))
127 return -1; // ioctl errors?
132 r
= (vo_colorkey
& 0x00ff0000) >> 16;
133 g
= (vo_colorkey
& 0x0000ff00) >> 8;
134 b
= vo_colorkey
& 0x000000ff;
135 switch (vo_depthonscreen
)
138 colorkey
= vo_colorkey
;
141 colorkey
= vo_colorkey
& 0x00ffffff;
144 colorkey
= ((r
>> 3) << 11) | ((g
>> 2) << 5) | (b
>> 3);
147 colorkey
= ((r
>> 3) << 10) | ((g
>> 3) << 5) | (b
>> 3);
150 mp_msg(MSGT_VO
, MSGL_ERR
,
151 "Sorry, this (%d) color depth not supported.\n",
155 mp_msg(MSGT_VO
, MSGL_V
, "Using colorkey: %x\n", colorkey
);
159 XGetWindowAttributes(mDisplay
, mRootWin
, &attribs
);
160 mDepth
= attribs
.depth
;
161 if (mDepth
!= 15 && mDepth
!= 16 && mDepth
!= 24 && mDepth
!= 32)
163 XMatchVisualInfo(mDisplay
, mScreen
, mDepth
, TrueColor
, &vinfo
);
165 XCreateColormap(mDisplay
, mRootWin
, vinfo
.visual
, AllocNone
);
166 xWAttribs
.background_pixel
= 0;
167 xWAttribs
.border_pixel
= 0;
168 xswamask
= CWBackPixel
| CWBorderPixel
| CWColormap
;
170 vo_x11_create_vo_window(&vinfo
, vo_dx
, vo_dy
, d_width
, d_height
,
171 flags
, xWAttribs
.colormap
, "xmga", title
);
172 XChangeWindowAttributes(mDisplay
, vo_window
, xswamask
, &xWAttribs
);
174 mga_vid_config
.colkey_on
= 1;
175 mga_vid_config
.colkey_red
= r
;
176 mga_vid_config
.colkey_green
= g
;
177 mga_vid_config
.colkey_blue
= b
;
179 set_window(); // set up mga_vid_config.dest_width etc
181 XSync(mDisplay
, False
);
183 ioctl(f
, MGA_VID_ON
, 0);
188 static void uninit(void)
190 mp_msg(MSGT_VO
, MSGL_V
, "vo: uninit!\n");
193 return; // no window?
195 vo_x11_uninit(); // destroy the window