summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/onevpl/onevpl/0001-sample_misc-use-wayland-dmabuf-to-render-nv12.patch
blob: d061e3ef32f0146641d4d04728c65dccba3a4ae9 (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
90
91
92
93
94
From 0091d3fea76e64ffbd537b2ae47b8912c89c09d7 Mon Sep 17 00:00:00 2001
From: "Ung, Teng En" <teng.en.ung@intel.com>
Date: Fri, 8 Oct 2021 14:38:45 +0000
Subject: [PATCH 3/3] sample_misc: use wayland dmabuf to render nv12

Upstream-Status: Submitted
innersource PR #269

---
 .../sample_misc/wayland/src/class_wayland.cpp | 60 +++++++++++++++----
 1 file changed, 47 insertions(+), 13 deletions(-)

diff --git a/tools/legacy/sample_misc/wayland/src/class_wayland.cpp b/tools/legacy/sample_misc/wayland/src/class_wayland.cpp
index dc2fc718..d2e7e4e2 100644
--- a/tools/legacy/sample_misc/wayland/src/class_wayland.cpp
+++ b/tools/legacy/sample_misc/wayland/src/class_wayland.cpp
@@ -26,6 +26,7 @@ or https://software.intel.com/en-us/media-client-solutions-support.
 #include <iostream>
 extern "C" {
 #include <drm.h>
+#include <drm_fourcc.h>
 #include <intel_bufmgr.h>
 #include <xf86drm.h>
 }
@@ -305,20 +306,53 @@ struct wl_buffer* Wayland::CreatePrimeBuffer(uint32_t name,
                                              int32_t offsets[3],
                                              int32_t pitches[3]) {
     struct wl_buffer* buffer = NULL;
-    if (NULL == m_drm)
-        return NULL;
 
-    buffer = wl_drm_create_prime_buffer(m_drm,
-                                        name,
-                                        width,
-                                        height,
-                                        format,
-                                        offsets[0],
-                                        pitches[0],
-                                        offsets[1],
-                                        pitches[1],
-                                        offsets[2],
-                                        pitches[2]);
+#if defined(WAYLAND_LINUX_DMABUF_SUPPORT)
+    if (format == WL_DRM_FORMAT_NV12) {
+        if(NULL == m_dmabuf)
+            return NULL;
+
+        struct zwp_linux_buffer_params_v1 *dmabuf_params = NULL;
+        int i = 0;
+        uint64_t modifier = I915_FORMAT_MOD_Y_TILED;
+
+        dmabuf_params = zwp_linux_dmabuf_v1_create_params(m_dmabuf);
+        for(i = 0; i < 2; i++) {
+            zwp_linux_buffer_params_v1_add(dmabuf_params,
+                                           name,
+                                           i,
+                                           offsets[i],
+                                           pitches[i],
+                                           modifier >> 32,
+                                           modifier & 0xffffffff);
+        }
+
+        buffer = zwp_linux_buffer_params_v1_create_immed(dmabuf_params,
+                                                         width,
+                                                         height,
+                                                         format,
+                                                         0);
+
+        zwp_linux_buffer_params_v1_destroy(dmabuf_params);
+    } else
+#endif
+    {
+        if(NULL == m_drm)
+            return NULL;
+
+        buffer = wl_drm_create_prime_buffer(m_drm,
+                                            name,
+                                            width,
+                                            height,
+                                            format,
+                                            offsets[0],
+                                            pitches[0],
+                                            offsets[1],
+                                            pitches[1],
+                                            offsets[2],
+                                            pitches[2]);
+    }
+
     return buffer;
 }
 
-- 
2.31.1