summaryrefslogtreecommitdiff
path: root/sdm/libs/hwc2/hwc_display_external.cpp
diff options
context:
space:
mode:
authorDileep Marchya <dmarchya@codeaurora.org>2017-05-20 01:56:21 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2017-07-05 06:09:59 -0700
commitd16da3ecba5cf3a7fcdbf5bc8ad1d60c75624bf3 (patch)
tree13954b740a1518704d22e1a4e54cc9a820311083 /sdm/libs/hwc2/hwc_display_external.cpp
parenta46ce7c6e3737d2d0f5d01c16e1cb14dbe6e733e (diff)
downloaddisplay-d16da3ecba5cf3a7fcdbf5bc8ad1d60c75624bf3.tar.gz
sdm: hwc2: Add support for HDMI as primary.
- Create external display if HDMI is already connected on boot. - Wait for hotplug connect event if HDMI is not connected on boot. - Notify surfaceflinger only once when primary display is created for first time. - Destroy and recreate SDM external display on successive disconnect/connect. Do not notify surfaceflinger any subsequent hotplug events. - Add null display implementation to route any incoming calls from surfaceflinger when display is disconnected. CRs-Fixed: 2037067 Change-Id: I649756452d714e538c313cf80c0144934ad494f9
Diffstat (limited to 'sdm/libs/hwc2/hwc_display_external.cpp')
-rw-r--r--sdm/libs/hwc2/hwc_display_external.cpp64
1 files changed, 63 insertions, 1 deletions
diff --git a/sdm/libs/hwc2/hwc_display_external.cpp b/sdm/libs/hwc2/hwc_display_external.cpp
index a8f8480f..e89451d5 100644
--- a/sdm/libs/hwc2/hwc_display_external.cpp
+++ b/sdm/libs/hwc2/hwc_display_external.cpp
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -64,6 +64,7 @@ int HWCDisplayExternal::Create(CoreInterface *core_intf, HWCBufferAllocator *buf
error = hwc_display_external->GetMixerResolution(&external_width, &external_height);
if (error != kErrorNone) {
+ Destroy(hwc_display_external);
return -EINVAL;
}
@@ -215,4 +216,65 @@ void HWCDisplayExternal::GetDownscaleResolution(uint32_t primary_width, uint32_t
}
}
+int HWCDisplayExternal::SetState(bool connected) {
+ DisplayError error = kErrorNone;
+ DisplayState state = kStateOff;
+ DisplayConfigVariableInfo fb_config = {};
+
+ if (connected) {
+ if (display_null_.IsActive()) {
+ error = core_intf_->CreateDisplay(type_, this, &display_intf_);
+ if (error != kErrorNone) {
+ DLOGE("Display create failed. Error = %d display_type %d event_handler %p disp_intf %p",
+ error, type_, this, &display_intf_);
+ return -EINVAL;
+ }
+
+ // Restore HDMI attributes when display is reconnected.
+ // This is to ensure that surfaceflinger & sdm are in sync.
+ display_null_.GetFrameBufferConfig(&fb_config);
+ int status = SetFrameBufferResolution(fb_config.x_pixels, fb_config.y_pixels);
+ if (status) {
+ DLOGW("Set frame buffer config failed. Error = %d", error);
+ return -1;
+ }
+
+ display_null_.GetDisplayState(&state);
+ display_intf_->SetDisplayState(state);
+
+ SetVsyncEnabled(HWC2::Vsync::Enable);
+
+ display_null_.SetActive(false);
+ DLOGI("Display is connected successfully.");
+ } else {
+ DLOGI("Display is already connected.");
+ }
+ } else {
+ if (!display_null_.IsActive()) {
+ // Preserve required attributes of HDMI display that surfaceflinger sees.
+ // Restore HDMI attributes when display is reconnected.
+ display_intf_->GetDisplayState(&state);
+ display_null_.SetDisplayState(state);
+
+ error = display_intf_->GetFrameBufferConfig(&fb_config);
+ if (error != kErrorNone) {
+ DLOGW("Get frame buffer config failed. Error = %d", error);
+ return -1;
+ }
+ display_null_.SetFrameBufferConfig(fb_config);
+
+ SetVsyncEnabled(HWC2::Vsync::Disable);
+ core_intf_->DestroyDisplay(display_intf_);
+ display_intf_ = &display_null_;
+
+ display_null_.SetActive(true);
+ DLOGI("Display is disconnected successfully.");
+ } else {
+ DLOGI("Display is already disconnected.");
+ }
+ }
+
+ return 0;
+}
+
} // namespace sdm