| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2016 Linaro Ltd. |
|---|
| 3 | 4 | * Copyright 2016 ZTE Corporation. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 7 | | - * published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | 5 | */ |
|---|
| 10 | 6 | |
|---|
| 11 | 7 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 18 | 14 | |
|---|
| 19 | 15 | #include <drm/drm_atomic_helper.h> |
|---|
| 20 | 16 | #include <drm/drm_crtc.h> |
|---|
| 21 | | -#include <drm/drm_crtc_helper.h> |
|---|
| 17 | +#include <drm/drm_drv.h> |
|---|
| 22 | 18 | #include <drm/drm_fb_cma_helper.h> |
|---|
| 23 | 19 | #include <drm/drm_fb_helper.h> |
|---|
| 24 | 20 | #include <drm/drm_gem_cma_helper.h> |
|---|
| 25 | 21 | #include <drm/drm_gem_framebuffer_helper.h> |
|---|
| 26 | 22 | #include <drm/drm_of.h> |
|---|
| 27 | | -#include <drm/drmP.h> |
|---|
| 23 | +#include <drm/drm_probe_helper.h> |
|---|
| 24 | +#include <drm/drm_vblank.h> |
|---|
| 28 | 25 | |
|---|
| 29 | 26 | #include "zx_drm_drv.h" |
|---|
| 30 | 27 | #include "zx_vou.h" |
|---|
| 31 | 28 | |
|---|
| 32 | 29 | static const struct drm_mode_config_funcs zx_drm_mode_config_funcs = { |
|---|
| 33 | 30 | .fb_create = drm_gem_fb_create, |
|---|
| 34 | | - .output_poll_changed = drm_fb_helper_output_poll_changed, |
|---|
| 35 | 31 | .atomic_check = drm_atomic_helper_check, |
|---|
| 36 | 32 | .atomic_commit = drm_atomic_helper_commit, |
|---|
| 37 | 33 | }; |
|---|
| .. | .. |
|---|
| 39 | 35 | DEFINE_DRM_GEM_CMA_FOPS(zx_drm_fops); |
|---|
| 40 | 36 | |
|---|
| 41 | 37 | static struct drm_driver zx_drm_driver = { |
|---|
| 42 | | - .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | |
|---|
| 43 | | - DRIVER_ATOMIC, |
|---|
| 44 | | - .lastclose = drm_fb_helper_lastclose, |
|---|
| 45 | | - .gem_free_object_unlocked = drm_gem_cma_free_object, |
|---|
| 46 | | - .gem_vm_ops = &drm_gem_cma_vm_ops, |
|---|
| 47 | | - .dumb_create = drm_gem_cma_dumb_create, |
|---|
| 48 | | - .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
|---|
| 49 | | - .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
|---|
| 50 | | - .gem_prime_export = drm_gem_prime_export, |
|---|
| 51 | | - .gem_prime_import = drm_gem_prime_import, |
|---|
| 52 | | - .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, |
|---|
| 53 | | - .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, |
|---|
| 54 | | - .gem_prime_vmap = drm_gem_cma_prime_vmap, |
|---|
| 55 | | - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, |
|---|
| 56 | | - .gem_prime_mmap = drm_gem_cma_prime_mmap, |
|---|
| 38 | + .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, |
|---|
| 39 | + DRM_GEM_CMA_DRIVER_OPS, |
|---|
| 57 | 40 | .fops = &zx_drm_fops, |
|---|
| 58 | 41 | .name = "zx-vou", |
|---|
| 59 | 42 | .desc = "ZTE VOU Controller DRM", |
|---|
| .. | .. |
|---|
| 101 | 84 | drm_mode_config_reset(drm); |
|---|
| 102 | 85 | drm_kms_helper_poll_init(drm); |
|---|
| 103 | 86 | |
|---|
| 104 | | - ret = drm_fb_cma_fbdev_init(drm, 32, 0); |
|---|
| 105 | | - if (ret) { |
|---|
| 106 | | - DRM_DEV_ERROR(dev, "failed to init cma fbdev: %d\n", ret); |
|---|
| 107 | | - goto out_poll_fini; |
|---|
| 108 | | - } |
|---|
| 109 | | - |
|---|
| 110 | 87 | ret = drm_dev_register(drm, 0); |
|---|
| 111 | 88 | if (ret) |
|---|
| 112 | | - goto out_fbdev_fini; |
|---|
| 89 | + goto out_poll_fini; |
|---|
| 90 | + |
|---|
| 91 | + drm_fbdev_generic_setup(drm, 32); |
|---|
| 113 | 92 | |
|---|
| 114 | 93 | return 0; |
|---|
| 115 | 94 | |
|---|
| 116 | | -out_fbdev_fini: |
|---|
| 117 | | - drm_fb_cma_fbdev_fini(drm); |
|---|
| 118 | 95 | out_poll_fini: |
|---|
| 119 | 96 | drm_kms_helper_poll_fini(drm); |
|---|
| 120 | 97 | drm_mode_config_cleanup(drm); |
|---|
| .. | .. |
|---|
| 122 | 99 | component_unbind_all(dev, drm); |
|---|
| 123 | 100 | out_unregister: |
|---|
| 124 | 101 | dev_set_drvdata(dev, NULL); |
|---|
| 125 | | - drm_dev_unref(drm); |
|---|
| 102 | + drm_dev_put(drm); |
|---|
| 126 | 103 | return ret; |
|---|
| 127 | 104 | } |
|---|
| 128 | 105 | |
|---|
| .. | .. |
|---|
| 131 | 108 | struct drm_device *drm = dev_get_drvdata(dev); |
|---|
| 132 | 109 | |
|---|
| 133 | 110 | drm_dev_unregister(drm); |
|---|
| 134 | | - drm_fb_cma_fbdev_fini(drm); |
|---|
| 135 | 111 | drm_kms_helper_poll_fini(drm); |
|---|
| 112 | + drm_atomic_helper_shutdown(drm); |
|---|
| 136 | 113 | drm_mode_config_cleanup(drm); |
|---|
| 137 | 114 | component_unbind_all(dev, drm); |
|---|
| 138 | 115 | dev_set_drvdata(dev, NULL); |
|---|
| 139 | | - drm_dev_unref(drm); |
|---|
| 116 | + drm_dev_put(drm); |
|---|
| 140 | 117 | } |
|---|
| 141 | 118 | |
|---|
| 142 | 119 | static const struct component_master_ops zx_drm_master_ops = { |
|---|
| .. | .. |
|---|
| 161 | 138 | if (ret) |
|---|
| 162 | 139 | return ret; |
|---|
| 163 | 140 | |
|---|
| 164 | | - for_each_available_child_of_node(parent, child) { |
|---|
| 141 | + for_each_available_child_of_node(parent, child) |
|---|
| 165 | 142 | component_match_add(dev, &match, compare_of, child); |
|---|
| 166 | | - of_node_put(child); |
|---|
| 167 | | - } |
|---|
| 168 | 143 | |
|---|
| 169 | 144 | return component_master_add_with_match(dev, &zx_drm_master_ops, match); |
|---|
| 170 | 145 | } |
|---|