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/drmdevice.cpp b/drmdevice.cpp
index 138bb3d..7a54c9d 100644
--- a/drmdevice.cpp
+++ b/drmdevice.cpp
@@ -277,6 +277,7 @@
DrmCrtc *crtc = enc->crtc();
if (crtc && crtc->can_bind(display)) {
crtc->set_display(display);
+ enc->set_crtc(crtc);
return 0;
}
@@ -287,8 +288,8 @@
continue;
if (crtc->can_bind(display)) {
- enc->set_crtc(crtc);
crtc->set_display(display);
+ enc->set_crtc(crtc);
return 0;
}
}
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;
}
}
diff --git a/drmencoder.h b/drmencoder.h
index 58ccbfb..aeab5ac 100644
--- a/drmencoder.h
+++ b/drmencoder.h
@@ -36,6 +36,8 @@
DrmCrtc *crtc() const;
void set_crtc(DrmCrtc *crtc);
+ bool can_bind(int display) const;
+ int display() const;
const std::vector<DrmCrtc *> &possible_crtcs() const {
return possible_crtcs_;
@@ -44,6 +46,7 @@
private:
uint32_t id_;
DrmCrtc *crtc_;
+ int display_;
std::vector<DrmCrtc *> possible_crtcs_;
};