drm_hwcomposer: Parse and store possible_clones information
drmModeEncoder has a field called possible_clones. It's a bit mask
which tells if the encoder could be simultaneously connected, to the
same CRTC, with the encoders specified in the possible_clones mask.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
diff --git a/drmdevice.cpp b/drmdevice.cpp
index 7a54c9d..25273ac 100644
--- a/drmdevice.cpp
+++ b/drmdevice.cpp
@@ -96,6 +96,7 @@
crtcs_.emplace_back(std::move(crtc));
}
+ std::vector<int> possible_clones;
for (int i = 0; !ret && i < res->count_encoders; ++i) {
drmModeEncoderPtr e = drmModeGetEncoder(fd(), res->encoders[i]);
if (!e) {
@@ -116,12 +117,18 @@
std::unique_ptr<DrmEncoder> enc(
new DrmEncoder(e, current_crtc, possible_crtcs));
-
+ possible_clones.push_back(e->possible_clones);
drmModeFreeEncoder(e);
encoders_.emplace_back(std::move(enc));
}
+ for (unsigned int i = 0; i < encoders_.size(); i++) {
+ for (unsigned int j = 0; j < encoders_.size(); j++)
+ if (possible_clones[i] & (1 << j))
+ encoders_[i]->AddPossibleClone(encoders_[j].get());
+ }
+
for (int i = 0; !ret && i < res->count_connectors; ++i) {
drmModeConnectorPtr c = drmModeGetConnector(fd(), res->connectors[i]);
if (!c) {
diff --git a/drmencoder.cpp b/drmencoder.cpp
index 6ae5d9a..277f9a4 100644
--- a/drmencoder.cpp
+++ b/drmencoder.cpp
@@ -39,6 +39,14 @@
return crtc_;
}
+bool DrmEncoder::CanClone(DrmEncoder *possible_clone) {
+ return possible_clones_.find(possible_clone) != possible_clones_.end();
+}
+
+void DrmEncoder::AddPossibleClone(DrmEncoder *possible_clone) {
+ possible_clones_.insert(possible_clone);
+}
+
void DrmEncoder::set_crtc(DrmCrtc *crtc) {
crtc_ = crtc;
display_ = crtc->display();
diff --git a/drmencoder.h b/drmencoder.h
index aeab5ac..c99c36e 100644
--- a/drmencoder.h
+++ b/drmencoder.h
@@ -19,6 +19,7 @@
#include "drmcrtc.h"
+#include <set>
#include <stdint.h>
#include <vector>
#include <xf86drmMode.h>
@@ -42,6 +43,8 @@
const std::vector<DrmCrtc *> &possible_crtcs() const {
return possible_crtcs_;
}
+ bool CanClone(DrmEncoder *encoder);
+ void AddPossibleClone(DrmEncoder *possible_clone);
private:
uint32_t id_;
@@ -49,6 +52,7 @@
int display_;
std::vector<DrmCrtc *> possible_crtcs_;
+ std::set<DrmEncoder *> possible_clones_;
};
}