【Linux高級驅動】LCD驅動框架分析

1.framebuffer接口層(fbmem.c)

    功能:給用戶提供接口node

fbmem_init   //入口函數
  /*1.申請主設備號,註冊字符設備*/
 register_chrdev(FB_MAJOR( 29), "fb", &fb_fops)
 
  /*2.建立一個設備類*/
 fb_class = class_create(THIS_MODULE, "graphics");
static const struct file_operations fb_fops = {
 .owner = THIS_MODULE,
 .read =  fb_read,
 .write = fb_write,
 .unlocked_ioctl = fb_ioctl,
# ifdef CONFIG_COMPAT
 .compat_ioctl = fb_compat_ioctl,
# endif
 .mmap =  fb_mmap,
 .open =  fb_open,
 .release = fb_release,
# ifdef HAVE_ARCH_FB_UNMAPPED_AREA
 .get_unmapped_area = get_fb_unmapped_area,
# endif
# ifdef CONFIG_FB_DEFERRED_IO
 .fsync = fb_deferred_io_fsync,
# endif
};

 

2.從應用層往下分析

open

app : open( "/dev/xxx",xxx)
== == == == == == == == == == == == == == == =
vfs : sys_open
  ...
  ...
fbmem.c struct file_operations fb_fops
   .open =  fb_open,
     /*1.獲取此設備號*/
     int fbidx = iminor(inode);
     struct fb_info *info;
     /*2.以此設備號爲下標,從register_fb數組中取出fb_info結構體*/
    info = registered_fb[fbidx];
    file - >private_data = info;
     if (info - >fbops - >fb_open) {
     res = info - >fbops - >fb_open(info, 1);

ioctl

app : ioctl(fd,FBIOGET_VSCREENINFO,args)
== == == == == == == == == == == == == == == == == == == == == =
vfs : sys_ioctl
  ...
  ...
fbmem.c struct file_operations fb_fops
   .unlocked_ioctl = fb_ioctl,
     /*1.獲取此設備號*/
     struct inode *inode = file - >f_path.dentry - >d_inode;
     int fbidx = iminor(inode);
     /*2.以此設備號爲下標,從register_fb數組中取出fb_info結構體*/
     struct fb_info *info = registered_fb[fbidx];
    do_fb_ioctl(info, cmd, arg);
      struct fb_var_screeninfo var;   //表示可變參數
      struct fb_fix_screeninfo fix;   //表示固定參數
      switch (cmd) {
       case FBIOGET_VSCREENINFO :
        if ( !lock_fb_info(info))
         return -ENODEV;
       var = info - >var; //取出fb_info中的可變參數
       unlock_fb_info(info);
       ret = copy_to_user(argp, &var, sizeof(var)) ? -EFAULT : 0;
        break;
     }

    搜索registered_fb數組,看在哪裏被設置了?數組

s3c_fb_probe( struct platform_device *pdev)
 ...
 ...
  for (win = 0; win < S3C_FB_MAX_WIN; win ++) {
   /*設置一個硬件窗口:一個窗口就是一個幀緩衝設備,一個幀緩衝設備用struct fb_info來描述*/
  s3c_fb_probe_win      //drivers\video\s3c-fb.c
    /*構建fb_info:表示一個幀緩衝設備*/
   
    /*設置fb_info*/
    /*設置它的可變參數*/
    /*設置它的固定參數*/
    /*設置它的操做方法*/
    /*註冊一個fb_info結構體*/
   register_framebuffer( struct fb_info *fb_info)
     /*將fb_info加入數組項*/
    registered_fb[i] = fb_info;

 

 

  @成鵬致遠app

(blogs:http://lcw.cnblogs.comide

(emailwwwlllll@126.com)函數

(qq552158509spa

 



相關文章
相關標籤/搜索