weston: HDR Priority automatically switches to SDR, which should be HDR [1/1]

PD#SWPL-198032

Problem:
HDR Priority automatically switches to SDR, which should be HDR

Solution:
Modify the setBootEnv judgment criteria

Verify:
S7D

Change-Id: I74bf3f5d0c0092597ae663c24f2b47c962a8d043
Signed-off-by: chen.wang1 <chen.wang1@amlogic.com>
diff --git a/libweston/modepolicy/ModePolicy.cpp b/libweston/modepolicy/ModePolicy.cpp
index f435c40..88956d1 100644
--- a/libweston/modepolicy/ModePolicy.cpp
+++ b/libweston/modepolicy/ModePolicy.cpp
@@ -358,20 +358,25 @@
 }
 
 int32_t ModePolicy::setHdrPriority(int32_t type) {
-    MESON_LOGI("setHdrPriority is [%s]\n", meson_hdrPriorityToString(type));
+    MESON_LOGI("setHdrPriority is [%s] getHdrPriority is [%s]\n", meson_hdrPriorityToString(type),
+            meson_hdrPriorityToString(getHdrPriority()));
 
-    getConnectorData(&mConData, &mDvInfo);
-    meson_mode_set_policy_input(mModeConType, &mConData);
-    getDisplayMode(mCurrentMode);
+    if (getHdrPriority() != type) {
+        getConnectorData(&mConData, &mDvInfo);
+        meson_mode_set_policy_input(mModeConType, &mConData);
+        getDisplayMode(mCurrentMode);
 
-    if (!meson_mode_support_mode(mModeConType, type, mCurrentMode)) {
-        std::string value = std::to_string(type);
+        if (!meson_mode_support_mode(mModeConType, type, mCurrentMode)) {
+            std::string value = std::to_string(type);
 
-        setBootEnv(UBOOTENV_HDR_PRIORITY, value.c_str());
-        setSourceOutputMode(mCurrentMode);
+            setBootEnv(UBOOTENV_HDR_PRIORITY, value.c_str());
+            setSourceOutputMode(mCurrentMode);
+        } else {
+            MESON_LOGD("%s mode check failed", __func__);
+            return -EINVAL;
+        }
     } else {
-        MESON_LOGD("%s mode check failed", __func__);
-        return -EINVAL;
+        MESON_LOGI("setHdrPriority is [%d] and getHdrPriority [%d],They are equals", type, getHdrPriority());
     }
 
     return 0;