起因
最近在目標平台上移植 DirectFB,需要先用 Virtual framebuffer (虛擬幀緩衝) 進行測試,才能開始開發gfx device & gfx driver
需求
根據 directFb 官方 readme
至少會需要 /dev/fb0 , /dev/tty0, /dev/psaux or /dev/mouse
Usage Requirements
------------------
Depending on the DirectFB application you want to run, you need some
or all of these:
- A working frame buffer device (check the output of 'fbset -i').
- A keyboard (if it works on the console, everything should be fine).
- A PS/2 or serial mouse for windowing. USB and ADB mice do also work
via PS/2 emulation.
Using the single application core you always need access to /dev/tty0,
/dev/fb0 and the mouse device (/dev/psaux, /dev/mouse).
也就是最低需要以下權限
crw-rw---- 1 root tty 29, 0 /dev/fb0
crw-rw---- 1 root tty 10, 1 /dev/psaux
crw-r----- 1 root tty 4, 0 /dev/tty0
DirectFB source code
這裡以buildroot 進行舉例
- enable directfb
Target packages --> Graphic libraries and applications (graphic & text) --> directFb
- enable framebuffer tools (這些工具是linux 自帶的,可以用於檢查 /dev/fb0)
Target packages --> Graphic libraries and applications (graphic & text) --> fbdump
Target packages --> Graphic libraries and applications (graphic & text) --> fbset
linux kernel configs
frame buffer
同時需要搭配boot option
bootargs = {...... video=vfb\0}
USB mouse / keyboard
Device Drivers > HID support > USB HID support > USB HID Boot Protocol drivers > USB HIDBP Keyboard support
Device Drivers > HID support > USB HID support > USB HID Boot Protocol drivers > USB HIDBP Mouse support
>>> 只開這兩個就會有 /dev/psaux
Device Drivers > USB support > <*> Support for Host-side USB
Device Drivers > USB support > DWC2 Mode Selection (Host only mode) > Host only mode
Device Drivers > Input device support > <*> Generic input layer (needed for keyboard, mouse, ...)
Device Drivers > Input device support > <*>Event interface
>>> 開到這邊才會有 /dev/input/event1 /dev/input/mouse1
Virtual terminal
Device Drivers --> Character device -->Enable TTY --> virtual terminal
Frame buffer tools
> Device Drivers > Graphics support > Frame buffer Devices > Virtual Frame Buffer support (ONLY FOR TESTING!)