Skip to content

Commit 5d0f38d

Browse files
committed
Reset HDR Pipeline When Hotplug
To ensure proper reset and reinitialization of the HDR (High Dynamic Range) pipeline during hotplug events (e.g., when a display connector is plugged or unplugged). This prevents potential issues like stale HDR configurations persisting across display changes. The changes refactor EDID (Extended Display Identification Data) handling for better modularity and add explicit HDR reset logic in the display deinitialization and color mode switching paths. This improves reliability for HDR-enabled displays during dynamic connector updates, such as in multi-monitor setups or docking scenarios. Test-done: Verification was performed on a system with both SDR and HDR displays. The displays were alternately hotplugged (inserted and removed) multiple times to simulate dynamic scenarios. Tracked-On: OAM-134602 Change-Id: I288792da7bdd93d2de1530e2f7e749a73bac9005 Signed-off-by: Kanli Hu <kanli.hu@intel.com>
1 parent 728c296 commit 5d0f38d

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

drm/DrmConnector.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ auto DrmConnector::CreateInstance(DrmDevice &dev, uint32_t connector_id,
8282
return c;
8383
}
8484

85+
void DrmConnector::UpdateEdidWrapper() {
86+
UpdateEdidProperty();
87+
#if HAS_LIBDISPLAY_INFO
88+
auto edid = LibdisplayEdidWrapper::Create(GetEdidBlob());
89+
edid_wrapper_ = edid ? std::move(edid) : std::make_unique<EdidWrapper>();
90+
#else
91+
edid_wrapper_ = std::make_unique<EdidWrapper>();
92+
#endif
93+
}
94+
8595
auto DrmConnector::Init()-> bool {
8696
if (!GetConnectorProperty("Content Protection", &hdcp_id_property_)) {
8797
ALOGE("%s GetHDCPConnectorProperty check failed!", __FUNCTION__);
@@ -95,13 +105,7 @@ auto DrmConnector::Init()-> bool {
95105
return false;
96106
}
97107

98-
UpdateEdidProperty();
99-
#if HAS_LIBDISPLAY_INFO
100-
auto edid = LibdisplayEdidWrapper::Create(GetEdidBlob());
101-
edid_wrapper_ = edid ? std::move(edid) : std::make_unique<EdidWrapper>();
102-
#else
103-
edid_wrapper_ = std::make_unique<EdidWrapper>();
104-
#endif
108+
UpdateEdidWrapper();
105109

106110
if (IsWriteback() &&
107111
(!GetConnectorProperty("WRITEBACK_PIXEL_FORMATS",

drm/DrmConnector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class DrmConnector : public PipelineBindable<DrmConnector> {
4444
DrmConnector &operator=(const DrmProperty &) = delete;
4545

4646
int UpdateEdidProperty();
47+
void UpdateEdidWrapper();
4748
auto GetEdidBlob() -> DrmModePropertyBlobUnique;
4849
auto GetParsedEdid() -> EdidWrapperUnique & {
4950
return edid_wrapper_;

drm/ResourceManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ void ResourceManager::UpdateFrontendDisplays() {
250250

251251
for (auto *conn : ordered_connectors) {
252252
conn->UpdateModes();
253+
conn->UpdateEdidWrapper();
253254
auto connected = conn->IsConnected();
254255
auto attached = attached_pipelines_.count(conn) != 0;
255256

hwc2_device/HwcDisplay.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ auto HwcDisplay::PresentStagedComposition(
415415

416416
void HwcDisplay::SetPipeline(std::shared_ptr<DrmDisplayPipeline> pipeline) {
417417
Deinit();
418-
419418
pipeline_ = std::move(pipeline);
420419

421420
if (pipeline_ != nullptr || handle_ == kPrimaryDisplay) {
@@ -442,6 +441,7 @@ void HwcDisplay::Deinit() {
442441
flatcon_->StopThread();
443442
flatcon_.reset();
444443
}
444+
ResetHdrPipelineInDisplay();
445445
}
446446

447447
if (vsync_worker_) {
@@ -991,6 +991,14 @@ HWC2::Error HwcDisplay::SetActiveConfig(hwc2_config_t config) {
991991
return SetActiveConfigInternal(config, ResourceManager::GetTimeMonotonicNs());
992992
}
993993

994+
void HwcDisplay::ResetHdrPipelineInDisplay() {
995+
hdr_metadata_.reset();
996+
hdr_degamma_lut_.reset();
997+
hdr_gamma_lut_.reset();
998+
SetColorMatrixToIdentity();
999+
hdr_active_ = false;
1000+
}
1001+
9941002
HWC2::Error HwcDisplay::SetColorMode(int32_t mode) {
9951003
ATRACE_CALL();
9961004
/* Maps to the Colorspace DRM connector property:
@@ -1050,11 +1058,7 @@ HWC2::Error HwcDisplay::SetColorMode(int32_t mode) {
10501058
}
10511059
hdr_active_ = true;
10521060
} else if (hdr_active_) {
1053-
hdr_degamma_lut_.reset();
1054-
hdr_gamma_lut_.reset();
1055-
SetColorMatrixToIdentity();
1056-
hdr_metadata_.reset();
1057-
hdr_active_ = false;
1061+
ResetHdrPipelineInDisplay();
10581062
}
10591063

10601064
color_mode_ = mode;

0 commit comments

Comments
 (0)