附录:register_framebuffer分析
int
register_framebuffer(struct fb_info *fb_info)
{
int i;
struct fb_event event;
struct fb_videomode mode;
if (num_registered_fb == FB_MAX)
return -ENXIO;
num_registered_fb++;
// 1.算法:找到次设备号
for (i = 0 ; i < FB_MAX; i++)
if (!registered_fb[i])
break;
fb_info->node = i;
// 2.建立设备节点
fb_info->dev = device_create(fb_class, fb_info->device,//以该次设备号建立设备节点
MKDEV(FB_MAJOR, i), "fb%d", i);//
在app open的时候fb%d,就有次设备号就传递进来了
// 驱动可以利用该次设备号
if (IS_ERR(fb_info->dev)) {
/* Not fatal */
printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
fb_info->dev = NULL;
} else
fb_init_device(fb_info);