From 456e2d6b0d3a98e62e942c083cde02e853c4af24 Mon Sep 17 00:00:00 2001 From: Roman Stratiienko Date: Sat, 29 Jan 2022 01:17:39 +0200 Subject: drm_hwcomposer: Handle primary display in GetDisplayConnectionType() Primary display should always be internal. Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/58 Signed-off-by: Roman Stratiienko --- hwc2_device/HwcDisplay.cpp | 9 ++++++++- hwc2_device/HwcDisplay.h | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp index 8936136..f18e00d 100644 --- a/hwc2_device/HwcDisplay.cpp +++ b/hwc2_device/HwcDisplay.cpp @@ -708,7 +708,14 @@ std::vector HwcDisplay::GetOrderLayersByZPos() { #if PLATFORM_SDK_VERSION > 29 HWC2::Error HwcDisplay::GetDisplayConnectionType(uint32_t *outType) { - if (connector_->internal()) + if (IsInHeadlessMode()) { + *outType = static_cast(HWC2::DisplayConnectionType::Internal); + return HWC2::Error::None; + } + /* Primary display should be always internal, + * otherwise SF will be unhappy and will crash + */ + if (connector_->internal() || handle_ == kPrimaryDisplay) *outType = static_cast(HWC2::DisplayConnectionType::Internal); else if (connector_->external()) *outType = static_cast(HWC2::DisplayConnectionType::External); diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h index c3e0f6e..76456b7 100644 --- a/hwc2_device/HwcDisplay.h +++ b/hwc2_device/HwcDisplay.h @@ -33,6 +33,8 @@ namespace android { class Backend; class DrmHwcTwo; +inline constexpr uint32_t kPrimaryDisplay = 0; + class HwcDisplay { public: HwcDisplay(ResourceManager *resource_manager, DrmDevice *drm, @@ -207,7 +209,8 @@ class HwcDisplay { * https://source.android.com/devices/graphics/hotplug#handling-common-scenarios */ bool IsInHeadlessMode() { - return handle_ == 0 && connector_->state() != DRM_MODE_CONNECTED; + return handle_ == kPrimaryDisplay && + connector_->state() != DRM_MODE_CONNECTED; } private: -- cgit v1.2.3