summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia
diff options
context:
space:
mode:
authorSodhi, Vunny <vunny.sodhi@intel.com>2021-08-16 09:13:46 (GMT)
committerAnuj Mittal <anuj.mittal@intel.com>2021-08-17 02:49:25 (GMT)
commitcfa56575f7330ebef9ded88c61e72c4eda667f27 (patch)
treecb2d5fade38390dbb7aeb0532021e16b1b5e247a /recipes-multimedia
parentd9b542621493423745ba2a5bf51e546ea4f3a382 (diff)
downloadmeta-intel-cfa56575f7330ebef9ded88c61e72c4eda667f27.tar.gz
intel-mediasdk: 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>
Diffstat (limited to 'recipes-multimedia')
-rw-r--r--recipes-multimedia/mediasdk/files/0001-Add-support-of-DRM_FORMAT_NV12-for-console-mode-rend.patch146
-rw-r--r--recipes-multimedia/mediasdk/files/0001-Fixed-tile-modifier-issue-for-NV12-format.patch49
-rw-r--r--recipes-multimedia/mediasdk/intel-mediasdk_21.2.3.bb2
3 files changed, 197 insertions, 0 deletions
diff --git a/recipes-multimedia/mediasdk/files/0001-Add-support-of-DRM_FORMAT_NV12-for-console-mode-rend.patch b/recipes-multimedia/mediasdk/files/0001-Add-support-of-DRM_FORMAT_NV12-for-console-mode-rend.patch
new file mode 100644
index 0000000..4b3c650
--- /dev/null
+++ b/recipes-multimedia/mediasdk/files/0001-Add-support-of-DRM_FORMAT_NV12-for-console-mode-rend.patch
@@ -0,0 +1,146 @@
1From a1216ce48771a2c7cf690d148d64c2797a960720 Mon Sep 17 00:00:00 2001
2From: "Sodhi, Vunny" <vunny.sodhi@intel.com>
3Date: Fri, 28 May 2021 11:40:21 +0800
4Subject: [meta-intel][PATCH] Add support of DRM_FORMAT_NV12 for console mode rendering
5
6Currently in drm/console mode only RGB4 direct rendering
7is possible. This patch add NV12 format provided your
8platform and kernel can support it.
9
10Tested both formats using:
11sample_encode h265 -i 4k.h265 -rdrm -nv12
12sample_encode h265 -i 4k.h265 -rdrm -rgb4
13
14Issue: #2675
15
16Upstream-Status: Backport
17https://github.com/Intel-Media-SDK/MediaSDK/pull/2704
18
19Signed-off: Fu, Wei A <wei.a.fu@intel.com>
20Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com>
21---
22 samples/sample_common/include/vaapi_utils.h | 4 +++
23 samples/sample_common/src/vaapi_allocator.cpp | 1 +
24 samples/sample_common/src/vaapi_utils.cpp | 1 +
25 samples/sample_common/src/vaapi_utils_drm.cpp | 45 ++++++++++++++++++++++++---
26 4 files changed, 46 insertions(+), 5 deletions(-)
27
28diff --git a/samples/sample_common/include/vaapi_utils.h b/samples/sample_common/include/vaapi_utils.h
29index 49589c6..39f77b9 100644
30--- a/samples/sample_common/include/vaapi_utils.h
31+++ b/samples/sample_common/include/vaapi_utils.h
32@@ -154,6 +154,9 @@ namespace MfxLoader
33 int fd, uint32_t width, uint32_t height, uint8_t depth,
34 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
35 uint32_t *buf_id);
36+ typedef int (*drmModeAddFB2WithModifiers_type)(int fd, uint32_t width, uint32_t height, uint32_t pixel_format,
37+ uint32_t bo_handles[4], uint32_t pitches[4], uint32_t offsets[4], uint64_t modifier[4],
38+ uint32_t *buf_id, uint32_t flags);
39 typedef void (*drmModeFreeConnector_type)( drmModeConnectorPtr ptr );
40 typedef void (*drmModeFreeCrtc_type)( drmModeCrtcPtr ptr );
41 typedef void (*drmModeFreeEncoder_type)( drmModeEncoderPtr ptr );
42@@ -188,6 +191,7 @@ namespace MfxLoader
43 #define __DECLARE(name) const name ## _type name
44 __DECLARE(drmIoctl);
45 __DECLARE(drmModeAddFB);
46+ __DECLARE(drmModeAddFB2WithModifiers);
47 __DECLARE(drmModeFreeConnector);
48 __DECLARE(drmModeFreeCrtc);
49 __DECLARE(drmModeFreeEncoder);
50diff --git a/samples/sample_common/src/vaapi_allocator.cpp b/samples/sample_common/src/vaapi_allocator.cpp
51index bf20b0d..442eca0 100644
52--- a/samples/sample_common/src/vaapi_allocator.cpp
53+++ b/samples/sample_common/src/vaapi_allocator.cpp
54@@ -408,6 +408,7 @@ mfxStatus vaapiFrameAllocator::AllocImpl(mfxFrameAllocRequest *request, mfxFrame
55 }
56 }
57 if (m_exporter) {
58+ vaapi_mids[i].m_fourcc = va_fourcc;
59 vaapi_mids[i].m_custom = m_exporter->acquire(&vaapi_mids[i]);
60 if (!vaapi_mids[i].m_custom) {
61 mfx_res = MFX_ERR_UNKNOWN;
62diff --git a/samples/sample_common/src/vaapi_utils.cpp b/samples/sample_common/src/vaapi_utils.cpp
63index 680c5c3..83ba46c 100644
64--- a/samples/sample_common/src/vaapi_utils.cpp
65+++ b/samples/sample_common/src/vaapi_utils.cpp
66@@ -111,6 +111,7 @@ DRM_Proxy::DRM_Proxy()
67 : lib("libdrm.so.2")
68 , SIMPLE_LOADER_FUNCTION(drmIoctl)
69 , SIMPLE_LOADER_FUNCTION(drmModeAddFB)
70+ , SIMPLE_LOADER_FUNCTION(drmModeAddFB2WithModifiers)
71 , SIMPLE_LOADER_FUNCTION(drmModeFreeConnector)
72 , SIMPLE_LOADER_FUNCTION(drmModeFreeCrtc)
73 , SIMPLE_LOADER_FUNCTION(drmModeFreeEncoder)
74diff --git a/samples/sample_common/src/vaapi_utils_drm.cpp b/samples/sample_common/src/vaapi_utils_drm.cpp
75index 9663245..5ad73dd 100644
76--- a/samples/sample_common/src/vaapi_utils_drm.cpp
77+++ b/samples/sample_common/src/vaapi_utils_drm.cpp
78@@ -28,6 +28,7 @@ or https://software.intel.com/en-us/media-client-solutions-support.
79
80 #include "vaapi_utils_drm.h"
81 #include <drm_fourcc.h>
82+#include "i915_drm.h"
83
84 constexpr mfxU32 MFX_DRI_MAX_NODES_NUM = 16;
85 constexpr mfxU32 MFX_DRI_RENDER_START_INDEX = 128;
86@@ -343,7 +344,8 @@ bool drmRenderer::getPlane()
87 if (plane) {
88 if (plane->possible_crtcs & (1 << m_crtcIndex)) {
89 for (uint32_t j = 0; j < plane->count_formats; ++j) {
90- if (plane->formats[j] == DRM_FORMAT_XRGB8888) {
91+ if ((plane->formats[j] == DRM_FORMAT_XRGB8888)
92+ || (plane->formats[j] == DRM_FORMAT_NV12)) {
93 m_planeID = plane->plane_id;
94 m_drmlib.drmModeFreePlane(plane);
95 m_drmlib.drmModeFreePlaneResources(planes);
96@@ -420,10 +422,43 @@ void* drmRenderer::acquire(mfxMemId mid)
97 int ret = m_drmlib.drmIoctl(m_fd, DRM_IOCTL_GEM_OPEN, &flink_open);
98 if (ret) return NULL;
99
100- ret = m_drmlib.drmModeAddFB(m_fd,
101- vmid->m_image.width, vmid->m_image.height,
102- 24, 32, vmid->m_image.pitches[0],
103- flink_open.handle, &fbhandle);
104+ uint32_t handles[4], pitches[4], offsets[4], pixel_format;
105+ uint64_t modifiers[4];
106+
107+ memset(&handles, 0, sizeof(handles));
108+ memset(&pitches, 0, sizeof(pitches));
109+ memset(&offsets, 0, sizeof(offsets));
110+ memset(&modifiers, 0, sizeof(modifiers));
111+
112+ handles[0] = flink_open.handle;
113+ pitches[0] = vmid->m_image.pitches[0];
114+ offsets[0] = vmid->m_image.offsets[0];
115+
116+ if (VA_FOURCC_NV12 == vmid->m_fourcc) {
117+ struct drm_i915_gem_set_tiling set_tiling;
118+
119+ pixel_format = DRM_FORMAT_NV12;
120+ memset(&set_tiling, 0, sizeof(set_tiling));
121+ set_tiling.handle = flink_open.handle;
122+ set_tiling.tiling_mode = I915_TILING_Y;
123+ set_tiling.stride = vmid->m_image.pitches[0];
124+ ret = m_drmlib.drmIoctl(m_fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling);
125+ if (ret) {
126+ msdk_printf(MSDK_STRING("DRM_IOCTL_I915_GEM_SET_TILING Failed ret = %d\n"),ret);
127+ return NULL;
128+ }
129+
130+ handles[1] = flink_open.handle;
131+ pitches[1] = vmid->m_image.pitches[1];
132+ offsets[1] = vmid->m_image.offsets[1];
133+ modifiers[0] = modifiers[1] = I915_FORMAT_MOD_Y_TILED;
134+ }
135+ else {
136+ pixel_format = DRM_FORMAT_XRGB8888;
137+ }
138+
139+ ret = m_drmlib.drmModeAddFB2WithModifiers(m_fd, vmid->m_image.width, vmid->m_image.height,
140+ pixel_format, handles, pitches, offsets, modifiers, &fbhandle, 0);
141 if (ret) return NULL;
142
143 MSDK_ZERO_MEMORY(flink_close);
144--
1452.7.4
146
diff --git a/recipes-multimedia/mediasdk/files/0001-Fixed-tile-modifier-issue-for-NV12-format.patch b/recipes-multimedia/mediasdk/files/0001-Fixed-tile-modifier-issue-for-NV12-format.patch
new file mode 100644
index 0000000..c249c17
--- /dev/null
+++ b/recipes-multimedia/mediasdk/files/0001-Fixed-tile-modifier-issue-for-NV12-format.patch
@@ -0,0 +1,49 @@
1From 3fc9fe078c850643f8070cce1d2b0307a9014523 Mon Sep 17 00:00:00 2001
2From: "Sodhi, Vunny" <vunny.sodhi@intel.com>
3Date: Fri, 13 Aug 2021 12:09:26 +0800
4Subject: [meta-intel][PATCH] 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
11https://github.com/Intel-Media-SDK/MediaSDK/pull/2755
12
13Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com>
14---
15 samples/sample_common/src/vaapi_utils_drm.cpp | 5 +++--
16 1 file changed, 3 insertions(+), 2 deletions(-)
17
18diff --git a/samples/sample_common/src/vaapi_utils_drm.cpp b/samples/sample_common/src/vaapi_utils_drm.cpp
19index 5ad73dd..73c8bd2 100644
20--- a/samples/sample_common/src/vaapi_utils_drm.cpp
21+++ b/samples/sample_common/src/vaapi_utils_drm.cpp
22@@ -422,7 +422,7 @@ void* drmRenderer::acquire(mfxMemId mid)
23 int ret = m_drmlib.drmIoctl(m_fd, DRM_IOCTL_GEM_OPEN, &flink_open);
24 if (ret) return NULL;
25
26- uint32_t handles[4], pitches[4], offsets[4], pixel_format;
27+ uint32_t handles[4], pitches[4], offsets[4], pixel_format, flags = 0;
28 uint64_t modifiers[4];
29
30 memset(&handles, 0, sizeof(handles));
31@@ -452,13 +452,14 @@ void* drmRenderer::acquire(mfxMemId mid)
32 pitches[1] = vmid->m_image.pitches[1];
33 offsets[1] = vmid->m_image.offsets[1];
34 modifiers[0] = modifiers[1] = I915_FORMAT_MOD_Y_TILED;
35+ flags = 2; // DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[]
36 }
37 else {
38 pixel_format = DRM_FORMAT_XRGB8888;
39 }
40
41 ret = m_drmlib.drmModeAddFB2WithModifiers(m_fd, vmid->m_image.width, vmid->m_image.height,
42- pixel_format, handles, pitches, offsets, modifiers, &fbhandle, 0);
43+ pixel_format, handles, pitches, offsets, modifiers, &fbhandle, flags);
44 if (ret) return NULL;
45
46 MSDK_ZERO_MEMORY(flink_close);
47--
482.7.4
49
diff --git a/recipes-multimedia/mediasdk/intel-mediasdk_21.2.3.bb b/recipes-multimedia/mediasdk/intel-mediasdk_21.2.3.bb
index acdc83e..4f2690d 100644
--- a/recipes-multimedia/mediasdk/intel-mediasdk_21.2.3.bb
+++ b/recipes-multimedia/mediasdk/intel-mediasdk_21.2.3.bb
@@ -33,6 +33,8 @@ PACKAGECONFIG[wayland] = "-DENABLE_WAYLAND=ON, -DENABLE_WAYLAND=OFF, wayland way
33 33
34SRC_URI = "git://github.com/Intel-Media-SDK/MediaSDK.git;protocol=https;nobranch=1;lfs=0 \ 34SRC_URI = "git://github.com/Intel-Media-SDK/MediaSDK.git;protocol=https;nobranch=1;lfs=0 \
35 file://0001-FindITT.cmake-fix-detection-of-header-library.patch \ 35 file://0001-FindITT.cmake-fix-detection-of-header-library.patch \
36 file://0001-Add-support-of-DRM_FORMAT_NV12-for-console-mode-rend.patch \
37 file://0001-Fixed-tile-modifier-issue-for-NV12-format.patch \
36 " 38 "
37 39
38SRCREV = "24b964e32692f68ed01aad73850bdaa440c2fcd7" 40SRCREV = "24b964e32692f68ed01aad73850bdaa440c2fcd7"