summaryrefslogtreecommitdiff
path: root/multimedia/cmrtlib/files/patch-static-render-node
blob: da70f7944448f2d515e8e427ef0f4faea8e03dd2 (plain) (blame)
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
Revert https://github.com/intel/media-driver/commit/6cafa0bf2aa1 due
to incomplete BSD support in bundled libdrm.

--- linux/hardware/cm_device.h.orig	2020-02-28 07:13:28 UTC
+++ linux/hardware/cm_device.h
@@ -33,7 +33,6 @@ class CmSurfaceManager;
 class CmDevice_RT : public CmDevice
 {
 public:
-    static int32_t GetSupportedRenderer(uint32_t &count);
     static int32_t Create( CmDevice_RT* &device, uint32_t createOption );
     static int32_t Destroy( CmDevice_RT* &device );
     static int32_t Create(VADisplay &vaDisplay, CmDevice_RT* &device,uint32_t createOption );
@@ -176,7 +175,7 @@ class CmDevice_RT : public CmDevice (protected)
     void    *m_deviceInUmd;    //CmDevice pointer in UMD
     bool    m_cmCreated;
 
-    int32_t Initialize(bool isCmCreated, uint32_t Index = 0);
+    int32_t Initialize(bool isCmCreated);
     int32_t FreeResources();
 #if USE_EXTENSION_CODE
     int32_t EnableGtpin( void );
@@ -190,9 +189,8 @@ class CmDevice_RT : public CmDevice (protected)
     int32_t GetLibvaDisplayDrm(VADisplay & vaDisplay);
 #endif
 
-    int32_t InitializeLibvaDisplay(uint32_t Index = 0);
+    int32_t InitializeLibvaDisplay(void);
     VADisplay m_vaDisplay;
-    uint32_t m_drmIndex;
     pvaCmExtSendReqMsg    m_fvaCmExtSendReqMsg;
 
 #if !defined(ANDROID)
--- linux/hardware/cm_device_os.cpp.orig	2020-02-28 07:13:28 UTC
+++ linux/hardware/cm_device_os.cpp
@@ -21,7 +21,6 @@
 */
 
 #include "cm_device.h"
-#include "drm_device.h"
 #include <dlfcn.h>
 #include <cstdio>
 
@@ -39,13 +38,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-#define INTEL_VENDOR_ID 0x8086
-
-// hold up to 32 GPU adapters
-drmDevicePtr g_AdapterList[32];
-int32_t g_AdapterCount = 0;
-int32_t g_supportedAdapterCount = 0;
-
 #ifndef ANDROID
 uint32_t CmDevice_RT::m_vaReferenceCount = 0;
 CSync CmDevice_RT::m_vaReferenceCountCriticalSection;
@@ -58,90 +50,27 @@ volatile static char cmrtCurrentVersion[] = "cmrt_curr
 "6.0.0.9010\0";
 CSync gDeviceCreationCriticalSection;
 
-
-int32_t CmDevice_RT::GetSupportedRenderer(uint32_t& count)
-{
-    INSERT_PROFILER_RECORD();
-    int32_t result = CM_SUCCESS;
-    uint32_t i = 0;
-    uint32_t k = 0;
-    char* driver_name;
-
-    if (g_AdapterCount == 0)
-    {
-        int max_dev = 256;
-        drmDevicePtr devices[max_dev];
-        int nodes = drmGetDevices(devices, max_dev);
-        int i = 0;
-        for (int k = 0; k < nodes; k++)
-        {
-            driver_name = strrchr(devices[k]->nodes[0], '/');
-            driver_name++;
-            int len = strlen(devices[k]->deviceinfo.pci->driverInfo);
-            if (len > 0)
-                devices[k]->deviceinfo.pci->driverInfo[len - 1] = ' ';
-
-            snprintf(devices[k]->deviceinfo.pci->driverInfo + len, (sizeof devices[k]->deviceinfo.pci->driverInfo) - len, "  %s", driver_name);
-            driver_name = strrchr(devices[k]->nodes[2], '/');
-            driver_name++;
-            len = strlen(devices[k]->deviceinfo.pci->driverInfo);
-            snprintf(devices[k]->deviceinfo.pci->driverInfo + len, (sizeof devices[k]->deviceinfo.pci->driverInfo) - len, "  %s", driver_name);
-            if (devices[k]->deviceinfo.pci->vendor_id == INTEL_VENDOR_ID)
-            {
-                g_AdapterList[i] = devices[k];
-                i++;
-            }
-        }
-        if (nodes == 0)
-            result = CM_NO_SUPPORTED_ADAPTER;
-
-        g_AdapterCount = k;
-        g_supportedAdapterCount = i;
-    }
-    count = g_supportedAdapterCount;
-    return result;
-}
-
-
 int32_t CmDevice_RT::Create(CmDevice_RT* &device, uint32_t createOption)
 {
     INSERT_PROFILER_RECORD();
 
     int32_t result = CM_SUCCESS;
-    uint32_t count = 0;
 
-    if (g_AdapterCount == 0 )
+    device = new CmDevice_RT(nullptr, createOption);
+    if( device )
     {
-        result = GetSupportedRenderer(count);
-    }
-
-    if (g_supportedAdapterCount > 0)
-    {
-        // start from first supported GPU
-        uint32_t Index = 0;
-        device = new CmDevice_RT(nullptr, createOption);
-
-        if (CM_DEVICE_CREATE_OPTION_DEFAULT != createOption)
-            // select last supported GPU
-            Index = g_supportedAdapterCount - 1;
-
-        if (device)
+        result = device->Initialize(true);
+        if(result != CM_SUCCESS)
         {
-            result = device->Initialize(true, Index);
-            if (result != CM_SUCCESS)
-            {
-                CmAssert(0);
-                Destroy(device);
-            }
-        }
-        else
-        {
             CmAssert(0);
-            result = CM_OUT_OF_HOST_MEMORY;
+            Destroy(device);
         }
     }
     else
-        result = CM_NO_SUPPORTED_ADAPTER;
+    {
+        CmAssert(0);
+        result = CM_OUT_OF_HOST_MEMORY;
+    }
 
     return result;
 }
@@ -209,7 +138,6 @@ CmDevice_RT::CmDevice_RT(
 #ifdef ANDROID
     m_display(nullptr),
 #endif
-    m_drmIndex(0),
     m_fvaCmExtSendReqMsg(nullptr),
     m_gtpinEnabled(false),
     m_gtpinBufferUP0(nullptr),
@@ -295,7 +223,7 @@ static int32_t CmrtVaSurfaceRelease(void *vaDisplay, v
     return vaStatus;
 }
 
-int32_t CmDevice_RT::Initialize(bool isCmCreated, uint32_t Index)
+int32_t CmDevice_RT::Initialize(bool isCmCreated)
 {
     int32_t result = CM_SUCCESS;
 
@@ -303,7 +231,7 @@ int32_t CmDevice_RT::Initialize(bool isCmCreated, uint
 
     CLock locker(gDeviceCreationCriticalSection);
 
-    CHK_RET(InitializeLibvaDisplay(Index));
+    CHK_RET(InitializeLibvaDisplay());
 
     CHK_RET(CreateDeviceInUmd());
 
@@ -427,14 +355,13 @@ int32_t CmDevice_RT::OSALExtensionExecute(uint32_t fun
     return hr;
 }
 
-//Initalize LibVA's VADisplay by supported dri device list index
-int32_t CmDevice_RT::InitializeLibvaDisplay(uint32_t Index)
+//Initalize LibVA's VADisplay
+int32_t CmDevice_RT::InitializeLibvaDisplay()
 {
     if (m_cmCreated)
     {
         VAStatus vaStatus = VA_STATUS_SUCCESS;
         int vaMajorVersion, vaMinorVersion;
-        m_drmIndex = Index;
 
 #ifndef ANDROID
         int32_t ret = GetLibvaDisplayDrm(m_vaDisplay);
@@ -528,22 +455,7 @@ int32_t CmDevice_RT::GetLibvaDisplayDrm(VADisplay & va
     }
 
     // open the GPU device
-    if (g_supportedAdapterCount < 1)
-    {
-        fprintf(stderr, "No supported Intel GPU device file node detected\n");
-        return CM_INVALID_LIBVA_INITIALIZE;
-    }
-
-    if (m_drmIndex < g_supportedAdapterCount)
-    {
-        m_driFileDescriptor = GetRendererFileDescriptor(g_AdapterList[m_drmIndex]->nodes[2]);
-    }
-    else
-    {
-        fprintf(stderr, "Invalid drm list index used\n");
-        return CM_INVALID_LIBVA_INITIALIZE;
-    }
-
+    m_driFileDescriptor = open("/dev/dri/renderD128", O_RDWR);
     if (m_driFileDescriptor < 0)
     {
         fprintf(stderr, "Failed to open GPU device file node\n");