From: Sandor Yu Date: Fri, 19 Oct 2018 07:22:31 +0000 (+0800) Subject: MLK-19990-1: hdmi rx: enable low power mode for cable plugout X-Git-Tag: rel_imx_4.19.35_1.1.0~724 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=43d0c337fbe5a26c14de505293ea6810881ca135;p=linux.git MLK-19990-1: hdmi rx: enable low power mode for cable plugout -HDMI RX controller enter low power mode when cable plug out. -Replace CDN_API_HDMIRX_ReadEvent with CDN_API_General_GetHpdState_blocking, hdmi rx could enter low power mode. 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 c7c8ed9fc886..41dec480d86a 100644 --- a/drivers/media/platform/imx8/hdmi/mxc-hdmi-hw.c +++ b/drivers/media/platform/imx8/hdmi/mxc-hdmi-hw.c @@ -324,28 +324,9 @@ int hdmirx_init(state_struct *state) return ret; } -int hdmirx_check5v(state_struct *state) +int hdmirx_get_hpd_state(state_struct *state, u8 *hpd) { - struct mxc_hdmi_rx_dev *hdmi_rx = state_to_mxc_hdmirx(state); - u8 event5V = 0; - u32 i; - - /* check for 5v to get hdmi cable state */ - CDN_API_HDMIRX_ReadEvent(state, &event5V); - for (i = 0; i < 5; i++) { - if (event5V & (1 << HDMI_RX_EVENT_5V_VAL)) { - dev_dbg(&hdmi_rx->pdev->dev, "HDMI 5V present\n"); - break; - } - msleep(20); - CDN_API_HDMIRX_ReadEvent(state, &event5V); - } - if (i == 5) { - dev_dbg(&hdmi_rx->pdev->dev, "No HDMI 5V present!!!\n"); - return -1; - } - - return 0; + return CDN_API_General_GetHpdState_blocking(state, hpd); } void hdmirx_hotplug_trigger(state_struct *state) diff --git a/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c b/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c index cb2e2de07dfc..449f10f2ec92 100644 --- a/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c +++ b/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c @@ -714,12 +714,15 @@ static void hpd5v_work_func(struct work_struct *work) hpd5v_work.work); char event_string[32]; char *envp[] = { event_string, NULL }; - int hpd5v; + u8 sts; + u8 hpd; /* Check cable states before enable irq */ - hpd5v = hdmirx_check5v(&hdmi_rx->state); - if (hpd5v == 0) { + hdmirx_get_hpd_state(&hdmi_rx->state, &hpd); + if (hpd == 1) { pr_info("HDMI RX Cable Plug In\n"); + + CDN_API_MainControl_blocking(&hdmi_rx->state, 1, &sts); hdmirx_hotplug_trigger(&hdmi_rx->state); hdmirx_startup(&hdmi_rx->state); enable_irq(hdmi_rx->irq[HPD5V_IRQ_OUT]); @@ -731,7 +734,7 @@ static void hpd5v_work_func(struct work_struct *work) imx_cec_register(&hdmi_rx->cec); } #endif - } else { + } else if (hpd == 0){ pr_info("HDMI RX Cable Plug Out\n"); hdmirx_stop(&hdmi_rx->state); #ifdef CONFIG_IMX_HDP_CEC @@ -743,7 +746,10 @@ static void hpd5v_work_func(struct work_struct *work) sprintf(event_string, "EVENT=hdmirxout"); kobject_uevent_env(&hdmi_rx->pdev->dev.kobj, KOBJ_CHANGE, envp); enable_irq(hdmi_rx->irq[HPD5V_IRQ_IN]); - } + CDN_API_MainControl_blocking(&hdmi_rx->state, 0, &sts); + } else + pr_warn("HDMI RX Cable State unknow\n"); + } #define HOTPLUG_DEBOUNCE_MS 200 @@ -764,8 +770,8 @@ static int mxc_hdmi_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct mxc_hdmi_rx_dev *hdmi_rx; struct resource *res; + u8 hpd; int ret = 0; - int hpd5v; dev_dbg(dev, "%s\n", __func__); hdmi_rx = devm_kzalloc(dev, sizeof(*hdmi_rx), GFP_KERNEL); @@ -856,7 +862,7 @@ static int mxc_hdmi_probe(struct platform_device *pdev) } /* Check cable states before enable irq */ - hpd5v = hdmirx_check5v(&hdmi_rx->state); + hdmirx_get_hpd_state(&hdmi_rx->state, &hpd); /* Enable Hotplug Detect IRQ thread */ if (hdmi_rx->irq[HPD5V_IRQ_IN] > 0) { @@ -870,7 +876,7 @@ static int mxc_hdmi_probe(struct platform_device *pdev) goto failed; } /* Cable Disconnedted, enable Plug in IRQ */ - if (hpd5v < 0) + if (hpd == 0) enable_irq(hdmi_rx->irq[HPD5V_IRQ_IN]); } if (hdmi_rx->irq[HPD5V_IRQ_OUT] > 0) { @@ -883,7 +889,7 @@ static int mxc_hdmi_probe(struct platform_device *pdev) hdmi_rx->irq[HPD5V_IRQ_OUT]); goto failed; } - if (hpd5v == 0) { + if (hpd == 1) { hdmirx_hotplug_trigger(&hdmi_rx->state); hdmirx_startup(&hdmi_rx->state); /* Cable Connected, enable Plug out IRQ */ @@ -891,7 +897,6 @@ static int mxc_hdmi_probe(struct platform_device *pdev) } } - mxc_hdmi_rx_register_audio_driver(dev); dev_info(dev, "iMX8 HDMI RX probe successfully\n"); diff --git a/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h b/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h index 4ba9ba59028d..11afb99a74d5 100644 --- a/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h +++ b/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h @@ -143,7 +143,7 @@ void hdmirx_hotplug_trigger(state_struct *state); void hdmirx_phy_pix_engine_reset(state_struct *state); int hdmirx_startup(state_struct *state); int hdmirx_init(state_struct *state); -int hdmirx_check5v(state_struct *state); +int hdmirx_get_hpd_state(state_struct *state, u8 *hpd); int mxc_hdmi_frame_timing(struct mxc_hdmi_rx_dev *hdmi_rx); void mxc_hdmi_rx_register_audio_driver(struct device *dev); void imx8qm_hdmi_phy_reset(state_struct *state, u8 reset);