From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
Date: Wed, 15 Nov 2017 15:19:53 +0100
Subject: drm/sun4i: Use drm_fb_cma_fbdev_init/fini()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Git-commit: 22efc85b6ca5c2df26fc6fcba1d049927f0a0557
Patch-mainline: v4.16-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166
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: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171115142001.45358-15-noralf@tronnes.org
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
drivers/gpu/drm/sun4i/sun4i_drv.c | 14 +++-----------
drivers/gpu/drm/sun4i/sun4i_drv.h | 2 --
drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 18 +++++-------------
drivers/gpu/drm/sun4i/sun4i_framebuffer.h | 2 +-
4 files changed, 9 insertions(+), 27 deletions(-)
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -26,20 +26,13 @@
#include "sun4i_framebuffer.h"
#include "sun4i_tcon.h"
-static void sun4i_drv_lastclose(struct drm_device *dev)
-{
- struct sun4i_drv *drv = dev->dev_private;
-
- drm_fbdev_cma_restore_mode(drv->fbdev);
-}
-
DEFINE_DRM_GEM_CMA_FOPS(sun4i_drv_fops);
static struct drm_driver sun4i_drv_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
/* Generic Operations */
- .lastclose = sun4i_drv_lastclose,
+ .lastclose = drm_fb_helper_lastclose,
.fops = &sun4i_drv_fops,
.name = "sun4i-drm",
.desc = "Allwinner sun4i Display Engine",
@@ -126,10 +119,9 @@ static int sun4i_drv_bind(struct device
sun4i_remove_framebuffers();
/* Create our framebuffer */
- drv->fbdev = sun4i_framebuffer_init(drm);
- if (IS_ERR(drv->fbdev)) {
+ ret = sun4i_framebuffer_init(drm);
+ if (ret) {
dev_err(drm->dev, "Couldn't create our framebuffer\n");
- ret = PTR_ERR(drv->fbdev);
goto cleanup_mode_config;
}
--- a/drivers/gpu/drm/sun4i/sun4i_drv.h
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.h
@@ -20,8 +20,6 @@
struct sun4i_drv {
struct list_head engine_list;
struct list_head tcon_list;
-
- struct drm_fbdev_cma *fbdev;
};
#endif /* _SUN4I_DRV_H_ */
--- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
@@ -11,6 +11,7 @@
*/
#include <drm/drm_atomic_helper.h>
+#include <drm/drm_fb_helper.h>
#include <drm/drm_fb_cma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drmP.h>
@@ -18,21 +19,14 @@
#include "sun4i_drv.h"
#include "sun4i_framebuffer.h"
-static void sun4i_de_output_poll_changed(struct drm_device *drm)
-{
- struct sun4i_drv *drv = drm->dev_private;
-
- drm_fbdev_cma_hotplug_event(drv->fbdev);
-}
-
static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {
- .output_poll_changed = sun4i_de_output_poll_changed,
+ .output_poll_changed = drm_fb_helper_output_poll_changed,
.atomic_check = drm_atomic_helper_check,
.atomic_commit = drm_atomic_helper_commit,
.fb_create = drm_gem_fb_create,
};
-struct drm_fbdev_cma *sun4i_framebuffer_init(struct drm_device *drm)
+int sun4i_framebuffer_init(struct drm_device *drm)
{
drm_mode_config_reset(drm);
@@ -41,12 +35,10 @@ struct drm_fbdev_cma *sun4i_framebuffer_
drm->mode_config.funcs = &sun4i_de_mode_config_funcs;
- return drm_fbdev_cma_init(drm, 32, drm->mode_config.num_connector);
+ return drm_fb_cma_fbdev_init(drm, 32, 0);
}
void sun4i_framebuffer_free(struct drm_device *drm)
{
- struct sun4i_drv *drv = drm->dev_private;
-
- drm_fbdev_cma_fini(drv->fbdev);
+ drm_fb_cma_fbdev_fini(drm);
}
--- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.h
+++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.h
@@ -13,7 +13,7 @@
#ifndef _SUN4I_FRAMEBUFFER_H_
#define _SUN4I_FRAMEBUFFER_H_
-struct drm_fbdev_cma *sun4i_framebuffer_init(struct drm_device *drm);
+int sun4i_framebuffer_init(struct drm_device *drm);
void sun4i_framebuffer_free(struct drm_device *drm);
#endif /* _SUN4I_FRAMEBUFFER_H_ */