lcd程序拽写层次结构

由于lcd依然是可以使用子系统进行操作,因此我们可以模仿输入子系统对lcd的整个过程进行设置,如下:

 1 #头文件部分
 2 //static相关定义部分
 3 
 4 static int lcd_init(void)
 5 {
 6 }
 7 static void lcd_exit(void)
 8 {
 9 }
10 
11 module_init(lcd_init);
12 module_exit(lcd_exit);
13 
14 MODULE_LICENSE("GPL");  //许可证声明

在此基础上对lcd_init进行填充,包括如下部分:

  •  /* 1.分配一个结构体*/
  •  /* 2.根据结构体配置参数*/
  •  /* 3.硬件相关操作*/
  •  /* 4.注册函数*/

下面进行函数填充:

1.分配一个结构体

 s3c_lcd = framebuffer_alloc(0, NULL);   //framebuffer 帧缓冲

(帧缓冲:由fb_ops结构体定义,他是Linux为显示设备提供的一个接口,它把一些显示设备描述成一个缓冲区,允许应用程序通过 FrameBuffer定义好的接口访问这些图形设备,从而不用去关心具体的硬件细节)

2.根据结构体配置参数

这里主要就是对fb_ops内容进行配置,fb_ops代码如下(含部分注释):

struct fb_info {
    int node;
    int flags;
    struct fb_var_screeninfo var;    /* Current var */
    struct fb_fix_screeninfo fix;    /* Current fix */
    struct fb_monspecs monspecs;    /* Current Monitor specs */  //屏幕规格
    struct work_struct queue;    /* Framebuffer event queue */    //帧缓冲区事件队列
    struct fb_pixmap pixmap;    /* Image hardware mapper */
    struct fb_pixmap sprite;    /* Cursor hardware mapper */
    struct fb_cmap cmap;        /* Current cmap */
    struct list_head modelist;      /* mode list */
    struct fb_videomode *mode;    /* current mode */

#ifdef CONFIG_FB_BACKLIGHT
    /* assigned backlight device */
    /* set before framebuffer registration, 
       remove after unregister */
    struct backlight_device *bl_dev;

    /* Backlight level curve */
    struct mutex bl_curve_mutex;    
    u8 bl_curve[FB_BACKLIGHT_LEVELS];
#endif
#ifdef CONFIG_FB_DEFERRED_IO
    struct delayed_work deferred_work;
    struct fb_deferred_io *fbdefio;
#endif

    struct fb_ops *fbops;
    struct device *device;        /* This is the parent */
    struct device *dev;        /* This is this fb device */
    int class_flag;                    /* private sysfs flags */
#ifdef CONFIG_FB_TILEBLITTING
    struct fb_tile_ops *tileops;    /* Tile Blitting */
#endif
    char __iomem *screen_base;    /* Virtual address */
    unsigned long screen_size;    /* Amount of ioremapped VRAM or 0 */ 
    void *pseudo_palette;        /* Fake palette of 16 colors */ 
#define FBINFO_STATE_RUNNING    0
#define FBINFO_STATE_SUSPENDED    1
    u32 state;            /* Hardware state i.e suspend */
    void *fbcon_par;                /* fbcon use-only private area */
    /* From here on everything is device dependent */
    void *par;    
};
View Code

 

 

 

参考资料:http://blog.chinaunix.net/uid-28328633-id-3565345.html (帧缓冲)

posted @ 2016-10-18 16:01  达达kiki  阅读(98)  评论(0)    收藏  举报