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>
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 @@
 
 #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);