return 0;
}
-unsigned DrmComposition::GetRemainingLayers(int display,
+unsigned DrmComposition::GetRemainingLayers(int /*display*/,
unsigned num_needed) const {
- DrmCrtc *crtc = drm_->GetCrtcForDisplay(display);
- if (!crtc) {
- ALOGE("Failed to find crtc for display %d", display);
- return 0;
- }
-
- unsigned num_planes = 0;
- for (std::vector<DrmPlane *>::const_iterator iter = primary_planes_.begin();
- iter != primary_planes_.end(); ++iter) {
- if ((*iter)->GetCrtcSupported(*crtc))
- ++num_planes;
- }
- for (std::deque<DrmPlane *>::const_iterator iter = overlay_planes_.begin();
- iter != overlay_planes_.end(); ++iter) {
- if ((*iter)->GetCrtcSupported(*crtc))
- ++num_planes;
- }
- return std::min(num_planes, num_needed);
+ return num_needed;
}
int DrmComposition::AddLayer(int display, hwc_layer_1_t *layer,
break;
}
}
- for (std::deque<DrmPlane *>::iterator iter = overlay_planes_.begin();
+ for (std::vector<DrmPlane *>::iterator iter = overlay_planes_.begin();
!plane && iter != overlay_planes_.end(); ++iter) {
if ((*iter)->GetCrtcSupported(*crtc)) {
plane = *iter;
break;
}
}
- if (!plane) {
- ALOGE("Failed to find plane for display %d", display);
- return -ENOENT;
- }
return composition_map_[display]->AddLayer(layer, bo, crtc, plane);
}
+int DrmComposition::AddDpmsMode(int display, uint32_t dpms_mode) {
+ return composition_map_[display]->AddDpmsMode(dpms_mode);
+}
+
std::unique_ptr<DrmDisplayComposition> DrmComposition::TakeDisplayComposition(
int display) {
return std::move(composition_map_[display]);
}
+
+int DrmComposition::DisableUnusedPlanes() {
+ for (DrmResources::ConnectorIter iter = drm_->begin_connectors();
+ iter != drm_->end_connectors(); ++iter) {
+ int display = (*iter)->display();
+ DrmDisplayComposition *comp = GetDisplayComposition(display);
+
+ /*
+ * Leave empty compositions alone
+ * TODO: re-visit this and potentially disable leftover planes after the
+ * active compositions have gobbled up all they can
+ */
+ if (comp->type() == DRM_COMPOSITION_TYPE_EMPTY)
+ continue;
+
+ DrmCrtc *crtc = drm_->GetCrtcForDisplay(display);
+ if (!crtc) {
+ ALOGE("Failed to find crtc for display %d", display);
+ continue;
+ }
+
+ for (std::vector<DrmPlane *>::iterator iter = primary_planes_.begin();
+ iter != primary_planes_.end(); ++iter) {
+ if ((*iter)->GetCrtcSupported(*crtc)) {
+ comp->AddPlaneDisable(*iter);
+ primary_planes_.erase(iter);
+ break;
+ }
+ }
+ for (std::vector<DrmPlane *>::iterator iter = overlay_planes_.begin();
+ iter != overlay_planes_.end();) {
+ if ((*iter)->GetCrtcSupported(*crtc)) {
+ comp->AddPlaneDisable(*iter);
+ iter = overlay_planes_.erase(iter);
+ } else {
+ iter++;
+ }
+ }
+ }
+ return 0;
+}
+
+DrmDisplayComposition *DrmComposition::GetDisplayComposition(int display) {
+ return composition_map_[display].get();
+}
}