Den 02.09.2016 10:22, skrev David Herrmann:
Create a simple fbdev device during SimpleDRM setup so legacy user-space
and fbcon can use it.
Signed-off-by: David Herrmann <dh.herrmann@xxxxxxxxx>
[...]
diff --git a/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c b/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c
[...]
+void sdrm_fbdev_bind(struct sdrm_device *sdrm)
+{
+ struct drm_fb_helper *fbdev;
+ int r;
+
+ fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
+ if (!fbdev)
+ return;
+
+ drm_fb_helper_prepare(sdrm->ddev, fbdev, &sdrm_fbdev_funcs);
+
+ r = drm_fb_helper_init(sdrm->ddev, fbdev, 1, 1);
+ if (r < 0)
+ goto error;
+
+ r = drm_fb_helper_single_add_all_connectors(fbdev);
+ if (r < 0)
+ goto error;
+
+ r = drm_fb_helper_initial_config(fbdev,
+ sdrm->ddev->mode_config.preferred_depth);
+ if (r < 0)
+ goto error;
+
+ if (!fbdev->fbdev)
+ goto error;
+
+ sdrm->fbdev = fbdev;
+ return;
+
+error:
+ drm_fb_helper_fini(fbdev);
+ kfree(fbdev);
+}
+
+void sdrm_fbdev_unbind(struct sdrm_device *sdrm)
+{
+ struct drm_fb_helper *fbdev = sdrm->fbdev;
+
+ if (!fbdev)
+ return;
+
+ sdrm->fbdev = NULL;
+ drm_fb_helper_unregister_fbi(fbdev);
+ cancel_work_sync(&fbdev->dirty_work);
+ drm_fb_helper_release_fbi(fbdev);
+ drm_framebuffer_unreference(fbdev->fb);
I get a warning that there are still fb's left during unbind:
[ 48.666003] WARNING: CPU: 0 PID: 716 at
drivers/gpu/drm/drm_crtc.c:3855 drm_mode_config_cleanup+0x180/0x1f4 [drm]
This worked:
- drm_framebuffer_unreference(fbdev->fb);
+ drm_framebuffer_unregister_private(fbdev->fb);
+ drm_framebuffer_cleanup(fbdev->fb);
Noralf.
+ fbdev->fb = NULL;
+ drm_fb_helper_fini(fbdev);
+ kfree(fbdev);
+}
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel