Linux Driver Development: User space operation LCD display simple picture "turn"

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/changliang7731/article/details/53074616

In the previous chapter, we briefly introduced some basic principles of LCD. And, of course, more esoteric, like gamma,dither,hue,satuation. OSD and so on.

We know we are using framebuffer to achieve the display.

Video memory: framebuffer. A portion of the RAM is drawn from the Ddram for video memory use.
The operation of the LCD is equivalent to operating memory.
The LCD controller (which has an LCD controller inside the s5pv210) periodically gets the data in the framebuffer. Processed LCD driver for lost display
The LCD driver analyzes, decodes, and displays the data to the LCD.

The work of LCD driver development:
Configure the LCD controller to have the LCD controller periodically read the data in the memory
The data is then sent to the LCD driver according to a certain sequence and format. The drive drives the LCD screen for display.
1) Apply for video memory

Framebuffer: Export LCD physical buffer (video memory) into user space (0-3g)
User space to display a picture to the LCD, in the user space directly manipulate the video memory, the image will be displayed copy to
The corresponding position in the video memory can be

Here is not much to say, because the time is too late, too tired. Let's draw a picture like this:

User Space Code:

#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <linux/fb.h>#include <sys/mman.h>#define _color_red 0x00ff0000#define _color_green 0X0000FF00#define _color_blue 0X000000FFStaticstruct Fb_fix_screeninfo fb_fix ={0};Staticstruct Fb_var_screeninfo Fb_var ={0};Long screen_size=0;int *fb32 =null;int main () {int FD =-1;int x, y; FD =open ("/dev/fb0", O_RDWR);if (FD <0) {printf"Open dev fb0 fail.\n");Return-1; }Get LCD param ioctl (fd,fbioget_fscreeninfo,&fb_fix); IOCTL (Fd,fbioget_vscreeninfo,&fb_var); Screen_size = fb_var.xres*fb_var.yres* (fb_var.bits_per_pixel/8); Fb32 =mmap (0,screen_size,prot_read | PROT_WRITE,MAP_SHARED,FD,0);if (fb32 = = NULL) {printf"Mmap framebuffer fail.\n");Return-1; }if (Fb_var.bits_per_pixel = =8) {printf"8BPP framebuffer test.\n"); }Elseif (Fb_var.bits_per_pixel = =16) {printf"16BPP framebuffer test.\n"); }Elseif (Fb_var.bits_per_pixel = =24) {printf"24BPP framebuffer test.\n"); }Elseif (Fb_var.bits_per_pixel = =32) {printf ( "32bpp framebuffer test.\n");} for (Y=0;y< fb_var.yres/3;y++) {for (X=0;x< fb_var.xres;x++) {* (Fb32 +y*fb_var.xres + x) = _ color_red; }} for (;y< fb_var.yres*2/3;y++ {for (X=0;x< fb_var.xres;x++) {* (Fb32 +y*fb_var.xres + x) = _ Color_green; }} for (;y< fb_var.yres;y++) {for (x= 0;x< fb_var.xres;x++) {* (Fb32 +y*fb_var.xres + x) = _color_blue;} } munmap (Fb32,screen_size); Close (FD); return 0;}         

Experimental results:

Can be seen, as we expected. There's a little black box over there. That's the cursor, we don't care.

Copyright Notice: Learning record, added up

Linux Driver Development: User space operation LCD display simple picture "turn"

Related Article

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.