From c394c3d4dada0c918f9563dcb6133de2c75ebe45 Mon Sep 17 00:00:00 2001 From: Shuai Li Date: Fri, 25 Aug 2017 19:05:08 +0800 Subject: [PATCH] audio: fix codecs kcontrol bugs PD#145715: kernel 4.9 use components to wrapper the codec instance. When poring form early versions, we have no idea about this change. And this commit fixes this issue. Change-Id: I56357b45c1bf93844f77fe89a828911fa9779406 Signed-off-by: Shuai Li --- sound/soc/codecs/amlogic/aml_codec_t9015.c | 6 +++-- sound/soc/codecs/amlogic/aml_codec_t9015S.c | 6 +++-- sound/soc/codecs/amlogic/pcm186x.c | 6 +++-- sound/soc/codecs/amlogic/tas5707.c | 34 +++++++++++++++++++---------- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/amlogic/aml_codec_t9015.c b/sound/soc/codecs/amlogic/aml_codec_t9015.c index 7cd19bf..f3110f2 100644 --- a/sound/soc/codecs/amlogic/aml_codec_t9015.c +++ b/sound/soc/codecs/amlogic/aml_codec_t9015.c @@ -66,7 +66,8 @@ static int aml_DAC_Gain_get_enum( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); u32 add, val, val1, val2; /*TODO: return 0 for tmp, this wolud modified later */ @@ -89,7 +90,8 @@ static int aml_DAC_Gain_set_enum( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); u32 add = ADC_VOL_CTR_PGA_IN_CONFIG; u32 val = snd_soc_read(codec, add); diff --git a/sound/soc/codecs/amlogic/aml_codec_t9015S.c b/sound/soc/codecs/amlogic/aml_codec_t9015S.c index cc28360..0b453e9 100644 --- a/sound/soc/codecs/amlogic/aml_codec_t9015S.c +++ b/sound/soc/codecs/amlogic/aml_codec_t9015S.c @@ -67,7 +67,8 @@ static int aml_DAC_Gain_get_enum( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); u32 add = ADC_VOL_CTR_PGA_IN_CONFIG; u32 val = snd_soc_read(codec, add); u32 val1 = (val & (0x1 << DAC_GAIN_SEL_L)) >> DAC_GAIN_SEL_L; @@ -82,7 +83,8 @@ static int aml_DAC_Gain_set_enum( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); u32 add = ADC_VOL_CTR_PGA_IN_CONFIG; u32 val = snd_soc_read(codec, add); diff --git a/sound/soc/codecs/amlogic/pcm186x.c b/sound/soc/codecs/amlogic/pcm186x.c index 4fdc83a..2c436c6 100644 --- a/sound/soc/codecs/amlogic/pcm186x.c +++ b/sound/soc/codecs/amlogic/pcm186x.c @@ -149,7 +149,8 @@ static int pcm186x_dsp_access_enable(struct device *dev, struct regmap *map) static int pcm186x_dsp_coefficients_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); struct device *dev = codec->dev; struct pcm186x_priv *priv = snd_soc_codec_get_drvdata(codec); struct regmap *map = priv->regmap; @@ -222,7 +223,8 @@ static int pcm186x_dsp_coefficients_get(struct snd_kcontrol *kcontrol, static int pcm186x_dsp_coefficients_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); struct device *dev = codec->dev; struct pcm186x_priv *priv = snd_soc_codec_get_drvdata(codec); struct regmap *map = priv->regmap; diff --git a/sound/soc/codecs/amlogic/tas5707.c b/sound/soc/codecs/amlogic/tas5707.c index 0c42513..3c515eb 100644 --- a/sound/soc/codecs/amlogic/tas5707.c +++ b/sound/soc/codecs/amlogic/tas5707.c @@ -145,6 +145,8 @@ struct tas5707_priv { unsigned char Ch2_vol; unsigned char master_vol; unsigned int mclk; + unsigned int EQ_enum_value; + unsigned int DRC_enum_value; #ifdef CONFIG_HAS_EARLYSUSPEND struct early_suspend early_suspend; #endif @@ -413,17 +415,17 @@ static int tas5707_set_eq(struct snd_soc_codec *codec) return 0; } -static bool EQ_enum_value = 1; static int tas5707_set_EQ_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); struct tas5707_priv *tas5707 = snd_soc_codec_get_drvdata(codec); u8 tas5707_eq_ctl_table[] = { 0x00, 0x00, 0x00, 0x80 }; - EQ_enum_value = ucontrol->value.integer.value[0]; + tas5707->EQ_enum_value = ucontrol->value.integer.value[0]; - if (EQ_enum_value == 1) + if (tas5707->EQ_enum_value == 1) tas5707_set_eq(codec); else regmap_raw_write(tas5707->regmap, @@ -435,22 +437,26 @@ static int tas5707_set_EQ_enum(struct snd_kcontrol *kcontrol, static int tas5707_get_EQ_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ucontrol->value.integer.value[0] = EQ_enum_value; + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); + struct tas5707_priv *tas5707 = snd_soc_codec_get_drvdata(codec); + + ucontrol->value.integer.value[0] = tas5707->EQ_enum_value; return 0; } -static bool DRC_enum_value = 1; static int tas5707_set_DRC_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); struct tas5707_priv *tas5707 = snd_soc_codec_get_drvdata(codec); u8 tas5707_drc_ctl_table[] = { 0x00, 0x00, 0x00, 0x00 }; - DRC_enum_value = ucontrol->value.integer.value[0]; + tas5707->DRC_enum_value = ucontrol->value.integer.value[0]; - if (DRC_enum_value == 1) + if (tas5707->DRC_enum_value == 1) tas5707_set_drc(codec); else regmap_raw_write(tas5707->regmap, DDX_DRC_CTL, @@ -461,7 +467,11 @@ static int tas5707_set_DRC_enum(struct snd_kcontrol *kcontrol, static int tas5707_get_DRC_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ucontrol->value.integer.value[0] = DRC_enum_value; + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); + struct tas5707_priv *tas5707 = snd_soc_codec_get_drvdata(codec); + + ucontrol->value.integer.value[0] = tas5707->DRC_enum_value; return 0; } @@ -514,9 +524,9 @@ static int tas5707_init(struct snd_soc_codec *codec) regmap_raw_write(tas5707->regmap, DDX_PWM_MUX, burst_data[2], 4); /*drc */ - tas5707_set_drc(codec); + //tas5707_set_drc(codec); /*eq */ - tas5707_set_eq(codec); + //tas5707_set_eq(codec); snd_soc_write(codec, DDX_VOLUME_CONFIG, 0xD1); snd_soc_write(codec, DDX_SYS_CTL_2, 0x84); -- 2.7.4