Framebuffer is a driver interface that appears in the 2.2.xx kernel. This interface will display
The backup is abstracted as the frame buffer. Users can regard it as an image for displaying memory and map it to the process location.
After the address space, you can directly perform read/write operations, and write operations can immediately respond to the screen. This driver
The device files of the program are generally/dev/fb0,/dev/Fb1, and so on. For example, assume that the current display mode is
To clear the screen, run the following command:
$ Dd if =/dev/zero of =/dev/fb0 bs = 1024 count = 768 in applications, it is generally used by ing the FrameBuffer device to the process address space,
For example, the following program opens the/dev/fb0 device and uses the mmap system to call the address ing.
Then use memset to clear the screen (Here we assume the display mode is 1024x7688-bit color mode, linear memory
Mode): int fb;
Unsigned char * fb_mem; fb = open ("/dev/fb0", O_RDWR );
Fb_mem = mmap (NULL, 1024*768, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0); memset (fb_mem, 0, 1024*768 ); the FrameBuffer device also provides several ioctl commands to obtain the display device.
Some fixed information (such as the Display memory size), variable information related to the display mode (such as resolution
Rate, pixel structure, byte width of each scanned line), and color palette information in pseudo-color mode. Through the FrameBuffer device, you can also obtain the type of the acceleration display card supported by the current kernel (through
Fixed information). This type is usually related to a specific display chip. For example, the latest kernel
(2.4.9), including acceleration of popular display chips such as S3, Matrox, nVidia, and 3Dfx
Yes. After obtaining the acceleration chip type, the application can change the memory I/O of the PCI device.
(Memio) maps to the address space of the process. These memio are generally used to control the registers of the display card,
By operating these registers, the application can control the acceleration function of a specific video card. PCI devices can map their own control registers to the physical memory space.
To the physical memory. Therefore, these registers are also called "memio ". Once
After being mapped to the physical memory, common processes in Linux can map these memory I/O
Process address space, so that you can directly access these registers. Of course, because different display chips have different acceleration capabilities, the use and definition of memio are also different.
At this time, you need to write different types of acceleration chips to implement different acceleration functions. For example, most
The number chip provides hardware acceleration for Rectangle filling, but different chip implementation methods are different,
You need to write different functions for filling the rectangle for different chip types. Speaking of this, the reader may have realized that framebuffer is only a display memory and display chip.
Registers are mapped from physical memory to devices in the process address space. Therefore, for applications, if
To program graphics on framebuffer, you still need to do a lot of work. For example
Speaking, framebuffer is like a canvas. You still need to know what the paint looks like and how to draw it.
Hands-on.