codecs.conf: add matchware screen codec fourcc MWSC
[mplayer/greg.git] / libvo / vo_mga.c
blobd398ec001aacf8d1cd10b9a8f849798ab1f81eba
1 /*
2 * video output through mga_vid kernel driver
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.
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
25 #include "config.h"
26 #include "mp_msg.h"
27 #include "video_out.h"
28 #include "video_out_internal.h"
30 #include <sys/ioctl.h>
31 #include <unistd.h>
32 #include <fcntl.h>
33 #include <sys/mman.h>
34 #include <linux/fb.h>
36 #include "drivers/mga_vid.h"
37 #include "sub.h"
38 #include "aspect.h"
40 static const vo_info_t info =
42 "Matrox G200/G4x0/G550 overlay (/dev/mga_vid)",
43 "mga",
44 "A'rpi",
45 "Based on some code by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>"
48 const LIBVO_EXTERN(mga)
50 #include "mga_template.c"
52 #define FBDEV "/dev/fb0"
54 static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
57 // if (f >= 0) mga_uninit();
58 if(!vo_screenwidth || !vo_screenheight) {
59 int fd;
60 struct fb_var_screeninfo fbinfo;
62 if(-1 != (fd = open(FBDEV, O_RDONLY))) {
63 if(0 == ioctl(fd, FBIOGET_VSCREENINFO, &fbinfo)) {
64 if(!vo_screenwidth) vo_screenwidth = fbinfo.xres;
65 if(!vo_screenheight) vo_screenheight = fbinfo.yres;
66 } else {
67 perror("FBIOGET_VSCREENINFO");
69 close(fd);
70 } else {
71 perror(FBDEV);
75 if(vo_screenwidth && vo_screenheight){
76 aspect_save_orig(width,height);
77 aspect_save_prescale(d_width,d_height);
78 aspect_save_screenres(vo_screenwidth,vo_screenheight);
80 if(flags&VOFLAG_FULLSCREEN) { /* -fs */
81 aspect(&d_width,&d_height,A_ZOOM);
82 vo_fs = VO_TRUE;
83 } else {
84 aspect(&d_width,&d_height,A_NOZOOM);
85 vo_fs = VO_FALSE;
87 mp_tmsg(MSGT_VO,MSGL_INFO, "[VO_MGA] aspect(): resized to %dx%d.\n",d_width,d_height);
90 vo_dwidth=d_width; vo_dheight=d_height;
91 mga_vid_config.dest_width = d_width;
92 mga_vid_config.dest_height= d_height;
93 mga_vid_config.x_org= 0; // (720-mga_vid_config.dest_width)/2;
94 mga_vid_config.y_org= 0; // (576-mga_vid_config.dest_height)/2;
95 if(vo_screenwidth && vo_screenheight){
96 mga_vid_config.x_org=(vo_screenwidth-d_width)/2;
97 mga_vid_config.y_org=(vo_screenheight-d_height)/2;
100 return mga_init(width,height,format);
103 static void uninit(void)
105 mp_tmsg(MSGT_VO,MSGL_INFO, "[VO] uninit!\n");
106 mga_uninit();
109 static void flip_page(void)
111 vo_mga_flip_page();
115 static void check_events(void)