[MPlayer-dev-eng] [PATCH] 1/5 Add vtswitch_init/vtswitch_uninit

Alan Curry pacman at theworld.com
Thu Apr 20 03:46:02 CEST 2006


The current code in mplayer related to VT switching is a couple of KDSETMODE
ioctls. (Setting KD_GRAPHICS disables switching, which prevents the ugliness
of switching to another VT and having mplayer continue to draw movie frames
on top of a tty that you're trying to use.) This patch moves those into a new
pair of functions vtswitch_init/vtswitch_uninit, which will soon contain more
initialization code.

While I'm working on the KDSETMODEs, I also save and restore the original
mode, instead of assuming that it was KD_TEXT. The call to vtswitch_init() is
done from preinit instead of config (where the KD_GRAPHICS setting used to
be) since it only needs to be done once.

--- libvo/vo_fbdev.c.orig	2006-04-11 18:31:33.000000000 -0500
+++ libvo/vo_fbdev.c	2006-04-18 14:31:52.000000000 -0500
@@ -544,6 +544,9 @@
 static FILE *vt_fp = NULL;
 static int vt_doit = 1;
 
+/* vt-switching variables */
+static int orig_kdmode;
+
 /* vo_fbdev related variables */
 static int fb_dev_fd;
 static int fb_tty_fd = -1;
@@ -646,6 +649,32 @@
   return cmap;
 }
 
+static void vtswitch_init(void)
+{
+	if (fb_tty_fd < 0)
+		return;
+
+	if (ioctl(fb_tty_fd, KDGETMODE, &orig_kdmode) < 0) {
+		mp_msg(MSGT_VO, MSGL_V, "Can't get graphics mode: %s\n", strerror(errno));
+		close(fb_tty_fd);
+		fb_tty_fd = -1;
+		return;
+	}
+	if (ioctl(fb_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) {
+		mp_msg(MSGT_VO, MSGL_V, "Can't set graphics mode: %s\n", strerror(errno));
+		close(fb_tty_fd);
+		fb_tty_fd = -1;
+		return;
+	}
+}
+
+static void vtswitch_uninit(void)
+{
+	if (fb_tty_fd >= 0) {
+		if (ioctl(fb_tty_fd, KDSETMODE, orig_kdmode) < 0)
+			mp_msg(MSGT_VO, MSGL_WARN, "Can't restore text mode: %s\n", strerror(errno));
+	}
+}
 
 static int fb_preinit(int reset)
 {
@@ -695,6 +724,8 @@
 		}
 		fb_bpp = vo_dbpp;		
 	}
+
+	vtswitch_init();
 	
 	if (!fb_mode_cfgfile)
 	    fb_mode_cfgfile = strdup("/etc/fb.modes");
@@ -863,12 +894,6 @@
 	fb_vinfo.xres_virtual = fb_vinfo.xres;
 	fb_vinfo.yres_virtual = fb_vinfo.yres;
 
-        if (fb_tty_fd >= 0 && ioctl(fb_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) {
-                mp_msg(MSGT_VO, MSGL_V, "Can't set graphics mode: %s\n", strerror(errno));
-                close(fb_tty_fd);
-                fb_tty_fd = -1;
-        }
-
 	if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) {
 		mp_msg(MSGT_VO, MSGL_ERR, "Can't put VSCREENINFO: %s\n", strerror(errno));
                 if (fb_tty_fd >= 0 && ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0) {
@@ -1110,10 +1135,7 @@
 	fb_orig_vinfo.yoffset = fb_vinfo.yoffset;
 	if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo))
 		mp_msg(MSGT_VO, MSGL_WARN, "Can't reset original fb_var_screeninfo: %s\n", strerror(errno));
-        if (fb_tty_fd >= 0) {
-                if (ioctl(fb_tty_fd, KDSETMODE, KD_TEXT) < 0)
-                        mp_msg(MSGT_VO, MSGL_WARN, "Can't restore text mode: %s\n", strerror(errno));
-        }
+	vtswitch_uninit();
 	if (vt_doit)
 		vt_set_textarea(0, fb_orig_vinfo.yres);
         close(fb_tty_fd);




More information about the MPlayer-dev-eng mailing list