summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia
diff options
context:
space:
mode:
authorYew, Chang Ching <chang.ching.yew@intel.com>2021-08-25 05:59:16 (GMT)
committerAnuj Mittal <anuj.mittal@intel.com>2021-08-26 04:10:09 (GMT)
commit036ca44cbb943f1bf46ad060d6f2e58ff276dfa7 (patch)
treee60b6e67bf86c8547e9b8c24806ea4f5c5ac6b10 /recipes-multimedia
parenta41f5a188a456fe82791d9dca534fd704e53aaca (diff)
downloadmeta-intel-036ca44cbb943f1bf46ad060d6f2e58ff276dfa7.tar.gz
onevpl: Add support of DRM_FORMAT_NV12 and fix tile issue
Currently in drm/console mode only RGB4 direct rendering is possible. This patch add NV12 format support. If we are using I915_FORMAT_MOD_Y_TILED which is needed for NV12 format then modifiers need to be enabled which can be passed as flags argument to ioctl. Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Yew, Chang Ching <chang.ching.yew@intel.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'recipes-multimedia')
-rw-r--r--recipes-multimedia/onevpl/onevpl/0001-samples-Add-support-of-DRM_FORMAT_NV12-for-console-m.patch170
-rw-r--r--recipes-multimedia/onevpl/onevpl/0001-samples-Fixed-tile-modifier-issue-for-NV12-format.patch51
-rw-r--r--recipes-multimedia/onevpl/onevpl_2021.5.0.bb2
3 files changed, 223 insertions, 0 deletions
diff --git a/recipes-multimedia/onevpl/onevpl/0001-samples-Add-support-of-DRM_FORMAT_NV12-for-console-m.patch b/recipes-multimedia/onevpl/onevpl/0001-samples-Add-support-of-DRM_FORMAT_NV12-for-console-m.patch
new file mode 100644
index 0000000..a5191fe
--- /dev/null
+++ b/recipes-multimedia/onevpl/onevpl/0001-samples-Add-support-of-DRM_FORMAT_NV12-for-console-m.patch
@@ -0,0 +1,170 @@
1From a7f667debb6cf3007ef5b581a91ff7c925d623c3 Mon Sep 17 00:00:00 2001
2From: "Yew, Chang Ching" <chang.ching.yew@intel.com>
3Date: Wed, 25 Aug 2021 11:13:28 +0000
4Subject: [PATCH 1/2] samples: Add support of DRM_FORMAT_NV12 for console mode
5 rendering
6
7Currently in drm/console mode only RGB4 direct rendering
8is possible. This patch add NV12 format provided your
9platform and kernel can support it.
10
11Tested both formats using:
12sample_encode h265 -i 4k.h265 -rdrm -nv12
13sample_encode h265 -i 4k.h265 -rdrm -rgb4
14
15Upstream-Status: Submitted
16innersource PR #221
17
18Signed-off: Fu, Wei A <wei.a.fu@intel.com>
19Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com>
20Signed-off-by: Yew, Chang Ching <chang.ching.yew@intel.com>
21---
22 .../sample_common/include/vaapi_utils.h | 11 ++++
23 .../sample_common/src/vaapi_allocator.cpp | 1 +
24 .../legacy/sample_common/src/vaapi_utils.cpp | 1 +
25 .../sample_common/src/vaapi_utils_drm.cpp | 61 +++++++++++++++----
26 4 files changed, 63 insertions(+), 11 deletions(-)
27
28diff --git a/tools/legacy/sample_common/include/vaapi_utils.h b/tools/legacy/sample_common/include/vaapi_utils.h
29index 53318630..9df5507b 100644
30--- a/tools/legacy/sample_common/include/vaapi_utils.h
31+++ b/tools/legacy/sample_common/include/vaapi_utils.h
32@@ -149,6 +149,16 @@ public:
33 uint32_t pitch,
34 uint32_t bo_handle,
35 uint32_t* buf_id);
36+ typedef int (*drmModeAddFB2WithModifiers_type)(int fd,
37+ uint32_t width,
38+ uint32_t height,
39+ uint32_t pixel_format,
40+ uint32_t bo_handles[4],
41+ uint32_t pitches[4],
42+ uint32_t offsets[4],
43+ uint64_t modifier[4],
44+ uint32_t* buf_id,
45+ uint32_t flags);
46 typedef void (*drmModeFreeConnector_type)(drmModeConnectorPtr ptr);
47 typedef void (*drmModeFreeCrtc_type)(drmModeCrtcPtr ptr);
48 typedef void (*drmModeFreeEncoder_type)(drmModeEncoderPtr ptr);
49@@ -192,6 +202,7 @@ public:
50 #define __DECLARE(name) const name##_type name
51 __DECLARE(drmIoctl);
52 __DECLARE(drmModeAddFB);
53+ __DECLARE(drmModeAddFB2WithModifiers);
54 __DECLARE(drmModeFreeConnector);
55 __DECLARE(drmModeFreeCrtc);
56 __DECLARE(drmModeFreeEncoder);
57diff --git a/tools/legacy/sample_common/src/vaapi_allocator.cpp b/tools/legacy/sample_common/src/vaapi_allocator.cpp
58index 51690186..12ace297 100644
59--- a/tools/legacy/sample_common/src/vaapi_allocator.cpp
60+++ b/tools/legacy/sample_common/src/vaapi_allocator.cpp
61@@ -364,6 +364,7 @@ mfxStatus vaapiFrameAllocator::AllocImpl(mfxFrameAllocRequest* request,
62 }
63 }
64 if (m_exporter) {
65+ vaapi_mids[i].m_fourcc = va_fourcc;
66 vaapi_mids[i].m_custom = m_exporter->acquire(&vaapi_mids[i]);
67 if (!vaapi_mids[i].m_custom) {
68 mfx_res = MFX_ERR_UNKNOWN;
69diff --git a/tools/legacy/sample_common/src/vaapi_utils.cpp b/tools/legacy/sample_common/src/vaapi_utils.cpp
70index b69dbe44..9531c65b 100644
71--- a/tools/legacy/sample_common/src/vaapi_utils.cpp
72+++ b/tools/legacy/sample_common/src/vaapi_utils.cpp
73@@ -94,6 +94,7 @@ DRM_Proxy::DRM_Proxy()
74 : lib("libdrm.so.2"),
75 SIMPLE_LOADER_FUNCTION(drmIoctl),
76 SIMPLE_LOADER_FUNCTION(drmModeAddFB),
77+ SIMPLE_LOADER_FUNCTION(drmModeAddFB2WithModifiers),
78 SIMPLE_LOADER_FUNCTION(drmModeFreeConnector),
79 SIMPLE_LOADER_FUNCTION(drmModeFreeCrtc),
80 SIMPLE_LOADER_FUNCTION(drmModeFreeEncoder),
81diff --git a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
82index c896017b..cf8d7ba7 100644
83--- a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
84+++ b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
85@@ -11,9 +11,9 @@
86 #include <sys/ioctl.h>
87 #include "vaapi_allocator.h"
88
89- #include <stdexcept>
90-
91 #include <drm_fourcc.h>
92+ #include <stdexcept>
93+ #include "i915_drm.h"
94 #include "vaapi_utils_drm.h"
95
96 constexpr mfxU32 MFX_DRI_MAX_NODES_NUM = 16;
97@@ -311,7 +311,8 @@ bool drmRenderer::getPlane() {
98 if (plane) {
99 if (plane->possible_crtcs & (1 << m_crtcIndex)) {
100 for (uint32_t j = 0; j < plane->count_formats; ++j) {
101- if (plane->formats[j] == DRM_FORMAT_XRGB8888) {
102+ if ((plane->formats[j] == DRM_FORMAT_XRGB8888) ||
103+ (plane->formats[j] == DRM_FORMAT_NV12)) {
104 m_planeID = plane->plane_id;
105 m_drmlib.drmModeFreePlane(plane);
106 m_drmlib.drmModeFreePlaneResources(planes);
107@@ -404,14 +405,52 @@ void* drmRenderer::acquire(mfxMemId mid) {
108 if (ret)
109 return NULL;
110
111- ret = m_drmlib.drmModeAddFB(m_fd,
112- vmid->m_image.width,
113- vmid->m_image.height,
114- 24,
115- 32,
116- vmid->m_image.pitches[0],
117- flink_open.handle,
118- &fbhandle);
119+ uint32_t handles[4], pitches[4], offsets[4], pixel_format;
120+ uint64_t modifiers[4];
121+
122+ memset(&handles, 0, sizeof(handles));
123+ memset(&pitches, 0, sizeof(pitches));
124+ memset(&offsets, 0, sizeof(offsets));
125+ memset(&modifiers, 0, sizeof(modifiers));
126+
127+ handles[0] = flink_open.handle;
128+ pitches[0] = vmid->m_image.pitches[0];
129+ offsets[0] = vmid->m_image.offsets[0];
130+
131+ if (VA_FOURCC_NV12 == vmid->m_fourcc) {
132+ struct drm_i915_gem_set_tiling set_tiling;
133+
134+ pixel_format = DRM_FORMAT_NV12;
135+ memset(&set_tiling, 0, sizeof(set_tiling));
136+ set_tiling.handle = flink_open.handle;
137+ set_tiling.tiling_mode = I915_TILING_Y;
138+ set_tiling.stride = vmid->m_image.pitches[0];
139+ ret = m_drmlib.drmIoctl(m_fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling);
140+ if (ret) {
141+ msdk_printf(MSDK_STRING("DRM_IOCTL_I915_GEM_SET_TILING Failed ret = %d\n"), ret);
142+ return NULL;
143+ }
144+
145+ handles[1] = flink_open.handle;
146+ pitches[1] = vmid->m_image.pitches[1];
147+ offsets[1] = vmid->m_image.offsets[1];
148+ modifiers[0] = modifiers[1] = I915_FORMAT_MOD_Y_TILED;
149+ }
150+ else {
151+ pixel_format = DRM_FORMAT_XRGB8888;
152+ }
153+
154+ ret = m_drmlib.drmModeAddFB2WithModifiers(m_fd,
155+ vmid->m_image.width,
156+ vmid->m_image.height,
157+ pixel_format,
158+ handles,
159+ pitches,
160+ offsets,
161+ modifiers,
162+ &fbhandle,
163+ 0);
164+
165 if (ret)
166 return NULL;
167
168--
1692.31.1
170
diff --git a/recipes-multimedia/onevpl/onevpl/0001-samples-Fixed-tile-modifier-issue-for-NV12-format.patch b/recipes-multimedia/onevpl/onevpl/0001-samples-Fixed-tile-modifier-issue-for-NV12-format.patch
new file mode 100644
index 0000000..c798e3f
--- /dev/null
+++ b/recipes-multimedia/onevpl/onevpl/0001-samples-Fixed-tile-modifier-issue-for-NV12-format.patch
@@ -0,0 +1,51 @@
1From 15cc366b66b625b0b2613a4365e7777563325a94 Mon Sep 17 00:00:00 2001
2From: "Yew, Chang Ching" <chang.ching.yew@intel.com>
3Date: Wed, 25 Aug 2021 11:20:30 +0000
4Subject: [PATCH 2/2] samples: Fixed tile modifier issue for NV12 format
5
6If we are using I915_FORMAT_MOD_Y_TILED which is needed for
7NV12 format then modifiers need to be enabled which can be passed
8as flags argument to ioctl.
9
10Upstream-Status: Submitted
11innersource PR #221
12
13Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com>
14Signed-off-by: Yew, Chang Ching <chang.ching.yew@intel.com>
15---
16 tools/legacy/sample_common/src/vaapi_utils_drm.cpp | 5 +++--
17 1 file changed, 3 insertions(+), 2 deletions(-)
18
19diff --git a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
20index cf8d7ba7..3df3bb8a 100644
21--- a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
22+++ b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
23@@ -405,7 +405,7 @@ void* drmRenderer::acquire(mfxMemId mid) {
24 if (ret)
25 return NULL;
26
27- uint32_t handles[4], pitches[4], offsets[4], pixel_format;
28+ uint32_t handles[4], pitches[4], offsets[4], pixel_format, flags = 0;
29 uint64_t modifiers[4];
30
31 memset(&handles, 0, sizeof(handles));
32@@ -435,6 +435,7 @@ void* drmRenderer::acquire(mfxMemId mid) {
33 pitches[1] = vmid->m_image.pitches[1];
34 offsets[1] = vmid->m_image.offsets[1];
35 modifiers[0] = modifiers[1] = I915_FORMAT_MOD_Y_TILED;
36+ flags = 2; // DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[]
37 }
38 else {
39 pixel_format = DRM_FORMAT_XRGB8888;
40@@ -449,7 +450,7 @@ void* drmRenderer::acquire(mfxMemId mid) {
41 offsets,
42 modifiers,
43 &fbhandle,
44- 0);
45+ flags);
46
47 if (ret)
48 return NULL;
49--
502.31.1
51
diff --git a/recipes-multimedia/onevpl/onevpl_2021.5.0.bb b/recipes-multimedia/onevpl/onevpl_2021.5.0.bb
index bb7ec49..da530d6 100644
--- a/recipes-multimedia/onevpl/onevpl_2021.5.0.bb
+++ b/recipes-multimedia/onevpl/onevpl_2021.5.0.bb
@@ -11,6 +11,8 @@ 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-Fix-the-rendering-to-X11-failures.patch \ 12 file://0001-Fix-the-rendering-to-X11-failures.patch \
13 file://0001-Fix-compile-issue-with-CMAKE_CXX_FLAGS-setting.patch \ 13 file://0001-Fix-compile-issue-with-CMAKE_CXX_FLAGS-setting.patch \
14 file://0001-samples-Add-support-of-DRM_FORMAT_NV12-for-console-m.patch \
15 file://0001-samples-Fixed-tile-modifier-issue-for-NV12-format.patch \
14 " 16 "
15SRCREV = "dde640ef0872b645d6e0275a6aaec26c01a9c0b9" 17SRCREV = "dde640ef0872b645d6e0275a6aaec26c01a9c0b9"
16S = "${WORKDIR}/git" 18S = "${WORKDIR}/git"