Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10a23102 authored by Thierry Reding's avatar Thierry Reding Committed by Dave Airlie
Browse files

drm: Introduce drm_fb_helper_prepare()



To implement hotplug detection in a race-free manner, drivers must call
drm_kms_helper_poll_init() before hotplug events can be triggered. Such
events can be triggered right after any of the encoders or connectors
are initialized. At the same time, if the drm_fb_helper_hotplug_event()
helper is used by a driver, then the poll helper requires some parts of
the FB helper to be initialized to prevent a crash.

At the same time, drm_fb_helper_init() requires information that is not
necessarily available at such an early stage (number of CRTCs and
connectors), so it cannot be used yet.

Add a new helper, drm_fb_helper_prepare(), that initializes the bare
minimum needed to allow drm_kms_helper_poll_init() to execute and any
subsequent hotplug events to be processed properly.

Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 3a493879
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ int armada_fbdev_init(struct drm_device *dev)

	priv->fbdev = fbh;

	fbh->funcs = &armada_fb_helper_funcs;
	drm_fb_helper_prepare(dev, fbh, &armada_fb_helper_funcs);

	ret = drm_fb_helper_init(dev, fbh, 1, 1);
	if (ret) {
+3 −1
Original line number Diff line number Diff line
@@ -328,8 +328,10 @@ int ast_fbdev_init(struct drm_device *dev)
		return -ENOMEM;

	ast->fbdev = afbdev;
	afbdev->helper.funcs = &ast_fb_helper_funcs;
	spin_lock_init(&afbdev->dirty_lock);

	drm_fb_helper_prepare(dev, &afbdev->helper, &ast_fb_helper_funcs);

	ret = drm_fb_helper_init(dev, &afbdev->helper,
				 1, 1);
	if (ret) {
+2 −1
Original line number Diff line number Diff line
@@ -189,7 +189,8 @@ int bochs_fbdev_init(struct bochs_device *bochs)
{
	int ret;

	bochs->fb.helper.funcs = &bochs_fb_helper_funcs;
	drm_fb_helper_prepare(bochs->dev, &bochs->fb.helper,
			      &bochs_fb_helper_funcs);

	ret = drm_fb_helper_init(bochs->dev, &bochs->fb.helper,
				 1, 1);
+3 −1
Original line number Diff line number Diff line
@@ -306,9 +306,11 @@ int cirrus_fbdev_init(struct cirrus_device *cdev)
		return -ENOMEM;

	cdev->mode_info.gfbdev = gfbdev;
	gfbdev->helper.funcs = &cirrus_fb_helper_funcs;
	spin_lock_init(&gfbdev->dirty_lock);

	drm_fb_helper_prepare(cdev->dev, &gfbdev->helper,
			      &cirrus_fb_helper_funcs);

	ret = drm_fb_helper_init(cdev->dev, &gfbdev->helper,
				 cdev->num_crtc, CIRRUSFB_CONN_LIMIT);
	if (ret) {
+2 −1
Original line number Diff line number Diff line
@@ -354,9 +354,10 @@ struct drm_fbdev_cma *drm_fbdev_cma_init(struct drm_device *dev,
		return ERR_PTR(-ENOMEM);
	}

	fbdev_cma->fb_helper.funcs = &drm_fb_cma_helper_funcs;
	helper = &fbdev_cma->fb_helper;

	drm_fb_helper_prepare(dev, helper, &drm_fb_cma_helper_funcs);

	ret = drm_fb_helper_init(dev, helper, num_crtc, max_conn_count);
	if (ret < 0) {
		dev_err(dev->dev, "Failed to initialize drm fb helper.\n");
Loading