aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/imx/imx-drm-core.c
diff options
context:
space:
mode:
authorNoralf Trønnes <noralf@tronnes.org>2017-11-15 09:19:46 -0500
committerNoralf Trønnes <noralf@tronnes.org>2017-12-08 08:47:40 -0500
commitb2ad94721047c0f047f36c172d68fed93a8f3fcd (patch)
tree2f2dca04f53153111af7c8ece4627ddb11f15bc2 /drivers/gpu/drm/imx/imx-drm-core.c
parentce4eb35bfa4034f3076f71666e869cd729e3d0e4 (diff)
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: Noralf Trønnes <noralf@tronnes.org> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Link: https://patchwork.freedesktop.org/patch/msgid/20171115142001.45358-8-noralf@tronnes.org
Diffstat (limited to 'drivers/gpu/drm/imx/imx-drm-core.c')
-rw-r--r--drivers/gpu/drm/imx/imx-drm-core.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 17d2f3a1c562..3f2b4afcb8a7 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -38,7 +38,6 @@
38struct imx_drm_device { 38struct imx_drm_device {
39 struct drm_device *drm; 39 struct drm_device *drm;
40 unsigned int pipes; 40 unsigned int pipes;
41 struct drm_fbdev_cma *fbhelper;
42 struct drm_atomic_state *state; 41 struct drm_atomic_state *state;
43}; 42};
44 43
@@ -47,13 +46,6 @@ static int legacyfb_depth = 16;
47module_param(legacyfb_depth, int, 0444); 46module_param(legacyfb_depth, int, 0444);
48#endif 47#endif
49 48
50static void imx_drm_driver_lastclose(struct drm_device *drm)
51{
52 struct imx_drm_device *imxdrm = drm->dev_private;
53
54 drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
55}
56
57DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops); 49DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops);
58 50
59void imx_drm_connector_destroy(struct drm_connector *connector) 51void imx_drm_connector_destroy(struct drm_connector *connector)
@@ -69,13 +61,6 @@ void imx_drm_encoder_destroy(struct drm_encoder *encoder)
69} 61}
70EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy); 62EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy);
71 63
72static void imx_drm_output_poll_changed(struct drm_device *drm)
73{
74 struct imx_drm_device *imxdrm = drm->dev_private;
75
76 drm_fbdev_cma_hotplug_event(imxdrm->fbhelper);
77}
78
79static int imx_drm_atomic_check(struct drm_device *dev, 64static int imx_drm_atomic_check(struct drm_device *dev,
80 struct drm_atomic_state *state) 65 struct drm_atomic_state *state)
81{ 66{
@@ -107,7 +92,7 @@ static int imx_drm_atomic_check(struct drm_device *dev,
107 92
108static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { 93static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
109 .fb_create = drm_gem_fb_create, 94 .fb_create = drm_gem_fb_create,
110 .output_poll_changed = imx_drm_output_poll_changed, 95 .output_poll_changed = drm_fb_helper_output_poll_changed,
111 .atomic_check = imx_drm_atomic_check, 96 .atomic_check = imx_drm_atomic_check,
112 .atomic_commit = drm_atomic_helper_commit, 97 .atomic_commit = drm_atomic_helper_commit,
113}; 98};
@@ -186,7 +171,7 @@ static const struct drm_ioctl_desc imx_drm_ioctls[] = {
186static struct drm_driver imx_drm_driver = { 171static struct drm_driver imx_drm_driver = {
187 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | 172 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
188 DRIVER_ATOMIC, 173 DRIVER_ATOMIC,
189 .lastclose = imx_drm_driver_lastclose, 174 .lastclose = drm_fb_helper_lastclose,
190 .gem_free_object_unlocked = drm_gem_cma_free_object, 175 .gem_free_object_unlocked = drm_gem_cma_free_object,
191 .gem_vm_ops = &drm_gem_cma_vm_ops, 176 .gem_vm_ops = &drm_gem_cma_vm_ops,
192 .dumb_create = drm_gem_cma_dumb_create, 177 .dumb_create = drm_gem_cma_dumb_create,
@@ -298,12 +283,9 @@ static int imx_drm_bind(struct device *dev)
298 dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n"); 283 dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n");
299 legacyfb_depth = 16; 284 legacyfb_depth = 16;
300 } 285 }
301 imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth, MAX_CRTC); 286 ret = drm_fb_cma_fbdev_init(drm, legacyfb_depth, MAX_CRTC);
302 if (IS_ERR(imxdrm->fbhelper)) { 287 if (ret)
303 ret = PTR_ERR(imxdrm->fbhelper);
304 imxdrm->fbhelper = NULL;
305 goto err_unbind; 288 goto err_unbind;
306 }
307#endif 289#endif
308 290
309 drm_kms_helper_poll_init(drm); 291 drm_kms_helper_poll_init(drm);
@@ -317,8 +299,7 @@ static int imx_drm_bind(struct device *dev)
317err_fbhelper: 299err_fbhelper:
318 drm_kms_helper_poll_fini(drm); 300 drm_kms_helper_poll_fini(drm);
319#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) 301#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
320 if (imxdrm->fbhelper) 302 drm_fb_cma_fbdev_fini(drm);
321 drm_fbdev_cma_fini(imxdrm->fbhelper);
322err_unbind: 303err_unbind:
323#endif 304#endif
324 component_unbind_all(drm->dev, drm); 305 component_unbind_all(drm->dev, drm);
@@ -333,14 +314,12 @@ err_unref:
333static void imx_drm_unbind(struct device *dev) 314static void imx_drm_unbind(struct device *dev)
334{ 315{
335 struct drm_device *drm = dev_get_drvdata(dev); 316 struct drm_device *drm = dev_get_drvdata(dev);
336 struct imx_drm_device *imxdrm = drm->dev_private;
337 317
338 drm_dev_unregister(drm); 318 drm_dev_unregister(drm);
339 319
340 drm_kms_helper_poll_fini(drm); 320 drm_kms_helper_poll_fini(drm);
341 321
342 if (imxdrm->fbhelper) 322 drm_fb_cma_fbdev_fini(drm);
343 drm_fbdev_cma_fini(imxdrm->fbhelper);
344 323
345 drm_mode_config_cleanup(drm); 324 drm_mode_config_cleanup(drm);
346 325