diff options
Diffstat (limited to 'libkms++')
-rw-r--r-- | libkms++/card.cpp | 31 | ||||
-rw-r--r-- | libkms++/card.h | 4 | ||||
-rw-r--r-- | libkms++/kms++.h | 1 | ||||
-rw-r--r-- | libkms++/pipeline.h | 11 |
4 files changed, 46 insertions, 1 deletions
diff --git a/libkms++/card.cpp b/libkms++/card.cpp index aebd9a1..3dea542 100644 --- a/libkms++/card.cpp +++ b/libkms++/card.cpp @@ -4,6 +4,7 @@ #include <utility> #include <stdexcept> #include <string.h> +#include <algorithm> #include <xf86drm.h> #include <xf86drmMode.h> @@ -197,4 +198,34 @@ Crtc* Card::get_crtc_by_index(uint32_t idx) const Crtc* Card::get_crtc(uint32_t id) const { return dynamic_cast<Crtc*>(get_object(id)); } Encoder* Card::get_encoder(uint32_t id) const { return dynamic_cast<Encoder*>(get_object(id)); } Property* Card::get_prop(uint32_t id) const { return dynamic_cast<Property*>(get_object(id)); } + +std::vector<kms::Pipeline> Card::get_connected_pipelines() +{ + vector<Pipeline> outputs; + + for (auto conn : get_connectors()) + { + if (conn->connected() == false) + continue; + + Crtc* crtc = conn->get_current_crtc(); + + if (!crtc) { + for (auto possible : conn->get_possible_crtcs()) { + if (find_if(outputs.begin(), outputs.end(), [possible](Pipeline out) { return out.crtc == possible; }) == outputs.end()) { + crtc = possible; + break; + } + } + } + + if (!crtc) + throw invalid_argument("fob"); + + outputs.push_back(Pipeline { crtc, conn }); + } + + return outputs; +} + } diff --git a/libkms++/card.h b/libkms++/card.h index fb45d04..fbfbe74 100644 --- a/libkms++/card.h +++ b/libkms++/card.h @@ -5,10 +5,10 @@ #include <map> #include "decls.h" +#include "pipeline.h" namespace kms { - class Card { public: @@ -38,6 +38,8 @@ public: std::vector<DrmObject*> get_objects() const; std::vector<Plane*> get_planes() const; + std::vector<Pipeline> get_connected_pipelines(); + private: std::map<uint32_t, DrmObject*> m_obmap; diff --git a/libkms++/kms++.h b/libkms++/kms++.h index f9808ed..7d6788d 100644 --- a/libkms++/kms++.h +++ b/libkms++/kms++.h @@ -8,3 +8,4 @@ #include "framebuffer.h" #include "plane.h" #include "property.h" +#include "pipeline.h" diff --git a/libkms++/pipeline.h b/libkms++/pipeline.h new file mode 100644 index 0000000..ef04ec1 --- /dev/null +++ b/libkms++/pipeline.h @@ -0,0 +1,11 @@ +#pragma once + +#include "decls.h" + +namespace kms +{ +struct Pipeline { + Crtc* crtc; + Connector* connector; +}; +} |