drm core初始化
/*** drm_sysfs_init - initialize sysfs helpers** This is used to create the DRM class, which is the implicit parent of any* other top-level DRM sysfs objects.** You must call drm_sysfs_destroy() to release the allocated resources.** Return: 0 on success, negative error code on failure.*/
int drm_sysfs_init(void)
{int err;drm_class = class_create(THIS_MODULE, "drm");//sys/class/drmif (IS_ERR(drm_class))return PTR_ERR(drm_class);err = class_create_file(drm_class, &class_attr_version.attr);if (err) {class_destroy(drm_class);drm_class = NULL;return err;}drm_class->devnode = drm_devnode;drm_setup_hdcp_srm(drm_class);return 0;
}drm core
static int __init drm_core_init(void)
{int ret;drm_connector_ida_init();idr_init(&drm_minors_idr);ret = drm_sysfs_init();//drm sysfsif (ret < 0) {DRM_ERROR("Cannot create DRM class: %d\n", ret);goto error;}drm_debugfs_root = debugfs_create_dir("dri", NULL);//sys/kernel/debug/driret = register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops);if (ret < 0)goto error;drm_core_init_complete = true;DRM_DEBUG("Initialized\n");return 0;error:drm_core_exit();return ret;
}module_init(drm_core_init);
sysfs node
ls -l /sys/kernel/debug/dri/0/
总用量 0
-r--r--r-- 1 root root 0 1月 1 2020 clients
drwxr-xr-x 2 root root 0 1月 1 2020 crtc-0
drwxr-xr-x 2 root root 0 1月 1 2020 crtc-1
-r--r--r-- 1 root root 0 1月 1 2020 framebuffer
-r--r--r-- 1 root root 0 1月 1 2020 gem_names
drwxr-xr-x 2 root root 0 1月 1 2020 HDMI-A-1
-r--r--r-- 1 root root 0 1月 1 2020 internal_clients
-r--r--r-- 1 root root 0 1月 1 2020 name
-r--r--r-- 1 root root 0 1月 1 2020 state
drwxr-xr-x 2 root root 0 1月 1 2020 VGA-1
sys/class/drm
ls -l /sys/class/drm/
总用量 0
lrwxrwxrwx 1 root root 0 1月 1 2020 card0 -> ../../devices/pci0000:00/0000:00:03.0/0000:04:00.0/drm/card0
lrwxrwxrwx 1 root root 0 1月 1 2020 card0-HDMI-A-1 -> ../../devices/pci0000:00/0000:00:03.0/0000:04:00.0/drm/card0/card0-HDMI-A-1
lrwxrwxrwx 1 root root 0 1月 1 2020 card0-VGA-1 -> ../../devices/pci0000:00/0000:00:03.0/0000:04:00.0/drm/card0/card0-VGA-1
lrwxrwxrwx 1 root root 0 1月 1 2020 renderD128 -> ../../devices/pci0000:00/0000:00:03.0/0000:04:00.0/drm/renderD128
lrwxrwxrwx 1 root root 0 1月 1 2020 ttm -> ../../devices/virtual/drm/ttm
-r--r--r-- 1 root root 4096 1月 1 2020 version