hdmi: add auto audio switch func
authoryzq <yzq@rock-chips.com>
Wed, 4 Sep 2013 03:32:03 +0000 (11:32 +0800)
committeryzq <yzq@rock-chips.com>
Wed, 4 Sep 2013 03:44:24 +0000 (11:44 +0800)
drivers/video/rockchip/hdmi/rk_hdmi.h
drivers/video/rockchip/hdmi/rk_hdmi_edid.c
drivers/video/rockchip/hdmi/rk_hdmi_lcdc.c
drivers/video/rockchip/hdmi/rk_hdmi_task.c

index 09dd016bc9b1e4c9f640321e79a6c7f4279004e0..5f50cdf9d3fa2c3a5e8a2d49c55356101221c65e 100755 (executable)
@@ -239,6 +239,7 @@ struct hdmi_edid {
        struct list_head modelist;                      //Device supported display mode list
        struct hdmi_audio *audio;                       //Device supported audio info
        int     audio_num;                                              //Device supported audio type number
+       int     base_audio_support;                             //Device supported base audio
 };
 
 /* RK HDMI Video Configure Parameters */
index 6a7d33f107903610e61cdc53199be8e7bb476ac8..2ffc745aefbd28fc710981ad80cc052cdbd4cf93 100755 (executable)
@@ -217,7 +217,8 @@ static int hdmi_edid_parse_extensions_cea(unsigned char *buf, struct hdmi_edid *
        pedid->ycbcr444 = (buf[3] >> 5) & 0x01;\r
        pedid->ycbcr422 = (buf[3] >> 4) & 0x01;\r
        native_dtd_num = buf[3] & 0x0F;\r
-//     hdmi_edid_debug("[EDID-CEA] ddc_offset %d underscan_support %d baseaudio_support %d yuv_support %d native_dtd_num %d\n", ddc_offset, underscan_support, baseaudio_support, yuv_support, native_dtd_num);\r
+       pedid->base_audio_support = baseaudio_support;\r
+       \r
        // Parse data block\r
        while(cur_offset < ddc_offset)\r
        {\r
index 2b43dad334fb5eb385f8156b6bc4481eb95680cf..a9c09bcdf664fdc150215121a12230e41b2b046f 100755 (executable)
@@ -246,8 +246,10 @@ int hdmi_ouputmode_select(struct hdmi *hdmi, int edid_ok)
        int i, pixclock;
        
        if(edid_ok != HDMI_ERROR_SUCESS) {
-               dev_err(hdmi->dev, "warning: EDID error, assume sink as HDMI !!!!");
+               dev_err(hdmi->dev, "warning: EDID error, assume sink as HDMI and asume minitor support audio output!!!!");
                hdmi->edid.sink_hdmi = 1;
+               //if edid error,asume monitor support audio output.
+               hdmi->edid.base_audio_support = 1;
        }
 
        if(edid_ok != HDMI_ERROR_SUCESS) {
index 55e4919b9a27f21a00f0c9e36f76f76e498a2b29..34b0f1179202159844de054ccbfdb467e895bba1 100755 (executable)
@@ -80,6 +80,10 @@ int hdmi_sys_init(void)
 
 void hdmi_sys_remove(void)
 {
+       int audio_need;
+
+       audio_need = hdmi->edid.base_audio_support == 1 &&  hdmi->edid.sink_hdmi == 1;
+       
        fb_destroy_modelist(&hdmi->edid.modelist);
        if(hdmi->edid.audio)
                kfree(hdmi->edid.audio);
@@ -96,8 +100,10 @@ void hdmi_sys_remove(void)
                hdmi->set_vif(hdmi->lcdc->screen1,0);
        rk_fb_switch_screen(hdmi->lcdc->screen1, 0, hdmi->lcdc->id);
        kobject_uevent_env(&hdmi->dev->kobj, KOBJ_REMOVE, envp);
+
        #ifdef CONFIG_SWITCH
-       switch_set_state(&(hdmi->switch_hdmi), 0);
+       if(audio_need)
+               switch_set_state(&(hdmi->switch_hdmi), 0);
        #endif
        #ifdef CONFIG_RK_HDMI_CTL_CODEC
 #ifdef CONFIG_MACH_RK_FAC
@@ -194,7 +200,7 @@ void hdmi_work(struct work_struct *work)
        int hotplug, state_last;
        int rc = HDMI_ERROR_SUCESS, trytimes = 0;
        struct hdmi_video_para video;
-       
+
        mutex_lock(&work_mutex);
        /* Process hdmi command */
        hdmi->state = hdmi_process_command();
@@ -249,8 +255,10 @@ void hdmi_work(struct work_struct *work)
                                {
                                        hdmi->state = SYSTEM_CONFIG;    
                                        kobject_uevent_env(&hdmi->dev->kobj, KOBJ_ADD, envp);
+                                       hdmi_dbg(hdmi->dev,"[%s],base_audio_support =%d,sink_hdmi = %d\n",hdmi->edid.base_audio_support,hdmi->edid.sink_hdmi );
                                        #ifdef CONFIG_SWITCH
-                                       switch_set_state(&(hdmi->switch_hdmi), 1);
+                                       if(hdmi->edid.base_audio_support == 1 &&  hdmi->edid.sink_hdmi == 1)
+                                               switch_set_state(&(hdmi->switch_hdmi), 1);
                                        #endif
                                        #ifdef CONFIG_RK_HDMI_CTL_CODEC
                                        #ifdef CONFIG_MACH_RK_FAC