[MPlayer-users] [PATCH] auto-detect screen resolution with -vo mga

Jason Lunz j at falooley.org
Thu Feb 7 03:55:02 CET 2002


kinali at gmx.net said:
> it does, but you have to provide the screen resolution by
> -screenh, -screenw

I wrote the patch below to fix this. It makes the defaults for -screenh
and -screenw be detected from the framebuffer device. If there is a
problem using the framebuffer device, it falls back to the old method.
If you don't like the defaults detected by this patch, you can still
override them by using -screenh and -screenw, just like before.

I submitted this on mplayer-dev-eng but it wasn't accepted. Arpi, is
there a reason for this? Do you want me to move this stuff out of
vo_mga.c into the option parsing code? or what?

I tested this on two different mga framebuffer resolutions and it
worked. I tried it without framebuffer with -vo mga, but it was the same
as not using my patch at all: broken.

the patch is against current cvs.

Jason


Index: libvo/vo_mga.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_mga.c,v
retrieving revision 1.22
diff -u -r1.22 vo_mga.c
--- libvo/vo_mga.c	1 Feb 2002 02:43:01 -0000	1.22
+++ libvo/vo_mga.c	7 Feb 2002 02:54:13 -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
 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info)
 {
 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-users mailing list