Commit 0a530d7a authored by Daniel Nicoara's avatar Daniel Nicoara Committed by Commit Bot

[OZONE-DRM] If the GAMMA properties aren't available always do legacy API

If we don't have the GAMMA properties try the legacy path even when
trying to disable GAMMA otherwise we could leave the GAMMA set to an
undesirable value.

BUG=868479
TEST=New unittest

Change-Id: I61b7c576b4ae09f1a2ad6d8bf837fb01bcd49b79
Reviewed-on: https://chromium-review.googlesource.com/1153599
Commit-Queue: Daniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578827}
parent bc21f890
...@@ -269,10 +269,7 @@ bool HardwareDisplayPlaneManager::SetGammaCorrection( ...@@ -269,10 +269,7 @@ bool HardwareDisplayPlaneManager::SetGammaCorrection(
(!crtc_props->degamma_lut.id || !crtc_props->degamma_lut_size.id)) (!crtc_props->degamma_lut.id || !crtc_props->degamma_lut_size.id))
return false; return false;
if (!gamma_lut.empty() && if (!crtc_props->gamma_lut.id || !crtc_props->gamma_lut_size.id) {
(!crtc_props->gamma_lut.id || !crtc_props->gamma_lut_size.id)) {
// If we can't find the degamma & gamma lut, it means the properties
// aren't available. We should then try to use the legacy gamma ramp ioctl.
if (degamma_lut.empty()) if (degamma_lut.empty())
return drm_->SetGammaRamp(crtc_id, gamma_lut); return drm_->SetGammaRamp(crtc_id, gamma_lut);
......
...@@ -586,15 +586,26 @@ TEST_P(HardwareDisplayPlaneManagerTest, SetGammaCorrection_MissingGamma) { ...@@ -586,15 +586,26 @@ TEST_P(HardwareDisplayPlaneManagerTest, SetGammaCorrection_MissingGamma) {
} else { } else {
EXPECT_EQ(0, fake_drm_->get_set_object_property_count()); EXPECT_EQ(0, fake_drm_->get_set_object_property_count());
} }
}
TEST_P(HardwareDisplayPlaneManagerTest, SetGammaCorrection_LegacyGamma) {
InitializeDrmState(/*crtc_count=*/1, /*planes_per_crtc=*/1);
fake_drm_->InitializeState(crtc_properties_, plane_properties_,
property_names_, use_atomic_);
fake_drm_->set_legacy_gamma_ramp_expectation(true); fake_drm_->set_legacy_gamma_ramp_expectation(true);
EXPECT_TRUE(fake_drm_->plane_manager()->SetGammaCorrection( EXPECT_TRUE(fake_drm_->plane_manager()->SetGammaCorrection(
crtc_properties_[0].id, {}, {{0, 0, 0}})); crtc_properties_[0].id, {}, {{0, 0, 0}}));
// Going through the legacy API, so we shouldn't commit anything. EXPECT_EQ(1, fake_drm_->get_set_gamma_ramp_count());
if (use_atomic_) EXPECT_EQ(0, fake_drm_->get_commit_count());
EXPECT_EQ(2, fake_drm_->get_commit_count()); EXPECT_EQ(0, fake_drm_->get_set_object_property_count());
else
EXPECT_EQ(0, fake_drm_->get_set_object_property_count()); // Ensure disabling gamma also works on legacy.
EXPECT_TRUE(fake_drm_->plane_manager()->SetGammaCorrection(
crtc_properties_[0].id, {}, {}));
EXPECT_EQ(2, fake_drm_->get_set_gamma_ramp_count());
EXPECT_EQ(0, fake_drm_->get_commit_count());
EXPECT_EQ(0, fake_drm_->get_set_object_property_count());
} }
TEST_P(HardwareDisplayPlaneManagerTest, SetGammaCorrection_Success) { TEST_P(HardwareDisplayPlaneManagerTest, SetGammaCorrection_Success) {
......
...@@ -423,6 +423,7 @@ bool MockDrmDevice::CommitProperties( ...@@ -423,6 +423,7 @@ bool MockDrmDevice::CommitProperties(
bool MockDrmDevice::SetGammaRamp( bool MockDrmDevice::SetGammaRamp(
uint32_t crtc_id, uint32_t crtc_id,
const std::vector<display::GammaRampRGBEntry>& lut) { const std::vector<display::GammaRampRGBEntry>& lut) {
set_gamma_ramp_count_++;
return legacy_gamma_ramp_expectation_; return legacy_gamma_ramp_expectation_;
} }
......
...@@ -67,6 +67,7 @@ class MockDrmDevice : public DrmDevice { ...@@ -67,6 +67,7 @@ class MockDrmDevice : public DrmDevice {
int get_set_object_property_count() const { int get_set_object_property_count() const {
return set_object_property_count_; return set_object_property_count_;
} }
int get_set_gamma_ramp_count() const { return set_gamma_ramp_count_; }
void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; } void set_set_crtc_expectation(bool state) { set_crtc_expectation_ = state; }
void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; } void set_page_flip_expectation(bool state) { page_flip_expectation_ = state; }
void set_add_framebuffer_expectation(bool state) { void set_add_framebuffer_expectation(bool state) {
...@@ -194,6 +195,7 @@ class MockDrmDevice : public DrmDevice { ...@@ -194,6 +195,7 @@ class MockDrmDevice : public DrmDevice {
int allocate_buffer_count_; int allocate_buffer_count_;
int commit_count_ = 0; int commit_count_ = 0;
int set_object_property_count_ = 0; int set_object_property_count_ = 0;
int set_gamma_ramp_count_ = 0;
bool set_crtc_expectation_; bool set_crtc_expectation_;
bool add_framebuffer_expectation_; bool add_framebuffer_expectation_;
......
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