Commit f05682a8 authored by Noralf Trønnes's avatar Noralf Trønnes

drm/zte: Use drm_fb_cma_fbdev_init/fini()

Use drm_fb_cma_fbdev_init() and drm_fb_cma_fbdev_fini() which relies on
the fact that drm_device holds a pointer to the drm_fb_helper structure.
This means that the driver doesn't have to keep track of that.
Also use the drm_fb_helper functions directly.

Cc: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Acked-by: default avatarShawn Guo <shawnguo@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20171115142001.45358-19-noralf@tronnes.org
parent b8f429a7
...@@ -29,37 +29,19 @@ ...@@ -29,37 +29,19 @@
#include "zx_drm_drv.h" #include "zx_drm_drv.h"
#include "zx_vou.h" #include "zx_vou.h"
struct zx_drm_private {
struct drm_fbdev_cma *fbdev;
};
static void zx_drm_fb_output_poll_changed(struct drm_device *drm)
{
struct zx_drm_private *priv = drm->dev_private;
drm_fbdev_cma_hotplug_event(priv->fbdev);
}
static const struct drm_mode_config_funcs zx_drm_mode_config_funcs = { static const struct drm_mode_config_funcs zx_drm_mode_config_funcs = {
.fb_create = drm_gem_fb_create, .fb_create = drm_gem_fb_create,
.output_poll_changed = zx_drm_fb_output_poll_changed, .output_poll_changed = drm_fb_helper_output_poll_changed,
.atomic_check = drm_atomic_helper_check, .atomic_check = drm_atomic_helper_check,
.atomic_commit = drm_atomic_helper_commit, .atomic_commit = drm_atomic_helper_commit,
}; };
static void zx_drm_lastclose(struct drm_device *drm)
{
struct zx_drm_private *priv = drm->dev_private;
drm_fbdev_cma_restore_mode(priv->fbdev);
}
DEFINE_DRM_GEM_CMA_FOPS(zx_drm_fops); DEFINE_DRM_GEM_CMA_FOPS(zx_drm_fops);
static struct drm_driver zx_drm_driver = { static struct drm_driver zx_drm_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
DRIVER_ATOMIC, DRIVER_ATOMIC,
.lastclose = zx_drm_lastclose, .lastclose = drm_fb_helper_lastclose,
.gem_free_object_unlocked = drm_gem_cma_free_object, .gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops, .gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = drm_gem_cma_dumb_create, .dumb_create = drm_gem_cma_dumb_create,
...@@ -83,18 +65,12 @@ static struct drm_driver zx_drm_driver = { ...@@ -83,18 +65,12 @@ static struct drm_driver zx_drm_driver = {
static int zx_drm_bind(struct device *dev) static int zx_drm_bind(struct device *dev)
{ {
struct drm_device *drm; struct drm_device *drm;
struct zx_drm_private *priv;
int ret; int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
drm = drm_dev_alloc(&zx_drm_driver, dev); drm = drm_dev_alloc(&zx_drm_driver, dev);
if (IS_ERR(drm)) if (IS_ERR(drm))
return PTR_ERR(drm); return PTR_ERR(drm);
drm->dev_private = priv;
dev_set_drvdata(dev, drm); dev_set_drvdata(dev, drm);
drm_mode_config_init(drm); drm_mode_config_init(drm);
...@@ -125,12 +101,9 @@ static int zx_drm_bind(struct device *dev) ...@@ -125,12 +101,9 @@ static int zx_drm_bind(struct device *dev)
drm_mode_config_reset(drm); drm_mode_config_reset(drm);
drm_kms_helper_poll_init(drm); drm_kms_helper_poll_init(drm);
priv->fbdev = drm_fbdev_cma_init(drm, 32, ret = drm_fb_cma_fbdev_init(drm, 32, 0);
drm->mode_config.num_connector); if (ret) {
if (IS_ERR(priv->fbdev)) {
ret = PTR_ERR(priv->fbdev);
DRM_DEV_ERROR(dev, "failed to init cma fbdev: %d\n", ret); DRM_DEV_ERROR(dev, "failed to init cma fbdev: %d\n", ret);
priv->fbdev = NULL;
goto out_poll_fini; goto out_poll_fini;
} }
...@@ -141,10 +114,7 @@ static int zx_drm_bind(struct device *dev) ...@@ -141,10 +114,7 @@ static int zx_drm_bind(struct device *dev)
return 0; return 0;
out_fbdev_fini: out_fbdev_fini:
if (priv->fbdev) { drm_fb_cma_fbdev_fini(drm);
drm_fbdev_cma_fini(priv->fbdev);
priv->fbdev = NULL;
}
out_poll_fini: out_poll_fini:
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
drm_mode_config_cleanup(drm); drm_mode_config_cleanup(drm);
...@@ -152,7 +122,6 @@ static int zx_drm_bind(struct device *dev) ...@@ -152,7 +122,6 @@ static int zx_drm_bind(struct device *dev)
component_unbind_all(dev, drm); component_unbind_all(dev, drm);
out_unregister: out_unregister:
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
drm->dev_private = NULL;
drm_dev_unref(drm); drm_dev_unref(drm);
return ret; return ret;
} }
...@@ -160,18 +129,13 @@ static int zx_drm_bind(struct device *dev) ...@@ -160,18 +129,13 @@ static int zx_drm_bind(struct device *dev)
static void zx_drm_unbind(struct device *dev) static void zx_drm_unbind(struct device *dev)
{ {
struct drm_device *drm = dev_get_drvdata(dev); struct drm_device *drm = dev_get_drvdata(dev);
struct zx_drm_private *priv = drm->dev_private;
drm_dev_unregister(drm); drm_dev_unregister(drm);
if (priv->fbdev) { drm_fb_cma_fbdev_fini(drm);
drm_fbdev_cma_fini(priv->fbdev);
priv->fbdev = NULL;
}
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
drm_mode_config_cleanup(drm); drm_mode_config_cleanup(drm);
component_unbind_all(dev, drm); component_unbind_all(dev, drm);
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
drm->dev_private = NULL;
drm_dev_unref(drm); drm_dev_unref(drm);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment