Commit 7e9145ee authored by Mark Yacoub's avatar Mark Yacoub Committed by Commit Bot

Ozone: Implement Atomic Disable Modeset

If the device supports atomic APIs, Disable the CRTC using Atomic
Modeset Commit instead of legacy API.

BUG=987274
TEST=HardwareDisplayControllerTest.CheckDisableResetsProps,
HardwareDisplayPlaneManagerAtomicTest.CheckPropsAfterDisable

Change-Id: I79350079c73aa4d852354244b0eca282a63ac632
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037712Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Mark Yacoub <markyacoub@google.com>
Cr-Commit-Position: refs/heads/master@{#738557}
parent 55bea927
......@@ -279,6 +279,40 @@ TEST_F(HardwareDisplayControllerTest, ModifiersWithConnectorType) {
internal_modifiers.end());
}
TEST_F(HardwareDisplayControllerTest, CheckDisableResetsProps) {
ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
ui::DrmOverlayPlane plane2(CreateBuffer(), nullptr);
std::vector<ui::DrmOverlayPlane> planes = {};
planes.push_back(plane2.Clone());
SchedulePageFlip(std::move(planes));
// Test props values after disabling.
controller_->Disable();
ui::DrmDevice::Property connector_prop_crtc_id;
ui::ScopedDrmObjectPropertyPtr connector_props =
drm_->GetObjectProperties(kConnectorIdBase, DRM_MODE_OBJECT_CONNECTOR);
ui::GetDrmPropertyForName(drm_.get(), connector_props.get(), "CRTC_ID",
&connector_prop_crtc_id);
EXPECT_EQ(0U, connector_prop_crtc_id.value);
ui::DrmDevice::Property crtc_prop_for_name;
ui::ScopedDrmObjectPropertyPtr crtc_props =
drm_->GetObjectProperties(kPrimaryCrtc, DRM_MODE_OBJECT_CRTC);
GetDrmPropertyForName(drm_.get(), crtc_props.get(), "ACTIVE",
&crtc_prop_for_name);
EXPECT_EQ(0U, crtc_prop_for_name.value);
crtc_props = drm_->GetObjectProperties(kPrimaryCrtc, DRM_MODE_OBJECT_CRTC);
GetDrmPropertyForName(drm_.get(), crtc_props.get(), "MODE_ID",
&crtc_prop_for_name);
EXPECT_EQ(0U, crtc_prop_for_name.value);
}
TEST_F(HardwareDisplayControllerTest, CheckStateAfterPageFlip) {
ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
......
......@@ -72,7 +72,26 @@ bool HardwareDisplayPlaneManagerAtomic::Modeset(
bool HardwareDisplayPlaneManagerAtomic::DisableModeset(uint32_t crtc_id,
uint32_t connector) {
return drm_->DisableCrtc(crtc_id);
ScopedDrmAtomicReqPtr property_set(drmModeAtomicAlloc());
const int connector_idx = LookupConnectorIndex(connector);
DCHECK_GE(connector_idx, 0);
connectors_props_[connector_idx].crtc_id.value = 0UL;
bool res = AddPropertyIfValid(property_set.get(), connector,
connectors_props_[connector_idx].crtc_id);
const int crtc_idx = LookupCrtcIndex(crtc_id);
DCHECK_GE(crtc_idx, 0);
crtc_state_[crtc_idx].properties.active.value = 0UL;
crtc_state_[crtc_idx].properties.mode_id.value = 0UL;
res &= AddPropertyIfValid(property_set.get(), crtc_id,
crtc_state_[crtc_idx].properties.active);
res &= AddPropertyIfValid(property_set.get(), crtc_id,
crtc_state_[crtc_idx].properties.mode_id);
DCHECK(res);
return drm_->CommitProperties(property_set.get(),
DRM_MODE_ATOMIC_ALLOW_MODESET, 1, nullptr);
}
bool HardwareDisplayPlaneManagerAtomic::Commit(
......
......@@ -31,11 +31,10 @@
namespace {
constexpr uint32_t kPlaneOffset = 100;
constexpr uint32_t kCrtcIdBase = 500;
constexpr uint32_t kConnectorIdBase = 700;
constexpr uint32_t kTypePropId = 3010;
constexpr uint32_t kInFormatsPropId = 3011;
constexpr uint32_t kPlaneCtmId = 3012;
constexpr uint32_t kActivePropId = 1000;
constexpr uint32_t kBackgroundColorPropId = 1002;
constexpr uint32_t kCtmPropId = 1003;
constexpr uint32_t kGammaLutPropId = 1004;
......@@ -43,6 +42,11 @@ constexpr uint32_t kGammaLutSizePropId = 1005;
constexpr uint32_t kDegammaLutPropId = 1006;
constexpr uint32_t kDegammaLutSizePropId = 1007;
constexpr uint32_t kOutFencePtrPropId = 1008;
constexpr uint32_t kTypePropId = 3010;
constexpr uint32_t kInFormatsPropId = 3011;
constexpr uint32_t kPlaneCtmId = 3012;
constexpr uint32_t kInFormatsBlobPropId = 400;
const gfx::Size kDefaultBufferSize(2, 2);
......@@ -113,7 +117,7 @@ void HardwareDisplayPlaneManagerTest::InitializeDrmState(
size_t crtc_count,
size_t planes_per_crtc) {
std::map<uint32_t, std::string> crtc_property_names = {
{1000, "ACTIVE"},
{kActivePropId, "ACTIVE"},
{1001, "MODE_ID"},
};
......@@ -154,7 +158,7 @@ void HardwareDisplayPlaneManagerTest::InitializeDrmState(
for (size_t i = 0; i < crtc_count; ++i) {
ui::MockDrmDevice::CrtcProperties crtc_prop;
// Start ID at 1 cause 0 is an invalid ID.
crtc_prop.id = i + 1;
crtc_prop.id = kCrtcIdBase + i;
for (const auto& pair : crtc_property_names) {
crtc_prop.properties.push_back(
{/* .id = */ pair.first, /* .value = */ 0});
......@@ -413,7 +417,32 @@ TEST_P(HardwareDisplayPlaneManagerAtomicTest, DisableModeset) {
EXPECT_TRUE(fake_drm_->plane_manager()->DisableModeset(
crtc_properties_[0].id, connector_properties_[0].id));
EXPECT_EQ(0, fake_drm_->get_commit_count());
EXPECT_EQ(1, fake_drm_->get_commit_count());
}
TEST_P(HardwareDisplayPlaneManagerAtomicTest, CheckPropsAfterDisable) {
InitializeDrmState(/*crtc_count=*/1, /*planes_per_crtc=*/1);
fake_drm_->InitializeState(crtc_properties_, connector_properties_,
plane_properties_, property_names_,
/*use_atomic=*/true);
constexpr uint32_t kFrameBuffer = 2;
ui::HardwareDisplayPlaneList state;
EXPECT_TRUE(fake_drm_->plane_manager()->Modeset(
crtc_properties_[0].id, kFrameBuffer, connector_properties_[0].id,
kDefaultMode, state));
// Test props values after disabling.
EXPECT_TRUE(fake_drm_->plane_manager()->DisableModeset(
crtc_properties_[0].id, connector_properties_[0].id));
ui::DrmDevice::Property crtc_prop_for_name;
ui::ScopedDrmObjectPropertyPtr crtc_props =
fake_drm_->GetObjectProperties(kCrtcIdBase, DRM_MODE_OBJECT_CRTC);
ui::GetDrmPropertyForName(fake_drm_.get(), crtc_props.get(), "ACTIVE",
&crtc_prop_for_name);
EXPECT_EQ(kActivePropId, crtc_prop_for_name.id);
EXPECT_EQ(0U, crtc_prop_for_name.value);
}
TEST_P(HardwareDisplayPlaneManagerAtomicTest, MultiplePlaneAssignment) {
......
......@@ -63,6 +63,7 @@ class ScreenManagerTest : public testing::Test {
device_manager_ = std::make_unique<ui::DrmDeviceManager>(nullptr);
screen_manager_ = std::make_unique<ui::ScreenManager>();
}
void TearDown() override {
screen_manager_.reset();
drm_ = nullptr;
......
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