From: 陈金泉 Date: Mon, 20 May 2013 09:40:47 +0000 (+0800) Subject: rk616 codec:do not set mclk when HDMI is in X-Git-Tag: firefly_0821_release~7067 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=08a5ce131481e208ccbb1fc33e260f1a27b9c496;p=firefly-linux-kernel-4.4.55.git rk616 codec:do not set mclk when HDMI is in --- diff --git a/sound/soc/codecs/rk616_codec.c b/sound/soc/codecs/rk616_codec.c index e702e91209d3..7f9b95ae4870 100755 --- a/sound/soc/codecs/rk616_codec.c +++ b/sound/soc/codecs/rk616_codec.c @@ -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; diff --git a/sound/soc/codecs/rk616_codec.h b/sound/soc/codecs/rk616_codec.h index bd540c4afcd9..c1342e63f394 100755 --- a/sound/soc/codecs/rk616_codec.h +++ b/sound/soc/codecs/rk616_codec.h @@ -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__ diff --git a/sound/soc/rk29/rk_rk616.c b/sound/soc/rk29/rk_rk616.c index 57610ed63035..89a9bf720a6e 100755 --- a/sound/soc/rk29/rk_rk616.c +++ b/sound/soc/rk29/rk_rk616.c @@ -98,7 +98,12 @@ static int rk_hifi_hw_params(struct snd_pcm_substream *substream, int ret; DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - + + /* MCLK must be 12M when HDMI is in */ + if (get_hdmi_state()) { + DBG("%s : HDMI is in, do not set sys clk\n",__FUNCTION__); + } + /* set codec DAI configuration */ #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) @@ -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 ); #endif if (ret < 0) - return ret; + return ret; /* set cpu DAI configuration */ #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); #endif - #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) + #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); - #endif + SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); + #endif if (ret < 0) return ret; @@ -171,8 +176,13 @@ static int rk_voice_hw_params(struct snd_pcm_substream *substream, unsigned int pll_out = 0; int ret; - DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - + DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); + + /* MCLK must be 12M when HDMI is in */ + if (get_hdmi_state()) { + DBG("%s : HDMI is in, do not set sys clk\n",__FUNCTION__); + } + /* set codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS); @@ -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); if (ret < 0) { - printk("rk_voice_hw_params:failed to set the sysclk for codec side\n"); + printk("rk_voice_hw_params:failed to set the sysclk for codec side\n"); return ret; } ret = snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0); - + return 0; }