rkfbsys:mask printk int set_dsp_lut
[firefly-linux-kernel-4.4.55.git] / drivers / video / sh_mobile_hdmi.c
index 6ae40b630dc9eb7c9c39641d4a0d2c27f7f1b1b3..647ba984f00f6b890c0fc7b9960c0ece05c31c9f 100644 (file)
@@ -1111,6 +1111,7 @@ static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate,
 static void sh_hdmi_edid_work_fn(struct work_struct *work)
 {
        struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work);
+       struct fb_info *info;
        struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data;
        struct sh_mobile_lcdc_chan *ch;
        int ret;
@@ -1123,27 +1124,21 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
 
        mutex_lock(&hdmi->mutex);
 
+       info = hdmi->info;
+
        if (hdmi->hp_state == HDMI_HOTPLUG_CONNECTED) {
-               struct fb_info *info = hdmi->info;
                unsigned long parent_rate = 0, hdmi_rate;
 
-               /* A device has been plugged in */
-               pm_runtime_get_sync(hdmi->dev);
-
                ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate);
-               if (ret < 0) {
-                       pm_runtime_put(hdmi->dev);
+               if (ret < 0)
                        goto out;
-               }
 
                hdmi->hp_state = HDMI_HOTPLUG_EDID_DONE;
 
                /* Reconfigure the clock */
                ret = sh_hdmi_clk_configure(hdmi, hdmi_rate, parent_rate);
-               if (ret < 0) {
-                       pm_runtime_put(hdmi->dev);
+               if (ret < 0)
                        goto out;
-               }
 
                msleep(10);
                sh_hdmi_configure(hdmi);
@@ -1155,43 +1150,45 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
 
                ch = info->par;
 
-               console_lock();
+               if (lock_fb_info(info)) {
+                       console_lock();
 
-               /* HDMI plug in */
-               if (!sh_hdmi_must_reconfigure(hdmi) &&
-                   info->state == FBINFO_STATE_RUNNING) {
-                       /*
-                        * First activation with the default monitor - just turn
-                        * on, if we run a resume here, the logo disappears
-                        */
-                       if (lock_fb_info(info)) {
+                       /* HDMI plug in */
+                       if (!sh_hdmi_must_reconfigure(hdmi) &&
+                           info->state == FBINFO_STATE_RUNNING) {
+                               /*
+                                * First activation with the default monitor - just turn
+                                * on, if we run a resume here, the logo disappears
+                                */
                                info->var.width = hdmi->var.width;
                                info->var.height = hdmi->var.height;
                                sh_hdmi_display_on(hdmi, info);
-                               unlock_fb_info(info);
+                       } else {
+                               /* New monitor or have to wake up */
+                               fb_set_suspend(info, 0);
                        }
-               } else {
-                       /* New monitor or have to wake up */
-                       fb_set_suspend(info, 0);
-               }
 
-               console_unlock();
+                       console_unlock();
+                       unlock_fb_info(info);
+               }
        } else {
                ret = 0;
-               if (!hdmi->info)
+               if (!info)
                        goto out;
 
                hdmi->monspec.modedb_len = 0;
                fb_destroy_modedb(hdmi->monspec.modedb);
                hdmi->monspec.modedb = NULL;
 
-               console_lock();
+               if (lock_fb_info(info)) {
+                       console_lock();
 
-               /* HDMI disconnect */
-               fb_set_suspend(hdmi->info, 1);
+                       /* HDMI disconnect */
+                       fb_set_suspend(info, 1);
 
-               console_unlock();
-               pm_runtime_put(hdmi->dev);
+                       console_unlock();
+                       unlock_fb_info(info);
+               }
        }
 
 out:
@@ -1312,7 +1309,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
        INIT_DELAYED_WORK(&hdmi->edid_work, sh_hdmi_edid_work_fn);
 
        pm_runtime_enable(&pdev->dev);
-       pm_runtime_resume(&pdev->dev);
+       pm_runtime_get_sync(&pdev->dev);
 
        /* Product and revision IDs are 0 in sh-mobile version */
        dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n",
@@ -1340,7 +1337,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
 ecodec:
        free_irq(irq, hdmi);
 ereqirq:
-       pm_runtime_suspend(&pdev->dev);
+       pm_runtime_put(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
        iounmap(hdmi->base);
 emap:
@@ -1377,7 +1374,7 @@ static int __exit sh_hdmi_remove(struct platform_device *pdev)
        free_irq(irq, hdmi);
        /* Wait for already scheduled work */
        cancel_delayed_work_sync(&hdmi->edid_work);
-       pm_runtime_suspend(&pdev->dev);
+       pm_runtime_put(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
        clk_disable(hdmi->hdmi_clk);
        clk_put(hdmi->hdmi_clk);