summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia
diff options
context:
space:
mode:
authorjinchung <jin.chung.teng@intel.com>2021-05-31 06:09:35 (GMT)
committerAnuj Mittal <anuj.mittal@intel.com>2021-06-01 02:34:36 (GMT)
commitfb8801cc2841b8658317bf0edce048d447ff782e (patch)
treeeaf1d76b17d3b84b065f7a03a32a7704879608a2 /recipes-multimedia
parent249830d91b12af1df6df904aebe6434dbaa9e709 (diff)
downloadmeta-intel-fb8801cc2841b8658317bf0edce048d447ff782e.tar.gz
onevpl: Add Wayland support to legacy tools
Signed-off-by: jinchung <jin.chung.teng@intel.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'recipes-multimedia')
-rw-r--r--recipes-multimedia/onevpl/onevpl/0001-Adding-Wayland-support-to-legacy-tools.patch1301
-rw-r--r--recipes-multimedia/onevpl/onevpl_2021.2.2.bb1
2 files changed, 1302 insertions, 0 deletions
diff --git a/recipes-multimedia/onevpl/onevpl/0001-Adding-Wayland-support-to-legacy-tools.patch b/recipes-multimedia/onevpl/onevpl/0001-Adding-Wayland-support-to-legacy-tools.patch
new file mode 100644
index 0000000..857626b
--- /dev/null
+++ b/recipes-multimedia/onevpl/onevpl/0001-Adding-Wayland-support-to-legacy-tools.patch
@@ -0,0 +1,1301 @@
1From 64250fb3e73c1977067381c70aeffbaa980f4136 Mon Sep 17 00:00:00 2001
2From: jinchung <jin.chung.teng@intel.com>
3Date: Fri, 28 May 2021 11:34:01 +0800
4Subject: [PATCH] Adding Wayland support to legacy tools
5
6Upstream-Status: Submitted
7https://github.com/oneapi-src/oneVPL/pull/6
8
9Signed-off-by: jinchung <jin.chung.teng@intel.com>
10---
11 tools/legacy/CMakeLists.txt | 1 +
12 tools/legacy/sample_common/CMakeLists.txt | 8 +
13 tools/legacy/sample_common/src/vaapi_device.cpp | 2 +-
14 tools/legacy/sample_misc/wayland/CMakeLists.txt | 29 ++
15 .../sample_misc/wayland/include/class_wayland.h | 160 +++++++
16 .../sample_misc/wayland/include/listener_wayland.h | 66 +++
17 .../wayland/include/wayland-drm-client-protocol.h | 235 ++++++++++
18 .../sample_misc/wayland/src/class_wayland.cpp | 500 +++++++++++++++++++++
19 .../sample_misc/wayland/src/listener_wayland.cpp | 105 +++++
20 .../sample_misc/wayland/src/wayland-drm-protocol.c | 84 ++++
21 10 files changed, 1189 insertions(+), 1 deletion(-)
22 create mode 100644 tools/legacy/sample_misc/wayland/CMakeLists.txt
23 create mode 100644 tools/legacy/sample_misc/wayland/include/class_wayland.h
24 create mode 100644 tools/legacy/sample_misc/wayland/include/listener_wayland.h
25 create mode 100644 tools/legacy/sample_misc/wayland/include/wayland-drm-client-protocol.h
26 create mode 100644 tools/legacy/sample_misc/wayland/src/class_wayland.cpp
27 create mode 100644 tools/legacy/sample_misc/wayland/src/listener_wayland.cpp
28 create mode 100644 tools/legacy/sample_misc/wayland/src/wayland-drm-protocol.c
29
30diff --git a/tools/legacy/CMakeLists.txt b/tools/legacy/CMakeLists.txt
31index 165a5b2..1d4af73 100644
32--- a/tools/legacy/CMakeLists.txt
33+++ b/tools/legacy/CMakeLists.txt
34@@ -11,3 +11,4 @@ add_subdirectory(sample_common)
35 add_subdirectory(sample_decode)
36 add_subdirectory(sample_vpp)
37 add_subdirectory(sample_encode)
38+add_subdirectory(sample_misc/wayland)
39diff --git a/tools/legacy/sample_common/CMakeLists.txt b/tools/legacy/sample_common/CMakeLists.txt
40index db4de3d..4f04226 100644
41--- a/tools/legacy/sample_common/CMakeLists.txt
42+++ b/tools/legacy/sample_common/CMakeLists.txt
43@@ -70,6 +70,7 @@ if(UNIX)
44 pkg_check_modules(PKG_LIBDRM libdrm)
45 pkg_check_modules(PKG_X11 x11)
46 pkg_check_modules(PKG_LIBVA_X11 libva-x11>=1.10.0)
47+ pkg_check_modules(PKG_WAYLAND_CLIENT wayland-client)
48 if(PKG_LIBVA_FOUND)
49 target_compile_definitions(${TARGET} PUBLIC -DLIBVA_SUPPORT)
50 target_include_directories(${TARGET} PUBLIC ${PKG_LIBVA_INCLUDE_DIRS})
51@@ -88,6 +89,13 @@ if(UNIX)
52 else()
53 message(WARNING "x11 modules not found: building without libVA X11 support")
54 endif()
55+ if(PKG_WAYLAND_CLIENT_FOUND)
56+ target_compile_definitions(${TARGET} PUBLIC -DLIBVA_WAYLAND_SUPPORT)
57+ target_include_directories(${TARGET} PUBLIC ${PKG_WAYLAND_CLIENT_LIBRARY_DIRS})
58+ target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../sample_misc/wayland/include)
59+ else()
60+ message(WARNING "wayland modules not found: building without Wayland support")
61+ endif()
62
63 target_link_libraries(${TARGET} ${CMAKE_DL_LIBS})
64
65diff --git a/tools/legacy/sample_common/src/vaapi_device.cpp b/tools/legacy/sample_common/src/vaapi_device.cpp
66index 3f6d3ba..b034376 100644
67--- a/tools/legacy/sample_common/src/vaapi_device.cpp
68+++ b/tools/legacy/sample_common/src/vaapi_device.cpp
69@@ -396,7 +396,7 @@ mfxStatus CVAAPIDeviceWayland::RenderFrame(mfxFrameSurface1* pSurface,
70 return mfx_res;
71 }
72
73- m_Wayland->RenderBuffer(m_wl_buffer, pSurface->Info.CropW, pSurface->Info.CropH);
74+ m_Wayland->RenderBuffer(m_wl_buffer, pSurface);
75
76 return mfx_res;
77 }
78diff --git a/tools/legacy/sample_misc/wayland/CMakeLists.txt b/tools/legacy/sample_misc/wayland/CMakeLists.txt
79new file mode 100644
80index 0000000..95057d4
81--- /dev/null
82+++ b/tools/legacy/sample_misc/wayland/CMakeLists.txt
83@@ -0,0 +1,29 @@
84+if (NOT PKG_WAYLAND_CLIENT_FOUND)
85+ return()
86+endif()
87+
88+set(TARGET mfx_wayland)
89+
90+find_package(PkgConfig REQUIRED)
91+pkg_check_modules(PKG_WAYLAND_CLIENT wayland-client)
92+pkg_check_modules(PKG_LIBVA libva libva-drm)
93+pkg_check_modules(PKG_LIBDRM libdrm)
94+
95+include_directories (
96+ ${CMAKE_CURRENT_SOURCE_DIR}/../../sample_common/include
97+ ${CMAKE_CURRENT_SOURCE_DIR}/include
98+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../api/vpl
99+ ${PKG_LIBDRM_INCLUDE_DIRS}
100+ ${PKG_WAYLAND_CLIENT_LIBRARY_DIRS}
101+)
102+
103+add_definitions(-DLIBVA_WAYLAND_SUPPORT)
104+add_library(${TARGET} SHARED "")
105+target_sources(${TARGET} PRIVATE
106+ ${CMAKE_CURRENT_SOURCE_DIR}/src/class_wayland.cpp
107+ ${CMAKE_CURRENT_SOURCE_DIR}/src/listener_wayland.cpp
108+ ${CMAKE_CURRENT_SOURCE_DIR}/src/wayland-drm-protocol.c)
109+
110+target_link_libraries(${TARGET} sample_common wayland-client va drm drm_intel)
111+
112+install( TARGETS ${TARGETS} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR} )
113diff --git a/tools/legacy/sample_misc/wayland/include/class_wayland.h b/tools/legacy/sample_misc/wayland/include/class_wayland.h
114new file mode 100644
115index 0000000..1c64f9c
116--- /dev/null
117+++ b/tools/legacy/sample_misc/wayland/include/class_wayland.h
118@@ -0,0 +1,160 @@
119+/******************************************************************************\
120+Copyright (c) 2005-2019, Intel Corporation
121+All rights reserved.
122+
123+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
124+
125+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
126+
127+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
128+
129+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
130+
131+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
132+
133+This sample was distributed or derived from the Intel's Media Samples package.
134+The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
135+or https://software.intel.com/en-us/media-client-solutions-support.
136+\**********************************************************************************/
137+
138+#ifndef WAYLAND_CLASS_H
139+#define WAYLAND_CLASS_H
140+
141+#if defined(LIBVA_WAYLAND_SUPPORT)
142+
143+extern "C"
144+{
145+ #include <intel_bufmgr.h>
146+}
147+#include <poll.h>
148+#include <wayland-client.h>
149+#include <list>
150+#include "wayland-drm-client-protocol.h"
151+#include "vpl/mfxstructures.h"
152+#include "mfx_buffering.h"
153+#include "sample_defs.h"
154+
155+typedef struct buffer wld_buffer;
156+
157+/* ShmPool Struct */
158+struct ShmPool {
159+ int fd;
160+ uint32_t *memory;
161+ unsigned capacity;
162+ unsigned size;
163+};
164+
165+class Wayland: public CBuffering {
166+ public:
167+ Wayland();
168+ virtual ~Wayland();
169+ virtual bool InitDisplay();
170+ virtual bool CreateSurface();
171+ virtual void FreeSurface();
172+ virtual void SetRenderWinPos(int x, int y);
173+ virtual void RenderBuffer(struct wl_buffer *buffer
174+ , mfxFrameSurface1 *surface);
175+ virtual void RenderBufferWinPosSize(struct wl_buffer *buffer
176+ , int x
177+ , int y
178+ , int32_t width
179+ , int32_t height);
180+ bool CreateShmPool(int fd, int32_t size, int prot);
181+ void FreeShmPool();
182+ /* Create wl_buffer from shm_pool */
183+ struct wl_buffer * CreateShmBuffer(unsigned width
184+ , unsigned height
185+ , unsigned stride
186+ , uint32_t PIXEL_FORMAT_ID);
187+ void FreeShmBuffer(struct wl_buffer *buffer);
188+ int Dispatch();
189+ struct wl_buffer * CreatePlanarBuffer(uint32_t name
190+ , int32_t width
191+ , int32_t height
192+ , uint32_t format
193+ , int32_t offsets[3]
194+ , int32_t pitches[3]);
195+ virtual struct wl_buffer * CreatePrimeBuffer(uint32_t name
196+ , int32_t width
197+ , int32_t height
198+ , uint32_t format
199+ , int32_t offsets[3]
200+ , int32_t pitches[3]);
201+ struct wl_display * GetDisplay() { return m_display; }
202+ struct wl_registry * GetRegistry() { return m_registry; }
203+ struct wl_compositor * GetCompositor() { return m_compositor; }
204+ struct wl_shell * GetShell() { return m_shell; }
205+ struct wl_drm * GetDrm() { return m_drm; }
206+ struct wl_shm * GetShm() { return m_shm; };
207+ struct wl_shm_pool * GetShmPool() { return m_pool; }
208+ struct wl_surface * GetSurface() { return m_surface; }
209+ struct wl_shell_surface * GetShellSurface() { return m_shell_surface; }
210+ struct wl_callback * GetCallback() { return m_callback; }
211+ void SetCompositor(struct wl_compositor *compositor)
212+ {
213+ m_compositor = compositor;
214+ }
215+ void SetShell(struct wl_shell *shell)
216+ {
217+ m_shell = shell;
218+ }
219+ void SetShm(struct wl_shm *shm)
220+ {
221+ m_shm = shm;
222+ }
223+ void SetDrm(struct wl_drm *drm)
224+ {
225+ m_drm = drm;
226+ }
227+ void DrmHandleDevice(const char* device);
228+ void DrmHandleAuthenticated();
229+ void RegistryGlobal(struct wl_registry *registry
230+ , uint32_t name
231+ , const char *interface
232+ , uint32_t version);
233+ void DisplayFlush()
234+ {
235+ wl_display_flush(m_display);
236+ }
237+ virtual int DisplayRoundtrip();
238+ void DestroyCallback();
239+ virtual void Sync();
240+ virtual void SetPerfMode(bool perf_mode);
241+ void AddBufferToList(wld_buffer *buffer);
242+ void RemoveBufferFromList(struct wl_buffer *buffer);
243+ void DestroyBufferList();
244+ private:
245+ //no copies allowed
246+ Wayland(const Wayland &);
247+ void operator = (const Wayland&);
248+
249+ struct wl_display *m_display;
250+ struct wl_registry *m_registry;
251+ struct wl_compositor *m_compositor;
252+ struct wl_shell *m_shell;
253+ struct wl_drm *m_drm;
254+ struct wl_shm *m_shm;
255+ struct wl_shm_pool *m_pool;
256+ struct wl_surface *m_surface;
257+ struct wl_shell_surface *m_shell_surface;
258+ struct wl_callback *m_callback;
259+ struct wl_event_queue *m_event_queue;
260+ volatile int m_pending_frame;
261+ struct ShmPool *m_shm_pool;
262+ int m_display_fd;
263+ int m_fd;
264+ struct pollfd m_poll;
265+ drm_intel_bufmgr *m_bufmgr;
266+ char *m_device_name;
267+ int m_x, m_y;
268+ bool m_perf_mode;
269+ protected:
270+ std::list<wld_buffer*> m_buffers_list;
271+};
272+
273+extern "C" Wayland* WaylandCreate();
274+extern "C" void WaylandDestroy(Wayland *pWld);
275+
276+#endif //LIBVA_WAYLAND_SUPPORT
277+
278+#endif /* WAYLAND_CLASS_H */
279diff --git a/tools/legacy/sample_misc/wayland/include/listener_wayland.h b/tools/legacy/sample_misc/wayland/include/listener_wayland.h
280new file mode 100644
281index 0000000..1bbaa91
282--- /dev/null
283+++ b/tools/legacy/sample_misc/wayland/include/listener_wayland.h
284@@ -0,0 +1,66 @@
285+/******************************************************************************\
286+Copyright (c) 2005-2019, Intel Corporation
287+All rights reserved.
288+
289+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
290+
291+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
292+
293+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
294+
295+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
296+
297+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
298+
299+This sample was distributed or derived from the Intel's Media Samples package.
300+The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
301+or https://software.intel.com/en-us/media-client-solutions-support.
302+\**********************************************************************************/
303+
304+#ifndef LISTENER_WAYLAND_H
305+#define LISTENER_WAYLAND_H
306+
307+#include "class_wayland.h"
308+
309+/* drm listeners */
310+void drm_handle_device(void *data
311+ , struct wl_drm *drm
312+ , const char *device);
313+
314+void drm_handle_format(void *data
315+ , struct wl_drm *drm
316+ , uint32_t format);
317+
318+void drm_handle_authenticated(void *data
319+ , struct wl_drm *drm);
320+
321+void drm_handle_capabilities(void *data
322+ , struct wl_drm *drm
323+ , uint32_t value);
324+
325+/* registry listeners */
326+void registry_handle_global(void *data
327+ , struct wl_registry *registry
328+ , uint32_t name
329+ , const char *interface
330+ , uint32_t version);
331+
332+void remove_registry_global(void *data
333+ , struct wl_registry *regsitry
334+ , uint32_t name);
335+
336+/* surface listener */
337+void shell_surface_ping(void *data
338+ , struct wl_shell_surface *shell_surface
339+ , uint32_t serial);
340+
341+void shell_surface_configure(void *data
342+ , struct wl_shell_surface *shell_surface
343+ , uint32_t edges
344+ , int32_t width
345+ , int32_t height);
346+
347+void handle_done(void *data, struct wl_callback *callback, uint32_t time);
348+
349+void buffer_release(void *data, struct wl_buffer *buffer);
350+#endif /* LISTENER_WAYLAND_H */
351diff --git a/tools/legacy/sample_misc/wayland/include/wayland-drm-client-protocol.h b/tools/legacy/sample_misc/wayland/include/wayland-drm-client-protocol.h
352new file mode 100644
353index 0000000..e11b35d
354--- /dev/null
355+++ b/tools/legacy/sample_misc/wayland/include/wayland-drm-client-protocol.h
356@@ -0,0 +1,235 @@
357+/*
358+ * Copyright � 2008-2011 Kristian H�gsberg
359+ * Copyright � 2010-2011 Intel Corporation
360+ *
361+ * Permission to use, copy, modify, distribute, and sell this
362+ * software and its documentation for any purpose is hereby granted
363+ * without fee, provided that\n the above copyright notice appear in
364+ * all copies and that both that copyright notice and this permission
365+ * notice appear in supporting documentation, and that the name of
366+ * the copyright holders not be used in advertising or publicity
367+ * pertaining to distribution of the software without specific,
368+ * written prior permission. The copyright holders make no
369+ * representations about the suitability of this software for any
370+ * purpose. It is provided "as is" without express or implied
371+ * warranty.
372+ *
373+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
374+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
375+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
376+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
377+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
378+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
379+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
380+ * THIS SOFTWARE.
381+ */
382+
383+#ifndef DRM_CLIENT_PROTOCOL_H
384+#define DRM_CLIENT_PROTOCOL_H
385+
386+#ifdef __cplusplus
387+extern "C" {
388+#endif
389+
390+#include <stdint.h>
391+#include <stddef.h>
392+#include "wayland-client.h"
393+
394+struct wl_client;
395+struct wl_resource;
396+
397+struct wl_drm;
398+
399+extern const struct wl_interface wl_drm_interface;
400+
401+#ifndef WL_DRM_ERROR_ENUM
402+#define WL_DRM_ERROR_ENUM
403+enum wl_drm_error {
404+ WL_DRM_ERROR_AUTHENTICATE_FAIL = 0,
405+ WL_DRM_ERROR_INVALID_FORMAT = 1,
406+ WL_DRM_ERROR_INVALID_NAME = 2,
407+};
408+#endif /* WL_DRM_ERROR_ENUM */
409+
410+#ifndef WL_DRM_FORMAT_ENUM
411+#define WL_DRM_FORMAT_ENUM
412+enum wl_drm_format {
413+ WL_DRM_FORMAT_C8 = 0x20203843,
414+ WL_DRM_FORMAT_RGB332 = 0x38424752,
415+ WL_DRM_FORMAT_BGR233 = 0x38524742,
416+ WL_DRM_FORMAT_XRGB4444 = 0x32315258,
417+ WL_DRM_FORMAT_XBGR4444 = 0x32314258,
418+ WL_DRM_FORMAT_RGBX4444 = 0x32315852,
419+ WL_DRM_FORMAT_BGRX4444 = 0x32315842,
420+ WL_DRM_FORMAT_ARGB4444 = 0x32315241,
421+ WL_DRM_FORMAT_ABGR4444 = 0x32314241,
422+ WL_DRM_FORMAT_RGBA4444 = 0x32314152,
423+ WL_DRM_FORMAT_BGRA4444 = 0x32314142,
424+ WL_DRM_FORMAT_XRGB1555 = 0x35315258,
425+ WL_DRM_FORMAT_XBGR1555 = 0x35314258,
426+ WL_DRM_FORMAT_RGBX5551 = 0x35315852,
427+ WL_DRM_FORMAT_BGRX5551 = 0x35315842,
428+ WL_DRM_FORMAT_ARGB1555 = 0x35315241,
429+ WL_DRM_FORMAT_ABGR1555 = 0x35314241,
430+ WL_DRM_FORMAT_RGBA5551 = 0x35314152,
431+ WL_DRM_FORMAT_BGRA5551 = 0x35314142,
432+ WL_DRM_FORMAT_RGB565 = 0x36314752,
433+ WL_DRM_FORMAT_BGR565 = 0x36314742,
434+ WL_DRM_FORMAT_RGB888 = 0x34324752,
435+ WL_DRM_FORMAT_BGR888 = 0x34324742,
436+ WL_DRM_FORMAT_XRGB8888 = 0x34325258,
437+ WL_DRM_FORMAT_XBGR8888 = 0x34324258,
438+ WL_DRM_FORMAT_RGBX8888 = 0x34325852,
439+ WL_DRM_FORMAT_BGRX8888 = 0x34325842,
440+ WL_DRM_FORMAT_ARGB8888 = 0x34325241,
441+ WL_DRM_FORMAT_ABGR8888 = 0x34324241,
442+ WL_DRM_FORMAT_RGBA8888 = 0x34324152,
443+ WL_DRM_FORMAT_BGRA8888 = 0x34324142,
444+ WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
445+ WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
446+ WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
447+ WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
448+ WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
449+ WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
450+ WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
451+ WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
452+ WL_DRM_FORMAT_YUYV = 0x56595559,
453+ WL_DRM_FORMAT_YVYU = 0x55595659,
454+ WL_DRM_FORMAT_UYVY = 0x59565955,
455+ WL_DRM_FORMAT_VYUY = 0x59555956,
456+ WL_DRM_FORMAT_AYUV = 0x56555941,
457+ WL_DRM_FORMAT_NV12 = 0x3231564e,
458+ WL_DRM_FORMAT_NV21 = 0x3132564e,
459+ WL_DRM_FORMAT_NV16 = 0x3631564e,
460+ WL_DRM_FORMAT_NV61 = 0x3136564e,
461+ WL_DRM_FORMAT_YUV410 = 0x39565559,
462+ WL_DRM_FORMAT_YVU410 = 0x39555659,
463+ WL_DRM_FORMAT_YUV411 = 0x31315559,
464+ WL_DRM_FORMAT_YVU411 = 0x31315659,
465+ WL_DRM_FORMAT_YUV420 = 0x32315559,
466+ WL_DRM_FORMAT_YVU420 = 0x32315659,
467+ WL_DRM_FORMAT_YUV422 = 0x36315559,
468+ WL_DRM_FORMAT_YVU422 = 0x36315659,
469+ WL_DRM_FORMAT_YUV444 = 0x34325559,
470+ WL_DRM_FORMAT_YVU444 = 0x34325659,
471+};
472+#endif /* WL_DRM_FORMAT_ENUM */
473+
474+#ifndef WL_DRM_CAPABILITY_ENUM
475+#define WL_DRM_CAPABILITY_ENUM
476+/**
477+ * wl_drm_capability - wl_drm capability bitmask
478+ * @WL_DRM_CAPABILITY_PRIME: wl_drm prime available
479+ *
480+ * Bitmask of capabilities.
481+ */
482+enum wl_drm_capability {
483+ WL_DRM_CAPABILITY_PRIME = 1,
484+};
485+#endif /* WL_DRM_CAPABILITY_ENUM */
486+
487+struct wl_drm_listener {
488+ /**
489+ * device - (none)
490+ * @name: (none)
491+ */
492+ void (*device)(void *data,
493+ struct wl_drm *wl_drm,
494+ const char *name);
495+ /**
496+ * format - (none)
497+ * @format: (none)
498+ */
499+ void (*format)(void *data,
500+ struct wl_drm *wl_drm,
501+ uint32_t format);
502+ /**
503+ * authenticated - (none)
504+ */
505+ void (*authenticated)(void *data,
506+ struct wl_drm *wl_drm);
507+ /**
508+ * capabilities - (none)
509+ * @value: (none)
510+ */
511+ void (*capabilities)(void *data,
512+ struct wl_drm *wl_drm,
513+ uint32_t value);
514+};
515+
516+static inline int
517+wl_drm_add_listener(struct wl_drm *wl_drm,
518+ const struct wl_drm_listener *listener, void *data)
519+{
520+ return wl_proxy_add_listener((struct wl_proxy *) wl_drm,
521+ (void (**)(void)) listener, data);
522+}
523+
524+#define WL_DRM_AUTHENTICATE 0
525+#define WL_DRM_CREATE_BUFFER 1
526+#define WL_DRM_CREATE_PLANAR_BUFFER 2
527+#define WL_DRM_CREATE_PRIME_BUFFER 3
528+
529+static inline void
530+wl_drm_set_user_data(struct wl_drm *wl_drm, void *user_data)
531+{
532+ wl_proxy_set_user_data((struct wl_proxy *) wl_drm, user_data);
533+}
534+
535+static inline void *
536+wl_drm_get_user_data(struct wl_drm *wl_drm)
537+{
538+ return wl_proxy_get_user_data((struct wl_proxy *) wl_drm);
539+}
540+
541+static inline void
542+wl_drm_destroy(struct wl_drm *wl_drm)
543+{
544+ wl_proxy_destroy((struct wl_proxy *) wl_drm);
545+}
546+
547+static inline void
548+wl_drm_authenticate(struct wl_drm *wl_drm, uint32_t id)
549+{
550+ wl_proxy_marshal((struct wl_proxy *) wl_drm,
551+ WL_DRM_AUTHENTICATE, id);
552+}
553+
554+static inline struct wl_buffer *
555+wl_drm_create_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format)
556+{
557+ struct wl_proxy *id;
558+
559+ id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_drm,
560+ WL_DRM_CREATE_BUFFER, &wl_buffer_interface, NULL, name, width, height, stride, format);
561+
562+ return (struct wl_buffer *) id;
563+}
564+
565+static inline struct wl_buffer *
566+wl_drm_create_planar_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t format, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
567+{
568+ struct wl_proxy *id;
569+
570+ id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_drm,
571+ WL_DRM_CREATE_PLANAR_BUFFER, &wl_buffer_interface, NULL, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2);
572+
573+ return (struct wl_buffer *) id;
574+}
575+
576+static inline struct wl_buffer *
577+wl_drm_create_prime_buffer(struct wl_drm *wl_drm, int32_t name, int32_t width, int32_t height, uint32_t format, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
578+{
579+ struct wl_proxy *id;
580+
581+ id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_drm,
582+ WL_DRM_CREATE_PRIME_BUFFER, &wl_buffer_interface, NULL, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2);
583+
584+ return (struct wl_buffer *) id;
585+}
586+
587+#ifdef __cplusplus
588+}
589+#endif
590+
591+#endif
592diff --git a/tools/legacy/sample_misc/wayland/src/class_wayland.cpp b/tools/legacy/sample_misc/wayland/src/class_wayland.cpp
593new file mode 100644
594index 0000000..2bafdb2
595--- /dev/null
596+++ b/tools/legacy/sample_misc/wayland/src/class_wayland.cpp
597@@ -0,0 +1,500 @@
598+/******************************************************************************\
599+Copyright (c) 2005-2019, Intel Corporation
600+All rights reserved.
601+
602+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
603+
604+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
605+
606+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
607+
608+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
609+
610+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
611+
612+This sample was distributed or derived from the Intel's Media Samples package.
613+The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
614+or https://software.intel.com/en-us/media-client-solutions-support.
615+\**********************************************************************************/
616+
617+#include <iostream>
618+#include <exception>
619+#include <cstring>
620+#include <fcntl.h>
621+#include <unistd.h>
622+#include <poll.h>
623+#include <sys/mman.h>
624+extern "C" {
625+#include <drm.h>
626+#include <xf86drm.h>
627+#include <intel_bufmgr.h>
628+}
629+#include "class_wayland.h"
630+#include "listener_wayland.h"
631+#include "wayland-drm-client-protocol.h"
632+
633+#define BATCH_SIZE 0x80000
634+
635+struct buffer {
636+ struct wl_buffer *buffer;
637+ mfxFrameSurface1 *pInSurface;
638+};
639+
640+static const struct wl_callback_listener frame_listener = {
641+ handle_done
642+};
643+
644+static const struct wl_buffer_listener buffer_listener = {
645+ buffer_release
646+};
647+
648+Wayland::Wayland()
649+ : m_display(NULL)
650+ , m_registry(NULL)
651+ , m_compositor(NULL)
652+ , m_shell(NULL)
653+ , m_drm(NULL)
654+ , m_shm(NULL)
655+ , m_pool(NULL)
656+ , m_surface(NULL)
657+ , m_shell_surface(NULL)
658+ , m_callback(NULL)
659+ , m_event_queue(NULL)
660+ , m_pending_frame(0)
661+ , m_shm_pool(NULL)
662+ , m_display_fd(-1)
663+ , m_fd(-1)
664+ , m_bufmgr(NULL)
665+ , m_device_name(NULL)
666+ , m_x(0), m_y(0)
667+ , m_perf_mode(false)
668+{
669+ std::memset(&m_poll, 0, sizeof(m_poll));
670+}
671+
672+bool Wayland::InitDisplay()
673+{
674+ static const struct wl_registry_listener registry_listener = {
675+ .global = registry_handle_global,
676+ .global_remove = remove_registry_global
677+ };
678+
679+ m_display = wl_display_connect(NULL);
680+ if (NULL == m_display) {
681+ std::cout << "Error: Cannot connect to wayland display\n";
682+ return false;
683+ }
684+ m_registry = wl_display_get_registry(m_display);
685+ wl_registry_add_listener(m_registry
686+ , &registry_listener
687+ , this);
688+
689+ m_display_fd = wl_display_get_fd(m_display);
690+ wl_display_roundtrip(m_display);
691+ wl_display_roundtrip(m_display);
692+ m_event_queue = wl_display_create_queue(m_display);
693+ if(NULL == m_event_queue)
694+ return false;
695+
696+ m_poll.fd = m_display_fd;
697+ m_poll.events = POLLIN;
698+ return true;
699+}
700+
701+int Wayland::DisplayRoundtrip()
702+{
703+ return wl_display_roundtrip(m_display);
704+}
705+
706+bool Wayland::CreateSurface()
707+{
708+ static const struct wl_shell_surface_listener
709+ shell_surface_listener = {
710+ shell_surface_ping,
711+ shell_surface_configure
712+ };
713+
714+ m_surface = wl_compositor_create_surface(m_compositor);
715+ if (NULL == m_surface)
716+ return false;
717+
718+ m_shell_surface = wl_shell_get_shell_surface(m_shell
719+ , m_surface);
720+ if(NULL == m_shell_surface)
721+ {
722+ wl_surface_destroy(m_surface);
723+ return false;
724+ }
725+
726+ wl_shell_surface_add_listener(m_shell_surface
727+ , &shell_surface_listener
728+ , 0);
729+ wl_shell_surface_set_toplevel(m_shell_surface);
730+ wl_shell_surface_set_user_data(m_shell_surface, m_surface);
731+ wl_surface_set_user_data(m_surface, NULL);
732+ return true;
733+}
734+
735+
736+void Wayland::FreeSurface()
737+{
738+ if(NULL != m_shell_surface)
739+ wl_shell_surface_destroy(m_shell_surface);
740+ if(NULL != m_surface)
741+ wl_surface_destroy(m_surface);
742+}
743+
744+void Wayland::Sync()
745+{
746+ int ret;
747+ while(NULL != m_callback)
748+ {
749+ while(wl_display_prepare_read_queue(m_display, m_event_queue) < 0)
750+ wl_display_dispatch_queue_pending(m_display, m_event_queue);
751+
752+ wl_display_flush(m_display);
753+
754+ ret = poll(&m_poll,1,-1);
755+ if(ret < 0 )
756+ wl_display_cancel_read(m_display);
757+ else
758+ wl_display_read_events(m_display);
759+ wl_display_dispatch_queue_pending(m_display, m_event_queue);
760+ }
761+}
762+
763+void Wayland::SetPerfMode(bool perf_mode)
764+{
765+ m_perf_mode = perf_mode;
766+}
767+
768+void Wayland::SetRenderWinPos(int x, int y)
769+{
770+ m_x = x; m_y = y;
771+}
772+
773+void Wayland::RenderBuffer(struct wl_buffer *buffer
774+ , mfxFrameSurface1 *surface)
775+{
776+ wld_buffer *m_buffer = new wld_buffer;
777+ if (m_buffer == NULL)
778+ return;
779+
780+ m_buffer->buffer = buffer;
781+ m_buffer->pInSurface = surface;
782+
783+ wl_surface_attach(m_surface, buffer, 0, 0);
784+ wl_surface_damage(m_surface, m_x, m_y, surface->Info.CropW, surface->Info.CropH);
785+
786+ wl_proxy_set_queue((struct wl_proxy *) buffer, m_event_queue);
787+
788+ AddBufferToList(m_buffer);
789+ wl_buffer_add_listener(buffer, &buffer_listener, this);
790+ m_pending_frame=1;
791+ if (m_perf_mode)
792+ m_callback = wl_display_sync(m_display);
793+ else
794+ m_callback = wl_surface_frame(m_surface);
795+ wl_callback_add_listener(m_callback, &frame_listener, this);
796+ wl_proxy_set_queue((struct wl_proxy *) m_callback, m_event_queue);
797+ wl_surface_commit(m_surface);
798+ wl_display_dispatch_queue(m_display, m_event_queue);
799+ /* Force a Sync before and after render to ensure client handles
800+ wayland events in a timely fashion. This also fixes the one time
801+ flicker issue on wl_shell_surface pointer enter */
802+ Sync();
803+
804+}
805+
806+void Wayland::RenderBufferWinPosSize(struct wl_buffer *buffer
807+ , int x
808+ , int y
809+ , int32_t width
810+ , int32_t height)
811+{
812+ wl_surface_attach(m_surface, buffer, 0, 0);
813+ wl_surface_damage(m_surface, x, y, width, height);
814+
815+ wl_proxy_set_queue((struct wl_proxy *) buffer, m_event_queue);
816+
817+ wl_buffer_add_listener(buffer, &buffer_listener, NULL);
818+ m_pending_frame=1;
819+ if (m_perf_mode)
820+ m_callback = wl_display_sync(m_display);
821+ else
822+ m_callback = wl_surface_frame(m_surface);
823+ wl_callback_add_listener(m_callback, &frame_listener, this);
824+ wl_proxy_set_queue((struct wl_proxy *) m_callback, m_event_queue);
825+ wl_surface_commit(m_surface);
826+ wl_display_dispatch_queue(m_display, m_event_queue);
827+}
828+
829+
830+void Wayland::DestroyCallback()
831+{
832+ if(m_callback)
833+ {
834+ wl_callback_destroy(m_callback);
835+ m_callback = NULL;
836+ m_pending_frame=0;
837+ }
838+}
839+
840+//ShmPool
841+bool Wayland::CreateShmPool(int fd, int32_t size, int prot)
842+{
843+ m_shm_pool = new struct ShmPool;
844+ if (NULL == m_shm_pool)
845+ return false;
846+
847+ m_shm_pool->capacity = size;
848+ m_shm_pool->size = 0;
849+ m_shm_pool->fd = fd;
850+
851+ m_shm_pool->memory = static_cast<uint32_t*>(mmap(0
852+ , size
853+ , prot
854+ , MAP_SHARED
855+ , m_shm_pool->fd
856+ , 0));
857+ if (MAP_FAILED == m_shm_pool->memory)
858+ {
859+ delete m_shm_pool;
860+ return false;
861+ }
862+
863+ m_pool = wl_shm_create_pool(m_shm
864+ , m_shm_pool->fd
865+ , size);
866+ if (NULL == m_pool)
867+ {
868+ munmap(m_shm_pool->memory, size);
869+ delete m_shm_pool;
870+ return false;
871+ }
872+ wl_shm_pool_set_user_data(m_pool, m_shm_pool);
873+ return true;
874+}
875+
876+
877+void Wayland::FreeShmPool()
878+{
879+ wl_shm_pool_destroy(m_pool);
880+ munmap(m_shm_pool->memory, m_shm_pool->capacity);
881+ delete m_shm_pool;
882+}
883+
884+
885+struct wl_buffer * Wayland::CreateShmBuffer(unsigned width
886+ , unsigned height
887+ , unsigned stride
888+ , uint32_t PIXEL_FORMAT_ID)
889+{
890+ struct wl_buffer *buffer;
891+ buffer = wl_shm_pool_create_buffer(m_pool
892+ , m_shm_pool->size*sizeof(uint32_t)
893+ , width
894+ , height
895+ , stride
896+ , PIXEL_FORMAT_ID);
897+ if(NULL == buffer)
898+ return NULL;
899+
900+ m_shm_pool->size += stride*height;
901+ return buffer;
902+}
903+
904+void Wayland::FreeShmBuffer(struct wl_buffer *buffer)
905+{
906+ wl_buffer_destroy(buffer);
907+}
908+
909+int Wayland::Dispatch()
910+{
911+ return wl_display_dispatch(m_display);
912+}
913+
914+struct wl_buffer * Wayland::CreatePlanarBuffer(uint32_t name
915+ , int32_t width
916+ , int32_t height
917+ , uint32_t format
918+ , int32_t offsets[3]
919+ , int32_t pitches[3])
920+{
921+ struct wl_buffer * buffer = NULL;
922+ if(NULL == m_drm)
923+ return NULL;
924+
925+ buffer = wl_drm_create_planar_buffer(m_drm
926+ , name
927+ , width
928+ , height
929+ , format
930+ , offsets[0]
931+ , pitches[0]
932+ , offsets[1]
933+ , pitches[1]
934+ , offsets[2]
935+ , pitches[2]);
936+ return buffer;
937+}
938+
939+struct wl_buffer * Wayland::CreatePrimeBuffer(uint32_t name
940+ , int32_t width
941+ , int32_t height
942+ , uint32_t format
943+ , int32_t offsets[3]
944+ , int32_t pitches[3])
945+{
946+ struct wl_buffer * buffer = NULL;
947+ if(NULL == m_drm)
948+ return NULL;
949+
950+ buffer = wl_drm_create_prime_buffer(m_drm
951+ , name
952+ , width
953+ , height
954+ , format
955+ , offsets[0]
956+ , pitches[0]
957+ , offsets[1]
958+ , pitches[1]
959+ , offsets[2]
960+ , pitches[2]);
961+ return buffer;
962+}
963+
964+Wayland::~Wayland()
965+{
966+ if(NULL != m_shell)
967+ wl_shell_destroy(m_shell);
968+ if(NULL != m_shm)
969+ wl_shm_destroy(m_shm);
970+ if(NULL != m_bufmgr) {
971+ drm_intel_bufmgr_destroy(m_bufmgr);
972+ }
973+ if(NULL != m_compositor)
974+ wl_compositor_destroy(m_compositor);
975+ if(NULL != m_event_queue)
976+ wl_event_queue_destroy(m_event_queue);
977+ if(0 != m_buffers_list.size())
978+ DestroyBufferList();
979+ if(NULL != m_registry)
980+ wl_registry_destroy(m_registry);
981+ if(NULL != m_display)
982+ wl_display_disconnect(m_display);
983+ if(NULL != m_device_name)
984+ delete m_device_name;
985+}
986+
987+// Registry
988+void Wayland::RegistryGlobal(struct wl_registry *registry
989+ , uint32_t name
990+ , const char *interface
991+ , uint32_t version)
992+{
993+ if(0 == strcmp(interface, "wl_compositor"))
994+ m_compositor = static_cast<wl_compositor*>
995+ (wl_registry_bind(registry
996+ , name
997+ , &wl_compositor_interface
998+ , version));
999+ else if(0 == strcmp(interface, "wl_shell"))
1000+ m_shell = static_cast<wl_shell*>
1001+ (wl_registry_bind(registry
1002+ , name
1003+ , &wl_shell_interface
1004+ , version));
1005+ else if(0 == strcmp(interface, "wl_drm")) {
1006+ static const struct wl_drm_listener drm_listener = {
1007+ drm_handle_device,
1008+ drm_handle_format,
1009+ drm_handle_authenticated,
1010+ drm_handle_capabilities
1011+ };
1012+ m_drm = static_cast<wl_drm*>(wl_registry_bind(registry
1013+ , name
1014+ , &wl_drm_interface
1015+ , 2));
1016+ wl_drm_add_listener(m_drm, &drm_listener, this);
1017+ }
1018+}
1019+
1020+void Wayland::DrmHandleDevice(const char *name)
1021+{
1022+ m_device_name = strdup(name);
1023+ if (!m_device_name)
1024+ return;
1025+
1026+ drm_magic_t magic;
1027+ m_fd = open(m_device_name, O_RDWR | O_CLOEXEC);
1028+ if (-1 == m_fd) {
1029+ std::cout << "Error: Could not open " <<
1030+ m_device_name << "\n";
1031+ return;
1032+ }
1033+ int type = drmGetNodeTypeFromFd(m_fd);
1034+ if (type != DRM_NODE_RENDER) {
1035+ drmGetMagic(m_fd, &magic);
1036+ wl_drm_authenticate(m_drm, magic);
1037+ }
1038+}
1039+
1040+void Wayland::DrmHandleAuthenticated()
1041+{
1042+ m_bufmgr = drm_intel_bufmgr_gem_init(m_fd, BATCH_SIZE);
1043+}
1044+
1045+void Wayland::AddBufferToList(wld_buffer *buffer)
1046+{
1047+ if (buffer == NULL)
1048+ return;
1049+
1050+ if (buffer->pInSurface) {
1051+ msdkFrameSurface *surface = FindUsedSurface(buffer->pInSurface);
1052+ msdk_atomic_inc16(&(surface->render_lock));
1053+ m_buffers_list.push_back(buffer);
1054+ }
1055+}
1056+
1057+void Wayland::RemoveBufferFromList(struct wl_buffer *buffer)
1058+{
1059+ wld_buffer *m_buffer = NULL;
1060+ m_buffer = m_buffers_list.front();
1061+ if (NULL != m_buffer && (m_buffer->buffer == buffer)) {
1062+ if (m_buffer->pInSurface) {
1063+ msdkFrameSurface *surface = FindUsedSurface(m_buffer->pInSurface);
1064+ msdk_atomic_dec16(&(surface->render_lock));
1065+ }
1066+ m_buffer->buffer = NULL;
1067+ m_buffer->pInSurface = NULL;
1068+ m_buffers_list.pop_front();
1069+ delete m_buffer;
1070+ }
1071+}
1072+
1073+void Wayland::DestroyBufferList()
1074+{
1075+ wld_buffer *m_buffer = NULL;
1076+ while (!m_buffers_list.empty())
1077+ {
1078+ m_buffer = m_buffers_list.front();
1079+ if (m_buffer->pInSurface)
1080+ {
1081+ msdkFrameSurface *surface = FindUsedSurface(m_buffer->pInSurface);
1082+ msdk_atomic_dec16(&(surface->render_lock));
1083+ }
1084+ m_buffers_list.pop_front();
1085+ delete m_buffer;
1086+ }
1087+}
1088+
1089+Wayland* WaylandCreate()
1090+{
1091+ return new Wayland;
1092+}
1093+
1094+void WaylandDestroy(Wayland *pWld)
1095+{
1096+ delete pWld;
1097+}
1098diff --git a/tools/legacy/sample_misc/wayland/src/listener_wayland.cpp b/tools/legacy/sample_misc/wayland/src/listener_wayland.cpp
1099new file mode 100644
1100index 0000000..90f582a
1101--- /dev/null
1102+++ b/tools/legacy/sample_misc/wayland/src/listener_wayland.cpp
1103@@ -0,0 +1,105 @@
1104+/******************************************************************************\
1105+Copyright (c) 2005-2019, Intel Corporation
1106+All rights reserved.
1107+
1108+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1109+
1110+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1111+
1112+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
1113+
1114+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1115+
1116+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1117+
1118+This sample was distributed or derived from the Intel's Media Samples package.
1119+The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
1120+or https://software.intel.com/en-us/media-client-solutions-support.
1121+\**********************************************************************************/
1122+
1123+#include <iostream>
1124+#include "listener_wayland.h"
1125+#include "class_wayland.h"
1126+
1127+/* drm listener */
1128+void drm_handle_device(void *data
1129+ , struct wl_drm *drm
1130+ , const char *device)
1131+{
1132+ Wayland *wayland = static_cast<Wayland*>(data);
1133+ wayland->DrmHandleDevice(device);
1134+}
1135+
1136+void drm_handle_format(void *data
1137+ , struct wl_drm *drm
1138+ , uint32_t format)
1139+{
1140+ /* NOT IMPLEMENTED */
1141+}
1142+
1143+void drm_handle_capabilities(void *data
1144+ , struct wl_drm *drm
1145+ , uint32_t value)
1146+{
1147+ /* NOT IMPLEMENTED */
1148+}
1149+
1150+void drm_handle_authenticated(void *data
1151+ , struct wl_drm *drm)
1152+{
1153+ Wayland *wayland = static_cast<Wayland*>(data);
1154+ wayland->DrmHandleAuthenticated();
1155+}
1156+
1157+/* registry listener */
1158+void registry_handle_global(void *data
1159+ , struct wl_registry *registry
1160+ , uint32_t name
1161+ , const char *interface
1162+ , uint32_t version)
1163+{
1164+ Wayland *wayland = static_cast<Wayland*>(data);
1165+ wayland->RegistryGlobal(registry
1166+ , name
1167+ , interface
1168+ , version);
1169+}
1170+
1171+void remove_registry_global(void *data
1172+ , struct wl_registry *registy
1173+ , uint32_t name)
1174+{
1175+ /* NOT IMPLEMENTED */
1176+}
1177+
1178+
1179+/* surface listener */
1180+void shell_surface_ping(void *data
1181+ , struct wl_shell_surface *shell_surface
1182+ , uint32_t serial)
1183+{
1184+ wl_shell_surface_pong(shell_surface, serial);
1185+}
1186+
1187+void shell_surface_configure(void *data
1188+ , struct wl_shell_surface *shell_surface
1189+ , uint32_t edges
1190+ , int32_t width
1191+ , int32_t height)
1192+{
1193+ /* NOT IMPLEMENTED */
1194+}
1195+
1196+void handle_done(void *data, struct wl_callback *callback, uint32_t time)
1197+{
1198+ Wayland *wayland = static_cast<Wayland*>(data);
1199+ wayland->DestroyCallback();
1200+}
1201+
1202+void buffer_release(void *data, struct wl_buffer *buffer)
1203+{
1204+ Wayland *wayland = static_cast<Wayland*>(data);
1205+ wayland->RemoveBufferFromList(buffer);
1206+ wl_buffer_destroy(buffer);
1207+ buffer = NULL;
1208+}
1209diff --git a/tools/legacy/sample_misc/wayland/src/wayland-drm-protocol.c b/tools/legacy/sample_misc/wayland/src/wayland-drm-protocol.c
1210new file mode 100644
1211index 0000000..8e1fd50
1212--- /dev/null
1213+++ b/tools/legacy/sample_misc/wayland/src/wayland-drm-protocol.c
1214@@ -0,0 +1,84 @@
1215+/*
1216+ * Copyright � 2008-2011 Kristian H�gsberg
1217+ * Copyright � 2010-2011 Intel Corporation
1218+ *
1219+ * Permission to use, copy, modify, distribute, and sell this
1220+ * software and its documentation for any purpose is hereby granted
1221+ * without fee, provided that\n the above copyright notice appear in
1222+ * all copies and that both that copyright notice and this permission
1223+ * notice appear in supporting documentation, and that the name of
1224+ * the copyright holders not be used in advertising or publicity
1225+ * pertaining to distribution of the software without specific,
1226+ * written prior permission. The copyright holders make no
1227+ * representations about the suitability of this software for any
1228+ * purpose. It is provided "as is" without express or implied
1229+ * warranty.
1230+ *
1231+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
1232+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
1233+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
1234+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1235+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
1236+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
1237+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
1238+ * THIS SOFTWARE.
1239+ */
1240+
1241+#include <stdlib.h>
1242+#include <stdint.h>
1243+#include "wayland-util.h"
1244+
1245+extern const struct wl_interface wl_buffer_interface;
1246+
1247+static const struct wl_interface *types[] = {
1248+ NULL,
1249+ &wl_buffer_interface,
1250+ NULL,
1251+ NULL,
1252+ NULL,
1253+ NULL,
1254+ NULL,
1255+ &wl_buffer_interface,
1256+ NULL,
1257+ NULL,
1258+ NULL,
1259+ NULL,
1260+ NULL,
1261+ NULL,
1262+ NULL,
1263+ NULL,
1264+ NULL,
1265+ NULL,
1266+ &wl_buffer_interface,
1267+ NULL,
1268+ NULL,
1269+ NULL,
1270+ NULL,
1271+ NULL,
1272+ NULL,
1273+ NULL,
1274+ NULL,
1275+ NULL,
1276+ NULL,
1277+};
1278+
1279+static const struct wl_message wl_drm_requests[] = {
1280+ { "authenticate", "u", types + 0 },
1281+ { "create_buffer", "nuiiuu", types + 1 },
1282+ { "create_planar_buffer", "nuiiuiiiiii", types + 7 },
1283+ { "create_prime_buffer", "2nhiiuiiiiii", types + 18 },
1284+};
1285+
1286+static const struct wl_message wl_drm_events[] = {
1287+ { "device", "s", types + 0 },
1288+ { "format", "u", types + 0 },
1289+ { "authenticated", "", types + 0 },
1290+ { "capabilities", "u", types + 0 },
1291+};
1292+
1293+WL_EXPORT const struct wl_interface wl_drm_interface = {
1294+ "wl_drm", 2,
1295+ 4, wl_drm_requests,
1296+ 4, wl_drm_events,
1297+};
1298+
1299--
13002.7.4
1301
diff --git a/recipes-multimedia/onevpl/onevpl_2021.2.2.bb b/recipes-multimedia/onevpl/onevpl_2021.2.2.bb
index 566d84d..a508432 100644
--- a/recipes-multimedia/onevpl/onevpl_2021.2.2.bb
+++ b/recipes-multimedia/onevpl/onevpl_2021.2.2.bb
@@ -11,6 +11,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=c18ea6bb4786a26bf4eee88a7424a408 \
11SRC_URI = "git://github.com/oneapi-src/oneVPL.git;protocol=https \ 11SRC_URI = "git://github.com/oneapi-src/oneVPL.git;protocol=https \
12 file://0001-cmake-Allow-build-env-to-set-variables.patch \ 12 file://0001-cmake-Allow-build-env-to-set-variables.patch \
13 file://0001-Add-X11-support-to-legacy-tools.patch \ 13 file://0001-Add-X11-support-to-legacy-tools.patch \
14 file://0001-Adding-Wayland-support-to-legacy-tools.patch \
14 " 15 "
15SRCREV = "17968d8d2299352f5a9e09388d24e81064c81c87" 16SRCREV = "17968d8d2299352f5a9e09388d24e81064c81c87"
16S = "${WORKDIR}/git" 17S = "${WORKDIR}/git"