Linux Framebuffer(一) - 概述

  • 了解Linux framebuffer.

1.Framebuffer Intro

  FrameBuffer是出现在 2.2.xx 内核当中的一种驱动程序接口。Linux是工作在保护模式下,所以用户态进程是无法象DOS那样使用显卡BIOS里提供的中断调用来实现直接写屏,Linux抽象出 FrameBuffer这 个设备来供用户态进程实现直接写屏。

  Framebuffer机制模仿显卡的功能,将显卡硬件结构抽象掉,可以通过Framebuffer的读写直接对显存进行操作。用户可以将Framebuffer看成是显示内存的一个映像,将其映射到进程地址空间之后,就可以直接进行读写操作,而写操作可以立即反应在屏幕上。 这种操作是抽象的,统一的。用户不必关心物理显存的位置、换页机制等等具体细节。这些都是由Framebuffer设备驱动来完成的。

  但Framebuffer本身不具备任何运算数据的能力,就只好比是一个暂时存放水的水池。CPU将运算后的结果放到这个水池,水池再将结果流到显示器,中间不会对数据做处理,应用程序也可以直接读写这个水池的内容。在这种机制下,尽管Framebuffer需要真正的显卡驱动的支持,但所有显示任务都有CPU完成,因此CPU 负担很重。

2.Accessing Graphics

  There are 3 different ways that graphics can be performed:

  • Using a kernel framebuffer driver
  • Using a kernel DRM driver
  • Mapping the card’s control registers into user-space (via mmap() calls on /dev/mem), and using user-space code to access the card (very complex)

3.What is a Framebuffer Driver?

  It is a Linux kernel driver which exposes a file /dev/fb{N} for a graphics card it is responsible for. Through that file, userspace apps can perform reads/writes to directly access the video card framebuffer - ie the pixel values being displayed on the screen. Via IOCTL calls on that file, other functionality can be accessed including:

  • setting the graphics mode (width, height, pixel-depth, etc)
  • passing bitmaps to be copied into video memory
  • passing coordinates of a rectangle to be filled with a specified colour

  The framebuffer interface does not offer much in the way of acceleration other than the bitblits and fills mentioned above.

There is a fairly generic “vesafb” driver that is capable of controlling any graphics card compatible with the VESA standard. Linux also comes with dozens of card-specific framebuffer drivers that support products of specific manufacturers. On boot, Linux uses the PCI ID of a graphics card to load the most appropriate framebuffer driver, which in turn creates the /dev/fb{n} control file.

4.Why Use a Framebuffer Driver?

  Embedded systems use them because they often don’t have complex graphics requirements, want a small kernel, and don’t want an X server running in userspace. While X can use a framebuffer to display graphics, so can other simpler graphical libraries.

  For many graphics chips, there is a framebuffer driver available but no specific X driver, and no 3D driver.

  Graphics display during startup is also a candidate for a framebuffer driver.

  And linux text consoles can use a framebuffer driver to display text at nice resolutions (better than available via the BIOS) without otherwise actually wanting to display graphics.

refer to

  • http://moi.vonos.net/linux/framebuffer-drivers/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Qt is a popular cross-platform framework for developing graphical user interfaces (GUI) and applications. It provides support for Linux framebuffer, which allows you to create GUI applications that can run directly on the Linux framebuffer without the need for an X server. To use Qt with Linux framebuffer, you can follow these general steps: 1. Install the required dependencies: Make sure you have the necessary libraries and development packages installed on your Linux system. This may include framebuffer-related libraries like `libdrm` and `libgbm`. 2. Configure Qt with framebuffer support: When building Qt from source, you can enable framebuffer support by passing the `-qt-libinput` flag to the `configure` script. For example: ``` ./configure -qt-libinput ``` 3. Build your Qt application: Once Qt is configured with framebuffer support, you can build your application using the `qmake` and `make` commands as usual. Make sure to set the appropriate target platform, such as `linuxfb`. 4. Run your Qt application on the Linux framebuffer: After building your application, you can run it directly on the Linux framebuffer by setting the appropriate environment variables. For example: ``` export QT_QPA_PLATFORM=linuxfb export QT_QPA_FB_TTY=/dev/fb0 ./your_application ``` By following these steps, you should be able to develop and run Qt applications using the Linux framebuffer as the target platform. Keep in mind that framebuffer support may vary depending on your specific Linux distribution and hardware setup.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值