整体架构分析
LCD 本为字符设备,fbmem.c中定义了各项fbmem_init frambuffer_register等
其中fbmem_init如下
1654
1655 static int __init
1656 fbmem_init(void)
1657 {
1658 proc_create("fb", 0, NULL, &fb_proc_fops);
1659
1660 if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
1661 printk("unable to get major %d for fb devs\n", FB_MAJOR);
1662
1663 fb_class = class_create(THIS_MODULE, "graphics");
1664 if (IS_ERR(fb_class)) {
1665 printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
1666 fb_class = NULL;
1667 }
1668 return 0;
1669 }
不言自寓啊,字符设备,呵呵
fb_fops调用的即是struct fb_info->fops成员,哈哈,至此明白之前写那么多干嘛的了吧
1413 static const struct file_operations fb_fops = {
1414 .owner = THIS_MODULE,
1415 .read = fb_read,
1416 .write = fb_write,
1417 .unlocked_ioctl = fb_ioctl,
1418 #ifdef CONFIG_COMPAT
1419 .compat_ioctl = fb_compat_ioctl,
1420 #endif
1421 .mmap = fb_mmap,
1422 .open = fb_open,
1423 .release = fb_release,
1424 #ifdef HAVE_ARCH_FB_UNMAPPED_AREA
1425 .get_unmapped_area = get_fb_unmapped_area,
1426 #endif
1427 #ifdef CONFIG_FB_DEFERRED_IO
1428 .fsync = fb_deferred_io_fsync,
1429 #endif
1430 };
好吧,找个fb_mmap给你看看
1310 static int
1311 fb_mmap(struct file *file, struct vm_area_struct * vma)
1312 {
1313 int fbidx = iminor(file->f_path.dentry->d_inode);
1314 struct fb_info *info = registered_fb[fbidx];
1315 struct fb_ops *fb = info->fbops;
1316 unsigned long off;
1317 unsigned long start;
1318 u32 len;
1319
1320 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
1321 return -EINVAL;
1322 off = vma->vm_pgoff << PAGE_SHIFT;
1323 if (!fb)
1324 return -ENODEV;
1325 mutex_lock(&info->mm_lock);
1326 if (fb->fb_mmap) {
1327 int res;
1328 res = fb->fb_mmap(info, vma);
1329 mutex_unlock(&info->mm_lock);
1330 return res;
1331 }
1332
1333 /* frame buffer memory */
1334 start = info->fix.smem_start;
1335 len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len);
1336 if (off >= len) {
1337 /* memory mapped io */
1338 off -= len;
1339 if (info->var.accel_flags) {
1340 mutex_unlock(&info->mm_lock);
1341 return -EINVAL;
1342 }
1343 start = info->fix.mmio_start;
1344 len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len);
1345 }
1346 mutex_unlock(&info->mm_lock);
1347 start &= PAGE_MASK;
1348 if ((vma->vm_end - vma->vm_start + off) > len)
1349 return -EINVAL;
1350 off += start;
1351 vma->vm_pgoff = off >> PAGE_SHIFT;
1352 /* This is an IO map - tell maydump to skip this VMA */
1353 vma->vm_flags |= VM_IO | VM_RESERVED;
1354 fb_pgprotect(file, vma, off);
1355 if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
1356 vma->vm_end - vma->vm_start, vma->vm_page_prot))
1357 return -EAGAIN;
1358 return 0;
1359 }
看看就行,我也没分析过,呵呵
好了,想看看frambuffer_register做了了什么吗,
我觉得你还是去看看,有好东西,我这里就不说了