From b211a1e817b04b8cc42c680d4807e5cb66aa6ccc Mon Sep 17 00:00:00 2001 From: Luan Yuan Date: Fri, 22 Dec 2017 12:05:41 +0000 Subject: hwcomposer: update params when switch hdmi to cvbs[2/2] PD#157561 remove unnecessary code and add new Uevent to observe change of mode state. Change-Id: Ib4ca4dfc2cb30447e84c55bfb52294acd58835b8 --- diff --git a/hwc2/common/devices/PrimaryDevice.cpp b/hwc2/common/devices/PrimaryDevice.cpp index 797f9ff..88ac1cb 100644 --- a/hwc2/common/devices/PrimaryDevice.cpp +++ b/hwc2/common/devices/PrimaryDevice.cpp @@ -49,7 +49,7 @@ bool PrimaryDevice::initialize() DEINIT_AND_RETURN_FALSE("failed to initialize physical device"); } - mSignalHpd = false; + mSignalHpd = Utils::getSysfsInt(DISPLAY_HPD_STATE, 1) == 1 ? true : false; UeventObserver *observer = Hwcomposer::getInstance().getUeventObserver(); if (observer) { @@ -75,20 +75,21 @@ void PrimaryDevice::deinitialize() void PrimaryDevice::hotplugEventListener(void *data, bool status) { + DTRACE("HDMI Plug State[%s]", status == true ? "Plug" : "UnPlug"); PrimaryDevice *pThis = (PrimaryDevice*)data; if (pThis) { - pThis->hotplugListener(0); - if (status) pThis->mSignalHpd = true; + pThis->mSignalHpd = status; } } void PrimaryDevice::modeChangeEventListener(void *data, bool status) { PrimaryDevice *pThis = (PrimaryDevice*)data; - DTRACE("mode change event: %d", status); + DTRACE("mode state: [%s] display mode.", status == true ? "Begin to change" : "Complete"); - if (status && pThis) { - pThis->changeModeDetectThread(); + if (!status && pThis) { + pThis->setOsdMouse(); + pThis->hotplugListener(pThis->mSignalHpd); } } @@ -143,32 +144,5 @@ int PrimaryDevice::parseConfigFile() return status; } -void PrimaryDevice::changeModeDetectThread() -{ - pthread_t id; - int ret = pthread_create(&id, NULL, changeModeDetect, this); - if (ret != 0) - ETRACE("Create changeModeDetect error!\n"); -} - -void* PrimaryDevice::changeModeDetect(void* data) -{ - PrimaryDevice *pThis = (PrimaryDevice*)data; - bool modeChanged = false; - char lastMode[32]; - Utils::getSysfsStr(SYSFS_DISPLAY_MODE, lastMode); - do { - modeChanged = Utils::checkSysfsStatus(SYSFS_DISPLAY_MODE, lastMode, 32); - usleep(500 * 1000); - } while (!modeChanged); - - if (pThis->mSignalHpd) { - pThis->setOsdMouse(); - pThis->hotplugListener(1); - pThis->mSignalHpd = false; - } - return NULL; -} - } // namespace amlogic } // namespace android diff --git a/hwc2/common/observers/UeventObserver.cpp b/hwc2/common/observers/UeventObserver.cpp index 7f6bbc1..3f458a8 100644 --- a/hwc2/common/observers/UeventObserver.cpp +++ b/hwc2/common/observers/UeventObserver.cpp @@ -212,6 +212,10 @@ void UeventObserver::onUevent() listener->func(listener->data, true); } else if (key.contains(Utils::getSwitchState0())) { listener->func(listener->data, false); + } else if (key.contains(Utils::getSwitchModeState1())) { + listener->func(listener->data, true); + } else if (key.contains(Utils::getSwitchModeState0())) { + listener->func(listener->data, false); } msg += strlen(msg) + 1; } diff --git a/hwc2/common/utils/Utils.cpp b/hwc2/common/utils/Utils.cpp index 4bccd50..ce733b3 100644 --- a/hwc2/common/utils/Utils.cpp +++ b/hwc2/common/utils/Utils.cpp @@ -213,7 +213,7 @@ const char* Utils::getHdcpUeventEnvelope() const char* Utils::getModeChangeUeventEnvelope() { - return "change@/devices/virtual/amhdmitx/amhdmitx0/setmode"; + return "change@/devices/platform/vout/extcon/setmode"; } const char* Utils::getSwitchState0() @@ -226,6 +226,15 @@ const char* Utils::getSwitchState1() return "STATE=HDMI=1"; } +const char* Utils::getSwitchModeState0() +{ + return "STATE=ACA=0"; +} + +const char* Utils::getSwitchModeState1() +{ + return "STATE=ACA=1"; +} bool Utils::rectEmpty(hwc_rect_t& rect) { if ((rect.right - rect.left <= 0) ||(rect.bottom - rect.top <= 0)) diff --git a/hwc2/common/utils/Utils.h b/hwc2/common/utils/Utils.h index f9c782f..5c7824d 100644 --- a/hwc2/common/utils/Utils.h +++ b/hwc2/common/utils/Utils.h @@ -66,6 +66,8 @@ public: static const char* getModeChangeUeventEnvelope(); static const char* getSwitchState0(); static const char* getSwitchState1(); + static const char* getSwitchModeState0(); + static const char* getSwitchModeState1(); template static inline bool compareRect(T a, S b) { diff --git a/hwc2/include/PrimaryDevice.h b/hwc2/include/PrimaryDevice.h index 216f404..423e705 100644 --- a/hwc2/include/PrimaryDevice.h +++ b/hwc2/include/PrimaryDevice.h @@ -53,8 +53,6 @@ private: static void modeChangeEventListener(void *data, bool status); void hotplugListener(bool connected); int parseConfigFile(); - void changeModeDetectThread(); - static void* changeModeDetect(void * data); const char* pConfigPath; int mDisplayType; -- cgit