标签:
1.分配一个fb_info结构体: framebuffer_alloc
2.设置
3.注册
4.硬件相关操
struct fb_fix_screeninfo {
char id[16]; /* identification string eg "TT Builtin" */
unsigned long smem_start; /* Start of frame buffer mem */
/* (physical address) */
__u32 smem_len; /* Length of frame buffer mem */
__u32 type; /* see FB_TYPE_* */
__u32 visual; /* see FB_VISUAL_* */
__u32 line_length; /* length of a line in bytes */
};
struct fb_var_screeninfo {
__u32 xres; /* visible resolution */
__u32 yres;
__u32 xres_virtual; /* virtual resolution */
__u32 yres_virtual;
__u32 bits_per_pixel; /* guess what */
struct fb_bitfield red; /* bitfield in fb mem if true color, */
struct fb_bitfield green; /* else only length is significant */
struct fb_bitfield blue;
__u32 activate; /* see FB_ACTIVATE_* */
};
1 static int lcd_init(void)
2 {
3 /* 1. 分配一个fb_info */
4 s3c_lcd = framebuffer_alloc(0, NULL);
5
6 /* 2. 设置 */
7 /* 2.1 设置固定的参数 */
8 strcpy(s3c_lcd->fix.id, "mylcd");
9 s3c_lcd->fix.smem_len = 480 * 272 * 16 / 8;
10 s3c_lcd->fix.type = FB_TYPE_PACKED_PIXELS;
11 s3c_lcd->fix.visual = FB_VISUAL_TRUECOLOR; /*TFT*/
12 s3c_lcd->fix.line_length = 480 * 2;
13
14 /* 2.2 设置可变的参数 */
15 s3c_lcd->var.xres = 480;
16 s3c_lcd->var.yres = 272;
17 s3c_lcd->var.xres_virtual = 480;
18 s3c_lcd->var.yres_virtual = 272;
19 s3c_lcd->var.bits_per_pixel = 16;
20
21 /* RGB:565 */
22 s3c_lcd->var.red.offset = 11;
23 s3c_lcd->var.red.length = 5;
24
25 s3c_lcd->var.green.offset = 5;
26 s3c_lcd->var.green.length = 6;
27
28 s3c_lcd->var.blue.offset = 0;
29 s3c_lcd->var.blue.length = 5;
30
31 s3c_lcd->var.activate = FB_ACTIVATE_NOW;
32
33 /* 2.3 设置操作函数 */
34 s3c_lcd->fbops = &s3c_lcdfb_ops;
35
36 /* 2.4 其他设置 */
37 //s3c_lcd->pseudo_palette;
38 //s3c_lcd->screen_base; //显存的虚拟地址
39 //s3c_lcd->screen_size = 480 * 272 * 16 / 8;
40 /* 3. 硬件相关的设置 */
41 /* 3.1 配置GPIO用于LCD */
42 /* 3.2 根据LCD手册设置LCD控制器,比如VCLK的频率等 */
43 /* 3.3 分配显存(framebuffer),并把地址告诉LCD控制器 */
44
45 /* 4. 注册 */
46
47 register_framebuffer(s3c_lcd);
48
49 return 0;
50 }
标签:
原文地址:http://www.cnblogs.com/CZM-/p/5167689.html