meson_display: add api for setting display mode and deepcolor [1/1]

PD#OTT-50879

Problem:
add api for setting display mode and deepcolor.

Solution:
add an api that can set mode and attr all at once

Verify:
AP222

Change-Id: I1356c2e69412e286c0bf52a27f640c68e22bfcda
Signed-off-by: chen.wang1 <chen.wang1@amlogic.com>
diff --git a/display_framework/src/extension/display_settings/display_settings.c b/display_framework/src/extension/display_settings/display_settings.c
index 376307e..d0fa79b 100644
--- a/display_framework/src/extension/display_settings/display_settings.c
+++ b/display_framework/src/extension/display_settings/display_settings.c
@@ -930,4 +930,56 @@
     return  ret;
 }
 
+int setDisplayModeAttr(DisplayModeInfo* modeInfo,uint32_t colorDepth,

+                     ENUM_DISPLAY_COLOR_SPACE colorSpace,DISPLAY_CONNECTOR_TYPE connType) {
+    int SupportedCheck = -1;
+    int changeModeNum = -1;
+    int ColorDepthNum = -1;
+    int ColorSpaceNum = -1;
+    int ret = -1;
+    int fd = 0;
+    drmModeAtomicReq *req = NULL;
+    if (modeInfo == NULL || modeInfo->name == NULL) {
+        ERROR("%s %d invalid parameter return",__FUNCTION__,__LINE__);
+        return ret;
+    }
+    DEBUG("%s %d modeName: %s colorSpace: %d,colorDepth: %d,connType: %d",__FUNCTION__,__LINE__,
+                   modeInfo->name, colorSpace,colorDepth,connType);
+    SupportedCheck = modeAttrSupportedCheck(modeInfo->name, colorSpace,colorDepth, connType );
+    if (SupportedCheck == 0) {
+        ERROR(" %s %d Mode Attr SupportedCheck Fail",__FUNCTION__,__LINE__);
+        return ret;
+    } else {
+        DEBUG("%s %d Mode Attr SupportedCheck Success",__FUNCTION__,__LINE__);
+    }
+    fd = display_meson_set_open();
+    req = drmModeAtomicAlloc();
+    if (req == NULL) {
+        DEBUG("%s %d invalid parameter return",__FUNCTION__,__LINE__);
+        goto out;
+    }
+    DEBUG("%s %d modeInfo %dx%d%s%dhz,colorSpace: %d,colorDepth: %d,connType: %d",__FUNCTION__,__LINE__,
+            modeInfo->w,modeInfo->h,(modeInfo->interlace == 0? "p":"i"),modeInfo->vrefresh,colorSpace,
+                   colorDepth,connType);
+    changeModeNum = meson_drm_changeMode(fd, req, modeInfo, connType);
+    ColorDepthNum = meson_drm_setColorDepth(fd, req, colorDepth, connType);
+    ColorSpaceNum = meson_drm_setColorSpace(fd, req, colorSpace, connType);
+    if (changeModeNum == -1 || ColorDepthNum == -1 || ColorSpaceNum == -1) {
+        ERROR("%s %d fail parameter return",__FUNCTION__,__LINE__);
+        goto out;
+    }
+    ret = drmModeAtomicCommit(fd, req, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+    if (ret) {
+        ERROR("%s %d drmModeAtomicCommit failed: ret %d errno %d", __FUNCTION__,__LINE__, ret, errno );
+        goto out;
+    }
+
+out:
+    if (req) {
+        drmModeAtomicFree(req);
+        req = NULL;
+    }
+    display_meson_close(fd);
+    return  ret;
+}
 
diff --git a/display_framework/src/extension/display_settings/display_settings.h b/display_framework/src/extension/display_settings/display_settings.h
index 7cacd76..19f304d 100644
--- a/display_framework/src/extension/display_settings/display_settings.h
+++ b/display_framework/src/extension/display_settings/display_settings.h
@@ -136,6 +136,8 @@
 int setDisplayVideoZorder(  unsigned int index, unsigned int zorder, unsigned int flag);
 ENUM_DISPLAY_ASPECT_RATIO getDisplayAspectRatioValue(DISPLAY_CONNECTOR_TYPE connType );
 int setDisplayAspectRatioValue(ENUM_DISPLAY_ASPECT_RATIO ASPECTRATIO, DISPLAY_CONNECTOR_TYPE connType);
+int setDisplayModeAttr(DisplayModeInfo* modeInfo,uint32_t colorDepth,

+                     ENUM_DISPLAY_COLOR_SPACE colorSpace,DISPLAY_CONNECTOR_TYPE connType);

 
 int display_meson_get_open();
 int display_meson_set_open();
diff --git a/display_framework/src/extension/display_settings/display_settings_Test.c b/display_framework/src/extension/display_settings/display_settings_Test.c
index b1b8362..54a9589 100644
--- a/display_framework/src/extension/display_settings/display_settings_Test.c
+++ b/display_framework/src/extension/display_settings/display_settings_Test.c
@@ -42,7 +42,8 @@
     select_len = scanf("%d",&select_s);
     if (select_s == 0 && select_len == 1) {
         printf("set:0->hdmi mode 1->cvbs mode 2->event test 3->hdr policy 4->av mute 5->HDMI HDCP enable 6-><colorDepth, colorSpace>"
-        "7->HDCP Content Type  8->DvEnable 9->active 10->vrr Enable 11->auto mode 12->dummy mode 13->video zorder 14->aspect ratio\n");
+        "7->HDCP Content Type  8->DvEnable 9->active 10->vrr Enable 11->auto mode 12->dummy mode 13->video zorder 14->aspect ratio"
+        "15->mode attr\n");
         len = scanf("%d",&set);
         if (set == 0 && len == 1) {
             printf("please input modeInfo:interlace, w, h, vrefresh\n");
@@ -198,6 +199,20 @@
                     printf("\n aspect ratio invalid\n");
                 }
             }
+        } else if (set == 15 && len == 1) {
+                uint32_t colorSpace = 0;
+                uint32_t colorDepth = 0;
+                printf("\n modeInfos: interlace, w, h, vrefresh colorDepth, colorSpace, modename: ");
+                scanf("%d %d %d %d %d %d %s",&modeInfo->interlace,&modeInfo->w, &modeInfo->h,&modeInfo->vrefresh,
+                                     &colorDepth,&colorSpace,modeInfo->name);
+                printf("modename:%s modeinfo: %dx%d%s%dhz %d %d",modeInfo->name,modeInfo->w, modeInfo->h,
+                        (modeInfo->interlace == 0? "p":"i") ,modeInfo->vrefresh, colorDepth, colorSpace);
+                int ret = setDisplayModeAttr(modeInfo, colorDepth, colorSpace, DISPLAY_CONNECTOR_HDMIA);
+                if (ret == 0) {
+                    printf("\n setDisplayModeAttr Success!\n");
+                } else {
+                    printf("\n setDisplayModeAttr Fail!\n");
+                }
         }
     }
     else if(select_s == 1 && select_len == 1) {