1
0
Fork 0

Support boot display config so system-preferred mode is non-null

This commit is contained in:
Brendan Szymanski 2026-07-13 15:49:45 -04:00
parent fbaba3b2b4
commit 03c3e116d1
3 changed files with 45 additions and 7 deletions

View file

@ -124,6 +124,11 @@ class HwcDisplay {
// Get the HwcDisplayConfig, or nullptr if none.
auto GetConfig(ConfigId config_id) const -> const HwcDisplayConfig *;
// Get the EDID-preferred config id. This is reported to the framework as the
// boot/system-preferred display config so the platform (and TV Settings) has
// a valid mode to fall back to when no user preference has been set.
ConfigId GetPreferredConfigId() const { return configs_.preferred_config_id; }
auto GetDisplayBoundsMm() -> std::pair<int32_t, int32_t>;
// To be called after SetDisplayProperties. Returns an empty vector if the

View file

@ -81,6 +81,12 @@ ndk::ScopedAStatus Composer::getCapabilities(std::vector<Capability>* caps) {
caps->emplace_back(Capability::LAYER_LIFECYCLE_BATCH_COMMAND);
// Report boot-display-config support so the framework populates a
// system-preferred display mode. Without this, DisplayManager leaves the
// system-preferred mode unset and TV Settings crashes dereferencing the null
// returned by Display.getSystemPreferredDisplayMode().
caps->emplace_back(Capability::BOOT_DISPLAY_CONFIG);
return ndk::ScopedAStatus::ok();
}

View file

@ -1323,22 +1323,49 @@ ndk::ScopedAStatus ComposerClient::setActiveConfigWithConstraints(
}
}
ndk::ScopedAStatus ComposerClient::setBootDisplayConfig(
int64_t /*display_handle*/, int32_t /*config*/) {
ndk::ScopedAStatus ComposerClient::setBootDisplayConfig(int64_t display_handle,
int32_t config) {
DEBUG_FUNC();
return ToBinderStatus(hwc3::Error::kUnsupported);
const std::unique_lock lock(hwc_->GetResMan().GetMainLock());
HwcDisplay* display = GetDisplay(display_handle);
if (display == nullptr) {
return ToBinderStatus(hwc3::Error::kBadDisplay);
}
if (display->GetConfig(config) == nullptr) {
return ToBinderStatus(hwc3::Error::kBadConfig);
}
// The boot config is not persisted across reboots: each boot re-selects the
// EDID-preferred mode. Accept the request so the capability we advertise
// behaves consistently, but there is nothing to store here.
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus ComposerClient::clearBootDisplayConfig(
int64_t /*display_handle*/) {
int64_t display_handle) {
DEBUG_FUNC();
return ToBinderStatus(hwc3::Error::kUnsupported);
const std::unique_lock lock(hwc_->GetResMan().GetMainLock());
HwcDisplay* display = GetDisplay(display_handle);
if (display == nullptr) {
return ToBinderStatus(hwc3::Error::kBadDisplay);
}
// Nothing is persisted (see setBootDisplayConfig); the preferred config is
// always the EDID-preferred mode, so there is nothing to clear.
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus ComposerClient::getPreferredBootDisplayConfig(
int64_t /*display_handle*/, int32_t* /*config*/) {
int64_t display_handle, int32_t* config) {
DEBUG_FUNC();
return ToBinderStatus(hwc3::Error::kUnsupported);
const std::unique_lock lock(hwc_->GetResMan().GetMainLock());
HwcDisplay* display = GetDisplay(display_handle);
if (display == nullptr) {
return ToBinderStatus(hwc3::Error::kBadDisplay);
}
*config = display->GetPreferredConfigId();
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus ComposerClient::setAutoLowLatencyMode(int64_t display_handle,