Commit 1115c2f7 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

ozone/drm: Add cursor to list of planes

crrev.com/c/1056165 moved setting |PLANE_CTM| properties trough
HardwareDisplayPlane.

Since we used to skip adding the cursor to
HardwareDisplayPlaneManager::planes_, after that CL we stopped applying
color correction to the cursor.

This CL makes sure we always add the cursor to the list of planes, so
that color correction will be applied correctly to the cursor.

It also makes sure we don't assign the cursor to an HW overlay.

Bug: 839487
Test: Ran unitests
Change-Id: If8a29e3517d5ead7b8a5edadf6446f910c26176f
Reviewed-on: https://chromium-review.googlesource.com/1077827Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562818}
parent d9732ad0
...@@ -194,14 +194,8 @@ bool HardwareDisplayPlaneManager::Initialize(DrmDevice* drm) { ...@@ -194,14 +194,8 @@ bool HardwareDisplayPlaneManager::Initialize(DrmDevice* drm) {
std::unique_ptr<HardwareDisplayPlane> plane( std::unique_ptr<HardwareDisplayPlane> plane(
CreatePlane(plane_resources->planes[i])); CreatePlane(plane_resources->planes[i]));
if (plane->Initialize(drm)) { if (plane->Initialize(drm))
// CRTC controllers always assume they have a cursor plane and the planes_.push_back(std::move(plane));
// cursor plane is updated via cursor specific DRM API. Hence, we don't
// keep track of cursor plane here to avoid re-using it for any other
// purpose.
if (plane->type() != HardwareDisplayPlane::kCursor)
planes_.push_back(std::move(plane));
}
} }
// crbug.com/464085: if driver reports no primary planes for a crtc, create a // crbug.com/464085: if driver reports no primary planes for a crtc, create a
...@@ -259,7 +253,8 @@ int HardwareDisplayPlaneManager::LookupCrtcIndex(uint32_t crtc_id) const { ...@@ -259,7 +253,8 @@ int HardwareDisplayPlaneManager::LookupCrtcIndex(uint32_t crtc_id) const {
bool HardwareDisplayPlaneManager::IsCompatible(HardwareDisplayPlane* plane, bool HardwareDisplayPlaneManager::IsCompatible(HardwareDisplayPlane* plane,
const OverlayPlane& overlay, const OverlayPlane& overlay,
uint32_t crtc_index) const { uint32_t crtc_index) const {
if (!plane->CanUseForCrtc(crtc_index)) if (plane->type() == HardwareDisplayPlane::kCursor ||
!plane->CanUseForCrtc(crtc_index))
return false; return false;
const uint32_t format = overlay.enable_blend ? const uint32_t format = overlay.enable_blend ?
......
...@@ -185,7 +185,8 @@ bool HardwareDisplayPlaneManagerLegacy::IsCompatible( ...@@ -185,7 +185,8 @@ bool HardwareDisplayPlaneManagerLegacy::IsCompatible(
HardwareDisplayPlane* plane, HardwareDisplayPlane* plane,
const OverlayPlane& overlay, const OverlayPlane& overlay,
uint32_t crtc_index) const { uint32_t crtc_index) const {
if (!plane->CanUseForCrtc(crtc_index)) if (plane->type() == HardwareDisplayPlane::kCursor ||
!plane->CanUseForCrtc(crtc_index))
return false; return false;
// When using legacy kms we always scanout only one plane (the primary), // When using legacy kms we always scanout only one plane (the primary),
......
...@@ -81,11 +81,12 @@ void HardwareDisplayPlaneManagerTest::InitializeDrmState( ...@@ -81,11 +81,12 @@ void HardwareDisplayPlaneManagerTest::InitializeDrmState(
{kTypePropId, "type"}, {kTypePropId, "type"},
{kInFormatsPropId, "IN_FORMATS"}, {kInFormatsPropId, "IN_FORMATS"},
}; };
// Always add an additional cursor plane.
++planes_per_crtc;
for (size_t i = 0; i < crtc_count; ++i) { for (size_t i = 0; i < crtc_count; ++i) {
ui::MockDrmDevice::CrtcProperties crtc_prop; ui::MockDrmDevice::CrtcProperties crtc_prop;
crtc_prop.id = i + 1;
// Start ID at 1 cause 0 is an invalid ID. // Start ID at 1 cause 0 is an invalid ID.
crtc_prop.id = i + 1;
crtc_properties_.emplace_back(std::move(crtc_prop)); crtc_properties_.emplace_back(std::move(crtc_prop));
for (size_t j = 0; j < planes_per_crtc; ++j) { for (size_t j = 0; j < planes_per_crtc; ++j) {
...@@ -94,11 +95,16 @@ void HardwareDisplayPlaneManagerTest::InitializeDrmState( ...@@ -94,11 +95,16 @@ void HardwareDisplayPlaneManagerTest::InitializeDrmState(
plane_prop.crtc_mask = 1 << i; plane_prop.crtc_mask = 1 << i;
for (const auto& pair : property_names_) { for (const auto& pair : property_names_) {
uint32_t value = 0; uint32_t value = 0;
if (pair.first == kTypePropId) if (pair.first == kTypePropId) {
value = j == 0 ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY; if (j == 0)
else if (pair.first == kInFormatsPropId) value = DRM_PLANE_TYPE_PRIMARY;
else if (j == planes_per_crtc - 1)
value = DRM_PLANE_TYPE_CURSOR;
else
value = DRM_PLANE_TYPE_OVERLAY;
} else if (pair.first == kInFormatsPropId) {
value = kInFormatsBlobPropId; value = kInFormatsBlobPropId;
}
plane_prop.properties.push_back({.id = pair.first, .value = value}); plane_prop.properties.push_back({.id = pair.first, .value = value});
}; };
...@@ -124,6 +130,24 @@ TEST_F(HardwareDisplayPlaneManagerTest, SinglePlaneAssignment) { ...@@ -124,6 +130,24 @@ TEST_F(HardwareDisplayPlaneManagerTest, SinglePlaneAssignment) {
EXPECT_EQ(1u, state_.plane_list.size()); EXPECT_EQ(1u, state_.plane_list.size());
} }
TEST_F(HardwareDisplayPlaneManagerTest, AddCursor) {
ui::OverlayPlaneList assigns;
assigns.push_back(ui::OverlayPlane(fake_buffer_, nullptr));
InitializeDrmState(/*crtc_count=*/2, /*planes_per_crtc=*/1);
fake_drm_->InitializeState(crtc_properties_, plane_properties_,
property_names_, /* use_atomic= */ false);
bool cursor_found = false;
for (const auto& plane : fake_drm_->plane_manager()->planes()) {
if (plane->type() == ui::HardwareDisplayPlane::kCursor) {
cursor_found = true;
break;
}
}
EXPECT_TRUE(cursor_found);
}
TEST_F(HardwareDisplayPlaneManagerTest, BadCrtc) { TEST_F(HardwareDisplayPlaneManagerTest, BadCrtc) {
ui::OverlayPlaneList assigns; ui::OverlayPlaneList assigns;
assigns.push_back(ui::OverlayPlane(fake_buffer_, nullptr)); assigns.push_back(ui::OverlayPlane(fake_buffer_, nullptr));
...@@ -321,6 +345,7 @@ TEST_F(HardwareDisplayPlaneManagerTest, ...@@ -321,6 +345,7 @@ TEST_F(HardwareDisplayPlaneManagerTest,
SetColorCorrectionOnAllCrtcPlanes_Success) { SetColorCorrectionOnAllCrtcPlanes_Success) {
InitializeDrmState(/*crtc_count=*/1, /*planes_per_crtc=*/1); InitializeDrmState(/*crtc_count=*/1, /*planes_per_crtc=*/1);
plane_properties_[0].properties.push_back({.id = kPlaneCtmId, .value = 0}); plane_properties_[0].properties.push_back({.id = kPlaneCtmId, .value = 0});
plane_properties_[1].properties.push_back({.id = kPlaneCtmId, .value = 0});
fake_drm_->InitializeState(crtc_properties_, plane_properties_, fake_drm_->InitializeState(crtc_properties_, plane_properties_,
property_names_, /* use_atomic= */ true); property_names_, /* use_atomic= */ true);
......
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