mirror of
git://git.yoctoproject.org/meta-intel.git
synced 2025-07-19 21:09:03 +02:00
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>
This commit is contained in:
parent
a41f5a188a
commit
036ca44cbb
|
@ -0,0 +1,170 @@
|
||||||
|
From a7f667debb6cf3007ef5b581a91ff7c925d623c3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Yew, Chang Ching" <chang.ching.yew@intel.com>
|
||||||
|
Date: Wed, 25 Aug 2021 11:13:28 +0000
|
||||||
|
Subject: [PATCH 1/2] samples: Add support of DRM_FORMAT_NV12 for console mode
|
||||||
|
rendering
|
||||||
|
|
||||||
|
Currently in drm/console mode only RGB4 direct rendering
|
||||||
|
is possible. This patch add NV12 format provided your
|
||||||
|
platform and kernel can support it.
|
||||||
|
|
||||||
|
Tested both formats using:
|
||||||
|
sample_encode h265 -i 4k.h265 -rdrm -nv12
|
||||||
|
sample_encode h265 -i 4k.h265 -rdrm -rgb4
|
||||||
|
|
||||||
|
Upstream-Status: Submitted
|
||||||
|
innersource PR #221
|
||||||
|
|
||||||
|
Signed-off: Fu, Wei A <wei.a.fu@intel.com>
|
||||||
|
Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com>
|
||||||
|
Signed-off-by: Yew, Chang Ching <chang.ching.yew@intel.com>
|
||||||
|
---
|
||||||
|
.../sample_common/include/vaapi_utils.h | 11 ++++
|
||||||
|
.../sample_common/src/vaapi_allocator.cpp | 1 +
|
||||||
|
.../legacy/sample_common/src/vaapi_utils.cpp | 1 +
|
||||||
|
.../sample_common/src/vaapi_utils_drm.cpp | 61 +++++++++++++++----
|
||||||
|
4 files changed, 63 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tools/legacy/sample_common/include/vaapi_utils.h b/tools/legacy/sample_common/include/vaapi_utils.h
|
||||||
|
index 53318630..9df5507b 100644
|
||||||
|
--- a/tools/legacy/sample_common/include/vaapi_utils.h
|
||||||
|
+++ b/tools/legacy/sample_common/include/vaapi_utils.h
|
||||||
|
@@ -149,6 +149,16 @@ public:
|
||||||
|
uint32_t pitch,
|
||||||
|
uint32_t bo_handle,
|
||||||
|
uint32_t* buf_id);
|
||||||
|
+ typedef int (*drmModeAddFB2WithModifiers_type)(int fd,
|
||||||
|
+ uint32_t width,
|
||||||
|
+ uint32_t height,
|
||||||
|
+ uint32_t pixel_format,
|
||||||
|
+ uint32_t bo_handles[4],
|
||||||
|
+ uint32_t pitches[4],
|
||||||
|
+ uint32_t offsets[4],
|
||||||
|
+ uint64_t modifier[4],
|
||||||
|
+ uint32_t* buf_id,
|
||||||
|
+ uint32_t flags);
|
||||||
|
typedef void (*drmModeFreeConnector_type)(drmModeConnectorPtr ptr);
|
||||||
|
typedef void (*drmModeFreeCrtc_type)(drmModeCrtcPtr ptr);
|
||||||
|
typedef void (*drmModeFreeEncoder_type)(drmModeEncoderPtr ptr);
|
||||||
|
@@ -192,6 +202,7 @@ public:
|
||||||
|
#define __DECLARE(name) const name##_type name
|
||||||
|
__DECLARE(drmIoctl);
|
||||||
|
__DECLARE(drmModeAddFB);
|
||||||
|
+ __DECLARE(drmModeAddFB2WithModifiers);
|
||||||
|
__DECLARE(drmModeFreeConnector);
|
||||||
|
__DECLARE(drmModeFreeCrtc);
|
||||||
|
__DECLARE(drmModeFreeEncoder);
|
||||||
|
diff --git a/tools/legacy/sample_common/src/vaapi_allocator.cpp b/tools/legacy/sample_common/src/vaapi_allocator.cpp
|
||||||
|
index 51690186..12ace297 100644
|
||||||
|
--- a/tools/legacy/sample_common/src/vaapi_allocator.cpp
|
||||||
|
+++ b/tools/legacy/sample_common/src/vaapi_allocator.cpp
|
||||||
|
@@ -364,6 +364,7 @@ mfxStatus vaapiFrameAllocator::AllocImpl(mfxFrameAllocRequest* request,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_exporter) {
|
||||||
|
+ vaapi_mids[i].m_fourcc = va_fourcc;
|
||||||
|
vaapi_mids[i].m_custom = m_exporter->acquire(&vaapi_mids[i]);
|
||||||
|
if (!vaapi_mids[i].m_custom) {
|
||||||
|
mfx_res = MFX_ERR_UNKNOWN;
|
||||||
|
diff --git a/tools/legacy/sample_common/src/vaapi_utils.cpp b/tools/legacy/sample_common/src/vaapi_utils.cpp
|
||||||
|
index b69dbe44..9531c65b 100644
|
||||||
|
--- a/tools/legacy/sample_common/src/vaapi_utils.cpp
|
||||||
|
+++ b/tools/legacy/sample_common/src/vaapi_utils.cpp
|
||||||
|
@@ -94,6 +94,7 @@ DRM_Proxy::DRM_Proxy()
|
||||||
|
: lib("libdrm.so.2"),
|
||||||
|
SIMPLE_LOADER_FUNCTION(drmIoctl),
|
||||||
|
SIMPLE_LOADER_FUNCTION(drmModeAddFB),
|
||||||
|
+ SIMPLE_LOADER_FUNCTION(drmModeAddFB2WithModifiers),
|
||||||
|
SIMPLE_LOADER_FUNCTION(drmModeFreeConnector),
|
||||||
|
SIMPLE_LOADER_FUNCTION(drmModeFreeCrtc),
|
||||||
|
SIMPLE_LOADER_FUNCTION(drmModeFreeEncoder),
|
||||||
|
diff --git a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
|
||||||
|
index c896017b..cf8d7ba7 100644
|
||||||
|
--- a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
|
||||||
|
+++ b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
|
||||||
|
@@ -11,9 +11,9 @@
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include "vaapi_allocator.h"
|
||||||
|
|
||||||
|
- #include <stdexcept>
|
||||||
|
-
|
||||||
|
#include <drm_fourcc.h>
|
||||||
|
+ #include <stdexcept>
|
||||||
|
+ #include "i915_drm.h"
|
||||||
|
#include "vaapi_utils_drm.h"
|
||||||
|
|
||||||
|
constexpr mfxU32 MFX_DRI_MAX_NODES_NUM = 16;
|
||||||
|
@@ -311,7 +311,8 @@ bool drmRenderer::getPlane() {
|
||||||
|
if (plane) {
|
||||||
|
if (plane->possible_crtcs & (1 << m_crtcIndex)) {
|
||||||
|
for (uint32_t j = 0; j < plane->count_formats; ++j) {
|
||||||
|
- if (plane->formats[j] == DRM_FORMAT_XRGB8888) {
|
||||||
|
+ if ((plane->formats[j] == DRM_FORMAT_XRGB8888) ||
|
||||||
|
+ (plane->formats[j] == DRM_FORMAT_NV12)) {
|
||||||
|
m_planeID = plane->plane_id;
|
||||||
|
m_drmlib.drmModeFreePlane(plane);
|
||||||
|
m_drmlib.drmModeFreePlaneResources(planes);
|
||||||
|
@@ -404,14 +405,52 @@ void* drmRenderer::acquire(mfxMemId mid) {
|
||||||
|
if (ret)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- ret = m_drmlib.drmModeAddFB(m_fd,
|
||||||
|
- vmid->m_image.width,
|
||||||
|
- vmid->m_image.height,
|
||||||
|
- 24,
|
||||||
|
- 32,
|
||||||
|
- vmid->m_image.pitches[0],
|
||||||
|
- flink_open.handle,
|
||||||
|
- &fbhandle);
|
||||||
|
+ uint32_t handles[4], pitches[4], offsets[4], pixel_format;
|
||||||
|
+ uint64_t modifiers[4];
|
||||||
|
+
|
||||||
|
+ memset(&handles, 0, sizeof(handles));
|
||||||
|
+ memset(&pitches, 0, sizeof(pitches));
|
||||||
|
+ memset(&offsets, 0, sizeof(offsets));
|
||||||
|
+ memset(&modifiers, 0, sizeof(modifiers));
|
||||||
|
+
|
||||||
|
+ handles[0] = flink_open.handle;
|
||||||
|
+ pitches[0] = vmid->m_image.pitches[0];
|
||||||
|
+ offsets[0] = vmid->m_image.offsets[0];
|
||||||
|
+
|
||||||
|
+ if (VA_FOURCC_NV12 == vmid->m_fourcc) {
|
||||||
|
+ struct drm_i915_gem_set_tiling set_tiling;
|
||||||
|
+
|
||||||
|
+ pixel_format = DRM_FORMAT_NV12;
|
||||||
|
+ memset(&set_tiling, 0, sizeof(set_tiling));
|
||||||
|
+ set_tiling.handle = flink_open.handle;
|
||||||
|
+ set_tiling.tiling_mode = I915_TILING_Y;
|
||||||
|
+ set_tiling.stride = vmid->m_image.pitches[0];
|
||||||
|
+ ret = m_drmlib.drmIoctl(m_fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling);
|
||||||
|
+ if (ret) {
|
||||||
|
+ msdk_printf(MSDK_STRING("DRM_IOCTL_I915_GEM_SET_TILING Failed ret = %d\n"), ret);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ handles[1] = flink_open.handle;
|
||||||
|
+ pitches[1] = vmid->m_image.pitches[1];
|
||||||
|
+ offsets[1] = vmid->m_image.offsets[1];
|
||||||
|
+ modifiers[0] = modifiers[1] = I915_FORMAT_MOD_Y_TILED;
|
||||||
|
+ }
|
||||||
|
+ else {
|
||||||
|
+ pixel_format = DRM_FORMAT_XRGB8888;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = m_drmlib.drmModeAddFB2WithModifiers(m_fd,
|
||||||
|
+ vmid->m_image.width,
|
||||||
|
+ vmid->m_image.height,
|
||||||
|
+ pixel_format,
|
||||||
|
+ handles,
|
||||||
|
+ pitches,
|
||||||
|
+ offsets,
|
||||||
|
+ modifiers,
|
||||||
|
+ &fbhandle,
|
||||||
|
+ 0);
|
||||||
|
+
|
||||||
|
if (ret)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
From 15cc366b66b625b0b2613a4365e7777563325a94 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Yew, Chang Ching" <chang.ching.yew@intel.com>
|
||||||
|
Date: Wed, 25 Aug 2021 11:20:30 +0000
|
||||||
|
Subject: [PATCH 2/2] samples: Fixed tile modifier issue for NV12 format
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Upstream-Status: Submitted
|
||||||
|
innersource PR #221
|
||||||
|
|
||||||
|
Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com>
|
||||||
|
Signed-off-by: Yew, Chang Ching <chang.ching.yew@intel.com>
|
||||||
|
---
|
||||||
|
tools/legacy/sample_common/src/vaapi_utils_drm.cpp | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
|
||||||
|
index cf8d7ba7..3df3bb8a 100644
|
||||||
|
--- a/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
|
||||||
|
+++ b/tools/legacy/sample_common/src/vaapi_utils_drm.cpp
|
||||||
|
@@ -405,7 +405,7 @@ void* drmRenderer::acquire(mfxMemId mid) {
|
||||||
|
if (ret)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- uint32_t handles[4], pitches[4], offsets[4], pixel_format;
|
||||||
|
+ uint32_t handles[4], pitches[4], offsets[4], pixel_format, flags = 0;
|
||||||
|
uint64_t modifiers[4];
|
||||||
|
|
||||||
|
memset(&handles, 0, sizeof(handles));
|
||||||
|
@@ -435,6 +435,7 @@ void* drmRenderer::acquire(mfxMemId mid) {
|
||||||
|
pitches[1] = vmid->m_image.pitches[1];
|
||||||
|
offsets[1] = vmid->m_image.offsets[1];
|
||||||
|
modifiers[0] = modifiers[1] = I915_FORMAT_MOD_Y_TILED;
|
||||||
|
+ flags = 2; // DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pixel_format = DRM_FORMAT_XRGB8888;
|
||||||
|
@@ -449,7 +450,7 @@ void* drmRenderer::acquire(mfxMemId mid) {
|
||||||
|
offsets,
|
||||||
|
modifiers,
|
||||||
|
&fbhandle,
|
||||||
|
- 0);
|
||||||
|
+ flags);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
return NULL;
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
|
@ -11,6 +11,8 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=c18ea6bb4786a26bf4eee88a7424a408 \
|
||||||
SRC_URI = "git://github.com/oneapi-src/oneVPL.git;protocol=https \
|
SRC_URI = "git://github.com/oneapi-src/oneVPL.git;protocol=https \
|
||||||
file://0001-Fix-the-rendering-to-X11-failures.patch \
|
file://0001-Fix-the-rendering-to-X11-failures.patch \
|
||||||
file://0001-Fix-compile-issue-with-CMAKE_CXX_FLAGS-setting.patch \
|
file://0001-Fix-compile-issue-with-CMAKE_CXX_FLAGS-setting.patch \
|
||||||
|
file://0001-samples-Add-support-of-DRM_FORMAT_NV12-for-console-m.patch \
|
||||||
|
file://0001-samples-Fixed-tile-modifier-issue-for-NV12-format.patch \
|
||||||
"
|
"
|
||||||
SRCREV = "dde640ef0872b645d6e0275a6aaec26c01a9c0b9"
|
SRCREV = "dde640ef0872b645d6e0275a6aaec26c01a9c0b9"
|
||||||
S = "${WORKDIR}/git"
|
S = "${WORKDIR}/git"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user