summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/vpl/files/0007-Fix-X11-rendering-for-xe.patch
blob: d6c5cea2d791736c35f5d84ae0163ea7bc21be97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
From fecf6b6cdb02c7dba3b838ee710363b57fe8e6e7 Mon Sep 17 00:00:00 2001
From: "Hoe, Sheng Yang" <sheng.yang.hoe@intel.com>
Date: Fri, 26 Jul 2024 23:35:25 +0800
Subject: [PATCH 7/9] Fix X11 rendering for xe

Upstream-Status: Backport [https://github.com/intel/libvpl-tools/commit/2d751730617682133bf066e61e1ca952136309bd]

Signed-off-by: Hoe, Sheng Yang <sheng.yang.hoe@intel.com>
---
 .../sample_common/include/vaapi_device.h      |  6 ---
 .../sample_common/include/vaapi_utils_x11.h   |  4 --
 .../legacy/sample_common/src/vaapi_device.cpp | 50 ++-----------------
 .../sample_common/src/vaapi_utils_x11.cpp     |  4 +-
 4 files changed, 7 insertions(+), 57 deletions(-)

diff --git a/tools/legacy/sample_common/include/vaapi_device.h b/tools/legacy/sample_common/include/vaapi_device.h
index 5752a28..dc71659 100644
--- a/tools/legacy/sample_common/include/vaapi_device.h
+++ b/tools/legacy/sample_common/include/vaapi_device.h
@@ -75,10 +75,7 @@ public:
         m_nRenderWinH = 0;
         m_bRenderWin  = false;
         #if defined(X11_DRI3_SUPPORT)
-        m_dri_fd      = 0;
-        m_bufmgr      = NULL;
         m_xcbconn     = NULL;
-        m_device_path = devicePath;
         #endif
     }
     virtual ~CVAAPIDeviceX11(void);
@@ -106,10 +103,7 @@ private:
     mfxU32 m_nRenderWinW;
     mfxU32 m_nRenderWinH;
         #if defined(X11_DRI3_SUPPORT)
-    int m_dri_fd;
-    drm_intel_bufmgr* m_bufmgr;
     xcb_connection_t* m_xcbconn;
-    std::string m_device_path;
         #endif
     // no copies allowed
     CVAAPIDeviceX11(const CVAAPIDeviceX11&);
diff --git a/tools/legacy/sample_common/include/vaapi_utils_x11.h b/tools/legacy/sample_common/include/vaapi_utils_x11.h
index acdd78e..840c29d 100644
--- a/tools/legacy/sample_common/include/vaapi_utils_x11.h
+++ b/tools/legacy/sample_common/include/vaapi_utils_x11.h
@@ -40,9 +40,6 @@ public:
     MfxLoader::Xcbpresent_Proxy& GetXcbpresentX11() {
         return m_xcbpresentlib;
     }
-    MfxLoader::DrmIntel_Proxy& GetDrmIntelX11() {
-        return m_drmintellib;
-    }
     #endif // X11_DRI3_SUPPORT
 
 protected:
@@ -57,7 +54,6 @@ protected:
     MfxLoader::X11_Xcb_Proxy m_x11xcblib;
     MfxLoader::XCB_Dri3_Proxy m_xcbdri3lib;
     MfxLoader::Xcbpresent_Proxy m_xcbpresentlib;
-    MfxLoader::DrmIntel_Proxy m_drmintellib;
     #endif // X11_DRI3_SUPPORT
     int fd;
 
diff --git a/tools/legacy/sample_common/src/vaapi_device.cpp b/tools/legacy/sample_common/src/vaapi_device.cpp
index c44e67e..9bf3433 100644
--- a/tools/legacy/sample_common/src/vaapi_device.cpp
+++ b/tools/legacy/sample_common/src/vaapi_device.cpp
@@ -72,39 +72,9 @@ mfxStatus CVAAPIDeviceX11::Init(mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNu
         }
     }
         #if defined(X11_DRI3_SUPPORT)
-    MfxLoader::DrmIntel_Proxy& drmintellib = m_X11LibVA.GetDrmIntelX11();
     MfxLoader::X11_Xcb_Proxy& x11xcblib    = m_X11LibVA.GetX11XcbX11();
 
     m_xcbconn = x11xcblib.XGetXCBConnection(VAAPI_GET_X_DISPLAY(m_X11LibVA.GetXDisplay()));
-
-    if (m_device_path.empty()) {
-        // it's enough to pass render node, because we only request
-        // information from kernel via m_dri_fd
-        for (mfxU32 i = 0; i < MFX_DEVICE_MAX_NODES; ++i) {
-            std::string devPath =
-                MFX_DEVICE_NODE_RENDER + std::to_string(MFX_DEVICE_NODE_INDEX + i);
-            m_dri_fd = open_intel_adapter(devPath);
-            if (m_dri_fd < 0)
-                continue;
-            else
-                break;
-        }
-    }
-    else {
-        m_dri_fd = open_intel_adapter(m_device_path);
-    }
-
-    if (m_dri_fd < 0) {
-        printf("Failed to open dri device\n");
-        return MFX_ERR_NOT_INITIALIZED;
-    }
-
-    m_bufmgr = drmintellib.drm_intel_bufmgr_gem_init(m_dri_fd, 4096);
-    if (!m_bufmgr) {
-        printf("Failed to get buffer manager\n");
-        return MFX_ERR_NOT_INITIALIZED;
-    }
-
         #endif
 
     return mfx_res;
@@ -121,11 +91,6 @@ void CVAAPIDeviceX11::Close(void) {
         free(m_window);
         m_window = NULL;
     }
-        #if defined(X11_DRI3_SUPPORT)
-    if (m_dri_fd) {
-        close(m_dri_fd);
-    }
-        #endif
 }
 
 mfxStatus CVAAPIDeviceX11::Reset(void) {
@@ -208,13 +173,11 @@ mfxStatus CVAAPIDeviceX11::RenderFrame(mfxFrameSurface1* pSurface,
         #else //\/ X11_DRI3_SUPPORT
     Window* window = VAAPI_GET_X_WINDOW(m_window);
     Window root;
-    drm_intel_bo* bo = NULL;
     unsigned int border, depth, stride, size, width, height;
     int fd = 0, bpp = 0, x, y;
 
     MfxLoader::Xcb_Proxy& xcblib               = m_X11LibVA.GetXcbX11();
     MfxLoader::XLib_Proxy& x11lib              = m_X11LibVA.GetX11();
-    MfxLoader::DrmIntel_Proxy& drmintellib     = m_X11LibVA.GetDrmIntelX11();
     MfxLoader::Xcbpresent_Proxy& xcbpresentlib = m_X11LibVA.GetXcbpresentX11();
     MfxLoader::XCB_Dri3_Proxy& dri3lib         = m_X11LibVA.GetXCBDri3X11();
 
@@ -271,15 +234,7 @@ mfxStatus CVAAPIDeviceX11::RenderFrame(mfxFrameSurface1* pSurface,
         stride = memId->m_image.pitches[0];
         size   = PAGE_ALIGN(stride * height);
 
-        bo = drmintellib.drm_intel_bo_gem_create_from_prime(m_bufmgr,
-                                                            memId->m_buffer_info.handle,
-                                                            size);
-        if (!bo) {
-            printf("Failed to create buffer object\n");
-            return MFX_ERR_INVALID_VIDEO_PARAM;
-        }
-
-        drmintellib.drm_intel_bo_gem_export_to_prime(bo, &fd);
+        fd = dup(memId->m_buffer_info.handle);
         if (!fd) {
             printf("Invalid fd\n");
             return MFX_ERR_NOT_INITIALIZED;
@@ -332,6 +287,9 @@ mfxStatus CVAAPIDeviceX11::RenderFrame(mfxFrameSurface1* pSurface,
 
         xcblib.xcb_free_pixmap(m_xcbconn, pixmap);
         xcblib.xcb_flush(m_xcbconn);
+
+        if (fd)
+            close(fd);
     }
 
     return mfx_res;
diff --git a/tools/legacy/sample_common/src/vaapi_utils_x11.cpp b/tools/legacy/sample_common/src/vaapi_utils_x11.cpp
index ec44752..1e76615 100644
--- a/tools/legacy/sample_common/src/vaapi_utils_x11.cpp
+++ b/tools/legacy/sample_common/src/vaapi_utils_x11.cpp
@@ -19,6 +19,7 @@
 
 const char* MFX_X11_NODE_RENDER          = "/dev/dri/renderD";
 const char* MFX_X11_DRIVER_NAME          = "i915";
+const char* MFX_X11_DRIVER_XE_NAME       = "xe";
 constexpr mfxU32 MFX_X11_DRIVER_NAME_LEN = 4;
 constexpr mfxU32 MFX_X11_NODE_INDEX      = 128;
 constexpr mfxU32 MFX_X11_MAX_NODES       = 16;
@@ -38,7 +39,8 @@ int open_intel_adapter(const std::string& devicePath) {
     version.name                                 = driverName;
 
     if (!ioctl(fd, DRM_IOWR(0, drm_version), &version) &&
-        msdk_match(driverName, MFX_X11_DRIVER_NAME)) {
+        (msdk_match(driverName, MFX_X11_DRIVER_NAME) ||
+         msdk_match(driverName, MFX_X11_DRIVER_XE_NAME))) {
         return fd;
     }
 
-- 
2.43.2