forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* exynos_drm_fbdev.c
23 *
34 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
....@@ -5,25 +6,21 @@
56 * Inki Dae <inki.dae@samsung.com>
67 * Joonyoung Shim <jy0922.shim@samsung.com>
78 * Seung-Woo Kim <sw0312.kim@samsung.com>
8
- *
9
- * This program is free software; you can redistribute it and/or modify it
10
- * under the terms of the GNU General Public License as published by the
11
- * Free Software Foundation; either version 2 of the License, or (at your
12
- * option) any later version.
139 */
1410
15
-#include <drm/drmP.h>
11
+#include <linux/console.h>
12
+#include <linux/dma-mapping.h>
13
+#include <linux/vmalloc.h>
14
+
1615 #include <drm/drm_crtc.h>
1716 #include <drm/drm_fb_helper.h>
18
-#include <drm/drm_crtc_helper.h>
17
+#include <drm/drm_fourcc.h>
18
+#include <drm/drm_probe_helper.h>
1919 #include <drm/exynos_drm.h>
20
-
21
-#include <linux/console.h>
2220
2321 #include "exynos_drm_drv.h"
2422 #include "exynos_drm_fb.h"
2523 #include "exynos_drm_fbdev.h"
26
-#include "exynos_drm_iommu.h"
2724
2825 #define MAX_CONNECTOR 4
2926 #define PREFERRED_BPP 32
....@@ -56,14 +53,14 @@
5653 exynos_gem->dma_addr, exynos_gem->size,
5754 exynos_gem->dma_attrs);
5855 if (ret < 0) {
59
- DRM_ERROR("failed to mmap.\n");
56
+ DRM_DEV_ERROR(to_dma_dev(helper->dev), "failed to mmap.\n");
6057 return ret;
6158 }
6259
6360 return 0;
6461 }
6562
66
-static struct fb_ops exynos_drm_fb_ops = {
63
+static const struct fb_ops exynos_drm_fb_ops = {
6764 .owner = THIS_MODULE,
6865 DRM_FB_HELPER_DEFAULT_OPS,
6966 .fb_mmap = exynos_drm_fb_mmap,
....@@ -79,35 +76,23 @@
7976 struct fb_info *fbi;
8077 struct drm_framebuffer *fb = helper->fb;
8178 unsigned int size = fb->width * fb->height * fb->format->cpp[0];
82
- unsigned int nr_pages;
8379 unsigned long offset;
8480
8581 fbi = drm_fb_helper_alloc_fbi(helper);
8682 if (IS_ERR(fbi)) {
87
- DRM_ERROR("failed to allocate fb info.\n");
83
+ DRM_DEV_ERROR(to_dma_dev(helper->dev),
84
+ "failed to allocate fb info.\n");
8885 return PTR_ERR(fbi);
8986 }
9087
91
- fbi->par = helper;
92
- fbi->flags = FBINFO_FLAG_DEFAULT;
9388 fbi->fbops = &exynos_drm_fb_ops;
9489
95
- drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
96
- drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
97
-
98
- nr_pages = exynos_gem->size >> PAGE_SHIFT;
99
-
100
- exynos_gem->kvaddr = (void __iomem *) vmap(exynos_gem->pages, nr_pages,
101
- VM_MAP, pgprot_writecombine(PAGE_KERNEL));
102
- if (!exynos_gem->kvaddr) {
103
- DRM_ERROR("failed to map pages to kernel space.\n");
104
- return -EIO;
105
- }
90
+ drm_fb_helper_fill_info(fbi, helper, sizes);
10691
10792 offset = fbi->var.xoffset * fb->format->cpp[0];
10893 offset += fbi->var.yoffset * fb->pitches[0];
10994
110
- fbi->screen_base = exynos_gem->kvaddr + offset;
95
+ fbi->screen_buffer = exynos_gem->kvaddr + offset;
11196 fbi->screen_size = size;
11297 fbi->fix.smem_len = size;
11398
....@@ -124,9 +109,10 @@
124109 unsigned long size;
125110 int ret;
126111
127
- DRM_DEBUG_KMS("surface width(%d), height(%d) and bpp(%d\n",
128
- sizes->surface_width, sizes->surface_height,
129
- sizes->surface_bpp);
112
+ DRM_DEV_DEBUG_KMS(dev->dev,
113
+ "surface width(%d), height(%d) and bpp(%d\n",
114
+ sizes->surface_width, sizes->surface_height,
115
+ sizes->surface_bpp);
130116
131117 mode_cmd.width = sizes->surface_width;
132118 mode_cmd.height = sizes->surface_height;
....@@ -136,18 +122,7 @@
136122
137123 size = mode_cmd.pitches[0] * mode_cmd.height;
138124
139
- exynos_gem = exynos_drm_gem_create(dev, EXYNOS_BO_CONTIG, size);
140
- /*
141
- * If physically contiguous memory allocation fails and if IOMMU is
142
- * supported then try to get buffer from non physically contiguous
143
- * memory area.
144
- */
145
- if (IS_ERR(exynos_gem) && is_drm_iommu_supported(dev)) {
146
- dev_warn(dev->dev, "contiguous FB allocation failed, falling back to non-contiguous\n");
147
- exynos_gem = exynos_drm_gem_create(dev, EXYNOS_BO_NONCONTIG,
148
- size);
149
- }
150
-
125
+ exynos_gem = exynos_drm_gem_create(dev, EXYNOS_BO_WC, size, true);
151126 if (IS_ERR(exynos_gem))
152127 return PTR_ERR(exynos_gem);
153128
....@@ -156,7 +131,7 @@
156131 helper->fb =
157132 exynos_drm_framebuffer_init(dev, &mode_cmd, &exynos_gem, 1);
158133 if (IS_ERR(helper->fb)) {
159
- DRM_ERROR("failed to create drm framebuffer.\n");
134
+ DRM_DEV_ERROR(dev->dev, "failed to create drm framebuffer.\n");
160135 ret = PTR_ERR(helper->fb);
161136 goto err_destroy_gem;
162137 }
....@@ -192,7 +167,7 @@
192167 struct drm_fb_helper *helper;
193168 int ret;
194169
195
- if (!dev->mode_config.num_crtc || !dev->mode_config.num_connector)
170
+ if (!dev->mode_config.num_crtc)
196171 return 0;
197172
198173 fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
....@@ -203,22 +178,17 @@
203178
204179 drm_fb_helper_prepare(dev, helper, &exynos_drm_fb_helper_funcs);
205180
206
- ret = drm_fb_helper_init(dev, helper, MAX_CONNECTOR);
181
+ ret = drm_fb_helper_init(dev, helper);
207182 if (ret < 0) {
208
- DRM_ERROR("failed to initialize drm fb helper.\n");
183
+ DRM_DEV_ERROR(dev->dev,
184
+ "failed to initialize drm fb helper.\n");
209185 goto err_init;
210
- }
211
-
212
- ret = drm_fb_helper_single_add_all_connectors(helper);
213
- if (ret < 0) {
214
- DRM_ERROR("failed to register drm_fb_helper_connector.\n");
215
- goto err_setup;
216
-
217186 }
218187
219188 ret = drm_fb_helper_initial_config(helper, PREFERRED_BPP);
220189 if (ret < 0) {
221
- DRM_ERROR("failed to set up hw configuration.\n");
190
+ DRM_DEV_ERROR(dev->dev,
191
+ "failed to set up hw configuration.\n");
222192 goto err_setup;
223193 }
224194
....@@ -237,11 +207,7 @@
237207 static void exynos_drm_fbdev_destroy(struct drm_device *dev,
238208 struct drm_fb_helper *fb_helper)
239209 {
240
- struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(fb_helper);
241
- struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;
242210 struct drm_framebuffer *fb;
243
-
244
- vunmap(exynos_gem->kvaddr);
245211
246212 /* release drm framebuffer and real buffer */
247213 if (fb_helper->fb && fb_helper->fb->funcs) {
....@@ -270,20 +236,3 @@
270236 private->fb_helper = NULL;
271237 }
272238
273
-void exynos_drm_fbdev_suspend(struct drm_device *dev)
274
-{
275
- struct exynos_drm_private *private = dev->dev_private;
276
-
277
- console_lock();
278
- drm_fb_helper_set_suspend(private->fb_helper, 1);
279
- console_unlock();
280
-}
281
-
282
-void exynos_drm_fbdev_resume(struct drm_device *dev)
283
-{
284
- struct exynos_drm_private *private = dev->dev_private;
285
-
286
- console_lock();
287
- drm_fb_helper_set_suspend(private->fb_helper, 0);
288
- console_unlock();
289
-}