Handle monitors in different GPU's
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "sunshine/main.h"
|
||||
#include "sunshine/platform/common.h"
|
||||
#include "sunshine/round_robin.h"
|
||||
@@ -14,6 +16,7 @@
|
||||
#include "vaapi.h"
|
||||
|
||||
using namespace std::literals;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace platf {
|
||||
|
||||
@@ -235,14 +238,23 @@ public:
|
||||
int init(const std::string &display_name, int framerate) {
|
||||
delay = std::chrono::nanoseconds { 1s } / framerate;
|
||||
|
||||
constexpr auto path = "/dev/dri/card1";
|
||||
if(card.init(path)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int monitor_index = util::from_view(display_name);
|
||||
int monitor = 0;
|
||||
|
||||
fs::path card_dir { "/dev/dri"sv };
|
||||
for(auto &entry : fs::directory_iterator { card_dir }) {
|
||||
auto file = entry.path().filename();
|
||||
|
||||
auto filestring = file.generic_u8string();
|
||||
if(std::string_view { filestring }.substr(0, 4) != "card"sv) {
|
||||
continue;
|
||||
}
|
||||
|
||||
kms::card_t card;
|
||||
if(card.init(entry.path().c_str())) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto end = std::end(card);
|
||||
for(auto plane = std::begin(card); plane != end; ++plane) {
|
||||
if(monitor != monitor_index) {
|
||||
@@ -287,9 +299,13 @@ public:
|
||||
offset_x = crct->x;
|
||||
offset_y = crct->y;
|
||||
|
||||
break;
|
||||
this->card = std::move(card);
|
||||
goto break_loop;
|
||||
}
|
||||
}
|
||||
|
||||
// Neatly break from nested for loop
|
||||
break_loop:
|
||||
if(monitor != monitor_index) {
|
||||
BOOST_LOG(error) << "Couldn't find monitor ["sv << monitor_index << ']';
|
||||
|
||||
@@ -525,6 +541,11 @@ std::shared_ptr<display_t> kms_display(mem_type_e hwdevice_type, const std::stri
|
||||
|
||||
// A list of names of displays accepted as display_name
|
||||
std::vector<std::string> kms_display_names() {
|
||||
kms::env_width = 0;
|
||||
kms::env_height = 0;
|
||||
|
||||
int count = 0;
|
||||
|
||||
if(!gbm::create_device) {
|
||||
BOOST_LOG(warning) << "libgbm not initialized"sv;
|
||||
return {};
|
||||
@@ -532,15 +553,19 @@ std::vector<std::string> kms_display_names() {
|
||||
|
||||
std::vector<std::string> display_names;
|
||||
|
||||
kms::card_t card;
|
||||
if(card.init("/dev/dri/card1")) {
|
||||
return {};
|
||||
fs::path card_dir { "/dev/dri"sv };
|
||||
for(auto &entry : fs::directory_iterator { card_dir }) {
|
||||
auto file = entry.path().filename();
|
||||
|
||||
auto filestring = file.generic_u8string();
|
||||
if(std::string_view { filestring }.substr(0, 4) != "card"sv) {
|
||||
continue;
|
||||
}
|
||||
|
||||
kms::env_width = 0;
|
||||
kms::env_height = 0;
|
||||
|
||||
int count = 0;
|
||||
kms::card_t card;
|
||||
if(card.init(entry.path().c_str())) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto end = std::end(card);
|
||||
for(auto plane = std::begin(card); plane != end; ++plane) {
|
||||
@@ -597,6 +622,7 @@ std::vector<std::string> kms_display_names() {
|
||||
|
||||
display_names.emplace_back(std::to_string(count++));
|
||||
}
|
||||
}
|
||||
|
||||
return display_names;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user