forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/pl111/pl111_drv.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved.
34 *
....@@ -6,27 +7,14 @@
67 * Copyright (c) 2006-2008 Intel Corporation
78 * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
89 * Copyright (C) 2011 Texas Instruments
9
- *
10
- * This program is free software and is provided to you under the terms of the
11
- * GNU General Public License version 2 as published by the Free Software
12
- * Foundation, and any use by you of this program is subject to the terms of
13
- * such GNU licence.
14
- *
1510 */
1611
1712 /**
18
- * DOC: ARM PrimeCell PL111 CLCD Driver
13
+ * DOC: ARM PrimeCell PL110 and PL111 CLCD Driver
1914 *
20
- * The PL111 is a simple LCD controller that can support TFT and STN
21
- * displays. This driver exposes a standard KMS interface for them.
22
- *
23
- * This driver uses the same Device Tree binding as the fbdev CLCD
24
- * driver. While the fbdev driver supports panels that may be
25
- * connected to the CLCD internally to the CLCD driver, in DRM the
26
- * panels get split out to drivers/gpu/drm/panels/. This means that,
27
- * in converting from using fbdev to using DRM, you also need to write
28
- * a panel driver (which may be as simple as an entry in
29
- * panel-simple.c).
15
+ * The PL110/PL111 is a simple LCD controller that can support TFT
16
+ * and STN displays. This driver exposes a standard KMS interface
17
+ * for them.
3018 *
3119 * The driver currently doesn't expose the cursor. The DRM API for
3220 * cursors requires support for 64x64 ARGB8888 cursor images, while
....@@ -34,15 +22,12 @@
3422 * cursors. While one could imagine trying to hack something together
3523 * to look at the ARGB8888 and program reasonable in monochrome, we
3624 * just don't expose the cursor at all instead, and leave cursor
37
- * support to the X11 software cursor layer.
25
+ * support to the application software cursor layer.
3826 *
3927 * TODO:
4028 *
4129 * - Fix race between setting plane base address and getting IRQ for
4230 * vsync firing the pageflip completion.
43
- *
44
- * - Use the "max-memory-bandwidth" DT property to filter the
45
- * supported formats.
4631 *
4732 * - Read back hardware state at boot to skip reprogramming the
4833 * hardware when doing a no-op modeset.
....@@ -52,26 +37,26 @@
5237 */
5338
5439 #include <linux/amba/bus.h>
55
-#include <linux/amba/clcd-regs.h>
56
-#include <linux/version.h>
57
-#include <linux/shmem_fs.h>
5840 #include <linux/dma-buf.h>
5941 #include <linux/module.h>
60
-#include <linux/slab.h>
6142 #include <linux/of.h>
6243 #include <linux/of_graph.h>
6344 #include <linux/of_reserved_mem.h>
45
+#include <linux/shmem_fs.h>
46
+#include <linux/slab.h>
47
+#include <linux/version.h>
6448
65
-#include <drm/drmP.h>
6649 #include <drm/drm_atomic_helper.h>
67
-#include <drm/drm_crtc_helper.h>
50
+#include <drm/drm_bridge.h>
51
+#include <drm/drm_drv.h>
52
+#include <drm/drm_fb_cma_helper.h>
53
+#include <drm/drm_fb_helper.h>
6854 #include <drm/drm_gem_cma_helper.h>
6955 #include <drm/drm_gem_framebuffer_helper.h>
70
-#include <drm/drm_fb_helper.h>
71
-#include <drm/drm_fb_cma_helper.h>
7256 #include <drm/drm_of.h>
73
-#include <drm/drm_bridge.h>
7457 #include <drm/drm_panel.h>
58
+#include <drm/drm_probe_helper.h>
59
+#include <drm/drm_vblank.h>
7560
7661 #include "pl111_drm.h"
7762 #include "pl111_versatile.h"
....@@ -94,10 +79,13 @@
9479 struct drm_panel *panel = NULL;
9580 struct drm_bridge *bridge = NULL;
9681 bool defer = false;
97
- int ret = 0;
82
+ int ret;
9883 int i;
9984
100
- drm_mode_config_init(dev);
85
+ ret = drmm_mode_config_init(dev);
86
+ if (ret)
87
+ return ret;
88
+
10189 mode_config = &dev->mode_config;
10290 mode_config->funcs = &mode_config_funcs;
10391 mode_config->min_width = 1;
....@@ -154,11 +142,11 @@
154142 return -EPROBE_DEFER;
155143
156144 if (panel) {
157
- bridge = drm_panel_bridge_add(panel,
158
- DRM_MODE_CONNECTOR_Unknown);
145
+ bridge = drm_panel_bridge_add_typed(panel,
146
+ DRM_MODE_CONNECTOR_Unknown);
159147 if (IS_ERR(bridge)) {
160148 ret = PTR_ERR(bridge);
161
- goto out_config;
149
+ goto finish;
162150 }
163151 } else if (bridge) {
164152 dev_info(dev->dev, "Using non-panel bridge\n");
....@@ -170,7 +158,7 @@
170158 priv->bridge = bridge;
171159 if (panel) {
172160 priv->panel = panel;
173
- priv->connector = panel->connector;
161
+ priv->connector = drm_panel_bridge_connector(bridge);
174162 }
175163
176164 ret = pl111_display_init(dev);
....@@ -194,8 +182,6 @@
194182
195183 drm_mode_config_reset(dev);
196184
197
- drm_fb_cma_fbdev_init(dev, priv->variant->fb_bpp, 0);
198
-
199185 drm_kms_helper_poll_init(dev);
200186
201187 goto finish;
....@@ -203,8 +189,6 @@
203189 out_bridge:
204190 if (panel)
205191 drm_panel_bridge_remove(bridge);
206
-out_config:
207
- drm_mode_config_cleanup(dev);
208192 finish:
209193 return ret;
210194 }
....@@ -231,8 +215,7 @@
231215
232216 static struct drm_driver pl111_drm_driver = {
233217 .driver_features =
234
- DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC,
235
- .lastclose = drm_fb_helper_lastclose,
218
+ DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
236219 .ioctls = NULL,
237220 .fops = &drm_fops,
238221 .name = "pl111",
....@@ -246,9 +229,7 @@
246229 .gem_vm_ops = &drm_gem_cma_vm_ops,
247230 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
248231 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
249
- .gem_prime_import = drm_gem_prime_import,
250232 .gem_prime_import_sg_table = pl111_gem_import_sg_table,
251
- .gem_prime_export = drm_gem_prime_export,
252233 .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
253234 .gem_prime_mmap = drm_gem_cma_prime_mmap,
254235 .gem_prime_vmap = drm_gem_cma_prime_vmap,
....@@ -332,6 +313,8 @@
332313 if (ret < 0)
333314 goto dev_put;
334315
316
+ drm_fbdev_generic_setup(drm, priv->variant->fb_bpp);
317
+
335318 return 0;
336319
337320 dev_put:
....@@ -341,21 +324,17 @@
341324 return ret;
342325 }
343326
344
-static int pl111_amba_remove(struct amba_device *amba_dev)
327
+static void pl111_amba_remove(struct amba_device *amba_dev)
345328 {
346329 struct device *dev = &amba_dev->dev;
347330 struct drm_device *drm = amba_get_drvdata(amba_dev);
348331 struct pl111_drm_dev_private *priv = drm->dev_private;
349332
350333 drm_dev_unregister(drm);
351
- drm_fb_cma_fbdev_fini(drm);
352334 if (priv->panel)
353335 drm_panel_bridge_remove(priv->bridge);
354
- drm_mode_config_cleanup(drm);
355336 drm_dev_put(drm);
356337 of_reserved_mem_device_release(dev);
357
-
358
- return 0;
359338 }
360339
361340 /*
....@@ -452,6 +431,7 @@
452431 },
453432 {0, 0},
454433 };
434
+MODULE_DEVICE_TABLE(amba, pl111_id_table);
455435
456436 static struct amba_driver pl111_amba_driver __maybe_unused = {
457437 .drv = {