From 331bd404a1b5394dd92573e95dd942d88675da51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Noralf=20Tr=C3=B8nnes?= Date: Wed, 28 Nov 2018 22:27:09 +0100 Subject: [PATCH] drm/hisilicon/kirin: Use drm_fbdev_generic_setup() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The CMA helper is already using the drm_fb_helper_generic_probe part of the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister(). The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing. struct kirin_drm_private can be removed now that driver doesn't have to store the fbdev pointer. Cc: Xinliang Liu Cc: Rongrong Zou Cc: Xinwei Kong Cc: Chen Feng Signed-off-by: Noralf Trønnes Acked-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20181128212713.43500-2-noralf@tronnes.org --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 38 ++----------------------- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 4 --- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c index e6a62d5a00a3..15e32e5d9101 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -33,32 +34,15 @@ static struct kirin_dc_ops *dc_ops; static int kirin_drm_kms_cleanup(struct drm_device *dev) { - struct kirin_drm_private *priv = dev->dev_private; - - if (priv->fbdev) { - drm_fbdev_cma_fini(priv->fbdev); - priv->fbdev = NULL; - } - drm_kms_helper_poll_fini(dev); dc_ops->cleanup(to_platform_device(dev->dev)); drm_mode_config_cleanup(dev); - devm_kfree(dev->dev, priv); - dev->dev_private = NULL; return 0; } -static void kirin_fbdev_output_poll_changed(struct drm_device *dev) -{ - struct kirin_drm_private *priv = dev->dev_private; - - drm_fbdev_cma_hotplug_event(priv->fbdev); -} - static const struct drm_mode_config_funcs kirin_drm_mode_config_funcs = { .fb_create = drm_gem_fb_create, - .output_poll_changed = kirin_fbdev_output_poll_changed, .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, }; @@ -76,14 +60,8 @@ static void kirin_drm_mode_config_init(struct drm_device *dev) static int kirin_drm_kms_init(struct drm_device *dev) { - struct kirin_drm_private *priv; int ret; - priv = devm_kzalloc(dev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - dev->dev_private = priv; dev_set_drvdata(dev->dev, dev); /* dev->mode_config initialization */ @@ -117,26 +95,14 @@ static int kirin_drm_kms_init(struct drm_device *dev) /* init kms poll for handling hpd */ drm_kms_helper_poll_init(dev); - priv->fbdev = drm_fbdev_cma_init(dev, 32, - dev->mode_config.num_connector); - - if (IS_ERR(priv->fbdev)) { - DRM_ERROR("failed to initialize fbdev.\n"); - ret = PTR_ERR(priv->fbdev); - goto err_cleanup_poll; - } return 0; -err_cleanup_poll: - drm_kms_helper_poll_fini(dev); err_unbind_all: component_unbind_all(dev->dev, dev); err_dc_cleanup: dc_ops->cleanup(to_platform_device(dev->dev)); err_mode_config_cleanup: drm_mode_config_cleanup(dev); - devm_kfree(dev->dev, priv); - dev->dev_private = NULL; return ret; } @@ -199,6 +165,8 @@ static int kirin_drm_bind(struct device *dev) if (ret) goto err_kms_cleanup; + drm_fbdev_generic_setup(drm_dev, 32); + return 0; err_kms_cleanup: diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 56cb62df065c..ad027d1cc826 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -19,10 +19,6 @@ struct kirin_dc_ops { void (*cleanup)(struct platform_device *pdev); }; -struct kirin_drm_private { - struct drm_fbdev_cma *fbdev; -}; - extern const struct kirin_dc_ops ade_dc_ops; #endif /* __KIRIN_DRM_DRV_H__ */ -- 2.11.0