Tina平台使用DirectFB

Tina SDK支持DirectFB通过FrameBuffer进行图显示,这篇文章介绍一下使用过程

1.开启Tina DirectFB支持:

make menuconfig 打开DirectFB支持,如下图所示:

2. 编译,烧录:

可以看到关于显示的两个节点,/dev/fb0即是传统意义上的framebuffer,而/dev/disp则是AW为了兼容自己的显示框架和显示方案,开放的display engine设备节点,用户层可以通过/dev/disp节点直接控制视频或者图像的显示。DirectFB不依赖这个节点。

Tina平台使用DirectFB

3.FrameBuffer与Display模块的关系

以Sunxi V831平台为例,Display的原理如下,DE可以支持3个channel,每个channel支持4个可以做overlay叠加的图层,其中channel 0,1是视频channel,支持YUV格式的数据输入并且可以做scaler.而channel 2 是RGB channel,支持RGB格式数据,不支持scaler,我们的framebuffer本质上就是将/dev/fb0和 DE的某个UI 图层关联起来,确切的说是将/dev/fb0和channel 2 ,layer 0的UI图层关联起来。

4.测试DirectFB用例

前面我们配置编译单的时候,选中了directFB本体和directfb的测试用例,则烧录后,文件系统中已经包括了测试用例的可执行程序。

Tina平台使用DirectFB

我们随便执行一个df_andi

Tina平台使用DirectFB

Tina平台使用DirectFB

另一个用例:

Tina平台使用DirectFB

测试效果:

经测试,其它可运行的用例包括df_flip, df_neo, df_knuckles.

strace调试:

strace调试与系统之间的交互行为,可以看到,显示的时候,调用热点是FBIO_WAITFORVSYNC和FBIOPAN_DISPLAY两个调用。

root@(none):/# strace -e trace=ioctl df_andi
(*) Direct/Thread: Started 'SigHandler' (920) [CRITICAL - OTHER/0] <85292>...

~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.7.7 |~~~~~~~~~~~~~~~~~~~~~~~~~~
(c) 2012-2015 DirectFB integrated media GmbH
(c) 2001-2015 The world wide DirectFB Open Source Community
(c) 2000-2004 Convergence (integrated media) GmbH
----------------------------------------------------------------

(*) DirectFB/Core: Single Application Core. (2021-09-22 03:09)
(*) Direct/Memcpy: Using libc memcpy()
(*) Direct/Thread: Started 'Fusion Dispatch' (921) [MESSAGING - OTHER/0] <85292>...
ioctl(5, VT_GETSTATE, 0xbed31a20) = 0
ioctl(5, VT_OPENQRY, 0x125ad8) = 0
ioctl(4, FBIOGET_CON2FBMAP, 0xbed31a10) = 0
ioctl(4, FBIOPUT_CON2FBMAP, 0xbed31998) = 0
ioctl(5, VT_ACTIVATE, 0x2) = 0
ioctl(5, VT_WAITACTIVE, 0x2) = 0
ioctl(6, TIOCSCTTY, 0) = 0
ioctl(6, KDSKBMODE, 0x2) = 0
ioctl(6, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(6, SNDCTL_TMR_CONTINUE or TCSETSF, {B38400 opost -isig -icanon -echo ...}) = 0
ioctl(6, KDSETMODE, 0x1) = 0
ioctl(6, VT_SETMODE, 0xbed31900) = 0
(*) Direct/Thread: Started 'VT Switcher' (922) [CRITICAL - OTHER/0] <85292>...
(*) Direct/Thread: Started 'VT Flusher' (923) [DEFAULT - OTHER/0] <85292>...
ioctl(4, FBIOGET_FSCREENINFO, 0x1257f0) = 0
(*) DirectFB/FBDev: Found '' (ID 0) with frame buffer at 0x00000000, 2400k (MMIO 0x00000000, 0k)
ioctl(4, FBIOGET_VSCREENINFO, 0x125928) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0x125888) = 0
ioctl(4, FBIOGETCMAP, 0x1259d4) = 0
ioctl(7, EVIOCGNAME(31), "axp2101-pek\0") = 12
ioctl(7, EVIOCGBIT(0, 4), [EV_SYN, EV_KEY, EV_REP]) = 4
ioctl(7, EVIOCGBIT(EV_KEY, 96), [KEY_POWER]) = 96
ioctl(7, EVIOCGID, {ID_BUS=0, ID_VENDOR=0, ID_PRODUCT=0, ID_VERSION=0}) = 0
ioctl(7, EVIOCGNAME(31), "sunxi-gpadc0\0") = 13
ioctl(7, EVIOCGBIT(0, 4), [EV_SYN, EV_KEY, EV_REP]) = 4
ioctl(7, EVIOCGBIT(EV_KEY, 96), [KEY_ENTER, KEY_HOME, KEY_VOLUMEDOWN, KEY_VOLUMEUP, ...]) = 96
ioctl(7, EVIOCGID, {ID_BUS=25, ID_VENDOR=1, ID_PRODUCT=1, ID_VERSION=256}) = 0
ioctl(7, EVIOCGNAME(31), "sunxi-gpadc0\0") = 13
ioctl(7, EVIOCGBIT(0, 4), [EV_SYN, EV_KEY, EV_REP]) = 4
ioctl(7, EVIOCGBIT(EV_KEY, 96), [KEY_ENTER, KEY_HOME, KEY_VOLUMEDOWN, KEY_VOLUMEUP, ...]) = 96
ioctl(7, EVIOCGID, {ID_BUS=25, ID_VENDOR=1, ID_PRODUCT=1, ID_VERSION=256}) = 0
ioctl(7, EVIOCGBIT(EV_LED, 4), [ 0 ]) = 4
(*) Direct/Thread: Started 'Linux Input' (924) [INPUT - OTHER/0] <85292>...
(*) DirectFB/Input: sunxi-gpadc0 0.1 (directfb.org)
ioctl(7, EVIOCGBIT(EV_ABS, 8), [ 0 ]) = 8
(*) Direct/Thread: Started 'Hotplug with Linux Input' (925) [INPUT - OTHER/0] <85292>...
(*) DirectFB/Input: Hot-plug detection enabled with Linux Input Driver
(*) DirectFB/Graphics: Generic Software Rasterizer 0.7 (directfb.org)
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31850) = 0
(*) DirectFB/Core/WM: Default 0.3 (directfb.org)
(*) Direct/Thread: Started 'Genefx' (926) [DEFAULT - OTHER/0] <85292>...
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed318c8) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed318b8) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31828) = 0
(*) FBDev/Mode: Setting 640x480 RGB32
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31680) = 0
ioctl(4, FBIOGET_VSCREENINFO, 0xbed31720) = 0
ioctl(4, FBIOGET_FSCREENINFO, 0x1257f0) = 0
(*) FBDev/Mode: Switched to 640x480 (virtual 640x480) at 32 bit (RGB32), pitch 2560
ioctl(4, FBIOPUTCMAP, 0x1259ec) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31928) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31918) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31888) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31878) = 0
(*) FBDev/Mode: Setting 640x480 RGB32
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31668) = 0
ioctl(4, FBIOGET_VSCREENINFO, 0xbed31708) = 0
ioctl(4, FBIOGET_FSCREENINFO, 0x1257f0) = 0
(*) FBDev/Mode: Switched to 640x480 (virtual 640x480) at 32 bit (RGB32), pitch 2560
ioctl(4, FBIOPUTCMAP, 0x1259ec) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31928) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31908) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed318f8) = 0
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31868) = 0
(*) Direct/Interface: Loaded 'FT2' implementation of 'IDirectFBFont'.
(*) Direct/Interface: Loaded 'PNG' implementation of 'IDirectFBImageProvider'.
(*) Direct/Interface: Using 'JPEG' implementation of 'IDirectFBImageProvider'.
(*) FBDev/Mode: Setting 640x480 RGB32
ioctl(4, FBIOPUT_VSCREENINFO, 0xbed31840) = 0
ioctl(4, FBIOGET_VSCREENINFO, 0xbed318e0) = 0
ioctl(4, FBIOGET_FSCREENINFO, 0x1257f0) = 0
(*) FBDev/Mode: Switched to 640x480 (virtual 640x960) at 32 bit (RGB32), pitch 2560
ioctl(4, FBIOPUTCMAP, 0x1259ec) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0
ioctl(4, FBIO_WAITFORVSYNC, 0xb6c03b6c) = 0
ioctl(4, FBIOPAN_DISPLAY, 0x125888) = 0

在directfb画面上添加文字:

执行cout进入编译目录,删除掉旧的编译环境:

Tina平台使用DirectFB

然后进入dl目录,解压

Tina平台使用DirectFB

修改df_andi的的实现,增加一条字符串打印,并调整之前打印的坐标,使之能在屏幕上显示出来,之后,重新编译整个Tina工程。

可以看到"Zilong lover"字符串已经清晰的显示在画面底部

Tina平台使用DirectFB

究竟写英文需要不需要字库呢? pidof df_andi得到进程PID,进入到proc PID目录下看每个线程的文件打开情况,发现没有打开字库文件的线程存在.

root@(none):/proc/909/task# ls -l */fd
909/fd:
lrwx------ 1 root root 64 Jan 2 10:33 0 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 1 -> /dev/console
lr-x------ 1 root root 64 Jan 2 10:33 10 -> pipe:[1552]
l-wx------ 1 root root 64 Jan 2 10:33 11 -> pipe:[1552]
lrwx------ 1 root root 64 Jan 2 10:33 14 -> socket:[1553]
lrwx------ 1 root root 64 Jan 2 10:33 2 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 3 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 4 -> /dev/fb0
lr-x------ 1 root root 64 Jan 2 10:33 5 -> /dev/tty0
lrwx------ 1 root root 64 Jan 2 10:33 6 -> /dev/tty2
lrwx------ 1 root root 64 Jan 2 10:33 7 -> /dev/input/event1
lr-x------ 1 root root 64 Jan 2 10:33 8 -> pipe:[1551]
l-wx------ 1 root root 64 Jan 2 10:33 9 -> pipe:[1551]

910/fd:
lrwx------ 1 root root 64 Jan 2 10:32 0 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:32 1 -> /dev/console
lr-x------ 1 root root 64 Jan 2 10:32 10 -> pipe:[1552]
l-wx------ 1 root root 64 Jan 2 10:32 11 -> pipe:[1552]
lrwx------ 1 root root 64 Jan 2 10:32 14 -> socket:[1553]
lrwx------ 1 root root 64 Jan 2 10:32 2 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:32 3 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:32 4 -> /dev/fb0
lr-x------ 1 root root 64 Jan 2 10:32 5 -> /dev/tty0
lrwx------ 1 root root 64 Jan 2 10:32 6 -> /dev/tty2
lrwx------ 1 root root 64 Jan 2 10:32 7 -> /dev/input/event1
lr-x------ 1 root root 64 Jan 2 10:32 8 -> pipe:[1551]
l-wx------ 1 root root 64 Jan 2 10:32 9 -> pipe:[1551]

911/fd:
lrwx------ 1 root root 64 Jan 2 10:33 0 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 1 -> /dev/console
lr-x------ 1 root root 64 Jan 2 10:33 10 -> pipe:[1552]
l-wx------ 1 root root 64 Jan 2 10:33 11 -> pipe:[1552]
lrwx------ 1 root root 64 Jan 2 10:33 14 -> socket:[1553]
lrwx------ 1 root root 64 Jan 2 10:33 2 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 3 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 4 -> /dev/fb0
lr-x------ 1 root root 64 Jan 2 10:33 5 -> /dev/tty0
lrwx------ 1 root root 64 Jan 2 10:33 6 -> /dev/tty2
lrwx------ 1 root root 64 Jan 2 10:33 7 -> /dev/input/event1
lr-x------ 1 root root 64 Jan 2 10:33 8 -> pipe:[1551]
l-wx------ 1 root root 64 Jan 2 10:33 9 -> pipe:[1551]

912/fd:
lrwx------ 1 root root 64 Jan 2 10:33 0 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 1 -> /dev/console
lr-x------ 1 root root 64 Jan 2 10:33 10 -> pipe:[1552]
l-wx------ 1 root root 64 Jan 2 10:33 11 -> pipe:[1552]
lrwx------ 1 root root 64 Jan 2 10:33 14 -> socket:[1553]
lrwx------ 1 root root 64 Jan 2 10:33 2 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 3 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 4 -> /dev/fb0
lr-x------ 1 root root 64 Jan 2 10:33 5 -> /dev/tty0
lrwx------ 1 root root 64 Jan 2 10:33 6 -> /dev/tty2
lrwx------ 1 root root 64 Jan 2 10:33 7 -> /dev/input/event1
lr-x------ 1 root root 64 Jan 2 10:33 8 -> pipe:[1551]
l-wx------ 1 root root 64 Jan 2 10:33 9 -> pipe:[1551]

913/fd:
lrwx------ 1 root root 64 Jan 2 10:33 0 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 1 -> /dev/console
lr-x------ 1 root root 64 Jan 2 10:33 10 -> pipe:[1552]
l-wx------ 1 root root 64 Jan 2 10:33 11 -> pipe:[1552]
lrwx------ 1 root root 64 Jan 2 10:33 14 -> socket:[1553]
lrwx------ 1 root root 64 Jan 2 10:33 2 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 3 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 4 -> /dev/fb0
lr-x------ 1 root root 64 Jan 2 10:33 5 -> /dev/tty0
lrwx------ 1 root root 64 Jan 2 10:33 6 -> /dev/tty2
lrwx------ 1 root root 64 Jan 2 10:33 7 -> /dev/input/event1
lr-x------ 1 root root 64 Jan 2 10:33 8 -> pipe:[1551]
l-wx------ 1 root root 64 Jan 2 10:33 9 -> pipe:[1551]

914/fd:
lrwx------ 1 root root 64 Jan 2 10:33 0 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 1 -> /dev/console
lr-x------ 1 root root 64 Jan 2 10:33 10 -> pipe:[1552]
l-wx------ 1 root root 64 Jan 2 10:33 11 -> pipe:[1552]
lrwx------ 1 root root 64 Jan 2 10:33 14 -> socket:[1553]
lrwx------ 1 root root 64 Jan 2 10:33 2 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 3 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 4 -> /dev/fb0
lr-x------ 1 root root 64 Jan 2 10:33 5 -> /dev/tty0
lrwx------ 1 root root 64 Jan 2 10:33 6 -> /dev/tty2
lrwx------ 1 root root 64 Jan 2 10:33 7 -> /dev/input/event1
lr-x------ 1 root root 64 Jan 2 10:33 8 -> pipe:[1551]
l-wx------ 1 root root 64 Jan 2 10:33 9 -> pipe:[1551]

915/fd:
lrwx------ 1 root root 64 Jan 2 10:33 0 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 1 -> /dev/console
lr-x------ 1 root root 64 Jan 2 10:33 10 -> pipe:[1552]
l-wx------ 1 root root 64 Jan 2 10:33 11 -> pipe:[1552]
lrwx------ 1 root root 64 Jan 2 10:33 14 -> socket:[1553]
lrwx------ 1 root root 64 Jan 2 10:33 2 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 3 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 4 -> /dev/fb0
lr-x------ 1 root root 64 Jan 2 10:33 5 -> /dev/tty0
lrwx------ 1 root root 64 Jan 2 10:33 6 -> /dev/tty2
lrwx------ 1 root root 64 Jan 2 10:33 7 -> /dev/input/event1
lr-x------ 1 root root 64 Jan 2 10:33 8 -> pipe:[1551]
l-wx------ 1 root root 64 Jan 2 10:33 9 -> pipe:[1551]

916/fd:
lrwx------ 1 root root 64 Jan 2 10:33 0 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 1 -> /dev/console
lr-x------ 1 root root 64 Jan 2 10:33 10 -> pipe:[1552]
l-wx------ 1 root root 64 Jan 2 10:33 11 -> pipe:[1552]
lrwx------ 1 root root 64 Jan 2 10:33 14 -> socket:[1553]
lrwx------ 1 root root 64 Jan 2 10:33 2 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 3 -> /dev/console
lrwx------ 1 root root 64 Jan 2 10:33 4 -> /dev/fb0
lr-x------ 1 root root 64 Jan 2 10:33 5 -> /dev/tty0
lrwx------ 1 root root 64 Jan 2 10:33 6 -> /dev/tty2
lrwx------ 1 root root 64 Jan 2 10:33 7 -> /dev/input/event1
lr-x------ 1 root root 64 Jan 2 10:33 8 -> pipe:[1551]
l-wx------ 1 root root 64 Jan 2 10:33 9 -> pipe:[1551]
root@(none):/proc/909/task#