author | baocheng sun <baocheng.sun@amlogic.com> | 2019-10-22 08:08:23 (GMT) |
---|---|---|
committer | sky zhou <sky.zhou@amlogic.com> | 2020-05-21 11:48:25 (GMT) |
commit | 9718b398e2943a557b7295d3ecf0fd2d740fe2b2 (patch) | |
tree | 466beafd9c8b3ea2a60e2698e6dbeebc4a77c432 | |
parent | 8ec4575aa27e8595a171724c7085e039327d5b5b (diff) | |
download | hwcomposer-9718b398e2943a557b7295d3ecf0fd2d740fe2b2.zip hwcomposer-9718b398e2943a557b7295d3ecf0fd2d740fe2b2.tar.gz hwcomposer-9718b398e2943a557b7295d3ecf0fd2d740fe2b2.tar.bz2 |
hwc: enable hotplug [1/2]
PD#SWPL-15303
Problem:
enable hotplug with google's commit
Solution:
when hdmi disconnect, send onHotplug DISCONNECT event
for the current display. Swap to a dummy config,
Then send onhotplug CONNECT for the dummy config.
Verify:
verify on franklin
Change-Id: I4f00e8e3443035ed1352d4f0ebe8a55b815c4eca
Signed-off-by: baocheng sun <baocheng.sun@amlogic.com>
-rw-r--r-- | common/hwc/FixedDisplayPipe.cpp | 13 | ||||
-rw-r--r-- | common/hwc/HwcDisplayPipe.cpp | 11 | ||||
-rw-r--r-- | hwc2/FixedSizeModeMgr.cpp | 18 | ||||
-rw-r--r-- | hwc2/FixedSizeModeMgr.h | 3 | ||||
-rw-r--r-- | hwc2/Hwc2Display.cpp | 43 |
5 files changed, 62 insertions, 26 deletions
diff --git a/common/hwc/FixedDisplayPipe.cpp b/common/hwc/FixedDisplayPipe.cpp index 55527c1..54e26e0 100644 --- a/common/hwc/FixedDisplayPipe.cpp +++ b/common/hwc/FixedDisplayPipe.cpp @@ -32,16 +32,17 @@ void FixedDisplayPipe::handleEvent(drm_display_event event, int val) { drm_connector_type_t targetConnector = DRM_MODE_CONNECTOR_INVALID; for (auto statIt : mPipeStats) { hwc_connector_t connectorType = HwcConfig::getConnectorType((int)statIt.first); + pipe = statIt.second; + + /*update current connector status, now getpipecfg() need + * read connector status to decide connector. + */ + statIt.second->modeConnector->update(); + if (connectorType == HWC_HDMI_CVBS) { - pipe = statIt.second; targetConnector = connected ? DRM_MODE_CONNECTOR_HDMI : DRM_MODE_CONNECTOR_CVBS; - /*update current connector status, now getpipecfg() need - * read connector status to decide connector. - */ - statIt.second->modeConnector->update(); - MESON_LOGD("handleEvent DRM_EVENT_HDMITX_HOTPLUG %d VS %d", pipe->cfg.hwcConnectorType, targetConnector); if (pipe->cfg.hwcConnectorType != targetConnector) { diff --git a/common/hwc/HwcDisplayPipe.cpp b/common/hwc/HwcDisplayPipe.cpp index 783227d..c4d8b08 100644 --- a/common/hwc/HwcDisplayPipe.cpp +++ b/common/hwc/HwcDisplayPipe.cpp @@ -280,6 +280,17 @@ void HwcDisplayPipe::handleEvent(drm_display_event event, int val) { if (statIt.second->modeConnector->getType() == DRM_MODE_CONNECTOR_HDMI) { statIt.second->modeConnector->update(); statIt.second->hwcDisplay->onHotplug(connected); + } else if (statIt.second->modeConnector->getType() == DRM_MODE_CONNECTOR_CVBS) { + /* + * Now Hdmi is plugIn. Switch from cvbs to hdmi. + * onHotplug DISCONNECT for CVBS in onHotplug(true) of Hwc2Display. + * onHotplug CONNECT for hdmi in onModeChanged() of Hwc2Display + * when displayPipe is ready. + */ + if (connected == true) { + MESON_LOGD("hdmi connected, switch from cvbs"); + statIt.second->hwcDisplay->onHotplug(connected); + } } } } diff --git a/hwc2/FixedSizeModeMgr.cpp b/hwc2/FixedSizeModeMgr.cpp index 52363b3..f512b3b 100644 --- a/hwc2/FixedSizeModeMgr.cpp +++ b/hwc2/FixedSizeModeMgr.cpp @@ -16,6 +16,15 @@ #define DEFUALT_DPI (159) #define DEFAULT_REFRESH_RATE (60.0f) +static drm_mode_info_t defaultMode = { + "dummy_hdmi", + DEFUALT_DPI, + DEFUALT_DPI, + 720, + 480, + DEFAULT_REFRESH_RATE +}; + FixedSizeModeMgr::FixedSizeModeMgr() { } @@ -32,8 +41,8 @@ const char * FixedSizeModeMgr::getName() { } void FixedSizeModeMgr::setFramebufferSize(uint32_t w, uint32_t h) { - mCurMode.pixelW = w; - mCurMode.pixelH = h; + mCurMode.pixelW = mFbWidth = w; + mCurMode.pixelH = mFbHeight = h; } void FixedSizeModeMgr::setDisplayResources( @@ -52,6 +61,8 @@ int32_t FixedSizeModeMgr::update() { mCurMode.refreshRate = realMode.refreshRate; mCurMode.dpiX = realMode.dpiX; mCurMode.dpiY = realMode.dpiY; + mCurMode.pixelW = mFbWidth; + mCurMode.pixelH = mFbHeight; strncpy(mCurMode.name, realMode.name , DRM_DISPLAY_MODE_LEN); MESON_LOGI("ModeMgr update to (%s)", mCurMode.name); useFakeMode = false; @@ -59,8 +70,7 @@ int32_t FixedSizeModeMgr::update() { } if (useFakeMode) { - mCurMode.refreshRate = DEFAULT_REFRESH_RATE; - mCurMode.dpiX = mCurMode.dpiY = DEFUALT_DPI; + mCurMode = defaultMode; strncpy(mCurMode.name, "NULL", DRM_DISPLAY_MODE_LEN); } diff --git a/hwc2/FixedSizeModeMgr.h b/hwc2/FixedSizeModeMgr.h index b8dc517..683a367 100644 --- a/hwc2/FixedSizeModeMgr.h +++ b/hwc2/FixedSizeModeMgr.h @@ -51,6 +51,9 @@ protected: std::map<uint32_t, drm_mode_info_t> mModes; drm_mode_info_t mCurMode; + uint32_t mFbWidth; + uint32_t mFbHeight; + }; #endif/*FIXED_SIZE_MODE_MGR_H*/ diff --git a/hwc2/Hwc2Display.cpp b/hwc2/Hwc2Display.cpp index 51a1ef6..f2aea08 100644 --- a/hwc2/Hwc2Display.cpp +++ b/hwc2/Hwc2Display.cpp @@ -235,9 +235,19 @@ hwc2_error_t Hwc2Display::setVsyncEnable(hwc2_vsync_t enabled) { // accordingly. void Hwc2Display::onHotplug(bool connected) { bool bSendPlugOut = false; + MESON_LOGD("On hot plug: [%s]", connected == true ? "Plug in" : "Plug out"); + /* + * call hotplug out of lock, SF may call some hwc function to cause deadlock. + * When a display is connected, First onHotplug DISCONNECT for the dummy config + * Swap out dummy display for the newly-connected display. OnHotplug CONNECT for + * the newly-connected display will be called onModeChanged function when the + * displayPip is Ready. + */ + if (connected) + mObserver->onHotplug(false); + { std::lock_guard<std::mutex> lock(mMutex); - MESON_LOGD("On hot plug: [%s]", connected == true ? "Plug in" : "Plug out"); if (connected) { mSignalHpd = true; @@ -249,20 +259,17 @@ void Hwc2Display::onHotplug(bool connected) { } } - /*call hotplug out of lock, SF may call some hwc function to cause deadlock.*/ - if (bSendPlugOut) { - std::shared_ptr<IComposer> clientComposer = mComposers.find(MESON_CLIENT_COMPOSER)->second; - clientComposer->prepare(); - if (mLayers.size() >= 1) - mLayers.clear(); - - uint32_t outNumTypes; - uint32_t outNumRequests; - int32_t outPresentFence; - validateDisplay(&outNumTypes,&outNumRequests); - presentDisplay(&outPresentFence); - + /* + * call hotplug out of lock, SF may call some hwc function to cause deadlock. + * When a display is disconnected: + * onHotplug DISCONNECT for the current display + * Swap in dummy config [only 1 config 720x480, with no HDR capabilities] + * onHotplug CONNECT for the dummy config + */ + if (mObserver) { mObserver->onHotplug(false); + mModeMgr->update(); + mObserver->onHotplug(true); } } @@ -308,7 +315,6 @@ void Hwc2Display::onModeChanged(int stage) { mPowerMode->setConnectorStatus(true); if (mSignalHpd) { bSendPlugIn = true; - mSignalHpd = false; } else { /*Workaround: needed for NTS test.*/ if (HwcConfig::primaryHotplugEnabled() @@ -328,7 +334,12 @@ void Hwc2Display::onModeChanged(int stage) { } /*call hotplug out of lock, SF may call some hwc function to cause deadlock.*/ if (bSendPlugIn && mModeMgr->needCallHotPlug()) { - MESON_LOGD("mObserver->onHotplug(true)"); + if (mSignalHpd == false) + mObserver->onHotplug(false); + else + mSignalHpd = false; + + MESON_LOGD("onModeChanged mObserver->onHotplug(true)"); mObserver->onHotplug(true); } else { MESON_LOGD("mModeMgr->resetTags"); |