author | baocheng sun <baocheng.sun@amlogic.com> | 2020-03-10 03:27:26 (GMT) |
---|---|---|
committer | sky zhou <sky.zhou@amlogic.com> | 2020-05-21 12:12:29 (GMT) |
commit | 7a43c0cc48490a32d0117a3d839c44daad21dc8e (patch) | |
tree | 196000e47f354564b130413d01e973f224e19beb | |
parent | f104ec959de91bb630d8361c975889fe0d459f9b (diff) | |
download | hwcomposer-7a43c0cc48490a32d0117a3d839c44daad21dc8e.zip hwcomposer-7a43c0cc48490a32d0117a3d839c44daad21dc8e.tar.gz hwcomposer-7a43c0cc48490a32d0117a3d839c44daad21dc8e.tar.bz2 |
hwc: Once hdmi connected, never switch to cvbs [3/4]
PD#SWPL-22037
Problem:
HDMI/CVBS simplified implementation
Solution:
When there is no hardware vsync, switch to software vsync ensure
everything works fine. Once hdmi connected, never switch to cvbs.
Verify:
franklin
Change-Id: Ic8c8faf6f00618fba839e69156268f4c6762c94f
Signed-off-by: baocheng sun <baocheng.sun@amlogic.com>
-rw-r--r-- | common/hwc/FixedDisplayPipe.cpp | 19 | ||||
-rw-r--r-- | common/hwc/FixedDisplayPipe.h | 1 | ||||
-rw-r--r-- | common/hwc/HwcConfig.cpp | 2 | ||||
-rw-r--r-- | common/hwc/HwcDisplayPipe.cpp | 15 | ||||
-rw-r--r-- | common/hwc/HwcVsync.cpp | 1 | ||||
-rw-r--r-- | hwc2/Hwc2Display.cpp | 5 |
6 files changed, 36 insertions, 7 deletions
diff --git a/common/hwc/FixedDisplayPipe.cpp b/common/hwc/FixedDisplayPipe.cpp index 54e26e0..5351174 100644 --- a/common/hwc/FixedDisplayPipe.cpp +++ b/common/hwc/FixedDisplayPipe.cpp @@ -10,6 +10,9 @@ #include "FixedDisplayPipe.h" #include <HwcConfig.h> #include <MesonLog.h> +#include <misc.h> + +#define HDMI_HAS_USED_STATE "/sys/class/amhdmitx/amhdmitx0/hdmi_used" FixedDisplayPipe::FixedDisplayPipe() : HwcDisplayPipe() { @@ -45,11 +48,14 @@ void FixedDisplayPipe::handleEvent(drm_display_event event, int val) { MESON_LOGD("handleEvent DRM_EVENT_HDMITX_HOTPLUG %d VS %d", pipe->cfg.hwcConnectorType, targetConnector); - if (pipe->cfg.hwcConnectorType != targetConnector) { + if (pipe->cfg.hwcConnectorType != targetConnector && + pipe->cfg.hwcConnectorType == DRM_MODE_CONNECTOR_CVBS && + hasHdmiConnected()) { #if 0 /*TODO: for fixed pipe, let systemcontrol to set displaymode.*/ pipe->hwcCrtc->unbind(); pipe->modeCrtc->unbind(); #endif + /* we need latest connector status, and no one will update *connector not bind to crtc, we update here. */ @@ -85,11 +91,11 @@ int32_t FixedDisplayPipe::getPipeCfg(uint32_t hwcid, PipeCfg & cfg) { drm_connector_type_t FixedDisplayPipe::getConnetorCfg(uint32_t hwcid) { drm_connector_type_t connector = HwcDisplayPipe::getConnetorCfg(hwcid); - if (connector == DRM_MODE_CONNECTOR_INVALID && - HwcConfig::getConnectorType(hwcid) == HWC_HDMI_CVBS) { + if (connector == DRM_MODE_CONNECTOR_INVALID || + connector == DRM_MODE_CONNECTOR_CVBS) { std::shared_ptr<HwDisplayConnector> hwConnector; getConnector(DRM_MODE_CONNECTOR_HDMI, hwConnector); - if (hwConnector->isConnected()) { + if (hwConnector->isConnected() || hasHdmiConnected()) { connector = DRM_MODE_CONNECTOR_HDMI; } else { connector = DRM_MODE_CONNECTOR_CVBS; @@ -100,3 +106,8 @@ drm_connector_type_t FixedDisplayPipe::getConnetorCfg(uint32_t hwcid) { return connector; } +bool FixedDisplayPipe::hasHdmiConnected() { + bool ret = sysfs_get_int(HDMI_HAS_USED_STATE, 0) == 1 ? true : false; + MESON_LOGD("FixedDisplayPipe::hasHdmiConnected:%d", ret); + return ret; +} diff --git a/common/hwc/FixedDisplayPipe.h b/common/hwc/FixedDisplayPipe.h index 239b693..52a8b93 100644 --- a/common/hwc/FixedDisplayPipe.h +++ b/common/hwc/FixedDisplayPipe.h @@ -22,6 +22,7 @@ public: protected: int32_t getPipeCfg(uint32_t hwcid, PipeCfg & cfg); drm_connector_type_t getConnetorCfg(uint32_t hwcid); + bool hasHdmiConnected(); }; diff --git a/common/hwc/HwcConfig.cpp b/common/hwc/HwcConfig.cpp index 717cce5..31d3ec4 100644 --- a/common/hwc/HwcConfig.cpp +++ b/common/hwc/HwcConfig.cpp @@ -140,7 +140,7 @@ int32_t HwcConfig::headlessRefreshRate() { } bool HwcConfig::softwareVsyncEnabled() { -#if 1//def HWC_ENABLE_SOFTWARE_VSYNC +#ifdef HWC_ENABLE_SOFTWARE_VSYNC return true; #else return false; diff --git a/common/hwc/HwcDisplayPipe.cpp b/common/hwc/HwcDisplayPipe.cpp index d95e7d0..fcde6ed 100644 --- a/common/hwc/HwcDisplayPipe.cpp +++ b/common/hwc/HwcDisplayPipe.cpp @@ -18,6 +18,7 @@ #include <HwDisplayManager.h> #define HWC_BOOTED_PROP "vendor.sys.hwc.booted" +#define DEFAULT_REFRESH_RATE (60.0f) HwcDisplayPipe::PipeStat::PipeStat(uint32_t id) { hwcId = id; @@ -231,7 +232,10 @@ int32_t HwcDisplayPipe::updatePipe(std::shared_ptr<PipeStat> & stat) { stat->modeMgr->setDisplayResources(stat->modeCrtc, stat->modeConnector); stat->modeMgr->update(); - if (HwcConfig::softwareVsyncEnabled()) { + MESON_LOGD("updatePipe connector:%s, connected:%d", stat->hwcConnector->getName(), + stat->hwcConnector->isConnected()); + + if (HwcConfig::softwareVsyncEnabled() || stat->hwcConnector->isConnected() == false) { stat->hwcVsync->setSoftwareMode(); } else { stat->hwcVsync->setHwMode(stat->modeCrtc); @@ -318,6 +322,15 @@ void HwcDisplayPipe::handleEvent(drm_display_event event, int val) { drm_mode_info_t mode; if (0 == statIt.second->modeMgr->getDisplayMode(mode)) { statIt.second->hwcVsync->setPeriod(1e9 / mode.refreshRate); + if (HwcConfig::softwareVsyncEnabled()) { + statIt.second->hwcVsync->setSoftwareMode(); + } else { + statIt.second->hwcVsync->setHwMode(statIt.second->modeCrtc); + } + } else { + /* could not get mode, switch to software vsync */ + statIt.second->hwcVsync->setPeriod(1e9 / DEFAULT_REFRESH_RATE); + statIt.second->hwcVsync->setSoftwareMode(); } } } diff --git a/common/hwc/HwcVsync.cpp b/common/hwc/HwcVsync.cpp index ce50877..adf6edf 100644 --- a/common/hwc/HwcVsync.cpp +++ b/common/hwc/HwcVsync.cpp @@ -131,7 +131,6 @@ int32_t HwcVsync::waitHwVsync(nsecs_t& vsync_timestamp) { nsecs_t now = systemTime(CLOCK_MONOTONIC); mVsyncTime = mVsyncTime + cur_vsync_period + (now - mVsyncTime ) /cur_vsync_period * cur_vsync_period; - MESON_LOGE("Wait hw vsync %lld - %lld", mVsyncTime, now); struct timespec spec; spec.tv_sec = mVsyncTime / 1000000000; diff --git a/hwc2/Hwc2Display.cpp b/hwc2/Hwc2Display.cpp index 65f5c07..d0d2735 100644 --- a/hwc2/Hwc2Display.cpp +++ b/hwc2/Hwc2Display.cpp @@ -253,6 +253,11 @@ void Hwc2Display::onHotplug(bool connected) { if (bSendPlugOut) { mObserver->onHotplug(false); } + + /* switch to software vsync when hdmi plug out and no cvbs mode */ + if (mConnector && mConnector->getType() == DRM_MODE_CONNECTOR_HDMI) { + mVsync->setSoftwareMode(); + } } void Hwc2Display::onUpdate(bool bHdcp) { |