forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
....@@ -1,21 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
34 * Author:Mark Yao <mark.yao@rock-chips.com>
4
- *
5
- * This software is licensed under the terms of the GNU General Public
6
- * License version 2, as published by the Free Software Foundation, and
7
- * may be copied, distributed, and modified under those terms.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
135 */
146
157 #include <drm/drm.h>
16
-#include <drm/drmP.h>
178 #include <drm/drm_fb_helper.h>
18
-#include <drm/drm_crtc_helper.h>
9
+#include <drm/drm_fourcc.h>
10
+#include <drm/drm_probe_helper.h>
1911
2012 #include "rockchip_drm_drv.h"
2113 #include "rockchip_drm_gem.h"
....@@ -33,33 +25,13 @@
3325 return rockchip_gem_mmap_buf(private->fbdev_bo, vma);
3426 }
3527
36
-static struct dma_buf *rockchip_fbdev_get_dma_buf(struct fb_info *info)
37
-{
38
- struct dma_buf *buf = NULL;
39
- struct drm_fb_helper *helper = info->par;
40
- struct rockchip_drm_private *private = helper->dev->dev_private;
41
- struct drm_device *dev = helper->dev;
42
-
43
- if (dev->driver->gem_prime_export) {
44
- buf = dev->driver->gem_prime_export(dev, private->fbdev_bo,
45
- O_RDWR);
46
- if (buf)
47
- drm_gem_object_get(private->fbdev_bo);
48
- }
49
-
50
- return buf;
51
-}
52
-
53
-static struct fb_ops rockchip_drm_fbdev_ops = {
28
+static const struct fb_ops rockchip_drm_fbdev_ops = {
5429 .owner = THIS_MODULE,
5530 DRM_FB_HELPER_DEFAULT_OPS,
31
+ .fb_mmap = rockchip_fbdev_mmap,
5632 .fb_fillrect = drm_fb_helper_cfb_fillrect,
5733 .fb_copyarea = drm_fb_helper_cfb_copyarea,
5834 .fb_imageblit = drm_fb_helper_cfb_imageblit,
59
- .fb_read = drm_fb_helper_sys_read,
60
- .fb_write = drm_fb_helper_sys_write,
61
- .fb_mmap = rockchip_fbdev_mmap,
62
- .fb_dmabuf_export = rockchip_fbdev_get_dma_buf,
6335 };
6436
6537 static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper,
....@@ -108,13 +80,10 @@
10880 goto out;
10981 }
11082
111
- fbi->par = helper;
112
- fbi->flags = FBINFO_FLAG_DEFAULT;
11383 fbi->fbops = &rockchip_drm_fbdev_ops;
11484
11585 fb = helper->fb;
116
- drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
117
- drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
86
+ drm_fb_helper_fill_info(fbi, helper, sizes);
11887
11988 offset = fbi->var.xoffset * bytes_per_pixel;
12089 offset += fbi->var.yoffset * fb->pitches[0];
....@@ -129,12 +98,10 @@
12998 rk_obj->kvaddr,
13099 offset, size);
131100
132
- fbi->skip_vt_switch = true;
133
-
134101 return 0;
135102
136103 out:
137
- rockchip_gem_free_object(&rk_obj->base);
104
+ drm_gem_object_put(&rk_obj->base);
138105 return ret;
139106 }
140107
....@@ -158,19 +125,12 @@
158125
159126 drm_fb_helper_prepare(dev, helper, &rockchip_drm_fb_helper_funcs);
160127
161
- ret = drm_fb_helper_init(dev, helper, ROCKCHIP_MAX_CONNECTOR);
128
+ ret = drm_fb_helper_init(dev, helper);
162129 if (ret < 0) {
163130 DRM_DEV_ERROR(dev->dev,
164131 "Failed to initialize drm fb helper - %d.\n",
165132 ret);
166133 return ret;
167
- }
168
-
169
- ret = drm_fb_helper_single_add_all_connectors(helper);
170
- if (ret < 0) {
171
- DRM_DEV_ERROR(dev->dev,
172
- "Failed to add connectors - %d.\n", ret);
173
- goto err_drm_fb_helper_fini;
174134 }
175135
176136 ret = drm_fb_helper_initial_config(helper, PREFERRED_BPP);