meson_display: Development meson_display API for weston [1/1]

PD#SWPL-140347

Problem:
Development meson_display API for weston

Solution:
Development meson_display API for weston

Verify:
AH212

Change-Id: Idf66bd8a5c03d797d4b89cd99d7eaaf10713d439
Signed-off-by: chen.wang1 <chen.wang1@amlogic.com>
diff --git a/display_framework/src/extension/display_settings/display_settings.h b/display_framework/src/extension/display_settings/display_settings.h
index dd3bbf0..45c0df1 100644
--- a/display_framework/src/extension/display_settings/display_settings.h
+++ b/display_framework/src/extension/display_settings/display_settings.h
@@ -174,6 +174,7 @@
 int getDisplayPhysicalSize( int* width, int* height, DISPLAY_CONNECTOR_TYPE connType );
 int getDisplaySignalTimingInfo(uint16_t* htotal, uint16_t* vtotal, uint16_t* hstart,
                                                    uint16_t* vstart, DISPLAY_CONNECTOR_TYPE connType);
+int setDisplayFracMode(int value, DISPLAY_CONNECTOR_TYPE connType);
 int getDisplayCvbsAVMute( );
 int setDisplayCvbsAVMute(bool mute);
 int getDisplayIsBestMode(int* value);
diff --git a/display_framework/src/extension/display_settings/weston/weston_settings.c b/display_framework/src/extension/display_settings/weston/weston_settings.c
index 9582507..4c0bbf9 100644
--- a/display_framework/src/extension/display_settings/weston/weston_settings.c
+++ b/display_framework/src/extension/display_settings/weston/weston_settings.c
@@ -25,52 +25,553 @@
 #define DEFAULT_CARD "/dev/dri/card0"
 #include "libdrm_meson/meson_drm_log.h"
 
-/*                         Interface to be Developed                          */
+#define CMDBUF_SIZE 256
+static int wstDisplaySendMessage(char* property);
+
+static int wstDisplaySendMessage(char* property) {
+    int ret = -1;
+    DEBUG("%s %d send message parameters %s ", __FUNCTION__, __LINE__, property);
+    if (property) {
+        do {
+            char cmdBuf[CMDBUF_SIZE] = {'\0'};
+            snprintf(cmdBuf, sizeof(cmdBuf) - 1, "drm-helper-client %s", property);
+            DEBUG("%s %d Executing '%s' \n", __FUNCTION__, __LINE__, cmdBuf);
+
+            FILE* fp = popen(cmdBuf, "r");
+            if (NULL != fp) {
+                char output[CMDBUF_SIZE] = {'\0'};
+                while (fgets(output, sizeof(output) - 1, fp) != NULL) {
+                    DEBUG("%s %d output: %s\n", __FUNCTION__, __LINE__, output);
+                }
+                ret = 0;
+                pclose(fp);
+            } else {
+                ERROR("%s %d Command execution failed", __FUNCTION__, __LINE__);
+                ret = -1;
+            }
+        } while (ret != 0);
+    } else {
+        ERROR("%s %d Invalid property", __FUNCTION__, __LINE__);
+        ret = -1;
+    }
+    return ret;
+}
 
 int setDisplayHDCPEnable(int enable, DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
+    int ret = -1;
+    int rc = -1;
+    int connId = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    char* prop_name = NULL;
+    connId = meson_drm_GetConnectorId(connType);
+    DEBUG(" %s %d weston set hdcp enable %d connId %d connType %d",__FUNCTION__,__LINE__,
+                                       enable,connId,connType);
+    if (connId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_CONTENT_PROTECTION);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, enable);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+       } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+       }
+    } else {
+        ERROR("%s %d meson_drm_GetConnectorId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
 }
 
 int setDisplayAVMute(int mute, DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
-}
-
-int setDisplayColorSpacedDepth(uint32_t colorDepth, ENUM_DISPLAY_COLOR_SPACE colorSpace,
-                                    DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
-}
-
-int setDisplayHDRPolicy(ENUM_DISPLAY_HDR_POLICY hdrPolicy, DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
+    int ret = -1;
+    int connId = -1;
+    int rc = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    char* prop_name = NULL;
+    connId = meson_drm_GetConnectorId(connType);
+    DEBUG("%s %d weston set mute value %d connId %d connType %d",__FUNCTION__,__LINE__,
+                                      mute,connId,connType);
+    if (connId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_HDMI_ENABLE);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, mute);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+        } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+        }
+    } else {
+        ERROR("%s %d meson_drm_GetConnectorId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
 }
 
 int setDisplayHDCPContentType(ENUM_DISPLAY_HDCP_Content_Type HDCPType, DISPLAY_CONNECTOR_TYPE connType) {
-    return 0;
+    int ret = -1;
+    int rc = -1;
+    int connId = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    char* prop_name = NULL;
+    connId = meson_drm_GetConnectorId(connType);
+    DEBUG(" %s %d weston set hdcp content type %d connId %d connType %d",__FUNCTION__,__LINE__,
+                              HDCPType,connId,connType);
+    if (connId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_HDCP_VERSION);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, HDCPType);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+       } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+       }
+    } else {
+        ERROR("%s %d meson_drm_GetConnectorId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
 }
 
 int setDisplayDvEnable(int dvEnable, DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
+    int ret = -1;
+    int rc = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    uint32_t crtcId = -1;
+    char* prop_name = NULL;
+    crtcId = meson_drm_GetCrtcId(connType);
+    DEBUG(" %s %d weston set DvEnable %d crtcId %d connType %d",__FUNCTION__,__LINE__,
+                                dvEnable,crtcId,connType);
+    if (crtcId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_DOLBY_VISION_ENABLE);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, dvEnable);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+       } else {
+           ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+       }
+    } else {
+        ERROR("%s %d meson_drm_GetCrtcId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
 }
 
 int setDisplayActive(int active, DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
+    int ret = -1;
+    int rc = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    uint32_t crtcId = -1;
+    char* prop_name = NULL;
+    crtcId = meson_drm_GetCrtcId(connType);
+    DEBUG(" %s %d weston set active %d crtcId %d connType %d",__FUNCTION__,__LINE__,
+                              active,crtcId, connType);
+    if (crtcId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_ACTIVE);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, active);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+       } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+       }
+    } else {
+        ERROR("%s %d meson_drm_GetCrtcId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
 }
 
 int setDisplayVrrEnabled(int VrrEnable, DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
+    int ret = -1;
+    int rc = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    uint32_t crtcId = -1;
+    char* prop_name = NULL;
+    crtcId = meson_drm_GetCrtcId(connType);
+    DEBUG(" %s %d weston set VrrEnable %d crtcId %d connType %d",__FUNCTION__,__LINE__,
+                            VrrEnable,crtcId,connType);
+    if ( crtcId > 0 ) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_VRR_ENABLED);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, VrrEnable);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if ( rc >= 0 ) {
+            ret = 0;
+        } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+        }
+    } else {
+        ERROR("%s %d meson_drm_GetCrtcId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
 }
 
 int setDisplayMode(DisplayModeInfo* modeInfo,DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
+    int ret = -1;
+    char modeSet[CMDBUF_SIZE] = {'\0'};
+    DisplayModeInfo* modes = NULL;
+    int count = 0;
+    bool found = false;
+    int rc = -1;
+    int fd = meson_open_drm();
+    if (modeInfo == NULL) {
+        ERROR("%s %d invalid parameter return",__FUNCTION__,__LINE__);
+        goto out;
+    }
+    DEBUG("%s %d weston set modeInfo %dx%d%c%dhz",__FUNCTION__,__LINE__, modeInfo->w, modeInfo->h, (modeInfo->interlace == 0? 'p':'i') , modeInfo->vrefresh);
+    ret = meson_drm_getsupportedModesList(fd, &modes, &count, connType);
+    if (ret != 0) {
+        ERROR("Failed to get supported modes list.\n");
+        goto out;
+    }
+    for (int i = 0; i < count; i++) {
+        if (modes[i].w == modeInfo->w && modes[i].h == modeInfo->h &&
+            modes[i].vrefresh == modeInfo->vrefresh &&
+            modes[i].interlace == modeInfo->interlace) {
+            found = true;
+            break;
+        }
+    }
+    if (!found) {
+        ERROR("The modeInfo is not in the supported modes list.\n");
+        goto out;;
+    } else {
+        DEBUG("The modeInfo is in the supported modes list.\n");
+    }
+
+    snprintf(modeSet, sizeof(modeSet)-1, "-c %dx%d%c@%d", modeInfo->w, modeInfo->h, (modeInfo->interlace == 0? 'p':'i'), modeInfo->vrefresh);
+    rc = wstDisplaySendMessage(modeSet);
+    if ( rc >= 0 ) {
+        ret = 0;
+    } else {
+        ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+    }
+
+out:
+    if (modes) {
+        free(modes);
+    }
+    meson_close_drm(fd);
+    return ret;
+}
+
+int setDisplayDummyMode(DISPLAY_CONNECTOR_TYPE connType) {
+    int ret = -1;
+    char modeSet[CMDBUF_SIZE] = {'\0'};
+    int rc = -1;
+    snprintf(modeSet, sizeof(modeSet)-1, "-c %s", "dummy_l");
+    DEBUG("%s %d weston set mode %s",__FUNCTION__,__LINE__, modeSet);
+    rc = wstDisplaySendMessage(modeSet);
+    if ( rc >= 0 ) {
+        ret = 0;
+    } else {
+        ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+    }
+    return ret;
+}
+
+int setDisplayDvMode(int dvmode,DISPLAY_CONNECTOR_TYPE connType) {
+    int ret = -1;
+    int crtcId = -1;
+    int rc = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    char* prop_name = NULL;
+    crtcId = meson_drm_GetCrtcId(connType);
+    DEBUG("%s %d weston set dv mode %d crtcId %d connType %d",__FUNCTION__,__LINE__,
+                               dvmode,crtcId,connType);
+    if (crtcId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_DV_MODE);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, dvmode);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+        } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+        }
+    } else {
+        ERROR("%s %d meson_drm_GetCrtcId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
+}
+
+int setDisplayCvbsAVMute(bool mute) {
+    int ret = -1;
+    int connId = -1;
+    int rc = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    char* prop_name = NULL;
+    connId = meson_drm_GetConnectorId(MESON_CONNECTOR_CVBS);
+    DEBUG("%s %d weston set cvbs mute value %d connId %d",__FUNCTION__,__LINE__,
+                                      mute,connId);
+    if (connId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_CVBS_PROP_AVMUTE);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, mute);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+        } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+        }
+    } else {
+        ERROR("%s %d meson_drm_GetConnectorId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+}
+
+
+int setDisplayFracMode(int value, DISPLAY_CONNECTOR_TYPE connType) {
+    int ret = -1;
+    int connId = -1;
+    int rc = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    char* prop_name = NULL;
+    connId = meson_drm_GetConnectorId(connType);
+    DEBUG(" %s %d weston set frac rate policy %d connId %d connType %d",__FUNCTION__,__LINE__,
+                                               value, connId, connType);
+    if (connId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_CONNECTOR_FRAC_RATE_POLICY);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, value);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+        } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+        }
+    } else {
+        ERROR("%s %d meson_drm_GetConnectorId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
+}
+
+
+int setDisplayColorSpacedDepth(uint32_t colorDepth, ENUM_DISPLAY_COLOR_SPACE colorSpace,
+                                    DISPLAY_CONNECTOR_TYPE connType) {
+    int ret = -1;
+    int connId = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    char* space_prop_name = NULL;
+    char* depth_prop_name = NULL;
+    struct mesonConnector* conn = NULL;
+    char* str = NULL;
+    switch (colorSpace)
+    {
+        case 0:
+            str = "DISPLAY_COLOR_SPACE_RGB";
+            break;
+        case 1:
+            str = "DISPLAY_COLOR_SPACE_YCBCR422";
+            break;
+        case 2:
+            str = "DISPLAY_COLOR_SPACE_YCBCR444";
+            break;
+        case 3:
+            str = "DISPLAY_COLOR_SPACE_YCBCR420";
+            break;
+        default:
+            str = "DISPLAY_COLOR_SPACE_RESERVED";
+            break;
+    }
+    DEBUG("%s %d weston set colorDepth: %d colorSpace: %s",__FUNCTION__,__LINE__,colorDepth,str);
+    connId = meson_drm_GetConnectorId(connType);
+    if (connId > 0) {
+        space_prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_COLOR_SPACE);
+        depth_prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_COLOR_DEPTH);
+        if (space_prop_name == NULL || depth_prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d depth_prop_name: %s space_prop_name: %s ",__FUNCTION__,__LINE__,depth_prop_name,space_prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d -s \"%s\"=%d", depth_prop_name, colorDepth,space_prop_name, colorSpace);
+        wstDisplaySendMessage(cmdBuf);
+        ret = 0;
+    } else {
+        ERROR("%s %d meson_drm_GetConnectorId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (space_prop_name) {
+        free(space_prop_name);
+    }
+    if (depth_prop_name) {
+        free(depth_prop_name);
+    }
+    return ret;
+}
+
+int setDisplayHDRPolicy(ENUM_DISPLAY_HDR_POLICY hdrPolicy, DISPLAY_CONNECTOR_TYPE connType) {
+    int ret = -1;
+    int crtcId = -1;
+    int rc = -1;
+    char* hdrpolicy_name = NULL;
+    char* force_output_name = NULL;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    ENUM_DISPLAY_FORCE_MODE forcemode = DISPLAY_UNKNOWN_FMT;
+    DEBUG("%s %d weston set hdr policy %d",__FUNCTION__,__LINE__,hdrPolicy);
+    crtcId = meson_drm_GetCrtcId(connType);
+    if (crtcId > 0) {
+        hdrpolicy_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_HDR_POLICY);
+        force_output_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_TX_HDR_OFF);
+        if (hdrpolicy_name == NULL || force_output_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d hdrpolicy_name %s force_output_name %s",__FUNCTION__,__LINE__, hdrpolicy_name,force_output_name);
+        if (hdrPolicy == DISPLAY_HDR_POLICY_FOLLOW_FORCE_MODE) {
+            forcemode = DISPLAY_BT709;
+            snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d -s \"%s\"=%d", hdrpolicy_name, hdrPolicy,force_output_name, forcemode);
+            DEBUG("%s %d hdrPolicy property: %s:%d forcemode property: %s:%d",__FUNCTION__,__LINE__,
+                   hdrpolicy_name, hdrPolicy,force_output_name, forcemode);
+            rc = wstDisplaySendMessage(cmdBuf);
+            if (rc >= 0) {
+                ret = 0;
+            } else {
+                ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+            }
+        } else {
+            forcemode = DISPLAY_UNKNOWN_FMT;
+            snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d -s \"%s\"=%d", hdrpolicy_name, hdrPolicy,force_output_name, forcemode);
+            DEBUG("%s %d hdrPolicy property: %s:%d forcemode property: %s:%d",__FUNCTION__,__LINE__,
+                   hdrpolicy_name, hdrPolicy, force_output_name, forcemode);
+            rc = wstDisplaySendMessage(cmdBuf);
+            if (rc >= 0) {
+                ret = 0;
+            } else {
+                ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+            }
+        }
+    } else {
+        ERROR("%s %d meson_drm_GetCrtcId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (force_output_name) {
+        free(force_output_name);
+    }
+    if (hdrpolicy_name) {
+        free(hdrpolicy_name);
+    }
+    return ret;;
 }
 
 int setDisplayAutoMode(DISPLAY_CONNECTOR_TYPE connType) {
-    return 0;
+    int ret = -1;
+    char modeSet[CMDBUF_SIZE] = {'\0'};
+    int rc = -1;
+    snprintf(modeSet, sizeof(modeSet)-1, "-c %s", "automode");
+    rc = wstDisplaySendMessage(modeSet);
+    if ( rc >= 0 ) {
+        ret = 0;
+    } else {
+        ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+    }
+
+    return ret;
 }
 
 int setDisplayAspectRatioValue(ENUM_DISPLAY_ASPECT_RATIO ASPECTRATIO, DISPLAY_CONNECTOR_TYPE connType) {
-
-    return  0;
+    int ret = -1;
+    int connId = -1;
+    int rc = -1;
+    char cmdBuf[CMDBUF_SIZE] = {'\0'};
+    char* prop_name = NULL;
+    connId = meson_drm_GetConnectorId(connType);
+    DEBUG(" %s %d weston set aspect ratio Value %d connId %d connType %d",__FUNCTION__,__LINE__,
+                                               ASPECTRATIO, connId, connType);
+    if (connId > 0) {
+        prop_name = meson_drm_GetPropName(ENUM_MESON_DRM_PROP_ASPECT_RATIO);
+        if (prop_name == NULL) {
+            ERROR("%s %d meson_drm_GetPropName return NULL",__FUNCTION__,__LINE__);
+            goto out;
+        }
+        DEBUG("%s %d get prop name %s",__FUNCTION__,__LINE__, prop_name);
+        snprintf(cmdBuf, sizeof(cmdBuf)-1, "-s \"%s\"=%d", prop_name, ASPECTRATIO);
+        rc = wstDisplaySendMessage(cmdBuf);
+        if (rc >= 0) {
+            ret = 0;
+        } else {
+            ERROR("%s %d send message fail",__FUNCTION__,__LINE__);
+        }
+    } else {
+        ERROR("%s %d meson_drm_GetConnectorId return fail",__FUNCTION__,__LINE__);
+    }
+out:
+    if (prop_name) {
+        free(prop_name);
+    }
+    return ret;
 }
 
 int setDisplayModeAttr(DisplayModeInfo* modeInfo,uint32_t colorDepth,
@@ -78,20 +579,6 @@
     return  0;
 }
 
-int setDisplayFunctionAttribute( DisplayModeInfo* modeInfo,ENUM_DISPLAY_HDR_POLICY hdrPolicy,uint32_t colorDepth,
-                 ENUM_DISPLAY_COLOR_SPACE colorSpace, int FracRate, DISPLAY_CONNECTOR_TYPE connType) {
-    return  0;
-}
-
-int setDisplayVideoZorder(unsigned int index, unsigned int zorder, unsigned int flag) {
-    return 0;
-}
-
-int setDisplayDvMode(int dvmode,DISPLAY_CONNECTOR_TYPE connType) {
-    return 0;
-}
-
-
 int getDisplayIsBestMode(int* value) {
     return 0;
 }
diff --git a/display_framework/src/extension/display_settings/weston/weston_settings_Test.c b/display_framework/src/extension/display_settings/weston/weston_settings_Test.c
index 3b8261a..3b2e4a9 100644
--- a/display_framework/src/extension/display_settings/weston/weston_settings_Test.c
+++ b/display_framework/src/extension/display_settings/weston/weston_settings_Test.c
@@ -43,21 +43,214 @@
     modeInfo= (DisplayModeInfo*)malloc(sizeof(DisplayModeInfo));
     select_len = scanf("%d",&select_s);
     if (select_s == 0 && select_len == 1) {
-        printf("The current weston set API is not developed\n");
+        printf("set:0->hdmi mode 1->cvbs mode 2->hdr policy 3->av mute 4->HDMI HDCP enable 5-><colorDepth, colorSpace>"
+        "6->HDCP Content Type 7->DvEnable 8->active 9->vrr Enable 10->auto mode 11->dummy mode 12->aspect ratio 13->mode attr"
+        "14->dv mode 15->cvbs video mute 16->frac rate policy\n");
+        len = scanf("%d",&set);
+        if (set == 0 && len == 1) {
+            printf("please input modeInfo: interlace, w, h, vrefresh\n");
+            scanf("%d %d %d %d",&modeInfo->interlace,&modeInfo->w, &modeInfo->h,&modeInfo->vrefresh);
+            if (setDisplayMode(modeInfo, DISPLAY_CONNECTOR_HDMIA) == 0) {
+                printf("\n set mode:%d %d %d %d\n",modeInfo->interlace,modeInfo->w, modeInfo->h, modeInfo->vrefresh);
+            }else{
+                printf("setDisplayModeFail\n");
+            }
+            if (modeInfo) {
+                free(modeInfo);
+            }
+        } else if(set == 1 && len == 1) {
+            printf("please input modeInfo:interlace, w, h, vrefresh\n");
+            scanf("%d %d %d %d",&modeInfo->interlace,&modeInfo->w, &modeInfo->h,&modeInfo->vrefresh);
+            if (setDisplayMode(modeInfo, DISPLAY_CONNECTOR_CVBS) == 0) {
+                printf("\n mode:%d %d %d %d\n",modeInfo->interlace,modeInfo->w, modeInfo->h, modeInfo->vrefresh);
+            } else {
+                printf("setDisplayModeFail\n");
+            }
+            if (modeInfo) {
+                free(modeInfo);
+            }
+        }else if (set == 2 && len == 1) {
+            /*
+            * setDisplayHDRPolicy API hdrPolicy Parameter Description
+            * hdrPolicy 2  <-- HDR OFF -->
+            * hdrPolicy 0,  <--Always HDR-->
+            * hdrPolicy 1,  <--Adaptive HDR-->
+            */
+            printf("0->set Always Hdr 1->set Adaptive Hdr 2->set force mode\n");
+            int Policy = 0;
+            scanf("%d",&Policy);
+            if (Policy == 0) {
+                if (setDisplayHDRPolicy(DISPLAY_HDR_POLICY_FOLLOW_SINK, DISPLAY_CONNECTOR_HDMIA) == 0) {
+                    printf("set always hdr success\n");
+                } else {
+                    printf("set always hdr fail\n");
+                }
+            } else if (Policy == 1) {
+                if (setDisplayHDRPolicy(DISPLAY_HDR_POLICY_FOLLOW_SOURCE, DISPLAY_CONNECTOR_HDMIA) == 0) {
+                    printf("set adaptive hdr success\n");
+                } else {
+                    printf("set adaptive hdr fail\n");
+                }
+            } else if (Policy == 2) {
+                if (setDisplayHDRPolicy(DISPLAY_HDR_POLICY_FOLLOW_FORCE_MODE, DISPLAY_CONNECTOR_HDMIA) == 0) {
+                    printf("set force mode success\n");
+                } else {
+                    printf("set force mode fail\n");
+                }
+            }
+        } else if(set == 3 && len == 1){
+            printf("\n AVMUTE:\n");
+            int avmute = 0;
+            len = scanf("%d", &avmute);
+            if (len == 1) {
+                if (setDisplayAVMute(avmute, DISPLAY_CONNECTOR_HDMIA))
+                    printf("\n setDisplayAVMute fail\n");
+            } else {
+                printf("\n scanf fail\n");
+            }
+        } else if (set == 4 && len == 1) {
+            printf("\n 1-HDCP enable:\n");
+            int hdcpEnable = 0;
+            len = scanf("%d", &hdcpEnable);
+            if (len == 1) {
+                if (setDisplayHDCPEnable(hdcpEnable, DISPLAY_CONNECTOR_HDMIA)) {
+                    printf("\n setDisplayHDCPEnable fail\n");
+                } else {
+                    printf("\n setDisplayHDCPEnable success\n");
+                }
+            } else {
+                    printf("\n scanf fail\n");
+            }
+        } else if (set == 5 && len == 1) {
+            uint32_t colorSpace = 0;
+            uint32_t colorDepth = 0;
+            printf("\n Please set <colorDepth, colorSpace> property value:\n");
+            scanf("%d %d", &colorDepth,&colorSpace);
+            int ret = setDisplayColorSpacedDepth(colorDepth, colorSpace, DISPLAY_CONNECTOR_HDMIA);
+            if (ret == 0) {
+                printf("\n set <colorDepth, colorSpace> Success!\n");
+            } else {
+                printf("\n set value Fail!\n");
+            }
+        } else if (set == 6 && len == 1) {
+            printf("\n HDCP Content Type:\n");
+            int HDCPContentType = 0;
+            len = scanf("%d", &HDCPContentType);
+            if (len == 1) {
+                if (setDisplayHDCPContentType(HDCPContentType, DISPLAY_CONNECTOR_HDMIA))
+                    printf("\n setDisplayHDCPContentType fail:\n");
+            } else {
+                    printf("\n scanf fail\n");
+            }
+        } else if (set == 7 && len == 1) {
+            printf("\n DvEnable:\n");
+            int dvEnable = 0;
+            len = scanf("%d", &dvEnable);
+            if (len == 1) {
+                if (setDisplayDvEnable(dvEnable, DISPLAY_CONNECTOR_HDMIA))
+                    printf("\n setDisplayDvEnable fail:\n");
+            } else {
+                    printf("\n scanf fail\n");
+            }
+        } else if (set == 8 && len == 1) {
+            printf("\n Active:\n");
+            int active = 0;
+            len = scanf("%d", &active);
+            if (len == 1) {
+                if (setDisplayActive( active, DISPLAY_CONNECTOR_HDMIA))
+                    printf("\n setDisplayActive fail:\n");
+            } else {
+                    printf("\n scanf fail\n");
+            }
+        } else if (set == 9 && len == 1) {
+            printf("\n vrr Enable:\n");
+            int vrrEnable = 0;
+            len = scanf("%d", &vrrEnable);
+            if (len == 1) {
+                if (setDisplayVrrEnabled( vrrEnable, DISPLAY_CONNECTOR_HDMIA))
+                    printf("\n setDisplayVrrEnabled fail:\n");
+            } else {
+                printf("\n scanf fail\n");
+            }
+        } else if (set == 10 && len == 1) {
+             if (0 == setDisplayAutoMode(DISPLAY_CONNECTOR_HDMIA)) {
+                printf("Successfully set the optimal resolution!\n");
+            } else {
+                printf("scanf fail\n");
+            }
+       } else if (set == 11 && len == 1) {
+            if (setDisplayDummyMode(DISPLAY_CONNECTOR_DUMMY) == 0) {
+                printf("\n set dummy mode success\n");
+            } else {
+                printf("set dummy mode fail\n");
+            }
+            if (modeInfo) {
+                free(modeInfo);
+            }
+        } else if (set == 12 && len == 1 ) {
+            printf("\n aspect ratio:\n");
+            int ASPECTRATIO =-1;
+            scanf("%d",&ASPECTRATIO);
+            int value = getDisplayAspectRatioValue( DISPLAY_CONNECTOR_HDMIA );
+            if (value == 0) {
+                printf("\n current mode do not support aspect ratio change\n"); //automatic
+            } else {
+                if (ASPECTRATIO == 1 && value == 2) {
+                    if (0 == setDisplayAspectRatioValue(ASPECTRATIO, DISPLAY_CONNECTOR_HDMIA))
+                        printf("\n aspect ratio 4:3 set success\n");
+                } else if (ASPECTRATIO == 2 && value == 1) {
+                    if (0 == setDisplayAspectRatioValue(ASPECTRATIO, DISPLAY_CONNECTOR_HDMIA))
+                        printf("\n aspect ratio 16:9 set success\n");
+                } else {
+                    printf("\n aspect ratio invalid\n");
+                }
+            }
+        } else if (set == 13 && len == 1) {
+            printf("The current weston set API is not developed\n");
+        } else if (set == 14 && len == 1) {
+            printf("dvmode: \n");
+            int dvmode = -1;
+            scanf("%d", &dvmode);
+            if (setDisplayDvMode(dvmode,DISPLAY_CONNECTOR_HDMIA) == 0) {
+                printf("\n setDisplayDvMode Success\n");
+            }else{
+                printf("setDisplayDvMode Fail\n");
+            }
+        } else if(set == 15 && len == 1){
+            printf("\n cvbs avmute:\n");
+            int mute = 0;
+            len = scanf("%d", &mute);
+            if (len == 1) {
+                if (setDisplayCvbsAVMute(mute))
+                    printf("\n setDisplayCvbsAVMute fail:\n");
+            } else {
+                printf("\n scanf fail\n");
+            }
+        } else if (set == 16 && len == 1) {
+            printf("frac rate policy value: \n");
+            int fracrate = -1;
+            scanf("%d", &fracrate);
+            if (setDisplayFracMode(fracrate,DISPLAY_CONNECTOR_HDMIA) == 0) {
+                printf("\n setDisplayFracMode Success\n");
+            }else{
+                printf("setDisplayFracMode Fail\n");
+            }
+        }
     }
     else if(select_s == 1 && select_len == 1) {
         printf("get:0->hdrPolicy 1->modeinfo 2->HDCP version 3->HDMI connected 4->color depth 5->color space"
          " 6->EDID 7->hdcp auth status 8->supportedModesList 9->prefer mode 10->HDCP Content Type 11->Content Type"
          " 12->Dv Enable 13->active 14->vrr Enable 15->av mute 16->hdr mode 17->CvbsModesList 18-> mode support check"
-         "19->current aspect ratio 20->event test 21->frac rate policy 22->scaling 23->Supported dvmode"
-         " 24->hdr supportedlist 25->DvCap 26->display enabled 27->dpms status 28->mode support attrlist 29->framrate"
-         " 30->primar plane fb size 31->physical size 32->Timing information 33->dv mode 34->rx supported hdcp version "
-         " 35->cvbs video mute\n");
+         " 19->current aspect ratio 20->event test 21->frac rate policy 22->Supported dvmode 23->hdr supportedlist"
+         " 24->DvCap 25->dpms status 26->mode support attrlist 27->framrate 28->primar plane fb size "
+         " 29>physical size 30->Timing information 31->dv mode 32->rx supported hdcp version 33->cvbs video mute "
+         " 34->frac rate policy\n");
         len = scanf("%d",&get);
         if (get == 0 && len == 1) {
             ENUM_DISPLAY_HDR_POLICY value = getDisplayHDRPolicy( DISPLAY_CONNECTOR_HDMIA);
             printf("\n DISPLAY_HDR_POLICY_FOLLOW_SINK = 0 \n"
-            "DISPLAY_HDR_POLICY_FOLLOW_SOURCE = 1 \n  value:%d\n", value);
+                   "DISPLAY_HDR_POLICY_FOLLOW_SOURCE = 1 \n"
+                   "DISPLAY_HDR_POLICY_FOLLOW_FORCE_MODE = 2 \n value:%d\n", value);
        } else if(get == 1 && len == 1) {
             if (getDisplayMode( modeInfo, DISPLAY_CONNECTOR_HDMIA) == 0) {
                 printf("\n mode (%d %d %d %d)\n",modeInfo->interlace,modeInfo->w, modeInfo->h, modeInfo->vrefresh);
@@ -219,11 +412,9 @@
                 printf("\n FracRate: %d\n",value);
             }
         } else if (get == 22 && len == 1) {
-            printf("The current weston set API is not developed\n");
-        } else if (get == 23 && len == 1) {
             int value = getDisplaySupportedDvMode(DISPLAY_CONNECTOR_HDMIA);
             printf("getDisplaySupportedDvMode %d\n",value);
-        } else if (get == 24 && len == 1) {
+        } else if (get == 23 && len == 1) {
             uint32_t value  = getDisplayHDRSupportList(DISPLAY_CONNECTOR_HDMIA);
             printf("\n value %d\n",value);
             if (value & 0x1)
@@ -240,19 +431,17 @@
                 printf("\n MESON_DRM_HDR_HLG\n");
             if (value & 0x40)
                 printf("\n MESON_DRM_SDR\n");
-       } else if (get == 25 && len == 1) {
+       } else if (get == 24 && len == 1) {
             int value = getDisplayDvCap( DISPLAY_CONNECTOR_HDMIA );
             if (value == 0) {
                 printf("The Rx don't support DolbyVision\n");
             } else {
                 printf("\n DvCap:%d\n",value);
             }
-        } else if (get == 26 && len == 1) {
-           printf("The current weston set API is not developed\n");
-        } else if (get == 27 && len == 1) {
+        } else if (get == 25 && len == 1) {
             int value = getDisplayDpmsStatus( DISPLAY_CONNECTOR_HDMIA );
             printf("\n get dpms status: %d\n",value);
-        } else if(get == 28 && len == 1) {
+        } else if(get == 26 && len == 1) {
             int num = getDisplaySupportAttrList( modeInfo, DISPLAY_CONNECTOR_HDMIA);
             if (num == 0) {
                 printf("\n getDisplaySupportAttrList Success");
@@ -261,10 +450,10 @@
             }
             if (modeInfo)
                 free(modeInfo);
-        } else if(get == 29 && len == 1) {
+        } else if(get == 27 && len == 1) {
             float value = getDisplayFrameRate( DISPLAY_CONNECTOR_HDMIA);
             printf("\n get framrate %.2f",value);
-        } else if(get == 30 && len == 1) {
+        } else if(get == 28 && len == 1) {
             int width = 0;
             int height = 0;
             int value = getDisplayPlaneSize( &width,&height );
@@ -273,7 +462,7 @@
            } else {
                printf("\n getDisplayPlaneSize fail\n");
            }
-        } else if(get == 31 && len == 1) {
+        } else if(get == 29 & len == 1) {
             int width = 0;
             int height = 0;
             int value  = getDisplayPhysicalSize( &width, &height, DISPLAY_CONNECTOR_HDMIA );
@@ -282,7 +471,7 @@
            } else {
                printf("\n getDisplayPhysicalSize fail\n");
            }
-        } else if(get ==32 && len == 1) {
+        } else if(get ==30 && len == 1) {
            uint16_t htotal = 0;
            uint16_t vtotal = 0;
            uint16_t hstart = 0;
@@ -293,14 +482,14 @@
             } else {
                 printf("\n getDisplaySignalTimingInfo fail\n");
             }
-        } else if (get == 33 && len == 1) {
+        } else if (get == 31 && len == 1) {
             int value = getDisplayDvMode( DISPLAY_CONNECTOR_HDMIA );
             if (value == -1) {
                 printf("\n get dv mode fail\n");
             } else  {
                 printf("\n get dv mode value: %d\n",value);
             }
-        } else if (get == 34 && len == 1) {
+        } else if (get == 32 && len == 1) {
             int value = getDisplayRxSupportedHdcpVersion(DISPLAY_CONNECTOR_HDMIA );
             if (value & 0x1) {
                printf("\nRX HDCP 1.4 supported \n");
@@ -314,7 +503,10 @@
                    printf("\n get_prop fail\n");
                }
            }
-        } else if (get == 36 && len == 1) {
+        } else if (get == 33 && len == 1) {
+            int value = getDisplayCvbsAVMute( DISPLAY_CONNECTOR_CVBS );
+            printf("\n cvbs video mute:%d\n",value);
+        } else if (get == 34 && len == 1) {
             int value = getDisplayCvbsAVMute( DISPLAY_CONNECTOR_CVBS );
             printf("\n cvbs video mute:%d\n",value);
         }
@@ -325,4 +517,3 @@
     return 0;
 }
 
-