Skip to content

Commit

Permalink
Linux環境で権限不足でデバイスをopenできなかった場合のメッセージを改善。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Feb 23, 2024
1 parent c16ec7a commit c92d2ee
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions QSVPipeline/qsv_hw_va_utils_drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ or https://software.intel.com/en-us/media-client-solutions-support.

#include "qsv_hw_va_utils_drm.h"
#include "qsv_allocator_va.h"
#include "rgy_filesystem.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
Expand Down Expand Up @@ -69,25 +68,27 @@ int open_target_intel_adapter(const int type, const int targetIntelAdaptorNum, R
throw std::invalid_argument("Wrong libVA backend type");
}

RGYLogLevel logLevelFound = RGY_LOG_DEBUG;
int intelAdaptorCount = 0;
for (mfxU32 i = 0; i < MFX_DRI_MAX_NODES_NUM; i++) {
std::string curAdapterPath = adapterPath + std::to_string(nodeIndex + i);
log->write(RGY_LOG_DEBUG, RGY_LOGT_DEV, _T("Adaptor #%d [%s]: try open.\n"), i, char_to_tstring(curAdapterPath).c_str());

const int fd = open(curAdapterPath.c_str(), O_RDWR);
if (fd < 0) {
if (!rgy_file_exists(curAdapterPath)) {
if (access(curAdapterPath.c_str(), F_OK)) {
log->write(RGY_LOG_DEBUG, RGY_LOGT_DEV, _T("Adaptor #%d [%s]: Does not exist.\n"), i, char_to_tstring(curAdapterPath).c_str());
} else {
log->write(RGY_LOG_DEBUG, RGY_LOGT_DEV, _T("Adaptor #%d [%s]: Failed to open.\n"), i, char_to_tstring(curAdapterPath).c_str());
log->write(RGY_LOG_ERROR, RGY_LOGT_DEV, _T("Adaptor #%d [%s]: Exists, but failed to open.\n"), i, char_to_tstring(curAdapterPath).c_str());
}
logLevelFound = RGY_LOG_INFO;
continue;
}

if (!get_drm_driver_name(fd, driverName, MFX_DRM_DRIVER_NAME_LEN)) {
log->write(RGY_LOG_DEBUG, RGY_LOGT_DEV, _T("Adaptor #%d [%s]: driver name %s\n"), i, char_to_tstring(curAdapterPath).c_str(), char_to_tstring(driverName).c_str());
if (!strcmp(driverName, MFX_DRM_INTEL_DRIVER_NAME)) {
log->write(RGY_LOG_DEBUG, RGY_LOGT_DEV, _T("Adaptor #%d [%s]: #%d Intel adaptor\n"), i, char_to_tstring(curAdapterPath).c_str(), intelAdaptorCount);
log->write(logLevelFound, RGY_LOGT_DEV, _T("Adaptor #%d [%s]: #%d Intel adaptor\n"), i, char_to_tstring(curAdapterPath).c_str(), intelAdaptorCount);
if (intelAdaptorCount == targetIntelAdaptorNum) {
return fd;
}
Expand Down

0 comments on commit c92d2ee

Please sign in to comment.