forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
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,31 +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_mmap = rockchip_fbdev_mmap,
60
- .fb_dmabuf_export = rockchip_fbdev_get_dma_buf,
6135 };
6236
6337 static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper,
....@@ -106,13 +80,10 @@
10680 goto out;
10781 }
10882
109
- fbi->par = helper;
110
- fbi->flags = FBINFO_FLAG_DEFAULT;
11183 fbi->fbops = &rockchip_drm_fbdev_ops;
11284
11385 fb = helper->fb;
114
- drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
115
- drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
86
+ drm_fb_helper_fill_info(fbi, helper, sizes);
11687
11788 offset = fbi->var.xoffset * bytes_per_pixel;
11889 offset += fbi->var.yoffset * fb->pitches[0];
....@@ -127,12 +98,10 @@
12798 rk_obj->kvaddr,
12899 offset, size);
129100
130
- fbi->skip_vt_switch = true;
131
-
132101 return 0;
133102
134103 out:
135
- rockchip_gem_free_object(&rk_obj->base);
104
+ drm_gem_object_put(&rk_obj->base);
136105 return ret;
137106 }
138107
....@@ -156,19 +125,12 @@
156125
157126 drm_fb_helper_prepare(dev, helper, &rockchip_drm_fb_helper_funcs);
158127
159
- ret = drm_fb_helper_init(dev, helper, ROCKCHIP_MAX_CONNECTOR);
128
+ ret = drm_fb_helper_init(dev, helper);
160129 if (ret < 0) {
161130 DRM_DEV_ERROR(dev->dev,
162131 "Failed to initialize drm fb helper - %d.\n",
163132 ret);
164133 return ret;
165
- }
166
-
167
- ret = drm_fb_helper_single_add_all_connectors(helper);
168
- if (ret < 0) {
169
- DRM_DEV_ERROR(dev->dev,
170
- "Failed to add connectors - %d.\n", ret);
171
- goto err_drm_fb_helper_fini;
172134 }
173135
174136 ret = drm_fb_helper_initial_config(helper, PREFERRED_BPP);