Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial
[pandora-kernel.git] / Documentation / fb / fbcon.txt
index f3a3be0..99ea58e 100644 (file)
@@ -150,14 +150,45 @@ C. Boot options
 
 C. Attaching, Detaching and Unloading
 
-It's possible to detach/attach the framebuffer console from the vt layer by
-echoing anything to the following sysfs attributes found
-/sys/class/graphics/fbcon.
+Before going on on how to attach, detach and unload the framebuffer console, an
+illustration of the dependencies may help.
 
-          attach - attach framebuffer console to vt layer
-          detach - detach framebuffer console to vt layer
+The console layer, as with most subsystems, needs a driver that interfaces with
+the hardware. Thus, in a VGA console:
 
-If fbcon is detached from the vt layer, your boot console driver (which is
+console ---> VGA driver ---> hardware.
+
+Assuming the VGA driver can be unloaded, one must first unbind the VGA driver
+from the console layer before unloading the driver.  The VGA driver cannot be
+unloaded if it is still bound to the console layer. (See
+Documentation/console/console.txt for more information).
+
+This is more complicated in the case of the framebuffer console (fbcon),
+because fbcon is an intermediate layer between the console and the drivers:
+
+console ---> fbcon ---> fbdev drivers ---> hardware
+
+The fbdev drivers cannot be unloaded if it's bound to fbcon, and fbcon cannot
+be unloaded if it's bound to the console layer.
+
+So to unload the fbdev drivers, one must first unbind fbcon from the console,
+then unbind the fbdev drivers from fbcon.  Fortunately, unbinding fbcon from
+the console layer will automatically unbind framebuffer drivers from
+fbcon. Thus, there is no need to explicitly unbind the fbdev drivers from
+fbcon.
+
+So, how do we unbind fbcon from the console? Part of the answer is in
+Documentation/console/console.txt. To summarize:
+
+Echo a value to the bind file that represents the framebuffer console
+driver. So assuming vtcon1 represents fbcon, then:
+
+echo 1 > sys/class/vtconsole/vtcon1/bind - attach framebuffer console to
+                                           console layer
+echo 0 > sys/class/vtconsole/vtcon1/bind - detach framebuffer console from
+                                           console layer
+
+If fbcon is detached from the console layer, your boot console driver (which is
 usually VGA text mode) will take over.  A few drivers (rivafb and i810fb) will
 restore VGA text mode for you.  With the rest, before detaching fbcon, you
 must take a few additional steps to make sure that your VGA text mode is
@@ -184,26 +215,21 @@ restored properly. The following is one of the several methods that you can do:
 5. Now to detach fbcon:
 
        vbetool vbestate restore < <vga state file> && \
-       echo 1 > /sys/class/graphics/fbcon/detach
+       echo 0 > /sys/class/vtconsole/vtcon1/bind
 
-6. That's it, you're back to VGA mode. And if you compiled your drivers as
-   modules, you can unload them at will.  So if you want to change your driver
-   from xxxfb to yyyfb, you can do this:
-
-       detach fbcon
-       rmmod xxxfb
-       modprobe yyyfb
-
-       Of course, con2fbmap can do the same thing but will not work if xxxfb
-       and yyyfb are not compatible (ie, cannot be loaded at the same time).
+6. That's it, you're back to VGA mode. And if you compiled fbcon as a module,
+   you can unload it by 'rmmod fbcon'
 
 7. To reattach fbcon:
 
-       echo 1 > /sys/class/graphics/fbcon/attach
+       echo 1 > /sys/class/vtconsole/vtcon1/bind
 
-8. Once the framebuffer console is detached, and if it is compiled as a module,
-the module can be unloaded with 'rmmod fbcon'.  This feature is great for
-developers.
+8. Once fbcon is unbound, all drivers registered to the system will also
+become unbound.  This means that fbcon and individual framebuffer drivers
+can be unloaded or reloaded at will. Reloading the drivers or fbcon will
+automatically bind the console, fbcon and the drivers together. Unloading
+all the drivers without unloading fbcon will make it impossible for the
+console to bind fbcon.
 
 Notes for vesafb users:
 =======================
@@ -227,11 +253,13 @@ Variation 1:
     c. Attach fbcon
 
         vbetool vbestate restore < <vesa state file> && \
-       echo 1 > /sys/class/graphics/fbcon/attach
+       echo 1 > /sys/class/vtconsole/vtcon1/bind
 
 Variation 2:
 
     a. Before detaching fbcon, do:
+       echo <ID> > /sys/class/tty/console/bind
+
 
        vbetool vbemode get
 
@@ -242,7 +270,55 @@ Variation 2:
     c. Attach fbcon:
 
        vbetool vbemode set <mode number> && \
-       echo 1 > /sys/class/graphics/fbcon/attach
+       echo 1 > /sys/class/vtconsole/vtcon1/bind
+
+Samples:
+========
+
+Here are 2 sample bash scripts that you can use to bind or unbind the
+framebuffer console driver if you are in an X86 box:
+
+---------------------------------------------------------------------------
+#!/bin/bash
+# Unbind fbcon
+
+# Change this to where your actual vgastate file is located
+# Or Use VGASTATE=$1 to indicate the state file at runtime
+VGASTATE=/tmp/vgastate
+
+# path to vbetool
+VBETOOL=/usr/local/bin
+
+
+for (( i = 0; i < 16; i++))
+do
+  if test -x /sys/class/vtconsole/vtcon$i; then
+      if [ `cat /sys/class/vtconsole/vtcon$i/name | grep -c "frame buffer"` \
+           = 1 ]; then
+           if test -x $VBETOOL/vbetool; then
+              echo Unbinding vtcon$i
+              $VBETOOL/vbetool vbestate restore < $VGASTATE
+              echo 0 > /sys/class/vtconsole/vtcon$i/bind
+           fi
+      fi
+  fi
+done
+
+---------------------------------------------------------------------------
+#!/bin/bash
+# Bind fbcon
+
+for (( i = 0; i < 16; i++))
+do
+  if test -x /sys/class/vtconsole/vtcon$i; then
+      if [ `cat /sys/class/vtconsole/vtcon$i/name | grep -c "frame buffer"` \
+           = 1 ]; then
+         echo Unbinding vtcon$i
+         echo 1 > /sys/class/vtconsole/vtcon$i/bind
+      fi
+  fi
+done
+---------------------------------------------------------------------------
 
 --
 Antonino Daplas <adaplas@pol.net>