Commit 312c49a4 authored by Mark Yacoub's avatar Mark Yacoub Committed by Commit Bot

Make Hardware Display Controller enable state dependent on its CRTCs.

1. Change is_disabled variables in CRTC Controller and Hardware Display
Controller to positive connotation(is_enabled).
2. HDC doesn't have its own enable state now; instead, it checks the states of
all CRTC controllers it manages.

BUG=b/172069469
TEST=ozone_unittests, modesetting and disabling an external  monitor

Change-Id: I0f613616ef4dd219298432904c4acabf5f5335ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510690
Commit-Queue: Mark Yacoub <markyacoub@google.com>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823165}
parent bc8e1c1f
......@@ -27,7 +27,7 @@ CrtcController::CrtcController(const scoped_refptr<DrmDevice>& drm,
state_(drm->plane_manager()->GetCrtcStateForCrtcId(crtc)) {}
CrtcController::~CrtcController() {
if (!is_disabled()) {
if (is_enabled()) {
const std::vector<std::unique_ptr<HardwareDisplayPlane>>& all_planes =
drm_->plane_manager()->planes();
for (const auto& plane : all_planes) {
......@@ -51,7 +51,7 @@ bool CrtcController::AssignOverlayPlanes(HardwareDisplayPlaneList* plane_list,
bool is_modesetting) {
// If we're in the process of modesetting, the CRTC is still disabled.
// Once the modeset is done, we expect it to be enabled.
DCHECK(is_modesetting || !is_disabled());
DCHECK(is_modesetting || is_enabled());
const DrmOverlayPlane* primary = DrmOverlayPlane::GetPrimaryPlane(overlays);
if (primary &&
......@@ -76,7 +76,7 @@ std::vector<uint64_t> CrtcController::GetFormatModifiers(uint32_t format) {
}
void CrtcController::SetCursor(uint32_t handle, const gfx::Size& size) {
if (is_disabled())
if (!is_enabled())
return;
if (!drm_->SetCursor(crtc_, handle, size)) {
PLOG(ERROR) << "drmModeSetCursor: device " << drm_->device_path().value()
......@@ -86,7 +86,7 @@ void CrtcController::SetCursor(uint32_t handle, const gfx::Size& size) {
}
void CrtcController::MoveCursor(const gfx::Point& location) {
if (is_disabled())
if (!is_enabled())
return;
drm_->MoveCursor(crtc_, location);
}
......
......@@ -38,7 +38,7 @@ class CrtcController {
uint32_t crtc() const { return crtc_; }
uint32_t connector() const { return connector_; }
const scoped_refptr<DrmDevice>& drm() const { return drm_; }
bool is_disabled() const { return !state_.properties.active.value; }
bool is_enabled() const { return state_.properties.active.value; }
bool AssignOverlayPlanes(HardwareDisplayPlaneList* plane_list,
const DrmOverlayPlaneList& planes,
......
......@@ -88,7 +88,7 @@ class DrmOverlayValidatorTest : public testing::Test {
bool status = drm_->plane_manager()->Commit(std::move(commit_request),
DRM_MODE_ATOMIC_ALLOW_MODESET);
controller->UpdateState(
/*enabled=*/true,
/*enable_requested=*/true,
ui::DrmOverlayPlane::GetPrimaryPlane(request_for_update[0].overlays()));
return status;
......
......@@ -66,7 +66,7 @@ void DrawCursor(DrmDumbBuffer* cursor, const SkBitmap& image) {
HardwareDisplayController::HardwareDisplayController(
std::unique_ptr<CrtcController> controller,
const gfx::Point& origin)
: origin_(origin), is_disabled_(controller->is_disabled()) {
: origin_(origin) {
AddCrtc(std::move(controller));
AllocateCursorBuffers();
}
......@@ -124,14 +124,10 @@ void HardwareDisplayController::GetDisableProps(CommitRequest* commit_request) {
}
void HardwareDisplayController::UpdateState(
bool is_enabled,
bool enable_requested,
const DrmOverlayPlane* primary_plane) {
// TODO(markyacoub): Update how we report the controller state. Right now, the
// controller state is independent of its CRTCs; however, it should reflect
// its CRTCs active states.
is_disabled_ = !is_enabled;
if (is_enabled) {
// Verify that the current state matches the requested state.
if (enable_requested && IsEnabled()) {
DCHECK(primary_plane);
// TODO(markyacoub): This should be absorbed in the commit request.
ResetCursor();
......@@ -182,7 +178,7 @@ bool HardwareDisplayController::ScheduleOrTestPageFlip(
scoped_refptr<PageFlipRequest> page_flip_request,
std::unique_ptr<gfx::GpuFence>* out_fence) {
TRACE_EVENT0("drm", "HDC::SchedulePageFlip");
DCHECK(!is_disabled_);
DCHECK(IsEnabled());
// Ignore requests with no planes to schedule.
if (plane_list.empty())
......@@ -331,8 +327,13 @@ bool HardwareDisplayController::IsMirrored() const {
return crtc_controllers_.size() > 1;
}
bool HardwareDisplayController::IsDisabled() const {
return is_disabled_;
bool HardwareDisplayController::IsEnabled() const {
bool is_enabled = true;
for (const auto& controller : crtc_controllers_)
is_enabled &= controller->is_enabled();
return is_enabled;
}
gfx::Size HardwareDisplayController::GetModeSize() const {
......
......@@ -104,7 +104,7 @@ class HardwareDisplayController {
void GetDisableProps(CommitRequest* commit_request);
// Updates state of the controller after modeset/enable/disable is performed.
void UpdateState(bool is_enabled, const DrmOverlayPlane* primary_plane);
void UpdateState(bool enable_requested, const DrmOverlayPlane* primary_plane);
// Schedules the |overlays|' framebuffers to be displayed on the next vsync
// event. The event will be posted on the graphics card file descriptor |fd_|
......@@ -152,7 +152,7 @@ class HardwareDisplayController {
uint32_t crtc);
bool HasCrtc(const scoped_refptr<DrmDevice>& drm, uint32_t crtc) const;
bool IsMirrored() const;
bool IsDisabled() const;
bool IsEnabled() const;
gfx::Size GetModeSize() const;
gfx::Point origin() const { return origin_; }
......@@ -207,8 +207,6 @@ class HardwareDisplayController {
int cursor_frontbuffer_ = 0;
DrmDumbBuffer* current_cursor_ = nullptr;
bool is_disabled_;
base::WeakPtrFactory<HardwareDisplayController> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(HardwareDisplayController);
......
......@@ -250,7 +250,7 @@ bool HardwareDisplayControllerTest::ModesetWithPlane(
bool status = drm_->plane_manager()->Commit(std::move(commit_request),
DRM_MODE_ATOMIC_ALLOW_MODESET);
controller_->UpdateState(
/*enabled=*/true,
/*enable_requested=*/true,
ui::DrmOverlayPlane::GetPrimaryPlane(request_for_update[0].overlays()));
return status;
......@@ -262,7 +262,7 @@ bool HardwareDisplayControllerTest::DisableController() {
ui::CommitRequest request_for_update = commit_request;
bool status = drm_->plane_manager()->Commit(std::move(commit_request),
DRM_MODE_ATOMIC_ALLOW_MODESET);
controller_->UpdateState(/*enabled=*/false, nullptr);
controller_->UpdateState(/*enable_requested=*/false, nullptr);
return status;
}
......
......@@ -315,7 +315,7 @@ void ScreenManager::SetDisplayControllerForEnableAndGetProps(
// comparison on the mode since the refresh rate may have changed.
if (SameMode(mode, crtc_controller->mode()) &&
origin == controller->origin()) {
if (controller->IsDisabled()) {
if (!controller->IsEnabled()) {
// Even if there is a mirrored display, Modeset the CRTC with its mode in
// the original controller so that only this CRTC is affected by the mode.
// Otherwise it could apply a mode with the same resolution and refresh
......@@ -449,7 +449,7 @@ ScreenManager::HardwareDisplayControllers::iterator
ScreenManager::FindActiveDisplayControllerByLocation(const gfx::Rect& bounds) {
for (auto it = controllers_.begin(); it != controllers_.end(); ++it) {
gfx::Rect controller_bounds((*it)->origin(), (*it)->GetModeSize());
if (controller_bounds == bounds && !(*it)->IsDisabled())
if (controller_bounds == bounds && (*it)->IsEnabled())
return it;
}
......@@ -463,7 +463,7 @@ ScreenManager::FindActiveDisplayControllerByLocation(
for (auto it = controllers_.begin(); it != controllers_.end(); ++it) {
gfx::Rect controller_bounds((*it)->origin(), (*it)->GetModeSize());
if ((*it)->GetDrmDevice() == drm && controller_bounds == bounds &&
!(*it)->IsDisabled())
(*it)->IsEnabled())
return it;
}
......@@ -475,7 +475,7 @@ void ScreenManager::UpdateControllerToWindowMapping() {
// First create a unique mapping between a window and a controller. Note, a
// controller may be associated with at most 1 window.
for (const auto& controller : controllers_) {
if (controller->IsDisabled())
if (!controller->IsEnabled())
continue;
DrmWindow* window = FindWindowAt(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment