/* 平台驱动结构体 */
static struct platform_driver xxxfb_driver = {
.probe = xxxfb_probe,
.remove = xxxfb_remove,
.suspend = xxxfb_suspend,
.resume = xxxfb_resume,
.driver = {
.name = "xxx-lcd", /* 驱动名 */
.owner = THIS_MODULE,
}
};
/* 平台驱动探测函数 */
static int _ _init xxxfb_probe(...)
{
struct fb_info *info;
/*分配 fb_info 结构体*/
info = framebuffer_alloc(...);
info->screen_base = framebuffer_virtual_memory;
info->var = xxxfb_var; /* 可变参数 */
info->fix = xxxfb_fix; /* 固定参数 */
/*分配显示缓冲区*/
alloc_dis_buffer(...);
/*初始化 LCD 控制器*/
lcd_init(...);
/*检查可变参数*/
xxxfb_check_var(&info->var, info);
/*注册 fb_info*/
if (register_framebuffer(info) < 0)
return - EINVAL;
return 0;
}
/* 平台驱动移除函数 */
static void _ _exit xxxfb_remove(...)
{
struct fb_info *info = dev_get_drv_data(dev);
if (info) {
unregister_framebuffer(info); /* 注销 fb_info */
dealloc_dis_buffer(...); /* 释放显示缓冲区 */
framebuffer_release(info); /* 注销 fb_info */
}
return 0;
}
/* 帧缓冲设备驱动模块加载与卸载函数 */
int __init xxxfb_init(void)
{
return platform_driver_register(&xxxfb_driver); /* 注册平台设备 */
}
static void __exit xxxfb_cleanup(void)
{
platform_driver_unregister(&xxxfb_driver); /* 注销平台设备 */
}
module_init(xxxfb_init);
module_exit(xxxfb_cleanup);