Commit 79f03ab2 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

ozone/drm: Pick the first preferred mode

Ozone/drm selects a native mode looking at the preferred mode of
a connector when a monitor is plugged in.

KMS specification (https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html)
says that there should be at most one preferred mode, but we found
that is not the case on some monitors.

This CL changes the behavior of the selected preferred mode when more than
one mode is listed and it now selects the first preferred mode instead of
the last one.

Bug: 999630
Test: DrmUtilTest.TestDisplayModesExtraction
Change-Id: I862ed2a1f4eaddf09b6ffb920bd494411746c43e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1777281
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692367}
parent 514a111f
......@@ -402,8 +402,14 @@ display::DisplaySnapshot::DisplayModeList ExtractDisplayModes(
if (info->crtc()->mode_valid && SameMode(info->crtc()->mode, mode))
*out_current_mode = modes.back().get();
if (mode.type & DRM_MODE_TYPE_PREFERRED)
*out_native_mode = modes.back().get();
if (mode.type & DRM_MODE_TYPE_PREFERRED) {
if (*out_native_mode == nullptr) {
*out_native_mode = modes.back().get();
} else {
LOG(WARNING) << "Found more than one preferred modes. The first one "
"will be used.";
}
}
}
// If we couldn't find a preferred mode, then try to find a mode that has the
......
......@@ -615,6 +615,15 @@ TEST_F(DrmUtilTest, TestDisplayModesExtraction) {
EXPECT_EQ(extracted_modes[0].get(), current_mode);
EXPECT_EQ(extracted_modes[2].get(), native_mode);
EXPECT_EQ(gfx::Size(800, 600), native_mode->size());
// While KMS specification says there should be at most one preferred mode per
// connector, we found monitors with more than one preferred mode. With this
// test we make sure the first one is the one used for native_mode.
modes_ptr[1].type |= DRM_MODE_TYPE_PREFERRED;
extracted_modes = ExtractDisplayModes(&info, active_pixel_size, &current_mode,
&native_mode);
ASSERT_EQ(5u, extracted_modes.size());
EXPECT_EQ(extracted_modes[1].get(), native_mode);
}
} // namespace ui
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