MLK-19990-1: hdmi rx: enable low power mode for cable plugout
authorSandor Yu <Sandor.yu@nxp.com>
Fri, 19 Oct 2018 07:22:31 +0000 (15:22 +0800)
committerSandor Yu <Sandor.yu@nxp.com>
Fri, 19 Apr 2019 02:40:50 +0000 (10:40 +0800)
-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 <Sandor.yu@nxp.com>
drivers/media/platform/imx8/hdmi/mxc-hdmi-hw.c
drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c
drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h

index c7c8ed9..41dec48 100644 (file)
@@ -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)
index cb2e2de..449f10f 100644 (file)
@@ -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");
index 4ba9ba5..11afb99 100644 (file)
@@ -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);