hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/gpu/drm/omapdrm/omap_fb.c
....@@ -1,24 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
34 * Author: Rob Clark <rob@ti.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2 as published by
7
- * the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program. If not, see <http://www.gnu.org/licenses/>.
165 */
176
18
-#include <linux/seq_file.h>
7
+#include <linux/dma-mapping.h>
198
20
-#include <drm/drm_crtc.h>
21
-#include <drm/drm_crtc_helper.h>
9
+#include <drm/drm_modeset_helper.h>
10
+#include <drm/drm_fourcc.h>
2211 #include <drm/drm_gem_framebuffer_helper.h>
2312
2413 #include "omap_dmm_tiler.h"
....@@ -66,8 +55,27 @@
6655 struct mutex lock;
6756 };
6857
58
+static int omap_framebuffer_dirty(struct drm_framebuffer *fb,
59
+ struct drm_file *file_priv,
60
+ unsigned flags, unsigned color,
61
+ struct drm_clip_rect *clips,
62
+ unsigned num_clips)
63
+{
64
+ struct drm_crtc *crtc;
65
+
66
+ drm_modeset_lock_all(fb->dev);
67
+
68
+ drm_for_each_crtc(crtc, fb->dev)
69
+ omap_crtc_flush(crtc);
70
+
71
+ drm_modeset_unlock_all(fb->dev);
72
+
73
+ return 0;
74
+}
75
+
6976 static const struct drm_framebuffer_funcs omap_framebuffer_funcs = {
7077 .create_handle = drm_gem_fb_create_handle,
78
+ .dirty = omap_framebuffer_dirty,
7179 .destroy = drm_gem_fb_destroy,
7280 };
7381
....@@ -87,7 +95,7 @@
8795
8896 bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
8997 {
90
- return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED;
98
+ return omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED_MASK;
9199 }
92100
93101 /* Note: DRM rotates counter-clockwise, TILER & DSS rotates clockwise */
....@@ -127,7 +135,6 @@
127135 {
128136 struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
129137 const struct drm_format_info *format = omap_fb->format;
130
- struct plane *plane = &omap_fb->planes[0];
131138 u32 x, y, orient = 0;
132139
133140 info->fourcc = fb->format->format;
....@@ -146,7 +153,7 @@
146153 x = state->src_x >> 16;
147154 y = state->src_y >> 16;
148155
149
- if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED) {
156
+ if (omap_gem_flags(fb->obj[0]) & OMAP_BO_TILED_MASK) {
150157 u32 w = state->src_w >> 16;
151158 u32 h = state->src_h >> 16;
152159
....@@ -201,10 +208,8 @@
201208 info->screen_width /= format->cpp[0];
202209
203210 if (fb->format->format == DRM_FORMAT_NV12) {
204
- plane = &omap_fb->planes[1];
205
-
206211 if (info->rotation_type == OMAP_DSS_ROT_TILER) {
207
- WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED));
212
+ WARN_ON(!(omap_gem_flags(fb->obj[1]) & OMAP_BO_TILED_MASK));
208213 omap_gem_rotated_dma_addr(fb->obj[1], orient, x/2, y/2,
209214 &info->p_uv_addr);
210215 } else {
....@@ -298,7 +303,9 @@
298303 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
299304 struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd)
300305 {
301
- unsigned int num_planes = drm_format_num_planes(mode_cmd->pixel_format);
306
+ const struct drm_format_info *info = drm_get_format_info(dev,
307
+ mode_cmd);
308
+ unsigned int num_planes = info->num_planes;
302309 struct drm_gem_object *bos[4];
303310 struct drm_framebuffer *fb;
304311 int i;
....@@ -319,7 +326,7 @@
319326
320327 error:
321328 while (--i >= 0)
322
- drm_gem_object_unreference_unlocked(bos[i]);
329
+ drm_gem_object_put(bos[i]);
323330
324331 return fb;
325332 }
....@@ -337,7 +344,7 @@
337344 dev, mode_cmd, mode_cmd->width, mode_cmd->height,
338345 (char *)&mode_cmd->pixel_format);
339346
340
- format = drm_format_info(mode_cmd->pixel_format);
347
+ format = drm_get_format_info(dev, mode_cmd);
341348
342349 for (i = 0; i < ARRAY_SIZE(formats); i++) {
343350 if (formats[i] == mode_cmd->pixel_format)