From a1c15deb2b2190751ae327cb0492568b5ae5fbfc Mon Sep 17 00:00:00 2001 From: Zheng Yang Date: Wed, 2 May 2012 11:49:51 +0800 Subject: [PATCH] rk30 hdmi: support switch class to detect hotplug status. --- drivers/video/rockchip/hdmi/rk30_hdmi.c | 19 ++++++++++++++----- drivers/video/rockchip/hdmi/rk30_hdmi.h | 10 ++++++++-- drivers/video/rockchip/hdmi/rk30_hdmi_task.c | 8 +++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/video/rockchip/hdmi/rk30_hdmi.c b/drivers/video/rockchip/hdmi/rk30_hdmi.c index c0038bf0274c..ef50f282d87a 100755 --- a/drivers/video/rockchip/hdmi/rk30_hdmi.c +++ b/drivers/video/rockchip/hdmi/rk30_hdmi.c @@ -154,10 +154,13 @@ static int __devinit rk30_hdmi_probe (struct platform_device *pdev) hdmi->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 10; register_early_suspend(&hdmi->early_suspend); #endif - - + hdmi_register_display_sysfs(hdmi, hdmi->dev); - + #ifdef CONFIG_SWITCH + hdmi->switch_hdmi.name="hdmi"; + switch_dev_register(&(hdmi->switch_hdmi)); + #endif + spin_lock_init(&hdmi->irq_lock); mutex_init(&hdmi->enable_mutex); @@ -180,9 +183,12 @@ static int __devinit rk30_hdmi_probe (struct platform_device *pdev) hdmi_dbg(hdmi->dev, "rk30 hdmi probe sucess.\n"); return 0; err2: -#ifdef CONFIG_HAS_EARLYSUSPEND + #ifdef CONFIG_SWITCH + switch_dev_unregister(&(hdmi->switch_hdmi)); + #endif + #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&hdmi->early_suspend); -#endif + #endif iounmap((void*)hdmi->regbase); err1: release_mem_region(res->start,(res->end - res->start) + 1); @@ -197,6 +203,9 @@ static int __devexit rk30_hdmi_remove(struct platform_device *pdev) { flush_scheduled_work(); destroy_workqueue(hdmi->workqueue); + #ifdef CONFIG_SWITCH + switch_dev_unregister(&(hdmi->switch_hdmi)); + #endif #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&hdmi->early_suspend); #endif diff --git a/drivers/video/rockchip/hdmi/rk30_hdmi.h b/drivers/video/rockchip/hdmi/rk30_hdmi.h index caf8b495f0fe..7e57f8fc4e25 100755 --- a/drivers/video/rockchip/hdmi/rk30_hdmi.h +++ b/drivers/video/rockchip/hdmi/rk30_hdmi.h @@ -1,18 +1,20 @@ #ifndef __RK30_HDMI_H__ #define __RK30_HDMI_H__ +#include #include #include #include #include #include #include - +#ifdef CONFIG_SWITCH +#include +#endif #ifdef CONFIG_HAS_EARLYSUSPEND #include #endif -//#include "../../display/screen/screen.h" #include #include #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; diff --git a/drivers/video/rockchip/hdmi/rk30_hdmi_task.c b/drivers/video/rockchip/hdmi/rk30_hdmi_task.c index 72728864831c..04e46a7c8951 100755 --- a/drivers/video/rockchip/hdmi/rk30_hdmi_task.c +++ b/drivers/video/rockchip/hdmi/rk30_hdmi_task.c @@ -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: -- 2.34.1