Linux framebuffer --- Double Buffer

Source: Internet
Author: User

[What is framebuffer]

Frame Buffer.

Frame: the image of the screen you see, or the image in a window, is called a frame.

Buffer: A piece of RAM used to store image data, which is directly written to the display device.

Frame buffering is equivalent to a man-in-the-middle between image operations and image output. The program processes the graphic data and sends it back to the display output.

Video Card (data in video memory) <-> frame buffer (the program processes the data) <-> display (output image)

Frame buffering can be used to achieve resolutions that are not supported by the original video card.

The video card may not support a display with a larger resolution. However, you can use frame buffering to obtain the data in the video card's memory. After processing, you can achieve a larger resolution image, then, output the data directly to the monitor.

[Dual-display example]

One example may be dual display. A developer's system has just been seen recently, namely, two monitors. When the mouse moves more than a single monitor to the rightmost, it runs to another monitor. This function is very practical for developers who often use multiple systems or need to open many things.

Frame buffering can be used for page switching Page Flipping (also called double buffering). Many Games use this technology to achieve smoother video output, this gives users a better gaming experience. This technology is also used for 3D graphics acceleration.

[Implementation principle of dual buffering]

If your monitor is in VGA mode, 640x400, that is, the virtual resolution is 640x800, that is, 800 lines (each line of data is called a line, that is, 640x1 data ). The data of the 800 line is stored in framebuffer, while the actual display content is only the 400 line. In the framebuffer model of the Linux kernel, The yoffset variable should be used to represent the specific ordinate, the default value is 0, so the displayed content is 0-. Because it is the same as the actual displayed page size, it can be referred to as the first frame. If the yoffset is changed, for example, if it is changed to 400 in this example, the remaining part is displayed, with a line. This is referred to as the second frame.

When the system displays the first frame, the system quietly prepares the second frame of data in the background. Therefore, when the first frame is displayed, most of the time, the second frame of data is also ready, it can be directly displayed, and the system is preparing the next frame of data, which can greatly improve the display efficiency.

[Implementation principle of smooth Page scrolling]

Same as above. When the first frame of data is displayed, that is, when the line 0-is displayed, set yoffset to 1 to display the data of the line 1-. After the display is complete, set yoffset to 2 to display the data of the 2-401 line. In this way, you can smoothly display the entire scrolling screen. In fact, this is the vertical scroll of the screen. When yoffset is added, you can use a timer for each period of time, such as 10us and 1. The system will automatically update the corresponding content, so that the content we see is the scrolling screen.

In addition, the framebuffer model in Linux provides some IOCTL functions. Given some parameters, the system can implement the corresponding functions. One parameter is fbiopan_display. Specifically, it is similar to the following call:

IOCTL (framebuffer_handler, fbiopan_display, & variable_info );
If this call shows that the framebuffer double buffer is not supported, the buffer size of its framebuffer is equivalent to the physical display size, then the corresponding yoffset will not change as the double buffer.

That is to say, if the video card/display controller does not support double buffering, The yoffset should always be 0, and it should not be changed during running, nor should it call ioctl for the fbiopan_display parameter.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.