summaryrefslogtreecommitdiffstats
path: root/bsp/meta-synopsys/recipes-graphics/wayland/weston/1046-compositor-drm-Read-FB2_MODIFIERS-capability.patch
blob: f3a46b1a7f030096bfc663bb89d9bf19c2c95c23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From a864f58f44d701164dbb32bfcdde8c6d761f28ee Mon Sep 17 00:00:00 2001
From: Deepak Rawat <drawat@vmware.com>
Date: Fri, 24 Aug 2018 13:16:03 -0700
Subject: [PATCH 46/46] compositor-drm: Read FB2_MODIFIERS capability

Not all drivers support fb2 modifiers so read the capability before
using drmModeAddFB2WithModifiers.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
---
 libweston/compositor-drm.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index e024e66f..4cf0d31f 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -346,6 +346,8 @@ struct drm_backend {
 
 	bool aspect_ratio_supported;
 
+	bool fb_modifiers;
+
 	struct weston_debug_scope *debug;
 };
 
@@ -961,7 +963,7 @@ drm_fb_destroy_gbm(struct gbm_bo *bo, void *data)
 }
 
 static int
-drm_fb_addfb(struct drm_fb *fb)
+drm_fb_addfb(struct drm_backend *b, struct drm_fb *fb)
 {
 	int ret = -EINVAL;
 #ifdef HAVE_DRM_ADDFB2_MODIFIERS
@@ -971,7 +973,7 @@ drm_fb_addfb(struct drm_fb *fb)
 
 	/* If we have a modifier set, we must only use the WithModifiers
 	 * entrypoint; we cannot import it through legacy ioctls. */
-	if (fb->modifier != DRM_FORMAT_MOD_INVALID) {
+	if (b->fb_modifiers && fb->modifier != DRM_FORMAT_MOD_INVALID) {
 		/* KMS demands that if a modifier is set, it must be the same
 		 * for all planes. */
 #ifdef HAVE_DRM_ADDFB2_MODIFIERS
@@ -1055,7 +1057,7 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int height,
 	fb->height = height;
 	fb->fd = b->drm.fd;
 
-	if (drm_fb_addfb(fb) != 0) {
+	if (drm_fb_addfb(b, fb) != 0) {
 		weston_log("failed to create kms fb: %m\n");
 		goto err_bo;
 	}
@@ -1228,7 +1230,7 @@ drm_fb_get_from_dmabuf(struct linux_dmabuf_buffer *dmabuf,
 			goto err_free;
 	}
 
-	if (drm_fb_addfb(fb) != 0)
+	if (drm_fb_addfb(backend, fb) != 0)
 		goto err_free;
 
 	return fb;
@@ -1301,7 +1303,7 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
 		goto err_free;
 	}
 
-	if (drm_fb_addfb(fb) != 0) {
+	if (drm_fb_addfb(backend, fb) != 0) {
 		if (type == BUFFER_GBM_SURFACE)
 			weston_log("failed to create kms fb: %m\n");
 		goto err_free;
@@ -4062,6 +4064,14 @@ init_kms_caps(struct drm_backend *b)
 	weston_log("DRM: %s atomic modesetting\n",
 		   b->atomic_modeset ? "supports" : "does not support");
 
+#ifdef HAVE_DRM_ADDFB2_MODIFIERS
+	ret = drmGetCap(b->drm.fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
+	if (ret == 0)
+		b->fb_modifiers = cap;
+	else
+#endif
+		b->fb_modifiers = 0;
+
 	/*
 	 * KMS support for hardware planes cannot properly synchronize
 	 * without nuclear page flip. Without nuclear/atomic, hw plane
-- 
2.16.2