diff options
| -rw-r--r-- | recipes-multimedia/onevpl/onevpl/0001-Fix-the-rendering-to-X11-failures.patch | 135 | ||||
| -rw-r--r-- | recipes-multimedia/onevpl/onevpl_2021.4.0.bb | 1 |
2 files changed, 136 insertions, 0 deletions
diff --git a/recipes-multimedia/onevpl/onevpl/0001-Fix-the-rendering-to-X11-failures.patch b/recipes-multimedia/onevpl/onevpl/0001-Fix-the-rendering-to-X11-failures.patch new file mode 100644 index 00000000..9335c214 --- /dev/null +++ b/recipes-multimedia/onevpl/onevpl/0001-Fix-the-rendering-to-X11-failures.patch | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | From 775669dbdd97a52dc32dab82c3d5efd160f9e807 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: "Chew, Tong Liang" <tong.liang.chew@intel.com> | ||
| 3 | Date: Mon, 9 Aug 2021 02:19:01 +0000 | ||
| 4 | Subject: [PATCH] Fix the rendering to X11 failures | ||
| 5 | |||
| 6 | The i915 render device node is not always in renderD128. | ||
| 7 | Change the hard coded with autodetect the i915 device via ioctl | ||
| 8 | |||
| 9 | Upstream-Status: Submitted | ||
| 10 | https://github.com/oneapi-src/oneVPL/pull/21 | ||
| 11 | |||
| 12 | Signed-off-by: Chew, Tong Liang <tong.liang.chew@intel.com> | ||
| 13 | Signed-off-by: Teng, Jin Chung <jin.chung.teng@intel.com> | ||
| 14 | --- | ||
| 15 | tools/legacy/sample_common/src/vaapi_device.cpp | 24 +++++++++++++- | ||
| 16 | tools/legacy/sample_common/src/vaapi_utils_x11.cpp | 38 +++++++++++++++++++--- | ||
| 17 | 2 files changed, 57 insertions(+), 5 deletions(-) | ||
| 18 | |||
| 19 | diff --git a/tools/legacy/sample_common/src/vaapi_device.cpp b/tools/legacy/sample_common/src/vaapi_device.cpp | ||
| 20 | index b034376..f78c5aa 100644 | ||
| 21 | --- a/tools/legacy/sample_common/src/vaapi_device.cpp | ||
| 22 | +++ b/tools/legacy/sample_common/src/vaapi_device.cpp | ||
| 23 | @@ -20,6 +20,7 @@ | ||
| 24 | #include "vaapi_allocator.h" | ||
| 25 | #if defined(X11_DRI3_SUPPORT) | ||
| 26 | #include <fcntl.h> | ||
| 27 | + #include <sys/ioctl.h> | ||
| 28 | |||
| 29 | #define ALIGN(x, y) (((x) + (y)-1) & -(y)) | ||
| 30 | #define PAGE_ALIGN(x) ALIGN(x, 4096) | ||
| 31 | @@ -27,6 +28,11 @@ | ||
| 32 | |||
| 33 | #define VAAPI_GET_X_DISPLAY(_display) (Display*)(_display) | ||
| 34 | #define VAAPI_GET_X_WINDOW(_window) (Window*)(_window) | ||
| 35 | + const char* MFX_DEVICE_NODE_RENDER = "/dev/dri/renderD"; | ||
| 36 | + const char* MFX_DEVICE_DRIVER_NAME = "i915"; | ||
| 37 | + constexpr mfxU32 MFX_DEVICE_DRIVER_NAME_LEN = 4; | ||
| 38 | + constexpr mfxU32 MFX_DEVICE_NODE_INDEX = 128; | ||
| 39 | + constexpr mfxU32 MFX_DEVICE_MAX_NODES = 16; | ||
| 40 | |||
| 41 | CVAAPIDeviceX11::~CVAAPIDeviceX11(void) { | ||
| 42 | Close(); | ||
| 43 | @@ -73,7 +79,23 @@ mfxStatus CVAAPIDeviceX11::Init(mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNu | ||
| 44 | |||
| 45 | // it's enough to pass render node, because we only request | ||
| 46 | // information from kernel via m_dri_fd | ||
| 47 | - m_dri_fd = open("/dev/dri/renderD128", O_RDWR); | ||
| 48 | + for (mfxU32 i = 0; i < MFX_DEVICE_MAX_NODES; ++i) { | ||
| 49 | + std::string devPath = MFX_DEVICE_NODE_RENDER + std::to_string(MFX_DEVICE_NODE_INDEX + i); | ||
| 50 | + m_dri_fd = open(devPath.c_str(), O_RDWR); | ||
| 51 | + if (m_dri_fd < 0) continue; | ||
| 52 | + | ||
| 53 | + char driverName[MFX_DEVICE_DRIVER_NAME_LEN + 1] = {}; | ||
| 54 | + drm_version_t version = {}; | ||
| 55 | + version.name_len = MFX_DEVICE_DRIVER_NAME_LEN; | ||
| 56 | + version.name = driverName; | ||
| 57 | + | ||
| 58 | + if(!ioctl(m_dri_fd, DRM_IOWR(0, drm_version), &version) && | ||
| 59 | + !strcmp(driverName, MFX_DEVICE_DRIVER_NAME)) { | ||
| 60 | + break; | ||
| 61 | + } | ||
| 62 | + close(m_dri_fd); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | if (m_dri_fd < 0) { | ||
| 66 | msdk_printf(MSDK_STRING("Failed to open dri device\n")); | ||
| 67 | return MFX_ERR_NOT_INITIALIZED; | ||
| 68 | diff --git a/tools/legacy/sample_common/src/vaapi_utils_x11.cpp b/tools/legacy/sample_common/src/vaapi_utils_x11.cpp | ||
| 69 | index 9770a2f..734cd10 100644 | ||
| 70 | --- a/tools/legacy/sample_common/src/vaapi_utils_x11.cpp | ||
| 71 | +++ b/tools/legacy/sample_common/src/vaapi_utils_x11.cpp | ||
| 72 | @@ -10,18 +10,24 @@ | ||
| 73 | #include "sample_defs.h" | ||
| 74 | |||
| 75 | #include <dlfcn.h> | ||
| 76 | - #if defined(X11_DRI3_SUPPORT) | ||
| 77 | - #include <fcntl.h> | ||
| 78 | - #endif | ||
| 79 | + #include <fcntl.h> | ||
| 80 | + #include <sys/ioctl.h> | ||
| 81 | |||
| 82 | #define VAAPI_X_DEFAULT_DISPLAY ":0.0" | ||
| 83 | |||
| 84 | + const char* MFX_X11_NODE_RENDER = "/dev/dri/renderD"; | ||
| 85 | + const char* MFX_X11_DRIVER_NAME = "i915"; | ||
| 86 | + constexpr mfxU32 MFX_X11_DRIVER_NAME_LEN = 4; | ||
| 87 | + constexpr mfxU32 MFX_X11_NODE_INDEX = 128; | ||
| 88 | + constexpr mfxU32 MFX_X11_MAX_NODES = 16; | ||
| 89 | + | ||
| 90 | X11LibVA::X11LibVA(void) | ||
| 91 | : CLibVA(MFX_LIBVA_X11), | ||
| 92 | m_display(0), | ||
| 93 | m_configID(VA_INVALID_ID), | ||
| 94 | m_contextID(VA_INVALID_ID) { | ||
| 95 | char* currentDisplay = getenv("DISPLAY"); | ||
| 96 | + int fd = -1; | ||
| 97 | |||
| 98 | m_display = (currentDisplay) ? m_x11lib.XOpenDisplay(currentDisplay) | ||
| 99 | : m_x11lib.XOpenDisplay(VAAPI_X_DEFAULT_DISPLAY); | ||
| 100 | @@ -32,7 +38,31 @@ X11LibVA::X11LibVA(void) | ||
| 101 | throw std::bad_alloc(); | ||
| 102 | } | ||
| 103 | |||
| 104 | - m_va_dpy = m_vax11lib.vaGetDisplay(m_display); | ||
| 105 | + for (mfxU32 i = 0; i < MFX_X11_MAX_NODES; ++i) { | ||
| 106 | + std::string devPath = MFX_X11_NODE_RENDER + std::to_string(MFX_X11_NODE_INDEX + i); | ||
| 107 | + fd = -1; | ||
| 108 | + fd = open(devPath.c_str(), O_RDWR); | ||
| 109 | + if (fd < 0) continue; | ||
| 110 | + | ||
| 111 | + char driverName[MFX_X11_DRIVER_NAME_LEN + 1] = {}; | ||
| 112 | + drm_version_t version = {}; | ||
| 113 | + version.name_len = MFX_X11_DRIVER_NAME_LEN; | ||
| 114 | + version.name = driverName; | ||
| 115 | + | ||
| 116 | + if(!ioctl(fd, DRM_IOWR(0, drm_version), &version) && | ||
| 117 | + !strcmp(driverName, MFX_X11_DRIVER_NAME)) { | ||
| 118 | + break; | ||
| 119 | + } | ||
| 120 | + close(fd); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + if (fd < 0) { | ||
| 124 | + m_x11lib.XCloseDisplay(m_display); | ||
| 125 | + msdk_printf(MSDK_STRING("Failed to open adapter\n")); | ||
| 126 | + throw std::bad_alloc(); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + m_va_dpy = m_vadrmlib.vaGetDisplayDRM(fd); | ||
| 130 | if (!m_va_dpy) { | ||
| 131 | m_x11lib.XCloseDisplay(m_display); | ||
| 132 | msdk_printf(MSDK_STRING("Failed to get VA Display\n")); | ||
| 133 | -- | ||
| 134 | 2.7.4 | ||
| 135 | |||
diff --git a/recipes-multimedia/onevpl/onevpl_2021.4.0.bb b/recipes-multimedia/onevpl/onevpl_2021.4.0.bb index cdd22a34..5982c18a 100644 --- a/recipes-multimedia/onevpl/onevpl_2021.4.0.bb +++ b/recipes-multimedia/onevpl/onevpl_2021.4.0.bb | |||
| @@ -13,6 +13,7 @@ SRC_URI = "git://github.com/oneapi-src/oneVPL.git;protocol=https \ | |||
| 13 | file://0001-Corrected-the-install-path.patch \ | 13 | file://0001-Corrected-the-install-path.patch \ |
| 14 | file://0001-Adding-X11-DRI3-support.patch \ | 14 | file://0001-Adding-X11-DRI3-support.patch \ |
| 15 | file://0001-Fix-sample_multi_transcode-join-issue.patch \ | 15 | file://0001-Fix-sample_multi_transcode-join-issue.patch \ |
| 16 | file://0001-Fix-the-rendering-to-X11-failures.patch \ | ||
| 16 | " | 17 | " |
| 17 | SRCREV = "d5c072584ee6f81305ed85de8759658ab7854606" | 18 | SRCREV = "d5c072584ee6f81305ed85de8759658ab7854606" |
| 18 | S = "${WORKDIR}/git" | 19 | S = "${WORKDIR}/git" |
