[MPlayer-dev-eng] [PATCH] autodetect screen size for vo_mga fullscreen

Jason Lunz j at falooley.org
Wed Jan 30 06:24:16 CET 2002


I liked the TOOLS/mpconsole script, but I think mplayer's vo_mga should
be able to detect the screen size if fbset can. So I wrote this patch to
make vo_mga autodetect the -screenh and -screenw parameters if they're
not specified. The patch is against current CVS, and it works for me.

thanks for the great work on mplayer,

Jason


Index: libvo/vo_mga.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_mga.c,v
retrieving revision 1.20
diff -u -r1.20 vo_mga.c
--- libvo/vo_mga.c	26 Jan 2002 16:01:26 -0000	1.20
+++ libvo/vo_mga.c	30 Jan 2002 05:33:07 -0000
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <linux/fb.h>
 
 #include "config.h"
 #include "video_out.h"
@@ -54,11 +55,29 @@
 
 #include "mga_common.c"
 
+#define FBDEV	"/dev/fb0"
+
 static uint32_t
 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
 {
 char *devname=vo_subdevice?vo_subdevice:"/dev/mga_vid";
 
+	if(0 == vo_screenwidth || 0 == vo_screenheight) {
+		int fd;
+		struct fb_var_screeninfo fbinfo;
+
+		if(-1 != (fd = open(FBDEV, O_RDONLY))) {
+			if(0 == ioctl(fd, FBIOGET_VSCREENINFO, &fbinfo)) {
+				if(!vo_screenwidth)   vo_screenwidth = fbinfo.xres;
+				if(!vo_screenheight) vo_screenheight = fbinfo.yres;
+			} else {
+				perror("FBIOGET_VSCREENINFO");
+			}
+			close(fd);
+		} else {
+			perror(FBDEV);
+		}
+	}
 	if(vo_screenwidth && vo_screenheight){
 		aspect_save_orig(width,height);
 		aspect_save_prescale(d_width,d_height);



More information about the MPlayer-dev-eng mailing list