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 #include @@ -39,13 +38,6 @@ #include #include -#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");