aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Stratiienko <roman.o.stratiienko@globallogic.com>2022-01-29 01:17:39 +0200
committerRoman Stratiienko <roman.o.stratiienko@globallogic.com>2022-01-31 21:31:32 +0200
commit456e2d6b0d3a98e62e942c083cde02e853c4af24 (patch)
tree7e576471e9aa67b451f5dc0f7f7beb4d3a26f0cd
parentb671fab16a08830703f5fe73037563ff8001a1a3 (diff)
downloaddrm_hwcomposer-456e2d6b0d3a98e62e942c083cde02e853c4af24.tar.gz
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 <roman.o.stratiienko@globallogic.com>
-rw-r--r--hwc2_device/HwcDisplay.cpp9
-rw-r--r--hwc2_device/HwcDisplay.h5
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<HwcLayer *> HwcDisplay::GetOrderLayersByZPos() {
#if PLATFORM_SDK_VERSION > 29
HWC2::Error HwcDisplay::GetDisplayConnectionType(uint32_t *outType) {
- if (connector_->internal())
+ if (IsInHeadlessMode()) {
+ *outType = static_cast<uint32_t>(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<uint32_t>(HWC2::DisplayConnectionType::Internal);
else if (connector_->external())
*outType = static_cast<uint32_t>(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: