aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/imx/imx-drm-core.c
diff options
context:
space:
mode:
authorNoralf Trønnes <noralf@tronnes.org>2018-09-08 09:46:39 -0400
committerNoralf Trønnes <noralf@tronnes.org>2018-09-25 05:32:15 -0400
commitf53705fd98030a814fb8e9c05bbed9d0c49d211b (patch)
treee090549b0f8d58054ecdc5af0797ef9ed87717e6 /drivers/gpu/drm/imx/imx-drm-core.c
parent9595809896d7ecfdf779b803055c0eb4ae846921 (diff)
drm/imx: Use drm_fbdev_generic_setup()
The CMA helper is already using the drm_fb_helper_generic_probe part of the generic fbdev emulation. This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister(). The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing. CONFIG_DRM_FBDEV_EMULATION wasn't honoured by the CMA helper, but it is by drm_fb_helper. Cc: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Acked-by: Sam Ravnborg <sam@ravnborg.org> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Link: https://patchwork.freedesktop.org/patch/msgid/20180908134648.2582-12-noralf@tronnes.org
Diffstat (limited to 'drivers/gpu/drm/imx/imx-drm-core.c')
-rw-r--r--drivers/gpu/drm/imx/imx-drm-core.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 5ea0c82f9957..a70f3131a377 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -86,7 +86,6 @@ static int imx_drm_atomic_check(struct drm_device *dev,
86 86
87static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { 87static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
88 .fb_create = drm_gem_fb_create, 88 .fb_create = drm_gem_fb_create,
89 .output_poll_changed = drm_fb_helper_output_poll_changed,
90 .atomic_check = imx_drm_atomic_check, 89 .atomic_check = imx_drm_atomic_check,
91 .atomic_commit = drm_atomic_helper_commit, 90 .atomic_commit = drm_atomic_helper_commit,
92}; 91};
@@ -165,7 +164,6 @@ static const struct drm_ioctl_desc imx_drm_ioctls[] = {
165static struct drm_driver imx_drm_driver = { 164static struct drm_driver imx_drm_driver = {
166 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | 165 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
167 DRIVER_ATOMIC, 166 DRIVER_ATOMIC,
168 .lastclose = drm_fb_helper_lastclose,
169 .gem_free_object_unlocked = drm_gem_cma_free_object, 167 .gem_free_object_unlocked = drm_gem_cma_free_object,
170 .gem_vm_ops = &drm_gem_cma_vm_ops, 168 .gem_vm_ops = &drm_gem_cma_vm_ops,
171 .dumb_create = drm_gem_cma_dumb_create, 169 .dumb_create = drm_gem_cma_dumb_create,
@@ -263,30 +261,23 @@ static int imx_drm_bind(struct device *dev)
263 * The fb helper takes copies of key hardware information, so the 261 * The fb helper takes copies of key hardware information, so the
264 * crtcs/connectors/encoders must not change after this point. 262 * crtcs/connectors/encoders must not change after this point.
265 */ 263 */
266#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
267 if (legacyfb_depth != 16 && legacyfb_depth != 32) { 264 if (legacyfb_depth != 16 && legacyfb_depth != 32) {
268 dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n"); 265 dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n");
269 legacyfb_depth = 16; 266 legacyfb_depth = 16;
270 } 267 }
271 ret = drm_fb_cma_fbdev_init(drm, legacyfb_depth, MAX_CRTC);
272 if (ret)
273 goto err_unbind;
274#endif
275 268
276 drm_kms_helper_poll_init(drm); 269 drm_kms_helper_poll_init(drm);
277 270
278 ret = drm_dev_register(drm, 0); 271 ret = drm_dev_register(drm, 0);
279 if (ret) 272 if (ret)
280 goto err_fbhelper; 273 goto err_poll_fini;
274
275 drm_fbdev_generic_setup(drm, legacyfb_depth);
281 276
282 return 0; 277 return 0;
283 278
284err_fbhelper: 279err_poll_fini:
285 drm_kms_helper_poll_fini(drm); 280 drm_kms_helper_poll_fini(drm);
286#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
287 drm_fb_cma_fbdev_fini(drm);
288err_unbind:
289#endif
290 component_unbind_all(drm->dev, drm); 281 component_unbind_all(drm->dev, drm);
291err_kms: 282err_kms:
292 drm_mode_config_cleanup(drm); 283 drm_mode_config_cleanup(drm);
@@ -303,8 +294,6 @@ static void imx_drm_unbind(struct device *dev)
303 294
304 drm_kms_helper_poll_fini(drm); 295 drm_kms_helper_poll_fini(drm);
305 296
306 drm_fb_cma_fbdev_fini(drm);
307
308 drm_mode_config_cleanup(drm); 297 drm_mode_config_cleanup(drm);
309 298
310 component_unbind_all(drm->dev, drm); 299 component_unbind_all(drm->dev, drm);