diff options
author | Noralf Trønnes <noralf@tronnes.org> | 2017-11-15 09:19:46 -0500 |
---|---|---|
committer | Noralf Trønnes <noralf@tronnes.org> | 2017-12-08 08:47:40 -0500 |
commit | b2ad94721047c0f047f36c172d68fed93a8f3fcd (patch) | |
tree | 2f2dca04f53153111af7c8ece4627ddb11f15bc2 /drivers/gpu/drm/imx/imx-drm-core.c | |
parent | ce4eb35bfa4034f3076f71666e869cd729e3d0e4 (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.c | 33 |
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 @@ | |||
38 | struct imx_drm_device { | 38 | struct 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; | |||
47 | module_param(legacyfb_depth, int, 0444); | 46 | module_param(legacyfb_depth, int, 0444); |
48 | #endif | 47 | #endif |
49 | 48 | ||
50 | static 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 | |||
57 | DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops); | 49 | DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops); |
58 | 50 | ||
59 | void imx_drm_connector_destroy(struct drm_connector *connector) | 51 | void imx_drm_connector_destroy(struct drm_connector *connector) |
@@ -69,13 +61,6 @@ void imx_drm_encoder_destroy(struct drm_encoder *encoder) | |||
69 | } | 61 | } |
70 | EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy); | 62 | EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy); |
71 | 63 | ||
72 | static 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 | |||
79 | static int imx_drm_atomic_check(struct drm_device *dev, | 64 | static 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 | ||
108 | static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { | 93 | static 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[] = { | |||
186 | static struct drm_driver imx_drm_driver = { | 171 | static 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) | |||
317 | err_fbhelper: | 299 | err_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); | ||
322 | err_unbind: | 303 | err_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: | |||
333 | static void imx_drm_unbind(struct device *dev) | 314 | static 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 | ||