libdrm_meson: Add API get TV's ability to support HDCP [1/1]

PD#SWPL-163440

Problem:
App ApI get TV's ability to support HDCP

Solution:
Add APT get TV's ability to support HDCP

Verify:
AH212

Change-Id: I72c8d30f1f8b9b5e2b58375b81a6d3ab0becf537
Signed-off-by: chen.wang1 <chen.wang1@amlogic.com>
diff --git a/meson/meson_drm_settings.c b/meson/meson_drm_settings.c
index 0b223b5..821366f 100644
--- a/meson/meson_drm_settings.c
+++ b/meson/meson_drm_settings.c
@@ -1447,3 +1447,27 @@
     return ret;
 }
 
+int meson_drm_getRxSupportedHdcpVersion( int drmFd, MESON_CONNECTOR_TYPE connType )
+{
+    char propName[PROP_NAME_MAX_LEN] = {'\0'};
+    sprintf( propName, "%s", DRM_CONNECTOR_PROP_RX_HDCP_SUPPORTED_VER);
+    uint32_t value = 0;
+    int prop_value = 0;
+    if ( drmFd < 0) {
+        ERROR("%s %d drmFd < 0",__FUNCTION__,__LINE__);
+        return prop_value;
+    }
+    if ( 0 == meson_drm_get_conn_prop_value( drmFd, connType, propName, &value )) {
+        DEBUG("%s %d get prop_value %d",__FUNCTION__,__LINE__,value);
+        if (value == 14)
+            prop_value = 0x1 << 0;
+        if (value == 22)
+            prop_value = 0x1 << 1;
+        if (value == 36)
+            prop_value = 0x1 | (0x1 << 1);
+    }
+    DEBUG("%s %d return prop_value %d",__FUNCTION__,__LINE__,prop_value);
+    return prop_value;
+}
+
+
diff --git a/meson/meson_drm_settings.h b/meson/meson_drm_settings.h
index 7bbe3d8..55e038b 100644
--- a/meson/meson_drm_settings.h
+++ b/meson/meson_drm_settings.h
@@ -215,6 +215,7 @@
 int meson_drm_getPhysicalSize(int drmFd, uint32_t* width, uint32_t* height, MESON_CONNECTOR_TYPE connType);
 int meson_drm_getSignalTimingInfo(int drmFd, uint16_t* htotal, uint16_t* vtotal, uint16_t* hstart,
                                              uint16_t* vstart, MESON_CONNECTOR_TYPE connType);
+int meson_drm_getRxSupportedHdcpVersion( int drmFd, MESON_CONNECTOR_TYPE connType );
 
 int meson_open_drm();
 void meson_close_drm(int drmFd);
diff --git a/meson/meson_drm_settings_test.c b/meson/meson_drm_settings_test.c
index 5447404..ebdf389 100644
--- a/meson/meson_drm_settings_test.c
+++ b/meson/meson_drm_settings_test.c
@@ -33,7 +33,7 @@
                " 11.prefer mode 12.HDCP Content Type 13.Content Type 14.Dv Enable 15.active "
                " 16.vrr Enable 17.AVMute 18.Hdrcap 19.DvCap 20.default modeInfo 21.current aspect ratio value"
                " 22.frac rate policy 23.hdr force mode 24.dpms status 25.plane size 26.physical size"
-               " 27.Timing information 28.dv mode\n");
+               " 27.Timing information 28.dv mode 29.Rx supported HDCP versions\n");
         int get = 0;
         int drmFd = meson_open_drm();
         int len = scanf("%d", &get);
@@ -231,6 +231,20 @@
             } else {
                 printf("\n get dolby vision mode %d\n",value);
             }
+        } else if (get == 29 && len == 1) {
+            int value = meson_drm_getRxSupportedHdcpVersion( drmFd,MESON_CONNECTOR_HDMIA );
+            if (value & 0x1) {
+               printf("\nRX HDCP 1.4 supported\n");
+               if (value & 0x2) {
+                   printf("RX HDCP 2.2 supported as well\n");
+               } else {
+                   printf("RX HDCP 2.2 not supported\n");
+               }
+           } else {
+               if (!(value & 0x2)) {
+                   printf("\n meson_drm_get_prop fail\n");
+               }
+           }
         }
         meson_close_drm(drmFd);
     } else if (select_s_g == 0 && select_len == 1) {