rk30 hdmi: support switch class to detect hotplug status.
authorZheng Yang <zhengyang@rock-chips.com>
Wed, 2 May 2012 03:49:51 +0000 (11:49 +0800)
committerZheng Yang <zhengyang@rock-chips.com>
Wed, 2 May 2012 03:49:51 +0000 (11:49 +0800)
drivers/video/rockchip/hdmi/rk30_hdmi.c
drivers/video/rockchip/hdmi/rk30_hdmi.h
drivers/video/rockchip/hdmi/rk30_hdmi_task.c

index c0038bf0274cfff364e312e6c0ed83050389b00d..ef50f282d87a172c269eceedf961391b9d1264ea 100755 (executable)
@@ -154,10 +154,13 @@ static int __devinit rk30_hdmi_probe (struct platform_device *pdev)
        hdmi->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 10;\r
        register_early_suspend(&hdmi->early_suspend);\r
        #endif\r
-       \r
-       \r
+               \r
        hdmi_register_display_sysfs(hdmi, hdmi->dev);\r
-       \r
+       #ifdef CONFIG_SWITCH\r
+       hdmi->switch_hdmi.name="hdmi";\r
+       switch_dev_register(&(hdmi->switch_hdmi));\r
+       #endif\r
+               \r
        spin_lock_init(&hdmi->irq_lock);\r
        mutex_init(&hdmi->enable_mutex);\r
        \r
@@ -180,9 +183,12 @@ static int __devinit rk30_hdmi_probe (struct platform_device *pdev)
        hdmi_dbg(hdmi->dev, "rk30 hdmi probe sucess.\n");\r
        return 0;\r
 err2:\r
-#ifdef CONFIG_HAS_EARLYSUSPEND\r
+       #ifdef CONFIG_SWITCH\r
+       switch_dev_unregister(&(hdmi->switch_hdmi));\r
+       #endif\r
+       #ifdef CONFIG_HAS_EARLYSUSPEND\r
        unregister_early_suspend(&hdmi->early_suspend);\r
-#endif\r
+       #endif\r
        iounmap((void*)hdmi->regbase);\r
 err1:\r
        release_mem_region(res->start,(res->end - res->start) + 1);\r
@@ -197,6 +203,9 @@ static int __devexit rk30_hdmi_remove(struct platform_device *pdev)
 {\r
        flush_scheduled_work();\r
        destroy_workqueue(hdmi->workqueue);\r
+       #ifdef CONFIG_SWITCH\r
+       switch_dev_unregister(&(hdmi->switch_hdmi));\r
+       #endif\r
        #ifdef CONFIG_HAS_EARLYSUSPEND\r
        unregister_early_suspend(&hdmi->early_suspend);\r
        #endif\r
index caf8b495f0fe16845510f3b1c24901ce81c037dd..7e57f8fc4e259a23162c376f712f262868f2cb5c 100755 (executable)
@@ -1,18 +1,20 @@
 #ifndef __RK30_HDMI_H__
 #define __RK30_HDMI_H__
 
+#include <linux/kernel.h>
 #include <linux/fb.h>
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/workqueue.h>
 #include <linux/display-sys.h>
-
+#ifdef CONFIG_SWITCH
+#include <linux/switch.h>
+#endif
 #ifdef CONFIG_HAS_EARLYSUSPEND
 #include <linux/earlysuspend.h>
 #endif
 
-//#include "../../display/screen/screen.h"
 #include<linux/rk_screen.h>
 #include <linux/rk_fb.h>
 #include "rk_hdmi.h"
@@ -45,6 +47,10 @@ struct hdmi {
        int                             irq;
        struct rk_lcdc_device_driver *lcdc;
        
+       #ifdef CONFIG_SWITCH
+       struct switch_dev       switch_hdmi;
+       #endif
+       
        struct workqueue_struct *workqueue;
        struct delayed_work delay_work;
        
index 72728864831c3eb21efbc584485570c955bce539..04e46a7c8951afea9353be14a21c68897adcb9d9 100755 (executable)
@@ -78,6 +78,10 @@ void hdmi_sys_remove(void)
        memset(&hdmi->edid, 0, sizeof(struct hdmi_edid));
        INIT_LIST_HEAD(&hdmi->edid.modelist);
        hdmi->display   = HDMI_DISABLE;
+       kobject_uevent_env(&hdmi->dev->kobj, KOBJ_REMOVE, envp);
+       #ifdef CONFIG_SWITCH
+       switch_set_state(&(hdmi->switch_hdmi), 0);
+       #endif
 }
 
 static void hdmi_sys_sleep(void)
@@ -188,7 +192,6 @@ void hdmi_work(struct work_struct *work)
                                complete(&hdmi->complete);
                                hdmi->wait = 0; 
                        }
-                       kobject_uevent_env(&hdmi->dev->kobj, KOBJ_REMOVE, envp);
                        mutex_unlock(&work_mutex);
                        return;
                }
@@ -210,6 +213,9 @@ void hdmi_work(struct work_struct *work)
                                {
                                        hdmi->state = SYSTEM_CONFIG;    
                                        kobject_uevent_env(&hdmi->dev->kobj, KOBJ_ADD, envp);
+                                       #ifdef CONFIG_SWITCH
+                                       switch_set_state(&(hdmi->switch_hdmi), 1);
+                                       #endif
                                }
                                break;
                        case SYSTEM_CONFIG: