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

drm/imx: 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: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Acked-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20171115142001.45358-8-noralf@tronnes.org
parent ce4eb35b
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
struct imx_drm_device { struct imx_drm_device {
struct drm_device *drm; struct drm_device *drm;
unsigned int pipes; unsigned int pipes;
struct drm_fbdev_cma *fbhelper;
struct drm_atomic_state *state; struct drm_atomic_state *state;
}; };
...@@ -47,13 +46,6 @@ static int legacyfb_depth = 16; ...@@ -47,13 +46,6 @@ static int legacyfb_depth = 16;
module_param(legacyfb_depth, int, 0444); module_param(legacyfb_depth, int, 0444);
#endif #endif
static void imx_drm_driver_lastclose(struct drm_device *drm)
{
struct imx_drm_device *imxdrm = drm->dev_private;
drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
}
DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops); DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops);
void imx_drm_connector_destroy(struct drm_connector *connector) void imx_drm_connector_destroy(struct drm_connector *connector)
...@@ -69,13 +61,6 @@ void imx_drm_encoder_destroy(struct drm_encoder *encoder) ...@@ -69,13 +61,6 @@ void imx_drm_encoder_destroy(struct drm_encoder *encoder)
} }
EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy); EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy);
static void imx_drm_output_poll_changed(struct drm_device *drm)
{
struct imx_drm_device *imxdrm = drm->dev_private;
drm_fbdev_cma_hotplug_event(imxdrm->fbhelper);
}
static int imx_drm_atomic_check(struct drm_device *dev, static int imx_drm_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state) struct drm_atomic_state *state)
{ {
...@@ -107,7 +92,7 @@ static int imx_drm_atomic_check(struct drm_device *dev, ...@@ -107,7 +92,7 @@ static int imx_drm_atomic_check(struct drm_device *dev,
static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
.fb_create = drm_gem_fb_create, .fb_create = drm_gem_fb_create,
.output_poll_changed = imx_drm_output_poll_changed, .output_poll_changed = drm_fb_helper_output_poll_changed,
.atomic_check = imx_drm_atomic_check, .atomic_check = imx_drm_atomic_check,
.atomic_commit = drm_atomic_helper_commit, .atomic_commit = drm_atomic_helper_commit,
}; };
...@@ -186,7 +171,7 @@ static const struct drm_ioctl_desc imx_drm_ioctls[] = { ...@@ -186,7 +171,7 @@ static const struct drm_ioctl_desc imx_drm_ioctls[] = {
static struct drm_driver imx_drm_driver = { static struct drm_driver imx_drm_driver = {
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
DRIVER_ATOMIC, DRIVER_ATOMIC,
.lastclose = imx_drm_driver_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,
...@@ -298,12 +283,9 @@ static int imx_drm_bind(struct device *dev) ...@@ -298,12 +283,9 @@ static int imx_drm_bind(struct device *dev)
dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n"); dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n");
legacyfb_depth = 16; legacyfb_depth = 16;
} }
imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth, MAX_CRTC); ret = drm_fb_cma_fbdev_init(drm, legacyfb_depth, MAX_CRTC);
if (IS_ERR(imxdrm->fbhelper)) { if (ret)
ret = PTR_ERR(imxdrm->fbhelper);
imxdrm->fbhelper = NULL;
goto err_unbind; goto err_unbind;
}
#endif #endif
drm_kms_helper_poll_init(drm); drm_kms_helper_poll_init(drm);
...@@ -317,8 +299,7 @@ static int imx_drm_bind(struct device *dev) ...@@ -317,8 +299,7 @@ static int imx_drm_bind(struct device *dev)
err_fbhelper: err_fbhelper:
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) #if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
if (imxdrm->fbhelper) drm_fb_cma_fbdev_fini(drm);
drm_fbdev_cma_fini(imxdrm->fbhelper);
err_unbind: err_unbind:
#endif #endif
component_unbind_all(drm->dev, drm); component_unbind_all(drm->dev, drm);
...@@ -333,14 +314,12 @@ static int imx_drm_bind(struct device *dev) ...@@ -333,14 +314,12 @@ static int imx_drm_bind(struct device *dev)
static void imx_drm_unbind(struct device *dev) static void imx_drm_unbind(struct device *dev)
{ {
struct drm_device *drm = dev_get_drvdata(dev); struct drm_device *drm = dev_get_drvdata(dev);
struct imx_drm_device *imxdrm = drm->dev_private;
drm_dev_unregister(drm); drm_dev_unregister(drm);
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
if (imxdrm->fbhelper) drm_fb_cma_fbdev_fini(drm);
drm_fbdev_cma_fini(imxdrm->fbhelper);
drm_mode_config_cleanup(drm); drm_mode_config_cleanup(drm);
......
...@@ -8,7 +8,6 @@ struct drm_connector; ...@@ -8,7 +8,6 @@ struct drm_connector;
struct drm_device; struct drm_device;
struct drm_display_mode; struct drm_display_mode;
struct drm_encoder; struct drm_encoder;
struct drm_fbdev_cma;
struct drm_framebuffer; struct drm_framebuffer;
struct drm_plane; struct drm_plane;
struct imx_drm_crtc; struct imx_drm_crtc;
......
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