forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/gpu/drm/xen/xen_drm_front_kms.c
....@@ -8,17 +8,18 @@
88 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
99 */
1010
11
-#include "xen_drm_front_kms.h"
12
-
13
-#include <drm/drmP.h>
1411 #include <drm/drm_atomic.h>
1512 #include <drm/drm_atomic_helper.h>
16
-#include <drm/drm_crtc_helper.h>
13
+#include <drm/drm_drv.h>
14
+#include <drm/drm_fourcc.h>
1715 #include <drm/drm_gem.h>
1816 #include <drm/drm_gem_framebuffer_helper.h>
17
+#include <drm/drm_probe_helper.h>
18
+#include <drm/drm_vblank.h>
1919
2020 #include "xen_drm_front.h"
2121 #include "xen_drm_front_conn.h"
22
+#include "xen_drm_front_kms.h"
2223
2324 /*
2425 * Timeout in ms to wait for frame done event from the backend:
....@@ -45,7 +46,7 @@
4546 drm_gem_fb_destroy(fb);
4647 }
4748
48
-static struct drm_framebuffer_funcs fb_funcs = {
49
+static const struct drm_framebuffer_funcs fb_funcs = {
4950 .destroy = fb_destroy,
5051 };
5152
....@@ -54,7 +55,7 @@
5455 const struct drm_mode_fb_cmd2 *mode_cmd)
5556 {
5657 struct xen_drm_front_drm_info *drm_info = dev->dev_private;
57
- static struct drm_framebuffer *fb;
58
+ struct drm_framebuffer *fb;
5859 struct drm_gem_object *gem_obj;
5960 int ret;
6061
....@@ -62,14 +63,7 @@
6263 if (IS_ERR(fb))
6364 return fb;
6465
65
- gem_obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
66
- if (!gem_obj) {
67
- DRM_ERROR("Failed to lookup GEM object\n");
68
- ret = -ENOENT;
69
- goto fail;
70
- }
71
-
72
- drm_gem_object_put_unlocked(gem_obj);
66
+ gem_obj = fb->obj[0];
7367
7468 ret = xen_drm_front_fb_attach(drm_info->front_info,
7569 xen_drm_front_dbuf_to_cookie(gem_obj),
....@@ -226,6 +220,24 @@
226220 return false;
227221 }
228222
223
+static int display_check(struct drm_simple_display_pipe *pipe,
224
+ struct drm_plane_state *plane_state,
225
+ struct drm_crtc_state *crtc_state)
226
+{
227
+ /*
228
+ * Xen doesn't initialize vblanking via drm_vblank_init(), so
229
+ * DRM helpers assume that it doesn't handle vblanking and start
230
+ * sending out fake VBLANK events automatically.
231
+ *
232
+ * As xen contains it's own logic for sending out VBLANK events
233
+ * in send_pending_event(), disable no_vblank (i.e., the xen
234
+ * driver has vblanking support).
235
+ */
236
+ crtc_state->no_vblank = false;
237
+
238
+ return 0;
239
+}
240
+
229241 static void display_update(struct drm_simple_display_pipe *pipe,
230242 struct drm_plane_state *old_plane_state)
231243 {
....@@ -269,11 +281,12 @@
269281 }
270282
271283 static enum drm_mode_status
272
-display_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
284
+display_mode_valid(struct drm_simple_display_pipe *pipe,
285
+ const struct drm_display_mode *mode)
273286 {
274287 struct xen_drm_front_drm_pipeline *pipeline =
275
- container_of(crtc, struct xen_drm_front_drm_pipeline,
276
- pipe.crtc);
288
+ container_of(pipe, struct xen_drm_front_drm_pipeline,
289
+ pipe);
277290
278291 if (mode->hdisplay != pipeline->width)
279292 return MODE_ERROR;
....@@ -289,6 +302,7 @@
289302 .enable = display_enable,
290303 .disable = display_disable,
291304 .prepare_fb = drm_gem_fb_simple_display_pipe_prepare_fb,
305
+ .check = display_check,
292306 .update = display_update,
293307 };
294308