1*4882a593Smuzhiyun======================= 2*4882a593SmuzhiyunThe Framebuffer Console 3*4882a593Smuzhiyun======================= 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunThe framebuffer console (fbcon), as its name implies, is a text 6*4882a593Smuzhiyunconsole running on top of the framebuffer device. It has the functionality of 7*4882a593Smuzhiyunany standard text console driver, such as the VGA console, with the added 8*4882a593Smuzhiyunfeatures that can be attributed to the graphical nature of the framebuffer. 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunIn the x86 architecture, the framebuffer console is optional, and 11*4882a593Smuzhiyunsome even treat it as a toy. For other architectures, it is the only available 12*4882a593Smuzhiyundisplay device, text or graphical. 13*4882a593Smuzhiyun 14*4882a593SmuzhiyunWhat are the features of fbcon? The framebuffer console supports 15*4882a593Smuzhiyunhigh resolutions, varying font types, display rotation, primitive multihead, 16*4882a593Smuzhiyunetc. Theoretically, multi-colored fonts, blending, aliasing, and any feature 17*4882a593Smuzhiyunmade available by the underlying graphics card are also possible. 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunA. Configuration 20*4882a593Smuzhiyun================ 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunThe framebuffer console can be enabled by using your favorite kernel 23*4882a593Smuzhiyunconfiguration tool. It is under Device Drivers->Graphics Support-> 24*4882a593SmuzhiyunConsole display driver support->Framebuffer Console Support. 25*4882a593SmuzhiyunSelect 'y' to compile support statically or 'm' for module support. The 26*4882a593Smuzhiyunmodule will be fbcon. 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunIn order for fbcon to activate, at least one framebuffer driver is 29*4882a593Smuzhiyunrequired, so choose from any of the numerous drivers available. For x86 30*4882a593Smuzhiyunsystems, they almost universally have VGA cards, so vga16fb and vesafb will 31*4882a593Smuzhiyunalways be available. However, using a chipset-specific driver will give you 32*4882a593Smuzhiyunmore speed and features, such as the ability to change the video mode 33*4882a593Smuzhiyundynamically. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunTo display the penguin logo, choose any logo available in Graphics 36*4882a593Smuzhiyunsupport->Bootup logo. 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunAlso, you will need to select at least one compiled-in font, but if 39*4882a593Smuzhiyunyou don't do anything, the kernel configuration tool will select one for you, 40*4882a593Smuzhiyunusually an 8x16 font. 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunGOTCHA: A common bug report is enabling the framebuffer without enabling the 43*4882a593Smuzhiyunframebuffer console. Depending on the driver, you may get a blanked or 44*4882a593Smuzhiyungarbled display, but the system still boots to completion. If you are 45*4882a593Smuzhiyunfortunate to have a driver that does not alter the graphics chip, then you 46*4882a593Smuzhiyunwill still get a VGA console. 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunB. Loading 49*4882a593Smuzhiyun========== 50*4882a593Smuzhiyun 51*4882a593SmuzhiyunPossible scenarios: 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun1. Driver and fbcon are compiled statically 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun Usually, fbcon will automatically take over your console. The notable 56*4882a593Smuzhiyun exception is vesafb. It needs to be explicitly activated with the 57*4882a593Smuzhiyun vga= boot option parameter. 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun2. Driver is compiled statically, fbcon is compiled as a module 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun Depending on the driver, you either get a standard console, or a 62*4882a593Smuzhiyun garbled display, as mentioned above. To get a framebuffer console, 63*4882a593Smuzhiyun do a 'modprobe fbcon'. 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun3. Driver is compiled as a module, fbcon is compiled statically 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun You get your standard console. Once the driver is loaded with 68*4882a593Smuzhiyun 'modprobe xxxfb', fbcon automatically takes over the console with 69*4882a593Smuzhiyun the possible exception of using the fbcon=map:n option. See below. 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun4. Driver and fbcon are compiled as a module. 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun You can load them in any order. Once both are loaded, fbcon will take 74*4882a593Smuzhiyun over the console. 75*4882a593Smuzhiyun 76*4882a593SmuzhiyunC. Boot options 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun The framebuffer console has several, largely unknown, boot options 79*4882a593Smuzhiyun that can change its behavior. 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun1. fbcon=font:<name> 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun Select the initial font to use. The value 'name' can be any of the 84*4882a593Smuzhiyun compiled-in fonts: 10x18, 6x10, 6x8, 7x14, Acorn8x8, MINI4x6, 85*4882a593Smuzhiyun PEARL8x8, ProFont6x11, SUN12x22, SUN8x16, TER16x32, VGA8x16, VGA8x8. 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun Note, not all drivers can handle font with widths not divisible by 8, 88*4882a593Smuzhiyun such as vga16fb. 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun2. fbcon=map:<0123> 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun This is an interesting option. It tells which driver gets mapped to 94*4882a593Smuzhiyun which console. The value '0123' is a sequence that gets repeated until 95*4882a593Smuzhiyun the total length is 64 which is the number of consoles available. In 96*4882a593Smuzhiyun the above example, it is expanded to 012301230123... and the mapping 97*4882a593Smuzhiyun will be:: 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun tty | 1 2 3 4 5 6 7 8 9 ... 100*4882a593Smuzhiyun fb | 0 1 2 3 0 1 2 3 0 ... 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun ('cat /proc/fb' should tell you what the fb numbers are) 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun One side effect that may be useful is using a map value that exceeds 105*4882a593Smuzhiyun the number of loaded fb drivers. For example, if only one driver is 106*4882a593Smuzhiyun available, fb0, adding fbcon=map:1 tells fbcon not to take over the 107*4882a593Smuzhiyun console. 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun Later on, when you want to map the console the to the framebuffer 110*4882a593Smuzhiyun device, you can use the con2fbmap utility. 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun3. fbcon=vc:<n1>-<n2> 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun This option tells fbcon to take over only a range of consoles as 115*4882a593Smuzhiyun specified by the values 'n1' and 'n2'. The rest of the consoles 116*4882a593Smuzhiyun outside the given range will still be controlled by the standard 117*4882a593Smuzhiyun console driver. 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun NOTE: For x86 machines, the standard console is the VGA console which 120*4882a593Smuzhiyun is typically located on the same video card. Thus, the consoles that 121*4882a593Smuzhiyun are controlled by the VGA console will be garbled. 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun4. fbcon=rotate:<n> 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun This option changes the orientation angle of the console display. The 126*4882a593Smuzhiyun value 'n' accepts the following: 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun - 0 - normal orientation (0 degree) 129*4882a593Smuzhiyun - 1 - clockwise orientation (90 degrees) 130*4882a593Smuzhiyun - 2 - upside down orientation (180 degrees) 131*4882a593Smuzhiyun - 3 - counterclockwise orientation (270 degrees) 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun The angle can be changed anytime afterwards by 'echoing' the same 134*4882a593Smuzhiyun numbers to any one of the 2 attributes found in 135*4882a593Smuzhiyun /sys/class/graphics/fbcon: 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun - rotate - rotate the display of the active console 138*4882a593Smuzhiyun - rotate_all - rotate the display of all consoles 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun Console rotation will only become available if Framebuffer Console 141*4882a593Smuzhiyun Rotation support is compiled in your kernel. 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun NOTE: This is purely console rotation. Any other applications that 144*4882a593Smuzhiyun use the framebuffer will remain at their 'normal' orientation. 145*4882a593Smuzhiyun Actually, the underlying fb driver is totally ignorant of console 146*4882a593Smuzhiyun rotation. 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun5. fbcon=margin:<color> 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun This option specifies the color of the margins. The margins are the 151*4882a593Smuzhiyun leftover area at the right and the bottom of the screen that are not 152*4882a593Smuzhiyun used by text. By default, this area will be black. The 'color' value 153*4882a593Smuzhiyun is an integer number that depends on the framebuffer driver being used. 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun6. fbcon=nodefer 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun If the kernel is compiled with deferred fbcon takeover support, normally 158*4882a593Smuzhiyun the framebuffer contents, left in place by the firmware/bootloader, will 159*4882a593Smuzhiyun be preserved until there actually is some text is output to the console. 160*4882a593Smuzhiyun This option causes fbcon to bind immediately to the fbdev device. 161*4882a593Smuzhiyun 162*4882a593Smuzhiyun7. fbcon=logo-pos:<location> 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun The only possible 'location' is 'center' (without quotes), and when 165*4882a593Smuzhiyun given, the bootup logo is moved from the default top-left corner 166*4882a593Smuzhiyun location to the center of the framebuffer. If more than one logo is 167*4882a593Smuzhiyun displayed due to multiple CPUs, the collected line of logos is moved 168*4882a593Smuzhiyun as a whole. 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun8. fbcon=logo-count:<n> 171*4882a593Smuzhiyun 172*4882a593Smuzhiyun The value 'n' overrides the number of bootup logos. 0 disables the 173*4882a593Smuzhiyun logo, and -1 gives the default which is the number of online CPUs. 174*4882a593Smuzhiyun 175*4882a593SmuzhiyunC. Attaching, Detaching and Unloading 176*4882a593Smuzhiyun 177*4882a593SmuzhiyunBefore going on to how to attach, detach and unload the framebuffer console, an 178*4882a593Smuzhiyunillustration of the dependencies may help. 179*4882a593Smuzhiyun 180*4882a593SmuzhiyunThe console layer, as with most subsystems, needs a driver that interfaces with 181*4882a593Smuzhiyunthe hardware. Thus, in a VGA console:: 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun console ---> VGA driver ---> hardware. 184*4882a593Smuzhiyun 185*4882a593SmuzhiyunAssuming the VGA driver can be unloaded, one must first unbind the VGA driver 186*4882a593Smuzhiyunfrom the console layer before unloading the driver. The VGA driver cannot be 187*4882a593Smuzhiyununloaded if it is still bound to the console layer. (See 188*4882a593SmuzhiyunDocumentation/driver-api/console.rst for more information). 189*4882a593Smuzhiyun 190*4882a593SmuzhiyunThis is more complicated in the case of the framebuffer console (fbcon), 191*4882a593Smuzhiyunbecause fbcon is an intermediate layer between the console and the drivers:: 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun console ---> fbcon ---> fbdev drivers ---> hardware 194*4882a593Smuzhiyun 195*4882a593SmuzhiyunThe fbdev drivers cannot be unloaded if bound to fbcon, and fbcon cannot 196*4882a593Smuzhiyunbe unloaded if it's bound to the console layer. 197*4882a593Smuzhiyun 198*4882a593SmuzhiyunSo to unload the fbdev drivers, one must first unbind fbcon from the console, 199*4882a593Smuzhiyunthen unbind the fbdev drivers from fbcon. Fortunately, unbinding fbcon from 200*4882a593Smuzhiyunthe console layer will automatically unbind framebuffer drivers from 201*4882a593Smuzhiyunfbcon. Thus, there is no need to explicitly unbind the fbdev drivers from 202*4882a593Smuzhiyunfbcon. 203*4882a593Smuzhiyun 204*4882a593SmuzhiyunSo, how do we unbind fbcon from the console? Part of the answer is in 205*4882a593SmuzhiyunDocumentation/driver-api/console.rst. To summarize: 206*4882a593Smuzhiyun 207*4882a593SmuzhiyunEcho a value to the bind file that represents the framebuffer console 208*4882a593Smuzhiyundriver. So assuming vtcon1 represents fbcon, then:: 209*4882a593Smuzhiyun 210*4882a593Smuzhiyun echo 1 > sys/class/vtconsole/vtcon1/bind - attach framebuffer console to 211*4882a593Smuzhiyun console layer 212*4882a593Smuzhiyun echo 0 > sys/class/vtconsole/vtcon1/bind - detach framebuffer console from 213*4882a593Smuzhiyun console layer 214*4882a593Smuzhiyun 215*4882a593SmuzhiyunIf fbcon is detached from the console layer, your boot console driver (which is 216*4882a593Smuzhiyunusually VGA text mode) will take over. A few drivers (rivafb and i810fb) will 217*4882a593Smuzhiyunrestore VGA text mode for you. With the rest, before detaching fbcon, you 218*4882a593Smuzhiyunmust take a few additional steps to make sure that your VGA text mode is 219*4882a593Smuzhiyunrestored properly. The following is one of the several methods that you can do: 220*4882a593Smuzhiyun 221*4882a593Smuzhiyun1. Download or install vbetool. This utility is included with most 222*4882a593Smuzhiyun distributions nowadays, and is usually part of the suspend/resume tool. 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun2. In your kernel configuration, ensure that CONFIG_FRAMEBUFFER_CONSOLE is set 225*4882a593Smuzhiyun to 'y' or 'm'. Enable one or more of your favorite framebuffer drivers. 226*4882a593Smuzhiyun 227*4882a593Smuzhiyun3. Boot into text mode and as root run:: 228*4882a593Smuzhiyun 229*4882a593Smuzhiyun vbetool vbestate save > <vga state file> 230*4882a593Smuzhiyun 231*4882a593Smuzhiyun The above command saves the register contents of your graphics 232*4882a593Smuzhiyun hardware to <vga state file>. You need to do this step only once as 233*4882a593Smuzhiyun the state file can be reused. 234*4882a593Smuzhiyun 235*4882a593Smuzhiyun4. If fbcon is compiled as a module, load fbcon by doing:: 236*4882a593Smuzhiyun 237*4882a593Smuzhiyun modprobe fbcon 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun5. Now to detach fbcon:: 240*4882a593Smuzhiyun 241*4882a593Smuzhiyun vbetool vbestate restore < <vga state file> && \ 242*4882a593Smuzhiyun echo 0 > /sys/class/vtconsole/vtcon1/bind 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun6. That's it, you're back to VGA mode. And if you compiled fbcon as a module, 245*4882a593Smuzhiyun you can unload it by 'rmmod fbcon'. 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun7. To reattach fbcon:: 248*4882a593Smuzhiyun 249*4882a593Smuzhiyun echo 1 > /sys/class/vtconsole/vtcon1/bind 250*4882a593Smuzhiyun 251*4882a593Smuzhiyun8. Once fbcon is unbound, all drivers registered to the system will also 252*4882a593Smuzhiyunbecome unbound. This means that fbcon and individual framebuffer drivers 253*4882a593Smuzhiyuncan be unloaded or reloaded at will. Reloading the drivers or fbcon will 254*4882a593Smuzhiyunautomatically bind the console, fbcon and the drivers together. Unloading 255*4882a593Smuzhiyunall the drivers without unloading fbcon will make it impossible for the 256*4882a593Smuzhiyunconsole to bind fbcon. 257*4882a593Smuzhiyun 258*4882a593SmuzhiyunNotes for vesafb users: 259*4882a593Smuzhiyun======================= 260*4882a593Smuzhiyun 261*4882a593SmuzhiyunUnfortunately, if your bootline includes a vga=xxx parameter that sets the 262*4882a593Smuzhiyunhardware in graphics mode, such as when loading vesafb, vgacon will not load. 263*4882a593SmuzhiyunInstead, vgacon will replace the default boot console with dummycon, and you 264*4882a593Smuzhiyunwon't get any display after detaching fbcon. Your machine is still alive, so 265*4882a593Smuzhiyunyou can reattach vesafb. However, to reattach vesafb, you need to do one of 266*4882a593Smuzhiyunthe following: 267*4882a593Smuzhiyun 268*4882a593SmuzhiyunVariation 1: 269*4882a593Smuzhiyun 270*4882a593Smuzhiyun a. Before detaching fbcon, do:: 271*4882a593Smuzhiyun 272*4882a593Smuzhiyun vbetool vbemode save > <vesa state file> # do once for each vesafb mode, 273*4882a593Smuzhiyun # the file can be reused 274*4882a593Smuzhiyun 275*4882a593Smuzhiyun b. Detach fbcon as in step 5. 276*4882a593Smuzhiyun 277*4882a593Smuzhiyun c. Attach fbcon:: 278*4882a593Smuzhiyun 279*4882a593Smuzhiyun vbetool vbestate restore < <vesa state file> && \ 280*4882a593Smuzhiyun echo 1 > /sys/class/vtconsole/vtcon1/bind 281*4882a593Smuzhiyun 282*4882a593SmuzhiyunVariation 2: 283*4882a593Smuzhiyun 284*4882a593Smuzhiyun a. Before detaching fbcon, do:: 285*4882a593Smuzhiyun 286*4882a593Smuzhiyun echo <ID> > /sys/class/tty/console/bind 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun vbetool vbemode get 289*4882a593Smuzhiyun 290*4882a593Smuzhiyun b. Take note of the mode number 291*4882a593Smuzhiyun 292*4882a593Smuzhiyun b. Detach fbcon as in step 5. 293*4882a593Smuzhiyun 294*4882a593Smuzhiyun c. Attach fbcon:: 295*4882a593Smuzhiyun 296*4882a593Smuzhiyun vbetool vbemode set <mode number> && \ 297*4882a593Smuzhiyun echo 1 > /sys/class/vtconsole/vtcon1/bind 298*4882a593Smuzhiyun 299*4882a593SmuzhiyunSamples: 300*4882a593Smuzhiyun======== 301*4882a593Smuzhiyun 302*4882a593SmuzhiyunHere are 2 sample bash scripts that you can use to bind or unbind the 303*4882a593Smuzhiyunframebuffer console driver if you are on an X86 box:: 304*4882a593Smuzhiyun 305*4882a593Smuzhiyun #!/bin/bash 306*4882a593Smuzhiyun # Unbind fbcon 307*4882a593Smuzhiyun 308*4882a593Smuzhiyun # Change this to where your actual vgastate file is located 309*4882a593Smuzhiyun # Or Use VGASTATE=$1 to indicate the state file at runtime 310*4882a593Smuzhiyun VGASTATE=/tmp/vgastate 311*4882a593Smuzhiyun 312*4882a593Smuzhiyun # path to vbetool 313*4882a593Smuzhiyun VBETOOL=/usr/local/bin 314*4882a593Smuzhiyun 315*4882a593Smuzhiyun 316*4882a593Smuzhiyun for (( i = 0; i < 16; i++)) 317*4882a593Smuzhiyun do 318*4882a593Smuzhiyun if test -x /sys/class/vtconsole/vtcon$i; then 319*4882a593Smuzhiyun if [ `cat /sys/class/vtconsole/vtcon$i/name | grep -c "frame buffer"` \ 320*4882a593Smuzhiyun = 1 ]; then 321*4882a593Smuzhiyun if test -x $VBETOOL/vbetool; then 322*4882a593Smuzhiyun echo Unbinding vtcon$i 323*4882a593Smuzhiyun $VBETOOL/vbetool vbestate restore < $VGASTATE 324*4882a593Smuzhiyun echo 0 > /sys/class/vtconsole/vtcon$i/bind 325*4882a593Smuzhiyun fi 326*4882a593Smuzhiyun fi 327*4882a593Smuzhiyun fi 328*4882a593Smuzhiyun done 329*4882a593Smuzhiyun 330*4882a593Smuzhiyun--------------------------------------------------------------------------- 331*4882a593Smuzhiyun 332*4882a593Smuzhiyun:: 333*4882a593Smuzhiyun 334*4882a593Smuzhiyun #!/bin/bash 335*4882a593Smuzhiyun # Bind fbcon 336*4882a593Smuzhiyun 337*4882a593Smuzhiyun for (( i = 0; i < 16; i++)) 338*4882a593Smuzhiyun do 339*4882a593Smuzhiyun if test -x /sys/class/vtconsole/vtcon$i; then 340*4882a593Smuzhiyun if [ `cat /sys/class/vtconsole/vtcon$i/name | grep -c "frame buffer"` \ 341*4882a593Smuzhiyun = 1 ]; then 342*4882a593Smuzhiyun echo Unbinding vtcon$i 343*4882a593Smuzhiyun echo 1 > /sys/class/vtconsole/vtcon$i/bind 344*4882a593Smuzhiyun fi 345*4882a593Smuzhiyun fi 346*4882a593Smuzhiyun done 347*4882a593Smuzhiyun 348*4882a593SmuzhiyunAntonino Daplas <adaplas@pol.net> 349