Linux: Stop hardcoding dri device path (#1847)
Co-authored-by: Krzysztof Nairaner Machura <krzysztofmachura1@gmail.com>
This commit is contained in:
parent
43eb6ec6ac
commit
edb4239089
|
@ -7,6 +7,7 @@
|
|||
#include <xf86drmMode.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#define PICOJSON_USE_INT64
|
||||
#include "../server/cpp/alvr_server/include/picojson.h"
|
||||
|
@ -66,11 +67,16 @@ static void open_drm_fd()
|
|||
{
|
||||
static drmModeResPtr (*real_drmModeGetResources)(int fd) = nullptr;
|
||||
LOAD_FN(drmModeGetResources);
|
||||
|
||||
drm_fd = open("/dev/dri/card0", O_RDONLY);
|
||||
auto res = real_drmModeGetResources(drm_fd);
|
||||
if (res && res->count_connectors) {
|
||||
drm_connector_id = res->connectors[0];
|
||||
for(auto cardCandidate : std::filesystem::directory_iterator("/dev/dri")) {
|
||||
if(cardCandidate.path().filename().string().rfind("card", 0) == 0) {
|
||||
LOG("cardCandidateFound: file=%s", cardCandidate.path().c_str());
|
||||
drm_fd = open(cardCandidate.path().c_str(), O_RDONLY);
|
||||
auto res = real_drmModeGetResources(drm_fd);
|
||||
if (res && res->count_connectors) {
|
||||
drm_connector_id = res->connectors[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG("DRM: fd=%d, connector_id=%d", drm_fd, drm_connector_id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue