From: Sandor Yu Date: Mon, 21 May 2018 02:41:08 +0000 (+0800) Subject: MLK-18355-5: hdmi_rx: Add timeout for check HDMI 5V X-Git-Tag: rel_imx_4.19.35_1.1.0~737 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=e30bbfc6a2d3e94dcfba8ef6222e8bdfcc312bba;p=linux.git MLK-18355-5: hdmi_rx: Add timeout for check HDMI 5V Add timeout for HDMI 5V check. Signed-off-by: Sandor Yu --- diff --git a/drivers/media/platform/imx8/hdmi/mxc-hdmi-hw.c b/drivers/media/platform/imx8/hdmi/mxc-hdmi-hw.c index f524f7bcda35..0e1526522550 100644 --- a/drivers/media/platform/imx8/hdmi/mxc-hdmi-hw.c +++ b/drivers/media/platform/imx8/hdmi/mxc-hdmi-hw.c @@ -273,6 +273,7 @@ int hdmirx_startup(state_struct *state) struct mxc_hdmi_rx_dev *hdmi_rx = state_to_mxc_hdmirx(state); S_HDMI_SCDC_GET_MSG *scdcData = &hdmi_rx->scdcData; u8 ret = 0; + u32 i; /* Start from TMDS/pixel clock ratio of 1:1. * It affects only pixel clock frequency as the character/data clocks are generated based on @@ -308,11 +309,23 @@ int hdmirx_startup(state_struct *state) CDN_API_HDMIRX_SetHpd_blocking(state, 0); dev_dbg(&hdmi_rx->pdev->dev, "Clear HDP\n"); - /* Wait for 5v */ - while ((event5V & (1 << HDMI_RX_EVENT_5V_VAL)) == 0) { + /* check for 5v to get hdmi cable state */ + CDN_API_HDMIRX_ReadEvent(state, &event5V); + dev_dbg(&hdmi_rx->pdev->dev, "event5V = 0x%02X\n", event5V); + for (i = 0; i < 5; i++) { + if (event5V & (1 << HDMI_RX_EVENT_5V_VAL)) { + dev_info(&hdmi_rx->pdev->dev, "HDMI 5V present\n"); + break; + } + msleep(20); CDN_API_HDMIRX_ReadEvent(state, &event5V); dev_dbg(&hdmi_rx->pdev->dev, "event5V = 0x%02X\n", event5V); } + if (i == 5) { + dev_info(&hdmi_rx->pdev->dev, "No HDMI 5V present!!!\n"); + return -1; + } + /* Got 5v, set hpd */ msleep(100); /* provide minimum low pulse length (100ms) */ CDN_API_HDMIRX_SetHpd_blocking(state, 1); @@ -409,6 +422,5 @@ int hdmirx_startup(state_struct *state) CDN_API_HDMIRX_Init_blocking(state); dev_dbg(&hdmi_rx->pdev->dev, "CDN_API_HDMIRX_Init_blocking() complete.\n"); - return 0; }