Documentation/fb/fbcon.rst GitHub 원문 ↗

Linux 6.18.37 · Frame Buffer

The Framebuffer Console

Framebuffer console 구성, boot option, driver mapping, attach/detach와 VGA/VESA 복구의 한국어 전문 번역입니다.

Source pathDocumentation/fb/fbcon.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

fbcon.rst:1-354

`fbcon`은 fbdev 위의 text console layer입니다. Kernel 구성, built-in/module load 순서, virtual console mapping, rotation과 logo option, sysfs attach/detach 및 VGA/VESA state 복원 절차를 제공합니다.

안전한 unload의 핵심은 `console -> fbcon -> fbdev -> hardware` 의존 순서를 거꾸로 해제하는 것입니다. Console에서 fbcon을 unbind하면 fbdev driver도 자동으로 풀립니다.

fbcon 운영 lifecycle
Enable fbcon, fbdev driver and fontLoad built-in/module componentsApply boot mapping and rotation optionsBind console -> fbcon -> fbdevRestore VGA/VESA state before detachUnbind or reload as needed

구성부터 안전한 detach와 재연결까지의 핵심 흐름입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Framebuffer console 개요와 기능

1-18

Framebuffer console(`fbcon`)은 framebuffer device 위에서 동작하는 text console입니다. VGA console 같은 표준 text console driver의 기능에 framebuffer의 graphics 특성을 활용한 기능을 더합니다.

x86에서는 framebuffer console이 선택 사항이고 단순한 부가 기능으로 취급되기도 하지만, 다른 architecture에서는 text와 graphics를 포함해 사용할 수 있는 유일한 display device인 경우가 있습니다.

`fbcon`은 high resolution, 다양한 font, display rotation, 기초적인 multihead 등을 지원합니다. 이론적으로는 underlying graphics card가 제공하는 multi-colored font, blending, aliasing 같은 기능도 구현할 수 있습니다.

fbcon 역할
기능
Console표준 text console 동작
FramebufferHigh resolution과 graphics memory
fbcon 확장Font, rotation, primitive multihead
잠재 기능Color font, blending, aliasing

=======================
The Framebuffer Console
=======================

The framebuffer console (fbcon), as its name implies, is a text
console running on top of the framebuffer device. It has the functionality of
any standard text console driver, such as the VGA console, with the added
features that can be attributed to the graphical nature of the framebuffer.

In the x86 architecture, the framebuffer console is optional, and
some even treat it as a toy. For other architectures, it is the only available
display device, text or graphical.

What are the features of fbcon?  The framebuffer console supports
high resolutions, varying font types, display rotation, primitive multihead,
etc. Theoretically, multi-colored fonts, blending, aliasing, and any feature
made available by the underlying graphics card are also possible.

Kernel configuration과 필수 구성 요소

19-49

Kernel configuration의 `Device Drivers -> Graphics Support -> Console display driver support -> Framebuffer Console Support`에서 framebuffer console을 활성화합니다. `y`는 built-in, `m`은 module이며 module 이름은 `fbcon`입니다.

`fbcon`이 활성화되려면 framebuffer driver가 최소 하나 필요합니다. x86에서는 `vga16fb`와 `vesafb`를 사용할 수 있지만 chipset-specific driver가 더 빠르고 runtime video mode 변경 같은 추가 기능을 제공합니다.

Boot penguin logo는 `Graphics support -> Bootup logo`에서 선택합니다. Built-in font도 하나 이상 필요하며 아무것도 고르지 않으면 configuration tool이 보통 8x16 font를 선택합니다.

Framebuffer만 활성화하고 framebuffer console을 빠뜨리는 것이 흔한 문제입니다. Driver에 따라 화면이 blank 또는 깨진 상태가 되더라도 system은 boot를 완료합니다. Graphics chip을 변경하지 않는 driver라면 VGA console이 계속 보일 수도 있습니다.

fbcon 구성
Enable Framebuffer Console SupportBuild as `y` or module `fbcon`Enable at least one fbdev driverPrefer chipset-specific driver when availableCompile at least one fontOptionally enable boot logo

Console이 실제로 표시되려면 fbcon 외에도 framebuffer driver와 font가 필요합니다.

A. Configuration
================

The framebuffer console can be enabled by using your favorite kernel
configuration tool.  It is under Device Drivers->Graphics Support->
Console display driver support->Framebuffer Console Support.
Select 'y' to compile support statically or 'm' for module support.  The
module will be fbcon.

In order for fbcon to activate, at least one framebuffer driver is
required, so choose from any of the numerous drivers available. For x86
systems, they almost universally have VGA cards, so vga16fb and vesafb will
always be available. However, using a chipset-specific driver will give you
more speed and features, such as the ability to change the video mode
dynamically.

To display the penguin logo, choose any logo available in Graphics
support->Bootup logo.

Also, you will need to select at least one compiled-in font, but if
you don't do anything, the kernel configuration tool will select one for you,
usually an 8x16 font.

.. admonition:: GOTCHA

   A common bug report is enabling the framebuffer without enabling the
   framebuffer console.  Depending on the driver, you may get a blanked or
   garbled display, but the system still boots to completion.  If you are
   fortunate to have a driver that does not alter the graphics chip, then you
   will still get a VGA console.

Built-in과 module 조합별 takeover

50-77

Driver와 `fbcon`이 모두 built-in이면 보통 `fbcon`이 console을 자동 takeover합니다. 대표적인 예외인 `vesafb`는 `vga=` boot option으로 명시적으로 활성화해야 합니다.

Driver는 built-in이고 `fbcon`이 module이면 driver에 따라 표준 console 또는 깨진 화면이 나타납니다. `modprobe fbcon`을 실행하면 framebuffer console을 사용할 수 있습니다.

Driver가 module이고 `fbcon`이 built-in이면 처음에는 표준 console이 유지됩니다. `modprobe xxxfb`로 driver를 load하면 `fbcon=map:n`의 영향이 없는 한 `fbcon`이 자동 takeover합니다.

Driver와 `fbcon`이 모두 module이면 어느 순서로든 load할 수 있으며, 둘 다 load되는 시점에 `fbcon`이 console을 takeover합니다.

fbcon load 조합
Fbdev driverfbcon결과
Built-inBuilt-in자동 takeover, vesafb는 `vga=` 필요
Built-inModule`modprobe fbcon` 후 takeover
ModuleBuilt-in`modprobe xxxfb` 후 takeover
ModuleModule둘 다 load되면 takeover

B. Loading
==========

Possible scenarios:

1. Driver and fbcon are compiled statically

         Usually, fbcon will automatically take over your console. The notable
         exception is vesafb.  It needs to be explicitly activated with the
         vga= boot option parameter.

2. Driver is compiled statically, fbcon is compiled as a module

         Depending on the driver, you either get a standard console, or a
         garbled display, as mentioned above.  To get a framebuffer console,
         do a 'modprobe fbcon'.

3. Driver is compiled as a module, fbcon is compiled statically

         You get your standard console.  Once the driver is loaded with
         'modprobe xxxfb', fbcon automatically takes over the console with
         the possible exception of using the fbcon=map:n option. See below.

4. Driver and fbcon are compiled as a module.

         You can load them in any order. Once both are loaded, fbcon will take
         over the console.

Font, map, VC, rotation과 logo boot option

78-179

`fbcon=font:<name>`은 초기 font를 선택합니다. 사용할 수 있는 built-in font는 `10x18`, `6x10`, `6x8`, `7x14`, `Acorn8x8`, `MINI4x6`, `PEARL8x8`, `ProFont6x11`, `SUN12x22`, `SUN8x16`, `TER16x32`, `VGA8x16`, `VGA8x8`입니다. `vga16fb`처럼 width가 8의 배수가 아닌 font를 처리하지 못하는 driver도 있습니다.

`fbcon=map:<0123>`은 각 virtual console에 mapping할 framebuffer driver 번호 sequence를 지정합니다. Sequence는 사용 가능한 console 수인 64자리까지 반복됩니다. 예를 들어 `0123`은 tty1~tty4를 fb0~fb3에 대응시키고 이후 반복합니다. Framebuffer 번호는 `cat /proc/fb`로 확인합니다.

Load된 fb driver 수보다 큰 map 값을 사용하면 takeover를 막을 수 있습니다. 예를 들어 fb0만 있을 때 `fbcon=map:1`을 주면 `fbcon`이 console을 takeover하지 않습니다. 나중에 `con2fbmap` utility로 console을 framebuffer device에 mapping할 수 있습니다.

`fbcon=vc:<n1>-<n2>`는 지정된 virtual console 범위만 takeover하고 나머지는 표준 console driver에 남깁니다. x86에서 표준 VGA console이 같은 video card를 사용하면 VGA가 담당하는 console 화면이 깨질 수 있습니다.

`fbcon=rotate:<n>`은 orientation을 바꿉니다. 0은 0도, 1은 clockwise 90도, 2는 180도, 3은 counterclockwise 270도입니다. 이후 `/sys/class/graphics/fbcon/rotate`에 쓰면 active console, `rotate_all`에 쓰면 모든 console을 회전합니다.

Console rotation은 kernel에 Framebuffer Console Rotation support가 built-in된 경우만 사용할 수 있습니다. 이는 console만 회전하며 framebuffer를 사용하는 다른 application과 underlying fb driver의 orientation은 그대로입니다.

`fbcon=margin:<color>`는 text가 사용하지 않는 화면 오른쪽과 아래 margin의 색을 정합니다. 기본은 black이며 정수 color 값의 의미는 framebuffer driver에 따라 달라집니다.

Deferred fbcon takeover가 활성화된 kernel은 실제 console text가 출력될 때까지 firmware/bootloader가 남긴 framebuffer를 보존합니다. `fbcon=nodefer`는 기다리지 않고 즉시 fbdev device에 bind합니다.

`fbcon=logo-pos:center`는 boot logo 또는 여러 CPU logo의 전체 line을 기본 top-left에서 framebuffer 중앙으로 옮깁니다. `fbcon=logo-count:<n>`은 logo 수를 override하며 0은 비활성화, -1은 online CPU 수인 기본값입니다.

`fbcon=map:0123` 구조화 mapping
Virtual consoletty1tty2tty3tty4tty5tty6tty7tty8
Framebufferfb0fb1fb2fb3fb0fb1fb2fb3

원문의 두 줄 ASCII mapping을 반복 pattern 표로 다시 구성했습니다.

C. Boot options
===============

         The framebuffer console has several, largely unknown, boot options
         that can change its behavior.

1. fbcon=font:<name>

        Select the initial font to use. The value 'name' can be any of the
        compiled-in fonts: 10x18, 6x10, 6x8, 7x14, Acorn8x8, MINI4x6,
        PEARL8x8, ProFont6x11, SUN12x22, SUN8x16, TER16x32, VGA8x16, VGA8x8.

        Note, not all drivers can handle font with widths not divisible by 8,
        such as vga16fb.


2. fbcon=map:<0123>

        This is an interesting option. It tells which driver gets mapped to
        which console. The value '0123' is a sequence that gets repeated until
        the total length is 64 which is the number of consoles available. In
        the above example, it is expanded to 012301230123... and the mapping
        will be::

                tty | 1 2 3 4 5 6 7 8 9 ...
                fb  | 0 1 2 3 0 1 2 3 0 ...

                ('cat /proc/fb' should tell you what the fb numbers are)

        One side effect that may be useful is using a map value that exceeds
        the number of loaded fb drivers. For example, if only one driver is
        available, fb0, adding fbcon=map:1 tells fbcon not to take over the
        console.

        Later on, when you want to map the console the to the framebuffer
        device, you can use the con2fbmap utility.

3. fbcon=vc:<n1>-<n2>

        This option tells fbcon to take over only a range of consoles as
        specified by the values 'n1' and 'n2'. The rest of the consoles
        outside the given range will still be controlled by the standard
        console driver.

        .. note::
           For x86 machines, the standard console is the VGA console which
           is typically located on the same video card.  Thus, the consoles that
           are controlled by the VGA console will be garbled.

4. fbcon=rotate:<n>

        This option changes the orientation angle of the console display. The
        value 'n' accepts the following:

            - 0 - normal orientation (0 degree)
            - 1 - clockwise orientation (90 degrees)
            - 2 - upside down orientation (180 degrees)
            - 3 - counterclockwise orientation (270 degrees)

        The angle can be changed anytime afterwards by 'echoing' the same
        numbers to any one of the 2 attributes found in
        /sys/class/graphics/fbcon:

                - rotate     - rotate the display of the active console
                - rotate_all - rotate the display of all consoles

        Console rotation will only become available if Framebuffer Console
        Rotation support is compiled in your kernel.

        .. note::
           This is purely console rotation.  Any other applications that
           use the framebuffer will remain at their 'normal' orientation.
           Actually, the underlying fb driver is totally ignorant of console
           rotation.

5. fbcon=margin:<color>

        This option specifies the color of the margins. The margins are the
        leftover area at the right and the bottom of the screen that are not
        used by text. By default, this area will be black. The 'color' value
        is an integer number that depends on the framebuffer driver being used.

6. fbcon=nodefer

        If the kernel is compiled with deferred fbcon takeover support, normally
        the framebuffer contents, left in place by the firmware/bootloader, will
        be preserved until there actually is some text is output to the console.
        This option causes fbcon to bind immediately to the fbdev device.

7. fbcon=logo-pos:<location>

        The only possible 'location' is 'center' (without quotes), and when
        given, the bootup logo is moved from the default top-left corner
        location to the center of the framebuffer. If more than one logo is
        displayed due to multiple CPUs, the collected line of logos is moved
        as a whole.

8. fbcon=logo-count:<n>

        The value 'n' overrides the number of bootup logos. 0 disables the
        logo, and -1 gives the default which is the number of online CPUs.

Console, fbcon, fbdev 의존 관계와 bind

180-220

Console layer는 hardware와 interface하는 driver가 필요합니다. VGA console의 기본 경로는 `console -> VGA driver -> hardware`입니다. VGA driver를 unload할 수 있다고 가정해도 먼저 console layer에서 unbind해야 하며, bind된 상태에서는 unload할 수 없습니다. 자세한 내용은 `Documentation/driver-api/console.rst`를 참조합니다.

Framebuffer console에서는 `fbcon`이 console과 fbdev driver 사이의 중간 layer이므로 경로가 `console -> fbcon -> fbdev drivers -> hardware`가 됩니다.

Fbdev driver는 `fbcon`에 bind된 상태에서 unload할 수 없고, `fbcon`도 console layer에 bind된 상태에서는 unload할 수 없습니다. 따라서 console에서 `fbcon`을 먼저 unbind해야 합니다. 이 작업은 fbdev driver도 `fbcon`에서 자동 unbind하므로 driver별 추가 unbind는 필요하지 않습니다.

`vtcon1`이 fbcon이라고 가정하면 `/sys/class/vtconsole/vtcon1/bind`에 1을 쓰면 console layer에 attach하고 0을 쓰면 detach합니다.

Console dependency
VGA path: console -> VGA driver -> hardwareFramebuffer path: console -> fbcon -> fbdev drivers -> hardwareDetach console from fbcon firstFbdev drivers are then unbound automaticallyUnload fbdev drivers or fbcon

원문의 두 ASCII 의존 관계를 layer flow로 다시 구성했습니다.

D. Attaching, Detaching and Unloading
=====================================

Before going on to how to attach, detach and unload the framebuffer console, an
illustration of the dependencies may help.

The console layer, as with most subsystems, needs a driver that interfaces with
the hardware. Thus, in a VGA console::

        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/driver-api/console.rst 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 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/driver-api/console.rst. 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

VGA state 복원, detach와 module unload

221-263

`fbcon`을 console layer에서 detach하면 보통 VGA text mode인 boot console driver가 takeover합니다. `rivafb`와 `i810fb`는 VGA text mode를 복원하지만, 다른 driver에서는 detach 전에 VGA state를 직접 복원해야 합니다.

먼저 대부분 distribution의 suspend/resume 도구에 포함된 `vbetool`을 설치합니다. Kernel에서 `CONFIG_FRAMEBUFFER_CONSOLE`을 `y` 또는 `m`으로 설정하고 framebuffer driver를 하나 이상 활성화합니다.

Text mode로 boot한 뒤 root로 `vbetool vbestate save > <vga state file>`을 한 번 실행해 graphics register를 저장합니다. State file은 재사용할 수 있습니다.

`fbcon`이 module이면 `modprobe fbcon`으로 load합니다. Detach할 때 `vbetool vbestate restore < <vga state file>`로 VGA state를 복원한 뒤 `/sys/class/vtconsole/vtcon1/bind`에 0을 씁니다. Module은 `rmmod fbcon`으로 unload할 수 있습니다.

다시 attach하려면 bind file에 1을 씁니다. `fbcon`이 unbind되면 등록된 모든 framebuffer driver도 unbind되어 자유롭게 unload/reload할 수 있습니다. Driver나 `fbcon`을 reload하면 console chain이 자동 bind됩니다. `fbcon`은 남겨 둔 채 모든 framebuffer driver를 unload하면 console이 `fbcon`에 bind할 수 없습니다.

안전한 fbcon detach
Save VGA state once with `vbetool`Load fbcon when modularRestore VGA stateWrite 0 to vtconsole bindOptionally `rmmod fbcon`Write 1 to reattach

Graphics register state를 보존한 뒤 console chain을 해제합니다.

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
restored properly. The following is one of the several methods that you can do:

1. Download or install vbetool.  This utility is included with most
   distributions nowadays, and is usually part of the suspend/resume tool.

2. In your kernel configuration, ensure that CONFIG_FRAMEBUFFER_CONSOLE is set
   to 'y' or 'm'. Enable one or more of your favorite framebuffer drivers.

3. Boot into text mode and as root run::

        vbetool vbestate save > <vga state file>

   The above command saves the register contents of your graphics
   hardware to <vga state file>.  You need to do this step only once as
   the state file can be reused.

4. If fbcon is compiled as a module, load fbcon by doing::

       modprobe fbcon

5. Now to detach fbcon::

       vbetool vbestate restore < <vga state file> && \
       echo 0 > /sys/class/vtconsole/vtcon1/bind

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/vtconsole/vtcon1/bind

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.

vesafb에서 detach 후 화면 복구

264-304

Boot line의 `vga=xxx`가 `vesafb`를 load하면서 hardware를 graphics mode로 설정하면 `vgacon`이 load되지 않습니다. `vgacon`은 기본 boot console을 `dummycon`으로 바꾸므로 `fbcon` detach 후 display가 사라집니다. System은 계속 실행 중이므로 `vesafb`를 다시 attach할 수 있습니다.

Variation 1에서는 mode마다 한 번 `vbetool vbemode save > <vesa state file>`로 VESA state를 저장하고, 일반 절차로 `fbcon`을 detach합니다. Reattach할 때 VESA state를 복원하고 vtconsole bind에 1을 씁니다.

Variation 2에서는 detach 전에 `<ID>`를 `/sys/class/tty/console/bind`에 쓰고 `vbetool vbemode get`으로 mode number를 기록합니다. Reattach할 때 `vbetool vbemode set <mode number>`를 실행한 뒤 vtconsole bind에 1을 씁니다.

vesafb 재연결 방법
방법Detach 전 저장Attach 전 복원
Variation 1`vbetool vbemode save``vbetool vbestate restore`
Variation 2Console ID bind 후 `vbemode get``vbemode set <mode number>`

Notes for vesafb users:
=======================

Unfortunately, if your bootline includes a vga=xxx parameter that sets the
hardware in graphics mode, such as when loading vesafb, vgacon will not load.
Instead, vgacon will replace the default boot console with dummycon, and you
won't get any display after detaching fbcon. Your machine is still alive, so
you can reattach vesafb. However, to reattach vesafb, you need to do one of
the following:

Variation 1:

    a. Before detaching fbcon, do::

        vbetool vbemode save > <vesa state file> # do once for each vesafb mode,
                                                 # the file can be reused

    b. Detach fbcon as in step 5.

    c. Attach fbcon::

        vbetool vbestate restore < <vesa state file> && \
        echo 1 > /sys/class/vtconsole/vtcon1/bind

Variation 2:

    a. Before detaching fbcon, do::

        echo <ID> > /sys/class/tty/console/bind

        vbetool vbemode get

    b. Take note of the mode number

    b. Detach fbcon as in step 5.

    c. Attach fbcon::

        vbetool vbemode set <mode number> && \
        echo 1 > /sys/class/vtconsole/vtcon1/bind

X86 bind/unbind sample script

305-354

첫 번째 bash script는 X86에서 `vtcon0`부터 `vtcon15`까지 순회하며 존재하는 vtconsole의 `name`에 `frame buffer`가 포함되는지 검사합니다. `vbetool`이 실행 가능하면 저장된 `VGASTATE`를 복원하고 해당 `bind` file에 0을 써서 framebuffer console을 unbind합니다.

`VGASTATE`는 실제 VGA state file 위치로 바꾸거나 runtime argument를 받도록 수정할 수 있고, `VBETOOL`은 `vbetool` executable 경로입니다.

두 번째 script도 같은 방식으로 framebuffer vtconsole을 찾고 `bind` file에 1을 써서 attach합니다. 원문 script의 message는 bind 동작에서도 `Unbinding vtcon$i`라고 출력하므로 code는 그대로 보존합니다.

Sample script 동작
Loop vtcon0..vtcon15Check vtconsole existsMatch name containing `frame buffer`Unbind: restore VGA state and write 0Bind: write 1

Sysfs name으로 framebuffer console을 식별해 state 복원과 bind 값을 자동화합니다.

Samples:
========

Here are 2 sample bash scripts that you can use to bind or unbind the
framebuffer console driver if you are on 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 <[email protected]>