Hi,

attached is a patch that makes it possible to specify the TTY to run 
on when using the fbdev system. If vt-switch option is on, DFB will 
switch to the given TTY instead of the first available with this 
patch applied; if vt-switch is off, it will use (but not switch to) 
the given TTY instead of the current one.

The motivation for this patch is that I need to run some apps 
on /dev/fb0 and control them from /dev/tty1 and some apps 
on /dev/fb1+/dev/tty3 and so some means of forcing the app to run on 
specified TTY was needed (in addition to fbdev and session options) 
to make this work.

Let me know if you want any changes to the patch made (maybe 
using "vt-tty" instead of "tty" for the option?).

Thanks,
Vaclav

-- 
PGP key: 0x465264C9, available from http://pgp.mit.edu/
Index: src/misc/conf.c
===================================================================
RCS file: /cvs/directfb/DirectFB/src/misc/conf.c,v
retrieving revision 1.122
diff -u -u -r1.122 conf.c
--- src/misc/conf.c	18 Nov 2006 10:45:14 -0000	1.122
+++ src/misc/conf.c	20 Dec 2006 10:15:39 -0000
@@ -99,6 +99,7 @@
      "  [no-]deinit-check              Enable deinit check at exit\n"
      "  block-all-signals              Block all signals\n"
      "  [no-]vt-switch                 Allocate/switch to a new VT\n"
+     "  tty=<num>                      Use given VT instead of current/new one\n"
      "  [no-]vt-switching              Allow Ctrl+Alt+<F?> (EXPERIMENTAL)\n"
      "  [no-]graphics-vt               Put terminal into graphics mode\n"
      "  [no-]vt                        Use VT handling code at all?\n"
@@ -340,6 +341,7 @@
      dfb_config->mmx                      = true;
      dfb_config->vt                       = true;
      dfb_config->vt_switch                = true;
+     dfb_config->tty                      = -1;
      dfb_config->vt_switching             = true;
      dfb_config->kd_graphics              = true;
      dfb_config->translucent_windows      = true;
@@ -866,6 +868,22 @@
      if (strcmp (name, "no-vt-switch" ) == 0) {
           dfb_config->vt_switch = false;
      } else
+     if (strcmp (name, "tty" ) == 0) {
+          if (value) {
+               int tty;
+
+               if (sscanf( value, "%d", &tty ) < 1) {
+                    D_ERROR("DirectFB/Config 'tty': Could not parse value!\n");
+                    return DFB_INVARG;
+               }
+
+               dfb_config->tty = tty;
+          }
+          else {
+               D_ERROR("DirectFB/Config 'tty': No value specified!\n");
+               return DFB_INVARG;
+          }
+     } else
      if (strcmp (name, "vt-switching" ) == 0) {
           dfb_config->vt_switching = true;
      } else
Index: src/misc/conf.h
===================================================================
RCS file: /cvs/directfb/DirectFB/src/misc/conf.h,v
retrieving revision 1.66
diff -u -u -r1.66 conf.h
--- src/misc/conf.h	18 Nov 2006 10:45:14 -0000	1.66
+++ src/misc/conf.h	20 Dec 2006 10:15:39 -0000
@@ -67,6 +67,8 @@
      bool      deinit_check;
 
      bool      vt_switch;                         /* allocate a new VT */
+     int       tty;                               /* number of TTY to use or -1
+                                                     if the default */
      bool      kd_graphics;                       /* put terminal into graphics
                                                      mode */
 
Index: systems/fbdev/vt.c
===================================================================
RCS file: /cvs/directfb/DirectFB/systems/fbdev/vt.c,v
retrieving revision 1.6
diff -u -u -r1.6 vt.c
--- systems/fbdev/vt.c	28 Oct 2006 13:35:54 -0000	1.6
+++ systems/fbdev/vt.c	20 Dec 2006 10:15:39 -0000
@@ -146,22 +146,30 @@
 
 
      if (!dfb_config->vt_switch) {
-          dfb_vt->num = dfb_vt->prev;
+          if (dfb_config->tty != -1)
+               dfb_vt->num = dfb_config->tty;
+          else
+               dfb_vt->num = dfb_vt->prev;
 
           /* move vt to framebuffer */
           dfb_vt->old_fb = vt_get_fb( dfb_vt->num );
           vt_set_fb( dfb_vt->num, -1 );
      }
      else {
-          int n;
+          if (dfb_config->tty == -1) {
+               int n;
 
-          n = ioctl( dfb_vt->fd0, VT_OPENQRY, &dfb_vt->num );
-          if (n < 0 || dfb_vt->num == -1) {
-               D_PERROR( "DirectFB/core/vt: Cannot allocate VT!\n" );
-               close( dfb_vt->fd0 );
-               D_FREE( dfb_vt );
-               dfb_vt = NULL;
-               return DFB_INIT;
+               n = ioctl( dfb_vt->fd0, VT_OPENQRY, &dfb_vt->num );
+               if (n < 0 || dfb_vt->num == -1) {
+                    D_PERROR( "DirectFB/core/vt: Cannot allocate VT!\n" );
+                    close( dfb_vt->fd0 );
+                    D_FREE( dfb_vt );
+                    dfb_vt = NULL;
+                    return DFB_INIT;
+               }
+          }
+          else {
+               dfb_vt->num = dfb_config->tty;
           }
 
           /* move vt to framebuffer */

Attachment: pgpd54Dnrp30b.pgp
Description: PGP signature

_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to