fbcon总结

来源:互联网 发布:淘宝买万艾可处方单 编辑:程序博客网 时间:2024/06/03 12:28
图形显示的driver 一般分为两类,一类是drm,一类是fbcon。
如果是drm的话,一般是console ---> VGA driver ---> hardware.
如果是fbcon的话,则是console ---> fbcon ---> fbdev drivers ---> hardware。
我们这里以fbcon 为例。fbcon的话一定对应一个fbdev drivers,个人的理解是fbdev driver 有分为kernel 提供framebuffer和 uefi 提供framebuffer,这里以uefi提供framebuffer为例,在这种case下必须enable CONFIG_FB_EFI
如果要debug的话,一般先看在dev下是否生产fb device
      0 = /dev/fb0    First frame buffer
      1 = /dev/fb1    Second frame buffer
      ...
     31 = /dev/fb31    32nd frame buffer
fb device 目前看起来最多有32个,这个/dev/fb 是read和write的。cp /dev/fb0 myfile。这样可以把当前显示的内容v保存在myfile中,繁殖既然.

如果已经产生/dev/fbn的话,可以通过下面的命令查看当前的console是bind到哪个设备上面
cat /sys/class/vtconsole/vtcon0/name
    (S) VGA+

        '(S)' stands for a (S)ystem driver, ie, it cannot be directly
        commanded to bind or unbind

        'VGA+' is the name of the driver

    cat /sys/class/vtconsole/vtcon1/name
    (M) frame buffer device

        In this case, '(M)' stands for a (M)odular driver, one that can be
        directly commanded to bind or unbind.
例如,vtcon1就是bind到 frame buffer device。
        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)
这里需要注意的是fb0 对应的是tty1,这样即使你传递的console=tty0,但是用tty看到当前是tty1的话,就是这个道理.
如果有多个dev/fb device的话,可以通过下面的code切换fbcon用那个frambuffer
# 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
---------------------------------------------------------------------------


0 0