drm_hwcomposer: Add display field to Drmencoder
In the current implementation TryEncoderForDisplay just looks
at the crtc linked to the display, if that's not assigned to
a display it means the encoder could be used, otherwise iterate
to the list of possible_crtcs and find one which is not used.
This logic works fine when you have just one encoder connected to a
crtc but with two or more, like is the case when we attach a writeback
connector, we need to know if we already assigned the encoder to a
display.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
diff --git a/drmencoder.cpp b/drmencoder.cpp
index f61c8fd..6ae5d9a 100644
--- a/drmencoder.cpp
+++ b/drmencoder.cpp
@@ -27,6 +27,7 @@
const std::vector<DrmCrtc *> &possible_crtcs)
: id_(e->encoder_id),
crtc_(current_crtc),
+ display_(-1),
possible_crtcs_(possible_crtcs) {
}
@@ -40,5 +41,14 @@
void DrmEncoder::set_crtc(DrmCrtc *crtc) {
crtc_ = crtc;
+ display_ = crtc->display();
+}
+
+int DrmEncoder::display() const {
+ return display_;
+}
+
+bool DrmEncoder::can_bind(int display) const {
+ return display_ == -1 || display_ == display;
}
}