Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3515614
  • 博文数量: 1805
  • 博客积分: 135
  • 博客等级: 入伍新兵
  • 技术积分: 3345
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-19 20:01
文章分类

全部博文(1805)

文章存档

2017年(19)

2016年(80)

2015年(341)

2014年(438)

2013年(349)

2012年(332)

2011年(248)

分类: LINUX

2014-09-02 00:35:12

原文地址:DRM内核代码分析之二 作者:tbfly

    话未完毕,AMD/ATI的TTM+KMS已经进git了……
    所以,还是得抓紧,2.6.31出来,就更复杂了。GEM+TTM两套DRM内存管理子系统。开源的分裂或自由,随你怎么想。

    接着从i915.ko的编译文件出发。drivers/gpu/drm/i915/i915_drv.c
   
static unsigned int i915_modeset = -1;
module_param_named(modeset, i915_modeset, int, 0400);

   
    这几行代码,就是处理grub中,给内核传的参数"i915.modeset=1".

    很简单,所以看看变量“i915_modeset”如何影响代码执行的。直接跳到i915_init函数。
   
 #if defined(CONFIG_DRM_I915_KMS)
        if (i915_modeset != 0)
                driver.driver_features |= DRIVER_MODESET;
#endif
        if (i915_modeset == 1)
                driver.driver_features |= DRIVER_MODESET;

#ifdef CONFIG_VGA_CONSOLE
        if (vgacon_text_force() && i915_modeset == -1)
                driver.driver_features &= ~DRIVER_MODESET;
#endif
   
   只是影响一些flag的。关系到KMS是否开启。

   分析函数, 大头的是结构体“static struct drm_driver driver”里面的函数回调。
   先贴一段:
  
 static struct drm_driver driver = {
        /* don't use mtrr's here, the Xserver or user space app should
         * deal with them for intel hardware.
         */
        .driver_features =
            DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/
            DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM,
        .load = i915_driver_load,
        .unload = i915_driver_unload,
        .open = i915_driver_open,
        .lastclose = i915_driver_lastclose,
        .preclose = i915_driver_preclose,
        .postclose = i915_driver_postclose,
        .suspend = i915_suspend,
        .resume = i915_resume,
        .device_is_agp = i915_driver_device_is_agp,
        .enable_vblank = i915_enable_vblank,
        .irq_preinstall = i915_driver_irq_preinstall,
        .irq_postinstall = i915_driver_irq_postinstall,
        .irq_uninstall = i915_driver_irq_uninstall,
        .irq_handler = i915_driver_irq_handler,
        .reclaim_buffers = drm_core_reclaim_buffers,
        .get_map_ofs = drm_core_get_map_ofs,
        .get_reg_ofs = drm_core_get_reg_ofs,
        .master_create = i915_master_create,
        .master_destroy = i915_master_destroy,
#if defined(CONFIG_DEBUG_FS)
        .debugfs_init = i915_gem_debugfs_init,
        .debugfs_cleanup = i915_gem_debugfs_cleanup,
#endif
        .gem_init_object = i915_gem_init_object,
        .gem_free_object = i915_gem_free_object,
        .gem_vm_ops = &i915_gem_vm_ops,
        .ioctls = i915_ioctls,
        .fops = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
                 .ioctl = drm_ioctl,
                 .mmap = drm_gem_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
#ifdef CONFIG_COMPAT
                 .compat_ioctl = i915_compat_ioctl,
#endif
        },

        .pci_driver = {
                 .name = DRIVER_NAME,
                 .id_table = pciidlist,
                 .probe = i915_pci_probe,
                 .remove = i915_pci_remove,
#ifdef CONFIG_PM
                 .resume = i915_pci_resume,
                 .suspend = i915_pci_suspend,
#endif
        },
        .name = DRIVER_NAME,
        .desc = DRIVER_DESC,
        .date = DRIVER_DATE,
        .major = DRIVER_MAJOR,
        .minor = DRIVER_MINOR,
        .patchlevel = DRIVER_PATCHLEVEL,
};

   粗略看了一下,
        .gem_init_object = i915_gem_init_object,
        .gem_free_object = i915_gem_free_object,
        .gem_vm_ops = &i915_gem_vm_ops,
        .ioctls = i915_ioctls,
        ...
        .ioctl = drm_ioctl,
        .mmap = drm_gem_mmap,

   将是分析的难点.
   "struct drm_ioctl_desc i915_ioctls[]" 又是N多的回调函数……

 

   
阅读(2320) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~