diff options
| author | Yew, Chang Ching <chang.ching.yew@intel.com> | 2021-08-25 13:59:16 +0800 |
|---|---|---|
| committer | Anuj Mittal <anuj.mittal@intel.com> | 2021-08-26 12:10:09 +0800 |
| commit | 036ca44cbb943f1bf46ad060d6f2e58ff276dfa7 (patch) | |
| tree | e60b6e67bf86c8547e9b8c24806ea4f5c5ac6b10 | |
| parent | a41f5a188a456fe82791d9dca534fd704e53aaca (diff) | |
| download | meta-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>
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 00000000..a5191fe2 --- /dev/null +++ b/recipes-multimedia/onevpl/onevpl/0001-samples-Add-support-of-DRM_FORMAT_NV12-for-console-m.patch | |||
| @@ -0,0 +1,170 @@ | |||
| 1 | From a7f667debb6cf3007ef5b581a91ff7c925d623c3 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: "Yew, Chang Ching" <chang.ching.yew@intel.com> | ||
| 3 | Date: Wed, 25 Aug 2021 11:13:28 +0000 | ||
| 4 | Subject: [PATCH 1/2] samples: Add support of DRM_FORMAT_NV12 for console mode | ||
| 5 | rendering | ||
| 6 | |||
| 7 | Currently in drm/console mode only RGB4 direct rendering | ||
| 8 | is possible. This patch add NV12 format provided your | ||
| 9 | platform and kernel can support it. | ||
| 10 | |||
| 11 | Tested both formats using: | ||
| 12 | sample_encode h265 -i 4k.h265 -rdrm -nv12 | ||
| 13 | sample_encode h265 -i 4k.h265 -rdrm -rgb4 | ||
| 14 | |||
| 15 | Upstream-Status: Submitted | ||
| 16 | innersource PR #221 | ||
| 17 | |||
| 18 | Signed-off: Fu, Wei A <wei.a.fu@intel.com> | ||
| 19 | Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com> | ||
| 20 | Signed-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 | |||
| 28 | diff --git a/tools/legacy/sample_common/include/vaapi_utils.h b/tools/legacy/sample_common/include/vaapi_utils.h | ||
| 29 | index 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); | ||
| 57 | diff --git a/tools/legacy/sample_common/src/vaapi_allocator.cpp b/tools/legacy/sample_common/src/vaapi_allocator.cpp | ||
| 58 | index 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; | ||
| 69 | diff --git a/tools/legacy/sample_common/src/vaapi_utils.cpp b/tools/legacy/sample_common/src/vaapi_utils.cpp | ||
| 70 | index 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), | ||
| 81 | diff --git a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp | ||
| 82 | index 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 | -- | ||
| 169 | 2.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 00000000..c798e3f1 --- /dev/null +++ b/recipes-multimedia/onevpl/onevpl/0001-samples-Fixed-tile-modifier-issue-for-NV12-format.patch | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | From 15cc366b66b625b0b2613a4365e7777563325a94 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: "Yew, Chang Ching" <chang.ching.yew@intel.com> | ||
| 3 | Date: Wed, 25 Aug 2021 11:20:30 +0000 | ||
| 4 | Subject: [PATCH 2/2] samples: Fixed tile modifier issue for NV12 format | ||
| 5 | |||
| 6 | If we are using I915_FORMAT_MOD_Y_TILED which is needed for | ||
| 7 | NV12 format then modifiers need to be enabled which can be passed | ||
| 8 | as flags argument to ioctl. | ||
| 9 | |||
| 10 | Upstream-Status: Submitted | ||
| 11 | innersource PR #221 | ||
| 12 | |||
| 13 | Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com> | ||
| 14 | Signed-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 | |||
| 19 | diff --git a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp | ||
| 20 | index 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 | -- | ||
| 50 | 2.31.1 | ||
| 51 | |||
diff --git a/recipes-multimedia/onevpl/onevpl_2021.5.0.bb b/recipes-multimedia/onevpl/onevpl_2021.5.0.bb index bb7ec49d..da530d64 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 \ | |||
| 11 | SRC_URI = "git://github.com/oneapi-src/oneVPL.git;protocol=https \ | 11 | SRC_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 | " |
| 15 | SRCREV = "dde640ef0872b645d6e0275a6aaec26c01a9c0b9" | 17 | SRCREV = "dde640ef0872b645d6e0275a6aaec26c01a9c0b9" |
| 16 | S = "${WORKDIR}/git" | 18 | S = "${WORKDIR}/git" |
