1. 程式人生 > 實用技巧 >LCD幀緩衝裝置驅動結構詳解

LCD幀緩衝裝置驅動結構詳解

s3c2410fb_probe分析:
幀緩衝裝置涉及的重要資料結構分析:
staticstructs3c2410fb_mach_info*mach_info;
structs3c2410fb_hwregs;
structs3c2410fb_hw{
unsignedlonglcdcon1;
unsignedlonglcdcon2;
unsignedlonglcdcon3;
unsignedlonglcdcon4;
unsignedlonglcdcon5;
};
structfb_info{
structfb_var_screeninfovar;/*可變引數*/
structfb_fix_screeninfofix;/*固定引數*/
structfb_ops

*fbops;/*操作底層硬體的方法*/

char__iomem*screen_base;/*虛擬地址*/
unsignedlongscreen_size;
};
structfb_fix_screeninfo{
unsignedlongsmem_start;/*實體地址*/
__u32smem_len;/*視訊記憶體的大小240*320*/
__u32line_length;/*一行的大小*/
};

__inits3c2410fb_probe(structplatform_device*pdev)
/*構建一個fb_info結構體,用來描述一個幀緩衝裝置*/
structs3c2410fb_info*info;
structfb_info*fbinfo;

/*獲取lcd屏的控制器配置引數*//*這個地方的資源在mach-smdk2410.c檔案中,如果換了屏就要該相應的引數*/
mach_info=pdev->dev.platform_data;
/*2.放到以個結構體裡面*/
mregs=&mach_info->regs;
/*3.獲取中斷資源*/
irq=platform_get_irq(pdev,0);
/*4.分配fb_info結構體*/
fbinfo=framebuffer_alloc(sizeof(structs3c2410fb_info),&pdev->dev);
/*5.設定固定引數*/
/*6.設定可變引數*/
/*7.申請irq*/
/*8.使能lcd
時鐘*/

/*9.分配記憶體空間*/
ret=s3c2410fb_map_video_memory(info);
/*對齊*/
fbi->map_size=PAGE_ALIGN(fbi->fb->fix.smem_len+PAGE_SIZE);
/*分配緩衝區*/
fbi->map_cpu((核心空間)虛擬地址)=dma_alloc_writecombine(fbi->dev,fbi->map_size,
&fbi->map_dma(實體地址),GFP_KERNEL);
/*這隻lcd控制的幾個暫存器*/
ret=s3c2410fb_init_registers(info);
/*向上註冊*/
ret=register_framebuffer(fbinfo);
/*搜尋陣列,看那項是空的*/
for(i=0;i<FB_MAX;i++)
if(!registered_fb[i])
/*建立一個裝置節點。在fbmem.c層只建立類,在此處LCD控制器驅動中建立fb_info結構體同時向上層註冊之後才建立裝置節點*/
fb_info->dev=device_create(fb_class,fb_info->device,
MKDEV(FB_MAJOR,i),"fb%d",i);
/*fb_info加入到陣列中*/
registered_fb[i]=fb_info;

轉載於:https://blog.51cto.com/doublewen/802534