rk616 codec:do not set mclk when HDMI is in
author陈金泉 <chenjq@rock-chips.com>
Mon, 20 May 2013 09:40:47 +0000 (17:40 +0800)
committer陈金泉 <chenjq@rock-chips.com>
Mon, 20 May 2013 09:40:47 +0000 (17:40 +0800)
sound/soc/codecs/rk616_codec.c
sound/soc/codecs/rk616_codec.h
sound/soc/rk29/rk_rk616.c

index e702e91209d3ddfcf22babde045d9c7eef2bdc2e..7f9b95ae487029328e6c55652bacc59988bd973e 100755 (executable)
@@ -72,7 +72,7 @@ static struct workqueue_struct *rk616_codec_workq;
 static void rk616_codec_capture_work(struct work_struct *work);
 static DECLARE_DELAYED_WORK(capture_delayed_work, rk616_codec_capture_work);
 static int rk616_codec_work_capture_type = RK616_CODEC_WORK_NULL;
-static bool rk616_for_mid = 1;
+static bool rk616_for_mid = 1, is_hdmi_in = false;
 
 static int board_for_mid(char *str)
 {
@@ -535,6 +535,11 @@ int rk616_headset_mic_detect(bool headset_status)
 }
 EXPORT_SYMBOL(rk616_headset_mic_detect);
 
+bool get_hdmi_state(void)
+{
+       return is_hdmi_in;
+}
+
 void codec_set_spk(bool on)
 {
        struct snd_soc_codec *codec = rk616_priv->codec;
@@ -565,6 +570,17 @@ void codec_set_spk(bool on)
                        snd_soc_dapm_enable_pin(&codec->dapm, "Ext Spk");
                }
        } else {
+               if (rk616_priv->spk_ctl_gpio != INVALID_GPIO) {
+                       DBG("%s : set spk ctl gpio LOW\n", __func__);
+                       gpio_set_value(rk616_priv->spk_ctl_gpio, GPIO_LOW);
+               }
+
+               if (rk616_priv->hp_ctl_gpio != INVALID_GPIO) {
+                       DBG("%s : set hp ctl gpio LOW\n", __func__);
+                       gpio_set_value(rk616_priv->hp_ctl_gpio, GPIO_LOW);
+                       snd_soc_write(codec, RK616_CLK_CHPUMP, 0x41);
+               }
+
                if (rk616_for_mid)
                {
                        snd_soc_update_bits(codec, RK616_SPKL_CTL,
@@ -583,6 +599,8 @@ void codec_set_spk(bool on)
                }
        }
        snd_soc_dapm_sync(&codec->dapm);
+
+       is_hdmi_in = on ? 0 : 1;
 }
 EXPORT_SYMBOL_GPL(codec_set_spk);
 
@@ -1553,7 +1571,7 @@ static int rk616_hw_params(struct snd_pcm_substream *substream,
        case RK616_VOICE:
                mfd_aif1 |= I2S0_OUT_DISABLE | I2S1_PD_DISABLE;
                mfd_aif2 |= I2S1_SI_EN;
-               mfd_i2s_ctl |= I2S_CHANNEL_SEL;
+               mfd_i2s_ctl |= I2S_CHANNEL_SEL | PCM_TO_I2S_MUX;
                break;
        default:
                return -EINVAL;
@@ -1595,18 +1613,19 @@ static int rk616_digital_mute(struct snd_soc_dai *dai, int mute)
                        snd_soc_write(codec, RK616_CLK_CHPUMP, 0x41);
                }
        } else {
-               if (rk616_priv && rk616_priv->spk_ctl_gpio != INVALID_GPIO &&
-                   !is_spk_pd) {
-                       DBG("%s : set spk ctl gpio HIGH\n", __func__);
-                       gpio_set_value(rk616_priv->spk_ctl_gpio, GPIO_HIGH);
-               }
-
                if (rk616_priv && rk616_priv->hp_ctl_gpio != INVALID_GPIO &&
                    !is_hp_pd) {
-                       DBG("%s : set hp ctl gpio HIGH\n", __func__);
                        snd_soc_write(codec, RK616_CLK_CHPUMP, 0x21);
+                       msleep(10);
+                       DBG("%s : set hp ctl gpio HIGH\n", __func__);
                        gpio_set_value(rk616_priv->hp_ctl_gpio, GPIO_HIGH);
                }
+
+               if (rk616_priv && rk616_priv->spk_ctl_gpio != INVALID_GPIO &&
+                   !is_spk_pd) {
+                       DBG("%s : set spk ctl gpio HIGH\n", __func__);
+                       gpio_set_value(rk616_priv->spk_ctl_gpio, GPIO_HIGH);
+               }
        }
 
        return 0;
index bd540c4afcd921e001a055469b415df4c112a198..c1342e63f394b1e8274bca54f161fd14740acd06 100755 (executable)
@@ -11,6 +11,7 @@
 
 /* mfd register */
 //#define CRU_PCM2IS2_CON2                     0x0098
+#define PCM_TO_I2S_MUX                         (1 << 3)
 #define APS_SEL                                        (1 << 2)
 #define APS_CLR                                        (1 << 1)
 #define I2S_CHANNEL_SEL                                (1 << 0)
@@ -757,4 +758,6 @@ struct rk616_init_bit_typ {
        unsigned int init_bit;
 };
 
+bool get_hdmi_state(void);
+
 #endif //__RK616_CODEC_H__
index 57610ed630354f4cdb199eebf3ce2dba9c4d0563..89a9bf720a6e7bae360dcf5628ab5784786f0726 100755 (executable)
@@ -98,7 +98,12 @@ static int rk_hifi_hw_params(struct snd_pcm_substream *substream,
        int ret;\r
 \r
        DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);\r
-                \r
+\r
+       /* MCLK must be 12M when HDMI is in */\r
+       if (get_hdmi_state()) {\r
+               DBG("%s : HDMI is in, do not set sys clk\n",__FUNCTION__);\r
+       }\r
+\r
        /* set codec DAI configuration */\r
        #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) \r
 \r
@@ -111,17 +116,17 @@ static int rk_hifi_hw_params(struct snd_pcm_substream *substream,
                        SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); \r
        #endif\r
        if (ret < 0)\r
-               return ret; \r
+               return ret;\r
 \r
        /* set cpu DAI configuration */\r
        #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) \r
        ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |\r
                        SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);\r
        #endif  \r
-       #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) \r
+       #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)\r
        ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |\r
-                       SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); \r
-       #endif          \r
+                       SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);\r
+       #endif\r
        if (ret < 0)\r
                return ret;\r
 \r
@@ -171,8 +176,13 @@ static int rk_voice_hw_params(struct snd_pcm_substream *substream,
        unsigned int pll_out = 0;\r
        int ret;\r
 \r
-       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    \r
-       \r
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);\r
+\r
+       /* MCLK must be 12M when HDMI is in */\r
+       if (get_hdmi_state()) {\r
+               DBG("%s : HDMI is in, do not set sys clk\n",__FUNCTION__);\r
+       }\r
+\r
        /* set codec DAI configuration */\r
        ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A |\r
                                SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS);\r
@@ -202,12 +212,12 @@ static int rk_voice_hw_params(struct snd_pcm_substream *substream,
        ret = snd_soc_dai_set_sysclk(codec_dai, 0, pll_out, SND_SOC_CLOCK_IN);\r
 \r
        if (ret < 0) {\r
-               printk("rk_voice_hw_params:failed to set the sysclk for codec side\n"); \r
+               printk("rk_voice_hw_params:failed to set the sysclk for codec side\n");\r
                return ret;\r
        }\r
 \r
        ret = snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);\r
\r
+\r
        return 0;\r
 }\r
 \r