summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorSimon Je <sje@nvidia.com>2013-10-04 13:54:03 +0900
committerGabby Lee <galee@nvidia.com>2013-10-06 22:41:25 -0700
commitd192373ee15a75bc05ee4f2e8c36410dd2570029 (patch)
tree7a86c35be6ab53a7f8ae6b18d29cf4a33a438ff5 /sound
parent985f7b6b29eb515ad1f01bea7e5d914be6739a50 (diff)
asoc: rt5639: Set Speaker OVCD to default
Set the speaker over-voltage protection value to the power on reset value. Set OVCD to low value when audio is not playing. Make sure codec mclk is enabled when writing the codec registers. Change-Id: Ib673d667af54f3b4fd7bf3183cbde1759838ae4a Signed-off-by: Scott Peterson <speterson@nvidia.com> Signed-off-by: Simon Je <sje@nvidia.com> Reviewed-on: http://git-master/r/274022 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Vinod Subbarayalu <vsubbarayalu@nvidia.com> Reviewed-by: Simon Je <sje@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Gabby Lee <galee@nvidia.com> Tested-by: Gabby Lee <galee@nvidia.com> (cherry picked from commit 2e0cd932ce9c116b5a0e07a3ce5ad865a63121b3) Reviewed-on: http://git-master/r/281662
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/rt5639.c54
-rw-r--r--sound/soc/tegra/tegra_rt5640.c2
2 files changed, 35 insertions, 21 deletions
diff --git a/sound/soc/codecs/rt5639.c b/sound/soc/codecs/rt5639.c
index 5ac1ebcd4263..97fbd9749c34 100644
--- a/sound/soc/codecs/rt5639.c
+++ b/sound/soc/codecs/rt5639.c
@@ -58,7 +58,7 @@ static struct rt5639_init_reg init_list[] = {
{RT5639_ADDA_CLK1 , 0x1114},/* 73[2] = 1'b */
{RT5639_MICBIAS , 0x3030},/* 93[5:4] = 11'b */
{RT5639_CLS_D_OUT , 0xa000},/* 8d[11] = 0'b */
- {RT5639_CLS_D_OVCD , 0x0334},/* 8c[8] = 1'b */
+ {RT5639_CLS_D_OVCD , 0x0301},/* 8c[8] = 1'b */
{RT5639_PRIV_INDEX , 0x001d},/* PR1d[8] = 1'b; */
{RT5639_PRIV_DATA , 0x0347},
{RT5639_PRIV_INDEX , 0x003d},/* PR3d[12] = 0'b; PR3d[9] = 1'b */
@@ -196,7 +196,7 @@ static const u16 rt5639_reg[RT5639_VENDOR_ID2 + 1] = {
[RT5639_DMIC] = 0x1d00,
[RT5639_ASRC_3] = 0x0008,
[RT5639_HP_OVCD] = 0x0600,
- [RT5639_CLS_D_OVCD] = 0x0228,
+ [RT5639_CLS_D_OVCD] = 0x0201, /*Init to 0.15A OVCD */
[RT5639_CLS_D_OUT] = 0xa800,
[RT5639_DEPOP_M1] = 0x0004,
[RT5639_DEPOP_M2] = 0x1100,
@@ -1340,6 +1340,7 @@ static int rt5639_mono_adcr_event(struct snd_soc_dapm_widget *w,
static int rt5639_spk_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
+ int val;
struct snd_soc_codec *codec = w->codec;
switch (event) {
@@ -1353,9 +1354,17 @@ static int rt5639_spk_event(struct snd_soc_dapm_widget *w,
RT5639_CLSD_INT_REG1, 0xf000, 0xf000);
snd_soc_update_bits(codec, RT5639_SPK_VOL,
RT5639_L_MUTE | RT5639_R_MUTE, 0);
+
+ /* Make sure test mode is not enabled */
+ val = rt5639_index_read(codec, 0x001B);
+ if (val == 0x9200)
+ snd_soc_write(codec, RT5639_CLS_D_OVCD, 0x0301);
+ else
+ snd_soc_write(codec, RT5639_CLS_D_OVCD, 0x0328);
break;
case SND_SOC_DAPM_PRE_PMD:
+ snd_soc_write(codec, RT5639_CLS_D_OVCD, 0x0301);
snd_soc_update_bits(codec, RT5639_SPK_VOL,
RT5639_L_MUTE | RT5639_R_MUTE,
RT5639_L_MUTE | RT5639_R_MUTE);
@@ -2824,6 +2833,15 @@ static DEVICE_ATTR(codec_reg, 0644, rt5639_codec_show, rt5639_codec_store);
static int rt5639_set_bias_level(struct snd_soc_codec *codec,
enum snd_soc_bias_level level)
{
+ int val;
+
+ /* Make sure test mode is not enabled */
+ val = rt5639_index_read(codec, 0x001B);
+ if (val == 0x9200)
+ snd_soc_write(codec, RT5639_CLS_D_OVCD, 0x0301);
+ else
+ snd_soc_write(codec, RT5639_CLS_D_OVCD, 0x0328);
+
switch (level) {
case SND_SOC_BIAS_ON:
break;
@@ -2865,6 +2883,7 @@ static int rt5639_set_bias_level(struct snd_soc_codec *codec,
snd_soc_write(codec, RT5639_PWR_MIXER, 0x0000);
snd_soc_write(codec, RT5639_PWR_ANLG1, 0x0000);
snd_soc_write(codec, RT5639_PWR_ANLG2, 0x0000);
+ snd_soc_write(codec, RT5639_CLS_D_OVCD, 0x0301);
break;
default:
@@ -2879,6 +2898,12 @@ static int rt5639_probe(struct snd_soc_codec *codec)
{
struct rt5639_priv *rt5639 = snd_soc_codec_get_drvdata(codec);
int ret;
+#ifdef RTK_IOCTL
+#if defined(CONFIG_SND_HWDEP) || defined(CONFIG_SND_HWDEP_MODULE)
+ struct rt56xx_ops *ioctl_ops;
+#endif
+#endif
+
pr_info("Codec driver version %s\n", VERSION);
@@ -2937,14 +2962,12 @@ static int rt5639_probe(struct snd_soc_codec *codec)
#ifdef RTK_IOCTL
#if defined(CONFIG_SND_HWDEP) || defined(CONFIG_SND_HWDEP_MODULE)
- {
- struct rt56xx_ops *ioctl_ops = rt56xx_get_ioctl_ops();
- ioctl_ops->index_write = rt5639_index_write;
- ioctl_ops->index_read = rt5639_index_read;
- ioctl_ops->index_update_bits = rt5639_index_update_bits;
- ioctl_ops->ioctl_common = rt5639_ioctl_common;
- realtek_ce_init_hwdep(codec);
- }
+ ioctl_ops = rt56xx_get_ioctl_ops();
+ ioctl_ops->index_write = rt5639_index_write;
+ ioctl_ops->index_read = rt5639_index_read;
+ ioctl_ops->index_update_bits = rt5639_index_update_bits;
+ ioctl_ops->ioctl_common = rt5639_ioctl_common;
+ realtek_ce_init_hwdep(codec);
#endif
#endif
@@ -3088,16 +3111,6 @@ static int __devexit rt5639_i2c_remove(struct i2c_client *i2c)
return 0;
}
-static void rt5639_i2c_shutdown(struct i2c_client *client)
-{
- struct rt5639_priv *rt5639 = i2c_get_clientdata(client);
- struct snd_soc_codec *codec = rt5639->codec;
-
- if (codec != NULL)
- rt5639_set_bias_level(codec, SND_SOC_BIAS_OFF);
-
-}
-
struct i2c_driver rt5639_i2c_driver = {
.driver = {
.name = "rt5639",
@@ -3105,7 +3118,6 @@ struct i2c_driver rt5639_i2c_driver = {
},
.probe = rt5639_i2c_probe,
.remove = __devexit_p(rt5639_i2c_remove),
- .shutdown = rt5639_i2c_shutdown,
.id_table = rt5639_i2c_id,
};
diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c
index 7afdf27804f9..223a9347e1a8 100644
--- a/sound/soc/tegra/tegra_rt5640.c
+++ b/sound/soc/tegra/tegra_rt5640.c
@@ -451,6 +451,7 @@ static void tegra_speaker_edp_set_volume(struct snd_soc_codec *codec,
int l_vol,
int r_vol)
{
+ tegra_asoc_enable_clocks();
snd_soc_update_bits(codec,
RT5640_SPK_VOL,
RT5640_L_VOL_MASK,
@@ -459,6 +460,7 @@ static void tegra_speaker_edp_set_volume(struct snd_soc_codec *codec,
RT5640_SPK_VOL,
RT5640_R_VOL_MASK,
r_vol << RT5640_R_VOL_SFT);
+ tegra_asoc_disable_clocks();
}
static void tegra_speaker_throttle(unsigned int new_state, void *priv_data)