mirror of
git://git.yoctoproject.org/meta-intel.git
synced 2025-07-19 12:59:03 +02:00
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>
This commit is contained in:
parent
d9b5426214
commit
cfa56575f7
|
@ -0,0 +1,146 @@
|
|||
From a1216ce48771a2c7cf690d148d64c2797a960720 Mon Sep 17 00:00:00 2001
|
||||
From: "Sodhi, Vunny" <vunny.sodhi@intel.com>
|
||||
Date: Fri, 28 May 2021 11:40:21 +0800
|
||||
Subject: [meta-intel][PATCH] 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
|
||||
|
||||
Issue: #2675
|
||||
|
||||
Upstream-Status: Backport
|
||||
https://github.com/Intel-Media-SDK/MediaSDK/pull/2704
|
||||
|
||||
Signed-off: Fu, Wei A <wei.a.fu@intel.com>
|
||||
Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com>
|
||||
---
|
||||
samples/sample_common/include/vaapi_utils.h | 4 +++
|
||||
samples/sample_common/src/vaapi_allocator.cpp | 1 +
|
||||
samples/sample_common/src/vaapi_utils.cpp | 1 +
|
||||
samples/sample_common/src/vaapi_utils_drm.cpp | 45 ++++++++++++++++++++++++---
|
||||
4 files changed, 46 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/samples/sample_common/include/vaapi_utils.h b/samples/sample_common/include/vaapi_utils.h
|
||||
index 49589c6..39f77b9 100644
|
||||
--- a/samples/sample_common/include/vaapi_utils.h
|
||||
+++ b/samples/sample_common/include/vaapi_utils.h
|
||||
@@ -154,6 +154,9 @@ namespace MfxLoader
|
||||
int fd, uint32_t width, uint32_t height, uint8_t depth,
|
||||
uint8_t bpp, 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 );
|
||||
@@ -188,6 +191,7 @@ namespace MfxLoader
|
||||
#define __DECLARE(name) const name ## _type name
|
||||
__DECLARE(drmIoctl);
|
||||
__DECLARE(drmModeAddFB);
|
||||
+ __DECLARE(drmModeAddFB2WithModifiers);
|
||||
__DECLARE(drmModeFreeConnector);
|
||||
__DECLARE(drmModeFreeCrtc);
|
||||
__DECLARE(drmModeFreeEncoder);
|
||||
diff --git a/samples/sample_common/src/vaapi_allocator.cpp b/samples/sample_common/src/vaapi_allocator.cpp
|
||||
index bf20b0d..442eca0 100644
|
||||
--- a/samples/sample_common/src/vaapi_allocator.cpp
|
||||
+++ b/samples/sample_common/src/vaapi_allocator.cpp
|
||||
@@ -408,6 +408,7 @@ mfxStatus vaapiFrameAllocator::AllocImpl(mfxFrameAllocRequest *request, mfxFrame
|
||||
}
|
||||
}
|
||||
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/samples/sample_common/src/vaapi_utils.cpp b/samples/sample_common/src/vaapi_utils.cpp
|
||||
index 680c5c3..83ba46c 100644
|
||||
--- a/samples/sample_common/src/vaapi_utils.cpp
|
||||
+++ b/samples/sample_common/src/vaapi_utils.cpp
|
||||
@@ -111,6 +111,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/samples/sample_common/src/vaapi_utils_drm.cpp b/samples/sample_common/src/vaapi_utils_drm.cpp
|
||||
index 9663245..5ad73dd 100644
|
||||
--- a/samples/sample_common/src/vaapi_utils_drm.cpp
|
||||
+++ b/samples/sample_common/src/vaapi_utils_drm.cpp
|
||||
@@ -28,6 +28,7 @@ or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
|
||||
#include "vaapi_utils_drm.h"
|
||||
#include <drm_fourcc.h>
|
||||
+#include "i915_drm.h"
|
||||
|
||||
constexpr mfxU32 MFX_DRI_MAX_NODES_NUM = 16;
|
||||
constexpr mfxU32 MFX_DRI_RENDER_START_INDEX = 128;
|
||||
@@ -343,7 +344,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);
|
||||
@@ -420,10 +422,43 @@ void* drmRenderer::acquire(mfxMemId mid)
|
||||
int ret = m_drmlib.drmIoctl(m_fd, DRM_IOCTL_GEM_OPEN, &flink_open);
|
||||
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;
|
||||
|
||||
MSDK_ZERO_MEMORY(flink_close);
|
||||
--
|
||||
2.7.4
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
From 3fc9fe078c850643f8070cce1d2b0307a9014523 Mon Sep 17 00:00:00 2001
|
||||
From: "Sodhi, Vunny" <vunny.sodhi@intel.com>
|
||||
Date: Fri, 13 Aug 2021 12:09:26 +0800
|
||||
Subject: [meta-intel][PATCH] 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
|
||||
https://github.com/Intel-Media-SDK/MediaSDK/pull/2755
|
||||
|
||||
Signed-off-by: Sodhi, Vunny <vunny.sodhi@intel.com>
|
||||
---
|
||||
samples/sample_common/src/vaapi_utils_drm.cpp | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/samples/sample_common/src/vaapi_utils_drm.cpp b/samples/sample_common/src/vaapi_utils_drm.cpp
|
||||
index 5ad73dd..73c8bd2 100644
|
||||
--- a/samples/sample_common/src/vaapi_utils_drm.cpp
|
||||
+++ b/samples/sample_common/src/vaapi_utils_drm.cpp
|
||||
@@ -422,7 +422,7 @@ void* drmRenderer::acquire(mfxMemId mid)
|
||||
int ret = m_drmlib.drmIoctl(m_fd, DRM_IOCTL_GEM_OPEN, &flink_open);
|
||||
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));
|
||||
@@ -452,13 +452,14 @@ 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;
|
||||
}
|
||||
|
||||
ret = m_drmlib.drmModeAddFB2WithModifiers(m_fd, vmid->m_image.width, vmid->m_image.height,
|
||||
- pixel_format, handles, pitches, offsets, modifiers, &fbhandle, 0);
|
||||
+ pixel_format, handles, pitches, offsets, modifiers, &fbhandle, flags);
|
||||
if (ret) return NULL;
|
||||
|
||||
MSDK_ZERO_MEMORY(flink_close);
|
||||
--
|
||||
2.7.4
|
||||
|
|
@ -33,6 +33,8 @@ PACKAGECONFIG[wayland] = "-DENABLE_WAYLAND=ON, -DENABLE_WAYLAND=OFF, wayland way
|
|||
|
||||
SRC_URI = "git://github.com/Intel-Media-SDK/MediaSDK.git;protocol=https;nobranch=1;lfs=0 \
|
||||
file://0001-FindITT.cmake-fix-detection-of-header-library.patch \
|
||||
file://0001-Add-support-of-DRM_FORMAT_NV12-for-console-mode-rend.patch \
|
||||
file://0001-Fixed-tile-modifier-issue-for-NV12-format.patch \
|
||||
"
|
||||
|
||||
SRCREV = "24b964e32692f68ed01aad73850bdaa440c2fcd7"
|
||||
|
|
Loading…
Reference in New Issue
Block a user