| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2015 Freescale Semiconductor, Inc. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Freescale DCU drm device driver |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 22 | 18 | #include <linux/pm_runtime.h> |
|---|
| 23 | 19 | #include <linux/regmap.h> |
|---|
| 24 | 20 | |
|---|
| 25 | | -#include <drm/drmP.h> |
|---|
| 26 | 21 | #include <drm/drm_atomic_helper.h> |
|---|
| 27 | | -#include <drm/drm_crtc_helper.h> |
|---|
| 22 | +#include <drm/drm_drv.h> |
|---|
| 28 | 23 | #include <drm/drm_fb_cma_helper.h> |
|---|
| 24 | +#include <drm/drm_fb_helper.h> |
|---|
| 29 | 25 | #include <drm/drm_gem_cma_helper.h> |
|---|
| 26 | +#include <drm/drm_irq.h> |
|---|
| 30 | 27 | #include <drm/drm_modeset_helper.h> |
|---|
| 28 | +#include <drm/drm_probe_helper.h> |
|---|
| 29 | +#include <drm/drm_vblank.h> |
|---|
| 31 | 30 | |
|---|
| 32 | 31 | #include "fsl_dcu_drm_crtc.h" |
|---|
| 33 | 32 | #include "fsl_dcu_drm_drv.h" |
|---|
| .. | .. |
|---|
| 89 | 88 | "Invalid legacyfb_depth. Defaulting to 24bpp\n"); |
|---|
| 90 | 89 | legacyfb_depth = 24; |
|---|
| 91 | 90 | } |
|---|
| 92 | | - fsl_dev->fbdev = drm_fbdev_cma_init(dev, legacyfb_depth, 1); |
|---|
| 93 | | - if (IS_ERR(fsl_dev->fbdev)) { |
|---|
| 94 | | - ret = PTR_ERR(fsl_dev->fbdev); |
|---|
| 95 | | - fsl_dev->fbdev = NULL; |
|---|
| 96 | | - goto done; |
|---|
| 97 | | - } |
|---|
| 98 | 91 | |
|---|
| 99 | 92 | return 0; |
|---|
| 100 | 93 | done: |
|---|
| 101 | 94 | drm_kms_helper_poll_fini(dev); |
|---|
| 102 | | - |
|---|
| 103 | | - if (fsl_dev->fbdev) |
|---|
| 104 | | - drm_fbdev_cma_fini(fsl_dev->fbdev); |
|---|
| 105 | 95 | |
|---|
| 106 | 96 | drm_mode_config_cleanup(dev); |
|---|
| 107 | 97 | drm_irq_uninstall(dev); |
|---|
| .. | .. |
|---|
| 112 | 102 | |
|---|
| 113 | 103 | static void fsl_dcu_unload(struct drm_device *dev) |
|---|
| 114 | 104 | { |
|---|
| 115 | | - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; |
|---|
| 116 | | - |
|---|
| 117 | 105 | drm_atomic_helper_shutdown(dev); |
|---|
| 118 | 106 | drm_kms_helper_poll_fini(dev); |
|---|
| 119 | | - |
|---|
| 120 | | - if (fsl_dev->fbdev) |
|---|
| 121 | | - drm_fbdev_cma_fini(fsl_dev->fbdev); |
|---|
| 122 | 107 | |
|---|
| 123 | 108 | drm_mode_config_cleanup(dev); |
|---|
| 124 | 109 | drm_irq_uninstall(dev); |
|---|
| .. | .. |
|---|
| 147 | 132 | return IRQ_HANDLED; |
|---|
| 148 | 133 | } |
|---|
| 149 | 134 | |
|---|
| 150 | | -static void fsl_dcu_drm_lastclose(struct drm_device *dev) |
|---|
| 151 | | -{ |
|---|
| 152 | | - struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; |
|---|
| 153 | | - |
|---|
| 154 | | - drm_fbdev_cma_restore_mode(fsl_dev->fbdev); |
|---|
| 155 | | -} |
|---|
| 156 | | - |
|---|
| 157 | 135 | DEFINE_DRM_GEM_CMA_FOPS(fsl_dcu_drm_fops); |
|---|
| 158 | 136 | |
|---|
| 159 | 137 | static struct drm_driver fsl_dcu_drm_driver = { |
|---|
| 160 | | - .driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
|---|
| 161 | | - | DRIVER_PRIME | DRIVER_ATOMIC, |
|---|
| 162 | | - .lastclose = fsl_dcu_drm_lastclose, |
|---|
| 138 | + .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, |
|---|
| 163 | 139 | .load = fsl_dcu_load, |
|---|
| 164 | 140 | .unload = fsl_dcu_unload, |
|---|
| 165 | 141 | .irq_handler = fsl_dcu_drm_irq, |
|---|
| 166 | 142 | .irq_preinstall = fsl_dcu_irq_uninstall, |
|---|
| 167 | 143 | .irq_uninstall = fsl_dcu_irq_uninstall, |
|---|
| 168 | | - .gem_free_object_unlocked = drm_gem_cma_free_object, |
|---|
| 169 | | - .gem_vm_ops = &drm_gem_cma_vm_ops, |
|---|
| 170 | | - .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
|---|
| 171 | | - .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
|---|
| 172 | | - .gem_prime_import = drm_gem_prime_import, |
|---|
| 173 | | - .gem_prime_export = drm_gem_prime_export, |
|---|
| 174 | | - .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, |
|---|
| 175 | | - .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, |
|---|
| 176 | | - .gem_prime_vmap = drm_gem_cma_prime_vmap, |
|---|
| 177 | | - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, |
|---|
| 178 | | - .gem_prime_mmap = drm_gem_cma_prime_mmap, |
|---|
| 179 | | - .dumb_create = drm_gem_cma_dumb_create, |
|---|
| 144 | + DRM_GEM_CMA_DRIVER_OPS, |
|---|
| 180 | 145 | .fops = &fsl_dcu_drm_fops, |
|---|
| 181 | 146 | .name = "fsl-dcu-drm", |
|---|
| 182 | 147 | .desc = "Freescale DCU DRM", |
|---|
| .. | .. |
|---|
| 353 | 318 | |
|---|
| 354 | 319 | ret = drm_dev_register(drm, 0); |
|---|
| 355 | 320 | if (ret < 0) |
|---|
| 356 | | - goto unref; |
|---|
| 321 | + goto put; |
|---|
| 322 | + |
|---|
| 323 | + drm_fbdev_generic_setup(drm, legacyfb_depth); |
|---|
| 357 | 324 | |
|---|
| 358 | 325 | return 0; |
|---|
| 359 | 326 | |
|---|
| 360 | | -unref: |
|---|
| 361 | | - drm_dev_unref(drm); |
|---|
| 327 | +put: |
|---|
| 328 | + drm_dev_put(drm); |
|---|
| 362 | 329 | unregister_pix_clk: |
|---|
| 363 | 330 | clk_unregister(fsl_dev->pix_clk); |
|---|
| 364 | 331 | disable_clk: |
|---|
| .. | .. |
|---|
| 371 | 338 | struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev); |
|---|
| 372 | 339 | |
|---|
| 373 | 340 | drm_dev_unregister(fsl_dev->drm); |
|---|
| 374 | | - drm_dev_unref(fsl_dev->drm); |
|---|
| 341 | + drm_dev_put(fsl_dev->drm); |
|---|
| 375 | 342 | clk_disable_unprepare(fsl_dev->clk); |
|---|
| 376 | 343 | clk_unregister(fsl_dev->pix_clk); |
|---|
| 377 | 344 | |
|---|