libdrm_meson: expand MESON_CONNECTOR_TYPE Returns the current mode [1/1]
PD#OTT-49973
Problem:
AMMP 4K display mode playback cannot be full screen
Solution:
add api send MESON_CONNECTOR_RESERVED type returns current mode
Verify:
Ah212
Change-Id: I4a3aa5ad76ac21e34a35962b9d58ad6037024986
Signed-off-by: chen.wang1 <chen.wang1@amlogic.com>
diff --git a/meson/meson_drm_settings.c b/meson/meson_drm_settings.c
index f8c01d7..eff843a 100644
--- a/meson/meson_drm_settings.c
+++ b/meson/meson_drm_settings.c
@@ -29,6 +29,8 @@
uint32_t objType, char* name, uint32_t* propValue );
static struct mesonConnector* get_current_connector(int drmFd, MESON_CONNECTOR_TYPE connType);
+static struct mesonConnector* get_default_connector(int drmFd);
+
static int meson_drm_set_property(int drmFd, drmModeAtomicReq *req, uint32_t objId,
uint32_t objType, char* name, uint64_t value);
@@ -235,6 +237,42 @@
return ret;
}
+struct mesonConnector* get_default_connector(int drmFd)
+{
+ struct mesonConnector* connectorHDMI = NULL;
+ struct mesonConnector* connectorLVDS = NULL;
+ struct mesonConnector* connectorCVBS = NULL;
+ int HDMIconnected = 0;
+ int LVDSConnected = 0;
+ int CVBSConnected = 0;
+
+ connectorHDMI = mesonConnectorCreate(drmFd, DRM_MODE_CONNECTOR_HDMIA);
+ if (connectorHDMI)
+ HDMIconnected = mesonConnectorGetConnectState(connectorHDMI);
+ if (HDMIconnected == 1) {
+ return connectorHDMI;
+ } else {
+ mesonConnectorDestroy(drmFd,connectorHDMI);
+ connectorLVDS = mesonConnectorCreate(drmFd, DRM_MODE_CONNECTOR_LVDS);
+ if (connectorLVDS)
+ LVDSConnected = mesonConnectorGetConnectState(connectorLVDS);
+ if (LVDSConnected == 1) {
+ return connectorLVDS;
+ } else {
+ mesonConnectorDestroy(drmFd,connectorLVDS);
+ connectorCVBS = mesonConnectorCreate(drmFd, DRM_MODE_CONNECTOR_TV);
+ if (connectorCVBS)
+ CVBSConnected = mesonConnectorGetConnectState(connectorCVBS);
+ if (CVBSConnected == 1) {
+ return connectorCVBS;
+ } else {
+ mesonConnectorDestroy(drmFd, connectorCVBS);
+ return NULL;
+ }
+ }
+ }
+}
+
int meson_drm_getModeInfo(int drmFd, MESON_CONNECTOR_TYPE connType, DisplayMode* modeInfo)
{
int ret = -1;
@@ -244,7 +282,13 @@
ERROR("%s %d modeInfo == NULL || drmFd < 0 return",__FUNCTION__,__LINE__);
return ret;
}
- conn = get_current_connector(drmFd, connType);
+ if ( connType == MESON_CONNECTOR_RESERVED ) {
+ conn = get_default_connector(drmFd);
+ DEBUG("%s %d get default connector",__FUNCTION__,__LINE__);
+ } else {
+ conn = get_current_connector(drmFd, connType);
+ DEBUG("%s %d get current connector",__FUNCTION__,__LINE__);
+ }
if ( conn ) {
mode = mesonConnectorGetCurMode(drmFd, conn);
if (mode) {
diff --git a/meson/meson_drm_settings_test.c b/meson/meson_drm_settings_test.c
index e7e6cec..f9938b5 100644
--- a/meson/meson_drm_settings_test.c
+++ b/meson/meson_drm_settings_test.c
@@ -31,7 +31,7 @@
printf("get value: 1.HDCP version 2.HDMI connected 3.color space 4. color depth"
"5. hdr mode 6. mode 7. hdr policy 8. EDID 9. hdcp auth status 10.supportedModesList"
" 11.prefer mode 12.HDCP Content Type 13.Content Type 14.Dv Enable 15.active "
- " 16.vrr Enable 17.AVMute 18.Hdrcap 19.DvCap\n");
+ " 16.vrr Enable 17.AVMute 18.Hdrcap 19.DvCap 20.default modeInfo\n");
int get = 0;
int drmFd = meson_open_drm();
int len = scanf("%d", &get);
@@ -152,6 +152,11 @@
// presents the RX dolbyvision capability, [r] such as std or ll mode
int value = meson_drm_getDvCap( drmFd, MESON_CONNECTOR_HDMIA );
printf("\n DvCap:%d\n",value);
+ } else if (get == 20 && len == 1) {
+ DisplayMode mode;
+ if (meson_drm_getModeInfo(drmFd, MESON_CONNECTOR_RESERVED, &mode ) == 0) {
+ printf("\n mode (%d %d %d %d)\n",mode.w, mode.h, mode.vrefresh, mode.interlace);
+ }
}
meson_close_drm(drmFd);
} else if (select_s_g == 0 && select_len == 1) {