diff options
Diffstat (limited to 'sound/soc/codecs')
250 files changed, 4888 insertions, 2248 deletions
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index be01f0928393..b4f5b24cde45 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -269,7 +269,7 @@ static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; int val[2], val2[2], i; @@ -293,7 +293,7 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; int err; @@ -326,7 +326,7 @@ static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -346,7 +346,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -1106,6 +1106,7 @@ static int pm860x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int data; switch (level) { @@ -1116,7 +1117,7 @@ static int pm860x_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Enable Audio PLL & Audio section */ data = AUDIO_PLL | AUDIO_SECTION_ON; pm860x_reg_write(pm860x->i2c, REG_MISC2, data); diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 160c07699a8b..6087ebde9523 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -106,6 +106,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_CS48L32 imply SND_SOC_CS53L30 imply SND_SOC_CS530X_I2C + imply SND_SOC_CS530X_SPI imply SND_SOC_CX20442 imply SND_SOC_CX2072X imply SND_SOC_DA7210 @@ -170,6 +171,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_MT6359 imply SND_SOC_MT6660 imply SND_SOC_NAU8315 + imply SND_SOC_NAU8325 imply SND_SOC_NAU8540 imply SND_SOC_NAU8810 imply SND_SOC_NAU8821 @@ -896,6 +898,38 @@ config SND_SOC_CS35L56_SDW help Enable support for Cirrus Logic CS35L56 boosted amplifier with SoundWire control +config SND_SOC_CS35L56_CAL_DEBUGFS_COMMON + bool + +menu "CS35L56 driver options" + depends on SND_SOC_CS35L56 + +config SND_SOC_CS35L56_CAL_DEBUGFS + bool "CS35L56 create debugfs for factory calibration" + default N + depends on DEBUG_FS + select SND_SOC_CS35L56_CAL_DEBUGFS_COMMON + help + Create debugfs entries used during factory-line manufacture + for factory calibration. + + If unsure select "N". + +config SND_SOC_CS35L56_CAL_SET_CTRL + bool "CS35L56 ALSA control to restore factory calibration" + default N + select SND_SOC_CS35L56_CAL_SYSFS_COMMON + help + Allow restoring factory calibration data through an ALSA + control. This is only needed on platforms without UEFI or + some other method of non-volatile storage that the driver + can access directly. + + On most platforms this is not needed. + + If unsure select "N". +endmenu + config SND_SOC_CS40L50 tristate "Cirrus Logic CS40L50 CODEC" depends on MFD_CS40L50_CORE @@ -1082,6 +1116,15 @@ config SND_SOC_CS530X_I2C Enable support for Cirrus Logic CS530X ADCs with I2C control. +config SND_SOC_CS530X_SPI + tristate "Cirrus Logic CS530x ADCs (SPI)" + depends on SPI_MASTER + select REGMAP_SPI + select SND_SOC_CS530X + help + Enable support for Cirrus Logic CS530X ADCs + with SPI control. + config SND_SOC_CX20442 tristate depends on TTY @@ -1567,6 +1610,7 @@ config SND_SOC_PEB2466 config SND_SOC_PM4125 depends on SND_SOC_PM4125_SDW + select SND_SOC_WCD_COMMON tristate depends on SOUNDWIRE || !SOUNDWIRE @@ -1575,6 +1619,7 @@ config SND_SOC_PM4125_SDW select SND_SOC_PM4125 select SND_SOC_WCD_MBHC select REGMAP_IRQ + select SND_SOC_WCD_COMMON depends on SOUNDWIRE select REGMAP_SOUNDWIRE help @@ -2310,6 +2355,7 @@ config SND_SOC_WCD934X tristate "WCD9340/WCD9341 Codec" depends on COMMON_CLK depends on SLIMBUS + depends on SOUNDWIRE || !SOUNDWIRE select REGMAP_IRQ select REGMAP_SLIMBUS select SND_SOC_WCD_CLASSH @@ -2715,6 +2761,10 @@ config SND_SOC_MT6660 config SND_SOC_NAU8315 tristate "Nuvoton Technology Corporation NAU8315 CODEC" +config SND_SOC_NAU8325 + tristate "Nuvoton Technology Corporation NAU8325 CODEC" + depends on I2C + config SND_SOC_NAU8540 tristate "Nuvoton Technology Corporation NAU85L40 CODEC" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index bd95a7c911d5..d687d4f74363 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -50,9 +50,9 @@ snd-soc-audio-iio-aux-y := audio-iio-aux.o snd-soc-aw8738-y := aw8738.o snd-soc-aw87390-y := aw87390.o snd-soc-aw88081-y := aw88081.o -snd-soc-aw88395-lib-y := aw88395/aw88395_lib.o -snd-soc-aw88395-y := aw88395/aw88395.o \ +snd-soc-aw88395-lib-y := aw88395/aw88395_lib.o \ aw88395/aw88395_device.o +snd-soc-aw88395-y := aw88395/aw88395.o snd-soc-aw88166-y := aw88166.o snd-soc-aw88261-y := aw88261.o snd-soc-aw88399-y := aw88399.o @@ -115,6 +115,7 @@ snd-soc-cs48l32-y := cs48l32.o cs48l32-tables.o snd-soc-cs53l30-y := cs53l30.o snd-soc-cs530x-y := cs530x.o snd-soc-cs530x-i2c-y := cs530x-i2c.o +snd-soc-cs530x-spi-y := cs530x-spi.o snd-soc-cx20442-y := cx20442.o snd-soc-cx2072x-y := cx2072x.o snd-soc-da7210-y := da7210.o @@ -192,6 +193,7 @@ snd-soc-mt6359-y := mt6359.o snd-soc-mt6359-accdet-y := mt6359-accdet.o snd-soc-mt6660-y := mt6660.o snd-soc-nau8315-y := nau8315.o +snd-soc-nau8325-y := nau8325.o snd-soc-nau8540-y := nau8540.o snd-soc-nau8810-y := nau8810.o snd-soc-nau8821-y := nau8821.o @@ -546,6 +548,7 @@ obj-$(CONFIG_SND_SOC_CS48L32) += snd-soc-cs48l32.o obj-$(CONFIG_SND_SOC_CS53L30) += snd-soc-cs53l30.o obj-$(CONFIG_SND_SOC_CS530X) += snd-soc-cs530x.o obj-$(CONFIG_SND_SOC_CS530X_I2C) += snd-soc-cs530x-i2c.o +obj-$(CONFIG_SND_SOC_CS530X_SPI) += snd-soc-cs530x-spi.o obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o obj-$(CONFIG_SND_SOC_CX2072X) += snd-soc-cx2072x.o obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o @@ -618,6 +621,7 @@ obj-$(CONFIG_SND_SOC_MT6359) += snd-soc-mt6359.o obj-$(CONFIG_SND_SOC_MT6359_ACCDET) += mt6359-accdet.o obj-$(CONFIG_SND_SOC_MT6660) += snd-soc-mt6660.o obj-$(CONFIG_SND_SOC_NAU8315) += snd-soc-nau8315.o +obj-$(CONFIG_SND_SOC_NAU8325) += snd-soc-nau8325.o obj-$(CONFIG_SND_SOC_NAU8540) += snd-soc-nau8540.o obj-$(CONFIG_SND_SOC_NAU8810) += snd-soc-nau8810.o obj-$(CONFIG_SND_SOC_NAU8821) += snd-soc-nau8821.o diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 04b5e1d5a653..fdda1b747bf7 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c @@ -1114,7 +1114,7 @@ static void anc_configure(struct snd_soc_component *component, static int sid_status_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); mutex_lock(&drvdata->ctrl_lock); @@ -1128,7 +1128,7 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol, static int sid_status_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); unsigned int param, sidconf, val; int status = 1; @@ -1183,7 +1183,7 @@ out: static int anc_status_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); mutex_lock(&drvdata->ctrl_lock); @@ -1196,8 +1196,8 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol, static int anc_status_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); struct device *dev = component->dev; bool apply_fir, apply_iir; @@ -1279,7 +1279,7 @@ static int filter_control_info(struct snd_kcontrol *kcontrol, static int filter_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ab8500_codec_drvdata *drvdata = snd_soc_component_get_drvdata(component); struct filter_control *fc = (struct filter_control *)kcontrol->private_value; @@ -1296,7 +1296,7 @@ static int filter_control_get(struct snd_kcontrol *kcontrol, static int filter_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ab8500_codec_drvdata *drvdata = snd_soc_component_get_drvdata(component); struct filter_control *fc = (struct filter_control *)kcontrol->private_value; @@ -1934,7 +1934,7 @@ static int ab8500_audio_init_audioblock(struct snd_soc_component *component) static int ab8500_audio_setup_mics(struct snd_soc_component *component, struct amic_settings *amics) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u8 value8; unsigned int value; int status; @@ -2449,7 +2449,7 @@ static void ab8500_codec_of_probe(struct device *dev, struct device_node *np, static int ab8500_codec_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct device *dev = component->dev; struct device_node *np = dev->of_node; struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(dev); diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c index 949077108bef..8afeadcaf8b0 100644 --- a/sound/soc/codecs/ad1836.c +++ b/sound/soc/codecs/ad1836.c @@ -250,7 +250,7 @@ static int ad1836_resume(struct snd_soc_component *component) static int ad1836_probe(struct snd_soc_component *component) { struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int num_dacs, num_adcs; int ret = 0; int i; diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index 1d3c4d94b4ae..b93531c3a9a4 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -282,7 +282,7 @@ static int ad193x_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { struct snd_soc_component *component = codec_dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component); if (clk_id == AD193X_SYSCLK_MCLK) { @@ -476,7 +476,7 @@ static void ad193x_reg_default_init(struct ad193x_priv *ad193x) static int ad193x_component_probe(struct snd_soc_component *component) { struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int num, ret; /* default setting for ad193x */ diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c index 1f09ea385f8a..a70c46dd5d76 100644 --- a/sound/soc/codecs/adau1761.c +++ b/sound/soc/codecs/adau1761.c @@ -621,6 +621,7 @@ static int adau1761_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct adau *adau = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -632,7 +633,7 @@ static int adau1761_set_bias_level(struct snd_soc_component *component, regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, ADAU17X1_CLOCK_CONTROL_SYSCLK_EN, ADAU17X1_CLOCK_CONTROL_SYSCLK_EN); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) regcache_sync(adau->regmap); break; case SND_SOC_BIAS_OFF: @@ -658,7 +659,7 @@ static enum adau1761_output_mode adau1761_get_lineout_mode( static int adau1761_setup_digmic_jackdetect(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adau1761_platform_data *pdata = component->dev->platform_data; struct adau *adau = snd_soc_component_get_drvdata(component); enum adau1761_digmic_jackdet_pin_mode mode; @@ -721,7 +722,7 @@ static int adau1761_setup_digmic_jackdetect(struct snd_soc_component *component) static int adau1761_setup_headphone_mode(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adau *adau = snd_soc_component_get_drvdata(component); struct adau1761_platform_data *pdata = component->dev->platform_data; enum adau1761_output_mode mode; @@ -819,7 +820,7 @@ static bool adau1761_readable_register(struct device *dev, unsigned int reg) static int adau1761_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adau1761_platform_data *pdata = component->dev->platform_data; struct adau *adau = snd_soc_component_get_drvdata(component); int ret; diff --git a/sound/soc/codecs/adau1781.c b/sound/soc/codecs/adau1781.c index faad2f9f8dd2..38cc0b6e4122 100644 --- a/sound/soc/codecs/adau1781.c +++ b/sound/soc/codecs/adau1781.c @@ -381,7 +381,7 @@ static int adau1781_set_input_mode(struct adau *adau, unsigned int reg, static int adau1781_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adau1781_platform_data *pdata = dev_get_platdata(component->dev); struct adau *adau = snd_soc_component_get_drvdata(component); int ret; diff --git a/sound/soc/codecs/adau17x1.c b/sound/soc/codecs/adau17x1.c index 0b6b0d2115eb..26d7eb437ad1 100644 --- a/sound/soc/codecs/adau17x1.c +++ b/sound/soc/codecs/adau17x1.c @@ -185,8 +185,8 @@ static const struct snd_soc_dapm_route adau17x1_dapm_pll_route = { static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adau *adau = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update update = {}; @@ -230,7 +230,7 @@ static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol, static int adau17x1_dsp_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct adau *adau = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int stream = e->shift_l; @@ -383,7 +383,7 @@ static int adau17x1_set_dai_pll(struct snd_soc_dai *dai, int pll_id, static int adau17x1_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(dai->component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(dai->component); struct adau *adau = snd_soc_component_get_drvdata(dai->component); bool is_pll; bool was_pll; @@ -881,7 +881,7 @@ static int adau17x1_setup_firmware(struct snd_soc_component *component, int ret; int dspsr, dsp_run; struct adau *adau = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); /* Check if sample rate is the same as before. If it is there is no * point in performing the below steps as the call to @@ -922,7 +922,7 @@ err: int adau17x1_add_widgets(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adau *adau = snd_soc_component_get_drvdata(component); int ret; @@ -958,7 +958,7 @@ EXPORT_SYMBOL_GPL(adau17x1_add_widgets); int adau17x1_add_routes(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adau *adau = snd_soc_component_get_drvdata(component); int ret; diff --git a/sound/soc/codecs/adau1977.c b/sound/soc/codecs/adau1977.c index c193a9f22f59..b42f35b1a603 100644 --- a/sound/soc/codecs/adau1977.c +++ b/sound/soc/codecs/adau1977.c @@ -473,6 +473,7 @@ static int adau1977_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret = 0; switch (level) { @@ -481,7 +482,7 @@ static int adau1977_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) ret = adau1977_power_enable(adau1977); break; case SND_SOC_BIAS_OFF: @@ -845,7 +846,7 @@ static int adau1977_set_sysclk(struct snd_soc_component *component, static int adau1977_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); int ret; diff --git a/sound/soc/codecs/adau7118.c b/sound/soc/codecs/adau7118.c index 14259807c872..5ddea63a6612 100644 --- a/sound/soc/codecs/adau7118.c +++ b/sound/soc/codecs/adau7118.c @@ -335,6 +335,7 @@ static int adau7118_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct adau7118_data *st = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret = 0; dev_dbg(st->dev, "Set bias level %d\n", level); @@ -345,8 +346,7 @@ static int adau7118_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == - SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* power on */ ret = regulator_enable(st->iovdd); if (ret) @@ -393,8 +393,7 @@ static int adau7118_set_bias_level(struct snd_soc_component *component, static int adau7118_component_probe(struct snd_soc_component *component) { struct adau7118_data *st = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret = 0; if (st->hw_mode) { diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index c8c0fc928211..8a89187f9c78 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c @@ -314,7 +314,7 @@ static int adav80x_set_deemph(struct snd_soc_component *component) static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; @@ -329,7 +329,7 @@ static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, static int adav80x_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct adav80x *adav80x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = adav80x->deemph; @@ -539,7 +539,7 @@ static int adav80x_set_sysclk(struct snd_soc_component *component, unsigned int freq, int dir) { struct adav80x *adav80x = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); if (dir == SND_SOC_CLOCK_IN) { switch (clk_id) { @@ -622,7 +622,7 @@ static int adav80x_set_sysclk(struct snd_soc_component *component, static int adav80x_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int pll_ctrl1 = 0; unsigned int pll_ctrl2 = 0; @@ -802,7 +802,7 @@ static struct snd_soc_dai_driver adav80x_dais[] = { static int adav80x_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adav80x *adav80x = snd_soc_component_get_drvdata(component); /* Force PLLs on for SYSCLK output */ diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c index 57cf601d3df3..f0b465f9ded5 100644 --- a/sound/soc/codecs/ak4458.c +++ b/sound/soc/codecs/ak4458.c @@ -187,7 +187,7 @@ static const struct soc_enum ak4458_dif_enum = static int get_digfil(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = ak4458->digfil; @@ -198,7 +198,7 @@ static int get_digfil(struct snd_kcontrol *kcontrol, static int set_digfil(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); int num; diff --git a/sound/soc/codecs/ak4619.c b/sound/soc/codecs/ak4619.c index 8f2442482f72..daf6e15b7077 100644 --- a/sound/soc/codecs/ak4619.c +++ b/sound/soc/codecs/ak4619.c @@ -257,7 +257,7 @@ static void ak4619_set_deemph(struct snd_soc_component *component) static int ak4619_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ak4619_priv *ak4619 = snd_soc_component_get_drvdata(component); int deemph_en = ucontrol->value.integer.value[0]; int ret = 0; @@ -282,7 +282,7 @@ static int ak4619_put_deemph(struct snd_kcontrol *kcontrol, static int ak4619_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ak4619_priv *ak4619 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = ak4619->deemph_en; diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index ec33e7d73c6c..9db8cdb26d33 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c @@ -91,7 +91,7 @@ static int ak4641_set_deemph(struct snd_soc_component *component) static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); int deemph = ucontrol->value.integer.value[0]; @@ -106,7 +106,7 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = ak4641->deemph; @@ -415,6 +415,7 @@ static int ak4641_mute(struct snd_soc_dai *dai, int mute, int direction) static int ak4641_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); struct ak4641_platform_data *pdata = component->dev->platform_data; int ret; @@ -429,7 +430,7 @@ static int ak4641_set_bias_level(struct snd_soc_component *component, snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0x20); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { if (pdata && gpio_is_valid(pdata->gpio_power)) gpio_set_value(pdata->gpio_power, 1); mdelay(1); diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c index fbf723758079..a9946dcdc9f6 100644 --- a/sound/soc/codecs/alc5623.c +++ b/sound/soc/codecs/alc5623.c @@ -888,7 +888,7 @@ static int alc5623_resume(struct snd_soc_component *component) static int alc5623_probe(struct snd_soc_component *component) { struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); alc5623_reset(component); diff --git a/sound/soc/codecs/arizona-jack.c b/sound/soc/codecs/arizona-jack.c index 6b55610ad535..303c1d44ebd8 100644 --- a/sound/soc/codecs/arizona-jack.c +++ b/sound/soc/codecs/arizona-jack.c @@ -212,17 +212,16 @@ static void arizona_extcon_pulse_micbias(struct arizona_priv *info) struct arizona *arizona = info->arizona; const char *widget = arizona_extcon_get_micbias(info); struct snd_soc_dapm_context *dapm = arizona->dapm; - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); int ret; - ret = snd_soc_component_force_enable_pin(component, widget); + ret = snd_soc_dapm_force_enable_pin(dapm, widget); if (ret) dev_warn(arizona->dev, "Failed to enable %s: %d\n", widget, ret); snd_soc_dapm_sync(dapm); if (!arizona->pdata.micd_force_micbias) { - ret = snd_soc_component_disable_pin(component, widget); + ret = snd_soc_dapm_disable_pin(dapm, widget); if (ret) dev_warn(arizona->dev, "Failed to disable %s: %d\n", widget, ret); @@ -287,7 +286,6 @@ static void arizona_stop_mic(struct arizona_priv *info) struct arizona *arizona = info->arizona; const char *widget = arizona_extcon_get_micbias(info); struct snd_soc_dapm_context *dapm = arizona->dapm; - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); bool change = false; int ret; @@ -297,7 +295,7 @@ static void arizona_stop_mic(struct arizona_priv *info) if (ret < 0) dev_err(arizona->dev, "Failed to disable micd: %d\n", ret); - ret = snd_soc_component_disable_pin(component, widget); + ret = snd_soc_dapm_disable_pin(dapm, widget); if (ret) dev_warn(arizona->dev, "Failed to disable %s: %d\n", widget, ret); diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index f2f47f1c1ac8..8c683b0bb74c 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -169,7 +169,7 @@ static const struct snd_soc_dapm_widget arizona_spkr = int arizona_init_spk(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int ret; @@ -238,7 +238,7 @@ static const struct snd_soc_dapm_route arizona_mono_routes[] = { int arizona_init_mono(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int i; @@ -255,6 +255,7 @@ EXPORT_SYMBOL_GPL(arizona_init_mono); int arizona_init_gpio(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int i; @@ -262,24 +263,21 @@ int arizona_init_gpio(struct snd_soc_component *component) switch (arizona->type) { case WM5110: case WM8280: - snd_soc_component_disable_pin(component, - "DRC2 Signal Activity"); + snd_soc_dapm_disable_pin(dapm, "DRC2 Signal Activity"); break; default: break; } - snd_soc_component_disable_pin(component, "DRC1 Signal Activity"); + snd_soc_dapm_disable_pin(dapm, "DRC1 Signal Activity"); for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) { switch (arizona->pdata.gpio_defaults[i] & ARIZONA_GPN_FN_MASK) { case ARIZONA_GP_FN_DRC1_SIGNAL_DETECT: - snd_soc_component_enable_pin(component, - "DRC1 Signal Activity"); + snd_soc_dapm_enable_pin(dapm, "DRC1 Signal Activity"); break; case ARIZONA_GP_FN_DRC2_SIGNAL_DETECT: - snd_soc_component_enable_pin(component, - "DRC2 Signal Activity"); + snd_soc_dapm_enable_pin(dapm, "DRC2 Signal Activity"); break; default: break; @@ -1911,7 +1909,7 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { struct snd_soc_component *component = dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1]; struct snd_soc_dapm_route routes[2]; @@ -2724,7 +2722,7 @@ static bool arizona_eq_filter_unstable(bool mode, __be16 _a, __be16 _b) int arizona_eq_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct soc_bytes *params = (void *)kcontrol->private_value; unsigned int val; @@ -2768,7 +2766,7 @@ EXPORT_SYMBOL_GPL(arizona_eq_coeff_put); int arizona_lhpf_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct arizona *arizona = dev_get_drvdata(component->dev->parent); __be16 *data = (__be16 *)ucontrol->value.bytes.data; s16 val = be16_to_cpu(*data); diff --git a/sound/soc/codecs/audio-iio-aux.c b/sound/soc/codecs/audio-iio-aux.c index 588e48044c13..066e401912b0 100644 --- a/sound/soc/codecs/audio-iio-aux.c +++ b/sound/soc/codecs/audio-iio-aux.c @@ -131,7 +131,7 @@ static_assert(ARRAY_SIZE(routes) >= 2, "2 routes are needed"); static int audio_iio_aux_add_dapms(struct snd_soc_component *component, struct audio_iio_aux_chan *chan) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; /* Allocated names are not needed afterwards (duplicated in ASoC internals) */ diff --git a/sound/soc/codecs/aw87390.c b/sound/soc/codecs/aw87390.c index ef6f64856988..d7fd865c349f 100644 --- a/sound/soc/codecs/aw87390.c +++ b/sound/soc/codecs/aw87390.c @@ -175,7 +175,7 @@ static int aw87390_dev_set_profile_index(struct aw_device *aw_dev, int index) static int aw87390_profile_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw87390 *aw87390 = snd_soc_component_get_drvdata(codec); char *prof_name; int count, ret; @@ -210,7 +210,7 @@ static int aw87390_profile_info(struct snd_kcontrol *kcontrol, static int aw87390_profile_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw87390 *aw87390 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw87390->aw_pa->prof_index; @@ -221,7 +221,7 @@ static int aw87390_profile_get(struct snd_kcontrol *kcontrol, static int aw87390_profile_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw87390 *aw87390 = snd_soc_component_get_drvdata(codec); int ret; @@ -360,7 +360,7 @@ static void aw87390_parse_channel_dt(struct aw87390 *aw87390) aw_dev->channel = channel_value; } -static int aw87390_init(struct aw87390 **aw87390, struct i2c_client *i2c, struct regmap *regmap) +static int aw87390_init(struct aw87390 *aw87390, struct i2c_client *i2c, struct regmap *regmap) { struct aw_device *aw_dev; unsigned int chip_id; @@ -384,7 +384,7 @@ static int aw87390_init(struct aw87390 **aw87390, struct i2c_client *i2c, struct if (!aw_dev) return -ENOMEM; - (*aw87390)->aw_pa = aw_dev; + aw87390->aw_pa = aw_dev; aw_dev->i2c = i2c; aw_dev->regmap = regmap; aw_dev->dev = &i2c->dev; @@ -398,7 +398,7 @@ static int aw87390_init(struct aw87390 **aw87390, struct i2c_client *i2c, struct aw_dev->prof_index = AW87390_INIT_PROFILE; aw_dev->status = AW87390_DEV_PW_OFF; - aw87390_parse_channel_dt(*aw87390); + aw87390_parse_channel_dt(aw87390); return 0; } @@ -426,7 +426,7 @@ static int aw87390_i2c_probe(struct i2c_client *i2c) "failed to init regmap\n"); /* aw pa init */ - ret = aw87390_init(&aw87390, i2c, aw87390->regmap); + ret = aw87390_init(aw87390, i2c, aw87390->regmap); if (ret) return ret; diff --git a/sound/soc/codecs/aw88081.c b/sound/soc/codecs/aw88081.c index d61a7b8c5470..fbd1fd12381a 100644 --- a/sound/soc/codecs/aw88081.c +++ b/sound/soc/codecs/aw88081.c @@ -779,7 +779,7 @@ static void aw88081_start(struct aw88081 *aw88081, bool sync_start) if (sync_start == AW88081_SYNC_START) aw88081_start_pa(aw88081); else - queue_delayed_work(system_wq, + queue_delayed_work(system_dfl_wq, &aw88081->start_work, AW88081_START_WORK_DELAY_MS); } @@ -808,7 +808,7 @@ static struct snd_soc_dai_driver aw88081_dai[] = { static int aw88081_get_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88081->aw_pa; @@ -820,7 +820,7 @@ static int aw88081_get_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88081_set_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -843,7 +843,7 @@ static int aw88081_set_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88081_get_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88081->aw_pa; @@ -855,7 +855,7 @@ static int aw88081_get_fade_out_time(struct snd_kcontrol *kcontrol, static int aw88081_set_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -891,7 +891,7 @@ static int aw88081_dev_set_profile_index(struct aw_device *aw_dev, int index) static int aw88081_profile_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(codec); char *prof_name; int count, ret; @@ -926,7 +926,7 @@ static int aw88081_profile_info(struct snd_kcontrol *kcontrol, static int aw88081_profile_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88081->aw_pa->prof_index; @@ -937,7 +937,7 @@ static int aw88081_profile_get(struct snd_kcontrol *kcontrol, static int aw88081_profile_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(codec); int ret; @@ -963,7 +963,7 @@ static int aw88081_profile_set(struct snd_kcontrol *kcontrol, static int aw88081_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88081->aw_pa->volume_desc; @@ -975,7 +975,7 @@ static int aw88081_volume_get(struct snd_kcontrol *kcontrol, static int aw88081_volume_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88081->aw_pa->volume_desc; struct soc_mixer_control *mc = @@ -1003,7 +1003,7 @@ static int aw88081_volume_set(struct snd_kcontrol *kcontrol, static int aw88081_get_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88081->aw_pa->fade_step; @@ -1014,7 +1014,7 @@ static int aw88081_get_fade_step(struct snd_kcontrol *kcontrol, static int aw88081_set_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88081 *aw88081 = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; diff --git a/sound/soc/codecs/aw88166.c b/sound/soc/codecs/aw88166.c index 28f62b991ef2..daee4de9e3b0 100644 --- a/sound/soc/codecs/aw88166.c +++ b/sound/soc/codecs/aw88166.c @@ -41,109 +41,6 @@ static const struct regmap_config aw88166_remap_config = { .val_format_endian = REGMAP_ENDIAN_BIG, }; -static int aw_dev_dsp_write_16bit(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int dsp_data) -{ - int ret; - - ret = regmap_write(aw_dev->regmap, AW88166_DSPMADD_REG, dsp_addr); - if (ret) { - dev_err(aw_dev->dev, "%s write addr error, ret=%d", __func__, ret); - return ret; - } - - ret = regmap_write(aw_dev->regmap, AW88166_DSPMDAT_REG, (u16)dsp_data); - if (ret) { - dev_err(aw_dev->dev, "%s write data error, ret=%d", __func__, ret); - return ret; - } - - return 0; -} - -static int aw_dev_dsp_read_16bit(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int *dsp_data) -{ - unsigned int temp_data; - int ret; - - ret = regmap_write(aw_dev->regmap, AW88166_DSPMADD_REG, dsp_addr); - if (ret) { - dev_err(aw_dev->dev, "%s write error, ret=%d", __func__, ret); - return ret; - } - - ret = regmap_read(aw_dev->regmap, AW88166_DSPMDAT_REG, &temp_data); - if (ret) { - dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); - return ret; - } - *dsp_data = temp_data; - - return 0; -} - -static int aw_dev_dsp_read_32bit(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int *dsp_data) -{ - unsigned int temp_data; - int ret; - - ret = regmap_write(aw_dev->regmap, AW88166_DSPMADD_REG, dsp_addr); - if (ret) { - dev_err(aw_dev->dev, "%s write error, ret=%d", __func__, ret); - return ret; - } - - ret = regmap_read(aw_dev->regmap, AW88166_DSPMDAT_REG, &temp_data); - if (ret) { - dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); - return ret; - } - *dsp_data = temp_data; - - ret = regmap_read(aw_dev->regmap, AW88166_DSPMDAT_REG, &temp_data); - if (ret) { - dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); - return ret; - } - *dsp_data |= (temp_data << 16); - - return 0; -} - -static int aw_dev_dsp_read(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int *dsp_data, unsigned char data_type) -{ - u32 reg_value; - int ret; - - mutex_lock(&aw_dev->dsp_lock); - switch (data_type) { - case AW88166_DSP_16_DATA: - ret = aw_dev_dsp_read_16bit(aw_dev, dsp_addr, dsp_data); - if (ret) - dev_err(aw_dev->dev, "read dsp_addr[0x%x] 16-bit failed", (u32)dsp_addr); - break; - case AW88166_DSP_32_DATA: - ret = aw_dev_dsp_read_32bit(aw_dev, dsp_addr, dsp_data); - if (ret) - dev_err(aw_dev->dev, "read dsp_addr[0x%x] 32-bit failed", (u32)dsp_addr); - break; - default: - dev_err(aw_dev->dev, "data type[%d] unsupported", data_type); - ret = -EINVAL; - break; - } - - /* clear dsp chip select state */ - if (regmap_read(aw_dev->regmap, AW88166_ID_REG, ®_value)) - dev_err(aw_dev->dev, "%s fail to clear chip state. ret=%d\n", __func__, ret); - mutex_unlock(&aw_dev->dsp_lock); - - return ret; -} - static void aw_dev_pwd(struct aw_device *aw_dev, bool pwd) { int ret; @@ -904,25 +801,19 @@ static int aw_dev_dsp_update_container(struct aw_device *aw_dev, u32 tmp_len; int i, ret; - mutex_lock(&aw_dev->dsp_lock); ret = regmap_write(aw_dev->regmap, AW88166_DSPMADD_REG, base); if (ret) - goto error_operation; + return ret; for (i = 0; i < len; i += AW88166_MAX_RAM_WRITE_BYTE_SIZE) { tmp_len = min(len - i, AW88166_MAX_RAM_WRITE_BYTE_SIZE); ret = regmap_raw_write(aw_dev->regmap, AW88166_DSPMDAT_REG, &data[i], tmp_len); if (ret) - goto error_operation; + return ret; } - mutex_unlock(&aw_dev->dsp_lock); return 0; - -error_operation: - mutex_unlock(&aw_dev->dsp_lock); - return ret; } static int aw_dev_get_ra(struct aw_cali_desc *cali_desc) @@ -933,7 +824,7 @@ static int aw_dev_get_ra(struct aw_cali_desc *cali_desc) int ret; ret = aw_dev_dsp_read(aw_dev, AW88166_DSP_REG_CFG_ADPZ_RA, - &dsp_ra, AW88166_DSP_32_DATA); + &dsp_ra, AW_DSP_32_DATA); if (ret) { dev_err(aw_dev->dev, "read ra error\n"); return ret; @@ -990,29 +881,25 @@ static int aw_dev_check_sram(struct aw_device *aw_dev) { unsigned int reg_val; - mutex_lock(&aw_dev->dsp_lock); /* read dsp_rom_check_reg */ - aw_dev_dsp_read_16bit(aw_dev, AW88166_DSP_ROM_CHECK_ADDR, ®_val); + aw_dev_dsp_read(aw_dev, AW88166_DSP_ROM_CHECK_ADDR, ®_val, AW_DSP_16_DATA); if (reg_val != AW88166_DSP_ROM_CHECK_DATA) { dev_err(aw_dev->dev, "check dsp rom failed, read[0x%x] != check[0x%x]\n", reg_val, AW88166_DSP_ROM_CHECK_DATA); - goto error; + return -EPERM; } /* check dsp_cfg_base_addr */ - aw_dev_dsp_write_16bit(aw_dev, AW88166_DSP_CFG_ADDR, AW88166_DSP_ODD_NUM_BIT_TEST); - aw_dev_dsp_read_16bit(aw_dev, AW88166_DSP_CFG_ADDR, ®_val); + aw_dev_dsp_write(aw_dev, AW88166_DSP_CFG_ADDR, + AW88166_DSP_ODD_NUM_BIT_TEST, AW_DSP_16_DATA); + aw_dev_dsp_read(aw_dev, AW88166_DSP_CFG_ADDR, ®_val, AW_DSP_16_DATA); if (reg_val != AW88166_DSP_ODD_NUM_BIT_TEST) { dev_err(aw_dev->dev, "check dsp cfg failed, read[0x%x] != write[0x%x]\n", reg_val, AW88166_DSP_ODD_NUM_BIT_TEST); - goto error; + return -EPERM; } - mutex_unlock(&aw_dev->dsp_lock); return 0; -error: - mutex_unlock(&aw_dev->dsp_lock); - return -EPERM; } static void aw_dev_select_memclk(struct aw_device *aw_dev, unsigned char flag) @@ -1310,7 +1197,7 @@ static void aw88166_start(struct aw88166 *aw88166, bool sync_start) if (sync_start == AW88166_SYNC_START) aw88166_start_pa(aw88166); else - queue_delayed_work(system_wq, + queue_delayed_work(system_dfl_wq, &aw88166->start_work, AW88166_START_WORK_DELAY_MS); } @@ -1391,7 +1278,7 @@ static struct snd_soc_dai_driver aw88166_dai[] = { static int aw88166_get_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88166->aw_pa; @@ -1403,7 +1290,7 @@ static int aw88166_get_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88166_set_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1426,7 +1313,7 @@ static int aw88166_set_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88166_get_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88166->aw_pa; @@ -1438,7 +1325,7 @@ static int aw88166_get_fade_out_time(struct snd_kcontrol *kcontrol, static int aw88166_set_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1476,7 +1363,7 @@ static int aw88166_dev_set_profile_index(struct aw_device *aw_dev, int index) static int aw88166_profile_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); char *prof_name; int count, ret; @@ -1511,7 +1398,7 @@ static int aw88166_profile_info(struct snd_kcontrol *kcontrol, static int aw88166_profile_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88166->aw_pa->prof_index; @@ -1522,7 +1409,7 @@ static int aw88166_profile_get(struct snd_kcontrol *kcontrol, static int aw88166_profile_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); int ret; @@ -1547,7 +1434,7 @@ static int aw88166_profile_set(struct snd_kcontrol *kcontrol, static int aw88166_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88166->aw_pa->volume_desc; @@ -1559,7 +1446,7 @@ static int aw88166_volume_get(struct snd_kcontrol *kcontrol, static int aw88166_volume_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88166->aw_pa->volume_desc; struct soc_mixer_control *mc = @@ -1583,7 +1470,7 @@ static int aw88166_volume_set(struct snd_kcontrol *kcontrol, static int aw88166_get_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88166->aw_pa->fade_step; @@ -1594,7 +1481,7 @@ static int aw88166_get_fade_step(struct snd_kcontrol *kcontrol, static int aw88166_set_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1615,7 +1502,7 @@ static int aw88166_set_fade_step(struct snd_kcontrol *kcontrol, static int aw88166_re_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); struct aw_device *aw_dev = aw88166->aw_pa; @@ -1627,7 +1514,7 @@ static int aw88166_re_get(struct snd_kcontrol *kcontrol, static int aw88166_re_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88166 *aw88166 = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; diff --git a/sound/soc/codecs/aw88166.h b/sound/soc/codecs/aw88166.h index 3a53ba0ac625..9f3f47a7003e 100644 --- a/sound/soc/codecs/aw88166.h +++ b/sound/soc/codecs/aw88166.h @@ -517,11 +517,6 @@ enum AW88166_DEV_DSP_CFG { }; enum { - AW88166_DSP_16_DATA = 0, - AW88166_DSP_32_DATA = 1, -}; - -enum { AW88166_SYNC_START = 0, AW88166_ASYNC_START, }; diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c index de11ae8dd9d9..8f37bfb974ae 100644 --- a/sound/soc/codecs/aw88261.c +++ b/sound/soc/codecs/aw88261.c @@ -705,7 +705,7 @@ static void aw88261_start(struct aw88261 *aw88261, bool sync_start) if (sync_start == AW88261_SYNC_START) aw88261_start_pa(aw88261); else - queue_delayed_work(system_wq, + queue_delayed_work(system_dfl_wq, &aw88261->start_work, AW88261_START_WORK_DELAY_MS); } @@ -734,7 +734,7 @@ static struct snd_soc_dai_driver aw88261_dai[] = { static int aw88261_get_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88261->aw_pa; @@ -746,7 +746,7 @@ static int aw88261_get_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88261_set_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -769,7 +769,7 @@ static int aw88261_set_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88261_get_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88261->aw_pa; @@ -781,7 +781,7 @@ static int aw88261_get_fade_out_time(struct snd_kcontrol *kcontrol, static int aw88261_set_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -817,7 +817,7 @@ static int aw88261_dev_set_profile_index(struct aw_device *aw_dev, int index) static int aw88261_profile_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec); char *prof_name; int count, ret; @@ -852,7 +852,7 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol, static int aw88261_profile_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88261->aw_pa->prof_index; @@ -863,7 +863,7 @@ static int aw88261_profile_get(struct snd_kcontrol *kcontrol, static int aw88261_profile_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec); int ret; @@ -889,7 +889,7 @@ static int aw88261_profile_set(struct snd_kcontrol *kcontrol, static int aw88261_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88261->aw_pa->volume_desc; @@ -901,7 +901,7 @@ static int aw88261_volume_get(struct snd_kcontrol *kcontrol, static int aw88261_volume_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88261->aw_pa->volume_desc; struct soc_mixer_control *mc = @@ -926,7 +926,7 @@ static int aw88261_volume_set(struct snd_kcontrol *kcontrol, static int aw88261_get_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88261->aw_pa->fade_step; @@ -937,7 +937,7 @@ static int aw88261_get_fade_step(struct snd_kcontrol *kcontrol, static int aw88261_set_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1131,7 +1131,7 @@ static int aw88261_request_firmware_file(struct aw88261 *aw88261) static int aw88261_codec_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct aw88261 *aw88261 = snd_soc_component_get_drvdata(component); int ret; @@ -1184,7 +1184,7 @@ static void aw88261_parse_channel_dt(struct aw88261 *aw88261) aw_dev->channel = channel_value; } -static int aw88261_init(struct aw88261 **aw88261, struct i2c_client *i2c, struct regmap *regmap) +static int aw88261_init(struct aw88261 *aw88261, struct i2c_client *i2c, struct regmap *regmap) { struct aw_device *aw_dev; unsigned int chip_id; @@ -1207,7 +1207,7 @@ static int aw88261_init(struct aw88261 **aw88261, struct i2c_client *i2c, struct if (!aw_dev) return -ENOMEM; - (*aw88261)->aw_pa = aw_dev; + aw88261->aw_pa = aw_dev; aw_dev->i2c = i2c; aw_dev->regmap = regmap; aw_dev->dev = &i2c->dev; @@ -1221,7 +1221,7 @@ static int aw88261_init(struct aw88261 **aw88261, struct i2c_client *i2c, struct aw_dev->fade_step = AW88261_VOLUME_STEP_DB; aw_dev->volume_desc.ctl_volume = AW88261_VOL_DEFAULT_VALUE; aw_dev->volume_desc.mute_volume = AW88261_MUTE_VOL; - aw88261_parse_channel_dt(*aw88261); + aw88261_parse_channel_dt(aw88261); return ret; } @@ -1250,7 +1250,7 @@ static int aw88261_i2c_probe(struct i2c_client *i2c) } /* aw pa init */ - ret = aw88261_init(&aw88261, i2c, aw88261->regmap); + ret = aw88261_init(aw88261, i2c, aw88261->regmap); if (ret) return ret; diff --git a/sound/soc/codecs/aw88395/aw88395.c b/sound/soc/codecs/aw88395/aw88395.c index fb563b4c6971..3602b5b9f7d7 100644 --- a/sound/soc/codecs/aw88395/aw88395.c +++ b/sound/soc/codecs/aw88395/aw88395.c @@ -75,7 +75,7 @@ static void aw88395_start(struct aw88395 *aw88395, bool sync_start) if (sync_start == AW88395_SYNC_START) aw88395_start_pa(aw88395); else - queue_delayed_work(system_wq, + queue_delayed_work(system_dfl_wq, &aw88395->start_work, AW88395_START_WORK_DELAY_MS); } @@ -104,7 +104,7 @@ static struct snd_soc_dai_driver aw88395_dai[] = { static int aw88395_get_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88395->aw_pa; @@ -116,7 +116,7 @@ static int aw88395_get_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88395_set_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -139,7 +139,7 @@ static int aw88395_set_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88395_get_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88395->aw_pa; @@ -151,7 +151,7 @@ static int aw88395_get_fade_out_time(struct snd_kcontrol *kcontrol, static int aw88395_set_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -173,7 +173,7 @@ static int aw88395_set_fade_out_time(struct snd_kcontrol *kcontrol, static int aw88395_profile_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); char *prof_name; int count, ret; @@ -208,7 +208,7 @@ static int aw88395_profile_info(struct snd_kcontrol *kcontrol, static int aw88395_profile_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88395_dev_get_profile_index(aw88395->aw_pa); @@ -219,7 +219,7 @@ static int aw88395_profile_get(struct snd_kcontrol *kcontrol, static int aw88395_profile_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); int ret; @@ -245,7 +245,7 @@ static int aw88395_profile_set(struct snd_kcontrol *kcontrol, static int aw88395_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88395->aw_pa->volume_desc; @@ -257,7 +257,7 @@ static int aw88395_volume_get(struct snd_kcontrol *kcontrol, static int aw88395_volume_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88395->aw_pa->volume_desc; struct soc_mixer_control *mc = @@ -281,7 +281,7 @@ static int aw88395_volume_set(struct snd_kcontrol *kcontrol, static int aw88395_get_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88395->aw_pa->fade_step; @@ -292,7 +292,7 @@ static int aw88395_get_fade_step(struct snd_kcontrol *kcontrol, static int aw88395_set_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -313,7 +313,7 @@ static int aw88395_set_fade_step(struct snd_kcontrol *kcontrol, static int aw88395_re_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); struct aw_device *aw_dev = aw88395->aw_pa; @@ -325,7 +325,7 @@ static int aw88395_re_get(struct snd_kcontrol *kcontrol, static int aw88395_re_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -401,7 +401,7 @@ static const struct snd_soc_dapm_route aw88395_audio_map[] = { static int aw88395_codec_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); int ret; diff --git a/sound/soc/codecs/aw88395/aw88395_device.c b/sound/soc/codecs/aw88395/aw88395_device.c index e1430940015d..79c3135a4110 100644 --- a/sound/soc/codecs/aw88395/aw88395_device.c +++ b/sound/soc/codecs/aw88395/aw88395_device.c @@ -64,7 +64,7 @@ static int aw_dev_dsp_write_32bit(struct aw_device *aw_dev, return 0; } -static int aw_dev_dsp_write(struct aw_device *aw_dev, +int aw_dev_dsp_write(struct aw_device *aw_dev, unsigned short dsp_addr, unsigned int dsp_data, unsigned char data_type) { u32 reg_value; @@ -72,13 +72,13 @@ static int aw_dev_dsp_write(struct aw_device *aw_dev, mutex_lock(&aw_dev->dsp_lock); switch (data_type) { - case AW88395_DSP_16_DATA: + case AW_DSP_16_DATA: ret = aw_dev_dsp_write_16bit(aw_dev, dsp_addr, dsp_data); if (ret) dev_err(aw_dev->dev, "write dsp_addr[0x%x] 16-bit dsp_data[0x%x] failed", (u32)dsp_addr, dsp_data); break; - case AW88395_DSP_32_DATA: + case AW_DSP_32_DATA: ret = aw_dev_dsp_write_32bit(aw_dev, dsp_addr, dsp_data); if (ret) dev_err(aw_dev->dev, "write dsp_addr[0x%x] 32-bit dsp_data[0x%x] failed", @@ -97,6 +97,7 @@ static int aw_dev_dsp_write(struct aw_device *aw_dev, return ret; } +EXPORT_SYMBOL_GPL(aw_dev_dsp_write); static int aw_dev_dsp_read_16bit(struct aw_device *aw_dev, unsigned short dsp_addr, unsigned int *dsp_data) @@ -149,7 +150,7 @@ static int aw_dev_dsp_read_32bit(struct aw_device *aw_dev, return 0; } -static int aw_dev_dsp_read(struct aw_device *aw_dev, +int aw_dev_dsp_read(struct aw_device *aw_dev, unsigned short dsp_addr, unsigned int *dsp_data, unsigned char data_type) { u32 reg_value; @@ -157,13 +158,13 @@ static int aw_dev_dsp_read(struct aw_device *aw_dev, mutex_lock(&aw_dev->dsp_lock); switch (data_type) { - case AW88395_DSP_16_DATA: + case AW_DSP_16_DATA: ret = aw_dev_dsp_read_16bit(aw_dev, dsp_addr, dsp_data); if (ret) dev_err(aw_dev->dev, "read dsp_addr[0x%x] 16-bit dsp_data[0x%x] failed", (u32)dsp_addr, *dsp_data); break; - case AW88395_DSP_32_DATA: + case AW_DSP_32_DATA: ret = aw_dev_dsp_read_32bit(aw_dev, dsp_addr, dsp_data); if (ret) dev_err(aw_dev->dev, "read dsp_addr[0x%x] 32r-bit dsp_data[0x%x] failed", @@ -182,7 +183,7 @@ static int aw_dev_dsp_read(struct aw_device *aw_dev, return ret; } - +EXPORT_SYMBOL_GPL(aw_dev_dsp_read); static int aw_dev_read_chipid(struct aw_device *aw_dev, u16 *chip_id) { @@ -231,7 +232,7 @@ static int aw_dev_dsp_fw_check(struct aw_device *aw_dev) dsp_fw_desc = &set_prof_desc->sec_desc[AW88395_DATA_TYPE_DSP_FW]; for (i = 0; i < AW88395_FW_CHECK_PART; i++) { - ret = aw_dev_dsp_read(aw_dev, addr, &dsp_val, AW88395_DSP_16_DATA); + ret = aw_dev_dsp_read(aw_dev, addr, &dsp_val, AW_DSP_16_DATA); if (ret) { dev_err(aw_dev->dev, "dsp read failed"); return ret; @@ -351,11 +352,11 @@ static int aw_dev_modify_dsp_cfg(struct aw_device *aw_dev, return -EINVAL; } switch (data_type) { - case AW88395_DSP_16_DATA: + case AW_DSP_16_DATA: data1 = cpu_to_le16((u16)dsp_data); memcpy(crc_dsp_cfg->data + addr_offset, (u8 *)&data1, 2); break; - case AW88395_DSP_32_DATA: + case AW_DSP_32_DATA: data2 = cpu_to_le32(dsp_data); memcpy(crc_dsp_cfg->data + addr_offset, (u8 *)&data2, 4); break; @@ -377,14 +378,14 @@ static int aw_dev_dsp_set_cali_re(struct aw_device *aw_dev) /* set cali re to device */ ret = aw_dev_dsp_write(aw_dev, - AW88395_DSP_REG_CFG_ADPZ_RE, cali_re, AW88395_DSP_32_DATA); + AW88395_DSP_REG_CFG_ADPZ_RE, cali_re, AW_DSP_32_DATA); if (ret) { dev_err(aw_dev->dev, "set cali re error"); return ret; } ret = aw_dev_modify_dsp_cfg(aw_dev, AW88395_DSP_REG_CFG_ADPZ_RE, - cali_re, AW88395_DSP_32_DATA); + cali_re, AW_DSP_32_DATA); if (ret) dev_err(aw_dev->dev, "modify dsp cfg failed"); @@ -428,7 +429,7 @@ static int aw_dev_dsp_set_crc32(struct aw_device *aw_dev) crc_value = crc32c(0xFFFFFFFF, crc_dsp_cfg->data, crc_data_len) ^ 0xFFFFFFFF; return aw_dev_dsp_write(aw_dev, AW88395_DSP_REG_CRC_ADDR, crc_value, - AW88395_DSP_32_DATA); + AW_DSP_32_DATA); } static void aw_dev_dsp_check_crc_enable(struct aw_device *aw_dev, bool flag) @@ -663,7 +664,7 @@ static int aw_dev_set_vcalb(struct aw_device *aw_dev) int vcalb, vcalk; int ret; - ret = aw_dev_dsp_read(aw_dev, AW88395_DSP_REG_VCALB, &vcalb_adj, AW88395_DSP_16_DATA); + ret = aw_dev_dsp_read(aw_dev, AW88395_DSP_REG_VCALB, &vcalb_adj, AW_DSP_16_DATA); if (ret) { dev_err(aw_dev->dev, "read vcalb_adj failed"); return ret; @@ -720,14 +721,14 @@ static int aw_dev_set_vcalb(struct aw_device *aw_dev) dev_dbg(aw_dev->dev, "vcalb=%d, reg_val=0x%x, vcalb_adj =0x%x", vcalb, reg_val, vcalb_adj); - ret = aw_dev_dsp_write(aw_dev, AW88395_DSP_REG_VCALB, reg_val, AW88395_DSP_16_DATA); + ret = aw_dev_dsp_write(aw_dev, AW88395_DSP_REG_VCALB, reg_val, AW_DSP_16_DATA); if (ret) { dev_err(aw_dev->dev, "write vcalb failed"); return ret; } ret = aw_dev_modify_dsp_cfg(aw_dev, AW88395_DSP_REG_VCALB, - (u32)reg_val, AW88395_DSP_16_DATA); + (u32)reg_val, AW_DSP_16_DATA); if (ret) dev_err(aw_dev->dev, "modify dsp cfg failed"); @@ -741,7 +742,7 @@ static int aw_dev_get_cali_f0_delay(struct aw_device *aw_dev) int ret; ret = aw_dev_dsp_read(aw_dev, - AW88395_DSP_CALI_F0_DELAY, &cali_delay, AW88395_DSP_16_DATA); + AW88395_DSP_CALI_F0_DELAY, &cali_delay, AW_DSP_16_DATA); if (ret) dev_err(aw_dev->dev, "read cali delay failed, ret=%d", ret); else @@ -991,7 +992,7 @@ static int aw_dev_get_dsp_status(struct aw_device *aw_dev) static int aw_dev_get_vmax(struct aw_device *aw_dev, unsigned int *vmax) { - return aw_dev_dsp_read(aw_dev, AW88395_DSP_REG_VMAX, vmax, AW88395_DSP_16_DATA); + return aw_dev_dsp_read(aw_dev, AW88395_DSP_REG_VMAX, vmax, AW_DSP_16_DATA); } static int aw_dev_update_reg_container(struct aw_device *aw_dev, @@ -1089,7 +1090,7 @@ static int aw_dev_get_ra(struct aw_cali_desc *cali_desc) int ret; ret = aw_dev_dsp_read(aw_dev, AW88395_DSP_REG_CFG_ADPZ_RA, - &dsp_ra, AW88395_DSP_32_DATA); + &dsp_ra, AW_DSP_32_DATA); if (ret) { dev_err(aw_dev->dev, "read ra error"); return ret; diff --git a/sound/soc/codecs/aw88395/aw88395_device.h b/sound/soc/codecs/aw88395/aw88395_device.h index 6f8b30b475da..3626f222899d 100644 --- a/sound/soc/codecs/aw88395/aw88395_device.h +++ b/sound/soc/codecs/aw88395/aw88395_device.h @@ -89,8 +89,8 @@ enum AW88395_DEV_DSP_CFG { }; enum { - AW88395_DSP_16_DATA = 0, - AW88395_DSP_32_DATA = 1, + AW_DSP_16_DATA = 0, + AW_DSP_32_DATA = 1, }; enum { @@ -210,5 +210,9 @@ int aw88395_dev_get_profile_count(struct aw_device *aw_dev); int aw88395_dev_load_acf_check(struct aw_device *aw_dev, struct aw_container *aw_cfg); int aw88395_dev_cfg_load(struct aw_device *aw_dev, struct aw_container *aw_cfg); void aw88395_dev_mute(struct aw_device *aw_dev, bool is_mute); +int aw_dev_dsp_write(struct aw_device *aw_dev, + unsigned short dsp_addr, unsigned int dsp_data, unsigned char data_type); +int aw_dev_dsp_read(struct aw_device *aw_dev, + unsigned short dsp_addr, unsigned int *dsp_data, unsigned char data_type); #endif diff --git a/sound/soc/codecs/aw88399.c b/sound/soc/codecs/aw88399.c index 58846feb013d..b588c27909b5 100644 --- a/sound/soc/codecs/aw88399.c +++ b/sound/soc/codecs/aw88399.c @@ -26,172 +26,6 @@ static const struct regmap_config aw88399_remap_config = { .val_format_endian = REGMAP_ENDIAN_BIG, }; -static int aw_dev_dsp_write_16bit(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int dsp_data) -{ - int ret; - - ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, dsp_addr); - if (ret) { - dev_err(aw_dev->dev, "%s write addr error, ret=%d", __func__, ret); - return ret; - } - - ret = regmap_write(aw_dev->regmap, AW88399_DSPMDAT_REG, (u16)dsp_data); - if (ret) { - dev_err(aw_dev->dev, "%s write data error, ret=%d", __func__, ret); - return ret; - } - - return 0; -} - -static int aw_dev_dsp_write_32bit(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int dsp_data) -{ - unsigned int temp_data; - int ret; - - ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, dsp_addr); - if (ret) { - dev_err(aw_dev->dev, "%s write addr error, ret=%d", __func__, ret); - return ret; - } - - temp_data = dsp_data & AW88395_DSP_16_DATA_MASK; - ret = regmap_write(aw_dev->regmap, AW88399_DSPMDAT_REG, temp_data); - if (ret) { - dev_err(aw_dev->dev, "%s write datal error, ret=%d", __func__, ret); - return ret; - } - - temp_data = dsp_data >> 16; - ret = regmap_write(aw_dev->regmap, AW88399_DSPMDAT_REG, temp_data); - if (ret) - dev_err(aw_dev->dev, "%s write datah error, ret=%d", __func__, ret); - - return ret; -} - -static int aw_dev_dsp_write(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int dsp_data, unsigned char data_type) -{ - unsigned int reg_value; - int ret; - - mutex_lock(&aw_dev->dsp_lock); - switch (data_type) { - case AW88395_DSP_16_DATA: - ret = aw_dev_dsp_write_16bit(aw_dev, dsp_addr, dsp_data); - if (ret) - dev_err(aw_dev->dev, "write dsp_addr[0x%x] 16-bit dsp_data[0x%x] failed", - dsp_addr, dsp_data); - break; - case AW88395_DSP_32_DATA: - ret = aw_dev_dsp_write_32bit(aw_dev, dsp_addr, dsp_data); - if (ret) - dev_err(aw_dev->dev, "write dsp_addr[0x%x] 32-bit dsp_data[0x%x] failed", - dsp_addr, dsp_data); - break; - default: - dev_err(aw_dev->dev, "data type[%d] unsupported", data_type); - ret = -EINVAL; - break; - } - - /* clear dsp chip select state */ - if (regmap_read(aw_dev->regmap, 0x00, ®_value)) - dev_err(aw_dev->dev, "%s fail to clear chip state. Err=%d\n", __func__, ret); - mutex_unlock(&aw_dev->dsp_lock); - - return ret; -} - -static int aw_dev_dsp_read_16bit(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int *dsp_data) -{ - unsigned int temp_data; - int ret; - - ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, dsp_addr); - if (ret) { - dev_err(aw_dev->dev, "%s write error, ret=%d", __func__, ret); - return ret; - } - - ret = regmap_read(aw_dev->regmap, AW88399_DSPMDAT_REG, &temp_data); - if (ret) { - dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); - return ret; - } - *dsp_data = temp_data; - - return 0; -} - -static int aw_dev_dsp_read_32bit(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int *dsp_data) -{ - unsigned int temp_data; - int ret; - - ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, dsp_addr); - if (ret) { - dev_err(aw_dev->dev, "%s write error, ret=%d", __func__, ret); - return ret; - } - - ret = regmap_read(aw_dev->regmap, AW88399_DSPMDAT_REG, &temp_data); - if (ret) { - dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); - return ret; - } - *dsp_data = temp_data; - - ret = regmap_read(aw_dev->regmap, AW88399_DSPMDAT_REG, &temp_data); - if (ret) { - dev_err(aw_dev->dev, "%s read error, ret=%d", __func__, ret); - return ret; - } - *dsp_data |= (temp_data << 16); - - return 0; -} - -static int aw_dev_dsp_read(struct aw_device *aw_dev, - unsigned short dsp_addr, unsigned int *dsp_data, unsigned char data_type) -{ - u32 reg_value; - int ret; - - mutex_lock(&aw_dev->dsp_lock); - switch (data_type) { - case AW88399_DSP_16_DATA: - ret = aw_dev_dsp_read_16bit(aw_dev, dsp_addr, dsp_data); - if (ret) - dev_err(aw_dev->dev, "read dsp_addr[0x%x] 16-bit dsp_data[0x%x] failed", - (u32)dsp_addr, *dsp_data); - break; - case AW88399_DSP_32_DATA: - ret = aw_dev_dsp_read_32bit(aw_dev, dsp_addr, dsp_data); - if (ret) - dev_err(aw_dev->dev, "read dsp_addr[0x%x] 32r-bit dsp_data[0x%x] failed", - (u32)dsp_addr, *dsp_data); - break; - default: - dev_err(aw_dev->dev, "data type[%d] unsupported", data_type); - ret = -EINVAL; - break; - } - - /* clear dsp chip select state */ - if (regmap_read(aw_dev->regmap, AW88399_ID_REG, ®_value)) - dev_err(aw_dev->dev, "%s fail to clear chip state. ret=%d\n", __func__, ret); - mutex_unlock(&aw_dev->dsp_lock); - - return ret; -} - static void aw_dev_pwd(struct aw_device *aw_dev, bool pwd) { int ret; @@ -929,25 +763,19 @@ static int aw_dev_dsp_update_container(struct aw_device *aw_dev, u32 tmp_len; int i, ret; - mutex_lock(&aw_dev->dsp_lock); ret = regmap_write(aw_dev->regmap, AW88399_DSPMADD_REG, base); if (ret) - goto error_operation; + return ret; for (i = 0; i < len; i += AW88399_MAX_RAM_WRITE_BYTE_SIZE) { tmp_len = min(len - i, AW88399_MAX_RAM_WRITE_BYTE_SIZE); ret = regmap_raw_write(aw_dev->regmap, AW88399_DSPMDAT_REG, &data[i], tmp_len); if (ret) - goto error_operation; + return ret; } - mutex_unlock(&aw_dev->dsp_lock); return 0; - -error_operation: - mutex_unlock(&aw_dev->dsp_lock); - return ret; } static int aw_dev_get_ra(struct aw_cali_desc *cali_desc) @@ -958,7 +786,7 @@ static int aw_dev_get_ra(struct aw_cali_desc *cali_desc) int ret; ret = aw_dev_dsp_read(aw_dev, AW88399_DSP_REG_CFG_ADPZ_RA, - &dsp_ra, AW88399_DSP_32_DATA); + &dsp_ra, AW_DSP_32_DATA); if (ret) { dev_err(aw_dev->dev, "read ra error"); return ret; @@ -1015,29 +843,25 @@ static int aw_dev_check_sram(struct aw_device *aw_dev) { unsigned int reg_val; - mutex_lock(&aw_dev->dsp_lock); /* read dsp_rom_check_reg */ - aw_dev_dsp_read_16bit(aw_dev, AW88399_DSP_ROM_CHECK_ADDR, ®_val); + aw_dev_dsp_read(aw_dev, AW88399_DSP_ROM_CHECK_ADDR, ®_val, AW_DSP_16_DATA); if (reg_val != AW88399_DSP_ROM_CHECK_DATA) { dev_err(aw_dev->dev, "check dsp rom failed, read[0x%x] != check[0x%x]", reg_val, AW88399_DSP_ROM_CHECK_DATA); - goto error; + return -EPERM; } /* check dsp_cfg_base_addr */ - aw_dev_dsp_write_16bit(aw_dev, AW88399_DSP_CFG_ADDR, AW88399_DSP_ODD_NUM_BIT_TEST); - aw_dev_dsp_read_16bit(aw_dev, AW88399_DSP_CFG_ADDR, ®_val); + aw_dev_dsp_write(aw_dev, AW88399_DSP_CFG_ADDR, + AW88399_DSP_ODD_NUM_BIT_TEST, AW_DSP_16_DATA); + aw_dev_dsp_read(aw_dev, AW88399_DSP_CFG_ADDR, ®_val, AW_DSP_16_DATA); if (reg_val != AW88399_DSP_ODD_NUM_BIT_TEST) { dev_err(aw_dev->dev, "check dsp cfg failed, read[0x%x] != write[0x%x]", reg_val, AW88399_DSP_ODD_NUM_BIT_TEST); - goto error; + return -EPERM; } - mutex_unlock(&aw_dev->dsp_lock); return 0; -error: - mutex_unlock(&aw_dev->dsp_lock); - return -EPERM; } static void aw_dev_select_memclk(struct aw_device *aw_dev, unsigned char flag) @@ -1340,7 +1164,7 @@ static void aw88399_start(struct aw88399 *aw88399, bool sync_start) if (sync_start == AW88399_SYNC_START) aw88399_start_pa(aw88399); else - queue_delayed_work(system_wq, + queue_delayed_work(system_dfl_wq, &aw88399->start_work, AW88399_START_WORK_DELAY_MS); } @@ -1432,22 +1256,22 @@ static int aw_cali_svc_get_cali_cfg(struct aw_device *aw_dev) int ret; ret = aw_dev_dsp_read(aw_dev, AW88399_DSP_REG_CFG_MBMEC_ACTAMPTH, - &cali_cfg->data[0], AW88399_DSP_32_DATA); + &cali_cfg->data[0], AW_DSP_32_DATA); if (ret) return ret; ret = aw_dev_dsp_read(aw_dev, AW88399_DSP_REG_CFG_MBMEC_NOISEAMPTH, - &cali_cfg->data[1], AW88399_DSP_32_DATA); + &cali_cfg->data[1], AW_DSP_32_DATA); if (ret) return ret; ret = aw_dev_dsp_read(aw_dev, AW88399_DSP_REG_CFG_ADPZ_USTEPN, - &cali_cfg->data[2], AW88399_DSP_16_DATA); + &cali_cfg->data[2], AW_DSP_16_DATA); if (ret) return ret; ret = aw_dev_dsp_read(aw_dev, AW88399_DSP_REG_CFG_RE_ALPHA, - &cali_cfg->data[3], AW88399_DSP_16_DATA); + &cali_cfg->data[3], AW_DSP_16_DATA); return ret; } @@ -1458,22 +1282,22 @@ static int aw_cali_svc_set_cali_cfg(struct aw_device *aw_dev, int ret; ret = aw_dev_dsp_write(aw_dev, AW88399_DSP_REG_CFG_MBMEC_ACTAMPTH, - cali_cfg.data[0], AW88399_DSP_32_DATA); + cali_cfg.data[0], AW_DSP_32_DATA); if (ret) return ret; ret = aw_dev_dsp_write(aw_dev, AW88399_DSP_REG_CFG_MBMEC_NOISEAMPTH, - cali_cfg.data[1], AW88399_DSP_32_DATA); + cali_cfg.data[1], AW_DSP_32_DATA); if (ret) return ret; ret = aw_dev_dsp_write(aw_dev, AW88399_DSP_REG_CFG_ADPZ_USTEPN, - cali_cfg.data[2], AW88399_DSP_16_DATA); + cali_cfg.data[2], AW_DSP_16_DATA); if (ret) return ret; ret = aw_dev_dsp_write(aw_dev, AW88399_DSP_REG_CFG_RE_ALPHA, - cali_cfg.data[3], AW88399_DSP_16_DATA); + cali_cfg.data[3], AW_DSP_16_DATA); return ret; } @@ -1488,7 +1312,7 @@ static int aw_cali_svc_cali_en(struct aw_device *aw_dev, bool cali_en) regmap_update_bits(aw_dev->regmap, AW88399_DBGCTRL_REG, ~AW883XX_DSP_NG_EN_MASK, AW883XX_DSP_NG_EN_DISABLE_VALUE); aw_dev_dsp_write(aw_dev, AW88399_DSP_LOW_POWER_SWITCH_CFG_ADDR, - AW88399_DSP_LOW_POWER_SWITCH_DISABLE, AW88399_DSP_16_DATA); + AW88399_DSP_LOW_POWER_SWITCH_DISABLE, AW_DSP_16_DATA); ret = aw_cali_svc_get_cali_cfg(aw_dev); if (ret) { @@ -1548,8 +1372,7 @@ static void aw_cali_svc_backup_info(struct aw_device *aw_dev) regmap_read(aw_dev->regmap, AW88399_DBGCTRL_REG, ®_val); backup_desc->dsp_ng_cfg = reg_val & (~AW883XX_DSP_NG_EN_MASK); - aw_dev_dsp_read(aw_dev, AW88399_DSP_LOW_POWER_SWITCH_CFG_ADDR, - &dsp_val, AW88399_DSP_16_DATA); + aw_dev_dsp_read(aw_dev, AW88399_DSP_LOW_POWER_SWITCH_CFG_ADDR, &dsp_val, AW_DSP_16_DATA); backup_desc->dsp_lp_cfg = dsp_val; } @@ -1562,7 +1385,7 @@ static void aw_cali_svc_recover_info(struct aw_device *aw_dev) ~AW883XX_DSP_NG_EN_MASK, backup_desc->dsp_ng_cfg); aw_dev_dsp_write(aw_dev, AW88399_DSP_LOW_POWER_SWITCH_CFG_ADDR, - backup_desc->dsp_lp_cfg, AW88399_DSP_16_DATA); + backup_desc->dsp_lp_cfg, AW_DSP_16_DATA); } static int aw_cali_svc_cali_re_mode_enable(struct aw_device *aw_dev, bool is_enable) @@ -1609,7 +1432,7 @@ static int aw_cali_svc_get_dev_re(struct aw_device *aw_dev, uint32_t *re) uint32_t dsp_re, show_re; int ret; - ret = aw_dev_dsp_read(aw_dev, AW88399_DSP_REG_CALRE, &dsp_re, AW88399_DSP_16_DATA); + ret = aw_dev_dsp_read(aw_dev, AW88399_DSP_REG_CALRE, &dsp_re, AW_DSP_16_DATA); if (ret) return ret; @@ -1744,7 +1567,7 @@ re_mode_err: static int aw88399_get_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88399->aw_pa; @@ -1756,7 +1579,7 @@ static int aw88399_get_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88399_set_fade_in_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1779,7 +1602,7 @@ static int aw88399_set_fade_in_time(struct snd_kcontrol *kcontrol, static int aw88399_get_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(component); struct aw_device *aw_dev = aw88399->aw_pa; @@ -1791,7 +1614,7 @@ static int aw88399_get_fade_out_time(struct snd_kcontrol *kcontrol, static int aw88399_set_fade_out_time(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1829,7 +1652,7 @@ static int aw88399_dev_set_profile_index(struct aw_device *aw_dev, int index) static int aw88399_profile_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); char *prof_name; int count, ret; @@ -1864,7 +1687,7 @@ static int aw88399_profile_info(struct snd_kcontrol *kcontrol, static int aw88399_profile_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88399->aw_pa->prof_index; @@ -1875,7 +1698,7 @@ static int aw88399_profile_get(struct snd_kcontrol *kcontrol, static int aw88399_profile_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); int ret; @@ -1900,7 +1723,7 @@ static int aw88399_profile_set(struct snd_kcontrol *kcontrol, static int aw88399_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88399->aw_pa->volume_desc; @@ -1912,7 +1735,7 @@ static int aw88399_volume_get(struct snd_kcontrol *kcontrol, static int aw88399_volume_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); struct aw_volume_desc *vol_desc = &aw88399->aw_pa->volume_desc; struct soc_mixer_control *mc = @@ -1936,7 +1759,7 @@ static int aw88399_volume_set(struct snd_kcontrol *kcontrol, static int aw88399_get_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = aw88399->aw_pa->fade_step; @@ -1947,7 +1770,7 @@ static int aw88399_get_fade_step(struct snd_kcontrol *kcontrol, static int aw88399_set_fade_step(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1968,7 +1791,7 @@ static int aw88399_set_fade_step(struct snd_kcontrol *kcontrol, static int aw88399_re_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); struct aw_device *aw_dev = aw88399->aw_pa; @@ -1980,7 +1803,7 @@ static int aw88399_re_get(struct snd_kcontrol *kcontrol, static int aw88399_re_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -2002,7 +1825,7 @@ static int aw88399_re_set(struct snd_kcontrol *kcontrol, static int aw88399_calib_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); struct aw_device *aw_dev = aw88399->aw_pa; @@ -2014,7 +1837,7 @@ static int aw88399_calib_switch_get(struct snd_kcontrol *kcontrol, static int aw88399_calib_switch_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); struct aw_device *aw_dev = aw88399->aw_pa; @@ -2036,7 +1859,7 @@ static int aw88399_calib_get(struct snd_kcontrol *kcontrol, static int aw88399_calib_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct aw88399 *aw88399 = snd_soc_component_get_drvdata(codec); struct aw_device *aw_dev = aw88399->aw_pa; diff --git a/sound/soc/codecs/aw88399.h b/sound/soc/codecs/aw88399.h index cacc03b1eefa..b386f4836748 100644 --- a/sound/soc/codecs/aw88399.h +++ b/sound/soc/codecs/aw88399.h @@ -603,11 +603,6 @@ enum AW88399_DEV_DSP_CFG { }; enum { - AW88399_DSP_16_DATA = 0, - AW88399_DSP_32_DATA = 1, -}; - -enum { AW88399_NOT_RCV_MODE = 0, AW88399_RCV_MODE = 1, }; diff --git a/sound/soc/codecs/bd28623.c b/sound/soc/codecs/bd28623.c index 82a94211d012..07e7bd79c8b0 100644 --- a/sound/soc/codecs/bd28623.c +++ b/sound/soc/codecs/bd28623.c @@ -70,8 +70,7 @@ static void bd28623_power_off(struct bd28623_priv *bd) static int bd28623_get_switch_spk(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct bd28623_priv *bd = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = bd->switch_spk; @@ -82,8 +81,7 @@ static int bd28623_get_switch_spk(struct snd_kcontrol *kcontrol, static int bd28623_set_switch_spk(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct bd28623_priv *bd = snd_soc_component_get_drvdata(component); if (bd->switch_spk == ucontrol->value.integer.value[0]) diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c index 3eb862643b53..6b80c455b074 100644 --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -380,7 +380,7 @@ static SOC_ENUM_SINGLE_DECL(cpcap_emu_r_mux_enum, 0, 8, cpcap_out_mux_texts); static int cpcap_output_mux_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int shift = e->shift_l; @@ -423,10 +423,9 @@ static int cpcap_output_mux_get_enum(struct snd_kcontrol *kcontrol, static int cpcap_output_mux_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int muxval = ucontrol->value.enumerated.item[0]; unsigned int mask = BIT(e->shift_l); @@ -468,7 +467,7 @@ static int cpcap_output_mux_put_enum(struct snd_kcontrol *kcontrol, static int cpcap_input_right_mux_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); int regval, mask; int err; @@ -507,10 +506,9 @@ static int cpcap_input_right_mux_get_enum(struct snd_kcontrol *kcontrol, static int cpcap_input_right_mux_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int muxval = ucontrol->value.enumerated.item[0]; int regval = 0, mask; @@ -552,7 +550,7 @@ static int cpcap_input_right_mux_put_enum(struct snd_kcontrol *kcontrol, static int cpcap_input_left_mux_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); int regval, mask; int err; @@ -583,10 +581,9 @@ static int cpcap_input_left_mux_get_enum(struct snd_kcontrol *kcontrol, static int cpcap_input_left_mux_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int muxval = ucontrol->value.enumerated.item[0]; int regval = 0, mask; diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c index 937c8cec682a..f78a85b89d95 100644 --- a/sound/soc/codecs/cros_ec_codec.c +++ b/sound/soc/codecs/cros_ec_codec.c @@ -108,8 +108,7 @@ error: static int dmic_get_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cros_ec_codec_priv *priv = snd_soc_component_get_drvdata(component); struct ec_param_ec_codec_dmic p; @@ -140,8 +139,7 @@ static int dmic_get_gain(struct snd_kcontrol *kcontrol, static int dmic_put_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cros_ec_codec_priv *priv = snd_soc_component_get_drvdata(component); struct soc_mixer_control *control = @@ -633,7 +631,7 @@ leave: static int wov_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct cros_ec_codec_priv *priv = snd_soc_component_get_drvdata(c); ucontrol->value.integer.value[0] = priv->wov_enabled; @@ -643,7 +641,7 @@ static int wov_enable_get(struct snd_kcontrol *kcontrol, static int wov_enable_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct cros_ec_codec_priv *priv = snd_soc_component_get_drvdata(c); int enabled = ucontrol->value.integer.value[0]; struct ec_param_ec_codec_wov p; diff --git a/sound/soc/codecs/cs-amp-lib-test.c b/sound/soc/codecs/cs-amp-lib-test.c index 3406887cdfa2..923f1857e45b 100644 --- a/sound/soc/codecs/cs-amp-lib-test.c +++ b/sound/soc/codecs/cs-amp-lib-test.c @@ -20,6 +20,10 @@ #include <linux/random.h> #include <sound/cs-amp-lib.h> +#define CIRRUS_LOGIC_CALIBRATION_EFI_NAME L"CirrusSmartAmpCalibrationData" +#define CIRRUS_LOGIC_CALIBRATION_EFI_GUID \ + EFI_GUID(0x02f9af02, 0x7734, 0x4233, 0xb4, 0x3d, 0x93, 0xfe, 0x5a, 0xa3, 0x5d, 0xb3) + #define LENOVO_SPEAKER_ID_EFI_NAME L"SdwSpeaker" #define LENOVO_SPEAKER_ID_EFI_GUID \ EFI_GUID(0x48df970e, 0xe27f, 0x460a, 0xb5, 0x86, 0x77, 0x19, 0x80, 0x1d, 0x92, 0x82) @@ -28,6 +32,10 @@ #define HP_SPEAKER_ID_EFI_GUID \ EFI_GUID(0xc49593a4, 0xd099, 0x419b, 0xa2, 0xc3, 0x67, 0xe9, 0x80, 0xe6, 0x1d, 0x1e) +#define HP_CALIBRATION_EFI_NAME L"SmartAmpCalibrationData" +#define HP_CALIBRATION_EFI_GUID \ + EFI_GUID(0x53559579, 0x8753, 0x4f5c, 0x91, 0x30, 0xe8, 0x2a, 0xcf, 0xb8, 0xd8, 0x93) + KUNIT_DEFINE_ACTION_WRAPPER(faux_device_destroy_wrapper, faux_device_destroy, struct faux_device *) @@ -36,6 +44,7 @@ struct cs_amp_lib_test_priv { struct cirrus_amp_efi_data *cal_blob; struct list_head ctl_write_list; + u32 efi_attr; }; struct cs_amp_lib_test_ctl_write_entry { @@ -49,6 +58,20 @@ struct cs_amp_lib_test_param { int amp_index; }; +static struct cirrus_amp_efi_data *cs_amp_lib_test_cal_blob_dup(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct cirrus_amp_efi_data *temp; + + KUNIT_ASSERT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + temp = kunit_kmalloc(test, priv->cal_blob->size, GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, temp); + memcpy(temp, priv->cal_blob, priv->cal_blob->size); + + return temp; +} + static void cs_amp_lib_test_init_dummy_cal_blob(struct kunit *test, int num_amps) { struct cs_amp_lib_test_priv *priv = test->priv; @@ -69,9 +92,15 @@ static void cs_amp_lib_test_init_dummy_cal_blob(struct kunit *test, int num_amps for (i = 0; i < num_amps; i++) priv->cal_blob->data[i].calTime[0] |= 1; - /* Ensure that all UIDs are non-zero and unique. */ - for (i = 0; i < num_amps; i++) + /* + * Ensure that all UIDs are non-zero and unique. + * Make both words non-zero and not equal values, so that + * tests can verify that both words were checked or changed. + */ + for (i = 0; i < num_amps; i++) { *(u8 *)&priv->cal_blob->data[i].calTarget[0] = i + 1; + *(u8 *)&priv->cal_blob->data[i].calTarget[1] = i; + } } static u64 cs_amp_lib_test_get_target_uid(struct kunit *test) @@ -90,6 +119,7 @@ static u64 cs_amp_lib_test_get_target_uid(struct kunit *test) /* Redirected get_efi_variable to simulate that the file is too short */ static efi_status_t cs_amp_lib_test_get_efi_variable_nohead(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -115,13 +145,12 @@ static void cs_amp_lib_test_cal_data_too_short_test(struct kunit *test) ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, 0, 0, &result_data); KUNIT_EXPECT_EQ(test, ret, -EOVERFLOW); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* Redirected get_efi_variable to simulate that the count is larger than the file */ static efi_status_t cs_amp_lib_test_get_efi_variable_bad_count(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -158,13 +187,12 @@ static void cs_amp_lib_test_cal_count_too_big_test(struct kunit *test) ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, 0, 0, &result_data); KUNIT_EXPECT_EQ(test, ret, -EOVERFLOW); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* Redirected get_efi_variable to simulate that the variable not found */ static efi_status_t cs_amp_lib_test_get_efi_variable_none(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -185,19 +213,17 @@ static void cs_amp_lib_test_no_cal_data_test(struct kunit *test) ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, 0, 0, &result_data); KUNIT_EXPECT_EQ(test, ret, -ENOENT); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* Redirected get_efi_variable to simulate reading a cal data blob */ static efi_status_t cs_amp_lib_test_get_efi_variable(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { - static const efi_char16_t expected_name[] = L"CirrusSmartAmpCalibrationData"; - static const efi_guid_t expected_guid = - EFI_GUID(0x02f9af02, 0x7734, 0x4233, 0xb4, 0x3d, 0x93, 0xfe, 0x5a, 0xa3, 0x5d, 0xb3); + static const efi_char16_t expected_name[] = CIRRUS_LOGIC_CALIBRATION_EFI_NAME; + static const efi_guid_t expected_guid = CIRRUS_LOGIC_CALIBRATION_EFI_GUID; struct kunit *test = kunit_get_current_test(); struct cs_amp_lib_test_priv *priv = test->priv; @@ -218,11 +244,65 @@ static efi_status_t cs_amp_lib_test_get_efi_variable(efi_char16_t *name, memcpy(buf, priv->cal_blob, priv->cal_blob->size); + if (returned_attr) { + if (priv->efi_attr) + *returned_attr = priv->efi_attr; + else + *returned_attr = EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; + } + + return EFI_SUCCESS; +} + +#define CS_AMP_LIB_ZERO_FILLED_BLOB_SIZE \ + struct_size_t(struct cirrus_amp_efi_data, data, 8) + +/* Redirected get_efi_variable to simulate reading a prealloced zero-filled blob */ +static efi_status_t cs_amp_lib_test_get_efi_variable_all_zeros(efi_char16_t *name, + efi_guid_t *guid, + u32 *returned_attr, + unsigned long *size, + void *buf) +{ + static const efi_char16_t expected_name[] = CIRRUS_LOGIC_CALIBRATION_EFI_NAME; + static const efi_guid_t expected_guid = CIRRUS_LOGIC_CALIBRATION_EFI_GUID; + struct kunit *test = kunit_get_current_test(); + struct cs_amp_lib_test_priv *priv = test->priv; + + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, name); + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, guid); + + if (memcmp(name, expected_name, sizeof(expected_name)) || + efi_guidcmp(*guid, expected_guid)) + return -EFI_NOT_FOUND; + + if (!buf) { + *size = CS_AMP_LIB_ZERO_FILLED_BLOB_SIZE; + return EFI_BUFFER_TOO_SMALL; + } + + KUNIT_ASSERT_EQ(test, *size, struct_size(priv->cal_blob, data, 8)); + priv->cal_blob = kunit_kzalloc(test, CS_AMP_LIB_ZERO_FILLED_BLOB_SIZE, GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, priv->cal_blob); + memset(buf, 0, CS_AMP_LIB_ZERO_FILLED_BLOB_SIZE); + + if (returned_attr) { + if (priv->efi_attr) + *returned_attr = priv->efi_attr; + else + *returned_attr = EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; + } + return EFI_SUCCESS; } static efi_status_t cs_amp_lib_test_get_hp_cal_efi_variable(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -249,6 +329,12 @@ static efi_status_t cs_amp_lib_test_get_hp_cal_efi_variable(efi_char16_t *name, memcpy(buf, priv->cal_blob, priv->cal_blob->size); + if (returned_attr) { + *returned_attr = EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS; + } + return EFI_SUCCESS; } @@ -291,8 +377,6 @@ static void cs_amp_lib_test_get_efi_cal_by_uid_test(struct kunit *test) ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, target_uid, -1, &result_data); KUNIT_EXPECT_EQ(test, ret, 0); - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); - KUNIT_EXPECT_EQ(test, result_data.calTarget[0], target_uid & 0xFFFFFFFFULL); KUNIT_EXPECT_EQ(test, result_data.calTarget[1], target_uid >> 32); KUNIT_EXPECT_EQ(test, result_data.calTime[0], @@ -326,8 +410,6 @@ static void cs_amp_lib_test_get_efi_cal_by_index_unchecked_test(struct kunit *te param->amp_index, &result_data); KUNIT_EXPECT_EQ(test, ret, 0); - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); - KUNIT_EXPECT_EQ(test, result_data.calTime[0], priv->cal_blob->data[param->amp_index].calTime[0]); KUNIT_EXPECT_EQ(test, result_data.calTime[1], @@ -361,8 +443,6 @@ static void cs_amp_lib_test_get_efi_cal_by_index_checked_test(struct kunit *test param->amp_index, &result_data); KUNIT_EXPECT_EQ(test, ret, 0); - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); - KUNIT_EXPECT_EQ(test, result_data.calTime[0], priv->cal_blob->data[param->amp_index].calTime[0]); KUNIT_EXPECT_EQ(test, result_data.calTime[1], @@ -399,8 +479,6 @@ static void cs_amp_lib_test_get_efi_cal_by_index_uid_mismatch_test(struct kunit ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, target_uid, param->amp_index, &result_data); KUNIT_EXPECT_EQ(test, ret, -ENOENT); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* @@ -432,8 +510,6 @@ static void cs_amp_lib_test_get_efi_cal_by_index_fallback_test(struct kunit *tes param->amp_index, &result_data); KUNIT_EXPECT_EQ(test, ret, 0); - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); - KUNIT_EXPECT_EQ(test, result_data.calTime[0], priv->cal_blob->data[param->amp_index].calTime[0]); KUNIT_EXPECT_EQ(test, result_data.calTime[1], @@ -473,8 +549,6 @@ static void cs_amp_lib_test_get_efi_cal_uid_not_found_noindex_test(struct kunit ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, bad_target_uid, -1, &result_data); KUNIT_EXPECT_EQ(test, ret, -ENOENT); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* @@ -504,8 +578,6 @@ static void cs_amp_lib_test_get_efi_cal_uid_not_found_index_not_found_test(struc ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, bad_target_uid, 99, &result_data); KUNIT_EXPECT_EQ(test, ret, -ENOENT); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* @@ -527,8 +599,6 @@ static void cs_amp_lib_test_get_efi_cal_no_uid_index_not_found_test(struct kunit ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, 0, 99, &result_data); KUNIT_EXPECT_EQ(test, ret, -ENOENT); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* If neither the target UID or the index is given the result should be -ENOENT. */ @@ -547,8 +617,6 @@ static void cs_amp_lib_test_get_efi_cal_no_uid_no_index_test(struct kunit *test) ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, 0, -1, &result_data); KUNIT_EXPECT_EQ(test, ret, -ENOENT); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* @@ -576,8 +644,6 @@ static void cs_amp_lib_test_get_efi_cal_zero_not_matched_test(struct kunit *test ret = cs_amp_get_efi_calibration_data(&priv->amp_dev->dev, 0, -1, &result_data); KUNIT_EXPECT_EQ(test, ret, -ENOENT); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } /* @@ -619,8 +685,6 @@ static void cs_amp_lib_test_get_efi_cal_empty_entry_test(struct kunit *test) 0, 2, &result_data), -ENOENT); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->get_efi_variable); } static const struct cirrus_amp_cal_controls cs_amp_lib_test_calibration_controls = { @@ -676,9 +740,6 @@ static void cs_amp_lib_test_write_cal_data_test(struct kunit *test) ret = cs_amp_write_cal_coeffs(dsp, &cs_amp_lib_test_calibration_controls, &data); KUNIT_EXPECT_EQ(test, ret, 0); - - kunit_deactivate_static_stub(test, cs_amp_test_hooks->write_cal_coeff); - KUNIT_EXPECT_EQ(test, list_count_nodes(&priv->ctl_write_list), 4); /* Checksum control must be written last */ @@ -702,6 +763,1363 @@ static void cs_amp_lib_test_write_cal_data_test(struct kunit *test) KUNIT_EXPECT_EQ(test, entry->value, data.calStatus); } +static int cs_amp_lib_test_read_cal_coeff(struct cs_dsp *dsp, + const struct cirrus_amp_cal_controls *controls, + const char *ctl_name, u32 *val) +{ + struct kunit *test = kunit_get_current_test(); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctl_name); + KUNIT_EXPECT_PTR_EQ(test, controls, &cs_amp_lib_test_calibration_controls); + + if (strcmp(ctl_name, controls->ambient) == 0) + *val = 19; + else if (strcmp(ctl_name, controls->calr) == 0) + *val = 1077; + else if (strcmp(ctl_name, controls->status) == 0) + *val = 2; + else + kunit_fail_current_test("Bad control '%s'\n", ctl_name); + + return 0; +} + +static void cs_amp_lib_test_read_cal_data_test(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct cirrus_amp_cal_data data = { 0 }; + struct cs_dsp *dsp; + int ret; + + dsp = kunit_kzalloc(test, sizeof(*dsp), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dsp); + dsp->dev = &priv->amp_dev->dev; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->read_cal_coeff, + cs_amp_lib_test_read_cal_coeff); + + ret = cs_amp_read_cal_coeffs(dsp, &cs_amp_lib_test_calibration_controls, &data); + KUNIT_EXPECT_EQ(test, ret, 0); + + KUNIT_EXPECT_EQ(test, 19, data.calAmbient); + KUNIT_EXPECT_EQ(test, 1077, data.calR); + KUNIT_EXPECT_EQ(test, 2, data.calStatus); + KUNIT_EXPECT_NE(test, 0, data.calTime[0] | data.calTime[1]); +} + +static void cs_amp_lib_test_write_ambient_test(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct cs_amp_lib_test_ctl_write_entry *entry; + struct cs_dsp *dsp; + int ret; + + dsp = kunit_kzalloc(test, sizeof(*dsp), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dsp); + dsp->dev = &priv->amp_dev->dev; + + /* Redirect calls to write firmware controls */ + kunit_activate_static_stub(test, + cs_amp_test_hooks->write_cal_coeff, + cs_amp_lib_test_write_cal_coeff); + + ret = cs_amp_write_ambient_temp(dsp, &cs_amp_lib_test_calibration_controls, 18); + KUNIT_EXPECT_EQ(test, ret, 0); + + KUNIT_EXPECT_EQ(test, list_count_nodes(&priv->ctl_write_list), 1); + + entry = list_first_entry(&priv->ctl_write_list, typeof(*entry), list); + KUNIT_EXPECT_STREQ(test, entry->name, cs_amp_lib_test_calibration_controls.ambient); + KUNIT_EXPECT_EQ(test, entry->value, 18); +} + +static efi_status_t cs_amp_lib_test_set_efi_variable(efi_char16_t *name, + efi_guid_t *guid, + u32 attr, + unsigned long size, + void *buf) +{ + static const efi_char16_t expected_name[] = CIRRUS_LOGIC_CALIBRATION_EFI_NAME; + static const efi_guid_t expected_guid = CIRRUS_LOGIC_CALIBRATION_EFI_GUID; + struct kunit *test = kunit_get_current_test(); + struct cs_amp_lib_test_priv *priv = test->priv; + + KUNIT_ASSERT_NOT_NULL(test, name); + KUNIT_ASSERT_NOT_NULL(test, guid); + + if (memcmp(name, expected_name, sizeof(expected_name)) || + efi_guidcmp(*guid, expected_guid)) + return -EFI_NOT_FOUND; + + KUNIT_ASSERT_NOT_NULL(test, buf); + KUNIT_ASSERT_NE(test, 0, size); + + kunit_kfree(test, priv->cal_blob); + priv->cal_blob = kunit_kmalloc(test, size, GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, priv->cal_blob); + memcpy(priv->cal_blob, buf, size); + priv->efi_attr = attr; + + return EFI_SUCCESS; +} + +static efi_status_t cs_amp_lib_test_set_efi_variable_denied(efi_char16_t *name, + efi_guid_t *guid, + u32 attr, + unsigned long size, + void *buf) +{ + return EFI_WRITE_PROTECTED; +} + +#define CS_AMP_CAL_DEFAULT_EFI_ATTR \ + (EFI_VARIABLE_NON_VOLATILE | \ + EFI_VARIABLE_BOOTSERVICE_ACCESS | \ + EFI_VARIABLE_RUNTIME_ACCESS) + +static void cs_amp_lib_test_create_new_cal_efi(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + int i; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable_none); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* For unspecified number of amps */ + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, CS_AMP_CAL_DEFAULT_EFI_ATTR, priv->efi_attr); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 1); + KUNIT_EXPECT_LE(test, priv->cal_blob->count, 8); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + for (i = 1; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); + + /* For 2 amps */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 2, &data)); + KUNIT_EXPECT_EQ(test, CS_AMP_CAL_DEFAULT_EFI_ATTR, priv->efi_attr); + KUNIT_EXPECT_EQ(test, 2, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 2), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[1], sizeof(data))); + + /* For 4 amps */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 4, &data)); + KUNIT_EXPECT_EQ(test, 4, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 4), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[1], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + + /* For 6 amps */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[1], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); +} + +static void cs_amp_lib_test_create_new_cal_efi_indexed(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable_none); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* In slot 0 */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 0, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[1], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* In slot 1 */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[0], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* In slot 5 */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 5, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[5], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[0], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[1], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); +} + +static void cs_amp_lib_test_create_new_cal_efi_indexed_no_max(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + int i; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable_none); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* In slot 0 with unspecified number of amps */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 0, -1, &data)); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 1); + KUNIT_EXPECT_LE(test, priv->cal_blob->count, 8); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + for (i = 1; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); + + /* In slot 1 with unspecified number of amps */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, -1, &data)); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 2); + KUNIT_EXPECT_LE(test, priv->cal_blob->count, 8); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[0], sizeof(data))); + for (i = 2; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); + + /* In slot 5 with unspecified number of amps */ + priv->cal_blob = NULL; + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 5, -1, &data)); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 6); + KUNIT_EXPECT_LE(test, priv->cal_blob->count, 8); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + for (i = 0; (i < 5) && (i < priv->cal_blob->count); i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); + + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[5], sizeof(data)); + for (i = 6; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); +} + +static void cs_amp_lib_test_grow_append_cal_efi(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* Initially 1 used entry grown to 2 entries */ + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 2, &data)); + KUNIT_EXPECT_EQ(test, CS_AMP_CAL_DEFAULT_EFI_ATTR, priv->efi_attr); + KUNIT_EXPECT_EQ(test, 2, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 2), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + + /* Initially 1 entry grown to 4 entries */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 4, &data)); + KUNIT_EXPECT_EQ(test, 4, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 4), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + + /* Initially 2 entries grown to 4 entries */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 2); + KUNIT_ASSERT_EQ(test, 2, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 4, &data)); + KUNIT_EXPECT_EQ(test, 4, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 4), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + + /* Initially 1 entry grown to 6 entries */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* Initially 4 entries grown to 6 entries */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); +} + +static void cs_amp_lib_test_grow_append_cal_efi_indexed(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* Initially 1 entry grown to 2 entries using slot 1 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, 2, &data)); + KUNIT_EXPECT_EQ(test, 2, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 2), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + + /* Initially 1 entry grown to 6 entries using slot 1 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* Initially 2 entries grown to 6 entries using slot 2 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 2); + KUNIT_ASSERT_EQ(test, 2, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 2, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* Initially 2 entries grown to 6 entries using slot 4 */ + kunit_kfree(test, original_blob); + kunit_kfree(test, priv->cal_blob); + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 2); + KUNIT_ASSERT_EQ(test, 2, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 4, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); +} + +static void cs_amp_lib_test_cal_efi_all_zeros_add_first(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + int i; + + /* Simulate a BIOS reserving EFI space that is entirely zero-filled. */ + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable_all_zeros); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* + * Add an entry. The header should be filled in to match the + * original EFI variable size. + */ + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 8), priv->cal_blob->size); + KUNIT_EXPECT_EQ(test, 8, priv->cal_blob->count); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + for (i = 1; i < priv->cal_blob->count; i++) { + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[i].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[i].calTime[1]); + } +} + +static void cs_amp_lib_test_cal_efi_all_zeros_add_first_no_shrink(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + int i; + + /* Simulate a BIOS reserving EFI space that is entirely zero-filled. */ + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable_all_zeros); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* + * Add an entry. The header should be filled in to match the + * original EFI variable size. A number of amps less than the + * available preallocated space does not shrink the EFI variable. + */ + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 4, &data)); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 8), priv->cal_blob->size); + KUNIT_EXPECT_EQ(test, 8, priv->cal_blob->count); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + for (i = 1; i < priv->cal_blob->count; i++) { + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[i].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[i].calTime[1]); + } +} + +static void cs_amp_lib_test_cal_efi_all_zeros_add_first_indexed(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + int i; + + /* Simulate a BIOS reserving EFI space that is entirely zero-filled. */ + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable_all_zeros); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* + * Write entry to slot 2. The header should be filled in to match + * the original EFI variable size. + */ + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 2, -1, &data)); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 8), priv->cal_blob->size); + KUNIT_EXPECT_EQ(test, 8, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[0].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[0].calTime[1]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[1].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[1].calTime[1]); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[2], sizeof(data)); + for (i = 3; i < priv->cal_blob->count; i++) { + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[i].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[i].calTime[1]); + } +} + +static void cs_amp_lib_test_cal_efi_all_zeros_add_first_indexed_no_shrink(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + int i; + + /* Simulate a BIOS reserving EFI space that is entirely zero-filled. */ + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable_all_zeros); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* + * Write entry to slot 2. The header should be filled in to match + * the original EFI variable size. A number of amps less than the + * available preallocated space does not shrink the EFI variable. + */ + get_random_bytes(&data, sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 2, 4, &data)); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 8), priv->cal_blob->size); + KUNIT_EXPECT_EQ(test, 8, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[0].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[0].calTime[1]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[1].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[1].calTime[1]); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[2], sizeof(data)); + for (i = 3; i < priv->cal_blob->count; i++) { + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[i].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[i].calTime[1]); + } +} + +static void cs_amp_lib_test_grow_append_cal_efi_indexed_no_max(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + int i; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* Initially 1 entry adding slot 1 */ + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, -1, &data)); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 2); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + for (i = 2; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); + + /* Initially 1 entry adding slot 3 */ + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 3, -1, &data)); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 4); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[1], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[3], sizeof(data)); + for (i = 4; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); + + /* Initially 2 entries adding slot 3 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 2); + KUNIT_ASSERT_EQ(test, 2, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 3, -1, &data)); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 1); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[3], sizeof(data)); + for (i = 4; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); + + /* Initially 4 entries adding slot 4 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 4, -1, &data)); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 1); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + for (i = 5; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); + + /* Initially 4 entries adding slot 6 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 6, -1, &data)); + KUNIT_EXPECT_GE(test, priv->cal_blob->count, 1); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count), + priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[6], sizeof(data)); + for (i = 7; i < priv->cal_blob->count; i++) + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[i], sizeof(data))); +} + +static void cs_amp_lib_test_grow_cal_efi_replace_indexed(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* Initially 1 entry grown to 2 entries overwriting slot 0 */ + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 0, 2, &data)); + KUNIT_EXPECT_EQ(test, 2, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 2), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[1], sizeof(data))); + + /* Initially 2 entries grown to 4 entries overwriting slot 1 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 2); + KUNIT_ASSERT_EQ(test, 2, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, 4, &data)); + KUNIT_EXPECT_EQ(test, 4, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 4), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + + /* Initially 4 entries grown to 6 entries overwriting slot 1 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* Initially 4 entries grown to 6 entries overwriting slot 3 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 3, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* Initially 6 entries grown to 8 entries overwriting slot 4 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 6); + KUNIT_ASSERT_EQ(test, 6, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; /* won't match */ + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 4, 8, &data)); + KUNIT_EXPECT_EQ(test, 8, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 8), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[6], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[7], sizeof(data))); +} + +static void cs_amp_lib_test_grow_cal_efi_replace_by_uid(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* Initially 1 entry grown to 2 entries overwriting slot 0 */ + cs_amp_lib_test_init_dummy_cal_blob(test, 1); + KUNIT_ASSERT_EQ(test, 1, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[0].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 2, &data)); + KUNIT_EXPECT_EQ(test, 2, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 2), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[1], sizeof(data))); + + /* Initially 2 entries grown to 4 entries overwriting slot 1 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 2); + KUNIT_ASSERT_EQ(test, 2, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[1].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 4, &data)); + KUNIT_EXPECT_EQ(test, 4, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 4), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[2], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[3], sizeof(data))); + + /* Initially 4 entries grown to 6 entries overwriting slot 1 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[1].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* Initially 4 entries grown to 6 entries overwriting slot 3 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[3].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 6, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[4], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[5], sizeof(data))); + + /* Initially 6 entries grown to 8 entries overwriting slot 4 */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 6); + KUNIT_ASSERT_EQ(test, 6, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[4].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, 8, &data)); + KUNIT_EXPECT_EQ(test, 8, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 8), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[6], sizeof(data))); + KUNIT_EXPECT_TRUE(test, mem_is_zero(&priv->cal_blob->data[7], sizeof(data))); +} + +static void cs_amp_lib_test_cal_efi_replace_by_uid(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + cs_amp_lib_test_init_dummy_cal_blob(test, 6); + KUNIT_ASSERT_EQ(test, 6, priv->cal_blob->count); + + /* Replace entry matching slot 0 */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[0].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Replace entry matching slot 4 */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[4].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Replace entry matching slot 3 */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[3].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Replace entry matching slot 5 */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[5].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[5], sizeof(data)); +} + +static void cs_amp_lib_test_cal_efi_replace_by_index(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + cs_amp_lib_test_init_dummy_cal_blob(test, 6); + KUNIT_ASSERT_EQ(test, 6, priv->cal_blob->count); + + /* + * Replace entry matching slot 0. + * data.calTarget is deliberately set different to current calTarget + * of the slot to check that the index forces that slot to be used. + */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = ~priv->cal_blob->data[0].calTarget[0]; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 0, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Replace entry matching slot 4 */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = ~priv->cal_blob->data[4].calTarget[0]; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 4, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Replace entry matching slot 3 */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = ~priv->cal_blob->data[3].calTarget[0]; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 3, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Replace entry matching slot 5 */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = ~priv->cal_blob->data[5].calTarget[0]; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 5, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[5], sizeof(data)); +} + +static void cs_amp_lib_test_cal_efi_deduplicate(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + int i; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + /* + * Replace entry matching slot 0. + * An active entry in slot 1 for the same UID should be marked empty. + * Other entries are unaltered. + */ + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[1].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 0, -1, &data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[1].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[1].calTime[1]); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + + /* + * Replace entry matching slot 1. + * An active entry in slot 0 for the same UID should be marked empty. + * Other entries are unaltered. + */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[0].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, -1, &data)); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[0].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[0].calTime[1]); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + + /* + * Replace entry matching slot 1. + * An active entry in slot 3 for the same UID should be marked empty. + * Other entries are unaltered. + */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + memcpy(data.calTarget, priv->cal_blob->data[3].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 1, -1, &data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[3].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[3].calTime[1]); + + /* + * Worst case, all entries have the same UID + */ + priv->cal_blob = NULL; + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + for (i = 0; i < priv->cal_blob->count; i++) { + priv->cal_blob->data[i].calTarget[0] = 0xe5e5e5e5; + priv->cal_blob->data[i].calTarget[1] = 0xa7a7a7a7; + } + memcpy(data.calTarget, priv->cal_blob->data[2].calTarget, sizeof(data.calTarget)); + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 2, -1, &data)); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[0].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[0].calTime[1]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[1].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[1].calTime[1]); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[3].calTime[0]); + KUNIT_EXPECT_EQ(test, 0, priv->cal_blob->data[3].calTime[1]); +} + +static void cs_amp_lib_test_cal_efi_find_free(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + cs_amp_lib_test_init_dummy_cal_blob(test, 6); + KUNIT_ASSERT_EQ(test, 6, priv->cal_blob->count); + + /* + * Slot 0 is empty. + * data.calTarget is set to a value that won't match any existing entry. + */ + memset(&priv->cal_blob->data[0].calTime, 0, sizeof(priv->cal_blob->data[0].calTime)); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Slot 4 is empty */ + memset(&priv->cal_blob->data[4].calTime, 0, sizeof(priv->cal_blob->data[4].calTime)); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Slot 3 is empty */ + memset(&priv->cal_blob->data[3].calTime, 0, sizeof(priv->cal_blob->data[3].calTime)); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); + + /* Replace entry matching slot 5 */ + memset(&priv->cal_blob->data[5].calTime, 0, sizeof(priv->cal_blob->data[5].calTime)); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = 0xaaaaaaaa; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[4], &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[5], sizeof(data)); +} + +static void cs_amp_lib_test_cal_efi_bad_cal_target(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + + /* Zero calTarget is illegal */ + get_random_bytes(&data, sizeof(data)); + memset(data.calTarget, 0, sizeof(data.calTarget)); + KUNIT_EXPECT_LT(test, cs_amp_set_efi_calibration_data(dev, -1, -1, &data), 0); + KUNIT_EXPECT_LT(test, cs_amp_set_efi_calibration_data(dev, 0, -1, &data), 0); + KUNIT_EXPECT_LT(test, cs_amp_set_efi_calibration_data(dev, 0, 2, &data), 0); +} + +static void cs_amp_lib_test_cal_efi_write_denied(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable_denied); + + cs_amp_lib_test_init_dummy_cal_blob(test, 4); + KUNIT_ASSERT_EQ(test, 4, priv->cal_blob->count); + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + + /* Unspecified slot */ + KUNIT_EXPECT_LT(test, cs_amp_set_efi_calibration_data(dev, -1, -1, &data), 0); + KUNIT_EXPECT_MEMEQ(test, original_blob, priv->cal_blob, original_blob->size); + + /* Unspecified slot with size */ + KUNIT_EXPECT_LT(test, cs_amp_set_efi_calibration_data(dev, -1, 6, &data), 0); + KUNIT_EXPECT_MEMEQ(test, original_blob, priv->cal_blob, original_blob->size); + + /* Specified slot */ + KUNIT_EXPECT_LT(test, cs_amp_set_efi_calibration_data(dev, 1, -1, &data), 0); + KUNIT_EXPECT_MEMEQ(test, original_blob, priv->cal_blob, original_blob->size); + + /* Specified slot with size */ + KUNIT_EXPECT_LT(test, cs_amp_set_efi_calibration_data(dev, 1, 6, &data), 0); + KUNIT_EXPECT_MEMEQ(test, original_blob, priv->cal_blob, original_blob->size); +} + +static void cs_amp_lib_test_cal_efi_attr_preserved(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_efi_variable); + + cs_amp_lib_test_init_dummy_cal_blob(test, 6); + KUNIT_ASSERT_EQ(test, 6, priv->cal_blob->count); + memset(&priv->cal_blob->data[0], 0, sizeof(priv->cal_blob->data[0])); + get_random_bytes(&data, sizeof(data)); + + /* Set a non-standard attr to return from get_efi_variable() */ + priv->efi_attr = EFI_VARIABLE_HARDWARE_ERROR_RECORD; + + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, -1, -1, &data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_EQ(test, priv->efi_attr, EFI_VARIABLE_HARDWARE_ERROR_RECORD); +} + +static efi_status_t cs_amp_lib_test_set_hp_efi_cal_variable(efi_char16_t *name, + efi_guid_t *guid, + u32 attr, + unsigned long size, + void *buf) +{ + static const efi_char16_t expected_name[] = HP_CALIBRATION_EFI_NAME; + static const efi_guid_t expected_guid = HP_CALIBRATION_EFI_GUID; + struct kunit *test = kunit_get_current_test(); + struct cs_amp_lib_test_priv *priv = test->priv; + + KUNIT_ASSERT_NOT_NULL(test, name); + KUNIT_ASSERT_NOT_NULL(test, guid); + + if (memcmp(name, expected_name, sizeof(expected_name)) || + efi_guidcmp(*guid, expected_guid)) + return -EFI_ACCESS_DENIED; + + KUNIT_ASSERT_NOT_NULL(test, buf); + KUNIT_ASSERT_NE(test, 0, size); + + kunit_kfree(test, priv->cal_blob); + priv->cal_blob = kunit_kmalloc(test, size, GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, priv->cal_blob); + memcpy(priv->cal_blob, buf, size); + priv->efi_attr = attr; + + return EFI_SUCCESS; +} + +/* + * If the HP EFI exists it should be the one that is updated. + */ +static void cs_amp_lib_test_cal_efi_update_hp(struct kunit *test) +{ + struct cs_amp_lib_test_priv *priv = test->priv; + struct device *dev = &priv->amp_dev->dev; + const struct cirrus_amp_efi_data *original_blob; + struct cirrus_amp_cal_data data; + + kunit_activate_static_stub(test, + cs_amp_test_hooks->get_efi_variable, + cs_amp_lib_test_get_hp_cal_efi_variable); + kunit_activate_static_stub(test, + cs_amp_test_hooks->set_efi_variable, + cs_amp_lib_test_set_hp_efi_cal_variable); + + cs_amp_lib_test_init_dummy_cal_blob(test, 6); + KUNIT_ASSERT_EQ(test, 6, priv->cal_blob->count); + + /* Replace entry matching slot 4 */ + original_blob = cs_amp_lib_test_cal_blob_dup(test); + get_random_bytes(&data, sizeof(data)); + data.calTarget[0] = ~priv->cal_blob->data[4].calTarget[0]; + KUNIT_EXPECT_EQ(test, 0, cs_amp_set_efi_calibration_data(dev, 4, -1, &data)); + KUNIT_EXPECT_EQ(test, 6, priv->cal_blob->count); + KUNIT_EXPECT_EQ(test, struct_size(priv->cal_blob, data, 6), priv->cal_blob->size); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[0], &priv->cal_blob->data[0], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[1], &priv->cal_blob->data[1], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[2], &priv->cal_blob->data[2], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[3], &priv->cal_blob->data[3], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &data, &priv->cal_blob->data[4], sizeof(data)); + KUNIT_EXPECT_MEMEQ(test, &original_blob->data[5], &priv->cal_blob->data[5], sizeof(data)); +} + static void cs_amp_lib_test_spkid_lenovo_not_present(struct kunit *test) { struct cs_amp_lib_test_priv *priv = test->priv; @@ -716,6 +2134,7 @@ static void cs_amp_lib_test_spkid_lenovo_not_present(struct kunit *test) static efi_status_t cs_amp_lib_test_get_efi_variable_lenovo_d0(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -734,6 +2153,7 @@ static efi_status_t cs_amp_lib_test_get_efi_variable_lenovo_d0(efi_char16_t *nam static efi_status_t cs_amp_lib_test_get_efi_variable_lenovo_d1(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -752,6 +2172,7 @@ static efi_status_t cs_amp_lib_test_get_efi_variable_lenovo_d1(efi_char16_t *nam static efi_status_t cs_amp_lib_test_get_efi_variable_lenovo_00(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -803,6 +2224,7 @@ static void cs_amp_lib_test_spkid_lenovo_illegal(struct kunit *test) static efi_status_t cs_amp_lib_test_get_efi_variable_buf_too_small(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -823,6 +2245,7 @@ static void cs_amp_lib_test_spkid_lenovo_oversize(struct kunit *test) static efi_status_t cs_amp_lib_test_get_efi_variable_hp_30(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -841,6 +2264,7 @@ static efi_status_t cs_amp_lib_test_get_efi_variable_hp_30(efi_char16_t *name, static efi_status_t cs_amp_lib_test_get_efi_variable_hp_31(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { @@ -974,8 +2398,32 @@ static struct kunit_case cs_amp_lib_test_cases[] = { cs_amp_lib_test_get_cal_gen_params), KUNIT_CASE(cs_amp_lib_test_get_efi_cal_empty_entry_test), - /* Tests for writing calibration data */ + /* Tests for writing and reading calibration data */ KUNIT_CASE(cs_amp_lib_test_write_cal_data_test), + KUNIT_CASE(cs_amp_lib_test_read_cal_data_test), + KUNIT_CASE(cs_amp_lib_test_write_ambient_test), + + /* Test cases for writing cal data to UEFI */ + KUNIT_CASE(cs_amp_lib_test_create_new_cal_efi), + KUNIT_CASE(cs_amp_lib_test_create_new_cal_efi_indexed), + KUNIT_CASE(cs_amp_lib_test_create_new_cal_efi_indexed_no_max), + KUNIT_CASE(cs_amp_lib_test_cal_efi_all_zeros_add_first), + KUNIT_CASE(cs_amp_lib_test_cal_efi_all_zeros_add_first_no_shrink), + KUNIT_CASE(cs_amp_lib_test_cal_efi_all_zeros_add_first_indexed), + KUNIT_CASE(cs_amp_lib_test_cal_efi_all_zeros_add_first_indexed_no_shrink), + KUNIT_CASE(cs_amp_lib_test_grow_append_cal_efi), + KUNIT_CASE(cs_amp_lib_test_grow_append_cal_efi_indexed), + KUNIT_CASE(cs_amp_lib_test_grow_append_cal_efi_indexed_no_max), + KUNIT_CASE(cs_amp_lib_test_grow_cal_efi_replace_indexed), + KUNIT_CASE(cs_amp_lib_test_grow_cal_efi_replace_by_uid), + KUNIT_CASE(cs_amp_lib_test_cal_efi_replace_by_uid), + KUNIT_CASE(cs_amp_lib_test_cal_efi_replace_by_index), + KUNIT_CASE(cs_amp_lib_test_cal_efi_deduplicate), + KUNIT_CASE(cs_amp_lib_test_cal_efi_find_free), + KUNIT_CASE(cs_amp_lib_test_cal_efi_bad_cal_target), + KUNIT_CASE(cs_amp_lib_test_cal_efi_write_denied), + KUNIT_CASE(cs_amp_lib_test_cal_efi_attr_preserved), + KUNIT_CASE(cs_amp_lib_test_cal_efi_update_hp), /* Test cases for speaker ID */ KUNIT_CASE(cs_amp_lib_test_spkid_lenovo_not_present), diff --git a/sound/soc/codecs/cs-amp-lib.c b/sound/soc/codecs/cs-amp-lib.c index 8434d5196107..8c9fd9980a7d 100644 --- a/sound/soc/codecs/cs-amp-lib.c +++ b/sound/soc/codecs/cs-amp-lib.c @@ -7,12 +7,17 @@ #include <asm/byteorder.h> #include <kunit/static_stub.h> +#include <linux/cleanup.h> +#include <linux/debugfs.h> #include <linux/dev_printk.h> #include <linux/efi.h> #include <linux/firmware/cirrus/cs_dsp.h> +#include <linux/math64.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/overflow.h> #include <linux/slab.h> +#include <linux/timekeeping.h> #include <linux/types.h> #include <sound/cs-amp-lib.h> @@ -46,6 +51,23 @@ static const struct cs_amp_lib_cal_efivar { }, }; +#define CS_AMP_CAL_DEFAULT_EFI_ATTR \ + (EFI_VARIABLE_NON_VOLATILE | \ + EFI_VARIABLE_BOOTSERVICE_ACCESS | \ + EFI_VARIABLE_RUNTIME_ACCESS) + +/* Offset from Unix time to Windows time (100ns since 1 Jan 1601) */ +#define UNIX_TIME_TO_WINDOWS_TIME_OFFSET 116444736000000000ULL + +static DEFINE_MUTEX(cs_amp_efi_cal_write_lock); + +static u64 cs_amp_time_now_in_windows_time(void) +{ + u64 time_in_100ns = div_u64(ktime_get_real_ns(), 100); + + return time_in_100ns + UNIX_TIME_TO_WINDOWS_TIME_OFFSET; +} + static int cs_amp_write_cal_coeff(struct cs_dsp *dsp, const struct cirrus_amp_cal_controls *controls, const char *ctl_name, u32 val) @@ -73,6 +95,34 @@ static int cs_amp_write_cal_coeff(struct cs_dsp *dsp, return -ENODEV; } +static int cs_amp_read_cal_coeff(struct cs_dsp *dsp, + const struct cirrus_amp_cal_controls *controls, + const char *ctl_name, u32 *val) +{ + struct cs_dsp_coeff_ctl *cs_ctl; + __be32 beval; + int ret; + + KUNIT_STATIC_STUB_REDIRECT(cs_amp_read_cal_coeff, dsp, controls, ctl_name, val); + + if (!IS_REACHABLE(CONFIG_FW_CS_DSP)) + return -ENODEV; + + scoped_guard(mutex, &dsp->pwr_lock) { + cs_ctl = cs_dsp_get_ctl(dsp, ctl_name, controls->mem_region, controls->alg_id); + ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, &beval, sizeof(beval)); + } + + if (ret < 0) { + dev_err(dsp->dev, "Failed to write to '%s': %d\n", ctl_name, ret); + return ret; + } + + *val = be32_to_cpu(beval); + + return 0; +} + static int _cs_amp_write_cal_coeffs(struct cs_dsp *dsp, const struct cirrus_amp_cal_controls *controls, const struct cirrus_amp_cal_data *data) @@ -106,6 +156,45 @@ static int _cs_amp_write_cal_coeffs(struct cs_dsp *dsp, return 0; } +static int _cs_amp_read_cal_coeffs(struct cs_dsp *dsp, + const struct cirrus_amp_cal_controls *controls, + struct cirrus_amp_cal_data *data) +{ + u64 time; + u32 val; + int ret; + + if (list_empty(&dsp->ctl_list)) { + dev_info(dsp->dev, "Calibration disabled due to missing firmware controls\n"); + return -ENOENT; + } + + ret = cs_amp_read_cal_coeff(dsp, controls, controls->ambient, &val); + if (ret) + return ret; + + data->calAmbient = (s8)val; + + ret = cs_amp_read_cal_coeff(dsp, controls, controls->calr, &val); + if (ret) + return ret; + + data->calR = (u16)val; + + ret = cs_amp_read_cal_coeff(dsp, controls, controls->status, &val); + if (ret) + return ret; + + data->calStatus = (u8)val; + + /* Fill in timestamp */ + time = cs_amp_time_now_in_windows_time(); + data->calTime[0] = (u32)time; + data->calTime[1] = (u32)(time >> 32); + + return 0; +} + /** * cs_amp_write_cal_coeffs - Write calibration data to firmware controls. * @dsp: Pointer to struct cs_dsp. @@ -125,21 +214,78 @@ int cs_amp_write_cal_coeffs(struct cs_dsp *dsp, } EXPORT_SYMBOL_NS_GPL(cs_amp_write_cal_coeffs, "SND_SOC_CS_AMP_LIB"); +/** + * cs_amp_read_cal_coeffs - Read calibration data from firmware controls. + * @dsp: Pointer to struct cs_dsp. + * @controls: Pointer to definition of firmware controls to be read. + * @data: Pointer to calibration data where results will be written. + * + * Returns: 0 on success, else negative error value. + */ +int cs_amp_read_cal_coeffs(struct cs_dsp *dsp, + const struct cirrus_amp_cal_controls *controls, + struct cirrus_amp_cal_data *data) +{ + if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST)) + return _cs_amp_read_cal_coeffs(dsp, controls, data); + else + return -ENODEV; +} +EXPORT_SYMBOL_NS_GPL(cs_amp_read_cal_coeffs, "SND_SOC_CS_AMP_LIB"); + +/** + * cs_amp_write_ambient_temp - write value to calibration ambient temperature + * @dsp: Pointer to struct cs_dsp. + * @controls: Pointer to definition of firmware controls to be read. + * @temp: Temperature in degrees celcius. + * + * Returns: 0 on success, else negative error value. + */ +int cs_amp_write_ambient_temp(struct cs_dsp *dsp, + const struct cirrus_amp_cal_controls *controls, + u32 temp) +{ + if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST)) + return cs_amp_write_cal_coeff(dsp, controls, controls->ambient, temp); + else + return -ENODEV; +} +EXPORT_SYMBOL_NS_GPL(cs_amp_write_ambient_temp, "SND_SOC_CS_AMP_LIB"); + static efi_status_t cs_amp_get_efi_variable(efi_char16_t *name, efi_guid_t *guid, + u32 *returned_attr, unsigned long *size, void *buf) { u32 attr; - KUNIT_STATIC_STUB_REDIRECT(cs_amp_get_efi_variable, name, guid, size, buf); + if (!returned_attr) + returned_attr = &attr; + + KUNIT_STATIC_STUB_REDIRECT(cs_amp_get_efi_variable, name, guid, + returned_attr, size, buf); if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) - return efi.get_variable(name, guid, &attr, size, buf); + return efi.get_variable(name, guid, returned_attr, size, buf); return EFI_NOT_FOUND; } +static efi_status_t cs_amp_set_efi_variable(efi_char16_t *name, + efi_guid_t *guid, + u32 attr, + unsigned long size, + void *buf) +{ + KUNIT_STATIC_STUB_REDIRECT(cs_amp_set_efi_variable, name, guid, attr, size, buf); + + if (!efi_rt_services_supported(EFI_RT_SUPPORTED_SET_VARIABLE)) + return EFI_NOT_FOUND; + + return efi.set_variable(name, guid, attr, size, buf); +} + static int cs_amp_convert_efi_status(efi_status_t status) { switch (status) { @@ -149,6 +295,7 @@ static int cs_amp_convert_efi_status(efi_status_t status) return -ENOENT; case EFI_BUFFER_TOO_SMALL: return -EFBIG; + case EFI_WRITE_PROTECTED: case EFI_UNSUPPORTED: case EFI_ACCESS_DENIED: case EFI_SECURITY_VIOLATION: @@ -158,11 +305,13 @@ static int cs_amp_convert_efi_status(efi_status_t status) } } -static struct cirrus_amp_efi_data *cs_amp_get_cal_efi_buffer(struct device *dev) +static struct cirrus_amp_efi_data *cs_amp_get_cal_efi_buffer(struct device *dev, + efi_char16_t **name, + efi_guid_t **guid, + u32 *attr) { - struct cirrus_amp_efi_data *efi_data; + struct cirrus_amp_efi_data *efi_data __free(kfree) = NULL; unsigned long data_size = 0; - u8 *data; efi_status_t status; int i, ret; @@ -170,7 +319,7 @@ static struct cirrus_amp_efi_data *cs_amp_get_cal_efi_buffer(struct device *dev) for (i = 0; i < ARRAY_SIZE(cs_amp_lib_cal_efivars); i++) { status = cs_amp_get_efi_variable(cs_amp_lib_cal_efivars[i].name, cs_amp_lib_cal_efivars[i].guid, - &data_size, NULL); + attr, &data_size, NULL); if (status == EFI_BUFFER_TOO_SMALL) break; } @@ -178,25 +327,30 @@ static struct cirrus_amp_efi_data *cs_amp_get_cal_efi_buffer(struct device *dev) if (status != EFI_BUFFER_TOO_SMALL) return ERR_PTR(-ENOENT); + if (name) + *name = cs_amp_lib_cal_efivars[i].name; + + if (guid) + *guid = cs_amp_lib_cal_efivars[i].guid; + if (data_size < sizeof(*efi_data)) { dev_err(dev, "EFI cal variable truncated\n"); return ERR_PTR(-EOVERFLOW); } /* Get variable contents into buffer */ - data = kmalloc(data_size, GFP_KERNEL); - if (!data) + efi_data = kmalloc(data_size, GFP_KERNEL); + if (!efi_data) return ERR_PTR(-ENOMEM); status = cs_amp_get_efi_variable(cs_amp_lib_cal_efivars[i].name, cs_amp_lib_cal_efivars[i].guid, - &data_size, data); + attr, &data_size, efi_data); if (status != EFI_SUCCESS) { ret = -EINVAL; goto err; } - efi_data = (struct cirrus_amp_efi_data *)data; dev_dbg(dev, "Calibration: Size=%d, Amp Count=%d\n", efi_data->size, efi_data->count); if ((efi_data->count > 128) || @@ -206,28 +360,40 @@ static struct cirrus_amp_efi_data *cs_amp_get_cal_efi_buffer(struct device *dev) goto err; } - return efi_data; + /* This could be zero-filled space pre-allocated by the BIOS */ + if (efi_data->size == 0) + efi_data->size = data_size; + + return_ptr(efi_data); err: - kfree(data); dev_err(dev, "Failed to read calibration data from EFI: %d\n", ret); return ERR_PTR(ret); } -static u64 cs_amp_cal_target_u64(const struct cirrus_amp_cal_data *data) +static int cs_amp_set_cal_efi_buffer(struct device *dev, + efi_char16_t *name, + efi_guid_t *guid, + u32 attr, + struct cirrus_amp_efi_data *data) { - return ((u64)data->calTarget[1] << 32) | data->calTarget[0]; + efi_status_t status; + + status = cs_amp_set_efi_variable(name, guid, attr, + struct_size(data, data, data->count), data); + + return cs_amp_convert_efi_status(status); } static int _cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_index, struct cirrus_amp_cal_data *out_data) { - struct cirrus_amp_efi_data *efi_data; + struct cirrus_amp_efi_data *efi_data __free(kfree) = NULL; struct cirrus_amp_cal_data *cal = NULL; - int i, ret; + int i; - efi_data = cs_amp_get_cal_efi_buffer(dev); + efi_data = cs_amp_get_cal_efi_buffer(dev, NULL, NULL, NULL); if (IS_ERR(efi_data)) return PTR_ERR(efi_data); @@ -266,17 +432,106 @@ static int _cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, dev_warn(dev, "Calibration entry %d does not match silicon ID", amp_index); } - if (cal) { - memcpy(out_data, cal, sizeof(*out_data)); - ret = 0; - } else { + if (!cal) { dev_warn(dev, "No calibration for silicon ID %#llx\n", target_uid); - ret = -ENOENT; + return -ENOENT; + } + + memcpy(out_data, cal, sizeof(*out_data)); + + return 0; +} + +static int _cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, int num_amps, + const struct cirrus_amp_cal_data *in_data) +{ + u64 cal_target = cs_amp_cal_target_u64(in_data); + unsigned long num_entries; + struct cirrus_amp_efi_data *data __free(kfree) = NULL; + efi_char16_t *name = CIRRUS_LOGIC_CALIBRATION_EFI_NAME; + efi_guid_t *guid = &CIRRUS_LOGIC_CALIBRATION_EFI_GUID; + u32 attr = CS_AMP_CAL_DEFAULT_EFI_ATTR; + int i, ret; + + if (cal_target == 0) + return -EINVAL; + + data = cs_amp_get_cal_efi_buffer(dev, &name, &guid, &attr); + ret = PTR_ERR_OR_ZERO(data); + if (ret == -ENOENT) { + data = NULL; + goto alloc_new; + } else if (ret) { + return ret; + } + + /* + * If the EFI variable is just zero-filled reserved space the count + * must be set. + */ + if (data->count == 0) + data->count = (data->size - sizeof(data)) / sizeof(data->data[0]); + + if (amp_index < 0) { + /* Is there already a slot for this target? */ + for (amp_index = 0; amp_index < data->count; amp_index++) { + if (cs_amp_cal_target_u64(&data->data[amp_index]) == cal_target) + break; + } + + /* Else find an empty slot */ + if (amp_index >= data->count) { + for (amp_index = 0; amp_index < data->count; amp_index++) { + if ((data->data[amp_index].calTime[0] == 0) && + (data->data[amp_index].calTime[1] == 0)) + break; + } + } + } else { + /* + * If the index is forced there could be another active + * slot with the same calTarget. So deduplicate. + */ + for (i = 0; i < data->count; i++) { + if (i == amp_index) + continue; + + if ((data->data[i].calTime[0] == 0) && (data->data[i].calTime[1] == 0)) + continue; + + if (cs_amp_cal_target_u64(&data->data[i]) == cal_target) + memset(data->data[i].calTime, 0, sizeof(data->data[i].calTime)); + } } - kfree(efi_data); +alloc_new: + if (amp_index < 0) + amp_index = 0; + + num_entries = max(num_amps, amp_index + 1); + if (!data || (data->count < num_entries)) { + struct cirrus_amp_efi_data *old_data __free(kfree) = no_free_ptr(data); + unsigned int new_data_size = struct_size(data, data, num_entries); + + data = kzalloc(new_data_size, GFP_KERNEL); + if (!data) + return -ENOMEM; - return ret; + if (old_data) + memcpy(data, old_data, struct_size(old_data, data, old_data->count)); + + data->count = num_entries; + data->size = new_data_size; + } + + data->data[amp_index] = *in_data; + ret = cs_amp_set_cal_efi_buffer(dev, name, guid, attr, data); + if (ret) { + dev_err(dev, "Failed writing calibration to EFI: %d\n", ret); + return ret; + } + + return 0; } /** @@ -325,6 +580,46 @@ int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_ } EXPORT_SYMBOL_NS_GPL(cs_amp_get_efi_calibration_data, "SND_SOC_CS_AMP_LIB"); +/** + * cs_amp_set_efi_calibration_data - write a calibration data entry to EFI. + * @dev: struct device of the caller. + * @amp_index: Entry index to use, or -1 to use any available slot. + * @num_amps: Maximum number of amps to reserve slots for, or -1 to ignore. + * @in_data: struct cirrus_amp_cal_data entry to be written to EFI. + * + * If a Vendor-specific variable exists it will be updated, + * else if the Cirrus variable exists it will be updated + * else the Cirrus variable will be created. + * + * If amp_index >= 0 the data will be placed in this entry of the calibration + * data array, overwriting what was in that entry. Any other entries with the + * same calTarget will be marked empty. + * + * If amp_index < 0 and in_data->calTarget matches any existing entry, that + * entry will be overwritten. Else the first available free entry will be used, + * extending the size of the EFI variable if there are no free entries. + * + * If num_amps > 0 the EFI variable will be sized to contain at least this + * many calibration entries, with any new entries marked empty. + * + * Return: 0 if the write was successful, -EFBIG if space could not be made in + * the EFI file to add the entry, -EACCES if it was not possible to + * read or write the EFI variable. + */ +int cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, int num_amps, + const struct cirrus_amp_cal_data *in_data) +{ + if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST)) { + scoped_guard(mutex, &cs_amp_efi_cal_write_lock) { + return _cs_amp_set_efi_calibration_data(dev, amp_index, + num_amps, in_data); + } + } + + return -ENOENT; +} +EXPORT_SYMBOL_NS_GPL(cs_amp_set_efi_calibration_data, "SND_SOC_CS_AMP_LIB"); + struct cs_amp_spkid_efi { efi_char16_t *name; efi_guid_t *guid; @@ -339,7 +634,7 @@ static int cs_amp_get_efi_byte_spkid(struct device *dev, const struct cs_amp_spk int i, ret; size = sizeof(spkid); - status = cs_amp_get_efi_variable(info->name, info->guid, &size, &spkid); + status = cs_amp_get_efi_variable(info->name, info->guid, NULL, &size, &spkid); ret = cs_amp_convert_efi_status(status); if (ret < 0) return ret; @@ -400,9 +695,36 @@ int cs_amp_get_vendor_spkid(struct device *dev) } EXPORT_SYMBOL_NS_GPL(cs_amp_get_vendor_spkid, "SND_SOC_CS_AMP_LIB"); +/** + * cs_amp_create_debugfs - create a debugfs directory for a device + * + * @dev: pointer to struct device + * + * Creates a node under "cirrus_logic" in the root of the debugfs filesystem. + * This is for Cirrus-specific debugfs functionality to be grouped in a + * defined way, independently of the debugfs provided by ALSA/ASoC. + * The general ALSA/ASoC debugfs may not be enabled, and does not necessarily + * have a stable layout or naming convention. + * + * Return: Pointer to the dentry for the created directory, or -ENODEV. + */ +struct dentry *cs_amp_create_debugfs(struct device *dev) +{ + struct dentry *dir; + + dir = debugfs_lookup("cirrus_logic", NULL); + if (!dir) + dir = debugfs_create_dir("cirrus_logic", NULL); + + return debugfs_create_dir(dev_name(dev), dir); +} +EXPORT_SYMBOL_NS_GPL(cs_amp_create_debugfs, "SND_SOC_CS_AMP_LIB"); + static const struct cs_amp_test_hooks cs_amp_test_hook_ptrs = { .get_efi_variable = cs_amp_get_efi_variable, + .set_efi_variable = cs_amp_set_efi_variable, .write_cal_coeff = cs_amp_write_cal_coeff, + .read_cal_coeff = cs_amp_read_cal_coeff, }; const struct cs_amp_test_hooks * const cs_amp_test_hooks = diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c index c927592f90c9..98b4d371d931 100644 --- a/sound/soc/codecs/cs35l33.c +++ b/sound/soc/codecs/cs35l33.c @@ -547,7 +547,7 @@ static int cs35l33_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { struct snd_soc_component *component = dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); unsigned int reg, bit_pos, i; int slot, slot_num; @@ -695,7 +695,7 @@ static int cs35l33_set_hg_data(struct snd_soc_component *component, struct cs35l33_pdata *pdata) { struct cs35l33_hg *hg_config = &pdata->hg_config; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); if (hg_config->enable_hg_algo) { diff --git a/sound/soc/codecs/cs35l36.c b/sound/soc/codecs/cs35l36.c index b60697ff7a50..93818d7ec1a7 100644 --- a/sound/soc/codecs/cs35l36.c +++ b/sound/soc/codecs/cs35l36.c @@ -455,8 +455,7 @@ static SOC_ENUM_SINGLE_DECL(pcm_sft_ramp, CS35L36_AMP_DIG_VOL_CTRL, 0, static int cs35l36_ldm_sel_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs35l36_private *cs35l36 = snd_soc_component_get_drvdata(component); @@ -468,8 +467,7 @@ static int cs35l36_ldm_sel_get(struct snd_kcontrol *kcontrol, static int cs35l36_ldm_sel_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs35l36_private *cs35l36 = snd_soc_component_get_drvdata(component); int val = (ucontrol->value.integer.value[0]) ? CS35L36_NG_AMP_EN_MASK : diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index 173d7c59b725..3a8a8dd065b7 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -928,7 +928,7 @@ static const struct snd_soc_dapm_widget cs35l41_ext_bst_widget[] = { static int cs35l41_component_probe(struct snd_soc_component *component) { struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) { diff --git a/sound/soc/codecs/cs35l45.c b/sound/soc/codecs/cs35l45.c index d4dcdf37bb70..e33f11435980 100644 --- a/sound/soc/codecs/cs35l45.c +++ b/sound/soc/codecs/cs35l45.c @@ -198,8 +198,7 @@ static int cs35l45_activate_ctl(struct snd_soc_component *component, static int cs35l45_amplifier_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs35l45_private *cs35l45 = snd_soc_component_get_drvdata(component); @@ -211,12 +210,11 @@ static int cs35l45_amplifier_mode_get(struct snd_kcontrol *kcontrol, static int cs35l45_amplifier_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs35l45_private *cs35l45 = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + snd_soc_component_to_dapm(component); unsigned int amp_state; int ret; @@ -235,7 +233,7 @@ static int cs35l45_amplifier_mode_put(struct snd_kcontrol *kcontrol, regmap_clear_bits(cs35l45->regmap, CS35L45_BLOCK_ENABLES, CS35L45_AMP_EN_MASK); - snd_soc_component_disable_pin_unlocked(component, "SPK"); + snd_soc_dapm_disable_pin_unlocked(dapm, "SPK"); snd_soc_dapm_sync_unlocked(dapm); if (ucontrol->value.integer.value[0] == AMP_MODE_SPK) { @@ -289,7 +287,7 @@ static int cs35l45_amplifier_mode_put(struct snd_kcontrol *kcontrol, regmap_set_bits(cs35l45->regmap, CS35L45_BLOCK_ENABLES, CS35L45_AMP_EN_MASK); - snd_soc_component_enable_pin_unlocked(component, "SPK"); + snd_soc_dapm_enable_pin_unlocked(dapm, "SPK"); snd_soc_dapm_sync_unlocked(dapm); snd_soc_dapm_mutex_unlock(dapm); diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c index 9e6b9ca2f354..60100c8f8c95 100644 --- a/sound/soc/codecs/cs35l56-shared.c +++ b/sound/soc/codecs/cs35l56-shared.c @@ -6,11 +6,18 @@ // Cirrus Logic International Semiconductor Ltd. #include <linux/array_size.h> +#include <linux/cleanup.h> +#include <linux/debugfs.h> #include <linux/firmware/cirrus/wmfw.h> +#include <linux/fs.h> #include <linux/gpio/consumer.h> +#include <linux/kstrtox.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/spi/spi.h> +#include <linux/stddef.h> +#include <linux/string.h> +#include <linux/string_choices.h> #include <linux/types.h> #include <sound/cs-amp-lib.h> @@ -206,6 +213,8 @@ static bool cs35l56_readable_reg(struct device *dev, unsigned int reg) case CS35L56_IRQ1_MASK_8: case CS35L56_IRQ1_MASK_18: case CS35L56_IRQ1_MASK_20: + case CS35L56_MIXER_NGATE_CH1_CFG: + case CS35L56_MIXER_NGATE_CH2_CFG: case CS35L56_DSP_VIRTUAL1_MBOX_1: case CS35L56_DSP_VIRTUAL1_MBOX_2: case CS35L56_DSP_VIRTUAL1_MBOX_3: @@ -263,6 +272,8 @@ static bool cs35l56_common_volatile_reg(unsigned int reg) case CS35L56_IRQ1_EINT_1 ... CS35L56_IRQ1_EINT_8: case CS35L56_IRQ1_EINT_18: case CS35L56_IRQ1_EINT_20: + case CS35L56_MIXER_NGATE_CH1_CFG: + case CS35L56_MIXER_NGATE_CH2_CFG: case CS35L56_DSP_VIRTUAL1_MBOX_1: case CS35L56_DSP_VIRTUAL1_MBOX_2: case CS35L56_DSP_VIRTUAL1_MBOX_3: @@ -724,15 +735,11 @@ static void cs35l56_issue_wake_event(struct cs35l56_base *cs35l56_base) cs35l56_wait_control_port_ready(); } -int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base) +static int cs35l56_wait_for_ps3(struct cs35l56_base *cs35l56_base) { unsigned int val; int ret; - if (!cs35l56_base->init_done) - return 0; - - /* Firmware must have entered a power-save state */ ret = regmap_read_poll_timeout(cs35l56_base->regmap, cs35l56_base->fw_reg->transducer_actual_ps, val, (val >= CS35L56_PS3), @@ -741,6 +748,17 @@ int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base) if (ret) dev_warn(cs35l56_base->dev, "PS3 wait failed: %d\n", ret); + return ret; +} + +int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base) +{ + if (!cs35l56_base->init_done) + return 0; + + /* Firmware must have entered a power-save state */ + cs35l56_wait_for_ps3(cs35l56_base); + /* Clear BOOT_DONE so it can be used to detect a reboot */ regmap_write(cs35l56_base->regmap, CS35L56_IRQ1_EINT_4, CS35L56_OTP_BOOT_DONE_MASK); @@ -839,6 +857,8 @@ void cs35l56_init_cs_dsp(struct cs35l56_base *cs35l56_base, struct cs_dsp *cs_ds cs_dsp->mem = cs35l56_dsp1_regions; cs_dsp->num_mems = ARRAY_SIZE(cs35l56_dsp1_regions); cs_dsp->no_core_startstop = true; + + cs35l56_base->dsp = cs_dsp; } EXPORT_SYMBOL_NS_GPL(cs35l56_init_cs_dsp, "SND_SOC_CS35L56_SHARED"); @@ -853,7 +873,7 @@ struct cs35l56_pte { } __packed; static_assert((sizeof(struct cs35l56_pte) % sizeof(u32)) == 0); -static int cs35l56_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid) +static int cs35l56_read_silicon_uid(struct cs35l56_base *cs35l56_base) { struct cs35l56_pte pte; u64 unique_id; @@ -870,14 +890,15 @@ static int cs35l56_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid) unique_id |= (u32)pte.x | ((u32)pte.y << 8) | ((u32)pte.wafer_id << 16) | ((u32)pte.dvs << 24); - *uid = unique_id; + cs35l56_base->silicon_uid = unique_id; return 0; } -static int cs35l63_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid) +static int cs35l63_read_silicon_uid(struct cs35l56_base *cs35l56_base) { u32 tmp[2]; + u64 unique_id; int ret; ret = regmap_bulk_read(cs35l56_base->regmap, CS35L56_DIE_STS1, tmp, ARRAY_SIZE(tmp)); @@ -886,9 +907,11 @@ static int cs35l63_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid) return ret; } - *uid = tmp[1]; - *uid <<= 32; - *uid |= tmp[0]; + unique_id = tmp[1]; + unique_id <<= 32; + unique_id |= tmp[0]; + + cs35l56_base->silicon_uid = unique_id; return 0; } @@ -915,48 +938,378 @@ static const struct cirrus_amp_cal_controls cs35l63_calibration_controls = { int cs35l56_get_calibration(struct cs35l56_base *cs35l56_base) { - u64 silicon_uid = 0; int ret; /* Driver can't apply calibration to a secured part, so skip */ if (cs35l56_base->secured) return 0; + ret = cs_amp_get_efi_calibration_data(cs35l56_base->dev, + cs35l56_base->silicon_uid, + cs35l56_base->cal_index, + &cs35l56_base->cal_data); + + /* Only return an error status if probe should be aborted */ + if ((ret == -ENOENT) || (ret == -EOVERFLOW)) + return 0; + + if (ret < 0) + return ret; + + cs35l56_base->cal_data_valid = true; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(cs35l56_get_calibration, "SND_SOC_CS35L56_SHARED"); + +int cs35l56_stash_calibration(struct cs35l56_base *cs35l56_base, + const struct cirrus_amp_cal_data *data) +{ + + /* Ignore if it is empty */ + if (!data->calTime[0] && !data->calTime[1]) + return -ENODATA; + + if (cs_amp_cal_target_u64(data) != cs35l56_base->silicon_uid) { + dev_err(cs35l56_base->dev, "cal_data not for this silicon ID\n"); + return -EINVAL; + } + + cs35l56_base->cal_data = *data; + cs35l56_base->cal_data_valid = true; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(cs35l56_stash_calibration, "SND_SOC_CS35L56_SHARED"); + +static int cs35l56_perform_calibration(struct cs35l56_base *cs35l56_base) +{ + const struct cirrus_amp_cal_controls *calibration_controls = + cs35l56_base->calibration_controls; + struct cs_dsp *dsp = cs35l56_base->dsp; + struct cirrus_amp_cal_data cal_data; + struct cs_dsp_coeff_ctl *ctl; + bool ngate_ch1_was_enabled = false; + bool ngate_ch2_was_enabled = false; + int cali_norm_en_alg_id, cali_norm_en_mem; + int ret; + __be32 val; + + if (cs35l56_base->silicon_uid == 0) { + dev_err(cs35l56_base->dev, "Cannot calibrate: no silicon UID\n"); + return -ENXIO; + } + switch (cs35l56_base->type) { case 0x54: case 0x56: case 0x57: - ret = cs35l56_read_silicon_uid(cs35l56_base, &silicon_uid); - break; - case 0x63: - ret = cs35l63_read_silicon_uid(cs35l56_base, &silicon_uid); + if (cs35l56_base->rev < 0xb2) { + cali_norm_en_alg_id = 0x9f22f; + cali_norm_en_mem = WMFW_ADSP2_YM; + } else { + cali_norm_en_alg_id = 0x9f210; + cali_norm_en_mem = WMFW_ADSP2_XM; + } break; default: - ret = -ENODEV; + cali_norm_en_alg_id = 0xbf210; + cali_norm_en_mem = WMFW_ADSP2_XM; break; } + ret = pm_runtime_resume_and_get(cs35l56_base->dev); + if (ret) + return ret; + + ret = cs35l56_wait_for_ps3(cs35l56_base); + if (ret) { + ret = -EBUSY; + goto err_pm_put; + } + + regmap_update_bits_check(cs35l56_base->regmap, CS35L56_MIXER_NGATE_CH1_CFG, + CS35L56_AUX_NGATE_CHn_EN, 0, &ngate_ch1_was_enabled); + regmap_update_bits_check(cs35l56_base->regmap, CS35L56_MIXER_NGATE_CH2_CFG, + CS35L56_AUX_NGATE_CHn_EN, 0, &ngate_ch2_was_enabled); + + scoped_guard(mutex, &dsp->pwr_lock) { + ctl = cs_dsp_get_ctl(dsp, + calibration_controls->status, + calibration_controls->mem_region, + calibration_controls->alg_id); + if (!ctl) { + dev_err(cs35l56_base->dev, "Could not get %s control\n", + calibration_controls->status); + ret = -EIO; + goto err; + } + + val = cpu_to_be32(0); + ret = cs_dsp_coeff_write_ctrl(cs_dsp_get_ctl(dsp, + "CALI_NORM_EN", + cali_norm_en_mem, + cali_norm_en_alg_id), + 0, &val, sizeof(val)); + if (ret < 0) { + dev_err(cs35l56_base->dev, "Could not write %s: %d\n", "CALI_NORM_EN", ret); + ret = -EIO; + goto err; + } + + ret = cs35l56_mbox_send(cs35l56_base, CS35L56_MBOX_CMD_AUDIO_CALIBRATION); + if (ret) { + ret = -EIO; + goto err; + } + + if (read_poll_timeout(cs_dsp_coeff_read_ctrl, ret, + (val == cpu_to_be32(1)), + CS35L56_CALIBRATION_POLL_US, + CS35L56_CALIBRATION_TIMEOUT_US, + true, + ctl, 0, &val, sizeof(val))) { + dev_err(cs35l56_base->dev, "Calibration timed out (CAL_STATUS: %u)\n", + be32_to_cpu(val)); + switch (be32_to_cpu(val)) { + case CS35L56_CAL_STATUS_OUT_OF_RANGE: + ret = -ERANGE; + goto err; + default: + ret = -ETIMEDOUT; + goto err; + } + } + } + + cs35l56_base->cal_data_valid = false; + memset(&cal_data, 0, sizeof(cal_data)); + ret = cs_amp_read_cal_coeffs(dsp, calibration_controls, &cal_data); + if (ret) { + ret = -EIO; + goto err; + } + + dev_info(cs35l56_base->dev, "Cal status:%d calR:%d ambient:%d\n", + cal_data.calStatus, cal_data.calR, cal_data.calAmbient); + + cal_data.calTarget[0] = (u32)cs35l56_base->silicon_uid; + cal_data.calTarget[1] = (u32)(cs35l56_base->silicon_uid >> 32); + cs35l56_base->cal_data = cal_data; + cs35l56_base->cal_data_valid = true; + + ret = 0; + +err: + if (ngate_ch1_was_enabled) { + regmap_set_bits(cs35l56_base->regmap, CS35L56_MIXER_NGATE_CH1_CFG, + CS35L56_AUX_NGATE_CHn_EN); + } + if (ngate_ch2_was_enabled) { + regmap_set_bits(cs35l56_base->regmap, CS35L56_MIXER_NGATE_CH2_CFG, + CS35L56_AUX_NGATE_CHn_EN); + } +err_pm_put: + pm_runtime_put(cs35l56_base->dev); + + return ret; +} + +ssize_t cs35l56_calibrate_debugfs_write(struct cs35l56_base *cs35l56_base, + const char __user *from, size_t count, + loff_t *ppos) +{ + static const char * const options[] = { "factory", "store_uefi" }; + char buf[11] = { 0 }; + int num_amps, ret; + + if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON)) + return -ENXIO; + + if (*ppos) + return -EINVAL; + + ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, from, count); if (ret < 0) return ret; - dev_dbg(cs35l56_base->dev, "UniqueID = %#llx\n", silicon_uid); + switch (sysfs_match_string(options, buf)) { + case 0: + ret = cs35l56_perform_calibration(cs35l56_base); + if (ret < 0) + return ret; + break; + case 1: + if (!cs35l56_base->cal_data_valid) + return -ENODATA; + + num_amps = cs35l56_base->num_amps; + if (num_amps == 0) + num_amps = -1; + + ret = cs_amp_set_efi_calibration_data(cs35l56_base->dev, + cs35l56_base->cal_index, + num_amps, + &cs35l56_base->cal_data); + if (ret < 0) + return ret; + break; + default: + return -EOPNOTSUPP; + } - ret = cs_amp_get_efi_calibration_data(cs35l56_base->dev, silicon_uid, - cs35l56_base->cal_index, - &cs35l56_base->cal_data); + return count; +} +EXPORT_SYMBOL_NS_GPL(cs35l56_calibrate_debugfs_write, "SND_SOC_CS35L56_SHARED"); - /* Only return an error status if probe should be aborted */ - if ((ret == -ENOENT) || (ret == -EOVERFLOW)) - return 0; +ssize_t cs35l56_cal_ambient_debugfs_write(struct cs35l56_base *cs35l56_base, + const char __user *from, size_t count, + loff_t *ppos) +{ + unsigned long val; + int ret; + + if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON)) + return -ENXIO; + + if (*ppos) + return -EINVAL; + + ret = pm_runtime_resume_and_get(cs35l56_base->dev); + if (ret) + return ret; + + ret = kstrtoul_from_user(from, count, 10, &val); + if (ret < 0) + goto out; + + ret = cs_amp_write_ambient_temp(cs35l56_base->dsp, cs35l56_base->calibration_controls, val); + if (ret) + ret = -EIO; +out: + pm_runtime_put(cs35l56_base->dev); if (ret < 0) return ret; - cs35l56_base->cal_data_valid = true; + return count; +} +EXPORT_SYMBOL_NS_GPL(cs35l56_cal_ambient_debugfs_write, "SND_SOC_CS35L56_SHARED"); - return 0; +ssize_t cs35l56_cal_data_debugfs_read(struct cs35l56_base *cs35l56_base, + char __user *to, size_t count, + loff_t *ppos) +{ + if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON)) + return -ENXIO; + + if (!cs35l56_base->cal_data_valid) + return 0; + + return simple_read_from_buffer(to, count, ppos, &cs35l56_base->cal_data, + sizeof(cs35l56_base->cal_data)); } -EXPORT_SYMBOL_NS_GPL(cs35l56_get_calibration, "SND_SOC_CS35L56_SHARED"); +EXPORT_SYMBOL_NS_GPL(cs35l56_cal_data_debugfs_read, "SND_SOC_CS35L56_SHARED"); + +ssize_t cs35l56_cal_data_debugfs_write(struct cs35l56_base *cs35l56_base, + const char __user *from, size_t count, + loff_t *ppos) +{ + struct cirrus_amp_cal_data cal_data; + int ret; + + if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON)) + return -ENXIO; + + /* Only allow a full blob to be written */ + if (*ppos || (count != sizeof(cal_data))) + return -EMSGSIZE; + + ret = simple_write_to_buffer(&cal_data, sizeof(cal_data), ppos, from, count); + if (ret) + return ret; + + ret = cs35l56_stash_calibration(cs35l56_base, &cal_data); + if (ret) + return ret; + + return count; +} +EXPORT_SYMBOL_NS_GPL(cs35l56_cal_data_debugfs_write, "SND_SOC_CS35L56_SHARED"); + +void cs35l56_create_cal_debugfs(struct cs35l56_base *cs35l56_base, + const struct cs35l56_cal_debugfs_fops *fops) +{ + if (!IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS_COMMON)) + return; + + cs35l56_base->debugfs = cs_amp_create_debugfs(cs35l56_base->dev); + + debugfs_create_file("calibrate", + 0200, cs35l56_base->debugfs, cs35l56_base, + &fops->calibrate); + debugfs_create_file("cal_temperature", + 0200, cs35l56_base->debugfs, cs35l56_base, + &fops->cal_temperature); + debugfs_create_file("cal_data", + 0644, cs35l56_base->debugfs, cs35l56_base, + &fops->cal_data); +} +EXPORT_SYMBOL_NS_GPL(cs35l56_create_cal_debugfs, "SND_SOC_CS35L56_SHARED"); + +void cs35l56_remove_cal_debugfs(struct cs35l56_base *cs35l56_base) +{ + debugfs_remove_recursive(cs35l56_base->debugfs); +} +EXPORT_SYMBOL_NS_GPL(cs35l56_remove_cal_debugfs, "SND_SOC_CS35L56_SHARED"); + +const char * const cs35l56_cal_set_status_text[] = { + "Unknown", "Default", "Set", +}; +EXPORT_SYMBOL_NS_GPL(cs35l56_cal_set_status_text, "SND_SOC_CS35L56_SHARED"); + +int cs35l56_cal_set_status_get(struct cs35l56_base *cs35l56_base, + struct snd_ctl_elem_value *uvalue) +{ + struct cs_dsp *dsp = cs35l56_base->dsp; + __be32 cal_set_status_be; + int alg_id; + int ret; + + switch (cs35l56_base->type) { + case 0x54: + case 0x56: + case 0x57: + alg_id = 0x9f210; + break; + default: + alg_id = 0xbf210; + break; + } + + scoped_guard(mutex, &dsp->pwr_lock) { + ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(dsp, + "CAL_SET_STATUS", + WMFW_ADSP2_YM, alg_id), + 0, &cal_set_status_be, + sizeof(cal_set_status_be)); + } + if (ret) { + uvalue->value.enumerated.item[0] = CS35L56_CAL_SET_STATUS_UNKNOWN; + return 0; + } + + switch (be32_to_cpu(cal_set_status_be)) { + case CS35L56_CAL_SET_STATUS_DEFAULT: + case CS35L56_CAL_SET_STATUS_SET: + uvalue->value.enumerated.item[0] = be32_to_cpu(cal_set_status_be); + return 0; + default: + uvalue->value.enumerated.item[0] = CS35L56_CAL_SET_STATUS_UNKNOWN; + return 0; + } +} +EXPORT_SYMBOL_NS_GPL(cs35l56_cal_set_status_get, "SND_SOC_CS35L56_SHARED"); int cs35l56_read_prot_status(struct cs35l56_base *cs35l56_base, bool *fw_missing, unsigned int *fw_version) @@ -984,6 +1337,23 @@ int cs35l56_read_prot_status(struct cs35l56_base *cs35l56_base, } EXPORT_SYMBOL_NS_GPL(cs35l56_read_prot_status, "SND_SOC_CS35L56_SHARED"); +void cs35l56_warn_if_firmware_missing(struct cs35l56_base *cs35l56_base) +{ + unsigned int firmware_version; + bool firmware_missing; + int ret; + + ret = cs35l56_read_prot_status(cs35l56_base, &firmware_missing, &firmware_version); + if (ret) + return; + + if (!firmware_missing) + return; + + dev_warn(cs35l56_base->dev, "FIRMWARE_MISSING\n"); +} +EXPORT_SYMBOL_NS_GPL(cs35l56_warn_if_firmware_missing, "SND_SOC_CS35L56_SHARED"); + void cs35l56_log_tuning(struct cs35l56_base *cs35l56_base, struct cs_dsp *cs_dsp) { __be32 pid, sid, tid; @@ -1111,6 +1481,21 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base) CS35L56_TEMP_ERR_EINT1_MASK, 0); + switch (cs35l56_base->type) { + case 0x54: + case 0x56: + case 0x57: + ret = cs35l56_read_silicon_uid(cs35l56_base); + break; + default: + ret = cs35l63_read_silicon_uid(cs35l56_base); + break; + } + if (ret) + return ret; + + dev_dbg(cs35l56_base->dev, "SiliconID = %#llx\n", cs35l56_base->silicon_uid); + return 0; } EXPORT_SYMBOL_NS_GPL(cs35l56_hw_init, "SND_SOC_CS35L56_SHARED"); diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c index 2c1edbd636ef..55b4d0d55712 100644 --- a/sound/soc/codecs/cs35l56.c +++ b/sound/soc/codecs/cs35l56.c @@ -10,6 +10,7 @@ #include <linux/completion.h> #include <linux/debugfs.h> #include <linux/delay.h> +#include <linux/device.h> #include <linux/err.h> #include <linux/gpio/consumer.h> #include <linux/interrupt.h> @@ -65,6 +66,18 @@ static int cs35l56_dspwait_put_volsw(struct snd_kcontrol *kcontrol, static DECLARE_TLV_DB_SCALE(vol_tlv, -10000, 25, 0); +static SOC_ENUM_SINGLE_DECL(cs35l56_cal_set_status_enum, SND_SOC_NOPM, 0, + cs35l56_cal_set_status_text); + +static int cs35l56_cal_set_status_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); + + return cs35l56_cal_set_status_get(&cs35l56->base, ucontrol); +} + static const struct snd_kcontrol_new cs35l56_controls[] = { SOC_SINGLE_EXT("Speaker Switch", CS35L56_MAIN_RENDER_USER_MUTE, 0, 1, 1, @@ -82,6 +95,9 @@ static const struct snd_kcontrol_new cs35l56_controls[] = { SOC_SINGLE_EXT("Posture Number", CS35L56_MAIN_POSTURE_NUMBER, 0, 255, 0, cs35l56_dspwait_get_volsw, cs35l56_dspwait_put_volsw), + SOC_ENUM_EXT_ACC("CAL_SET_STATUS", cs35l56_cal_set_status_enum, + cs35l56_cal_set_status_ctl_get, NULL, + SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE), }; static const struct snd_kcontrol_new cs35l63_controls[] = { @@ -101,6 +117,9 @@ static const struct snd_kcontrol_new cs35l63_controls[] = { SOC_SINGLE_EXT("Posture Number", CS35L63_MAIN_POSTURE_NUMBER, 0, 255, 0, cs35l56_dspwait_get_volsw, cs35l56_dspwait_put_volsw), + SOC_ENUM_EXT_ACC("CAL_SET_STATUS", cs35l56_cal_set_status_enum, + cs35l56_cal_set_status_ctl_get, NULL, + SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE), }; static SOC_VALUE_ENUM_SINGLE_DECL(cs35l56_asp1tx1_enum, @@ -250,6 +269,8 @@ static const struct snd_soc_dapm_widget cs35l56_dapm_widgets[] = { SND_SOC_DAPM_SIGGEN("VDDBMON ADC"), SND_SOC_DAPM_SIGGEN("VBSTMON ADC"), SND_SOC_DAPM_SIGGEN("TEMPMON ADC"), + + SND_SOC_DAPM_INPUT("Calibrate"), }; #define CS35L56_SRC_ROUTE(name) \ @@ -286,6 +307,7 @@ static const struct snd_soc_dapm_route cs35l56_audio_map[] = { { "DSP1", NULL, "ASP1RX1" }, { "DSP1", NULL, "ASP1RX2" }, { "DSP1", NULL, "SDW1 Playback" }, + { "DSP1", NULL, "Calibrate" }, { "AMP", NULL, "DSP1" }, { "SPK", NULL, "AMP" }, @@ -801,6 +823,9 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56, bool firmware_missing goto err_unlock; } + /* Check if the firmware is still reported missing */ + cs35l56_warn_if_firmware_missing(&cs35l56->base); + regmap_clear_bits(cs35l56->base.regmap, cs35l56->base.fw_reg->prot_sts, CS35L56_FIRMWARE_MISSING); @@ -874,6 +899,214 @@ err: pm_runtime_put_autosuspend(cs35l56->base.dev); } +static struct snd_soc_dapm_context *cs35l56_power_up_for_cal(struct cs35l56_private *cs35l56) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(cs35l56->component); + int ret; + + ret = snd_soc_dapm_enable_pin(dapm, "Calibrate"); + if (ret) + return ERR_PTR(ret); + + snd_soc_dapm_sync(dapm); + + return dapm; +} + +static void cs35l56_power_down_after_cal(struct cs35l56_private *cs35l56) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(cs35l56->component); + + snd_soc_dapm_disable_pin(dapm, "Calibrate"); + snd_soc_dapm_sync(dapm); +} + +static ssize_t cs35l56_debugfs_calibrate_write(struct file *file, + const char __user *from, + size_t count, loff_t *ppos) +{ + struct cs35l56_base *cs35l56_base = file->private_data; + struct cs35l56_private *cs35l56 = cs35l56_private_from_base(cs35l56_base); + struct snd_soc_dapm_context *dapm; + ssize_t ret; + + dapm = cs35l56_power_up_for_cal(cs35l56); + if (IS_ERR(dapm)) + return PTR_ERR(dapm); + + snd_soc_dapm_mutex_lock(dapm); + ret = cs35l56_calibrate_debugfs_write(&cs35l56->base, from, count, ppos); + snd_soc_dapm_mutex_unlock(dapm); + + cs35l56_power_down_after_cal(cs35l56); + + return ret; +} + +static ssize_t cs35l56_debugfs_cal_temperature_write(struct file *file, + const char __user *from, + size_t count, loff_t *ppos) +{ + struct cs35l56_base *cs35l56_base = file->private_data; + struct cs35l56_private *cs35l56 = cs35l56_private_from_base(cs35l56_base); + struct snd_soc_dapm_context *dapm; + ssize_t ret; + + dapm = cs35l56_power_up_for_cal(cs35l56); + if (IS_ERR(dapm)) + return PTR_ERR(dapm); + + ret = cs35l56_cal_ambient_debugfs_write(&cs35l56->base, from, count, ppos); + cs35l56_power_down_after_cal(cs35l56); + + return ret; +} + +static ssize_t cs35l56_debugfs_cal_data_read(struct file *file, + char __user *to, + size_t count, loff_t *ppos) +{ + struct cs35l56_base *cs35l56_base = file->private_data; + struct cs35l56_private *cs35l56 = cs35l56_private_from_base(cs35l56_base); + struct snd_soc_dapm_context *dapm; + ssize_t ret; + + dapm = cs35l56_power_up_for_cal(cs35l56); + if (IS_ERR(dapm)) + return PTR_ERR(dapm); + + ret = cs35l56_cal_data_debugfs_read(&cs35l56->base, to, count, ppos); + cs35l56_power_down_after_cal(cs35l56); + + return ret; +} + +static int cs35l56_new_cal_data_apply(struct cs35l56_private *cs35l56) +{ + struct snd_soc_dapm_context *dapm; + int ret; + + if (!cs35l56->base.cal_data_valid) + return -ENXIO; + + if (cs35l56->base.secured) + return -EACCES; + + dapm = cs35l56_power_up_for_cal(cs35l56); + if (IS_ERR(dapm)) + return PTR_ERR(dapm); + + snd_soc_dapm_mutex_lock(dapm); + ret = cs_amp_write_cal_coeffs(&cs35l56->dsp.cs_dsp, + cs35l56->base.calibration_controls, + &cs35l56->base.cal_data); + if (ret == 0) + cs35l56_mbox_send(&cs35l56->base, CS35L56_MBOX_CMD_AUDIO_REINIT); + else + ret = -EIO; + + snd_soc_dapm_mutex_unlock(dapm); + cs35l56_power_down_after_cal(cs35l56); + + return ret; +} + +static ssize_t cs35l56_debugfs_cal_data_write(struct file *file, + const char __user *from, + size_t count, loff_t *ppos) +{ + struct cs35l56_base *cs35l56_base = file->private_data; + struct cs35l56_private *cs35l56 = cs35l56_private_from_base(cs35l56_base); + int ret; + + ret = cs35l56_cal_data_debugfs_write(&cs35l56->base, from, count, ppos); + if (ret == -ENODATA) + return count; /* Ignore writes of empty cal blobs */ + else if (ret < 0) + return -EIO; + + ret = cs35l56_new_cal_data_apply(cs35l56); + if (ret) + return ret; + + return count; +} + +static const struct cs35l56_cal_debugfs_fops cs35l56_cal_debugfs_fops = { + .calibrate = { + .write = cs35l56_debugfs_calibrate_write, + }, + .cal_temperature = { + .write = cs35l56_debugfs_cal_temperature_write, + }, + .cal_data = { + .read = cs35l56_debugfs_cal_data_read, + .write = cs35l56_debugfs_cal_data_write, + }, +}; + +static int cs35l56_cal_data_rb_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); + + if (!cs35l56->base.cal_data_valid) + return -ENODATA; + + memcpy(ucontrol->value.bytes.data, &cs35l56->base.cal_data, + sizeof(cs35l56->base.cal_data)); + + return 0; +} + +static int cs35l56_cal_data_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); + + /* + * This control is write-only but mixer libraries often try to read + * a control before writing it. So we have to implement read. + * Return zeros so a write of valid data will always be a change + * from its "current value". + */ + memset(ucontrol->value.bytes.data, 0, sizeof(cs35l56->base.cal_data)); + + return 0; +} + +static int cs35l56_cal_data_ctl_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); + const struct cirrus_amp_cal_data *cal_data = (const void *)ucontrol->value.bytes.data; + int ret; + + if (cs35l56->base.cal_data_valid) + return -EACCES; + + ret = cs35l56_stash_calibration(&cs35l56->base, cal_data); + if (ret) + return ret; + + ret = cs35l56_new_cal_data_apply(cs35l56); + if (ret < 0) + return ret; + + return 1; +} + +static const struct snd_kcontrol_new cs35l56_cal_data_restore_controls[] = { + SND_SOC_BYTES_E("CAL_DATA", 0, sizeof(struct cirrus_amp_cal_data) / sizeof(u32), + cs35l56_cal_data_ctl_get, cs35l56_cal_data_ctl_set), + SND_SOC_BYTES_E_ACC("CAL_DATA_RB", 0, sizeof(struct cirrus_amp_cal_data) / sizeof(u32), + cs35l56_cal_data_rb_ctl_get, NULL, + SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE), +}; + static int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56) { if (cs35l56->dsp.fwf_suffix) @@ -904,6 +1137,7 @@ static int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56) static int cs35l56_component_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); struct dentry *debugfs_root = component->debugfs_root; unsigned short vendor, device; @@ -968,9 +1202,22 @@ static int cs35l56_component_probe(struct snd_soc_component *component) break; } + if (!ret && IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_SET_CTRL)) { + ret = snd_soc_add_component_controls(component, + cs35l56_cal_data_restore_controls, + ARRAY_SIZE(cs35l56_cal_data_restore_controls)); + } + if (ret) return dev_err_probe(cs35l56->base.dev, ret, "unable to add controls\n"); + ret = snd_soc_dapm_disable_pin(dapm, "Calibrate"); + if (ret) + return ret; + + if (IS_ENABLED(CONFIG_SND_SOC_CS35L56_CAL_DEBUGFS)) + cs35l56_create_cal_debugfs(&cs35l56->base, &cs35l56_cal_debugfs_fops); + queue_work(cs35l56->dsp_wq, &cs35l56->dsp_work); return 0; @@ -982,6 +1229,8 @@ static void cs35l56_component_remove(struct snd_soc_component *component) cancel_work_sync(&cs35l56->dsp_work); + cs35l56_remove_cal_debugfs(&cs35l56->base); + if (cs35l56->dsp.cs_dsp.booted) wm_adsp_power_down(&cs35l56->dsp); @@ -1000,6 +1249,7 @@ static int cs35l56_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_STANDBY: @@ -1007,7 +1257,7 @@ static int cs35l56_set_bias_level(struct snd_soc_component *component, * Wait for patching to complete when transitioning from * BIAS_OFF to BIAS_STANDBY */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) cs35l56_wait_dsp_ready(cs35l56); break; diff --git a/sound/soc/codecs/cs35l56.h b/sound/soc/codecs/cs35l56.h index 40a1800a4585..4c59f92f3206 100644 --- a/sound/soc/codecs/cs35l56.h +++ b/sound/soc/codecs/cs35l56.h @@ -10,6 +10,7 @@ #define CS35L56_H #include <linux/completion.h> +#include <linux/container_of.h> #include <linux/regulator/consumer.h> #include <linux/pm_runtime.h> #include <linux/workqueue.h> @@ -54,6 +55,11 @@ struct cs35l56_private { u8 sdw_unique_id; }; +static inline struct cs35l56_private *cs35l56_private_from_base(struct cs35l56_base *cs35l56_base) +{ + return container_of(cs35l56_base, struct cs35l56_private, base); +} + extern const struct dev_pm_ops cs35l56_pm_ops_i2c_spi; int cs35l56_system_suspend(struct device *dev); diff --git a/sound/soc/codecs/cs4234.c b/sound/soc/codecs/cs4234.c index dda7f5b4f2fb..89c424dd838b 100644 --- a/sound/soc/codecs/cs4234.c +++ b/sound/soc/codecs/cs4234.c @@ -85,9 +85,9 @@ static SOC_ENUM_SINGLE_DECL(cs4234_max_delay, CS4234_VOLUME_MODE, static int cs4234_dac14_grp_delay_put(struct snd_kcontrol *kctrl, struct snd_ctl_elem_value *uctrl) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kctrl); + struct snd_soc_component *component = snd_kcontrol_chip(kctrl); struct cs4234 *cs4234 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int val = 0; int ret = 0; @@ -126,10 +126,11 @@ static int cs4234_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct cs4234 *cs4234 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_PREPARE: - switch (snd_soc_component_get_bias_level(component)) { + switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_STANDBY: wait_for_completion(&cs4234->vq_ramp_complete); break; diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 9f9dc8b017a3..3139f03cd42b 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -433,7 +433,7 @@ static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute, int direction) static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); int left = !ucontrol->value.integer.value[0]; int right = !ucontrol->value.integer.value[1]; diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index ead447a5da7f..77dfc83a3c01 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -10,6 +10,7 @@ * DAPM support not implemented. */ +#include <linux/clk.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/delay.h> @@ -163,6 +164,7 @@ struct cs4271_private { /* enable soft reset workaround */ bool enable_soft_reset; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; + struct clk *clk; }; static const struct snd_soc_dapm_widget cs4271_dapm_widgets[] = { @@ -276,7 +278,7 @@ static int cs4271_set_deemph(struct snd_soc_component *component) static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = cs4271->deemph; @@ -286,7 +288,7 @@ static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, static int cs4271_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); cs4271->deemph = ucontrol->value.integer.value[0]; @@ -505,6 +507,7 @@ static int cs4271_soc_suspend(struct snd_soc_component *component) return ret; regcache_mark_dirty(cs4271->regmap); + clk_disable_unprepare(cs4271->clk); regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); return 0; @@ -522,6 +525,12 @@ static int cs4271_soc_resume(struct snd_soc_component *component) return ret; } + ret = clk_prepare_enable(cs4271->clk); + if (ret) { + dev_err(component->dev, "Failed to enable clk: %d\n", ret); + return ret; + } + /* Do a proper reset after power up */ cs4271_reset(component); @@ -576,22 +585,30 @@ static int cs4271_component_probe(struct snd_soc_component *component) cs4271->enable_soft_reset = cs4271plat->enable_soft_reset; } + ret = clk_prepare_enable(cs4271->clk); + if (ret) { + dev_err(component->dev, "Failed to enable clk: %d\n", ret); + goto err_disable_regulators; + } + /* Reset codec */ cs4271_reset(component); ret = regcache_sync(cs4271->regmap); if (ret < 0) - goto err_disable_regulator; + goto err_disable_clk; ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2, CS4271_MODE2_PDN | CS4271_MODE2_CPEN, CS4271_MODE2_PDN | CS4271_MODE2_CPEN); if (ret < 0) - goto err_disable_regulator; + goto err_disable_clk; + ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2, CS4271_MODE2_PDN, 0); if (ret < 0) - goto err_disable_regulator; + goto err_disable_clk; + /* Power-up sequence requires 85 uS */ udelay(85); @@ -602,7 +619,9 @@ static int cs4271_component_probe(struct snd_soc_component *component) return 0; -err_disable_regulator: +err_disable_clk: + clk_disable_unprepare(cs4271->clk); +err_disable_regulators: regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); return ret; } @@ -616,6 +635,7 @@ static void cs4271_component_remove(struct snd_soc_component *component) regcache_mark_dirty(cs4271->regmap); regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); + clk_disable_unprepare(cs4271->clk); }; static const struct snd_soc_component_driver soc_component_dev_cs4271 = { @@ -650,6 +670,10 @@ static int cs4271_common_probe(struct device *dev, "error retrieving RESET GPIO\n"); gpiod_set_consumer_name(cs4271->reset, "CS4271 Reset"); + cs4271->clk = devm_clk_get_optional(dev, "mclk"); + if (IS_ERR(cs4271->clk)) + return dev_err_probe(dev, PTR_ERR(cs4271->clk), "Failed to get mclk\n"); + for (i = 0; i < ARRAY_SIZE(supply_names); i++) cs4271->supplies[i].supply = supply_names[i]; diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index 78bb093fa0cc..2652a639a79a 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -403,7 +403,7 @@ static DECLARE_TLV_DB_SCALE(mixer_tlv, -6300, 100, true); static int cs42l42_slow_start_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 val; /* all bits of SLOW_START_EN must change together */ diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c index 867e23d4fb8d..b719d62635a0 100644 --- a/sound/soc/codecs/cs42l43-jack.c +++ b/sound/soc/codecs/cs42l43-jack.c @@ -300,7 +300,7 @@ irqreturn_t cs42l43_bias_detect_clamp(int irq, void *data) { struct cs42l43_codec *priv = data; - queue_delayed_work(system_wq, &priv->bias_sense_timeout, + queue_delayed_work(system_dfl_wq, &priv->bias_sense_timeout, msecs_to_jiffies(1000)); return IRQ_HANDLED; @@ -502,7 +502,7 @@ static void cs42l43_start_load_detect(struct cs42l43_codec *priv) dev_dbg(priv->dev, "Start load detect\n"); - snd_soc_dapm_mutex_lock(snd_soc_component_get_dapm(priv->component)); + snd_soc_dapm_mutex_lock(snd_soc_component_to_dapm(priv->component)); priv->load_detect_running = true; @@ -539,7 +539,7 @@ static void cs42l43_start_load_detect(struct cs42l43_codec *priv) CS42L43_HPLOAD_DET_EN_MASK, CS42L43_HPLOAD_DET_EN_MASK); - snd_soc_dapm_mutex_unlock(snd_soc_component_get_dapm(priv->component)); + snd_soc_dapm_mutex_unlock(snd_soc_component_to_dapm(priv->component)); } static void cs42l43_stop_load_detect(struct cs42l43_codec *priv) @@ -548,7 +548,7 @@ static void cs42l43_stop_load_detect(struct cs42l43_codec *priv) dev_dbg(priv->dev, "Stop load detect\n"); - snd_soc_dapm_mutex_lock(snd_soc_component_get_dapm(priv->component)); + snd_soc_dapm_mutex_lock(snd_soc_component_to_dapm(priv->component)); regmap_update_bits(cs42l43->regmap, CS42L43_LOADDETENA, CS42L43_HPLOAD_DET_EN_MASK, 0); @@ -587,7 +587,7 @@ static void cs42l43_stop_load_detect(struct cs42l43_codec *priv) priv->load_detect_running = false; - snd_soc_dapm_mutex_unlock(snd_soc_component_get_dapm(priv->component)); + snd_soc_dapm_mutex_unlock(snd_soc_component_to_dapm(priv->component)); } static int cs42l43_run_load_detect(struct cs42l43_codec *priv, bool mic) @@ -866,7 +866,7 @@ SOC_ENUM_SINGLE_VIRT_DECL(cs42l43_jack_enum, cs42l43_jack_text); int cs42l43_jack_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); mutex_lock(&priv->jack_lock); @@ -878,7 +878,7 @@ int cs42l43_jack_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *u int cs42l43_jack_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); struct cs42l43 *cs42l43 = priv->core; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c index b61df09f20cf..fd02d8a57e0f 100644 --- a/sound/soc/codecs/cs42l43.c +++ b/sound/soc/codecs/cs42l43.c @@ -154,14 +154,14 @@ static void cs42l43_hp_ilimit_clear_work(struct work_struct *work) { struct cs42l43_codec *priv = container_of(work, struct cs42l43_codec, hp_ilimit_clear_work.work); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(priv->component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(priv->component); snd_soc_dapm_mutex_lock(dapm); priv->hp_ilimit_count--; if (priv->hp_ilimit_count) - queue_delayed_work(system_wq, &priv->hp_ilimit_clear_work, + queue_delayed_work(system_dfl_wq, &priv->hp_ilimit_clear_work, msecs_to_jiffies(CS42L43_HP_ILIMIT_DECAY_MS)); snd_soc_dapm_mutex_unlock(dapm); @@ -170,7 +170,7 @@ static void cs42l43_hp_ilimit_clear_work(struct work_struct *work) static irqreturn_t cs42l43_hp_ilimit(int irq, void *data) { struct cs42l43_codec *priv = data; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(priv->component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(priv->component); struct cs42l43 *cs42l43 = priv->core; dev_dbg(priv->dev, "headphone ilimit IRQ\n"); @@ -179,7 +179,7 @@ static irqreturn_t cs42l43_hp_ilimit(int irq, void *data) if (priv->hp_ilimit_count < CS42L43_HP_ILIMIT_MAX_COUNT) { if (!priv->hp_ilimit_count) - queue_delayed_work(system_wq, &priv->hp_ilimit_clear_work, + queue_delayed_work(system_dfl_wq, &priv->hp_ilimit_clear_work, msecs_to_jiffies(CS42L43_HP_ILIMIT_DECAY_MS)); priv->hp_ilimit_count++; @@ -451,7 +451,7 @@ static int cs42l43_asp_hw_params(struct snd_pcm_substream *substream, static int cs42l43_asp_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct snd_soc_component *component = dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); struct cs42l43 *cs42l43 = priv->core; int provider = regmap_test_bits(cs42l43->regmap, CS42L43_ASP_CLK_CONFIG2, @@ -949,8 +949,8 @@ CS42L43_DECL_MIXER(amp4, CS42L43_AMP4MIX_INPUT1); static int cs42l43_dapm_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; snd_soc_dapm_mutex_lock(dapm); @@ -963,8 +963,8 @@ static int cs42l43_dapm_get_volsw(struct snd_kcontrol *kcontrol, static int cs42l43_dapm_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; snd_soc_dapm_mutex_lock(dapm); @@ -977,8 +977,8 @@ static int cs42l43_dapm_put_volsw(struct snd_kcontrol *kcontrol, static int cs42l43_dapm_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; snd_soc_dapm_mutex_lock(dapm); @@ -991,8 +991,8 @@ static int cs42l43_dapm_get_enum(struct snd_kcontrol *kcontrol, static int cs42l43_dapm_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; snd_soc_dapm_mutex_lock(dapm); @@ -1005,7 +1005,7 @@ static int cs42l43_dapm_put_enum(struct snd_kcontrol *kcontrol, static int cs42l43_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); memcpy(ucontrol->value.integer.value, priv->eq_coeffs, sizeof(priv->eq_coeffs)); @@ -1016,8 +1016,8 @@ static int cs42l43_eq_get(struct snd_kcontrol *kcontrol, static int cs42l43_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); snd_soc_dapm_mutex_lock(dapm); @@ -1088,7 +1088,7 @@ error: static int cs42l43_decim_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); int ret; @@ -1104,7 +1104,7 @@ static int cs42l43_decim_get(struct snd_kcontrol *kcontrol, static int cs42l43_spk_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); int ret; @@ -1120,7 +1120,7 @@ static int cs42l43_spk_get(struct snd_kcontrol *kcontrol, static int cs42l43_spk_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); int ret; diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 8083a339dc7b..0519affe0ed8 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -57,7 +57,7 @@ struct cs42l51_private { static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned long value = snd_soc_component_read(component, CS42L51_PCM_MIXER)&3; switch (value) { @@ -85,7 +85,7 @@ static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned char val; switch (ucontrol->value.enumerated.item[0]) { @@ -567,7 +567,7 @@ static int cs42l51_component_probe(struct snd_soc_component *component) struct cs42l51_private *cs42l51; cs42l51 = snd_soc_component_get_drvdata(component); - dapm = snd_soc_component_get_dapm(component); + dapm = snd_soc_component_to_dapm(component); if (cs42l51->mclk_handle) snd_soc_dapm_new_controls(dapm, cs42l51_dapm_mclk_widgets, 1); diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c index a9ffba62aaf8..662dc1a4835b 100644 --- a/sound/soc/codecs/cs42l52.c +++ b/sound/soc/codecs/cs42l52.c @@ -851,6 +851,7 @@ static int cs42l52_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -860,7 +861,7 @@ static int cs42l52_set_bias_level(struct snd_soc_component *component, CS42L52_PWRCTL1_PDN_CODEC, 0); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_cache_only(cs42l52->regmap, false); regcache_sync(cs42l52->regmap); } @@ -919,7 +920,7 @@ static void cs42l52_beep_work(struct work_struct *work) struct cs42l52_private *cs42l52 = container_of(work, struct cs42l52_private, beep_work); struct snd_soc_component *component = cs42l52->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int i; int val = 0; int best = 0; diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c index 98fa812bc07b..aabb74f1f43c 100644 --- a/sound/soc/codecs/cs42l56.c +++ b/sound/soc/codecs/cs42l56.c @@ -911,6 +911,7 @@ static int cs42l56_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct cs42l56_private *cs42l56 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -923,7 +924,7 @@ static int cs42l56_set_bias_level(struct snd_soc_component *component, CS42L56_PDN_ALL_MASK, 0); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_cache_only(cs42l56->regmap, false); regcache_sync(cs42l56->regmap); ret = regulator_bulk_enable(ARRAY_SIZE(cs42l56->supplies), @@ -996,7 +997,7 @@ static void cs42l56_beep_work(struct work_struct *work) struct cs42l56_private *cs42l56 = container_of(work, struct cs42l56_private, beep_work); struct snd_soc_component *component = cs42l56->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int i; int val = 0; int best = 0; diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c index 535a867f9f2a..bda8442c1d66 100644 --- a/sound/soc/codecs/cs42l73.c +++ b/sound/soc/codecs/cs42l73.c @@ -1101,6 +1101,7 @@ static int cs42l73_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct cs42l73_private *cs42l73 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -1112,7 +1113,7 @@ static int cs42l73_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_cache_only(cs42l73->regmap, false); regcache_sync(cs42l73->regmap); } diff --git a/sound/soc/codecs/cs42l84.c b/sound/soc/codecs/cs42l84.c index 88cf3c03986e..1e1307a16f81 100644 --- a/sound/soc/codecs/cs42l84.c +++ b/sound/soc/codecs/cs42l84.c @@ -84,7 +84,7 @@ static const struct regmap_config cs42l84_regmap = { static int cs42l84_put_dac_vol(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *val) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kctl); + struct snd_soc_component *component = snd_kcontrol_chip(kctl); struct soc_mixer_control *mc = (struct soc_mixer_control *) kctl->private_value; int vola, volb; int ret, ret2, updated = 0; @@ -138,7 +138,7 @@ bail: static int cs42l84_get_dac_vol(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *val) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kctl); + struct snd_soc_component *component = snd_kcontrol_chip(kctl); struct soc_mixer_control *mc = (struct soc_mixer_control *) kctl->private_value; int vola, volb; int ret; diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c index 6a925f3f7137..d14538c49b97 100644 --- a/sound/soc/codecs/cs42xx8.c +++ b/sound/soc/codecs/cs42xx8.c @@ -465,7 +465,7 @@ EXPORT_SYMBOL_GPL(cs42xx8_regmap_config); static int cs42xx8_component_probe(struct snd_soc_component *component) { struct cs42xx8_priv *cs42xx8 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (cs42xx8->drvdata->num_adcs) { case 3: diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c index d9b3d73c8388..a3bdaac9c059 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -1062,7 +1062,7 @@ static int cs43130_pcm_ch_put(struct snd_kcontrol *kcontrol, { struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); unsigned int val; diff --git a/sound/soc/codecs/cs47l15.c b/sound/soc/codecs/cs47l15.c index 29a2bcfb3048..da64e0a1db28 100644 --- a/sound/soc/codecs/cs47l15.c +++ b/sound/soc/codecs/cs47l15.c @@ -106,8 +106,7 @@ static int cs47l15_adsp_power_ev(struct snd_soc_dapm_widget *w, static int cs47l15_in1_adc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = !!cs47l15->in1_lp_mode; @@ -118,8 +117,7 @@ static int cs47l15_in1_adc_get(struct snd_kcontrol *kcontrol, static int cs47l15_in1_adc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component); if (!!ucontrol->value.integer.value[0] == cs47l15->in1_lp_mode) @@ -1280,6 +1278,7 @@ static const struct snd_soc_dapm_route cs47l15_mono_routes[] = { static int cs47l15_component_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component); struct madera *madera = cs47l15->core.madera; int ret; @@ -1287,7 +1286,7 @@ static int cs47l15_component_probe(struct snd_soc_component *component) snd_soc_component_init_regmap(component, madera->regmap); mutex_lock(&madera->dapm_ptr_lock); - madera->dapm = snd_soc_component_get_dapm(component); + madera->dapm = snd_soc_component_to_dapm(component); mutex_unlock(&madera->dapm_ptr_lock); ret = madera_init_inputs(component); @@ -1300,7 +1299,7 @@ static int cs47l15_component_probe(struct snd_soc_component *component) if (ret) return ret; - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); ret = snd_soc_add_component_controls(component, madera_adsp_rate_controls, diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index e2a839fae4fc..5100b1aac902 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -1124,7 +1124,7 @@ static irqreturn_t cs47l24_adsp2_irq(int irq, void *data) static int cs47l24_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int ret; @@ -1153,7 +1153,7 @@ static int cs47l24_component_probe(struct snd_soc_component *component) if (ret) goto err_adsp2_codec_probe; - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); return 0; diff --git a/sound/soc/codecs/cs47l35.c b/sound/soc/codecs/cs47l35.c index 85555c7a2e4b..a8fe5a99a8bb 100644 --- a/sound/soc/codecs/cs47l35.c +++ b/sound/soc/codecs/cs47l35.c @@ -1559,6 +1559,7 @@ static const struct snd_soc_dapm_route cs47l35_mono_routes[] = { static int cs47l35_component_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); struct madera *madera = cs47l35->core.madera; int i, ret; @@ -1566,7 +1567,7 @@ static int cs47l35_component_probe(struct snd_soc_component *component) snd_soc_component_init_regmap(component, madera->regmap); mutex_lock(&madera->dapm_ptr_lock); - madera->dapm = snd_soc_component_get_dapm(component); + madera->dapm = snd_soc_component_to_dapm(component); mutex_unlock(&madera->dapm_ptr_lock); ret = madera_init_inputs(component); @@ -1579,7 +1580,7 @@ static int cs47l35_component_probe(struct snd_soc_component *component) if (ret) return ret; - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); ret = snd_soc_add_component_controls(component, madera_adsp_rate_controls, diff --git a/sound/soc/codecs/cs47l85.c b/sound/soc/codecs/cs47l85.c index d34f4e8c26d3..42fafb0b392c 100644 --- a/sound/soc/codecs/cs47l85.c +++ b/sound/soc/codecs/cs47l85.c @@ -2497,6 +2497,7 @@ static irqreturn_t cs47l85_adsp2_irq(int irq, void *data) static int cs47l85_component_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs47l85 *cs47l85 = snd_soc_component_get_drvdata(component); struct madera *madera = cs47l85->core.madera; int i, ret; @@ -2504,7 +2505,7 @@ static int cs47l85_component_probe(struct snd_soc_component *component) snd_soc_component_init_regmap(component, madera->regmap); mutex_lock(&madera->dapm_ptr_lock); - madera->dapm = snd_soc_component_get_dapm(component); + madera->dapm = snd_soc_component_to_dapm(component); mutex_unlock(&madera->dapm_ptr_lock); ret = madera_init_inputs(component); @@ -2516,7 +2517,7 @@ static int cs47l85_component_probe(struct snd_soc_component *component) if (ret) return ret; - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); ret = snd_soc_add_component_controls(component, madera_adsp_rate_controls, diff --git a/sound/soc/codecs/cs47l90.c b/sound/soc/codecs/cs47l90.c index a9e703981f37..77e8aabb241a 100644 --- a/sound/soc/codecs/cs47l90.c +++ b/sound/soc/codecs/cs47l90.c @@ -2416,6 +2416,7 @@ static irqreturn_t cs47l90_adsp2_irq(int irq, void *data) static int cs47l90_component_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs47l90 *cs47l90 = snd_soc_component_get_drvdata(component); struct madera *madera = cs47l90->core.madera; int ret, i; @@ -2423,7 +2424,7 @@ static int cs47l90_component_probe(struct snd_soc_component *component) snd_soc_component_init_regmap(component, madera->regmap); mutex_lock(&madera->dapm_ptr_lock); - madera->dapm = snd_soc_component_get_dapm(component); + madera->dapm = snd_soc_component_to_dapm(component); mutex_unlock(&madera->dapm_ptr_lock); ret = madera_init_inputs(component); @@ -2435,7 +2436,7 @@ static int cs47l90_component_probe(struct snd_soc_component *component) if (ret) return ret; - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); ret = snd_soc_add_component_controls(component, madera_adsp_rate_controls, diff --git a/sound/soc/codecs/cs47l92.c b/sound/soc/codecs/cs47l92.c index 2c355c61acd8..868237bd6d91 100644 --- a/sound/soc/codecs/cs47l92.c +++ b/sound/soc/codecs/cs47l92.c @@ -52,10 +52,8 @@ static const char * const cs47l92_outdemux_texts[] = { static int cs47l92_put_demux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs47l92 *cs47l92 = snd_soc_component_get_drvdata(component); struct madera_priv *priv = &cs47l92->core; struct madera *madera = priv->madera; @@ -1887,6 +1885,7 @@ static const struct snd_soc_dapm_route cs47l92_mono_routes[] = { static int cs47l92_component_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs47l92 *cs47l92 = snd_soc_component_get_drvdata(component); struct madera *madera = cs47l92->core.madera; int ret; @@ -1894,7 +1893,7 @@ static int cs47l92_component_probe(struct snd_soc_component *component) snd_soc_component_init_regmap(component, madera->regmap); mutex_lock(&madera->dapm_ptr_lock); - madera->dapm = snd_soc_component_get_dapm(component); + madera->dapm = snd_soc_component_to_dapm(component); mutex_unlock(&madera->dapm_ptr_lock); ret = madera_init_inputs(component); @@ -1907,7 +1906,7 @@ static int cs47l92_component_probe(struct snd_soc_component *component) if (ret) return ret; - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); ret = snd_soc_add_component_controls(component, madera_adsp_rate_controls, diff --git a/sound/soc/codecs/cs48l32.c b/sound/soc/codecs/cs48l32.c index a306af4289ad..086ed0f57a85 100644 --- a/sound/soc/codecs/cs48l32.c +++ b/sound/soc/codecs/cs48l32.c @@ -231,7 +231,7 @@ static_assert(ARRAY_SIZE(cs48l32_rate_val) == ARRAY_SIZE(cs48l32_rate_text)); static int cs48l32_rate_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); int ret; @@ -320,8 +320,8 @@ static const struct soc_enum cs48l32_sample_rate[] = { static int cs48l32_inmux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *) kcontrol->private_value; unsigned int mux, src_val, in_type; @@ -347,7 +347,7 @@ static int cs48l32_inmux_put(struct snd_kcontrol *kcontrol, if (in_type == CS48L32_IN_TYPE_SE) src_val |= 1 << CS48L32_INx_SRC_SHIFT; - ret = snd_soc_component_update_bits(dapm->component, + ret = snd_soc_component_update_bits(component, e->reg, CS48L32_INx_SRC_MASK, src_val); @@ -385,7 +385,7 @@ static const char * const cs48l32_dmode_texts[] = { static int cs48l32_dmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); struct soc_enum *e = (struct soc_enum *) kcontrol->private_value; unsigned int mode; @@ -704,8 +704,8 @@ static bool cs48l32_is_input_enabled(struct snd_soc_component *component, static int cs48l32_in_rate_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int ret; @@ -755,8 +755,8 @@ static int cs48l32_low_power_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; snd_soc_dapm_mutex_lock(dapm); @@ -912,7 +912,7 @@ static const struct soc_enum cs48l32_lhpf_mode[] = { static int cs48l32_lhpf_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); __be32 *data = (__be32 *)ucontrol->value.bytes.data; s16 val = (s16)be32_to_cpu(*data); @@ -947,7 +947,7 @@ static const struct soc_enum cs48l32_eq_mode[] = { static int cs48l32_eq_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *) kcontrol->private_value; unsigned int item; @@ -961,8 +961,8 @@ static int cs48l32_eq_mode_get(struct snd_kcontrol *kcontrol, static int cs48l32_eq_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *) kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; @@ -1000,7 +1000,7 @@ static int cs48l32_eq_coeff_info(struct snd_kcontrol *kcontrol, static int cs48l32_eq_coeff_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); struct cs48l32_eq_control *params = (void *)kcontrol->private_value; __be16 *coeffs; @@ -1025,8 +1025,8 @@ static int cs48l32_eq_coeff_get(struct snd_kcontrol *kcontrol, static int cs48l32_eq_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); struct cs48l32_eq_control *params = (void *)kcontrol->private_value; __be16 *coeffs; @@ -1062,7 +1062,7 @@ static const struct snd_kcontrol_new cs48l32_dsp_trigger_output_mux[] = { static int cs48l32_dsp_rate_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *) kcontrol->private_value; unsigned int cached_rate; @@ -1082,8 +1082,8 @@ static int cs48l32_dsp_rate_get(struct snd_kcontrol *kcontrol, static int cs48l32_dsp_rate_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *) kcontrol->private_value; const unsigned int rate_num = e->mask; @@ -2465,7 +2465,7 @@ static int cs48l32_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kco static int cs48l32_in_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct cs48l32_codec *cs48l32_codec = snd_soc_component_get_drvdata(component); int ret; diff --git a/sound/soc/codecs/cs530x-i2c.c b/sound/soc/codecs/cs530x-i2c.c index 22b1a4d6b61c..52b02ceaa7e3 100644 --- a/sound/soc/codecs/cs530x-i2c.c +++ b/sound/soc/codecs/cs530x-i2c.c @@ -2,8 +2,8 @@ // // CS530x CODEC driver // -// Copyright (C) 2024 Cirrus Logic, Inc. and -// Cirrus Logic International Semiconductor Ltd. +// Copyright (C) 2024-2025 Cirrus Logic, Inc. and +// Cirrus Logic International Semiconductor Ltd. #include <linux/device.h> #include <linux/module.h> @@ -14,6 +14,18 @@ static const struct of_device_id cs530x_of_match[] = { { + .compatible = "cirrus,cs4282", + .data = (void *)CS4282, + }, { + .compatible = "cirrus,cs4302", + .data = (void *)CS4302, + }, { + .compatible = "cirrus,cs4304", + .data = (void *)CS4304, + }, { + .compatible = "cirrus,cs4308", + .data = (void *)CS4308, + }, { .compatible = "cirrus,cs5302", .data = (void *)CS5302, }, { @@ -28,6 +40,10 @@ static const struct of_device_id cs530x_of_match[] = { MODULE_DEVICE_TABLE(of, cs530x_of_match); static const struct i2c_device_id cs530x_i2c_id[] = { + { "cs4282", CS4282 }, + { "cs4302", CS4302 }, + { "cs4304", CS4304 }, + { "cs4308", CS4308 }, { "cs5302", CS5302 }, { "cs5304", CS5304 }, { "cs5308", CS5308 }, @@ -45,10 +61,10 @@ static int cs530x_i2c_probe(struct i2c_client *client) i2c_set_clientdata(client, cs530x); - cs530x->regmap = devm_regmap_init_i2c(client, &cs530x_regmap); + cs530x->regmap = devm_regmap_init_i2c(client, &cs530x_regmap_i2c); if (IS_ERR(cs530x->regmap)) return dev_err_probe(&client->dev, PTR_ERR(cs530x->regmap), - "Failed to allocate register map\n"); + "Failed to allocate register map\n"); cs530x->devtype = (uintptr_t)i2c_get_match_data(client); cs530x->dev = &client->dev; diff --git a/sound/soc/codecs/cs530x-spi.c b/sound/soc/codecs/cs530x-spi.c new file mode 100644 index 000000000000..dbf1e7bbec19 --- /dev/null +++ b/sound/soc/codecs/cs530x-spi.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// CS530x CODEC driver +// +// Copyright (C) 2025 Cirrus Logic, Inc. and +// Cirrus Logic International Semiconductor Ltd. + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/spi/spi.h> + +#include "cs530x.h" + +static const struct of_device_id cs530x_of_match[] = { + { + .compatible = "cirrus,cs4282", + .data = (void *)CS4282, + }, { + .compatible = "cirrus,cs4302", + .data = (void *)CS4302, + }, { + .compatible = "cirrus,cs4304", + .data = (void *)CS4304, + }, { + .compatible = "cirrus,cs4308", + .data = (void *)CS4308, + }, { + .compatible = "cirrus,cs5302", + .data = (void *)CS5302, + }, { + .compatible = "cirrus,cs5304", + .data = (void *)CS5304, + }, { + .compatible = "cirrus,cs5304", + .data = (void *)CS5308, + }, + {} +}; +MODULE_DEVICE_TABLE(of, cs530x_of_match); + +static const struct spi_device_id cs530x_spi_id[] = { + { "cs4282", CS4282 }, + { "cs4302", CS4302 }, + { "cs4304", CS4304 }, + { "cs4308", CS4308 }, + { "cs5302", CS5302 }, + { "cs5304", CS5304 }, + { "cs5308", CS5308 }, + { } +}; +MODULE_DEVICE_TABLE(spi, cs530x_spi_id); + +static int cs530x_spi_probe(struct spi_device *spi) +{ + struct cs530x_priv *cs530x; + struct device *dev = &spi->dev; + int ret; + + cs530x = devm_kzalloc(dev, sizeof(struct cs530x_priv), GFP_KERNEL); + if (cs530x == NULL) + return -ENOMEM; + + spi_set_drvdata(spi, cs530x); + + cs530x->regmap = devm_regmap_init_spi(spi, &cs530x_regmap_spi); + if (IS_ERR(cs530x->regmap)) { + ret = PTR_ERR(cs530x->regmap); + dev_err(dev, "Failed to allocate register map: %d\n", ret); + return ret; + } + + cs530x->devtype = (unsigned long)spi_get_device_match_data(spi); + cs530x->dev = &spi->dev; + + return cs530x_probe(cs530x); +} + +static struct spi_driver cs530x_spi_driver = { + .driver = { + .name = "cs530x", + .of_match_table = cs530x_of_match, + }, + .id_table = cs530x_spi_id, + .probe = cs530x_spi_probe, +}; + +module_spi_driver(cs530x_spi_driver); + +MODULE_DESCRIPTION("SPI CS530X driver"); +MODULE_IMPORT_NS("SND_SOC_CS530X"); +MODULE_AUTHOR("Vitaly Rodionov <vitalyr@opensource.cirrus.com>"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/cs530x.c b/sound/soc/codecs/cs530x.c index 535387cd7aa3..18b5ff75feec 100644 --- a/sound/soc/codecs/cs530x.c +++ b/sound/soc/codecs/cs530x.c @@ -2,28 +2,26 @@ // // CS530x CODEC driver // -// Copyright (C) 2024 Cirrus Logic, Inc. and -// Cirrus Logic International Semiconductor Ltd. +// Copyright (C) 2024-2025 Cirrus Logic, Inc. and +// Cirrus Logic International Semiconductor Ltd. -#include <sound/core.h> #include <linux/delay.h> #include <linux/i2c.h> #include <linux/init.h> -#include <sound/initval.h> #include <linux/module.h> -#include <sound/pcm.h> -#include <sound/pcm_params.h> #include <linux/pm.h> #include <linux/property.h> #include <linux/slab.h> +#include <linux/spi/spi.h> +#include <sound/core.h> +#include <sound/initval.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/tlv.h> #include "cs530x.h" -#define CS530X_MAX_ADC_CH 8 -#define CS530X_MIN_ADC_CH 2 - static const char *cs530x_supply_names[CS530X_NUM_SUPPLIES] = { "vdd-a", "vdd-io", @@ -48,6 +46,18 @@ static const struct reg_default cs530x_reg_defaults[] = { { CS530X_IN_VOL_CTRL3_1, 0x8000 }, { CS530X_IN_VOL_CTRL4_0, 0x8000 }, { CS530X_IN_VOL_CTRL4_1, 0x8000 }, + { CS530X_OUT_ENABLES, 0 }, + { CS530X_OUT_RAMP_SUM, 0x0022 }, + { CS530X_OUT_FILTER, 0 }, + { CS530X_OUT_INV, 0 }, + { CS530X_OUT_VOL_CTRL1_0, 0x8000 }, + { CS530X_OUT_VOL_CTRL1_1, 0x8000 }, + { CS530X_OUT_VOL_CTRL2_0, 0x8000 }, + { CS530X_OUT_VOL_CTRL2_1, 0x8000 }, + { CS530X_OUT_VOL_CTRL3_0, 0x8000 }, + { CS530X_OUT_VOL_CTRL3_1, 0x8000 }, + { CS530X_OUT_VOL_CTRL4_0, 0x8000 }, + { CS530X_OUT_VOL_CTRL4_1, 0x8000 }, { CS530X_PAD_FN, 0 }, { CS530X_PAD_LVL, 0 }, }; @@ -73,6 +83,19 @@ static bool cs530x_read_and_write_regs(unsigned int reg) case CS530X_IN_VOL_CTRL3_1: case CS530X_IN_VOL_CTRL4_0: case CS530X_IN_VOL_CTRL4_1: + case CS530X_OUT_ENABLES: + case CS530X_OUT_RAMP_SUM: + case CS530X_OUT_DEEMPH: + case CS530X_OUT_FILTER: + case CS530X_OUT_INV: + case CS530X_OUT_VOL_CTRL1_0: + case CS530X_OUT_VOL_CTRL1_1: + case CS530X_OUT_VOL_CTRL2_0: + case CS530X_OUT_VOL_CTRL2_1: + case CS530X_OUT_VOL_CTRL3_0: + case CS530X_OUT_VOL_CTRL3_1: + case CS530X_OUT_VOL_CTRL4_0: + case CS530X_OUT_VOL_CTRL4_1: case CS530X_PAD_FN: case CS530X_PAD_LVL: return true; @@ -97,6 +120,7 @@ static bool cs530x_writeable_register(struct device *dev, unsigned int reg) switch (reg) { case CS530X_SW_RESET: case CS530X_IN_VOL_CTRL5: + case CS530X_OUT_VOL_CTRL5: return true; default: return cs530x_read_and_write_regs(reg); @@ -104,10 +128,10 @@ static bool cs530x_writeable_register(struct device *dev, unsigned int reg) } static int cs530x_put_volsw_vu(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) + struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); struct regmap *regmap = cs530x->regmap; int ret; @@ -118,8 +142,8 @@ static int cs530x_put_volsw_vu(struct snd_kcontrol *kcontrol, if (ret) goto volsw_err; - /* Write IN_VU bit for the volume change to take effect */ - regmap_write(regmap, CS530X_IN_VOL_CTRL5, CS530X_IN_VU); + /* Write INOUT_VU bit for the volume change to take effect */ + regmap_write(regmap, CS530X_IN_VOL_CTRL5, CS530X_INOUT_VU); volsw_err: snd_soc_dapm_mutex_unlock(dapm); @@ -129,7 +153,7 @@ volsw_err: static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1270, 50, 0); -static const char * const cs530x_in_filter_text[] = { +static const char * const cs530x_inout_filter_text[] = { "Min Phase Slow Roll-off", "Min Phase Fast Roll-off", "Linear Phase Slow Roll-off", @@ -137,24 +161,36 @@ static const char * const cs530x_in_filter_text[] = { }; static SOC_ENUM_SINGLE_DECL(cs530x_in_filter_enum, CS530X_IN_FILTER, - CS530X_IN_FILTER_SHIFT, - cs530x_in_filter_text); + CS530X_INOUT_FILTER_SHIFT, + cs530x_inout_filter_text); -static const char * const cs530x_in_4ch_sum_text[] = { +static SOC_ENUM_SINGLE_DECL(cs530x_out_filter_enum, CS530X_OUT_FILTER, + CS530X_INOUT_FILTER_SHIFT, + cs530x_inout_filter_text); + +static const char * const cs530x_4ch_sum_text[] = { "None", "Groups of 2", "Groups of 4", }; static SOC_ENUM_SINGLE_DECL(cs530x_in_sum_ch4_enum, CS530X_IN_RAMP_SUM, - CS530X_IN_SUM_MODE_SHIFT, - cs530x_in_4ch_sum_text); + CS530X_INOUT_SUM_MODE_SHIFT, + cs530x_4ch_sum_text); static const struct snd_kcontrol_new cs530x_in_sum_4ch_controls[] = { SOC_ENUM("IN Sum Select", cs530x_in_sum_ch4_enum), }; -static const char * const cs530x_in_8ch_sum_text[] = { +static SOC_ENUM_SINGLE_DECL(cs530x_out_sum_ch4_enum, CS530X_OUT_RAMP_SUM, + CS530X_INOUT_SUM_MODE_SHIFT, + cs530x_4ch_sum_text); + +static const struct snd_kcontrol_new cs530x_out_sum_4ch_controls[] = { +SOC_ENUM("OUT Sum Select", cs530x_out_sum_ch4_enum), +}; + +static const char * const cs530x_8ch_sum_text[] = { "None", "Groups of 2", "Groups of 4", @@ -162,13 +198,20 @@ static const char * const cs530x_in_8ch_sum_text[] = { }; static SOC_ENUM_SINGLE_DECL(cs530x_in_sum_ch8_enum, CS530X_IN_RAMP_SUM, - CS530X_IN_SUM_MODE_SHIFT, - cs530x_in_8ch_sum_text); + CS530X_INOUT_SUM_MODE_SHIFT, + cs530x_8ch_sum_text); static const struct snd_kcontrol_new cs530x_in_sum_8ch_controls[] = { SOC_ENUM("IN Sum Select", cs530x_in_sum_ch8_enum), }; +static SOC_ENUM_SINGLE_DECL(cs530x_out_sum_ch8_enum, CS530X_OUT_RAMP_SUM, + CS530X_INOUT_SUM_MODE_SHIFT, + cs530x_8ch_sum_text); + +static const struct snd_kcontrol_new cs530x_out_sum_8ch_controls[] = { +SOC_ENUM("OUT Sum Select", cs530x_out_sum_ch8_enum), +}; static const char * const cs530x_vol_ramp_text[] = { "0ms/6dB", "0.5ms/6dB", "1ms/6dB", "2ms/6dB", "4ms/6dB", "8ms/6dB", @@ -193,8 +236,8 @@ SOC_ENUM("IN DEC Filter Select", cs530x_in_filter_enum), SOC_ENUM("Input Ramp Up", cs530x_ramp_inc_enum), SOC_ENUM("Input Ramp Down", cs530x_ramp_dec_enum), -SOC_SINGLE("ADC1 Invert Switch", CS530X_IN_INV, CS530X_IN1_INV_SHIFT, 1, 0), -SOC_SINGLE("ADC2 Invert Switch", CS530X_IN_INV, CS530X_IN2_INV_SHIFT, 1, 0), +SOC_SINGLE("ADC1 Invert Switch", CS530X_IN_INV, CS530X_INOUT1_INV_SHIFT, 1, 0), +SOC_SINGLE("ADC2 Invert Switch", CS530X_IN_INV, CS530X_INOUT2_INV_SHIFT, 1, 0), }; static const struct snd_kcontrol_new cs530x_in_3_to_4_controls[] = { @@ -203,8 +246,8 @@ SOC_SINGLE_EXT_TLV("IN3 Volume", CS530X_IN_VOL_CTRL2_0, 0, 255, 1, SOC_SINGLE_EXT_TLV("IN4 Volume", CS530X_IN_VOL_CTRL2_1, 0, 255, 1, snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), -SOC_SINGLE("ADC3 Invert Switch", CS530X_IN_INV, CS530X_IN3_INV_SHIFT, 1, 0), -SOC_SINGLE("ADC4 Invert Switch", CS530X_IN_INV, CS530X_IN4_INV_SHIFT, 1, 0), +SOC_SINGLE("ADC3 Invert Switch", CS530X_IN_INV, CS530X_INOUT3_INV_SHIFT, 1, 0), +SOC_SINGLE("ADC4 Invert Switch", CS530X_IN_INV, CS530X_INOUT4_INV_SHIFT, 1, 0), }; static const struct snd_kcontrol_new cs530x_in_5_to_8_controls[] = { @@ -217,14 +260,14 @@ SOC_SINGLE_EXT_TLV("IN7 Volume", CS530X_IN_VOL_CTRL4_0, 0, 255, 1, SOC_SINGLE_EXT_TLV("IN8 Volume", CS530X_IN_VOL_CTRL4_1, 0, 255, 1, snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), -SOC_SINGLE("ADC5 Invert Switch", CS530X_IN_INV, CS530X_IN5_INV_SHIFT, 1, 0), -SOC_SINGLE("ADC6 Invert Switch", CS530X_IN_INV, CS530X_IN6_INV_SHIFT, 1, 0), -SOC_SINGLE("ADC7 Invert Switch", CS530X_IN_INV, CS530X_IN7_INV_SHIFT, 1, 0), -SOC_SINGLE("ADC8 Invert Switch", CS530X_IN_INV, CS530X_IN8_INV_SHIFT, 1, 0), +SOC_SINGLE("ADC5 Invert Switch", CS530X_IN_INV, CS530X_INOUT5_INV_SHIFT, 1, 0), +SOC_SINGLE("ADC6 Invert Switch", CS530X_IN_INV, CS530X_INOUT6_INV_SHIFT, 1, 0), +SOC_SINGLE("ADC7 Invert Switch", CS530X_IN_INV, CS530X_INOUT7_INV_SHIFT, 1, 0), +SOC_SINGLE("ADC8 Invert Switch", CS530X_IN_INV, CS530X_INOUT8_INV_SHIFT, 1, 0), }; static int cs530x_adc_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) + struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); @@ -236,24 +279,110 @@ static int cs530x_adc_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMU: regmap_clear_bits(regmap, CS530X_IN_VOL_CTRL1_0 + - (w->shift * 2), CS530X_IN_MUTE); + (w->shift * 2), CS530X_INOUT_MUTE); regmap_clear_bits(regmap, CS530X_IN_VOL_CTRL1_0 + - ((w->shift+1) * 2), CS530X_IN_MUTE); + ((w->shift + 1) * 2), CS530X_INOUT_MUTE); cs530x->adc_pairs_count--; if (!cs530x->adc_pairs_count) { usleep_range(1000, 1100); return regmap_write(regmap, CS530X_IN_VOL_CTRL5, - CS530X_IN_VU); + CS530X_INOUT_VU); } break; case SND_SOC_DAPM_PRE_PMD: regmap_set_bits(regmap, CS530X_IN_VOL_CTRL1_0 + - (w->shift * 2), CS530X_IN_MUTE); + (w->shift * 2), CS530X_INOUT_MUTE); regmap_set_bits(regmap, CS530X_IN_VOL_CTRL1_0 + - ((w->shift+1) * 2), CS530X_IN_MUTE); + ((w->shift + 1) * 2), CS530X_INOUT_MUTE); return regmap_write(regmap, CS530X_IN_VOL_CTRL5, - CS530X_IN_VU); + CS530X_INOUT_VU); + default: + return -EINVAL; + } + + return 0; +} + +static SOC_ENUM_SINGLE_DECL(cs530x_ramp_out_inc_enum, CS530X_OUT_RAMP_SUM, + CS530X_RAMP_RATE_INC_SHIFT, + cs530x_vol_ramp_text); + +static SOC_ENUM_SINGLE_DECL(cs530x_ramp_out_dec_enum, CS530X_OUT_RAMP_SUM, + CS530X_RAMP_RATE_DEC_SHIFT, + cs530x_vol_ramp_text); + +static const struct snd_kcontrol_new cs530x_out_1_to_2_controls[] = { +SOC_SINGLE_EXT_TLV("OUT1 Volume", CS530X_OUT_VOL_CTRL1_0, 0, 255, 1, + snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), +SOC_SINGLE_EXT_TLV("OUT2 Volume", CS530X_OUT_VOL_CTRL1_1, 0, 255, 1, + snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), + +SOC_ENUM("OUT DEC Filter Select", cs530x_out_filter_enum), +SOC_ENUM("Output Ramp Up", cs530x_ramp_out_inc_enum), +SOC_ENUM("Output Ramp Down", cs530x_ramp_out_dec_enum), + +SOC_SINGLE("DAC1 Invert Switch", CS530X_OUT_INV, CS530X_INOUT1_INV_SHIFT, 1, 0), +SOC_SINGLE("DAC2 Invert Switch", CS530X_OUT_INV, CS530X_INOUT2_INV_SHIFT, 1, 0), +}; + +static const struct snd_kcontrol_new cs530x_out_3_to_4_controls[] = { +SOC_SINGLE_EXT_TLV("OUT3 Volume", CS530X_OUT_VOL_CTRL2_0, 0, 255, 1, + snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), +SOC_SINGLE_EXT_TLV("OUT4 Volume", CS530X_OUT_VOL_CTRL2_1, 0, 255, 1, + snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), + +SOC_SINGLE("DAC3 Invert Switch", CS530X_OUT_INV, CS530X_INOUT3_INV_SHIFT, 1, 0), +SOC_SINGLE("DAC4 Invert Switch", CS530X_OUT_INV, CS530X_INOUT4_INV_SHIFT, 1, 0), +}; + +static const struct snd_kcontrol_new cs530x_out_5_to_8_controls[] = { +SOC_SINGLE_EXT_TLV("OUT5 Volume", CS530X_OUT_VOL_CTRL3_0, 0, 255, 1, + snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), +SOC_SINGLE_EXT_TLV("OUT6 Volume", CS530X_OUT_VOL_CTRL3_1, 0, 255, 1, + snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), +SOC_SINGLE_EXT_TLV("OUT7 Volume", CS530X_OUT_VOL_CTRL4_0, 0, 255, 1, + snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), +SOC_SINGLE_EXT_TLV("OUT8 Volume", CS530X_OUT_VOL_CTRL4_1, 0, 255, 1, + snd_soc_get_volsw, cs530x_put_volsw_vu, in_vol_tlv), + +SOC_SINGLE("DAC5 Invert Switch", CS530X_OUT_INV, CS530X_INOUT5_INV_SHIFT, 1, 0), +SOC_SINGLE("DAC6 Invert Switch", CS530X_OUT_INV, CS530X_INOUT6_INV_SHIFT, 1, 0), +SOC_SINGLE("DAC7 Invert Switch", CS530X_OUT_INV, CS530X_INOUT7_INV_SHIFT, 1, 0), +SOC_SINGLE("DAC8 Invert Switch", CS530X_OUT_INV, CS530X_INOUT8_INV_SHIFT, 1, 0), +}; + +static int cs530x_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); + struct regmap *regmap = cs530x->regmap; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + cs530x->dac_pairs_count++; + break; + case SND_SOC_DAPM_POST_PMU: + regmap_clear_bits(regmap, CS530X_OUT_VOL_CTRL1_0 + + (w->shift * 2), CS530X_INOUT_MUTE); + regmap_clear_bits(regmap, CS530X_OUT_VOL_CTRL1_0 + + ((w->shift + 1) * 2), CS530X_INOUT_MUTE); + + cs530x->dac_pairs_count--; + if (!cs530x->dac_pairs_count) { + usleep_range(1000, 1100); + return regmap_write(regmap, CS530X_OUT_VOL_CTRL5, + CS530X_INOUT_VU); + } + break; + case SND_SOC_DAPM_PRE_PMD: + regmap_set_bits(regmap, CS530X_OUT_VOL_CTRL1_0 + + (w->shift * 2), CS530X_INOUT_MUTE); + regmap_set_bits(regmap, CS530X_OUT_VOL_CTRL1_0 + + ((w->shift + 1) * 2), CS530X_INOUT_MUTE); + return regmap_write(regmap, CS530X_OUT_VOL_CTRL5, + CS530X_INOUT_VU); default: return -EINVAL; } @@ -263,18 +392,24 @@ static int cs530x_adc_event(struct snd_soc_dapm_widget *w, static const struct snd_kcontrol_new adc12_ctrl = SOC_DAPM_SINGLE_VIRT("Switch", 1); - static const struct snd_kcontrol_new adc34_ctrl = SOC_DAPM_SINGLE_VIRT("Switch", 1); - static const struct snd_kcontrol_new adc56_ctrl = SOC_DAPM_SINGLE_VIRT("Switch", 1); - static const struct snd_kcontrol_new adc78_ctrl = SOC_DAPM_SINGLE_VIRT("Switch", 1); - +static const struct snd_kcontrol_new dac12_ctrl = + SOC_DAPM_SINGLE_VIRT("Switch", 1); +static const struct snd_kcontrol_new dac34_ctrl = + SOC_DAPM_SINGLE_VIRT("Switch", 1); +static const struct snd_kcontrol_new dac56_ctrl = + SOC_DAPM_SINGLE_VIRT("Switch", 1); +static const struct snd_kcontrol_new dac78_ctrl = + SOC_DAPM_SINGLE_VIRT("Switch", 1); static const struct snd_kcontrol_new in_hpf_ctrl = SOC_DAPM_SINGLE_VIRT("Switch", 1); +static const struct snd_kcontrol_new out_hpf_ctrl = + SOC_DAPM_SINGLE_VIRT("Switch", 1); /* General DAPM widgets for all devices */ static const struct snd_soc_dapm_widget cs530x_gen_dapm_widgets[] = { @@ -291,7 +426,7 @@ SND_SOC_DAPM_ADC_E("ADC1", NULL, CS530X_IN_ENABLES, 0, 0, SND_SOC_DAPM_PRE_PMU), SND_SOC_DAPM_ADC("ADC2", NULL, CS530X_IN_ENABLES, 1, 0), SND_SOC_DAPM_SWITCH("ADC12 Enable", SND_SOC_NOPM, 0, 0, &adc12_ctrl), -SND_SOC_DAPM_SWITCH("IN HPF", CS530X_IN_FILTER, CS530X_IN_HPF_EN_SHIFT, +SND_SOC_DAPM_SWITCH("IN HPF", CS530X_IN_FILTER, CS530X_INOUT_HPF_EN_SHIFT, 0, &in_hpf_ctrl), }; @@ -387,7 +522,7 @@ static const struct snd_soc_dapm_route adc_ch5_8_routes[] = { static void cs530x_add_12_adc_widgets(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_add_component_controls(component, cs530x_in_1_to_2_controls, @@ -402,7 +537,7 @@ static void cs530x_add_12_adc_widgets(struct snd_soc_component *component) static void cs530x_add_34_adc_widgets(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_add_component_controls(component, cs530x_in_3_to_4_controls, @@ -415,6 +550,153 @@ static void cs530x_add_34_adc_widgets(struct snd_soc_component *component) ARRAY_SIZE(adc_ch3_4_routes)); } +/* DAC's Channels 1 and 2 plus generic DAC DAPM events */ +static const struct snd_soc_dapm_widget cs530x_dac_ch12_dapm_widgets[] = { +SND_SOC_DAPM_OUTPUT("OUT1"), +SND_SOC_DAPM_OUTPUT("OUT2"), +SND_SOC_DAPM_DAC_E("DAC1", NULL, CS530X_OUT_ENABLES, 0, 0, + cs530x_dac_event, + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMU), +SND_SOC_DAPM_DAC("DAC2", NULL, CS530X_OUT_ENABLES, 1, 0), +SND_SOC_DAPM_SWITCH("DAC12 Enable", SND_SOC_NOPM, 0, 0, &dac12_ctrl), +SND_SOC_DAPM_SWITCH("OUT HPF", CS530X_OUT_FILTER, CS530X_INOUT_HPF_EN_SHIFT, + 0, &out_hpf_ctrl), +}; + +/* DAC's Channels 3 and 4 */ +static const struct snd_soc_dapm_widget cs530x_dac_ch34_dapm_widgets[] = { +SND_SOC_DAPM_OUTPUT("OUT3"), +SND_SOC_DAPM_OUTPUT("OUT4"), +SND_SOC_DAPM_DAC_E("DAC3", NULL, CS530X_OUT_ENABLES, 2, 0, + cs530x_dac_event, + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMU), +SND_SOC_DAPM_DAC("DAC4", NULL, CS530X_OUT_ENABLES, 3, 0), +SND_SOC_DAPM_SWITCH("DAC34 Enable", SND_SOC_NOPM, 0, 0, &dac34_ctrl), +}; + +/* DAC's Channels 5 to 8 */ +static const struct snd_soc_dapm_widget cs530x_dac_ch58_dapm_widgets[] = { +SND_SOC_DAPM_OUTPUT("OUT5"), +SND_SOC_DAPM_OUTPUT("OUT6"), +SND_SOC_DAPM_OUTPUT("OUT7"), +SND_SOC_DAPM_OUTPUT("OUT8"), +SND_SOC_DAPM_DAC_E("DAC5", NULL, CS530X_OUT_ENABLES, 4, 0, + cs530x_dac_event, + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMU), +SND_SOC_DAPM_DAC("DAC6", NULL, CS530X_OUT_ENABLES, 5, 0), +SND_SOC_DAPM_SWITCH("DAC56 Enable", SND_SOC_NOPM, 0, 0, &dac56_ctrl), +SND_SOC_DAPM_DAC_E("DAC7", NULL, CS530X_OUT_ENABLES, 6, 0, + cs530x_dac_event, + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMU), +SND_SOC_DAPM_DAC("DAC8", NULL, CS530X_OUT_ENABLES, 7, 0), +SND_SOC_DAPM_SWITCH("DAC78 Enable", SND_SOC_NOPM, 0, 0, &dac78_ctrl), +}; + +static const struct snd_soc_dapm_route dac_ch1_2_routes[] = { + { "DAC1", NULL, "Global Enable" }, + { "DAC2", NULL, "Global Enable" }, + + { "DAC12 Enable", "Switch", "OUT1" }, + { "DAC12 Enable", "Switch", "OUT2" }, + { "DAC1", NULL, "DAC12 Enable" }, + { "DAC2", NULL, "DAC12 Enable" }, + { "OUT HPF", "Switch", "DAC1" }, + { "OUT HPF", "Switch", "DAC2" }, + + { "OUT HPF", NULL, "AIF Playback" }, + { "DAC1", NULL, "AIF Playback" }, + { "DAC2", NULL, "AIF Playback" }, + + { "OUT1", NULL, "DAC1" }, + { "OUT2", NULL, "DAC2" }, +}; + +static const struct snd_soc_dapm_route dac_ch3_4_routes[] = { + { "DAC3", NULL, "Global Enable" }, + { "DAC4", NULL, "Global Enable" }, + + { "DAC34 Enable", "Switch", "OUT3" }, + { "DAC34 Enable", "Switch", "OUT4" }, + { "DAC3", NULL, "DAC34 Enable" }, + { "DAC4", NULL, "DAC34 Enable" }, + { "OUT HPF", "Switch", "DAC3" }, + { "OUT HPF", "Switch", "DAC4" }, + + { "DAC3", NULL, "AIF Playback" }, + { "DAC4", NULL, "AIF Playback" }, + + { "OUT3", NULL, "DAC3" }, + { "OUT4", NULL, "DAC4" }, +}; + +static const struct snd_soc_dapm_route dac_ch5_8_routes[] = { + { "DAC5", NULL, "Global Enable" }, + { "DAC6", NULL, "Global Enable" }, + + { "DAC56 Enable", "Switch", "OUT5" }, + { "DAC56 Enable", "Switch", "OUT6" }, + { "DAC5", NULL, "DAC56 Enable" }, + { "DAC6", NULL, "DAC56 Enable" }, + { "OUT HPF", "Switch", "DAC5" }, + { "OUT HPF", "Switch", "DAC6" }, + + { "DAC5", NULL, "AIF Playback" }, + { "DAC6", NULL, "AIF Playback" }, + + { "OUT5", NULL, "DAC5" }, + { "OUT6", NULL, "DAC6" }, + + { "DAC7", NULL, "Global Enable" }, + { "DAC8", NULL, "Global Enable" }, + + { "DAC78 Enable", "Switch", "OUT7" }, + { "DAC78 Enable", "Switch", "OUT8" }, + { "DAC7", NULL, "DAC78 Enable" }, + { "DAC8", NULL, "DAC78 Enable" }, + { "OUT HPF", "Switch", "DAC7" }, + { "OUT HPF", "Switch", "DAC8" }, + + { "DAC7", NULL, "AIF Playback" }, + { "DAC8", NULL, "AIF Playback" }, + + { "OUT7", NULL, "DAC7" }, + { "OUT8", NULL, "DAC8" }, +}; + +static void cs530x_add_12_dac_widgets(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + + snd_soc_add_component_controls(component, + cs530x_out_1_to_2_controls, + ARRAY_SIZE(cs530x_out_1_to_2_controls)); + + snd_soc_dapm_new_controls(dapm, cs530x_dac_ch12_dapm_widgets, + ARRAY_SIZE(cs530x_dac_ch12_dapm_widgets)); + + snd_soc_dapm_add_routes(dapm, dac_ch1_2_routes, + ARRAY_SIZE(dac_ch1_2_routes)); +} + +static void cs530x_add_34_dac_widgets(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + + snd_soc_add_component_controls(component, + cs530x_out_3_to_4_controls, + ARRAY_SIZE(cs530x_out_3_to_4_controls)); + + snd_soc_dapm_new_controls(dapm, cs530x_dac_ch34_dapm_widgets, + ARRAY_SIZE(cs530x_dac_ch34_dapm_widgets)); + + snd_soc_dapm_add_routes(dapm, dac_ch3_4_routes, + ARRAY_SIZE(dac_ch3_4_routes)); +} + static int cs530x_set_bclk(struct snd_soc_component *component, const int freq) { struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); @@ -450,7 +732,7 @@ static int cs530x_set_bclk(struct snd_soc_component *component, const int freq) } static int cs530x_set_pll_refclk(struct snd_soc_component *component, - const unsigned int freq) + const unsigned int freq) { struct cs530x_priv *priv = snd_soc_component_get_drvdata(component); struct regmap *regmap = priv->regmap; @@ -492,37 +774,35 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream, int ret = 0, fs = params_rate(params), bclk; unsigned int fs_val; - switch (fs) { case 32000: fs_val = CS530X_FS_32K; break; case 44100: case 48000: - fs_val = CS530X_FS_48K_44P1K; + fs_val = CS530X_FS_44P1K_48K; break; case 88200: case 96000: - fs_val = CS530X_FS_96K_88P2K; + fs_val = CS530X_FS_88P2K_96K; break; case 176400: case 192000: - fs_val = CS530X_FS_192K_176P4K; + fs_val = CS530X_FS_176P4K_192K; break; case 356800: case 384000: - fs_val = CS530X_FS_384K_356P8K; + fs_val = CS530X_FS_356P8K_384K; break; case 705600: case 768000: - fs_val = CS530X_FS_768K_705P6K; + fs_val = CS530X_FS_705P6K_768K; break; default: dev_err(component->dev, "Invalid sample rate %d\n", fs); return -EINVAL; } - cs530x->fs = fs; regmap_update_bits(regmap, CS530X_CLK_CFG_1, CS530X_SAMPLE_RATE_MASK, fs_val); @@ -540,7 +820,7 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream, } if (!regmap_test_bits(regmap, CS530X_CLK_CFG_0, - CS530X_PLL_REFCLK_SRC_MASK)) { + CS530X_PLL_REFCLK_SRC_MASK)) { ret = cs530x_set_pll_refclk(component, bclk); if (ret) return ret; @@ -614,7 +894,7 @@ static bool cs530x_check_mclk_freq(struct snd_soc_component *component, } static int cs530x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, - unsigned int rx_mask, int slots, int slot_width) + unsigned int rx_mask, int slots, int slot_width) { struct snd_soc_component *component = dai->component; struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); @@ -675,8 +955,11 @@ static const struct snd_soc_dai_driver cs530x_dai = { .name = "cs530x-dai", .capture = { .stream_name = "AIF Capture", - .channels_min = 2, - .channels_max = 8, + .rates = SNDRV_PCM_RATE_KNOT, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + }, + .playback = { + .stream_name = "AIF Playback", .rates = SNDRV_PCM_RATE_KNOT, .formats = SNDRV_PCM_FMTBIT_S32_LE, }, @@ -686,8 +969,8 @@ static const struct snd_soc_dai_driver cs530x_dai = { }; static int cs530x_set_pll(struct snd_soc_component *component, int pll_id, - int source, unsigned int freq_in, - unsigned int freq_out) + int source, unsigned int freq_in, + unsigned int freq_out) { struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); struct regmap *regmap = cs530x->regmap; @@ -724,13 +1007,50 @@ static int cs530x_set_pll(struct snd_soc_component *component, int pll_id, static int cs530x_component_probe(struct snd_soc_component *component) { struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int num_widgets; snd_soc_dapm_new_controls(dapm, cs530x_gen_dapm_widgets, ARRAY_SIZE(cs530x_gen_dapm_widgets)); switch (cs530x->devtype) { + case CS4282: + cs530x_add_12_adc_widgets(component); + cs530x_add_12_dac_widgets(component); + break; + case CS4302: + cs530x_add_12_dac_widgets(component); + break; + case CS4304: + cs530x_add_12_dac_widgets(component); + cs530x_add_34_dac_widgets(component); + + num_widgets = ARRAY_SIZE(cs530x_out_sum_4ch_controls); + snd_soc_add_component_controls(component, + cs530x_out_sum_4ch_controls, + num_widgets); + break; + case CS4308: + cs530x_add_12_dac_widgets(component); + cs530x_add_34_dac_widgets(component); + + num_widgets = ARRAY_SIZE(cs530x_out_5_to_8_controls); + snd_soc_add_component_controls(component, + cs530x_out_5_to_8_controls, + num_widgets); + + num_widgets = ARRAY_SIZE(cs530x_out_sum_8ch_controls); + snd_soc_add_component_controls(component, + cs530x_out_sum_8ch_controls, + num_widgets); + + num_widgets = ARRAY_SIZE(cs530x_dac_ch58_dapm_widgets); + snd_soc_dapm_new_controls(dapm, cs530x_dac_ch58_dapm_widgets, + num_widgets); + + snd_soc_dapm_add_routes(dapm, dac_ch5_8_routes, + ARRAY_SIZE(dac_ch5_8_routes)); + break; case CS5302: cs530x_add_12_adc_widgets(component); break; @@ -743,7 +1063,6 @@ static int cs530x_component_probe(struct snd_soc_component *component) cs530x_in_sum_4ch_controls, num_widgets); break; - case CS5308: cs530x_add_12_adc_widgets(component); cs530x_add_34_adc_widgets(component); @@ -775,20 +1094,21 @@ static int cs530x_component_probe(struct snd_soc_component *component) } static int cs530x_set_sysclk(struct snd_soc_component *component, int clk_id, - int source, unsigned int freq, int dir) + int source, unsigned int freq, int dir) { struct cs530x_priv *cs530x = snd_soc_component_get_drvdata(component); struct regmap *regmap = cs530x->regmap; switch (source) { case CS530X_SYSCLK_SRC_MCLK: - if (freq != 24560000 && freq != 22572000) { - dev_err(component->dev, "Invalid MCLK source rate %d\n", - freq); + switch (freq) { + case CS530X_SYSCLK_REF_45_1MHZ: + case CS530X_SYSCLK_REF_49_1MHZ: + break; + default: + dev_err(component->dev, "Invalid MCLK source rate %d\n", freq); return -EINVAL; } - - cs530x->mclk_rate = freq; break; case CS530X_SYSCLK_SRC_PLL: break; @@ -809,7 +1129,7 @@ static const struct snd_soc_component_driver soc_component_dev_cs530x = { .endianness = 1, }; -const struct regmap_config cs530x_regmap = { +const struct regmap_config cs530x_regmap_i2c = { .reg_bits = 16, .val_bits = 16, @@ -821,7 +1141,27 @@ const struct regmap_config cs530x_regmap = { .reg_defaults = cs530x_reg_defaults, .num_reg_defaults = ARRAY_SIZE(cs530x_reg_defaults), }; -EXPORT_SYMBOL_NS_GPL(cs530x_regmap, "SND_SOC_CS530X"); +EXPORT_SYMBOL_NS_GPL(cs530x_regmap_i2c, "SND_SOC_CS530X"); + +const struct regmap_config cs530x_regmap_spi = { + .reg_bits = 16, + .pad_bits = 16, + .val_bits = 16, + + .reg_stride = 2, + + .reg_format_endian = REGMAP_ENDIAN_BIG, + .val_format_endian = REGMAP_ENDIAN_BIG, + + .max_register = CS530X_MAX_REGISTER, + .writeable_reg = cs530x_writeable_register, + .readable_reg = cs530x_readable_register, + + .cache_type = REGCACHE_MAPLE, + .reg_defaults = cs530x_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(cs530x_reg_defaults), +}; +EXPORT_SYMBOL_NS_GPL(cs530x_regmap_spi, "SND_SOC_CS530X"); static int cs530x_check_device_id(struct cs530x_priv *cs530x) { @@ -837,9 +1177,20 @@ static int cs530x_check_device_id(struct cs530x_priv *cs530x) if (ret) return dev_err_probe(dev, ret, "Can't read REV ID\n"); - dev_dbg(dev, "Device ID 0x%x Rev ID 0x%x\n", dev_id, rev); - switch (dev_id) { + case CS530X_2CH_CODEC_DEV_ID: + cs530x->num_dacs = 2; + cs530x->num_adcs = 2; + break; + case CS530X_2CH_DAC_DEV_ID: + cs530x->num_dacs = 2; + break; + case CS530X_4CH_DAC_DEV_ID: + cs530x->num_dacs = 4; + break; + case CS530X_8CH_DAC_DEV_ID: + cs530x->num_dacs = 8; + break; case CS530X_2CH_ADC_DEV_ID: cs530x->num_adcs = 2; break; @@ -854,6 +1205,15 @@ static int cs530x_check_device_id(struct cs530x_priv *cs530x) dev_id); } + if (cs530x->devtype != dev_id) { + dev_err(dev, "Read device ID 0x%x is not the expected devtype 0x%x\n", + dev_id, cs530x->devtype); + return -EINVAL; + } + + dev_dbg(dev, "Device ID 0x%x Rev ID 0x%x (%d in %d out)\n", dev_id, rev, + cs530x->num_adcs, cs530x->num_dacs); + return 0; } @@ -882,6 +1242,9 @@ static int cs530x_parse_device_properties(struct cs530x_priv *cs530x) val |= CS530X_IN12_HIZ; return regmap_set_bits(regmap, CS530X_IN_HIZ, val); + case 0: + /* No ADCs */ + return 0; default: return dev_err_probe(dev, -EINVAL, "Invalid number of adcs %d\n", @@ -895,8 +1258,8 @@ int cs530x_probe(struct cs530x_priv *cs530x) int ret, i; cs530x->dev_dai = devm_kmemdup(dev, &cs530x_dai, - sizeof(*(cs530x->dev_dai)), - GFP_KERNEL); + sizeof(*(cs530x->dev_dai)), + GFP_KERNEL); if (!cs530x->dev_dai) return -ENOMEM; @@ -914,10 +1277,10 @@ int cs530x_probe(struct cs530x_priv *cs530x) return dev_err_probe(dev, ret, "Failed to enable supplies"); cs530x->reset_gpio = devm_gpiod_get_optional(dev, "reset", - GPIOD_OUT_HIGH); + GPIOD_OUT_HIGH); if (IS_ERR(cs530x->reset_gpio)) { ret = dev_err_probe(dev, PTR_ERR(cs530x->reset_gpio), - "Reset gpio not available\n"); + "Reset gpio not available\n"); goto err_regulator; } @@ -944,10 +1307,19 @@ int cs530x_probe(struct cs530x_priv *cs530x) if (ret) goto err_reset; - cs530x->dev_dai->capture.channels_max = cs530x->num_adcs; + if (cs530x->num_adcs) { + cs530x->dev_dai->capture.channels_min = 2; + cs530x->dev_dai->capture.channels_max = cs530x->num_adcs; + } + + if (cs530x->num_dacs) { + cs530x->dev_dai->playback.channels_min = 2; + cs530x->dev_dai->playback.channels_max = cs530x->num_dacs; + } ret = devm_snd_soc_register_component(dev, - &soc_component_dev_cs530x, cs530x->dev_dai, 1); + &soc_component_dev_cs530x, + cs530x->dev_dai, 1); if (ret) { dev_err_probe(dev, ret, "Can't register cs530x component\n"); goto err_reset; diff --git a/sound/soc/codecs/cs530x.h b/sound/soc/codecs/cs530x.h index f473e33eb835..1e2f6a7a589c 100644 --- a/sound/soc/codecs/cs530x.h +++ b/sound/soc/codecs/cs530x.h @@ -2,7 +2,7 @@ /* * CS530x CODEC driver internal data * - * Copyright (C) 2023-2024 Cirrus Logic, Inc. and + * Copyright (C) 2023-2025 Cirrus Logic, Inc. and * Cirrus Logic International Semiconductor Ltd. */ @@ -15,6 +15,10 @@ #include <linux/regulator/consumer.h> /* Devices */ +#define CS530X_2CH_CODEC_DEV_ID 0x4282 +#define CS530X_2CH_DAC_DEV_ID 0x4302 +#define CS530X_4CH_DAC_DEV_ID 0x4304 +#define CS530X_8CH_DAC_DEV_ID 0x4308 #define CS530X_2CH_ADC_DEV_ID 0x5302 #define CS530X_4CH_ADC_DEV_ID 0x5304 #define CS530X_8CH_ADC_DEV_ID 0x5308 @@ -45,6 +49,21 @@ #define CS530X_IN_VOL_CTRL4_1 0x000009E #define CS530X_IN_VOL_CTRL5 0x00000A0 +#define CS530X_OUT_ENABLES 0x00000C0 +#define CS530X_OUT_RAMP_SUM 0x00000C2 +#define CS530X_OUT_DEEMPH 0x00000C4 +#define CS530X_OUT_FILTER 0x00000C6 +#define CS530X_OUT_INV 0x00000CA +#define CS530X_OUT_VOL_CTRL1_0 0x00000D0 +#define CS530X_OUT_VOL_CTRL1_1 0x00000D2 +#define CS530X_OUT_VOL_CTRL2_0 0x00000D4 +#define CS530X_OUT_VOL_CTRL2_1 0x00000D6 +#define CS530X_OUT_VOL_CTRL3_0 0x00000D8 +#define CS530X_OUT_VOL_CTRL3_1 0x00000DA +#define CS530X_OUT_VOL_CTRL4_0 0x00000DC +#define CS530X_OUT_VOL_CTRL4_1 0x00000DE +#define CS530X_OUT_VOL_CTRL5 0x00000E0 + #define CS530X_PAD_FN 0x0003D24 #define CS530X_PAD_LVL 0x0003D28 @@ -73,11 +92,11 @@ /* CLK_CFG_1 */ #define CS530X_SAMPLE_RATE_MASK GENMASK(2, 0) #define CS530X_FS_32K 0 -#define CS530X_FS_48K_44P1K 1 -#define CS530X_FS_96K_88P2K 2 -#define CS530X_FS_192K_176P4K 3 -#define CS530X_FS_384K_356P8K 4 -#define CS530X_FS_768K_705P6K 5 +#define CS530X_FS_44P1K_48K 1 +#define CS530X_FS_88P2K_96K 2 +#define CS530X_FS_176P4K_192K 3 +#define CS530X_FS_356P8K_384K 4 +#define CS530X_FS_705P6K_768K 5 /* CHIP_ENABLE */ #define CS530X_GLOBAL_EN BIT(0) @@ -99,7 +118,7 @@ #define CS530X_TDM_EN_MASK BIT(2) #define CS530X_ASP_FMT_I2S 0 #define CS530X_ASP_FMT_LJ 1 -#define CS530X_ASP_FMT_DSP_A 0x6 +#define CS530X_ASP_FMT_DSP_A 6 /* TDM Slots */ #define CS530X_0_1_TDM_SLOT_MASK GENMASK(1, 0) @@ -132,14 +151,14 @@ #define CS530X_14_15_TDM_SLOT_MASK GENMASK(15, 14) #define CS530X_14_15_TDM_SLOT_VAL 7 -/* IN_RAMP_SUM */ +/* IN_RAMP_SUM and OUT_RAMP_SUM */ #define CS530X_RAMP_RATE_INC_SHIFT 0 #define CS530X_RAMP_RATE_DEC_SHIFT 4 -#define CS530X_IN_SUM_MODE_SHIFT 13 +#define CS530X_INOUT_SUM_MODE_SHIFT 13 -/* IN_FILTER */ -#define CS530X_IN_FILTER_SHIFT 8 -#define CS530X_IN_HPF_EN_SHIFT 12 +/* IN_FILTER and OUT_FILTER */ +#define CS530X_INOUT_FILTER_SHIFT 8 +#define CS530X_INOUT_HPF_EN_SHIFT 12 /* IN_HIZ */ #define CS530X_IN12_HIZ BIT(0) @@ -147,18 +166,18 @@ #define CS530X_IN56_HIZ BIT(2) #define CS530X_IN78_HIZ BIT(3) -/* IN_INV */ -#define CS530X_IN1_INV_SHIFT 0 -#define CS530X_IN2_INV_SHIFT 1 -#define CS530X_IN3_INV_SHIFT 2 -#define CS530X_IN4_INV_SHIFT 3 -#define CS530X_IN5_INV_SHIFT 4 -#define CS530X_IN6_INV_SHIFT 5 -#define CS530X_IN7_INV_SHIFT 6 -#define CS530X_IN8_INV_SHIFT 7 +/* IN_INV and OUT_INV */ +#define CS530X_INOUT1_INV_SHIFT 0 +#define CS530X_INOUT2_INV_SHIFT 1 +#define CS530X_INOUT3_INV_SHIFT 2 +#define CS530X_INOUT4_INV_SHIFT 3 +#define CS530X_INOUT5_INV_SHIFT 4 +#define CS530X_INOUT6_INV_SHIFT 5 +#define CS530X_INOUT7_INV_SHIFT 6 +#define CS530X_INOUT8_INV_SHIFT 7 -/* IN_VOL_CTLy_z */ -#define CS530X_IN_MUTE BIT(15) +/* IN_VOL_CTLy_z and OUT_VOL_CTLy_z */ +#define CS530X_INOUT_MUTE BIT(15) /* IN_VOL_CTL5 */ #define CS530X_IN_VU BIT(0) @@ -178,6 +197,14 @@ #define CS530X_CONFIG3_LVL BIT(7) #define CS530X_CONFIG4_LVL BIT(8) #define CS530X_CONFIG5_LVL BIT(9) +/* IN_VOL_CTL5 and OUT_VOL_CTL5 */ +#define CS530X_INOUT_VU BIT(0) + +/* MCLK Reference Source Frequency */ +/* 41KHz related */ +#define CS530X_SYSCLK_REF_45_1MHZ 45158400 +/* 48KHz related */ +#define CS530X_SYSCLK_REF_49_1MHZ 49152000 /* System Clock Source */ #define CS530X_SYSCLK_SRC_MCLK 0 @@ -190,9 +217,13 @@ #define CS530X_NUM_SUPPLIES 2 enum cs530x_type { - CS5302, - CS5304, - CS5308, + CS4282 = CS530X_2CH_CODEC_DEV_ID, + CS4302 = CS530X_2CH_DAC_DEV_ID, + CS4304 = CS530X_4CH_DAC_DEV_ID, + CS4308 = CS530X_8CH_DAC_DEV_ID, + CS5302 = CS530X_2CH_ADC_DEV_ID, + CS5304 = CS530X_4CH_ADC_DEV_ID, + CS5308 = CS530X_8CH_ADC_DEV_ID, }; /* codec private data */ @@ -207,17 +238,16 @@ struct cs530x_priv { struct regulator_bulk_data supplies[CS530X_NUM_SUPPLIES]; - unsigned int mclk_rate; - int tdm_width; int tdm_slots; - int fs; int adc_pairs_count; + int dac_pairs_count; struct gpio_desc *reset_gpio; }; -extern const struct regmap_config cs530x_regmap; +extern const struct regmap_config cs530x_regmap_i2c; +extern const struct regmap_config cs530x_regmap_spi; int cs530x_probe(struct cs530x_priv *cs530x); #endif diff --git a/sound/soc/codecs/cs53l30.c b/sound/soc/codecs/cs53l30.c index 61bf72681674..93ea2fb4dae9 100644 --- a/sound/soc/codecs/cs53l30.c +++ b/sound/soc/codecs/cs53l30.c @@ -649,8 +649,9 @@ static int cs53l30_pcm_hw_params(struct snd_pcm_substream *substream, static int cs53l30_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct cs53l30_private *priv = snd_soc_component_get_drvdata(component); + enum snd_soc_bias_level bias_level = snd_soc_dapm_get_bias_level(dapm); unsigned int reg; int i, inter_max_check, ret; @@ -658,12 +659,12 @@ static int cs53l30_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - if (dapm->bias_level == SND_SOC_BIAS_STANDBY) + if (bias_level == SND_SOC_BIAS_STANDBY) regmap_update_bits(priv->regmap, CS53L30_PWRCTL, CS53L30_PDN_LP_MASK, 0); break; case SND_SOC_BIAS_STANDBY: - if (dapm->bias_level == SND_SOC_BIAS_OFF) { + if (bias_level == SND_SOC_BIAS_OFF) { ret = clk_prepare_enable(priv->mclk); if (ret) { dev_err(component->dev, @@ -857,7 +858,7 @@ static struct snd_soc_dai_driver cs53l30_dai = { static int cs53l30_component_probe(struct snd_soc_component *component) { struct cs53l30_private *priv = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); if (priv->use_sdout2) snd_soc_dapm_add_routes(dapm, cs53l30_dapm_routes_sdout2, diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c index 9d54141a0cd1..d6121c0a2616 100644 --- a/sound/soc/codecs/cx20442.c +++ b/sound/soc/codecs/cx20442.c @@ -315,11 +315,12 @@ static int cx20442_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int err = 0; switch (level) { case SND_SOC_BIAS_PREPARE: - if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_STANDBY) break; if (IS_ERR(cx20442->por)) err = PTR_ERR(cx20442->por); @@ -327,7 +328,7 @@ static int cx20442_set_bias_level(struct snd_soc_component *component, err = regulator_enable(cx20442->por); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_PREPARE) + if (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_PREPARE) break; if (IS_ERR(cx20442->por)) err = PTR_ERR(cx20442->por); diff --git a/sound/soc/codecs/cx2072x.c b/sound/soc/codecs/cx2072x.c index 934526f8f292..b0033bf9be3a 100644 --- a/sound/soc/codecs/cx2072x.c +++ b/sound/soc/codecs/cx2072x.c @@ -1341,8 +1341,8 @@ static int cx2072x_set_bias_level(struct snd_soc_component *codec, enum snd_soc_bias_level level) { struct cx2072x_priv *cx2072x = snd_soc_component_get_drvdata(codec); - const enum snd_soc_bias_level old_level = - snd_soc_component_get_bias_level(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec); + const enum snd_soc_bias_level old_level = snd_soc_dapm_get_bias_level(dapm); if (level == SND_SOC_BIAS_STANDBY && old_level == SND_SOC_BIAS_OFF) regmap_write(cx2072x->regmap, CX2072X_AFG_POWER_STATE, 0); @@ -1363,7 +1363,7 @@ static int cx2072x_set_bias_level(struct snd_soc_component *codec, static void cx2072x_enable_jack_detect(struct snd_soc_component *codec) { struct cx2072x_priv *cx2072x = snd_soc_component_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec); /* No-sticky input type */ regmap_write(cx2072x->regmap, CX2072X_GPIO_STICKY_MASK, 0x1f); diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index a889f05119f8..94e59546c2fe 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -326,7 +326,7 @@ static SOC_ENUM_SINGLE_DECL(da7210_hp_mode_sel, static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); if (ucontrol->value.integer.value[0]) { /* Check if noise suppression is enabled */ @@ -349,7 +349,7 @@ static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 val; if (ucontrol->value.integer.value[0]) { diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 3420011da444..0a2b50cdea95 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -214,7 +214,7 @@ static SOC_ENUM_SINGLE_DECL(da7213_alc_integ_release_rate, static int da7213_volsw_locked_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); int ret; @@ -228,7 +228,7 @@ static int da7213_volsw_locked_get(struct snd_kcontrol *kcontrol, static int da7213_volsw_locked_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); int ret; @@ -242,7 +242,7 @@ static int da7213_volsw_locked_put(struct snd_kcontrol *kcontrol, static int da7213_enum_locked_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); int ret; @@ -256,7 +256,7 @@ static int da7213_enum_locked_get(struct snd_kcontrol *kcontrol, static int da7213_enum_locked_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); int ret; @@ -420,7 +420,7 @@ static void da7213_alc_calib(struct snd_soc_component *component) static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); int ret; @@ -436,7 +436,7 @@ static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); /* Force ALC offset calibration if enabling ALC */ @@ -457,7 +457,7 @@ static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, static int da7213_tonegen_freq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; @@ -484,7 +484,7 @@ static int da7213_tonegen_freq_get(struct snd_kcontrol *kcontrol, static int da7213_tonegen_freq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; @@ -1816,6 +1816,7 @@ static int da7213_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1823,7 +1824,7 @@ static int da7213_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_PREPARE: /* Enable MCLK for transition to ON state */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) { if (da7213->mclk) { ret = clk_prepare_enable(da7213->mclk); if (ret) { @@ -1837,7 +1838,7 @@ static int da7213_set_bias_level(struct snd_soc_component *component, } break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Enable VMID reference & master bias */ snd_soc_component_update_bits(component, DA7213_REFERENCES, DA7213_VMID_EN | DA7213_BIAS_EN, diff --git a/sound/soc/codecs/da7218.c b/sound/soc/codecs/da7218.c index a7539e1a1893..5c80839704c7 100644 --- a/sound/soc/codecs/da7218.c +++ b/sound/soc/codecs/da7218.c @@ -425,7 +425,7 @@ static void da7218_alc_calib(struct snd_soc_component *component) static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); int ret; @@ -446,7 +446,7 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *) kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); unsigned int lvalue = ucontrol->value.integer.value[0]; unsigned int rvalue = ucontrol->value.integer.value[1]; @@ -469,7 +469,7 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol, static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; @@ -493,7 +493,7 @@ static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol, static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; @@ -513,7 +513,7 @@ static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol, static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; @@ -540,7 +540,7 @@ static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol, static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; @@ -560,7 +560,7 @@ static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol, static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; @@ -585,7 +585,7 @@ static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol, static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; @@ -2562,6 +2562,7 @@ static int da7218_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -2569,7 +2570,7 @@ static int da7218_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_PREPARE: /* Enable MCLK for transition to ON state */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) { if (da7218->mclk) { ret = clk_prepare_enable(da7218->mclk); if (ret) { @@ -2581,7 +2582,7 @@ static int da7218_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Master bias */ snd_soc_component_update_bits(component, DA7218_REFERENCES, DA7218_BIAS_EN_MASK, diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c index 15e5e3eb592b..d9d932a78b71 100644 --- a/sound/soc/codecs/da7219-aad.c +++ b/sound/soc/codecs/da7219-aad.c @@ -53,7 +53,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work) struct da7219_aad_priv *da7219_aad = container_of(work, struct da7219_aad_priv, btn_det_work); struct snd_soc_component *component = da7219_aad->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 statusa, micbias_ctrl; bool micbias_up = false; @@ -109,7 +109,7 @@ static void da7219_aad_hptest_work(struct work_struct *work) struct da7219_aad_priv *da7219_aad = container_of(work, struct da7219_aad_priv, hptest_work); struct snd_soc_component *component = da7219_aad->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); __le16 tonegen_freq_hptest; @@ -351,7 +351,7 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) { struct da7219_aad_priv *da7219_aad = data; struct snd_soc_component *component = da7219_aad->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 events[DA7219_AAD_IRQ_REG_MAX]; u8 statusa; @@ -928,7 +928,7 @@ void da7219_aad_suspend(struct snd_soc_component *component) { struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u8 micbias_ctrl; disable_irq(da7219_aad->irq); @@ -962,7 +962,7 @@ void da7219_aad_resume(struct snd_soc_component *component) { struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); if (da7219_aad->jack) { /* Re-enable micbias if previously enabled for 4-pole jack */ diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 1742f91c788c..298a626df3ad 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -254,7 +254,7 @@ static const struct soc_enum da7219_cp_track_mode = static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; @@ -268,7 +268,7 @@ static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; @@ -282,7 +282,7 @@ static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; @@ -296,7 +296,7 @@ static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; @@ -376,7 +376,7 @@ static void da7219_alc_calib(struct snd_soc_component *component) static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; @@ -395,7 +395,7 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); @@ -414,7 +414,7 @@ static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; @@ -441,7 +441,7 @@ static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; @@ -1807,6 +1807,7 @@ static int da7219_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1814,7 +1815,7 @@ static int da7219_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_PREPARE: /* Enable MCLK for transition to ON state */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) { if (da7219->mclk) { ret = clk_prepare_enable(da7219->mclk); if (ret) { @@ -1827,13 +1828,13 @@ static int da7219_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) /* Master bias */ snd_soc_component_update_bits(component, DA7219_REFERENCES, DA7219_BIAS_EN_MASK, DA7219_BIAS_EN_MASK); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_PREPARE) { /* Remove MCLK */ if (da7219->mclk) clk_disable_unprepare(da7219->mclk); @@ -2613,12 +2614,13 @@ static void da7219_remove(struct snd_soc_component *component) static int da7219_suspend(struct snd_soc_component *component) { struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); /* Suspend AAD if we're not a wake-up source */ if (!da7219->wakeup_source) da7219_aad_suspend(component); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); return 0; } @@ -2626,8 +2628,9 @@ static int da7219_suspend(struct snd_soc_component *component) static int da7219_resume(struct snd_soc_component *component) { struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* Resume AAD if previously suspended */ if (!da7219->wakeup_source) diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c index 016c9be3ebda..140e449d3ef4 100644 --- a/sound/soc/codecs/da732x.c +++ b/sound/soc/codecs/da732x.c @@ -323,7 +323,7 @@ static SOC_ENUM_SINGLE_DECL(da732x_adc2_voice_filter_enum, static int da732x_hpf_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; unsigned int reg = enum_ctrl->reg; unsigned int sel = ucontrol->value.enumerated.item[0]; @@ -351,7 +351,7 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol, static int da732x_hpf_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; unsigned int reg = enum_ctrl->reg; int val; @@ -1408,6 +1408,7 @@ static int da732x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct da732x_priv *da732x = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -1418,7 +1419,7 @@ static int da732x_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Init Codec */ snd_soc_component_write(component, DA732X_REG_REF1, DA732X_VMID_FASTCHG); diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c index eb795abe9acd..a52276e32f2f 100644 --- a/sound/soc/codecs/da9055.c +++ b/sound/soc/codecs/da9055.c @@ -476,7 +476,7 @@ static int da9055_get_alc_data(struct snd_soc_component *component, u8 reg_val) static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 reg_val, adc_left, adc_right, mic_left, mic_right; int avg_left_data, avg_right_data, offset_l, offset_r; @@ -1352,12 +1352,14 @@ static struct snd_soc_dai_driver da9055_dai = { static int da9055_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Enable VMID reference & master bias */ snd_soc_component_update_bits(component, DA9055_REFERENCES, DA9055_VMID_EN | DA9055_BIAS_EN, diff --git a/sound/soc/codecs/es7134.c b/sound/soc/codecs/es7134.c index f5150d2f95da..441df1523f1c 100644 --- a/sound/soc/codecs/es7134.c +++ b/sound/soc/codecs/es7134.c @@ -104,7 +104,7 @@ static int es7134_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int es7134_component_probe(struct snd_soc_component *c) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(c); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(c); struct es7134_data *priv = snd_soc_component_get_drvdata(c); const struct es7134_chip *chip = priv->chip; int ret; diff --git a/sound/soc/codecs/es8311.c b/sound/soc/codecs/es8311.c index f557e33c26ad..0b07a53cc792 100644 --- a/sound/soc/codecs/es8311.c +++ b/sound/soc/codecs/es8311.c @@ -760,6 +760,7 @@ static int es8311_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct es8311_priv *es8311 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -767,7 +768,7 @@ static int es8311_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { int ret = clk_prepare_enable(es8311->mclk); if (ret) { dev_err(component->dev, diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index e7bd561a8f40..9245c33700de 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -590,7 +590,7 @@ static struct snd_soc_dai_driver es8316_dai = { static void es8316_enable_micbias_for_mic_gnd_short_detect( struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_force_enable_pin_unlocked(dapm, "Bias"); @@ -605,7 +605,7 @@ static void es8316_enable_micbias_for_mic_gnd_short_detect( static void es8316_disable_micbias_for_mic_gnd_short_detect( struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Bias"); diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c index 78c4e68f6002..05b13661c38c 100644 --- a/sound/soc/codecs/es8326.c +++ b/sound/soc/codecs/es8326.c @@ -737,7 +737,7 @@ static struct snd_soc_dai_driver es8326_dai = { static void es8326_enable_micbias(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_force_enable_pin_unlocked(dapm, "MICBIAS1"); @@ -748,7 +748,7 @@ static void es8326_enable_micbias(struct snd_soc_component *component) static void es8326_disable_micbias(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_disable_pin_unlocked(dapm, "MICBIAS1"); @@ -812,12 +812,12 @@ static void es8326_jack_button_handler(struct work_struct *work) press_count = 0; } button_to_report = cur_button; - queue_delayed_work(system_wq, &es8326->button_press_work, + queue_delayed_work(system_dfl_wq, &es8326->button_press_work, msecs_to_jiffies(35)); } else if (prev_button != cur_button) { /* mismatch, detect again */ prev_button = cur_button; - queue_delayed_work(system_wq, &es8326->button_press_work, + queue_delayed_work(system_dfl_wq, &es8326->button_press_work, msecs_to_jiffies(35)); } else { /* released or no pressed */ @@ -912,7 +912,7 @@ static void es8326_jack_detect_handler(struct work_struct *work) (ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON)); regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x1f); regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x0f, 0x0d); - queue_delayed_work(system_wq, &es8326->jack_detect_work, + queue_delayed_work(system_dfl_wq, &es8326->jack_detect_work, msecs_to_jiffies(400)); es8326->hp = 1; goto exit; @@ -923,7 +923,7 @@ static void es8326_jack_detect_handler(struct work_struct *work) regmap_write(es8326->regmap, ES8326_INT_SOURCE, (ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON)); es8326_enable_micbias(es8326->component); - queue_delayed_work(system_wq, &es8326->button_press_work, 10); + queue_delayed_work(system_dfl_wq, &es8326->button_press_work, 10); goto exit; } if ((iface & ES8326_HPBUTTON_FLAG) == 0x01) { @@ -958,10 +958,10 @@ static irqreturn_t es8326_irq(int irq, void *dev_id) goto out; if (es8326->jack->status & SND_JACK_HEADSET) - queue_delayed_work(system_wq, &es8326->jack_detect_work, + queue_delayed_work(system_dfl_wq, &es8326->jack_detect_work, msecs_to_jiffies(10)); else - queue_delayed_work(system_wq, &es8326->jack_detect_work, + queue_delayed_work(system_dfl_wq, &es8326->jack_detect_work, msecs_to_jiffies(300)); out: diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index 76159c45e6b5..1e11175cfbbb 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -142,7 +142,7 @@ static int es8328_set_deemph(struct snd_soc_component *component) static int es8328_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = es8328->deemph; @@ -152,7 +152,7 @@ static int es8328_get_deemph(struct snd_kcontrol *kcontrol, static int es8328_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; int ret; @@ -643,6 +643,8 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, static int es8328_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_ON: break; @@ -658,7 +660,7 @@ static int es8328_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_update_bits(component, ES8328_CONTROL1, ES8328_CONTROL1_VMIDSEL_MASK | ES8328_CONTROL1_ENREF, diff --git a/sound/soc/codecs/es8389.c b/sound/soc/codecs/es8389.c index 6e4c75d288ef..a84d79f9d3d1 100644 --- a/sound/soc/codecs/es8389.c +++ b/sound/soc/codecs/es8389.c @@ -57,8 +57,8 @@ static const DECLARE_TLV_DB_SCALE(alc_max_level, -3200, 200, 0); static int es8389_dmic_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct es8389_private *es8389 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; diff --git a/sound/soc/codecs/fs210x.c b/sound/soc/codecs/fs210x.c index e2f85714972d..e6195b71adad 100644 --- a/sound/soc/codecs/fs210x.c +++ b/sound/soc/codecs/fs210x.c @@ -924,7 +924,7 @@ static int fs210x_get_drvdata_from_kctrl(struct snd_kcontrol *kctrl, return -EINVAL; } - cmpnt = snd_soc_kcontrol_component(kctrl); + cmpnt = snd_kcontrol_chip(kctrl); if (!cmpnt) { pr_err("fs210x: component is null\n"); return -EINVAL; diff --git a/sound/soc/codecs/hda.c b/sound/soc/codecs/hda.c index ede980cc6050..237b0b060457 100644 --- a/sound/soc/codecs/hda.c +++ b/sound/soc/codecs/hda.c @@ -96,7 +96,7 @@ static int hda_codec_register_dais(struct hda_codec *codec, struct snd_soc_compo if (ret < 0) return ret; - dapm = snd_soc_component_get_dapm(component); + dapm = snd_soc_component_to_dapm(component); list_for_each_entry(pcm, &codec->pcm_list_head, list) { struct snd_soc_dai *dai; diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index afd8edf10fdc..680e341aa7f1 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -405,8 +405,6 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) { struct hdac_hda_priv *hda_pvt = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); struct hdac_device *hdev = &hda_pvt->codec->core; struct hda_codec *hcodec = hda_pvt->codec; struct hda_codec_driver *driver = hda_codec_to_driver(hcodec); @@ -470,7 +468,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) */ pm_runtime_get_noresume(&hdev->dev); - hcodec->bus->card = dapm->card->snd_card; + hcodec->bus->card = component->card->snd_card; ret = snd_hda_codec_set_name(hcodec, hcodec->preset->name); if (ret < 0) { diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index e50afd0bfcec..2652fcf2a3a3 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -769,7 +769,8 @@ static int hdac_hdmi_pin_output_widget_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kc, int event) { struct hdac_hdmi_port *port = w->priv; - struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); + struct device *dev = snd_soc_dapm_to_dev(w->dapm); + struct hdac_device *hdev = dev_to_hdac_dev(dev); struct hdac_hdmi_pcm *pcm; dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", @@ -814,7 +815,8 @@ static int hdac_hdmi_cvt_output_widget_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kc, int event) { struct hdac_hdmi_cvt *cvt = w->priv; - struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); + struct device *dev = snd_soc_dapm_to_dev(w->dapm); + struct hdac_device *hdev = dev_to_hdac_dev(dev); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); struct hdac_hdmi_pcm *pcm; @@ -869,7 +871,8 @@ static int hdac_hdmi_pin_mux_widget_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kc, int event) { struct hdac_hdmi_port *port = w->priv; - struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); + struct device *dev = snd_soc_dapm_to_dev(w->dapm); + struct hdac_device *hdev = dev_to_hdac_dev(dev); int mux_idx; dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", @@ -878,7 +881,7 @@ static int hdac_hdmi_pin_mux_widget_event(struct snd_soc_dapm_widget *w, if (!kc) kc = w->kcontrols[0]; - mux_idx = dapm_kcontrol_get_value(kc); + mux_idx = snd_soc_dapm_kcontrol_get_value(kc); /* set the device if pin is mst_capable */ if (hdac_hdmi_port_select_set(hdev, port) < 0) @@ -901,10 +904,11 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol, int ret; struct hdac_hdmi_port *p, *p_next; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_dapm_context *dapm = w->dapm; + struct device *dev = snd_soc_dapm_to_dev(dapm); struct hdac_hdmi_port *port = w->priv; - struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); + struct hdac_device *hdev = dev_to_hdac_dev(dev); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); struct hdac_hdmi_pcm *pcm; const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]]; @@ -1070,9 +1074,11 @@ static void hdac_hdmi_add_pinmux_cvt_route(struct hdac_device *hdev, */ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) { + struct device *dev = snd_soc_dapm_to_dev(dapm); + struct snd_soc_card *card = snd_soc_dapm_to_card(dapm); struct snd_soc_dapm_widget *widgets; struct snd_soc_dapm_route *route; - struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); + struct hdac_device *hdev = dev_to_hdac_dev(dev); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); struct snd_soc_dai_driver *dai_drv = hdmi->dai_drv; char widget_name[NAME_SIZE]; @@ -1083,7 +1089,7 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) if (list_empty(&hdmi->cvt_list) || list_empty(&hdmi->pin_list)) return -EINVAL; - widgets = devm_kzalloc(dapm->dev, (sizeof(*widgets) * + widgets = devm_kzalloc(dev, (sizeof(*widgets) * ((2 * hdmi->num_ports) + hdmi->num_cvt)), GFP_KERNEL); @@ -1093,7 +1099,7 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) /* DAPM widgets to represent each converter widget */ list_for_each_entry(cvt, &hdmi->cvt_list, head) { sprintf(widget_name, "Converter %d", cvt->nid); - ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], + ret = hdac_hdmi_fill_widget_info(dev, &widgets[i], snd_soc_dapm_aif_in, cvt, widget_name, dai_drv[i].playback.stream_name, NULL, 0, hdac_hdmi_cvt_output_widget_event, @@ -1107,7 +1113,7 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) for (j = 0; j < pin->num_ports; j++) { sprintf(widget_name, "hif%d-%d Output", pin->nid, pin->ports[j].id); - ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], + ret = hdac_hdmi_fill_widget_info(dev, &widgets[i], snd_soc_dapm_output, &pin->ports[j], widget_name, NULL, NULL, 0, hdac_hdmi_pin_output_widget_event, @@ -1140,7 +1146,7 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) } } - route = devm_kzalloc(dapm->dev, (sizeof(*route) * num_routes), + route = devm_kzalloc(dev, (sizeof(*route) * num_routes), GFP_KERNEL); if (!route) return -ENOMEM; @@ -1166,7 +1172,7 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) ((2 * hdmi->num_ports) + hdmi->num_cvt)); snd_soc_dapm_add_routes(dapm, route, num_routes); - snd_soc_dapm_new_widgets(dapm->card); + snd_soc_dapm_new_widgets(card); return 0; @@ -1666,8 +1672,7 @@ static int hdmi_codec_probe(struct snd_soc_component *component) { struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); struct hdac_device *hdev = hdmi->hdev; - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct hdac_ext_link *hlink; int ret; @@ -1698,7 +1703,7 @@ static int hdmi_codec_probe(struct snd_soc_component *component) hdac_hdmi_present_sense_all_pins(hdev, hdmi, true); /* Imp: Store the card pointer in hda_codec */ - hdmi->card = dapm->card->snd_card; + hdmi->card = component->card->snd_card; /* * Setup a device_link between card device and HDMI codec device. diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index e1933f733af1..13ae9e83bc21 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -908,7 +908,7 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai) }; int ret, i; - dapm = snd_soc_component_get_dapm(dai->component); + dapm = snd_soc_component_to_dapm(dai->component); /* One of the directions might be omitted for unidirectional DAIs */ for (i = 0; i < ARRAY_SIZE(route); i++) { diff --git a/sound/soc/codecs/idt821034.c b/sound/soc/codecs/idt821034.c index cab2f2eecdfb..39bafefa6a18 100644 --- a/sound/soc/codecs/idt821034.c +++ b/sound/soc/codecs/idt821034.c @@ -402,7 +402,7 @@ static int idt821034_kctrl_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component); int min = mc->min; int max = mc->max; @@ -433,7 +433,7 @@ static int idt821034_kctrl_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component); struct idt821034_amp *amp; int min = mc->min; @@ -487,7 +487,7 @@ end: static int idt821034_kctrl_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component); int id = kcontrol->private_value; bool is_muted; @@ -509,7 +509,7 @@ static int idt821034_kctrl_mute_get(struct snd_kcontrol *kcontrol, static int idt821034_kctrl_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component); int id = kcontrol->private_value; struct idt821034_amp *amp; diff --git a/sound/soc/codecs/jz4740.c b/sound/soc/codecs/jz4740.c index d1cea93bdb59..d3d801d850a1 100644 --- a/sound/soc/codecs/jz4740.c +++ b/sound/soc/codecs/jz4740.c @@ -231,6 +231,7 @@ static void jz4740_codec_wakeup(struct regmap *regmap) static int jz4740_codec_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct jz4740_codec *jz4740_codec = snd_soc_component_get_drvdata(component); struct regmap *regmap = jz4740_codec->regmap; unsigned int mask; @@ -247,7 +248,7 @@ static int jz4740_codec_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: /* The only way to clear the suspend flag is to reset the codec */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) jz4740_codec_wakeup(regmap); mask = JZ4740_CODEC_1_VREF_DISABLE | diff --git a/sound/soc/codecs/jz4760.c b/sound/soc/codecs/jz4760.c index e04af1b9ace8..344c251be397 100644 --- a/sound/soc/codecs/jz4760.c +++ b/sound/soc/codecs/jz4760.c @@ -197,7 +197,7 @@ static int jz4760_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *codec = dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec); int ret = 0; /* @@ -214,7 +214,7 @@ static void jz4760_codec_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *codec = dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) snd_soc_dapm_disable_pin(dapm, "SYSCLK"); @@ -225,6 +225,7 @@ static int jz4760_codec_pcm_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_component *codec = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec); int ret = 0; switch (cmd) { @@ -232,7 +233,7 @@ static int jz4760_codec_pcm_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) - snd_soc_component_force_bias_level(codec, SND_SOC_BIAS_ON); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_ON); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: diff --git a/sound/soc/codecs/jz4770.c b/sound/soc/codecs/jz4770.c index 312202ab5cea..6b86d47028d7 100644 --- a/sound/soc/codecs/jz4770.c +++ b/sound/soc/codecs/jz4770.c @@ -217,7 +217,7 @@ static int jz4770_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *codec = dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec); /* * SYSCLK output from the codec to the AIC is required to keep the @@ -234,7 +234,7 @@ static void jz4770_codec_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *codec = dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) snd_soc_dapm_disable_pin(dapm, "SYSCLK"); @@ -245,6 +245,7 @@ static int jz4770_codec_pcm_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_component *codec = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec); int ret = 0; switch (cmd) { @@ -252,8 +253,7 @@ static int jz4770_codec_pcm_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) - snd_soc_component_force_bias_level(codec, - SND_SOC_BIAS_ON); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_ON); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c index ab89af7965bf..043030509795 100644 --- a/sound/soc/codecs/lm49453.c +++ b/sound/soc/codecs/lm49453.c @@ -1255,6 +1255,7 @@ static int lm49453_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct lm49453_priv *lm49453 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -1262,7 +1263,7 @@ static int lm49453_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) regcache_sync(lm49453->regmap); snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG, diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index a8fc842cc94e..0a8de5620e72 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -1682,7 +1682,7 @@ static const struct regmap_config rx_regmap_config = { static int rx_macro_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct rx_macro *rx = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -1905,52 +1905,48 @@ static int rx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream) { struct snd_soc_component *component = dai->component; struct rx_macro *rx = snd_soc_component_get_drvdata(component); - uint16_t j, reg, mix_reg, dsm_reg; - u16 int_mux_cfg0, int_mux_cfg1; + u32 port, j, reg, mix_reg, int_mux_cfg0, int_mux_cfg1; + u32 mask, val; u8 int_mux_cfg0_val, int_mux_cfg1_val; - switch (dai->id) { - case RX_MACRO_AIF1_PB: - case RX_MACRO_AIF2_PB: - case RX_MACRO_AIF3_PB: - case RX_MACRO_AIF4_PB: - for (j = 0; j < INTERP_MAX; j++) { - reg = CDC_RX_RXn_RX_PATH_CTL(rx, j); - mix_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(rx, j); - dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, j); - - if (mute) { - snd_soc_component_update_bits(component, reg, - CDC_RX_PATH_PGA_MUTE_MASK, - CDC_RX_PATH_PGA_MUTE_ENABLE); - snd_soc_component_update_bits(component, mix_reg, - CDC_RX_PATH_PGA_MUTE_MASK, - CDC_RX_PATH_PGA_MUTE_ENABLE); - } else { - snd_soc_component_update_bits(component, reg, - CDC_RX_PATH_PGA_MUTE_MASK, 0x0); - snd_soc_component_update_bits(component, mix_reg, - CDC_RX_PATH_PGA_MUTE_MASK, 0x0); + if (stream != SNDRV_PCM_STREAM_PLAYBACK) + return 0; + + for (j = 0; j < INTERP_MAX; j++) { + reg = CDC_RX_RXn_RX_PATH_CTL(rx, j); + mix_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(rx, j); + + mask = CDC_RX_PATH_PGA_MUTE_MASK; + val = 0; + if (mute) + val |= CDC_RX_PATH_PGA_MUTE_ENABLE; + if (rx->main_clk_users[j] > 0) { + mask |= CDC_RX_PATH_CLK_EN_MASK; + val |= CDC_RX_PATH_CLK_ENABLE; + } + + int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + j * 8; + int_mux_cfg1 = int_mux_cfg0 + 4; + int_mux_cfg0_val = snd_soc_component_read(component, int_mux_cfg0); + int_mux_cfg1_val = snd_soc_component_read(component, int_mux_cfg1); + + for_each_set_bit(port, &rx->active_ch_mask[dai->id], RX_MACRO_PORTS_MAX) { + if (((int_mux_cfg0_val & 0x0f) == port + INTn_1_INP_SEL_RX0) || + ((int_mux_cfg0_val >> 4) == port + INTn_1_INP_SEL_RX0) || + ((int_mux_cfg1_val >> 4) == port + INTn_1_INP_SEL_RX0)) { + snd_soc_component_update_bits(component, reg, mask, val); } - int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + j * 8; - int_mux_cfg1 = int_mux_cfg0 + 4; - int_mux_cfg0_val = snd_soc_component_read(component, int_mux_cfg0); - int_mux_cfg1_val = snd_soc_component_read(component, int_mux_cfg1); - - if (snd_soc_component_read(component, dsm_reg) & 0x01) { - if (int_mux_cfg0_val || (int_mux_cfg1_val & 0xF0)) - snd_soc_component_update_bits(component, reg, 0x20, 0x20); - if (int_mux_cfg1_val & 0x0F) { - snd_soc_component_update_bits(component, reg, 0x20, 0x20); - snd_soc_component_update_bits(component, mix_reg, 0x20, - 0x20); + if ((int_mux_cfg1_val & 0x0f) == port + INTn_2_INP_SEL_RX0) { + snd_soc_component_update_bits(component, mix_reg, mask, val); + /* main clock needs to be enabled for mix to be useful: */ + if (rx->main_clk_users[j] > 0) { + snd_soc_component_update_bits(component, reg, + CDC_RX_PATH_CLK_EN_MASK, + CDC_RX_PATH_CLK_ENABLE); } } } - break; - default: - break; } return 0; } @@ -2434,8 +2430,7 @@ static void rx_macro_hd2_control(struct snd_soc_component *component, static int rx_macro_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; struct rx_macro *rx = snd_soc_component_get_drvdata(component); @@ -2446,7 +2441,7 @@ static int rx_macro_get_compander(struct snd_kcontrol *kcontrol, static int rx_macro_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; struct rx_macro *rx = snd_soc_component_get_drvdata(component); @@ -2459,7 +2454,7 @@ static int rx_macro_set_compander(struct snd_kcontrol *kcontrol, static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct rx_macro *rx = snd_soc_component_get_drvdata(component); @@ -2471,7 +2466,7 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; @@ -2548,7 +2543,7 @@ static const struct snd_kcontrol_new rx_macro_rx5_mux = static int rx_macro_get_ear_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rx->is_ear_mode_on; @@ -2558,7 +2553,7 @@ static int rx_macro_get_ear_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_ear_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->is_ear_mode_on = (!ucontrol->value.integer.value[0] ? false : true); @@ -2568,7 +2563,7 @@ static int rx_macro_put_ear_mode(struct snd_kcontrol *kcontrol, static int rx_macro_get_hph_hd2_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rx->hph_hd2_mode; @@ -2578,7 +2573,7 @@ static int rx_macro_get_hph_hd2_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_hph_hd2_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->hph_hd2_mode = ucontrol->value.integer.value[0]; @@ -2588,7 +2583,7 @@ static int rx_macro_put_hph_hd2_mode(struct snd_kcontrol *kcontrol, static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = rx->hph_pwr_mode; @@ -2598,7 +2593,7 @@ static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->hph_pwr_mode = ucontrol->value.enumerated.item[0]; @@ -2608,7 +2603,7 @@ static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, static int rx_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rx->is_softclip_on; @@ -2619,7 +2614,7 @@ static int rx_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, static int rx_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->is_softclip_on = ucontrol->value.integer.value[0]; @@ -2630,7 +2625,7 @@ static int rx_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, static int rx_macro_aux_hpf_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rx->is_aux_hpf_on; @@ -2641,7 +2636,7 @@ static int rx_macro_aux_hpf_mode_get(struct snd_kcontrol *kcontrol, static int rx_macro_aux_hpf_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); rx->is_aux_hpf_on = ucontrol->value.integer.value[0]; @@ -2930,8 +2925,7 @@ static int rx_macro_put_iir_band_audio_mixer( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd_iir_filter_ctl *ctl = (struct wcd_iir_filter_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -2959,8 +2953,7 @@ static int rx_macro_put_iir_band_audio_mixer( static int rx_macro_get_iir_band_audio_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd_iir_filter_ctl *ctl = (struct wcd_iir_filter_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -3612,7 +3605,7 @@ static const struct snd_soc_dapm_route rx_audio_map[] = { static int rx_macro_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rx_macro *rx = snd_soc_component_get_drvdata(component); const struct snd_soc_dapm_widget *widgets; const struct snd_kcontrol_new *controls; @@ -3955,6 +3948,9 @@ static const struct of_device_id rx_macro_dt_match[] = { .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, }, { + .compatible = "qcom,sm6115-lpass-rx-macro", + .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, + }, { .compatible = "qcom,sm8250-lpass-rx-macro", .data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK, }, { diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index 1da34cb3505f..f7d168f557dd 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -800,7 +800,7 @@ static void tx_macro_update_smic_sel_v9_2(struct snd_soc_component *component, static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct tx_macro *tx = snd_soc_component_get_drvdata(component); @@ -859,7 +859,7 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; u32 dai_id = widget->shift; @@ -877,7 +877,7 @@ static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct snd_soc_dapm_update *update = NULL; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1070,7 +1070,7 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tx_macro *tx = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; @@ -1083,7 +1083,7 @@ static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol, static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int value = ucontrol->value.integer.value[0]; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; @@ -1100,7 +1100,7 @@ static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol, static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tx_macro *tx = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tx->bcs_enable; @@ -1111,7 +1111,7 @@ static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol, static int tx_macro_set_bcs(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int value = ucontrol->value.integer.value[0]; struct tx_macro *tx = snd_soc_component_get_drvdata(component); @@ -2081,7 +2081,7 @@ static const struct snd_kcontrol_new tx_macro_snd_controls[] = { static int tx_macro_component_extend(struct snd_soc_component *comp) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(comp); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(comp); struct tx_macro *tx = snd_soc_component_get_drvdata(comp); int ret; @@ -2473,7 +2473,8 @@ static const struct tx_macro_data lpass_ver_9_2 = { }; static const struct tx_macro_data lpass_ver_10_sm6115 = { - .flags = LPASS_MACRO_FLAG_HAS_NPL_CLOCK, + .flags = LPASS_MACRO_FLAG_HAS_NPL_CLOCK | + LPASS_MACRO_FLAG_RESET_SWR, .ver = LPASS_VER_10_0_0, .extra_widgets = tx_macro_dapm_widgets_v9_2, .extra_widgets_num = ARRAY_SIZE(tx_macro_dapm_widgets_v9_2), diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c index 92c177b82a02..528d5b167ecf 100644 --- a/sound/soc/codecs/lpass-va-macro.c +++ b/sound/soc/codecs/lpass-va-macro.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/init.h> @@ -64,8 +65,15 @@ #define CDC_VA_TOP_CSR_I2S_CLK (0x00A8) #define CDC_VA_TOP_CSR_I2S_RESET (0x00AC) #define CDC_VA_TOP_CSR_CORE_ID_0 (0x00C0) + #define CORE_ID_0_REV_MAJ GENMASK(7, 0) #define CDC_VA_TOP_CSR_CORE_ID_1 (0x00C4) +#define CORE_ID_1_HAS_WSAMACRO BIT(0) +#define CORE_ID_1_HAS_RXMACRO BIT(1) +#define CORE_ID_1_HAS_TXMACRO BIT(2) +#define CORE_ID_1_HAS_VAMACRO BIT(3) #define CDC_VA_TOP_CSR_CORE_ID_2 (0x00C8) + #define CORE_ID_2_REV_MIN GENMASK(7, 4) + #define CORE_ID_2_REV_STEP GENMASK(3, 0) #define CDC_VA_TOP_CSR_CORE_ID_3 (0x00CC) #define CDC_VA_TOP_CSR_SWR_MIC_CTL0 (0x00D0) #define CDC_VA_TOP_CSR_SWR_MIC_CTL1 (0x00D4) @@ -516,8 +524,7 @@ static int va_macro_mclk_event(struct snd_soc_dapm_widget *w, static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -556,8 +563,7 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol, static int va_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_mixer_control *mc = @@ -577,8 +583,7 @@ static int va_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct snd_soc_dapm_update *update = NULL; @@ -819,7 +824,7 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w, static int va_macro_dec_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct va_macro *va = snd_soc_component_get_drvdata(comp); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; @@ -832,7 +837,7 @@ static int va_macro_dec_mode_get(struct snd_kcontrol *kcontrol, static int va_macro_dec_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); int value = ucontrol->value.enumerated.item[0]; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; @@ -1462,39 +1467,63 @@ undefined_rate: return dmic_sample_rate; } -static void va_macro_set_lpass_codec_version(struct va_macro *va) +static int va_macro_set_lpass_codec_version(struct va_macro *va) { - int core_id_0 = 0, core_id_1 = 0, core_id_2 = 0; int version = LPASS_CODEC_VERSION_UNKNOWN; + u32 maj, min, step; + u32 val; - regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_0, &core_id_0); - regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_1, &core_id_1); - regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_2, &core_id_2); + regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_0, &val); + maj = FIELD_GET(CORE_ID_0_REV_MAJ, val); - if ((core_id_0 == 0x01) && (core_id_1 == 0x0F)) - version = LPASS_CODEC_VERSION_2_0; - if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && core_id_2 == 0x01) + regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_1, &val); + if (!FIELD_GET(CORE_ID_1_HAS_VAMACRO, val)) { + dev_err(va->dev, "This is not a VA macro instance\n"); + return -ENODEV; + } + + regmap_read(va->regmap, CDC_VA_TOP_CSR_CORE_ID_2, &val); + min = FIELD_GET(CORE_ID_2_REV_MIN, val); + step = FIELD_GET(CORE_ID_2_REV_STEP, val); + + if (maj == 1) { version = LPASS_CODEC_VERSION_2_0; - if ((core_id_0 == 0x02) && (core_id_1 == 0x0E)) - version = LPASS_CODEC_VERSION_2_1; - if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x50 || core_id_2 == 0x51)) - version = LPASS_CODEC_VERSION_2_5; - if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x60 || core_id_2 == 0x61)) - version = LPASS_CODEC_VERSION_2_6; - if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x70 || core_id_2 == 0x71)) - version = LPASS_CODEC_VERSION_2_7; - if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x80 || core_id_2 == 0x81)) - version = LPASS_CODEC_VERSION_2_8; - if ((core_id_0 == 0x02) && (core_id_1 == 0x0F) && (core_id_2 == 0x90 || core_id_2 == 0x91)) - version = LPASS_CODEC_VERSION_2_9; - - if (version == LPASS_CODEC_VERSION_UNKNOWN) - dev_warn(va->dev, "Unknown Codec version, ID: %02x / %02x / %02x\n", - core_id_0, core_id_1, core_id_2); + } else if (maj == 2) { + switch (min) { + case 0: + version = LPASS_CODEC_VERSION_2_0; + break; + case 5: + version = LPASS_CODEC_VERSION_2_5; + break; + case 6: + version = LPASS_CODEC_VERSION_2_6; + break; + case 7: + version = LPASS_CODEC_VERSION_2_7; + break; + case 8: + version = LPASS_CODEC_VERSION_2_8; + break; + case 9: + version = LPASS_CODEC_VERSION_2_9; + break; + default: + break; + } + } + + if (version == LPASS_CODEC_VERSION_UNKNOWN) { + dev_err(va->dev, "VA Macro v%u.%u.%u is not supported\n", + maj, min, step); + return -EOPNOTSUPP; + } lpass_macro_set_codec_version(version); dev_dbg(va->dev, "LPASS Codec Version %s\n", lpass_macro_get_codec_version_string(version)); + + return 0; } static int va_macro_probe(struct platform_device *pdev) @@ -1594,10 +1623,14 @@ static int va_macro_probe(struct platform_device *pdev) * old version of codecs do not have a reliable way to determine the * version from registers, get them from soc specific data */ - if (data->version) + if (data->version) { lpass_macro_set_codec_version(data->version); - else /* read version from register */ - va_macro_set_lpass_codec_version(va); + } else { + /* read version from register */ + ret = va_macro_set_lpass_codec_version(va); + if (ret) + goto err_clkout; + } if (va->has_swr_master) { /* Set default CLK div to 1 */ @@ -1723,6 +1756,7 @@ static const struct dev_pm_ops va_macro_pm_ops = { static const struct of_device_id va_macro_dt_match[] = { { .compatible = "qcom,sc7280-lpass-va-macro", .data = &sm8250_va_data }, + { .compatible = "qcom,sm6115-lpass-va-macro", .data = &sm8450_va_data }, { .compatible = "qcom,sm8250-lpass-va-macro", .data = &sm8250_va_data }, { .compatible = "qcom,sm8450-lpass-va-macro", .data = &sm8450_va_data }, { .compatible = "qcom,sm8550-lpass-va-macro", .data = &sm8550_va_data }, diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index 38faa9074ca3..b695c77c18ac 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -297,8 +297,7 @@ enum { enum { WSA_MACRO_RX0 = 0, WSA_MACRO_RX1, - WSA_MACRO_RX_MIX, - WSA_MACRO_RX_MIX0 = WSA_MACRO_RX_MIX, + WSA_MACRO_RX_MIX0, WSA_MACRO_RX_MIX1, WSA_MACRO_RX_MAX, }; @@ -1168,12 +1167,6 @@ static int wsa_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, for_each_set_bit(port, &wsa->active_ch_mask[dai->id], WSA_MACRO_RX_MAX) { int_1_mix1_inp = port; - if ((int_1_mix1_inp < WSA_MACRO_RX0) || (int_1_mix1_inp > WSA_MACRO_RX_MIX1)) { - dev_err(component->dev, "%s: Invalid RX port, Dai ID is %d\n", - __func__, dai->id); - return -EINVAL; - } - int_mux_cfg0 = CDC_WSA_RX_INP_MUX_RX_INT0_CFG0; /* @@ -1220,11 +1213,6 @@ static int wsa_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, for_each_set_bit(port, &wsa->active_ch_mask[dai->id], WSA_MACRO_RX_MAX) { int_2_inp = port; - if ((int_2_inp < WSA_MACRO_RX0) || (int_2_inp > WSA_MACRO_RX_MIX1)) { - dev_err(component->dev, "%s: Invalid RX port, Dai ID is %d\n", - __func__, dai->id); - return -EINVAL; - } int_mux_cfg1 = CDC_WSA_RX_INP_MUX_RX_INT0_CFG1; for (j = 0; j < NUM_INTERPOLATORS; j++) { @@ -1574,41 +1562,6 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_dapm_widget *w, return 0; } -static int wsa_macro_enable_mix_path(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - u16 path_reg, gain_reg; - int val; - - switch (w->shift) { - case WSA_MACRO_RX_MIX0: - path_reg = CDC_WSA_RX0_RX_PATH_MIX_CTL; - gain_reg = CDC_WSA_RX0_RX_VOL_MIX_CTL; - break; - case WSA_MACRO_RX_MIX1: - path_reg = CDC_WSA_RX1_RX_PATH_MIX_CTL; - gain_reg = CDC_WSA_RX1_RX_VOL_MIX_CTL; - break; - default: - return 0; - } - - switch (event) { - case SND_SOC_DAPM_POST_PMU: - val = snd_soc_component_read(component, gain_reg); - snd_soc_component_write(component, gain_reg, val); - break; - case SND_SOC_DAPM_POST_PMD: - snd_soc_component_update_bits(component, path_reg, - CDC_WSA_RX_PATH_MIX_CLK_EN_MASK, - CDC_WSA_RX_PATH_MIX_CLK_DISABLE); - break; - } - - return 0; -} - static void wsa_macro_hd2_control(struct snd_soc_component *component, u16 reg, int event) { @@ -1772,59 +1725,6 @@ static int wsa_macro_config_softclip(struct snd_soc_component *component, return 0; } -static bool wsa_macro_adie_lb(struct snd_soc_component *component, - int interp_idx) -{ - struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); - u16 int_mux_cfg0, int_mux_cfg1; - u8 int_n_inp0, int_n_inp1, int_n_inp2; - - int_mux_cfg0 = CDC_WSA_RX_INP_MUX_RX_INT0_CFG0 + interp_idx * 8; - int_mux_cfg1 = int_mux_cfg0 + 4; - - int_n_inp0 = snd_soc_component_read_field(component, int_mux_cfg0, - wsa->reg_layout->rx_intx_1_mix_inp0_sel_mask); - if (int_n_inp0 == INTn_1_INP_SEL_DEC0 || - int_n_inp0 == INTn_1_INP_SEL_DEC1) - return true; - - int_n_inp1 = snd_soc_component_read_field(component, int_mux_cfg0, - wsa->reg_layout->rx_intx_1_mix_inp1_sel_mask); - if (int_n_inp1 == INTn_1_INP_SEL_DEC0 || - int_n_inp1 == INTn_1_INP_SEL_DEC1) - return true; - - int_n_inp2 = snd_soc_component_read_field(component, int_mux_cfg1, - wsa->reg_layout->rx_intx_1_mix_inp2_sel_mask); - if (int_n_inp2 == INTn_1_INP_SEL_DEC0 || - int_n_inp2 == INTn_1_INP_SEL_DEC1) - return true; - - return false; -} - -static int wsa_macro_enable_main_path(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, - int event) -{ - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - u16 reg; - - reg = CDC_WSA_RX0_RX_PATH_CTL + WSA_MACRO_RX_PATH_OFFSET * w->shift; - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - if (wsa_macro_adie_lb(component, w->shift)) { - snd_soc_component_update_bits(component, reg, - CDC_WSA_RX_PATH_CLK_EN_MASK, - CDC_WSA_RX_PATH_CLK_ENABLE); - } - break; - default: - break; - } - return 0; -} - static int wsa_macro_interp_get_primary_reg(u16 reg, u16 *ind) { u16 prim_int_reg = 0; @@ -1942,7 +1842,6 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w, struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u16 gain_reg; u16 reg; - int val; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); if (w->shift == WSA_MACRO_COMP1) { @@ -1982,8 +1881,6 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w, CDC_WSA_RX_PGA_HALF_DB_MASK, CDC_WSA_RX_PGA_HALF_DB_ENABLE); } - val = snd_soc_component_read(component, gain_reg); - snd_soc_component_write(component, gain_reg, val); wsa_macro_config_ear_spkr_gain(component, wsa, event, gain_reg); break; @@ -2114,7 +2011,7 @@ static int wsa_macro_get_ec_hq(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int ec_tx = ((struct soc_mixer_control *) kcontrol->private_value)->shift; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -2126,7 +2023,7 @@ static int wsa_macro_get_ec_hq(struct snd_kcontrol *kcontrol, static int wsa_macro_set_ec_hq(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int ec_tx = ((struct soc_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -2140,7 +2037,7 @@ static int wsa_macro_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -2151,7 +2048,7 @@ static int wsa_macro_get_compander(struct snd_kcontrol *kcontrol, static int wsa_macro_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -2164,7 +2061,7 @@ static int wsa_macro_set_compander(struct snd_kcontrol *kcontrol, static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wsa->ear_spkr_gain; @@ -2175,7 +2072,7 @@ static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, static int wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); wsa->ear_spkr_gain = ucontrol->value.integer.value[0]; @@ -2186,8 +2083,7 @@ static int wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol, static int wsa_macro_rx_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -2200,8 +2096,7 @@ static int wsa_macro_rx_mux_get(struct snd_kcontrol *kcontrol, static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -2259,7 +2154,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol, static int wsa_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); int path = ((struct soc_mixer_control *)kcontrol->private_value)->shift; @@ -2271,7 +2166,7 @@ static int wsa_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, static int wsa_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); int path = ((struct soc_mixer_control *) kcontrol->private_value)->shift; @@ -2297,6 +2192,10 @@ static const struct snd_kcontrol_new wsa_macro_snd_controls[] = { -84, 40, digital_gain), SOC_SINGLE_S8_TLV("WSA_RX1 Digital Volume", CDC_WSA_RX1_RX_VOL_CTL, -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("WSA_RX0_MIX Digital Volume", CDC_WSA_RX0_RX_VOL_MIX_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("WSA_RX1_MIX Digital Volume", CDC_WSA_RX1_RX_VOL_MIX_CTL, + -84, 40, digital_gain), SOC_SINGLE("WSA_RX0 Digital Mute", CDC_WSA_RX0_RX_PATH_CTL, 4, 1, 0), SOC_SINGLE("WSA_RX1 Digital Mute", CDC_WSA_RX1_RX_PATH_CTL, 4, 1, 0), @@ -2331,7 +2230,7 @@ static const struct snd_kcontrol_new rx_mux[WSA_MACRO_RX_MAX] = { static int wsa_macro_vi_feed_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -2349,7 +2248,7 @@ static int wsa_macro_vi_feed_mixer_get(struct snd_kcontrol *kcontrol, static int wsa_macro_vi_feed_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -2440,10 +2339,8 @@ static const struct snd_soc_dapm_widget wsa_macro_dapm_widgets[] = { SND_SOC_DAPM_MIXER("WSA RX_MIX0", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("WSA RX_MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), - SND_SOC_DAPM_MIXER_E("WSA_RX INT0 MIX", SND_SOC_NOPM, 0, 0, NULL, 0, - wsa_macro_enable_main_path, SND_SOC_DAPM_PRE_PMU), - SND_SOC_DAPM_MIXER_E("WSA_RX INT1 MIX", SND_SOC_NOPM, 1, 0, NULL, 0, - wsa_macro_enable_main_path, SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_MIXER("WSA_RX INT0 MIX", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("WSA_RX INT1 MIX", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("WSA_RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("WSA_RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), @@ -2494,30 +2391,22 @@ static const struct snd_soc_dapm_widget wsa_macro_dapm_widgets_v2_1[] = { SND_SOC_DAPM_MUX("WSA_RX0 INP0", SND_SOC_NOPM, 0, 0, &rx0_prim_inp0_mux_v2_1), SND_SOC_DAPM_MUX("WSA_RX0 INP1", SND_SOC_NOPM, 0, 0, &rx0_prim_inp1_mux_v2_1), SND_SOC_DAPM_MUX("WSA_RX0 INP2", SND_SOC_NOPM, 0, 0, &rx0_prim_inp2_mux_v2_1), - SND_SOC_DAPM_MUX_E("WSA_RX0 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX0, - 0, &rx0_mix_mux_v2_1, wsa_macro_enable_mix_path, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX("WSA_RX0 MIX INP", SND_SOC_NOPM, 0, 0, &rx0_mix_mux_v2_1), SND_SOC_DAPM_MUX("WSA_RX1 INP0", SND_SOC_NOPM, 0, 0, &rx1_prim_inp0_mux_v2_1), SND_SOC_DAPM_MUX("WSA_RX1 INP1", SND_SOC_NOPM, 0, 0, &rx1_prim_inp1_mux_v2_1), SND_SOC_DAPM_MUX("WSA_RX1 INP2", SND_SOC_NOPM, 0, 0, &rx1_prim_inp2_mux_v2_1), - SND_SOC_DAPM_MUX_E("WSA_RX1 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX1, - 0, &rx1_mix_mux_v2_1, wsa_macro_enable_mix_path, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX("WSA_RX1 MIX INP", SND_SOC_NOPM, 0, 0, &rx1_mix_mux_v2_1), }; static const struct snd_soc_dapm_widget wsa_macro_dapm_widgets_v2_5[] = { SND_SOC_DAPM_MUX("WSA_RX0 INP0", SND_SOC_NOPM, 0, 0, &rx0_prim_inp0_mux_v2_5), SND_SOC_DAPM_MUX("WSA_RX0 INP1", SND_SOC_NOPM, 0, 0, &rx0_prim_inp1_mux_v2_5), SND_SOC_DAPM_MUX("WSA_RX0 INP2", SND_SOC_NOPM, 0, 0, &rx0_prim_inp2_mux_v2_5), - SND_SOC_DAPM_MUX_E("WSA_RX0 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX0, - 0, &rx0_mix_mux_v2_5, wsa_macro_enable_mix_path, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX("WSA_RX0 MIX INP", SND_SOC_NOPM, 0, 0, &rx0_mix_mux_v2_5), SND_SOC_DAPM_MUX("WSA_RX1 INP0", SND_SOC_NOPM, 0, 0, &rx1_prim_inp0_mux_v2_5), SND_SOC_DAPM_MUX("WSA_RX1 INP1", SND_SOC_NOPM, 0, 0, &rx1_prim_inp1_mux_v2_5), SND_SOC_DAPM_MUX("WSA_RX1 INP2", SND_SOC_NOPM, 0, 0, &rx1_prim_inp2_mux_v2_5), - SND_SOC_DAPM_MUX_E("WSA_RX1 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX1, - 0, &rx1_mix_mux_v2_5, wsa_macro_enable_mix_path, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX("WSA_RX1 MIX INP", SND_SOC_NOPM, 0, 0, &rx1_mix_mux_v2_5), }; static const struct snd_soc_dapm_route wsa_audio_map[] = { @@ -2553,10 +2442,8 @@ static const struct snd_soc_dapm_route wsa_audio_map[] = { {"WSA RX_MIX0", NULL, "WSA RX_MIX0 MUX"}, {"WSA RX_MIX1", NULL, "WSA RX_MIX1 MUX"}, - {"WSA RX0", NULL, "WSA_RX0_CLK"}, - {"WSA RX1", NULL, "WSA_RX1_CLK"}, - {"WSA RX_MIX0", NULL, "WSA_RX_MIX0_CLK"}, - {"WSA RX_MIX1", NULL, "WSA_RX_MIX1_CLK"}, + {"WSA_RX INT0 MIX", NULL, "WSA_RX0_CLK"}, + {"WSA_RX INT1 MIX", NULL, "WSA_RX1_CLK"}, {"WSA_RX0 INP0", "RX0", "WSA RX0"}, {"WSA_RX0 INP0", "RX1", "WSA RX1"}, @@ -2586,6 +2473,8 @@ static const struct snd_soc_dapm_route wsa_audio_map[] = { {"WSA_RX0 MIX INP", "RX1", "WSA RX1"}, {"WSA_RX0 MIX INP", "RX_MIX0", "WSA RX_MIX0"}, {"WSA_RX0 MIX INP", "RX_MIX1", "WSA RX_MIX1"}, + {"WSA_RX0 MIX INP", NULL, "WSA_RX0_CLK"}, + {"WSA_RX0 MIX INP", NULL, "WSA_RX_MIX0_CLK"}, {"WSA_RX INT0 SEC MIX", NULL, "WSA_RX0 MIX INP"}, {"WSA_RX INT0 SEC MIX", NULL, "WSA_RX INT0 MIX"}, @@ -2625,6 +2514,8 @@ static const struct snd_soc_dapm_route wsa_audio_map[] = { {"WSA_RX1 MIX INP", "RX1", "WSA RX1"}, {"WSA_RX1 MIX INP", "RX_MIX0", "WSA RX_MIX0"}, {"WSA_RX1 MIX INP", "RX_MIX1", "WSA RX_MIX1"}, + {"WSA_RX1 MIX INP", NULL, "WSA_RX1_CLK"}, + {"WSA_RX1 MIX INP", NULL, "WSA_RX_MIX1_CLK"}, {"WSA_RX INT1 SEC MIX", NULL, "WSA_RX1 MIX INP"}, {"WSA_RX INT1 SEC MIX", NULL, "WSA_RX INT1 MIX"}, @@ -2665,7 +2556,7 @@ static int wsa_swrm_clock(struct wsa_macro *wsa, bool enable) static int wsa_macro_component_probe(struct snd_soc_component *comp) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(comp); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(comp); struct wsa_macro *wsa = snd_soc_component_get_drvdata(comp); const struct snd_soc_dapm_widget *widgets; unsigned int num_widgets; diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index bc3470cf2c54..98d72db599d8 100644 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -541,10 +541,8 @@ EXPORT_SYMBOL_GPL(madera_domain_clk_ev); int madera_out1_demux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct madera *madera = priv->madera; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -632,8 +630,7 @@ EXPORT_SYMBOL_GPL(madera_out1_demux_put); int madera_out1_demux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); unsigned int val; val = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1); @@ -648,10 +645,8 @@ EXPORT_SYMBOL_GPL(madera_out1_demux_get); static int madera_inmux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct madera *madera = priv->madera; struct regmap *regmap = madera->regmap; @@ -873,8 +868,7 @@ static bool madera_can_change_grp_rate(const struct madera_priv *priv, static int madera_adsp_rate_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int cached_rate; @@ -894,8 +888,7 @@ static int madera_adsp_rate_get(struct snd_kcontrol *kcontrol, static int madera_adsp_rate_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; const int adsp_num = e->shift_l; @@ -1054,8 +1047,7 @@ EXPORT_SYMBOL_GPL(madera_set_adsp_clk); int madera_rate_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int item = ucontrol->value.enumerated.item[0]; @@ -1214,8 +1206,7 @@ int madera_init_outputs(struct snd_soc_component *component, const struct snd_soc_dapm_route *routes, int n_mono_routes, int n_real) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct madera *madera = priv->madera; const struct madera_codec_pdata *pdata = &madera->pdata.codec; @@ -2163,10 +2154,8 @@ EXPORT_SYMBOL_GPL(madera_output_anc_src); int madera_dfc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int reg = e->reg; unsigned int val; @@ -2196,10 +2185,8 @@ int madera_lp_mode_put(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int val, mask; int ret; @@ -3241,8 +3228,7 @@ static int madera_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { struct snd_soc_component *component = dai->component; - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct madera_dai_priv *dai_priv = &priv->dai[dai->id - 1]; struct snd_soc_dapm_route routes[2]; @@ -4742,8 +4728,7 @@ static bool madera_eq_filter_unstable(bool mode, __be16 _a, __be16 _b) int madera_eq_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct madera *madera = priv->madera; struct soc_bytes *params = (void *)kcontrol->private_value; @@ -4789,8 +4774,7 @@ EXPORT_SYMBOL_GPL(madera_eq_coeff_put); int madera_lhpf_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct madera_priv *priv = snd_soc_component_get_drvdata(component); struct madera *madera = priv->madera; __be16 *data = (__be16 *)ucontrol->value.bytes.data; diff --git a/sound/soc/codecs/max9759.c b/sound/soc/codecs/max9759.c index bc57d7687f16..9760543f2922 100644 --- a/sound/soc/codecs/max9759.c +++ b/sound/soc/codecs/max9759.c @@ -42,7 +42,7 @@ static const DECLARE_TLV_DB_SCALE(speaker_gain_tlv, 600, 600, 0); static int speaker_gain_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct max9759 *priv = snd_soc_component_get_drvdata(c); ucontrol->value.integer.value[0] = priv->gain; @@ -61,7 +61,7 @@ static const bool speaker_gain_table[4][2] = { static int speaker_gain_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct max9759 *priv = snd_soc_component_get_drvdata(c); if (ucontrol->value.integer.value[0] < 0 || @@ -83,7 +83,7 @@ static int speaker_gain_control_put(struct snd_kcontrol *kcontrol, static int speaker_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct max9759 *priv = snd_soc_component_get_drvdata(c); ucontrol->value.integer.value[0] = !priv->is_mute; @@ -94,7 +94,7 @@ static int speaker_mute_get(struct snd_kcontrol *kcontrol, static int speaker_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct max9759 *priv = snd_soc_component_get_drvdata(c); priv->is_mute = !ucontrol->value.integer.value[0]; diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c index 8af3c7e5317f..7ad7a9fb7255 100644 --- a/sound/soc/codecs/max9768.c +++ b/sound/soc/codecs/max9768.c @@ -40,7 +40,7 @@ static const struct reg_default max9768_default_regs[] = { static int max9768_get_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct max9768 *max9768 = snd_soc_component_get_drvdata(c); int val = gpiod_get_value_cansleep(max9768->mute); @@ -52,7 +52,7 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol, static int max9768_set_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct max9768 *max9768 = snd_soc_component_get_drvdata(c); bool val = !ucontrol->value.integer.value[0]; int ret; diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 37e61d8d4be6..9f40ca4b60d5 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -380,7 +380,7 @@ static SOC_ENUM_SINGLE_DECL(max98088_dai1_adc_filter_enum, static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); unsigned int sel = ucontrol->value.integer.value[0]; @@ -394,7 +394,7 @@ static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol, static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = max98088->mic1pre; @@ -404,7 +404,7 @@ static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol, static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); unsigned int sel = ucontrol->value.integer.value[0]; @@ -418,7 +418,7 @@ static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol, static int max98088_mic2pre_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = max98088->mic2pre; @@ -1296,6 +1296,7 @@ static int max98088_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1311,8 +1312,7 @@ static int max98088_set_bias_level(struct snd_soc_component *component, * enable it. */ if (!IS_ERR(max98088->mclk)) { - if (snd_soc_component_get_bias_level(component) == - SND_SOC_BIAS_ON) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) { clk_disable_unprepare(max98088->mclk); } else { ret = clk_prepare_enable(max98088->mclk); @@ -1323,7 +1323,7 @@ static int max98088_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) regcache_sync(max98088->regmap); snd_soc_component_update_bits(component, M98088_REG_4C_PWR_EN_IN, @@ -1500,7 +1500,7 @@ static void max98088_setup_eq2(struct snd_soc_component *component) static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_pdata *pdata = max98088->pdata; int channel = max98088_get_channel(component, kcontrol->id.name); @@ -1532,7 +1532,7 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); int channel = max98088_get_channel(component, kcontrol->id.name); struct max98088_cdata *cdata; diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 5aff5a459a43..13a15459040f 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -347,7 +347,7 @@ static const DECLARE_TLV_DB_RANGE(max98090_rcv_lout_tlv, static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -387,7 +387,7 @@ static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -817,6 +817,16 @@ static SOC_ENUM_SINGLE_VIRT_DECL(dmic_mux_enum, dmic_mux_text); static const struct snd_kcontrol_new max98090_dmic_mux = SOC_DAPM_ENUM("DMIC Mux", dmic_mux_enum); +static const char * const dmic_mX_mux_text[] = { "Enable", "Disable" }; + +static SOC_ENUM_SINGLE_VIRT_DECL(dmic_m1_enum, dmic_mX_mux_text); +static const struct snd_kcontrol_new max98090_dmic_m1_mux = + SOC_DAPM_ENUM("DMIC M1 Mux", dmic_m1_enum); + +static SOC_ENUM_SINGLE_VIRT_DECL(dmic_m2_enum, dmic_mX_mux_text); +static const struct snd_kcontrol_new max98090_dmic_m2_mux = + SOC_DAPM_ENUM("DMIC M2 Mux", dmic_m2_enum); + /* LINEA mixer switch */ static const struct snd_kcontrol_new max98090_linea_mixer_controls[] = { SOC_DAPM_SINGLE("IN1 Switch", M98090_REG_LINE_INPUT_CONFIG, @@ -1106,6 +1116,9 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { SND_SOC_DAPM_MUX("DMIC Mux", SND_SOC_NOPM, 0, 0, &max98090_dmic_mux), + SND_SOC_DAPM_MUX("DMIC M1 Mux", SND_SOC_NOPM, 0, 0, + &max98090_dmic_m1_mux), + SND_SOC_DAPM_PGA_E("MIC1 Input", M98090_REG_MIC1_INPUT_LEVEL, M98090_MIC_PA1EN_SHIFT, 0, NULL, 0, max98090_micinput_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), @@ -1144,7 +1157,7 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { SND_SOC_DAPM_AIF_OUT("AIFOUTL", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0), - SND_SOC_DAPM_AIF_OUT("AIFOUTR", "HiFi Capture", 1, + SND_SOC_DAPM_AIF_OUT("AIFOUTR", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_MUX("LBENL Mux", SND_SOC_NOPM, @@ -1241,6 +1254,14 @@ static const struct snd_soc_dapm_widget max98091_dapm_widgets[] = { SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_SUPPLY("DMIC34_HPF", M98090_REG_FILTER_CONFIG, M98090_FLT_DMIC34HPF_SHIFT, 0, NULL, 0), + + SND_SOC_DAPM_MUX("DMIC M2 Mux", SND_SOC_NOPM, 0, 0, + &max98090_dmic_m2_mux), + + SND_SOC_DAPM_AIF_OUT("AIFOUT2L", "HiFi Capture", 0, + SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("AIFOUT2R", "HiFi Capture", 0, + SND_SOC_NOPM, 0, 0), }; static const struct snd_soc_dapm_route max98090_dapm_routes[] = { @@ -1304,10 +1325,12 @@ static const struct snd_soc_dapm_route max98090_dapm_routes[] = { {"ADCL", NULL, "SHDN"}, {"ADCR", NULL, "SHDN"}, + {"DMIC M1 Mux", "Enable", "DMICL"}, + {"DMIC M1 Mux", "Enable", "DMICR"}, + {"DMIC Mux", "ADC", "ADCL"}, {"DMIC Mux", "ADC", "ADCR"}, - {"DMIC Mux", "DMIC", "DMICL"}, - {"DMIC Mux", "DMIC", "DMICR"}, + {"DMIC Mux", "DMIC", "DMIC M1 Mux"}, {"LBENL Mux", "Normal", "DMIC Mux"}, {"LBENL Mux", "Loopback", "LTENL Mux"}, @@ -1431,12 +1454,22 @@ static const struct snd_soc_dapm_route max98091_dapm_routes[] = { {"DMIC4", NULL, "DMIC4_ENA"}, {"DMIC3", NULL, "DMIC34_HPF"}, {"DMIC4", NULL, "DMIC34_HPF"}, + + {"DMIC M2 Mux", "Enable", "DMIC3"}, + {"DMIC M2 Mux", "Enable", "DMIC4"}, + + {"AIFOUT2L", NULL, "DMIC M2 Mux"}, + {"AIFOUT2R", NULL, "DMIC M2 Mux"}, + {"AIFOUT2L", NULL, "SHDN"}, + {"AIFOUT2R", NULL, "SHDN"}, + {"AIFOUT2L", NULL, "SDOEN"}, + {"AIFOUT2R", NULL, "SDOEN"}, }; static int max98090_add_widgets(struct snd_soc_component *component) { struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_add_component_controls(component, max98090_snd_controls, ARRAY_SIZE(max98090_snd_controls)); @@ -1718,6 +1751,7 @@ static int max98090_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1735,7 +1769,7 @@ static int max98090_set_bias_level(struct snd_soc_component *component, if (IS_ERR(max98090->mclk)) break; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) { clk_disable_unprepare(max98090->mclk); } else { ret = clk_prepare_enable(max98090->mclk); @@ -1745,7 +1779,7 @@ static int max98090_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regcache_sync(max98090->regmap); if (ret != 0) { dev_err(component->dev, @@ -2371,11 +2405,11 @@ static struct snd_soc_dai_driver max98090_dai = { .capture = { .stream_name = "HiFi Capture", .channels_min = 1, - .channels_max = 2, + .channels_max = 4, .rates = MAX98090_RATES, .formats = MAX98090_FORMATS, }, - .ops = &max98090_dai_ops, + .ops = &max98090_dai_ops, }; static int max98090_probe(struct snd_soc_component *component) diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index cfb63fe69267..aae6423156e1 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -350,7 +350,7 @@ static SOC_ENUM_SINGLE_DECL(max98095_dai3_dac_filter_enum, static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); unsigned int sel = ucontrol->value.integer.value[0]; @@ -364,7 +364,7 @@ static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol, static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = max98095->mic1pre; @@ -374,7 +374,7 @@ static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol, static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); unsigned int sel = ucontrol->value.integer.value[0]; @@ -388,7 +388,7 @@ static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol, static int max98095_mic2pre_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = max98095->mic2pre; @@ -1359,6 +1359,7 @@ static int max98095_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1376,7 +1377,7 @@ static int max98095_set_bias_level(struct snd_soc_component *component, if (IS_ERR(max98095->mclk)) break; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) { clk_disable_unprepare(max98095->mclk); } else { ret = clk_prepare_enable(max98095->mclk); @@ -1386,7 +1387,7 @@ static int max98095_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regcache_sync(max98095->regmap); if (ret != 0) { @@ -1485,7 +1486,7 @@ static int max98095_get_eq_channel(const char *name) static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_pdata *pdata = max98095->pdata; int channel = max98095_get_eq_channel(kcontrol->id.name); @@ -1549,7 +1550,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, static int max98095_get_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); int channel = max98095_get_eq_channel(kcontrol->id.name); struct max98095_cdata *cdata; @@ -1636,7 +1637,7 @@ static int max98095_get_bq_channel(struct snd_soc_component *component, static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_pdata *pdata = max98095->pdata; int channel = max98095_get_bq_channel(component, kcontrol->id.name); @@ -1697,7 +1698,7 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, static int max98095_get_bq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); int channel = max98095_get_bq_channel(component, kcontrol->id.name); struct max98095_cdata *cdata; @@ -1917,11 +1918,12 @@ EXPORT_SYMBOL_GPL(max98095_jack_detect); static int max98095_suspend(struct snd_soc_component *component) { struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); if (max98095->headphone_jack || max98095->mic_jack) max98095_jack_detect_disable(component); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); return 0; } @@ -1930,8 +1932,9 @@ static int max98095_resume(struct snd_soc_component *component) { struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct i2c_client *client = to_i2c_client(component->dev); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); if (max98095->headphone_jack || max98095->mic_jack) { max98095_jack_detect_enable(component); diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c index 33eb4576da23..cfb95fd4f85e 100644 --- a/sound/soc/codecs/max98373.c +++ b/sound/soc/codecs/max98373.c @@ -174,12 +174,13 @@ static int max98373_feedback_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); int i; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* * Register values will be cached before suspend. The cached value * will be a valid value and userspace will happy with that. diff --git a/sound/soc/codecs/max98390.c b/sound/soc/codecs/max98390.c index a8a282ff9fc5..3dd4dd94bc37 100644 --- a/sound/soc/codecs/max98390.c +++ b/sound/soc/codecs/max98390.c @@ -534,8 +534,7 @@ static SOC_ENUM_SINGLE_DECL(max98390_current_limit, static int max98390_ref_rdc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98390_priv *max98390 = snd_soc_component_get_drvdata(component); @@ -554,8 +553,7 @@ static int max98390_ref_rdc_put(struct snd_kcontrol *kcontrol, static int max98390_ref_rdc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98390_priv *max98390 = snd_soc_component_get_drvdata(component); @@ -567,8 +565,7 @@ static int max98390_ref_rdc_get(struct snd_kcontrol *kcontrol, static int max98390_ambient_temp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98390_priv *max98390 = snd_soc_component_get_drvdata(component); @@ -585,8 +582,7 @@ static int max98390_ambient_temp_put(struct snd_kcontrol *kcontrol, static int max98390_ambient_temp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98390_priv *max98390 = snd_soc_component_get_drvdata(component); @@ -598,8 +594,7 @@ static int max98390_ambient_temp_get(struct snd_kcontrol *kcontrol, static int max98390_adaptive_rdc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); dev_warn(component->dev, "Put adaptive rdc not supported\n"); @@ -610,8 +605,7 @@ static int max98390_adaptive_rdc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int rdc, rdc0; - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98390_priv *max98390 = snd_soc_component_get_drvdata(component); @@ -632,9 +626,9 @@ static int max98390_dsm_calib_get(struct snd_kcontrol *kcontrol, static int max98390_dsm_calib_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98390_priv *max98390 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int rdc, rdc_cal_result, rdc_integer, rdc_factor, temp, val; snd_soc_dapm_mutex_lock(dapm); diff --git a/sound/soc/codecs/max98396.c b/sound/soc/codecs/max98396.c index 4b4e1fc98a6d..18fd90227187 100644 --- a/sound/soc/codecs/max98396.c +++ b/sound/soc/codecs/max98396.c @@ -953,8 +953,7 @@ static const DECLARE_TLV_DB_RANGE(max98397_spk_tlv, static int max98396_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); int reg, val; @@ -973,9 +972,8 @@ static int max98396_mux_get(struct snd_kcontrol *kcontrol, static int max98396_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; @@ -1107,6 +1105,7 @@ static int max98396_adc_value_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component); @@ -1115,7 +1114,7 @@ static int max98396_adc_value_get(struct snd_kcontrol *kcontrol, int reg = mc->reg; /* ADC value is not available if the device is powered down */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) goto exit; if (max98396->device_id == CODEC_TYPE_MAX98397) { diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c index c395132689b4..1fcbc64a2771 100644 --- a/sound/soc/codecs/max9850.c +++ b/sound/soc/codecs/max9850.c @@ -225,6 +225,7 @@ static int max9850_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -233,7 +234,7 @@ static int max9850_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regcache_sync(max9850->regmap); if (ret) { dev_err(component->dev, diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 50db88fce904..9cad9b698cf2 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -78,7 +78,7 @@ static int max9867_adc_dac_event(struct snd_soc_dapm_widget *w, static int max9867_filter_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); unsigned int reg; int ret; @@ -98,7 +98,7 @@ static int max9867_filter_get(struct snd_kcontrol *kcontrol, static int max9867_filter_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); unsigned int reg, mode = ucontrol->value.enumerated.item[0]; int ret; @@ -556,14 +556,18 @@ static struct snd_soc_dai_driver max9867_dai[] = { #ifdef CONFIG_PM static int max9867_suspend(struct snd_soc_component *component) { - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); return 0; } static int max9867_resume(struct snd_soc_component *component) { - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); return 0; } @@ -577,6 +581,7 @@ static int max9867_set_bias_level(struct snd_soc_component *component, { int err; struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -585,7 +590,7 @@ static int max9867_set_bias_level(struct snd_soc_component *component, return err; break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { err = regcache_sync(max9867->regmap); if (err) return err; diff --git a/sound/soc/codecs/max98925.c b/sound/soc/codecs/max98925.c index 66c78051bd09..124af6408d96 100644 --- a/sound/soc/codecs/max98925.c +++ b/sound/soc/codecs/max98925.c @@ -97,7 +97,7 @@ static const struct snd_kcontrol_new max98925_dai_sel_mux = static int max98925_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); switch (event) { diff --git a/sound/soc/codecs/ml26124.c b/sound/soc/codecs/ml26124.c index c6585e8143a5..fad0cc902346 100644 --- a/sound/soc/codecs/ml26124.c +++ b/sound/soc/codecs/ml26124.c @@ -459,6 +459,7 @@ static int ml26124_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -473,7 +474,7 @@ static int ml26124_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: /* VMID ON */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_update_bits(component, ML26124_PW_REF_PW_MNG, ML26124_VMID, ML26124_VMID); msleep(500); diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index ebb6f2e84818..cfadea2aa1f7 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -423,8 +423,7 @@ static int msm8x16_wcd_get_iir_band_audio_mixer( struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd_iir_filter_ctl *ctl = (struct wcd_iir_filter_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -469,8 +468,7 @@ static int msm8x16_wcd_put_iir_band_audio_mixer( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd_iir_filter_ctl *ctl = (struct wcd_iir_filter_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; diff --git a/sound/soc/codecs/mt6357.c b/sound/soc/codecs/mt6357.c index 988728df15e4..674cf7df9df4 100644 --- a/sound/soc/codecs/mt6357.c +++ b/sound/soc/codecs/mt6357.c @@ -597,7 +597,7 @@ static int mt_mic_type_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6357_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mic_type = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mic_type = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); switch (event) { case SND_SOC_DAPM_PRE_PMU: diff --git a/sound/soc/codecs/mt6358.c b/sound/soc/codecs/mt6358.c index e033027fd4c7..a787accb88e8 100644 --- a/sound/soc/codecs/mt6358.c +++ b/sound/soc/codecs/mt6358.c @@ -320,8 +320,7 @@ static void headset_volume_ramp(struct mt6358_priv *priv, int from, int to) static int mt6358_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct mt6358_priv *priv = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -442,7 +441,7 @@ static int mt6358_disable_wov_phase2(struct mt6358_priv *priv) static int mt6358_get_wov(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct mt6358_priv *priv = snd_soc_component_get_drvdata(c); ucontrol->value.integer.value[0] = priv->wov_enabled; @@ -452,7 +451,7 @@ static int mt6358_get_wov(struct snd_kcontrol *kcontrol, static int mt6358_put_wov(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct mt6358_priv *priv = snd_soc_component_get_drvdata(c); int enabled = ucontrol->value.integer.value[0]; @@ -476,7 +475,7 @@ static int mt6358_put_wov(struct snd_kcontrol *kcontrol, static int mt6358_dmic_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct mt6358_priv *priv = snd_soc_component_get_drvdata(c); ucontrol->value.integer.value[0] = priv->dmic_one_wire_mode; @@ -488,7 +487,7 @@ static int mt6358_dmic_mode_get(struct snd_kcontrol *kcontrol, static int mt6358_dmic_mode_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *c = snd_kcontrol_chip(kcontrol); struct mt6358_priv *priv = snd_soc_component_get_drvdata(c); int enabled = ucontrol->value.integer.value[0]; @@ -1288,7 +1287,7 @@ static int mt_hp_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6358_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); int device = DEVICE_HP; dev_info(priv->dev, "%s(), event 0x%x, dev_counter[DEV_HP] %d, mux %u\n", @@ -1350,7 +1349,7 @@ static int mt_rcv_event(struct snd_soc_dapm_widget *w, dev_info(priv->dev, "%s(), event 0x%x, mux %u\n", __func__, event, - dapm_kcontrol_get_value(w->kcontrols[0])); + snd_soc_dapm_kcontrol_get_value(w->kcontrols[0])); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1829,7 +1828,7 @@ static int mt_mic_type_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6358_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), event 0x%x, mux %u\n", __func__, event, mux); @@ -1875,7 +1874,7 @@ static int mt_adc_l_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6358_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), event = 0x%x, mux %u\n", __func__, event, mux); @@ -1891,7 +1890,7 @@ static int mt_adc_r_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6358_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), event = 0x%x, mux %u\n", __func__, event, mux); @@ -1907,7 +1906,7 @@ static int mt_pga_left_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6358_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), event = 0x%x, mux %u\n", __func__, event, mux); @@ -1923,7 +1922,7 @@ static int mt_pga_right_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6358_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), event = 0x%x, mux %u\n", __func__, event, mux); diff --git a/sound/soc/codecs/mt6359.c b/sound/soc/codecs/mt6359.c index f73120c6a6ce..b15bdb15dbb0 100644 --- a/sound/soc/codecs/mt6359.c +++ b/sound/soc/codecs/mt6359.c @@ -367,8 +367,7 @@ static void headset_volume_ramp(struct mt6359_priv *priv, static int mt6359_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct mt6359_priv *priv = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -468,8 +467,7 @@ static int mt6359_put_volsw(struct snd_kcontrol *kcontrol, static int mt6359_get_playback_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct mt6359_priv *priv = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -1045,7 +1043,7 @@ static int mt_hp_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6359_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); int device = DEVICE_HP; dev_dbg(priv->dev, "%s(), event 0x%x, dev_counter[DEV_HP] %d, mux %u\n", @@ -1077,7 +1075,7 @@ static int mt_rcv_event(struct snd_soc_dapm_widget *w, struct mt6359_priv *priv = snd_soc_component_get_drvdata(cmpnt); dev_dbg(priv->dev, "%s(), event 0x%x, mux %u\n", - __func__, event, dapm_kcontrol_get_value(w->kcontrols[0])); + __func__, event, snd_soc_dapm_kcontrol_get_value(w->kcontrols[0])); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1159,7 +1157,7 @@ static int mt_lo_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6359_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), event 0x%x, mux %u\n", __func__, event, mux); @@ -1639,7 +1637,7 @@ static int mt_pga_l_mux_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6359_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), mux %d\n", __func__, mux); priv->mux_select[MUX_PGA_L] = mux >> RG_AUDPREAMPLINPUTSEL_SFT; @@ -1652,7 +1650,7 @@ static int mt_pga_r_mux_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6359_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), mux %d\n", __func__, mux); priv->mux_select[MUX_PGA_R] = mux >> RG_AUDPREAMPRINPUTSEL_SFT; @@ -1665,7 +1663,7 @@ static int mt_pga_3_mux_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); struct mt6359_priv *priv = snd_soc_component_get_drvdata(cmpnt); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); dev_dbg(priv->dev, "%s(), mux %d\n", __func__, mux); priv->mux_select[MUX_PGA_3] = mux >> RG_AUDPREAMP3INPUTSEL_SFT; diff --git a/sound/soc/codecs/mt6660.c b/sound/soc/codecs/mt6660.c index d16bccebae52..ef63fd113cb7 100644 --- a/sound/soc/codecs/mt6660.c +++ b/sound/soc/codecs/mt6660.c @@ -187,8 +187,7 @@ static const struct snd_soc_dapm_route mt6660_component_dapm_routes[] = { static int mt6660_component_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct mt6660_chip *chip = (struct mt6660_chip *) snd_soc_component_get_drvdata(component); diff --git a/sound/soc/codecs/nau8325.c b/sound/soc/codecs/nau8325.c index 2266f320a8f2..3bfdb448f8bd 100644 --- a/sound/soc/codecs/nau8325.c +++ b/sound/soc/codecs/nau8325.c @@ -422,7 +422,7 @@ static int nau8325_clksrc_choose(struct nau8325 *nau8325, *n1_sel = i; *mult_sel = j; ratio_sel = ratio; - goto proc_done; + goto proc_done; } } } @@ -829,8 +829,7 @@ static int nau8325_read_device_properties(struct device *dev, return 0; } -static int nau8325_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) +static int nau8325_i2c_probe(struct i2c_client *i2c) { struct device *dev = &i2c->dev; struct nau8325 *nau8325 = dev_get_platdata(dev); diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c index 6f432b992941..9870e62d372e 100644 --- a/sound/soc/codecs/nau8810.c +++ b/sound/soc/codecs/nau8810.c @@ -164,7 +164,7 @@ static bool nau8810_volatile_reg(struct device *dev, unsigned int reg) static int nau8810_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); struct soc_bytes_ext *params = (void *)kcontrol->private_value; int i, reg, reg_val; @@ -196,7 +196,7 @@ static int nau8810_eq_get(struct snd_kcontrol *kcontrol, static int nau8810_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); struct soc_bytes_ext *params = (void *)kcontrol->private_value; void *data; @@ -775,6 +775,7 @@ static int nau8810_pcm_hw_params(struct snd_pcm_substream *substream, static int nau8810_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); struct regmap *map = nau8810->regmap; @@ -790,7 +791,7 @@ static int nau8810_set_bias_level(struct snd_soc_component *component, NAU8810_IOBUF_EN | NAU8810_ABIAS_EN, NAU8810_IOBUF_EN | NAU8810_ABIAS_EN); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_sync(map); regmap_update_bits(map, NAU8810_REG_POWER1, NAU8810_REFIMP_MASK, NAU8810_REFIMP_3K); diff --git a/sound/soc/codecs/nau8821.c b/sound/soc/codecs/nau8821.c index 4fa9a785513e..3beb3c44dc2c 100644 --- a/sound/soc/codecs/nau8821.c +++ b/sound/soc/codecs/nau8821.c @@ -1047,7 +1047,6 @@ static void nau8821_eject_jack(struct nau8821 *nau8821) { struct snd_soc_dapm_context *dapm = nau8821->dapm; struct regmap *regmap = nau8821->regmap; - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); /* Detach 2kOhm Resistors from MICBIAS to MICGND */ regmap_update_bits(regmap, NAU8821_R74_MIC_BIAS, @@ -1055,7 +1054,7 @@ static void nau8821_eject_jack(struct nau8821 *nau8821) /* HPL/HPR short to ground */ regmap_update_bits(regmap, NAU8821_R0D_JACK_DET_CTRL, NAU8821_SPKR_DWN1R | NAU8821_SPKR_DWN1L, 0); - snd_soc_component_disable_pin(component, "MICBIAS"); + snd_soc_dapm_disable_pin(dapm, "MICBIAS"); snd_soc_dapm_sync(dapm); /* Disable & mask both insertion & ejection IRQs */ @@ -1080,7 +1079,7 @@ static void nau8821_eject_jack(struct nau8821 *nau8821) NAU8821_JACK_DET_DB_BYPASS, NAU8821_JACK_DET_DB_BYPASS); /* Close clock for jack type detection at manual mode */ - if (dapm->bias_level < SND_SOC_BIAS_PREPARE) + if (snd_soc_dapm_get_bias_level(dapm) < SND_SOC_BIAS_PREPARE) nau8821_configure_sysclk(nau8821, NAU8821_CLK_DIS, 0); /* Recover to normal channel input */ @@ -1106,7 +1105,6 @@ static void nau8821_jdet_work(struct work_struct *work) struct nau8821 *nau8821 = container_of(work, struct nau8821, jdet_work.work); struct snd_soc_dapm_context *dapm = nau8821->dapm; - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); struct regmap *regmap = nau8821->regmap; int jack_status_reg, mic_detected, event = 0, event_mask = 0; @@ -1133,13 +1131,13 @@ static void nau8821_jdet_work(struct work_struct *work) NAU8821_IRQ_KEY_RELEASE_DIS | NAU8821_IRQ_KEY_PRESS_DIS, 0); } else { - snd_soc_component_disable_pin(component, "MICBIAS"); - snd_soc_dapm_sync(nau8821->dapm); + snd_soc_dapm_disable_pin(dapm, "MICBIAS"); + snd_soc_dapm_sync(dapm); } } else { dev_dbg(nau8821->dev, "Headphone connected\n"); event |= SND_JACK_HEADPHONE; - snd_soc_component_disable_pin(component, "MICBIAS"); + snd_soc_dapm_disable_pin(dapm, "MICBIAS"); snd_soc_dapm_sync(dapm); } @@ -1162,7 +1160,7 @@ static void nau8821_setup_inserted_irq(struct nau8821 *nau8821) nau8821_irq_status_clear(regmap, NAU8821_JACK_INSERT_DETECTED); /* Enable internal VCO needed for interruptions */ - if (nau8821->dapm->bias_level < SND_SOC_BIAS_PREPARE) + if (snd_soc_dapm_get_bias_level(nau8821->dapm) < SND_SOC_BIAS_PREPARE) nau8821_configure_sysclk(nau8821, NAU8821_CLK_INTERNAL, 0); /* Chip needs one FSCLK cycle in order to generate interruptions, @@ -1191,7 +1189,6 @@ static irqreturn_t nau8821_interrupt(int irq, void *data) { struct nau8821 *nau8821 = (struct nau8821 *)data; struct regmap *regmap = nau8821->regmap; - struct snd_soc_component *component; int active_irq, event = 0, event_mask = 0; if (regmap_read(regmap, NAU8821_R10_IRQ_STATUS, &active_irq)) { @@ -1222,8 +1219,7 @@ static irqreturn_t nau8821_interrupt(int irq, void *data) NAU8821_MICDET_MASK, NAU8821_MICDET_EN); if (nau8821_is_jack_inserted(regmap)) { /* Detect microphone and jack type */ - component = snd_soc_dapm_to_component(nau8821->dapm); - snd_soc_component_force_enable_pin(component, "MICBIAS"); + snd_soc_dapm_force_enable_pin(nau8821->dapm, "MICBIAS"); snd_soc_dapm_sync(nau8821->dapm); schedule_delayed_work(&nau8821->jdet_work, msecs_to_jiffies(20)); /* Turn off insertion interruption at manual mode */ @@ -1261,8 +1257,7 @@ static const struct regmap_config nau8821_regmap_config = { static int nau8821_component_probe(struct snd_soc_component *component) { struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); nau8821->dapm = dapm; @@ -1564,8 +1559,7 @@ static int nau8821_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_STANDBY: /* Setup codec configuration after resume */ - if (snd_soc_component_get_bias_level(component) == - SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(nau8821->dapm) == SND_SOC_BIAS_OFF) nau8821_resume_setup(nau8821); break; @@ -1603,9 +1597,9 @@ static int __maybe_unused nau8821_suspend(struct snd_soc_component *component) if (nau8821->irq) disable_irq(nau8821->irq); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(nau8821->dapm, SND_SOC_BIAS_OFF); /* Power down codec power; don't support button wakeup */ - snd_soc_component_disable_pin(component, "MICBIAS"); + snd_soc_dapm_disable_pin(nau8821->dapm, "MICBIAS"); snd_soc_dapm_sync(nau8821->dapm); regcache_cache_only(nau8821->regmap, true); regcache_mark_dirty(nau8821->regmap); diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c index 15d6f8d01f78..a11759f85eac 100644 --- a/sound/soc/codecs/nau8822.c +++ b/sound/soc/codecs/nau8822.c @@ -180,8 +180,7 @@ static bool nau8822_volatile(struct device *dev, unsigned int reg) static int nau8822_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct soc_bytes_ext *params = (void *)kcontrol->private_value; int i, reg; u16 reg_val, *val; @@ -212,8 +211,7 @@ static int nau8822_eq_get(struct snd_kcontrol *kcontrol, static int nau8822_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct soc_bytes_ext *params = (void *)kcontrol->private_value; void *data; u16 *val, value; @@ -959,6 +957,7 @@ static int nau8822_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -966,7 +965,7 @@ static int nau8822_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: if (nau8822->mclk && - snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON) { + snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON) { int ret = clk_prepare_enable(nau8822->mclk); if (ret) { @@ -983,7 +982,7 @@ static int nau8822_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_STANDBY: if (nau8822->mclk && - snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_OFF) + snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_OFF) clk_disable_unprepare(nau8822->mclk); snd_soc_component_update_bits(component, @@ -991,8 +990,7 @@ static int nau8822_set_bias_level(struct snd_soc_component *component, NAU8822_IOBUF_EN | NAU8822_ABIAS_EN, NAU8822_IOBUF_EN | NAU8822_ABIAS_EN); - if (snd_soc_component_get_bias_level(component) == - SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_update_bits(component, NAU8822_REG_POWER_MANAGEMENT_1, NAU8822_REFIMP_MASK, NAU8822_REFIMP_3K); @@ -1055,8 +1053,9 @@ static struct snd_soc_dai_driver nau8822_dai = { static int nau8822_suspend(struct snd_soc_component *component) { struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); regcache_mark_dirty(nau8822->regmap); @@ -1066,10 +1065,11 @@ static int nau8822_suspend(struct snd_soc_component *component) static int nau8822_resume(struct snd_soc_component *component) { struct nau8822 *nau8822 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); regcache_sync(nau8822->regmap); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); return 0; } diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c index 542bd22e6180..6ce763762443 100644 --- a/sound/soc/codecs/nau8824.c +++ b/sound/soc/codecs/nau8824.c @@ -876,7 +876,7 @@ static void nau8824_eject_jack(struct nau8824 *nau8824) NAU8824_JD_SLEEP_MODE, NAU8824_JD_SLEEP_MODE); /* Close clock for jack type detection at manual mode */ - if (dapm->bias_level < SND_SOC_BIAS_PREPARE) + if (snd_soc_dapm_get_bias_level(dapm) < SND_SOC_BIAS_PREPARE) nau8824_config_sysclk(nau8824, NAU8824_CLK_DIS, 0); } @@ -931,7 +931,7 @@ static void nau8824_setup_auto_irq(struct nau8824 *nau8824) regmap_update_bits(regmap, NAU8824_REG_INTERRUPT_SETTING, NAU8824_IRQ_EJECT_DIS, 0); /* Enable internal VCO needed for interruptions */ - if (nau8824->dapm->bias_level < SND_SOC_BIAS_PREPARE) + if (snd_soc_dapm_get_bias_level(nau8824->dapm) < SND_SOC_BIAS_PREPARE) nau8824_config_sysclk(nau8824, NAU8824_CLK_INTERNAL, 0); regmap_update_bits(regmap, NAU8824_REG_ENA_CTRL, NAU8824_JD_SLEEP_MODE, 0); @@ -1498,7 +1498,7 @@ static int nau8824_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(nau8824->dapm) == SND_SOC_BIAS_OFF) { /* Setup codec configuration after resume */ nau8824_resume_setup(nau8824); } @@ -1519,7 +1519,7 @@ static int nau8824_set_bias_level(struct snd_soc_component *component, static int nau8824_component_probe(struct snd_soc_component *component) { struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); nau8824->dapm = dapm; @@ -1532,7 +1532,7 @@ static int __maybe_unused nau8824_suspend(struct snd_soc_component *component) if (nau8824->irq) { disable_irq(nau8824->irq); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(nau8824->dapm, SND_SOC_BIAS_OFF); } regcache_cache_only(nau8824->regmap, true); regcache_mark_dirty(nau8824->regmap); diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 25b8b19e27ec..dd3528537ae4 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -2226,7 +2226,7 @@ static const struct regmap_config nau8825_regmap_config = { static int nau8825_component_probe(struct snd_soc_component *component) { struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); nau8825->dapm = dapm; @@ -2630,7 +2630,7 @@ static int nau8825_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(nau8825->dapm) == SND_SOC_BIAS_OFF) { if (nau8825->mclk_freq) { ret = clk_prepare_enable(nau8825->mclk); if (ret) { @@ -2673,7 +2673,7 @@ static int __maybe_unused nau8825_suspend(struct snd_soc_component *component) struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); disable_irq(nau8825->irq); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(nau8825->dapm, SND_SOC_BIAS_OFF); /* Power down codec power; don't suppoet button wakeup */ snd_soc_dapm_disable_pin(nau8825->dapm, "SAR"); snd_soc_dapm_disable_pin(nau8825->dapm, "MICBIAS"); diff --git a/sound/soc/codecs/ntp8835.c b/sound/soc/codecs/ntp8835.c index 2cc4c6395f55..2b93bea11752 100644 --- a/sound/soc/codecs/ntp8835.c +++ b/sound/soc/codecs/ntp8835.c @@ -92,7 +92,7 @@ static int ntp8835_mute_info(struct snd_kcontrol *kcontrol, static int ntp8835_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int val; val = snd_soc_component_read(component, NTP8835_SOFT_MUTE); @@ -104,7 +104,7 @@ static int ntp8835_mute_get(struct snd_kcontrol *kcontrol, static int ntp8835_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int val; val = ucontrol->value.integer.value[0] ? 0 : 7; diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c index a1ec881d7084..f4e5f3133f2b 100644 --- a/sound/soc/codecs/pcm1681.c +++ b/sound/soc/codecs/pcm1681.c @@ -108,7 +108,7 @@ static int pcm1681_set_deemph(struct snd_soc_component *component) static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = priv->deemph; @@ -119,7 +119,7 @@ static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, static int pcm1681_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); priv->deemph = ucontrol->value.integer.value[0]; diff --git a/sound/soc/codecs/pcm186x.c b/sound/soc/codecs/pcm186x.c index 13443f569ddb..0d1103fe4e04 100644 --- a/sound/soc/codecs/pcm186x.c +++ b/sound/soc/codecs/pcm186x.c @@ -546,8 +546,10 @@ static int pcm186x_power_off(struct snd_soc_component *component) static int pcm186x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + dev_dbg(component->dev, "## %s: %d -> %d\n", __func__, - snd_soc_component_get_bias_level(component), level); + snd_soc_dapm_get_bias_level(dapm), level); switch (level) { case SND_SOC_BIAS_ON: @@ -555,7 +557,7 @@ static int pcm186x_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) pcm186x_power_on(component); break; case SND_SOC_BIAS_OFF: diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 007dfc0fa224..a70e8ea166dc 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -224,7 +224,7 @@ static bool pcm512x_volatile(struct device *dev, unsigned int reg) static int pcm512x_overclock_pll_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = pcm512x->overclock_pll; @@ -234,10 +234,11 @@ static int pcm512x_overclock_pll_get(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_pll_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); - switch (snd_soc_component_get_bias_level(component)) { + switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_STANDBY: break; @@ -252,7 +253,7 @@ static int pcm512x_overclock_pll_put(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_dsp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = pcm512x->overclock_dsp; @@ -262,10 +263,11 @@ static int pcm512x_overclock_dsp_get(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_dsp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); - switch (snd_soc_component_get_bias_level(component)) { + switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_STANDBY: break; @@ -280,7 +282,7 @@ static int pcm512x_overclock_dsp_put(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_dac_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = pcm512x->overclock_dac; @@ -290,10 +292,11 @@ static int pcm512x_overclock_dac_get(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_dac_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); - switch (snd_soc_component_get_bias_level(component)) { + switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_STANDBY: break; @@ -393,7 +396,7 @@ static int pcm512x_update_mute(struct pcm512x_priv *pcm512x) static int pcm512x_digital_playback_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); mutex_lock(&pcm512x->mutex); @@ -407,7 +410,7 @@ static int pcm512x_digital_playback_switch_get(struct snd_kcontrol *kcontrol, static int pcm512x_digital_playback_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); int ret, changed = 0; diff --git a/sound/soc/codecs/pcm6240.c b/sound/soc/codecs/pcm6240.c index 08cc52b374a9..bde190a659b1 100644 --- a/sound/soc/codecs/pcm6240.c +++ b/sound/soc/codecs/pcm6240.c @@ -1139,8 +1139,7 @@ static int pcmdevice_info_profile( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec - = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct pcmdevice_priv *pcm_dev = snd_soc_component_get_drvdata(codec); @@ -1156,8 +1155,7 @@ static int pcmdevice_get_profile_id( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec - = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct pcmdevice_priv *pcm_dev = snd_soc_component_get_drvdata(codec); @@ -1170,8 +1168,7 @@ static int pcmdevice_set_profile_id( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec - = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct pcmdevice_priv *pcm_dev = snd_soc_component_get_drvdata(codec); int nr_profile = ucontrol->value.integer.value[0]; diff --git a/sound/soc/codecs/peb2466.c b/sound/soc/codecs/peb2466.c index c0c5b3c3e98b..f1ee42af264b 100644 --- a/sound/soc/codecs/peb2466.c +++ b/sound/soc/codecs/peb2466.c @@ -276,7 +276,7 @@ static int peb2466_lkup_ctrl_put(struct snd_kcontrol *kcontrol, { struct peb2466_lkup_ctrl *lkup_ctrl = (struct peb2466_lkup_ctrl *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct peb2466 *peb2466 = snd_soc_component_get_drvdata(component); unsigned int index; int ret; @@ -377,7 +377,7 @@ static const struct soc_enum peb2466_tg_freq[][2] = { static int peb2466_tg_freq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct peb2466 *peb2466 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -415,7 +415,7 @@ static int peb2466_tg_freq_get(struct snd_kcontrol *kcontrol, static int peb2466_tg_freq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct peb2466 *peb2466 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *tg_freq_item; diff --git a/sound/soc/codecs/pm4125-sdw.c b/sound/soc/codecs/pm4125-sdw.c index 4ed09fbe3f54..3167b38e2876 100644 --- a/sound/soc/codecs/pm4125-sdw.c +++ b/sound/soc/codecs/pm4125-sdw.c @@ -20,12 +20,12 @@ #include <sound/soc.h> #include "pm4125.h" -static struct pm4125_sdw_ch_info pm4125_sdw_rx_ch_info[] = { +static struct wcd_sdw_ch_info pm4125_sdw_rx_ch_info[] = { WCD_SDW_CH(PM4125_HPH_L, PM4125_HPH_PORT, BIT(0)), WCD_SDW_CH(PM4125_HPH_R, PM4125_HPH_PORT, BIT(1)), }; -static struct pm4125_sdw_ch_info pm4125_sdw_tx_ch_info[] = { +static struct wcd_sdw_ch_info pm4125_sdw_tx_ch_info[] = { WCD_SDW_CH(PM4125_ADC1, PM4125_ADC_1_2_DMIC1L_BCS_PORT, BIT(0)), WCD_SDW_CH(PM4125_ADC2, PM4125_ADC_1_2_DMIC1L_BCS_PORT, BIT(1)), }; @@ -46,12 +46,6 @@ static struct sdw_dpn_prop pm4125_dpn_prop[PM4125_MAX_SWR_PORTS] = { } }; -struct device *pm4125_sdw_device_get(struct device_node *np) -{ - return bus_find_device_by_of_node(&sdw_bus_type, np); -} -EXPORT_SYMBOL_GPL(pm4125_sdw_device_get); - int pm4125_sdw_hw_params(struct pm4125_sdw_priv *priv, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { @@ -83,19 +77,6 @@ int pm4125_sdw_hw_params(struct pm4125_sdw_priv *priv, struct snd_pcm_substream } EXPORT_SYMBOL_GPL(pm4125_sdw_hw_params); -static int pm4125_update_status(struct sdw_slave *slave, enum sdw_slave_status status) -{ - struct pm4125_sdw_priv *priv = dev_get_drvdata(&slave->dev); - - if (priv->regmap && status == SDW_SLAVE_ATTACHED) { - /* Write out any cached changes that happened between probe and attach */ - regcache_cache_only(priv->regmap, false); - return regcache_sync(priv->regmap); - } - - return 0; -} - /* * Handle Soundwire out-of-band interrupt event by triggering the first irq of the slave_irq * irq domain, which then will be handled by the regmap_irq threaded irq. @@ -104,18 +85,9 @@ static int pm4125_update_status(struct sdw_slave *slave, enum sdw_slave_status s static int pm4125_interrupt_callback(struct sdw_slave *slave, struct sdw_slave_intr_status *status) { struct pm4125_sdw_priv *priv = dev_get_drvdata(&slave->dev); - struct irq_domain *slave_irq = priv->slave_irq; - u32 sts1, sts2, sts3; - - do { - handle_nested_irq(irq_find_mapping(slave_irq, 0)); - regmap_read(priv->regmap, PM4125_DIG_SWR_INTR_STATUS_0, &sts1); - regmap_read(priv->regmap, PM4125_DIG_SWR_INTR_STATUS_1, &sts2); - regmap_read(priv->regmap, PM4125_DIG_SWR_INTR_STATUS_2, &sts3); - } while (sts1 || sts2 || sts3); - - return IRQ_HANDLED; + return wcd_interrupt_callback(slave, priv->slave_irq, PM4125_DIG_SWR_INTR_STATUS_0, + PM4125_DIG_SWR_INTR_STATUS_1, PM4125_DIG_SWR_INTR_STATUS_2); } static const struct reg_default pm4125_defaults[] = { @@ -369,32 +341,10 @@ static const struct regmap_config pm4125_regmap_config = { }; static const struct sdw_slave_ops pm4125_slave_ops = { - .update_status = pm4125_update_status, + .update_status = wcd_update_status, .interrupt_callback = pm4125_interrupt_callback, }; -static int pm4125_sdw_component_bind(struct device *dev, struct device *master, void *data) -{ - pm_runtime_set_autosuspend_delay(dev, 3000); - pm_runtime_use_autosuspend(dev); - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - - return 0; -} - -static void pm4125_sdw_component_unbind(struct device *dev, struct device *master, void *data) -{ - pm_runtime_disable(dev); - pm_runtime_set_suspended(dev); - pm_runtime_dont_use_autosuspend(dev); -} - -static const struct component_ops pm4125_sdw_component_ops = { - .bind = pm4125_sdw_component_bind, - .unbind = pm4125_sdw_component_unbind, -}; - static int pm4125_probe(struct sdw_slave *pdev, const struct sdw_device_id *id) { struct device *dev = &pdev->dev; @@ -476,7 +426,7 @@ static int pm4125_probe(struct sdw_slave *pdev, const struct sdw_device_id *id) priv->ch_info[i].master_ch_mask = PM4125_SWRM_CH_MASK(master_ch_mask[i]); } - ret = component_add(dev, &pm4125_sdw_component_ops); + ret = component_add(dev, &wcd_sdw_component_ops); if (ret) return ret; @@ -490,7 +440,7 @@ static int pm4125_remove(struct sdw_slave *pdev) { struct device *dev = &pdev->dev; - component_del(dev, &pm4125_sdw_component_ops); + component_del(dev, &wcd_sdw_component_ops); return 0; } diff --git a/sound/soc/codecs/pm4125.c b/sound/soc/codecs/pm4125.c index 706fc668ffe2..8bc3b9994019 100644 --- a/sound/soc/codecs/pm4125.c +++ b/sound/soc/codecs/pm4125.c @@ -69,16 +69,14 @@ struct pm4125_priv { struct wcd_mbhc *wcd_mbhc; struct wcd_mbhc_config mbhc_cfg; struct wcd_mbhc_intr intr_ids; + struct wcd_common common; struct irq_domain *virq; - const struct regmap_irq_chip *pm4125_regmap_irq_chip; + const struct regmap_irq_chip *chip_desc; struct regmap_irq_chip_data *irq_chip; struct snd_soc_jack *jack; unsigned long status_mask; s32 micb_ref[PM4125_MAX_MICBIAS]; s32 pullup_ref[PM4125_MAX_MICBIAS]; - u32 micb1_mv; - u32 micb2_mv; - u32 micb3_mv; int hphr_pdm_wd_int; int hphl_pdm_wd_int; @@ -179,7 +177,7 @@ static const u32 pm4125_config_regs[] = { PM4125_DIG_SWR_INTR_LEVEL_0, }; -static struct regmap_irq_chip pm4125_regmap_irq_chip = { +static const struct regmap_irq_chip pm4125_regmap_irq_chip = { .name = "pm4125", .irqs = pm4125_irqs, .num_irqs = ARRAY_SIZE(pm4125_irqs), @@ -644,16 +642,6 @@ static int pm4125_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, return 0; } -static int pm4125_get_micb_vout_ctl_val(struct device *dev, u32 micb_mv) -{ - if (micb_mv < 1600 || micb_mv > 2850) { - dev_err(dev, "%s: unsupported micbias voltage (%u mV)\n", __func__, micb_mv); - return -EINVAL; - } - - return (micb_mv - 1600) / 50; -} - static int pm4125_codec_enable_adc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -691,7 +679,7 @@ static int pm4125_codec_enable_adc(struct snd_soc_dapm_widget *w, 0x00); pm4125_global_mbias_disable(component); break; - }; + } return 0; } @@ -756,7 +744,7 @@ static int pm4125_micbias_control(struct snd_soc_component *component, int micb_ dev_err(component->dev, "%s: Invalid micbias number: %d\n", __func__, micb_num); return -EINVAL; - }; + } switch (req) { case MICB_PULLUP_ENABLE: @@ -799,7 +787,7 @@ static int pm4125_micbias_control(struct snd_soc_component *component, int micb_ pm4125_global_mbias_disable(component); } break; - }; + } return 0; } @@ -855,7 +843,7 @@ static int pm4125_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w, static int pm4125_connect_port(struct pm4125_sdw_priv *sdw_priv, u8 port_idx, u8 ch_id, bool enable) { struct sdw_port_config *port_config = &sdw_priv->port_config[port_idx - 1]; - const struct pm4125_sdw_ch_info *ch_info = &sdw_priv->ch_info[ch_id]; + const struct wcd_sdw_ch_info *ch_info = &sdw_priv->ch_info[ch_id]; struct sdw_slave *sdev = sdw_priv->sdev; u8 port_num = ch_info->port_num; u8 ch_mask = ch_info->ch_mask; @@ -879,7 +867,7 @@ static int pm4125_connect_port(struct pm4125_sdw_priv *sdw_priv, u8 port_idx, u8 static int pm4125_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pm4125_priv *pm4125 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc; bool hphr; @@ -893,7 +881,7 @@ static int pm4125_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_el static int pm4125_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct pm4125_priv *pm4125 = snd_soc_component_get_drvdata(component); struct pm4125_sdw_priv *sdw_priv = pm4125->sdw_priv[AIF1_PB]; int value = ucontrol->value.integer.value[0]; @@ -926,7 +914,7 @@ static int pm4125_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_el static int pm4125_get_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct pm4125_priv *pm4125 = snd_soc_component_get_drvdata(comp); struct pm4125_sdw_priv *sdw_priv; int dai_id = mixer->shift; @@ -944,7 +932,7 @@ static int pm4125_get_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_ele static int pm4125_set_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct pm4125_priv *pm4125 = snd_soc_component_get_drvdata(comp); struct pm4125_sdw_priv *sdw_priv; int dai_id = mixer->shift; @@ -1266,15 +1254,8 @@ static const struct snd_soc_dapm_route pm4125_audio_map[] = { static int pm4125_set_micbias_data(struct device *dev, struct pm4125_priv *pm4125) { - int vout_ctl; - - /* Set micbias voltage */ - vout_ctl = pm4125_get_micb_vout_ctl_val(dev, pm4125->micb1_mv); - if (vout_ctl < 0) - return -EINVAL; - regmap_update_bits(pm4125->regmap, PM4125_ANA_MICBIAS_LDO_1_SETTING, - PM4125_ANA_MICBIAS_MICB_OUT_VAL_MASK, vout_ctl << 3); + PM4125_ANA_MICBIAS_MICB_OUT_VAL_MASK, pm4125->common.micb_vout[0]); return 0; } @@ -1320,10 +1301,8 @@ static int pm4125_irq_init(struct pm4125_priv *pm4125, struct device *dev) return -EINVAL; } - pm4125_regmap_irq_chip.irq_drv_data = pm4125; - return devm_regmap_add_irq_chip(dev, pm4125->regmap, irq_create_mapping(pm4125->virq, 0), - IRQF_ONESHOT, 0, &pm4125_regmap_irq_chip, + IRQF_ONESHOT, 0, pm4125->chip_desc, &pm4125->irq_chip); } @@ -1418,31 +1397,6 @@ static const struct snd_soc_component_driver soc_codec_dev_pm4125 = { .endianness = 1, }; -static void pm4125_dt_parse_micbias_info(struct device *dev, struct pm4125_priv *priv) -{ - struct device_node *np = dev->of_node; - u32 prop_val = 0; - int ret; - - ret = of_property_read_u32(np, "qcom,micbias1-microvolt", &prop_val); - if (!ret) - priv->micb1_mv = prop_val / 1000; - else - dev_warn(dev, "Micbias1 DT property not found\n"); - - ret = of_property_read_u32(np, "qcom,micbias2-microvolt", &prop_val); - if (!ret) - priv->micb2_mv = prop_val / 1000; - else - dev_warn(dev, "Micbias2 DT property not found\n"); - - ret = of_property_read_u32(np, "qcom,micbias3-microvolt", &prop_val); - if (!ret) - priv->micb3_mv = prop_val / 1000; - else - dev_warn(dev, "Micbias3 DT property not found\n"); -} - static int pm4125_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -1551,6 +1505,10 @@ static int pm4125_bind(struct device *dev) struct device_link *devlink; int ret; + /* Initialize device pointers to NULL for safe cleanup */ + pm4125->rxdev = NULL; + pm4125->txdev = NULL; + /* Give the soundwire subdevices some more time to settle */ usleep_range(15000, 15010); @@ -1560,7 +1518,7 @@ static int pm4125_bind(struct device *dev) return ret; } - pm4125->rxdev = pm4125_sdw_device_get(pm4125->rxnode); + pm4125->rxdev = of_sdw_find_device_by_node(pm4125->rxnode); if (!pm4125->rxdev) { dev_err(dev, "could not find rxslave with matching of node\n"); ret = -EINVAL; @@ -1570,11 +1528,11 @@ static int pm4125_bind(struct device *dev) pm4125->sdw_priv[AIF1_PB] = dev_get_drvdata(pm4125->rxdev); pm4125->sdw_priv[AIF1_PB]->pm4125 = pm4125; - pm4125->txdev = pm4125_sdw_device_get(pm4125->txnode); + pm4125->txdev = of_sdw_find_device_by_node(pm4125->txnode); if (!pm4125->txdev) { dev_err(dev, "could not find txslave with matching of node\n"); ret = -EINVAL; - goto error_unbind_all; + goto error_put_rx; } pm4125->sdw_priv[AIF1_CAP] = dev_get_drvdata(pm4125->txdev); @@ -1584,7 +1542,7 @@ static int pm4125_bind(struct device *dev) if (!pm4125->tx_sdw_dev) { dev_err(dev, "could not get txslave with matching of dev\n"); ret = -EINVAL; - goto error_unbind_all; + goto error_put_tx; } /* @@ -1596,7 +1554,7 @@ static int pm4125_bind(struct device *dev) if (!devlink) { dev_err(dev, "Could not devlink TX and RX\n"); ret = -EINVAL; - goto error_unbind_all; + goto error_put_tx; } devlink = device_link_add(dev, pm4125->txdev, @@ -1615,7 +1573,7 @@ static int pm4125_bind(struct device *dev) goto link_remove_dev_tx; } - pm4125->regmap = dev_get_regmap(&pm4125->tx_sdw_dev->dev, NULL); + pm4125->regmap = pm4125->sdw_priv[AIF1_CAP]->regmap; if (!pm4125->regmap) { dev_err(dev, "could not get TX device regmap\n"); ret = -EINVAL; @@ -1631,11 +1589,7 @@ static int pm4125_bind(struct device *dev) pm4125->sdw_priv[AIF1_PB]->slave_irq = pm4125->virq; pm4125->sdw_priv[AIF1_CAP]->slave_irq = pm4125->virq; - ret = pm4125_set_micbias_data(dev, pm4125); - if (ret < 0) { - dev_err(dev, "Bad micbias pdata\n"); - goto link_remove_dev_rx; - } + pm4125_set_micbias_data(dev, pm4125); ret = snd_soc_register_component(dev, &soc_codec_dev_pm4125, pm4125_dais, ARRAY_SIZE(pm4125_dais)); @@ -1650,6 +1604,10 @@ link_remove_dev_tx: device_link_remove(dev, pm4125->txdev); link_remove_rx_tx: device_link_remove(pm4125->rxdev, pm4125->txdev); +error_put_tx: + put_device(pm4125->txdev); +error_put_rx: + put_device(pm4125->rxdev); error_unbind_all: component_unbind_all(dev, pm4125); return ret; @@ -1660,9 +1618,18 @@ static void pm4125_unbind(struct device *dev) struct pm4125_priv *pm4125 = dev_get_drvdata(dev); snd_soc_unregister_component(dev); + devm_regmap_del_irq_chip(dev, irq_find_mapping(pm4125->virq, 0), + pm4125->irq_chip); device_link_remove(dev, pm4125->txdev); device_link_remove(dev, pm4125->rxdev); device_link_remove(pm4125->rxdev, pm4125->txdev); + + /* Release device references acquired in bind */ + if (pm4125->txdev) + put_device(pm4125->txdev); + if (pm4125->rxdev) + put_device(pm4125->rxdev); + component_unbind_all(dev, pm4125); } @@ -1695,6 +1662,7 @@ static int pm4125_probe(struct platform_device *pdev) { struct component_match *match = NULL; struct device *dev = &pdev->dev; + struct regmap_irq_chip *chip_desc; struct pm4125_priv *pm4125; struct wcd_mbhc_config *cfg; int ret; @@ -1705,6 +1673,14 @@ static int pm4125_probe(struct platform_device *pdev) dev_set_drvdata(dev, pm4125); + chip_desc = devm_kmemdup(dev, &pm4125_regmap_irq_chip, + sizeof(pm4125_regmap_irq_chip), + GFP_KERNEL); + if (!chip_desc) + return -ENOMEM; + chip_desc->irq_drv_data = pm4125; + pm4125->chip_desc = chip_desc; + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(pm4125_power_supplies), pm4125_power_supplies); if (ret) @@ -1716,7 +1692,12 @@ static int pm4125_probe(struct platform_device *pdev) pm4125_reset(pm4125); - pm4125_dt_parse_micbias_info(dev, pm4125); + pm4125->common.dev = dev; + pm4125->common.max_bias = 3; + ret = wcd_dt_parse_micbias_info(&pm4125->common); + if (ret) + return dev_err_probe(dev, ret, "Failed to get micbias\n"); + atomic_set(&pm4125->gloal_mbias_cnt, 0); cfg = &pm4125->mbhc_cfg; @@ -1724,7 +1705,7 @@ static int pm4125_probe(struct platform_device *pdev) cfg->anc_micbias = MIC_BIAS_2; cfg->v_hs_max = WCD_MBHC_HS_V_MAX; cfg->num_btn = PM4125_MBHC_MAX_BUTTONS; - cfg->micb_mv = pm4125->micb2_mv; + cfg->micb_mv = pm4125->common.micb_mv[1]; cfg->linein_th = 5000; cfg->hs_thr = 1700; cfg->hph_thr = 50; diff --git a/sound/soc/codecs/pm4125.h b/sound/soc/codecs/pm4125.h index 3520c711b744..25fd3106f44f 100644 --- a/sound/soc/codecs/pm4125.h +++ b/sound/soc/codecs/pm4125.h @@ -7,6 +7,7 @@ #include <linux/soundwire/sdw.h> #include <linux/soundwire/sdw_type.h> +#include "wcd-common.h" #define PM4125_ANA_BASE_ADDR 0x3000 #define PM4125_DIG_BASE_ADDR 0x3400 @@ -202,26 +203,13 @@ enum pm4125_rx_sdw_ports { PM4125_MAX_SWR_PORTS = PM4125_COMP_PORT, }; -struct pm4125_sdw_ch_info { - int port_num; - unsigned int ch_mask; - unsigned int master_ch_mask; -}; - -#define WCD_SDW_CH(id, pn, cmask) \ - [id] = { \ - .port_num = pn, \ - .ch_mask = cmask, \ - .master_ch_mask = cmask, \ - } - struct pm4125_priv; struct pm4125_sdw_priv { struct sdw_slave *sdev; struct sdw_stream_config sconfig; struct sdw_stream_runtime *sruntime; struct sdw_port_config port_config[PM4125_MAX_SWR_PORTS]; - struct pm4125_sdw_ch_info *ch_info; + struct wcd_sdw_ch_info *ch_info; bool port_enable[PM4125_MAX_SWR_CH_IDS]; unsigned int master_channel_map[SDW_MAX_PORTS]; int active_ports; @@ -240,8 +228,6 @@ int pm4125_sdw_set_sdw_stream(struct pm4125_sdw_priv *pm4125, struct snd_soc_dai int pm4125_sdw_hw_params(struct pm4125_sdw_priv *pm4125, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai); -struct device *pm4125_sdw_device_get(struct device_node *np); - #else static inline int pm4125_sdw_free(struct pm4125_sdw_priv *pm4125, struct snd_pcm_substream *substream, struct snd_soc_dai *dai) diff --git a/sound/soc/codecs/rk3308_codec.c b/sound/soc/codecs/rk3308_codec.c index 8b51e87a1711..60befe9d37f0 100644 --- a/sound/soc/codecs/rk3308_codec.c +++ b/sound/soc/codecs/rk3308_codec.c @@ -786,6 +786,7 @@ static int rk3308_codec_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rk3308_codec_priv *rk3308 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -793,7 +794,7 @@ static int rk3308_codec_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_OFF) break; /* Sequence from TRM Section 8.6.3 "Power Up" */ diff --git a/sound/soc/codecs/rt1011.c b/sound/soc/codecs/rt1011.c index b84dd18ddde9..9f34a6a35487 100644 --- a/sound/soc/codecs/rt1011.c +++ b/sound/soc/codecs/rt1011.c @@ -1034,8 +1034,7 @@ static void rt1011_reset(struct regmap *regmap) static int rt1011_recv_spk_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); @@ -1047,15 +1046,15 @@ static int rt1011_recv_spk_mode_get(struct snd_kcontrol *kcontrol, static int rt1011_recv_spk_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); if (ucontrol->value.integer.value[0] == rt1011->recv_spk_mode) return 0; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { rt1011->recv_spk_mode = ucontrol->value.integer.value[0]; if (rt1011->recv_spk_mode) { @@ -1110,8 +1109,7 @@ static bool rt1011_validate_bq_drc_coeff(unsigned short reg) static int rt1011_bq_drc_coeff_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); struct rt1011_bq_drc_params *bq_drc_info; @@ -1147,8 +1145,7 @@ static int rt1011_bq_drc_coeff_get(struct snd_kcontrol *kcontrol, static int rt1011_bq_drc_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); struct rt1011_bq_drc_params *bq_drc_info; @@ -1224,10 +1221,11 @@ static int rt1011_r0_cali_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); rt1011->cali_done = 0; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF && + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF && ucontrol->value.integer.value[0]) rt1011_calibrate(rt1011, 1); @@ -1264,6 +1262,7 @@ static int rt1011_r0_load_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); struct device *dev; unsigned int r0_integer, r0_factor, format; @@ -1275,7 +1274,7 @@ static int rt1011_r0_load_mode_put(struct snd_kcontrol *kcontrol, return -EINVAL; dev = regmap_get_device(rt1011->regmap); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { rt1011->r0_reg = ucontrol->value.integer.value[0]; format = 2147483648U; /* 2^24 * 128 */ @@ -1319,8 +1318,7 @@ static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum, 0, 0, static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); @@ -1348,8 +1346,7 @@ static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol, static int rt1011_i2s_ref_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); @@ -1664,8 +1661,7 @@ static int rt1011_hw_params(struct snd_pcm_substream *substream, static int rt1011_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct snd_soc_component *component = dai->component; - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int reg_val = 0, reg_bclk_inv = 0; int ret = 0; @@ -1845,8 +1841,7 @@ static int rt1011_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { struct snd_soc_component *component = dai->component; - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int val = 0, tdm_en = 0, rx_slotnum, tx_slotnum; int ret = 0, first_bit, last_bit; @@ -2218,8 +2213,7 @@ static int rt1011_calibrate(struct rt1011_priv *rt1011, unsigned char cali_flag) unsigned int dc_offset; unsigned int r0_integer, r0_factor, format; struct device *dev = regmap_get_device(rt1011->regmap); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(rt1011->component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(rt1011->component); int ret = 0; snd_soc_dapm_mutex_lock(dapm); diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c index 818b45226b72..ca1ed9d5a24e 100644 --- a/sound/soc/codecs/rt1015.c +++ b/sound/soc/codecs/rt1015.c @@ -427,8 +427,7 @@ static SOC_ENUM_SINGLE_DECL(rt1015_boost_mode_enum, 0, 0, static int rt1015_boost_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); @@ -440,8 +439,7 @@ static int rt1015_boost_mode_get(struct snd_kcontrol *kcontrol, static int rt1015_boost_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); int boost_mode = ucontrol->value.integer.value[0]; @@ -481,8 +479,7 @@ static int rt1015_boost_mode_put(struct snd_kcontrol *kcontrol, static int rt1015_bypass_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); @@ -494,9 +491,10 @@ static int rt1015_bypass_boost_get(struct snd_kcontrol *kcontrol, static void rt1015_calibrate(struct rt1015_priv *rt1015) { struct snd_soc_component *component = rt1015->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct regmap *regmap = rt1015->regmap; - snd_soc_dapm_mutex_lock(&component->dapm); + snd_soc_dapm_mutex_lock(dapm); regcache_cache_bypass(regmap, true); regmap_write(regmap, RT1015_CLK_DET, 0x0000); @@ -518,14 +516,13 @@ static void rt1015_calibrate(struct rt1015_priv *rt1015) regcache_cache_bypass(regmap, false); regcache_mark_dirty(regmap); regcache_sync(regmap); - snd_soc_dapm_mutex_unlock(&component->dapm); + snd_soc_dapm_mutex_unlock(dapm); } static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); diff --git a/sound/soc/codecs/rt1318.c b/sound/soc/codecs/rt1318.c index ae01b2ce630b..01c58b15fd91 100644 --- a/sound/soc/codecs/rt1318.c +++ b/sound/soc/codecs/rt1318.c @@ -505,7 +505,7 @@ static int rt1318_dac_event(struct snd_soc_dapm_widget *w, static int rt1318_dvol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1318_priv *rt1318 = snd_soc_component_get_drvdata(component); rt1318->rt1318_dvol = ucontrol->value.integer.value[0]; @@ -528,7 +528,7 @@ static int rt1318_dvol_put(struct snd_kcontrol *kcontrol, static int rt1318_dvol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt1318_priv *rt1318 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rt1318->rt1318_dvol; diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index 2c055c45111f..5c33aeaced2f 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -925,10 +925,11 @@ static int rt274_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int rt274_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == - snd_soc_component_get_bias_level(component)) { + if (SND_SOC_BIAS_STANDBY == snd_soc_dapm_get_bias_level(dapm)) { snd_soc_component_write(component, RT274_SET_AUDIO_POWER, AC_PWRST_D0); } diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index fd8de8b49793..2fbb5860c421 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -223,7 +223,7 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic) if (!rt286->component) return -EINVAL; - dapm = snd_soc_component_get_dapm(rt286->component); + dapm = snd_soc_component_to_dapm(rt286->component); if (rt286->pdata.cbj_en) { regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); @@ -314,7 +314,7 @@ static void rt286_jack_detect_work(struct work_struct *work) static int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); rt286->jack = jack; @@ -887,9 +887,11 @@ static int rt286_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) static int rt286_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + if (SND_SOC_BIAS_STANDBY == snd_soc_dapm_get_bias_level(dapm)) { snd_soc_component_write(component, RT286_SET_AUDIO_POWER, AC_PWRST_D0); snd_soc_component_update_bits(component, diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c index ee3d9291eea6..02247593513a 100644 --- a/sound/soc/codecs/rt298.c +++ b/sound/soc/codecs/rt298.c @@ -227,7 +227,7 @@ static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic) if (!rt298->component) return -EINVAL; - dapm = snd_soc_component_get_dapm(rt298->component); + dapm = snd_soc_component_to_dapm(rt298->component); if (rt298->pdata.cbj_en) { regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf); @@ -329,7 +329,7 @@ static void rt298_jack_detect_work(struct work_struct *work) static int rt298_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); rt298->jack = jack; @@ -949,10 +949,11 @@ static int rt298_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) static int rt298_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == - snd_soc_component_get_bias_level(component)) { + if (SND_SOC_BIAS_STANDBY == snd_soc_dapm_get_bias_level(dapm)) { snd_soc_component_write(component, RT298_SET_AUDIO_POWER, AC_PWRST_D0); snd_soc_component_update_bits(component, 0x0d, 0x200, 0x200); diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index ab9d81c32be8..649b44b790b0 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -325,6 +325,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); const struct firmware *fw = NULL; u8 buf[8]; @@ -332,7 +333,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled) return 0; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { rt5514->dsp_enabled = ucontrol->value.integer.value[0]; if (rt5514->dsp_enabled) { @@ -1050,11 +1051,12 @@ static int rt5514_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { case SND_SOC_BIAS_PREPARE: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5514->mclk); } else { ret = clk_prepare_enable(rt5514->mclk); @@ -1064,7 +1066,7 @@ static int rt5514_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* * If the DSP is enabled in start of recording, the DSP * should be disabled, and sync back to normal recording diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c index 1ec486707ff9..fb9cf127e3ff 100644 --- a/sound/soc/codecs/rt5616.c +++ b/sound/soc/codecs/rt5616.c @@ -1159,6 +1159,7 @@ static int rt5616_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1174,7 +1175,7 @@ static int rt5616_set_bias_level(struct snd_soc_component *component, * away from ON. Disable the clock in that case, otherwise * enable it. */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5616->mclk); } else { ret = clk_prepare_enable(rt5616->mclk); @@ -1184,7 +1185,7 @@ static int rt5616_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_VREF1 | RT5616_PWR_MB | RT5616_PWR_BG | RT5616_PWR_VREF2, diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index d523477c5102..19c6d8f760d9 100644 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c @@ -183,7 +183,7 @@ static const DECLARE_TLV_DB_RANGE(mic_bst_tlv, static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rt5631->dmic_used_flag; @@ -194,7 +194,7 @@ static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, static int rt5631_dmic_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); rt5631->dmic_used_flag = ucontrol->value.integer.value[0]; @@ -1535,6 +1535,7 @@ static int rt5631_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -1545,7 +1546,7 @@ static int rt5631_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS, RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS); @@ -1575,6 +1576,7 @@ static int rt5631_set_bias_level(struct snd_soc_component *component, static int rt5631_probe(struct snd_soc_component *component) { struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int val; val = rt5631_read_index(component, RT5631_ADDA_MIXER_INTL_REG3); @@ -1613,7 +1615,7 @@ static int rt5631_probe(struct snd_soc_component *component) RT5631_DMIC_R_CH_LATCH_RISING); } - snd_soc_component_init_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_init_bias_level(dapm, SND_SOC_BIAS_STANDBY); return 0; } diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index f50e771db24b..4c08c274f50e 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1935,6 +1935,7 @@ static int rt5640_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1949,7 +1950,7 @@ static int rt5640_set_bias_level(struct snd_soc_component *component, * away from ON. Disable the clock in that case, otherwise * enable it. */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5640->mclk); } else { ret = clk_prepare_enable(rt5640->mclk); @@ -1959,7 +1960,7 @@ static int rt5640_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (SND_SOC_BIAS_OFF == snd_soc_component_get_bias_level(component)) { + if (SND_SOC_BIAS_OFF == snd_soc_dapm_get_bias_level(dapm)) { snd_soc_component_update_bits(component, RT5640_PWR_ANLG1, RT5640_PWR_VREF1 | RT5640_PWR_MB | RT5640_PWR_BG | RT5640_PWR_VREF2, @@ -2098,7 +2099,7 @@ EXPORT_SYMBOL_GPL(rt5640_sel_asrc_clk_src); void rt5640_enable_micbias1_for_ovcd(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); snd_soc_dapm_mutex_lock(dapm); @@ -2114,7 +2115,7 @@ EXPORT_SYMBOL_GPL(rt5640_enable_micbias1_for_ovcd); void rt5640_disable_micbias1_for_ovcd(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); snd_soc_dapm_mutex_lock(dapm); @@ -2586,8 +2587,7 @@ static void rt5640_enable_hda_jack_detect( struct snd_soc_component *component, struct snd_soc_jack *jack) { struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; /* Select JD1 for Mic */ @@ -2652,7 +2652,7 @@ static int rt5640_set_jack(struct snd_soc_component *component, static int rt5640_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); u32 dmic1_data_pin = 0; u32 dmic2_data_pin = 0; @@ -2666,7 +2666,7 @@ static int rt5640_probe(struct snd_soc_component *component) rt5640->component = component; - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); snd_soc_component_update_bits(component, RT5640_GCTL1, 0x0301, 0x0301); snd_soc_component_update_bits(component, RT5640_MICBIAS, 0x0030, 0x0030); @@ -2796,6 +2796,7 @@ static void rt5640_remove(struct snd_soc_component *component) static int rt5640_suspend(struct snd_soc_component *component) { struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); if (rt5640->jack) { /* disable jack interrupts during system suspend */ @@ -2804,7 +2805,7 @@ static int rt5640_suspend(struct snd_soc_component *component) cancel_delayed_work_sync(&rt5640->bp_work); } - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); rt5640_reset(component); regcache_cache_only(rt5640->regmap, true); regcache_mark_dirty(rt5640->regmap); diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 29a403526cd9..f7701b8d0d3c 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3071,10 +3071,11 @@ static int rt5645_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + if (SND_SOC_BIAS_STANDBY == snd_soc_dapm_get_bias_level(dapm)) { snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_VREF1 | RT5645_PWR_MB | RT5645_PWR_BG | RT5645_PWR_VREF2, @@ -3099,7 +3100,7 @@ static int rt5645_set_bias_level(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_FV1 | RT5645_PWR_FV2, RT5645_PWR_FV1 | RT5645_PWR_FV2); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_write(component, RT5645_DEPOP_M2, 0x1140); msleep(40); if (rt5645->en_button_func) @@ -3130,7 +3131,7 @@ static int rt5645_set_bias_level(struct snd_soc_component *component, static void rt5645_enable_push_button_irq(struct snd_soc_component *component, bool enable) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; if (enable) { @@ -3169,7 +3170,7 @@ static void rt5645_enable_push_button_irq(struct snd_soc_component *component, static int rt5645_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); unsigned int val; @@ -3180,7 +3181,7 @@ static int rt5645_jack_detect(struct snd_soc_component *component, int jack_inse snd_soc_dapm_force_enable_pin(dapm, "LDO2"); snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); - if (!snd_soc_card_is_instantiated(dapm->card)) { + if (!snd_soc_card_is_instantiated(component->card)) { /* Power up necessary bits for JD if dapm is not ready yet */ regmap_update_bits(rt5645->regmap, RT5645_PWR_ANLG1, @@ -3449,7 +3450,7 @@ static void rt5645_btn_check_callback(struct timer_list *t) static int rt5645_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); rt5645->component = component; @@ -3478,7 +3479,7 @@ static int rt5645_probe(struct snd_soc_component *component) break; } - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); /* for JD function */ if (rt5645->pdata.jd_mode) { diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 9eeeba8cd6ff..9af65a38f0ee 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1511,16 +1511,18 @@ static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5651_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + if (SND_SOC_BIAS_STANDBY == snd_soc_dapm_get_bias_level(dapm)) { if (snd_soc_component_read(component, RT5651_PLL_MODE_1) & 0x9200) snd_soc_component_update_bits(component, RT5651_D_MISC, 0xc00, 0xc00); } break; case SND_SOC_BIAS_STANDBY: - if (SND_SOC_BIAS_OFF == snd_soc_component_get_bias_level(component)) { + if (SND_SOC_BIAS_OFF == snd_soc_dapm_get_bias_level(dapm)) { snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2, @@ -1557,7 +1559,7 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO"); @@ -1570,7 +1572,7 @@ static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component) static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_disable_pin_unlocked(dapm, "Platform Clock"); @@ -2058,13 +2060,14 @@ static void rt5651_apply_properties(struct snd_soc_component *component) static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); rt5651->component = component; snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_LDO_DVO_MASK, RT5651_PWR_LDO_DVO_1_2V); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); rt5651_apply_properties(component); diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index 31b47db7b4f7..f5957470652c 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -1197,7 +1197,7 @@ static const struct snd_kcontrol_new rt5659_if3_adc_swap_mux = static int rt5659_hp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int ret = snd_soc_put_volsw(kcontrol, ucontrol); if (snd_soc_component_read(component, RT5659_STO_NG2_CTRL_1) & RT5659_NG2_EN) { @@ -1213,7 +1213,7 @@ static int rt5659_hp_vol_put(struct snd_kcontrol *kcontrol, static void rt5659_enable_push_button_irq(struct snd_soc_component *component, bool enable) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); if (enable) { snd_soc_component_write(component, RT5659_4BTN_IL_CMD_1, 0x000b); @@ -1257,7 +1257,7 @@ static void rt5659_enable_push_button_irq(struct snd_soc_component *component, static int rt5659_headset_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30}; int reg_63; @@ -3611,7 +3611,7 @@ static int rt5659_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) static int rt5659_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); int ret; @@ -3631,7 +3631,7 @@ static int rt5659_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (dapm->bias_level == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = clk_prepare_enable(rt5659->mclk); if (ret) { dev_err(component->dev, @@ -3662,8 +3662,7 @@ static int rt5659_set_bias_level(struct snd_soc_component *component, static int rt5659_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); rt5659->component = component; diff --git a/sound/soc/codecs/rt5660.c b/sound/soc/codecs/rt5660.c index 44c3a3b92f98..84cdfb810c66 100644 --- a/sound/soc/codecs/rt5660.c +++ b/sound/soc/codecs/rt5660.c @@ -1069,6 +1069,7 @@ static int rt5660_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1079,7 +1080,7 @@ static int rt5660_set_bias_level(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5660_GEN_CTRL1, RT5660_DIG_GATE_CTRL, RT5660_DIG_GATE_CTRL); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5660->mclk); } else { ret = clk_prepare_enable(rt5660->mclk); @@ -1089,7 +1090,7 @@ static int rt5660_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_update_bits(component, RT5660_PWR_ANLG1, RT5660_PWR_VREF1 | RT5660_PWR_MB | RT5660_PWR_BG | RT5660_PWR_VREF2, diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 45057562c0c8..e4d8785e64c1 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -1463,7 +1463,7 @@ static void rt5663_enable_push_button_irq(struct snd_soc_component *component, static int rt5663_v2_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30}; @@ -1859,7 +1859,7 @@ static irqreturn_t rt5663_irq(int irq, void *data) dev_dbg(regmap_get_device(rt5663->regmap), "%s IRQ queue work\n", __func__); - queue_delayed_work(system_wq, &rt5663->jack_detect_work, + queue_delayed_work(system_dfl_wq, &rt5663->jack_detect_work, msecs_to_jiffies(250)); return IRQ_HANDLED; @@ -1974,7 +1974,7 @@ static void rt5663_jack_detect_work(struct work_struct *work) cancel_delayed_work_sync( &rt5663->jd_unplug_work); } else { - queue_delayed_work(system_wq, + queue_delayed_work(system_dfl_wq, &rt5663->jd_unplug_work, msecs_to_jiffies(500)); } @@ -2024,7 +2024,7 @@ static void rt5663_jd_unplug_work(struct work_struct *work) SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3); } else { - queue_delayed_work(system_wq, &rt5663->jd_unplug_work, + queue_delayed_work(system_dfl_wq, &rt5663->jd_unplug_work, msecs_to_jiffies(500)); } } @@ -3140,7 +3140,7 @@ static int rt5663_set_bias_level(struct snd_soc_component *component, static int rt5663_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); rt5663->component = component; diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index b16b2c66e754..c7beccd54b16 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -993,7 +993,7 @@ static const struct snd_kcontrol_new rt5665_if3_adc_swap_mux = static int rt5665_hp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int ret = snd_soc_put_volsw(kcontrol, ucontrol); if (snd_soc_component_read(component, RT5665_STO_NG2_CTRL_1) & RT5665_NG2_EN) { @@ -1009,7 +1009,7 @@ static int rt5665_hp_vol_put(struct snd_kcontrol *kcontrol, static int rt5665_mono_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int ret = snd_soc_put_volsw(kcontrol, ucontrol); if (snd_soc_component_read(component, RT5665_MONO_NG2_CTRL_1) & RT5665_NG2_EN) { @@ -1067,7 +1067,7 @@ static void rt5665_enable_push_button_irq(struct snd_soc_component *component, static int rt5665_headset_detect(struct snd_soc_component *component, int jack_insert) { struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int sar_hs_type, val; if (jack_insert) { diff --git a/sound/soc/codecs/rt5668.c b/sound/soc/codecs/rt5668.c index 8442dd09cfaf..5fcdb50d5184 100644 --- a/sound/soc/codecs/rt5668.c +++ b/sound/soc/codecs/rt5668.c @@ -853,8 +853,7 @@ static int rt5668_headset_detect(struct snd_soc_component *component, int jack_insert) { struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int val, count; if (jack_insert) { diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index efd26082f19a..cb5d03bf4c7f 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -431,7 +431,7 @@ static bool rt5670_readable_register(struct device *dev, unsigned int reg) static int rt5670_headset_detect(struct snd_soc_component *component, int jack_insert) { int val; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (jack_insert) { @@ -652,7 +652,7 @@ static void rt5670_update_ad_da_mixer_dac1_m_bits(struct rt5670_priv *rt5670) static int rt5670_dac1_playback_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rt5670->dac1_playback_switch_l; @@ -664,7 +664,7 @@ static int rt5670_dac1_playback_switch_get(struct snd_kcontrol *kcontrol, static int rt5670_dac1_playback_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->dac1_playback_switch_l == ucontrol->value.integer.value[0] && @@ -966,7 +966,7 @@ static int rt5670_put_dac1_mix_dac1_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); int ret; @@ -1153,25 +1153,29 @@ static SOC_ENUM_SINGLE_DECL(rt5670_dac1r_enum, RT5670_AD_DA_MIXER, static const struct snd_kcontrol_new rt5670_dac1r_mux = SOC_DAPM_ENUM("DAC1 R source", rt5670_dac1r_enum); -/*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */ -/* TODO Use SOC_VALUE_ENUM_SINGLE_DECL */ -static const char * const rt5670_dac12_src[] = { - "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", - "Bass", "VAD_ADC", "IF4 DAC" -}; +/* DAC2 L source*/ /* MX-1B [6:4] */ +static const char *const rt5670_dac12_src[] = { + "IF1 DAC", "IF2 DAC", "TxDC DAC", "VAD_ADC" +}; /* VAD_ADC or TxDP_ADC_R */ + +static const unsigned int rt5670_dac12_values[] = { 0, 1, 3, 5 }; -static SOC_ENUM_SINGLE_DECL(rt5670_dac2l_enum, RT5670_DAC_CTRL, - RT5670_DAC2_L_SEL_SFT, rt5670_dac12_src); +static SOC_VALUE_ENUM_SINGLE_DECL(rt5670_dac2l_enum, RT5670_DAC_CTRL, + RT5670_DAC2_L_SEL_SFT, RT5670_DAC2_L_SEL_MASK, + rt5670_dac12_src, rt5670_dac12_values); static const struct snd_kcontrol_new rt5670_dac_l2_mux = SOC_DAPM_ENUM("DAC2 L source", rt5670_dac2l_enum); -static const char * const rt5670_dacr2_src[] = { - "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", "TxDP ADC", "IF4 DAC" -}; +/*DAC2 R source*/ /* MX-1B [2:0] */ +static const char *const rt5670_dacr2_src[] = { "IF1 DAC", "IF2 DAC", + "TxDC DAC", "TxDP ADC" }; + +static const unsigned int rt5670_dacr2_values[] = { 0, 1, 3, 4 }; -static SOC_ENUM_SINGLE_DECL(rt5670_dac2r_enum, RT5670_DAC_CTRL, - RT5670_DAC2_R_SEL_SFT, rt5670_dacr2_src); +static SOC_VALUE_ENUM_SINGLE_DECL(rt5670_dac2r_enum, RT5670_DAC_CTRL, + RT5670_DAC2_R_SEL_SFT, RT5670_DAC2_R_SEL_MASK, + rt5670_dacr2_src, rt5670_dacr2_values); static const struct snd_kcontrol_new rt5670_dac_r2_mux = SOC_DAPM_ENUM("DAC2 R source", rt5670_dac2r_enum); @@ -2666,10 +2670,11 @@ static int rt5670_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + if (SND_SOC_BIAS_STANDBY == snd_soc_dapm_get_bias_level(dapm)) { snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2, @@ -2719,7 +2724,7 @@ static int rt5670_set_bias_level(struct snd_soc_component *component, static int rt5670_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (snd_soc_component_read(component, RT5670_RESET) & RT5670_ID_MASK) { diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 6b6c690a9e45..d46385249867 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -706,8 +706,7 @@ static void rt5677_set_dsp_mode(struct rt5677_priv *rt5677, bool on) static unsigned int rt5677_set_vad_source(struct rt5677_priv *rt5677) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(rt5677->component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(rt5677->component); /* Force dapm to sync before we enable the * DSP to prevent write corruption */ @@ -2733,11 +2732,12 @@ static int rt5677_vref_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: - if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON && + if (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON && !rt5677->is_vref_slow) { mdelay(20); regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, @@ -4643,8 +4643,8 @@ static int rt5677_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); - enum snd_soc_bias_level prev_bias = - snd_soc_component_get_bias_level(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + enum snd_soc_bias_level prev_bias = snd_soc_dapm_get_bias_level(dapm); switch (level) { case SND_SOC_BIAS_ON: @@ -4880,7 +4880,7 @@ static void rt5677_free_gpio(struct i2c_client *i2c) static int rt5677_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); int i; @@ -4896,7 +4896,7 @@ static int rt5677_probe(struct snd_soc_component *component) ARRAY_SIZE(rt5677_dmic2_clk_1)); } - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, ~RT5677_IRQ_DEBOUNCE_SEL_MASK, 0x0020); diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index a0abd2ce0c1e..d39f8e4f3474 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -928,7 +928,7 @@ static void rt5682_enable_push_button_irq(struct snd_soc_component *component, static int rt5682_headset_detect(struct snd_soc_component *component, int jack_insert) { struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = &component->dapm; + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); unsigned int val, count; if (jack_insert) { @@ -1115,7 +1115,7 @@ void rt5682_jack_detect_handler(struct work_struct *work) } } - dapm = snd_soc_component_get_dapm(rt5682->component); + dapm = snd_soc_component_to_dapm(rt5682->component); snd_soc_dapm_mutex_lock(dapm); mutex_lock(&rt5682->calibrate_mutex); @@ -2595,7 +2595,7 @@ static int rt5682_wclk_prepare(struct clk_hw *hw) return -EINVAL; component = rt5682->component; - dapm = snd_soc_component_get_dapm(component); + dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_mutex_lock(dapm); @@ -2633,7 +2633,7 @@ static void rt5682_wclk_unprepare(struct clk_hw *hw) return; component = rt5682->component; - dapm = snd_soc_component_get_dapm(component); + dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_mutex_lock(dapm); @@ -2928,9 +2928,9 @@ EXPORT_SYMBOL_GPL(rt5682_register_dai_clks); static int rt5682_probe(struct snd_soc_component *component) { struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct sdw_slave *slave; unsigned long time; - struct snd_soc_dapm_context *dapm = &component->dapm; rt5682->component = component; diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c index 1d80a4b862e2..98de94a79260 100644 --- a/sound/soc/codecs/rt5682s.c +++ b/sound/soc/codecs/rt5682s.c @@ -841,7 +841,7 @@ static void rt5682s_jack_detect_handler(struct work_struct *work) return; } - dapm = snd_soc_component_get_dapm(rt5682s->component); + dapm = snd_soc_component_to_dapm(rt5682s->component); snd_soc_dapm_mutex_lock(dapm); mutex_lock(&rt5682s->calibrate_mutex); @@ -2485,6 +2485,7 @@ static int rt5682s_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_PREPARE: @@ -2492,7 +2493,7 @@ static int rt5682s_set_bias_level(struct snd_soc_component *component, RT5682S_PWR_LDO, RT5682S_PWR_LDO); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) regmap_update_bits(rt5682s->regmap, RT5682S_PWR_DIG_1, RT5682S_DIG_GATE_CTRL, RT5682S_DIG_GATE_CTRL); break; diff --git a/sound/soc/codecs/rt700.c b/sound/soc/codecs/rt700.c index 816117c13aea..21523d0a5f08 100644 --- a/sound/soc/codecs/rt700.c +++ b/sound/soc/codecs/rt700.c @@ -272,11 +272,10 @@ io_error: static void rt700_jack_init(struct rt700_priv *rt700) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(rt700->component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(rt700->component); /* power on */ - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); @@ -307,7 +306,7 @@ static void rt700_jack_init(struct rt700_priv *rt700) } /* power off */ - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3); } @@ -362,8 +361,7 @@ static int rt700_set_amp_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); @@ -398,7 +396,7 @@ static int rt700_set_amp_gain_put(struct snd_kcontrol *kcontrol, val_ll |= read_ll; } - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); @@ -450,7 +448,7 @@ static int rt700_set_amp_gain_put(struct snd_kcontrol *kcontrol, break; } - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3); return 0; @@ -524,8 +522,7 @@ static const struct snd_kcontrol_new rt700_snd_controls[] = { static int rt700_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); unsigned int reg, val = 0, nid; int ret; @@ -553,10 +550,8 @@ static int rt700_mux_get(struct snd_kcontrol *kcontrol, static int rt700_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; @@ -839,13 +834,12 @@ static int rt700_probe(struct snd_soc_component *component) static int rt700_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) { regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); diff --git a/sound/soc/codecs/rt711-sdca.c b/sound/soc/codecs/rt711-sdca.c index 16c351779243..3a26c782d800 100644 --- a/sound/soc/codecs/rt711-sdca.c +++ b/sound/soc/codecs/rt711-sdca.c @@ -813,7 +813,7 @@ static int rt711_sdca_ge_select_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component); unsigned int val, item; @@ -828,7 +828,7 @@ static int rt711_sdca_ge_select_put(struct snd_kcontrol *kcontrol, { struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component); unsigned int val, change = 0; @@ -900,8 +900,7 @@ static const struct snd_kcontrol_new rt711_sdca_snd_controls[] = { static int rt711_sdca_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component); unsigned int val = 0, mask_sft; @@ -923,10 +922,8 @@ static int rt711_sdca_mux_get(struct snd_kcontrol *kcontrol, static int rt711_sdca_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c index af3a49aee618..5dbe9b67703e 100644 --- a/sound/soc/codecs/rt711.c +++ b/sound/soc/codecs/rt711.c @@ -360,12 +360,11 @@ io_error: static void rt711_jack_init(struct rt711_priv *rt711) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(rt711->component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(rt711->component); mutex_lock(&rt711->calibrate_mutex); /* power on */ - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0); @@ -448,7 +447,7 @@ static void rt711_jack_init(struct rt711_priv *rt711) } /* power off */ - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3); mutex_unlock(&rt711->calibrate_mutex); @@ -504,8 +503,7 @@ static int rt711_set_amp_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); @@ -543,7 +541,7 @@ static int rt711_set_amp_gain_put(struct snd_kcontrol *kcontrol, val_ll |= read_ll; } - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0); @@ -597,7 +595,7 @@ static int rt711_set_amp_gain_put(struct snd_kcontrol *kcontrol, break; } - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3); @@ -682,8 +680,7 @@ static const struct snd_kcontrol_new rt711_snd_controls[] = { static int rt711_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); unsigned int reg, val = 0, nid; int ret; @@ -712,10 +709,8 @@ static int rt711_mux_get(struct snd_kcontrol *kcontrol, static int rt711_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; @@ -900,13 +895,12 @@ static const struct snd_soc_dapm_route rt711_audio_map[] = { static int rt711_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) { regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0); diff --git a/sound/soc/codecs/rt712-sdca-dmic.c b/sound/soc/codecs/rt712-sdca-dmic.c index 42f8f7b8bed0..2928649e80e4 100644 --- a/sound/soc/codecs/rt712-sdca-dmic.c +++ b/sound/soc/codecs/rt712-sdca-dmic.c @@ -429,8 +429,7 @@ static const struct snd_kcontrol_new rt712_sdca_dmic_snd_controls[] = { static int rt712_sdca_dmic_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt712_sdca_dmic_priv *rt712 = snd_soc_component_get_drvdata(component); unsigned int val = 0, mask_sft; @@ -452,10 +451,8 @@ static int rt712_sdca_dmic_mux_get(struct snd_kcontrol *kcontrol, static int rt712_sdca_dmic_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt712_sdca_dmic_priv *rt712 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; diff --git a/sound/soc/codecs/rt712-sdca.c b/sound/soc/codecs/rt712-sdca.c index 0ebaae426e73..4796fce084ff 100644 --- a/sound/soc/codecs/rt712-sdca.c +++ b/sound/soc/codecs/rt712-sdca.c @@ -743,8 +743,7 @@ static const struct snd_kcontrol_new rt712_sdca_spk_controls[] = { static int rt712_sdca_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component); unsigned int val = 0, mask = 0x3300; @@ -768,10 +767,8 @@ static int rt712_sdca_mux_get(struct snd_kcontrol *kcontrol, static int rt712_sdca_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; @@ -1017,7 +1014,7 @@ static int rt712_sdca_parse_dt(struct rt712_sdca_priv *rt712, struct device *dev static int rt712_sdca_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component); int ret; @@ -1230,8 +1227,7 @@ static const struct snd_kcontrol_new rt712_sdca_dmic_snd_controls[] = { static int rt712_sdca_dmic_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component); unsigned int val = 0, mask_sft; @@ -1253,10 +1249,8 @@ static int rt712_sdca_dmic_mux_get(struct snd_kcontrol *kcontrol, static int rt712_sdca_dmic_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt712_sdca_priv *rt712 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; diff --git a/sound/soc/codecs/rt715-sdca.c b/sound/soc/codecs/rt715-sdca.c index db7d43349d7d..b6a7a807a428 100644 --- a/sound/soc/codecs/rt715-sdca.c +++ b/sound/soc/codecs/rt715-sdca.c @@ -502,8 +502,7 @@ static const struct snd_kcontrol_new rt715_sdca_snd_controls[] = { static int rt715_sdca_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt715_sdca_priv *rt715 = snd_soc_component_get_drvdata(component); unsigned int val, mask_sft; @@ -538,10 +537,8 @@ static int rt715_sdca_mux_get(struct snd_kcontrol *kcontrol, static int rt715_sdca_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt715_sdca_priv *rt715 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c index 7e1628a5c9d1..0881826de2f1 100644 --- a/sound/soc/codecs/rt715.c +++ b/sound/soc/codecs/rt715.c @@ -125,8 +125,7 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); @@ -152,7 +151,7 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol, rt715_get_gain(rt715, addr_h, addr_l, val_h, &read_rl, &read_ll); - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D0); @@ -206,7 +205,7 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol, } /* D0:power on state, D3: power saving mode */ - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D3); return k_vol_changed; @@ -250,8 +249,7 @@ static int rt715_set_main_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); static const unsigned int capture_reg_H[] = { RT715_SET_GAIN_MIC_ADC_H, RT715_SET_GAIN_LINE_ADC_H, @@ -274,7 +272,7 @@ static int rt715_set_main_switch_put(struct snd_kcontrol *kcontrol, addr_l = capture_reg_L[j]; rt715_get_gain(rt715, addr_h, addr_l, val_h, &read_rl, &read_ll); - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D0); @@ -322,7 +320,7 @@ static int rt715_set_main_switch_put(struct snd_kcontrol *kcontrol, } /* D0:power on state, D3: power saving mode */ - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D3); return k_changed; @@ -358,8 +356,7 @@ static int rt715_set_main_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); static const unsigned int capture_reg_H[] = { RT715_SET_GAIN_MIC_ADC_H, RT715_SET_GAIN_LINE_ADC_H, @@ -381,7 +378,7 @@ static int rt715_set_main_vol_put(struct snd_kcontrol *kcontrol, addr_l = capture_reg_L[j]; rt715_get_gain(rt715, addr_h, addr_l, val_h, &read_rl, &read_ll); - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D0); @@ -431,7 +428,7 @@ static int rt715_set_main_vol_put(struct snd_kcontrol *kcontrol, } /* D0:power on state, D3: power saving mode */ - if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY) regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D3); return k_changed; @@ -546,8 +543,7 @@ static const struct snd_kcontrol_new rt715_snd_controls[] = { static int rt715_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int reg, val; @@ -577,10 +573,8 @@ static int rt715_mux_get(struct snd_kcontrol *kcontrol, static int rt715_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; @@ -752,13 +746,12 @@ static const struct snd_soc_dapm_route rt715_audio_map[] = { static int rt715_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) { regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D0); diff --git a/sound/soc/codecs/rt721-sdca.c b/sound/soc/codecs/rt721-sdca.c index 5f7b505d5414..8233532a1752 100644 --- a/sound/soc/codecs/rt721-sdca.c +++ b/sound/soc/codecs/rt721-sdca.c @@ -746,8 +746,7 @@ static const struct snd_kcontrol_new rt721_sdca_controls[] = { static int rt721_sdca_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct rt721_sdca_priv *rt721 = snd_soc_component_get_drvdata(component); unsigned int val = 0, mask_sft, mask; @@ -786,10 +785,8 @@ static int rt721_sdca_adc_mux_get(struct snd_kcontrol *kcontrol, static int rt721_sdca_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct rt721_sdca_priv *rt721 = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; diff --git a/sound/soc/codecs/rt722-sdca-sdw.c b/sound/soc/codecs/rt722-sdca-sdw.c index 5ea40c1b159a..a0f5601a262a 100644 --- a/sound/soc/codecs/rt722-sdca-sdw.c +++ b/sound/soc/codecs/rt722-sdca-sdw.c @@ -419,7 +419,9 @@ static int rt722_sdca_sdw_probe(struct sdw_slave *slave, struct regmap *regmap; /* Regmap Initialization */ - regmap = devm_regmap_init_sdw_mbq_cfg(slave, &rt722_sdca_regmap, &rt722_mbq_config); + regmap = devm_regmap_init_sdw_mbq_cfg(&slave->dev, slave, + &rt722_sdca_regmap, + &rt722_mbq_config); if (IS_ERR(regmap)) return PTR_ERR(regmap); diff --git a/sound/soc/codecs/rt9123.c b/sound/soc/codecs/rt9123.c index b162824526d6..84fd3d6861de 100644 --- a/sound/soc/codecs/rt9123.c +++ b/sound/soc/codecs/rt9123.c @@ -107,7 +107,7 @@ static const struct soc_enum rt9123_i2sch_select_enum = static int rt9123_kcontrol_name_comp(struct snd_kcontrol *kcontrol, const char *s) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); const char *kctlname = kcontrol->id.name; if (comp && comp->name_prefix) @@ -118,7 +118,7 @@ static int rt9123_kcontrol_name_comp(struct snd_kcontrol *kcontrol, const char * static int rt9123_xhandler_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct device *dev = comp->dev; int ret; @@ -145,7 +145,7 @@ static int rt9123_xhandler_get(struct snd_kcontrol *kcontrol, struct snd_ctl_ele static int rt9123_xhandler_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct device *dev = comp->dev; int ret; diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 2cc8efe3d896..320312f8db92 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -540,7 +540,7 @@ static int dac_info_volsw(struct snd_kcontrol *kcontrol, static int dac_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int reg; int l; int r; @@ -593,7 +593,7 @@ static int dac_get_volsw(struct snd_kcontrol *kcontrol, static int dac_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int reg; int l; int r; @@ -631,7 +631,7 @@ static int dac_put_volsw(struct snd_kcontrol *kcontrol, static int avc_get_threshold(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int db, i; u16 reg = snd_soc_component_read(component, SGTL5000_DAP_AVC_THRESHOLD); @@ -664,7 +664,7 @@ static int avc_get_threshold(struct snd_kcontrol *kcontrol, static int avc_put_threshold(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int db; u16 reg; diff --git a/sound/soc/codecs/simple-mux.c b/sound/soc/codecs/simple-mux.c index 390696440155..069555f35f73 100644 --- a/sound/soc/codecs/simple-mux.c +++ b/sound/soc/codecs/simple-mux.c @@ -34,7 +34,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(simple_mux_enum, simple_mux_texts); static int simple_mux_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct snd_soc_component *c = snd_soc_dapm_to_component(dapm); struct simple_mux *priv = snd_soc_component_get_drvdata(c); @@ -46,7 +46,7 @@ static int simple_mux_control_get(struct snd_kcontrol *kcontrol, static int simple_mux_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_component *c = snd_soc_dapm_to_component(dapm); struct simple_mux *priv = snd_soc_component_get_drvdata(c); @@ -59,7 +59,8 @@ static int simple_mux_control_put(struct snd_kcontrol *kcontrol, priv->mux = ucontrol->value.enumerated.item[0]; - if (priv->idle_state != MUX_IDLE_AS_IS && dapm->bias_level < SND_SOC_BIAS_PREPARE) + if (priv->idle_state != MUX_IDLE_AS_IS && + snd_soc_dapm_get_bias_level(dapm) < SND_SOC_BIAS_PREPARE) return 0; gpiod_set_value_cansleep(priv->gpiod_mux, priv->mux); diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 980c48cbc348..06de2b4fce5e 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -309,8 +309,7 @@ static const struct soc_enum sma1303_tdm_slot_enum = static int sma1303_force_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = (int)sma1303->force_mute_status; @@ -323,8 +322,7 @@ static int sma1303_force_mute_get(struct snd_kcontrol *kcontrol, static int sma1303_force_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); bool change = false, val = (bool)ucontrol->value.integer.value[0]; @@ -343,8 +341,7 @@ static int sma1303_force_mute_put(struct snd_kcontrol *kcontrol, static int sma1303_postscaler_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); int val, ret; @@ -360,8 +357,7 @@ static int sma1303_postscaler_get(struct snd_kcontrol *kcontrol, static int sma1303_postscaler_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); int ret, val = (int)ucontrol->value.integer.value[0]; bool change; @@ -377,8 +373,7 @@ static int sma1303_postscaler_put(struct snd_kcontrol *kcontrol, static int sma1303_tdm_slot_rx_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); int val, ret; @@ -395,8 +390,7 @@ static int sma1303_tdm_slot_rx_get(struct snd_kcontrol *kcontrol, static int sma1303_tdm_slot_rx_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); int ret, val = (int)ucontrol->value.integer.value[0]; bool change; @@ -412,8 +406,7 @@ static int sma1303_tdm_slot_rx_put(struct snd_kcontrol *kcontrol, static int sma1303_tdm_slot_tx_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); int val, ret; @@ -430,8 +423,7 @@ static int sma1303_tdm_slot_tx_get(struct snd_kcontrol *kcontrol, static int sma1303_tdm_slot_tx_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); int ret, val = (int)ucontrol->value.integer.value[0]; bool change; @@ -526,7 +518,7 @@ static int sma1303_aif_in_event(struct snd_soc_dapm_widget *w, struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); int ret = 0; bool change = false, temp = false; @@ -596,7 +588,7 @@ static int sma1303_aif_out_event(struct snd_soc_dapm_widget *w, struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + unsigned int mux = snd_soc_dapm_kcontrol_get_value(w->kcontrols[0]); int ret = 0; bool change = false, temp = false; @@ -1565,8 +1557,7 @@ static void sma1303_check_fault_worker(struct work_struct *work) static int sma1303_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_sync(dapm); diff --git a/sound/soc/codecs/sma1307.c b/sound/soc/codecs/sma1307.c index b683e676640d..4bb59e5c0891 100644 --- a/sound/soc/codecs/sma1307.c +++ b/sound/soc/codecs/sma1307.c @@ -303,8 +303,7 @@ SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1307_reset_text), static int sma1307_force_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = (int)sma1307->force_mute_status; @@ -315,8 +314,7 @@ static int sma1307_force_mute_get(struct snd_kcontrol *kcontrol, static int sma1307_force_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); bool change = false, val = (bool)ucontrol->value.integer.value[0]; @@ -333,8 +331,7 @@ static int sma1307_force_mute_put(struct snd_kcontrol *kcontrol, static int sma1307_tdm_slot_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); int val1, val2; @@ -367,8 +364,7 @@ static int sma1307_tdm_slot_get(struct snd_kcontrol *kcontrol, static int sma1307_tdm_slot_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); int val = (int)ucontrol->value.integer.value[0]; bool change; @@ -421,8 +417,7 @@ static int sma1307_tdm_slot_put(struct snd_kcontrol *kcontrol, static int sma1307_sw_ot1_prot_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = (int)sma1307->sw_ot1_prot; @@ -433,8 +428,7 @@ static int sma1307_sw_ot1_prot_get(struct snd_kcontrol *kcontrol, static int sma1307_sw_ot1_prot_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); bool change = false, val = (bool)ucontrol->value.integer.value[0]; @@ -451,8 +445,7 @@ static int sma1307_sw_ot1_prot_put(struct snd_kcontrol *kcontrol, static int sma1307_check_fault_status_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = (int)sma1307->check_fault_status; @@ -463,8 +456,7 @@ static int sma1307_check_fault_status_get(struct snd_kcontrol *kcontrol, static int sma1307_check_fault_status_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); bool change = false, val = (bool)ucontrol->value.integer.value[0]; @@ -481,8 +473,7 @@ static int sma1307_check_fault_status_put(struct snd_kcontrol *kcontrol, static int sma1307_check_fault_period_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = sma1307->check_fault_period; @@ -493,8 +484,7 @@ static int sma1307_check_fault_period_get(struct snd_kcontrol *kcontrol, static int sma1307_check_fault_period_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -516,8 +506,7 @@ static int sma1307_check_fault_period_put(struct snd_kcontrol *kcontrol, static int sma1307_reset_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); regmap_update_bits(sma1307->regmap, SMA1307_00_SYSTEM_CTRL, @@ -533,8 +522,7 @@ static int sma1307_reset_put(struct snd_kcontrol *kcontrol, static int sma1307_binary_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sma1307_priv *sma1307 = snd_kcontrol_chip(kcontrol); sma1307->binary_mode = (int)ucontrol->value.enumerated.item[0]; @@ -802,10 +790,9 @@ static int sma1307_power_event(struct snd_soc_dapm_widget *w, static int sma1307_dapm_aif_in_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct sma1307_priv *sma1307 = - snd_soc_component_get_drvdata(dapm->component); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = (unsigned int)sma1307->dapm_aif_in; snd_soc_dapm_put_enum_double(kcontrol, ucontrol); @@ -816,10 +803,9 @@ static int sma1307_dapm_aif_in_get(struct snd_kcontrol *kcontrol, static int sma1307_dapm_aif_in_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct sma1307_priv *sma1307 = - snd_soc_component_get_drvdata(dapm->component); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); int val = (int)ucontrol->value.enumerated.item[0]; bool change; @@ -842,10 +828,9 @@ static int sma1307_dapm_aif_in_put(struct snd_kcontrol *kcontrol, static int sma1307_dapm_sdo_setting_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct sma1307_priv *sma1307 = - snd_soc_component_get_drvdata(dapm->component); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = (unsigned int)sma1307->dapm_sdo_setting; @@ -857,10 +842,9 @@ static int sma1307_dapm_sdo_setting_get(struct snd_kcontrol *kcontrol, static int sma1307_dapm_sdo_setting_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct sma1307_priv *sma1307 = - snd_soc_component_get_drvdata(dapm->component); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); int val = (int)ucontrol->value.enumerated.item[0]; bool change; @@ -883,10 +867,9 @@ static int sma1307_dapm_sdo_setting_put(struct snd_kcontrol *kcontrol, static int sma1307_dapm_aif_out_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct sma1307_priv *sma1307 = - snd_soc_component_get_drvdata(dapm->component); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); unsigned int val = 0; if (!strcmp(kcontrol->id.name, SMA1307_AIF_OUT0_NAME)) { @@ -907,10 +890,9 @@ static int sma1307_dapm_aif_out_get(struct snd_kcontrol *kcontrol, static int sma1307_dapm_aif_out_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct sma1307_priv *sma1307 = - snd_soc_component_get_drvdata(dapm->component); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); int val = (int)ucontrol->value.enumerated.item[0]; bool change; @@ -945,10 +927,9 @@ static int sma1307_dapm_aif_out_put(struct snd_kcontrol *kcontrol, static int sma1307_dapm_sdo_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct sma1307_priv *sma1307 = - snd_soc_component_get_drvdata(dapm->component); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = (long)sma1307->dapm_sdo_en; snd_soc_dapm_put_volsw(kcontrol, ucontrol); @@ -959,10 +940,9 @@ static int sma1307_dapm_sdo_enable_get(struct snd_kcontrol *kcontrol, static int sma1307_dapm_sdo_enable_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct sma1307_priv *sma1307 = - snd_soc_component_get_drvdata(dapm->component); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct sma1307_priv *sma1307 = snd_soc_component_get_drvdata(component); int val = (int)ucontrol->value.integer.value[0]; bool change; @@ -1869,8 +1849,7 @@ static void sma1307_set_default(struct snd_soc_component *component) static int sma1307_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_sync(dapm); diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c index 06016e88dd27..9008e5416004 100644 --- a/sound/soc/codecs/ssm2518.c +++ b/sound/soc/codecs/ssm2518.c @@ -500,6 +500,7 @@ static int ssm2518_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct ssm2518 *ssm2518 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret = 0; switch (level) { @@ -508,7 +509,7 @@ static int ssm2518_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) ret = ssm2518_set_power(ssm2518, true); break; case SND_SOC_BIAS_OFF: diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index c29324403e9d..fccd2eacd7a6 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -562,7 +562,7 @@ static int ssm2602_resume(struct snd_soc_component *component) static int ssm2602_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(component); int ret; @@ -587,7 +587,7 @@ static int ssm2602_component_probe(struct snd_soc_component *component) static int ssm2604_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; ret = snd_soc_dapm_new_controls(dapm, ssm2604_dapm_widgets, diff --git a/sound/soc/codecs/ssm4567.c b/sound/soc/codecs/ssm4567.c index 3e09c85abedb..15f88624faeb 100644 --- a/sound/soc/codecs/ssm4567.c +++ b/sound/soc/codecs/ssm4567.c @@ -369,6 +369,7 @@ static int ssm4567_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct ssm4567 *ssm4567 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret = 0; switch (level) { @@ -377,7 +378,7 @@ static int ssm4567_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) ret = ssm4567_set_power(ssm4567, true); break; case SND_SOC_BIAS_OFF: diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 24d4b643917d..b9f9784f5164 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -264,7 +264,7 @@ static int sta32x_coefficient_info(struct snd_kcontrol *kcontrol, static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; @@ -306,7 +306,7 @@ exit_unlock: static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; @@ -799,6 +799,7 @@ static int sta32x_set_bias_level(struct snd_soc_component *component, { int ret; struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); dev_dbg(component->dev, "level = %d\n", level); switch (level) { @@ -813,7 +814,7 @@ static int sta32x_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); if (ret != 0) { @@ -870,6 +871,7 @@ static struct snd_soc_dai_driver sta32x_dai = { static int sta32x_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); struct sta32x_platform_data *pdata = sta32x->pdata; int i, ret = 0, thermal = 0; @@ -974,7 +976,7 @@ static int sta32x_probe(struct snd_soc_component *component) if (sta32x->pdata->needs_esd_watchdog) INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); diff --git a/sound/soc/codecs/sta350.c b/sound/soc/codecs/sta350.c index d1450de92652..71af82b099c0 100644 --- a/sound/soc/codecs/sta350.c +++ b/sound/soc/codecs/sta350.c @@ -301,7 +301,7 @@ static int sta350_coefficient_info(struct snd_kcontrol *kcontrol, static int sta350_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; @@ -343,7 +343,7 @@ exit_unlock: static int sta350_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; @@ -830,6 +830,7 @@ static int sta350_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; dev_dbg(component->dev, "level = %d\n", level); @@ -845,7 +846,7 @@ static int sta350_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable( ARRAY_SIZE(sta350->supplies), sta350->supplies); @@ -905,6 +906,7 @@ static struct snd_soc_dai_driver sta350_dai = { static int sta350_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); struct sta350_platform_data *pdata = sta350->pdata; int i, ret = 0, thermal = 0; @@ -1028,7 +1030,7 @@ static int sta350_probe(struct snd_soc_component *component) sta350->coef_shadow[60] = 0x400000; sta350->coef_shadow[61] = 0x400000; - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); diff --git a/sound/soc/codecs/sta529.c b/sound/soc/codecs/sta529.c index f7718491c899..8c3b2652b02e 100644 --- a/sound/soc/codecs/sta529.c +++ b/sound/soc/codecs/sta529.c @@ -155,6 +155,7 @@ static int sta529_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct sta529 *sta529 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -165,7 +166,7 @@ static int sta529_set_bias_level(struct snd_soc_component *component, enum FFX_CLK_ENB); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) regcache_sync(sta529->regmap); snd_soc_component_update_bits(component, STA529_FFXCFG0, POWER_CNTLMSAK, POWER_STDBY); diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c index 8e00dcc09d0c..ceb367ae05ba 100644 --- a/sound/soc/codecs/tas2562.c +++ b/sound/soc/codecs/tas2562.c @@ -459,7 +459,7 @@ static int tas2562_dac_event(struct snd_soc_dapm_widget *w, static int tas2562_volume_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tas2562_data *tas2562 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tas2562->volume_lvl; @@ -469,7 +469,7 @@ static int tas2562_volume_control_get(struct snd_kcontrol *kcontrol, static int tas2562_volume_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tas2562_data *tas2562 = snd_soc_component_get_drvdata(component); int ret; u32 reg_val; diff --git a/sound/soc/codecs/tas2781-comlib-i2c.c b/sound/soc/codecs/tas2781-comlib-i2c.c index b3fd7350143b..e24d56a14cfd 100644 --- a/sound/soc/codecs/tas2781-comlib-i2c.c +++ b/sound/soc/codecs/tas2781-comlib-i2c.c @@ -320,7 +320,7 @@ void tasdevice_reset(struct tasdevice_priv *tas_dev) for (i = 0; i < tas_dev->ndev; i++) { ret = tasdevice_dev_write(tas_dev, i, TASDEVICE_REG_SWRESET, - tas_dev->chip_id >= TAS5825 ? + tas_dev->chip_id >= TAS5802 ? TAS5825_REG_SWRESET_RESET : TASDEVICE_REG_SWRESET_RESET); if (ret < 0) diff --git a/sound/soc/codecs/tas2781-i2c.c b/sound/soc/codecs/tas2781-i2c.c index 8f37aa00e62e..d1c76ab0144d 100644 --- a/sound/soc/codecs/tas2781-i2c.c +++ b/sound/soc/codecs/tas2781-i2c.c @@ -105,14 +105,20 @@ static const struct i2c_device_id tasdevice_id[] = { { "tas2120", TAS2120 }, { "tas2320", TAS2320 }, { "tas2563", TAS2563 }, + { "tas2568", TAS2568 }, { "tas2570", TAS2570 }, { "tas2572", TAS2572 }, + { "tas2574", TAS2574 }, { "tas2781", TAS2781 }, { "tas5802", TAS5802 }, + { "tas5806m", TAS5806M }, + { "tas5806md", TAS5806MD }, { "tas5815", TAS5815 }, + { "tas5822", TAS5822 }, { "tas5825", TAS5825 }, { "tas5827", TAS5827 }, { "tas5828", TAS5828 }, + { "tas5830", TAS5830 }, {} }; MODULE_DEVICE_TABLE(i2c, tasdevice_id); @@ -124,14 +130,20 @@ static const struct of_device_id tasdevice_of_match[] = { { .compatible = "ti,tas2120" }, { .compatible = "ti,tas2320" }, { .compatible = "ti,tas2563" }, + { .compatible = "ti,tas2568" }, { .compatible = "ti,tas2570" }, { .compatible = "ti,tas2572" }, + { .compatible = "ti,tas2574" }, { .compatible = "ti,tas2781" }, { .compatible = "ti,tas5802" }, + { .compatible = "ti,tas5806m" }, + { .compatible = "ti,tas5806md" }, { .compatible = "ti,tas5815" }, + { .compatible = "ti,tas5822" }, { .compatible = "ti,tas5825" }, { .compatible = "ti,tas5827" }, { .compatible = "ti,tas5828" }, + { .compatible = "ti,tas5830" }, {}, }; MODULE_DEVICE_TABLE(of, tasdevice_of_match); @@ -151,7 +163,7 @@ MODULE_DEVICE_TABLE(of, tasdevice_of_match); static int tas2781_digital_getvol(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -162,7 +174,7 @@ static int tas2781_digital_getvol(struct snd_kcontrol *kcontrol, static int tas2781_digital_putvol(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -173,7 +185,7 @@ static int tas2781_digital_putvol(struct snd_kcontrol *kcontrol, static int tas2781_amp_getvol(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -184,7 +196,7 @@ static int tas2781_amp_getvol(struct snd_kcontrol *kcontrol, static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); struct soc_mixer_control *mc = @@ -196,8 +208,7 @@ static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol, static int tasdev_force_fwload_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(component); @@ -211,8 +222,7 @@ static int tasdev_force_fwload_get(struct snd_kcontrol *kcontrol, static int tasdev_force_fwload_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(component); bool change, val = (bool)ucontrol->value.integer.value[0]; @@ -232,7 +242,7 @@ static int tasdev_force_fwload_put(struct snd_kcontrol *kcontrol, static int tasdev_cali_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *priv = snd_soc_component_get_drvdata(comp); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; @@ -469,7 +479,7 @@ static void sngl_calib_start(struct tasdevice_priv *tas_priv, int i, static int tas2781_calib_start_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *priv = snd_soc_component_get_drvdata(comp); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; @@ -542,7 +552,7 @@ static int tas2563_calib_start_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct bulk_reg_val *q = (struct bulk_reg_val *)tas2563_cali_start_reg; - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp); const int sum = ARRAY_SIZE(tas2563_cali_start_reg); int i, j; @@ -606,7 +616,7 @@ static void tas2563_calib_stop_put(struct tasdevice_priv *tas_priv) static int tasdev_calib_stop_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *priv = snd_soc_component_get_drvdata(comp); guard(mutex)(&priv->codec_lock); @@ -621,7 +631,7 @@ static int tasdev_calib_stop_put(struct snd_kcontrol *kcontrol, static int tasdev_cali_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *priv = snd_soc_component_get_drvdata(comp); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; @@ -668,7 +678,7 @@ static int tasdev_cali_data_put(struct snd_kcontrol *kcontrol, static int tas2781_latch_reg_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp); struct i2c_client *clt = (struct i2c_client *)tas_priv->client; struct soc_bytes_ext *bytes_ext = @@ -701,7 +711,7 @@ static int tas2781_latch_reg_get(struct snd_kcontrol *kcontrol, static int tasdev_tf_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; @@ -728,7 +738,7 @@ static int tasdev_tf_data_get(struct snd_kcontrol *kcontrol, static int tasdev_re_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; @@ -754,7 +764,7 @@ static int tasdev_re_data_get(struct snd_kcontrol *kcontrol, static int tasdev_r0_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp); struct calidata *cali_data = &tas_priv->cali_data; struct soc_bytes_ext *bytes_ext = @@ -777,7 +787,7 @@ static int tasdev_r0_data_get(struct snd_kcontrol *kcontrol, static int tasdev_XMA1_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp); struct tasdevice_fw *tas_fmw = tas_priv->fmw; struct fct_param_address *p = &(tas_fmw->fct_par_addr); @@ -797,7 +807,7 @@ static int tasdev_XMA1_data_get(struct snd_kcontrol *kcontrol, static int tasdev_XMA2_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(comp); struct tasdevice_fw *tas_fmw = tas_priv->fmw; struct fct_param_address *p = &(tas_fmw->fct_par_addr); @@ -827,7 +837,7 @@ static int tasdevice_digital_gain_get( { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_dev = snd_soc_component_get_drvdata(codec); unsigned int l = 0, r = mc->max; unsigned int target, ar_mid, mid, ar_l, ar_r; @@ -871,7 +881,7 @@ static int tasdevice_digital_gain_put( { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_dev = snd_soc_component_get_drvdata(codec); int vol = ucontrol->value.integer.value[0]; int status = 0, max = mc->max, rc = 1; @@ -973,7 +983,7 @@ static const struct snd_kcontrol_new tas2563_cali_controls[] = { static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); int ret = 0; @@ -990,7 +1000,7 @@ static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol, static int tasdevice_info_active_num(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -1015,7 +1025,7 @@ static int tasdevice_info_chip_id(struct snd_kcontrol *kcontrol, static int tasdevice_info_programs(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); struct tasdevice_fw *tas_fw = tas_priv->fmw; @@ -1030,8 +1040,7 @@ static int tasdevice_info_programs(struct snd_kcontrol *kcontrol, static int tasdevice_info_configurations( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); struct tasdevice_fw *tas_fw = tas_priv->fmw; @@ -1046,7 +1055,7 @@ static int tasdevice_info_configurations( static int tasdevice_info_profile(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -1060,7 +1069,7 @@ static int tasdevice_info_profile(struct snd_kcontrol *kcontrol, static int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = tas_priv->rcabin.profile_cfg_id; @@ -1071,7 +1080,7 @@ static int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol, static int tasdevice_get_chip_id(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = tas_priv->chip_id; @@ -1117,7 +1126,7 @@ out: static int tasdevice_program_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = tas_priv->cur_prog; @@ -1128,7 +1137,7 @@ static int tasdevice_program_get(struct snd_kcontrol *kcontrol, static int tasdevice_program_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); unsigned int nr_program = ucontrol->value.integer.value[0]; int ret = 0; @@ -1145,7 +1154,7 @@ static int tasdevice_configuration_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); ucontrol->value.integer.value[0] = tas_priv->cur_conf; @@ -1157,7 +1166,7 @@ static int tasdevice_configuration_put( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); unsigned int nr_configuration = ucontrol->value.integer.value[0]; int ret = 0; @@ -1173,7 +1182,7 @@ static int tasdevice_configuration_put( static int tasdevice_active_num_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); struct i2c_client *clt = (struct i2c_client *)tas_priv->client; struct tasdevice *tasdev = tas_priv->tasdevice; @@ -1192,7 +1201,7 @@ static int tasdevice_active_num_get(struct snd_kcontrol *kcontrol, static int tasdevice_active_num_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec); int dev_id = ucontrol->value.integer.value[0]; int max = tas_priv->ndev - 1; @@ -1391,7 +1400,7 @@ static int tasdevice_create_cali_ctrls(struct tasdevice_priv *priv) /* * Alloc kcontrol via devm_kzalloc(), which don't manually - * free the kcontrol。 + * free the kcontrol. */ cali_ctrls = devm_kcalloc(priv->dev, nctrls, sizeof(cali_ctrls[0]), GFP_KERNEL); @@ -1644,8 +1653,10 @@ static void tasdevice_fw_ready(const struct firmware *fmw, case TAS2118: case TAS2120: case TAS2320: + case TAS2568: case TAS2570: case TAS2572: + case TAS2574: goto out; } if (tas_priv->name_prefix) @@ -1671,9 +1682,7 @@ static void tasdevice_fw_ready(const struct firmware *fmw, } tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK; - /* There is no calibration required for - * TAS5802/TAS5815/TAS5825/TAS5827/TAS5828. - */ + /* There is no calibration required for TAS58XX. */ if (tas_priv->chip_id < TAS5802) { ret = tasdevice_create_cali_ctrls(tas_priv); if (ret) { @@ -1729,10 +1738,14 @@ out: case TAS2563: case TAS2781: case TAS5802: + case TAS5806M: + case TAS5806MD: case TAS5815: + case TAS5822: case TAS5825: case TAS5827: case TAS5828: + case TAS5830: /* If DSP FW fail, DSP kcontrol won't be created. */ tasdevice_dsp_remove(tas_priv); } @@ -1883,8 +1896,10 @@ static int tasdevice_codec_probe(struct snd_soc_component *codec) case TAS2118: case TAS2120: case TAS2320: + case TAS2568: case TAS2570: case TAS2572: + case TAS2574: p = (struct snd_kcontrol_new *)tas2x20_snd_controls; size = ARRAY_SIZE(tas2x20_snd_controls); tas_priv->dvc_tlv_table = tas2x20_dvc_table; @@ -1894,10 +1909,14 @@ static int tasdevice_codec_probe(struct snd_soc_component *codec) size = ARRAY_SIZE(tas2781_snd_controls); break; case TAS5802: + case TAS5806M: + case TAS5806MD: case TAS5815: + case TAS5822: case TAS5825: case TAS5827: case TAS5828: + case TAS5830: p = (struct snd_kcontrol_new *)tas5825_snd_controls; size = ARRAY_SIZE(tas5825_snd_controls); break; @@ -2004,7 +2023,8 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv) dev_err(tas_priv->dev, "%s Can't get reset GPIO\n", __func__); - strcpy(tas_priv->dev_name, tasdevice_id[tas_priv->chip_id].name); + strscpy(tas_priv->dev_name, tasdevice_id[tas_priv->chip_id].name, + sizeof(tas_priv->dev_name)); } static int tasdevice_i2c_probe(struct i2c_client *i2c) @@ -2070,14 +2090,20 @@ static const struct acpi_device_id tasdevice_acpi_match[] = { { "TXNW2120", TAS2120 }, { "TXNW2320", TAS2320 }, { "TXNW2563", TAS2563 }, + { "TXNW2568", TAS2568 }, { "TXNW2570", TAS2570 }, { "TXNW2572", TAS2572 }, + { "TXNW2574", TAS2574 }, { "TXNW2781", TAS2781 }, { "TXNW5802", TAS5802 }, + { "TXNW806M", TAS5806M }, + { "TXNW806D", TAS5806MD }, { "TXNW5815", TAS5815 }, + { "TXNW5822", TAS5822 }, { "TXNW5825", TAS5825 }, { "TXNW5827", TAS5827 }, { "TXNW5828", TAS5828 }, + { "TXNW5830", TAS5830 }, {}, }; diff --git a/sound/soc/codecs/tas2783-sdw.c b/sound/soc/codecs/tas2783-sdw.c index e273b80d033e..43b779873b93 100644 --- a/sound/soc/codecs/tas2783-sdw.c +++ b/sound/soc/codecs/tas2783-sdw.c @@ -693,7 +693,6 @@ static s32 tas2783_update_calibdata(struct tas2783_prv *tas_dev) tmp_val = (u32 *)tas_dev->cali_data.data; attr = 0; - i = 0; /* * In some cases, the calibration is performed in Windows, @@ -1297,7 +1296,8 @@ static s32 tas_sdw_probe(struct sdw_slave *peripheral, init_waitqueue_head(&tas_dev->fw_wait); dev_set_drvdata(dev, tas_dev); - regmap = devm_regmap_init_sdw_mbq_cfg(peripheral, + regmap = devm_regmap_init_sdw_mbq_cfg(&peripheral->dev, + peripheral, &tas_regmap, &tas2783_mbq_cfg); if (IS_ERR(regmap)) diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index b97c0e885713..12bf6a89dbd8 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c @@ -272,7 +272,7 @@ static int tas5086_set_deemph(struct snd_soc_component *component) static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tas5086_private *priv = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = priv->deemph; @@ -283,7 +283,7 @@ static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, static int tas5086_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tas5086_private *priv = snd_soc_component_get_drvdata(component); priv->deemph = ucontrol->value.integer.value[0]; diff --git a/sound/soc/codecs/tas571x.c b/sound/soc/codecs/tas571x.c index 41d73f470f8b..19ccf8641e16 100644 --- a/sound/soc/codecs/tas571x.c +++ b/sound/soc/codecs/tas571x.c @@ -241,7 +241,7 @@ static int tas571x_coefficient_info(struct snd_kcontrol *kcontrol, static int tas571x_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct i2c_client *i2c = to_i2c_client(component->dev); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; @@ -253,7 +253,7 @@ static int tas571x_coefficient_get(struct snd_kcontrol *kcontrol, static int tas571x_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct i2c_client *i2c = to_i2c_client(component->dev); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; @@ -322,6 +322,7 @@ static int tas571x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct tas571x_private *priv = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -330,7 +331,7 @@ static int tas571x_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { if (!IS_ERR(priv->mclk)) { ret = clk_prepare_enable(priv->mclk); if (ret) { diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c index f0361822061f..2dcdd0a4bf80 100644 --- a/sound/soc/codecs/tas5720.c +++ b/sound/soc/codecs/tas5720.c @@ -564,7 +564,7 @@ static DECLARE_TLV_DB_SCALE(tas5722_dac_tlv, -10350, 25, 0); static int tas5722_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int val; val = snd_soc_component_read(component, TAS5720_VOLUME_CTRL_REG); @@ -579,7 +579,7 @@ static int tas5722_volume_get(struct snd_kcontrol *kcontrol, static int tas5722_volume_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int sel = ucontrol->value.integer.value[0]; snd_soc_component_write(component, TAS5720_VOLUME_CTRL_REG, sel >> 1); diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c index 4c32500eef3e..867046b7aaa0 100644 --- a/sound/soc/codecs/tas5805m.c +++ b/sound/soc/codecs/tas5805m.c @@ -226,8 +226,7 @@ static int tas5805m_vol_info(struct snd_kcontrol *kcontrol, static int tas5805m_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tas5805m_priv *tas5805m = snd_soc_component_get_drvdata(component); @@ -247,8 +246,7 @@ static inline int volume_is_valid(int v) static int tas5805m_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tas5805m_priv *tas5805m = snd_soc_component_get_drvdata(component); int ret = 0; diff --git a/sound/soc/codecs/tas6424.c b/sound/soc/codecs/tas6424.c index 9be054837f68..85ecc246896f 100644 --- a/sound/soc/codecs/tas6424.c +++ b/sound/soc/codecs/tas6424.c @@ -346,6 +346,8 @@ static int tas6424_power_on(struct snd_soc_component *component) static int tas6424_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + dev_dbg(component->dev, "%s() level=%d\n", __func__, level); switch (level) { @@ -353,7 +355,7 @@ static int tas6424_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) tas6424_power_on(component); break; case SND_SOC_BIAS_OFF: diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c index 79847a90ac46..7204be155eb9 100644 --- a/sound/soc/codecs/tfa989x.c +++ b/sound/soc/codecs/tfa989x.c @@ -105,7 +105,7 @@ static const struct snd_soc_dapm_route tfa989x_dapm_routes[] = { static int tfa989x_put_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tfa989x *tfa989x = snd_soc_component_get_drvdata(component); gpiod_set_value_cansleep(tfa989x->rcv_gpiod, ucontrol->value.enumerated.item[0]); diff --git a/sound/soc/codecs/tlv320adc3xxx.c b/sound/soc/codecs/tlv320adc3xxx.c index 258fbcaf345a..270eee1ea534 100644 --- a/sound/soc/codecs/tlv320adc3xxx.c +++ b/sound/soc/codecs/tlv320adc3xxx.c @@ -565,7 +565,7 @@ static int adc3xxx_coefficient_info(struct snd_kcontrol *kcontrol, static int adc3xxx_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int numcoeff = kcontrol->private_value >> 16; int reg = kcontrol->private_value & 0xffff; int index = 0; @@ -591,7 +591,7 @@ static int adc3xxx_coefficient_get(struct snd_kcontrol *kcontrol, static int adc3xxx_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int numcoeff = kcontrol->private_value >> 16; int reg = kcontrol->private_value & 0xffff; int index = 0; @@ -1193,7 +1193,7 @@ static int adc3xxx_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(dai->component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(dai->component); struct adc3xxx *adc3xxx = snd_soc_component_get_drvdata(component); int i, width = 16; u8 iface_len, bdiv; @@ -1299,7 +1299,7 @@ static int adc3xxx_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int adc3xxx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { struct snd_soc_component *component = codec_dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct adc3xxx *adc3xxx = snd_soc_component_get_drvdata(component); u8 clkdir = 0, format = 0; int master = 0; diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c index d594bf166c0e..443cf59cb71a 100644 --- a/sound/soc/codecs/tlv320adcx140.c +++ b/sound/soc/codecs/tlv320adcx140.c @@ -612,8 +612,7 @@ static int adcx140_phase_calib_info(struct snd_kcontrol *kcontrol, static int adcx140_phase_calib_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *value) { - struct snd_soc_component *codec = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(codec); value->value.integer.value[0] = adcx140->phase_calib_on ? 1 : 0; @@ -625,8 +624,7 @@ static int adcx140_phase_calib_get(struct snd_kcontrol *kcontrol, static int adcx140_phase_calib_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *value) { - struct snd_soc_component *codec - = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol); struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(codec); bool v = value->value.integer.value[0] ? true : false; diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index c47aa4d4162d..04ec8fb5c6e5 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -77,7 +77,7 @@ static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0); static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u16 val, reg; val = (ucontrol->value.integer.value[0] & 0x07); @@ -100,7 +100,7 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u16 val; val = snd_soc_component_read(component, TLV320AIC23_ANLG) & (0x1C0); diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index 4b3f9128ec37..4362c2c06ce8 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -799,7 +799,7 @@ static int aic31xx_add_controls(struct snd_soc_component *component) static int aic31xx_add_widgets(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); int ret = 0; @@ -1030,7 +1030,7 @@ static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute, static int aic31xx_clock_master_routes(struct snd_soc_component *component, unsigned int fmt) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); int ret; @@ -1316,18 +1316,20 @@ static void aic31xx_power_off(struct snd_soc_component *component) static int aic31xx_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + dev_dbg(component->dev, "## %s: %d -> %d\n", __func__, - snd_soc_component_get_bias_level(component), level); + snd_soc_dapm_get_bias_level(dapm), level); switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) aic31xx_clk_on(component); break; case SND_SOC_BIAS_STANDBY: - switch (snd_soc_component_get_bias_level(component)) { + switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_OFF: aic31xx_power_on(component); break; @@ -1339,7 +1341,7 @@ static int aic31xx_set_bias_level(struct snd_soc_component *component, } break; case SND_SOC_BIAS_OFF: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) aic31xx_power_off(component); break; } diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 715a07ab97b9..d85094557215 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -883,6 +883,7 @@ static int aic32x4_mute(struct snd_soc_dai *dai, int mute, int direction) static int aic32x4_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; static struct clk_bulk_data clocks[] = { @@ -907,7 +908,7 @@ static int aic32x4_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: /* Initial cold start */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) break; clk_bulk_disable_unprepare(ARRAY_SIZE(clocks), clocks); diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index eea8ca285f8e..ce22298b43ef 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -163,8 +163,8 @@ EXPORT_SYMBOL_GPL(aic3x_regmap); static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int reg = mc->reg; @@ -1009,7 +1009,7 @@ static const struct snd_soc_dapm_route intercon_3007[] = { static int aic3x_add_widgets(struct snd_soc_component *component) { struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (aic3x->model) { case AIC3X_MODEL_3X: @@ -1449,13 +1449,14 @@ out: static int aic3x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY && + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY && aic3x->master) { /* enable pll */ snd_soc_component_update_bits(component, AIC3X_PLL_PROGA_REG, @@ -1465,7 +1466,7 @@ static int aic3x_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_STANDBY: if (!aic3x->power) aic3x_set_power(component, 1); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE && + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_PREPARE && aic3x->master) { /* disable pll */ snd_soc_component_update_bits(component, AIC3X_PLL_PROGA_REG, diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index c495be1cf2ed..605da1259fc6 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -442,7 +442,7 @@ static int dac33_playback_event(struct snd_soc_dapm_widget *w, static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = dac33->fifo_mode; @@ -453,7 +453,7 @@ static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); int ret = 0; @@ -623,6 +623,7 @@ static const struct snd_soc_dapm_route audio_map[] = { static int dac33_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -631,7 +632,7 @@ static int dac33_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Coming from OFF, switch on the component */ ret = dac33_hard_power(component, 1); if (ret != 0) @@ -642,7 +643,7 @@ static int dac33_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_OFF: /* Do not power off, when the component is already off */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) return 0; ret = dac33_hard_power(component, 0); if (ret != 0) diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c index f8a3d1b40990..7390ab250ebb 100644 --- a/sound/soc/codecs/tscs42xx.c +++ b/sound/soc/codecs/tscs42xx.c @@ -263,8 +263,7 @@ exit: static int coeff_ram_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); struct coeff_ram_ctl *ctl = (struct coeff_ram_ctl *)kcontrol->private_value; @@ -283,8 +282,7 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol, static int coeff_ram_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); struct coeff_ram_ctl *ctl = (struct coeff_ram_ctl *)kcontrol->private_value; diff --git a/sound/soc/codecs/tscs454.c b/sound/soc/codecs/tscs454.c index da2f3cb1cd13..64d0da40fbaf 100644 --- a/sound/soc/codecs/tscs454.c +++ b/sound/soc/codecs/tscs454.c @@ -308,8 +308,7 @@ struct reg_setting { static int coeff_ram_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tscs454 *tscs454 = snd_soc_component_get_drvdata(component); struct coeff_ram_ctl *ctl = (struct coeff_ram_ctl *)kcontrol->private_value; @@ -389,8 +388,7 @@ static int write_coeff_ram(struct snd_soc_component *component, u8 *coeff_ram, static int coeff_ram_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct tscs454 *tscs454 = snd_soc_component_get_drvdata(component); struct coeff_ram_ctl *ctl = (struct coeff_ram_ctl *)kcontrol->private_value; diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 92194579e15b..9476cdfd4dde 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -830,7 +830,7 @@ static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg = mc->reg; unsigned int shift = mc->shift; unsigned int rshift = mc->rshift; @@ -859,7 +859,7 @@ static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg = mc->reg; unsigned int shift = mc->shift; unsigned int rshift = mc->rshift; @@ -888,7 +888,7 @@ static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -915,7 +915,7 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -956,7 +956,7 @@ static SOC_ENUM_SINGLE_DECL(twl4030_op_modes_enum, static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); if (twl4030->configured) { @@ -1570,13 +1570,15 @@ static const struct snd_soc_dapm_route intercon[] = { static int twl4030_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) twl4030_codec_enable(component, 1); break; case SND_SOC_BIAS_OFF: diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index dd5ee5dc0cd7..e10c51092a35 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -323,7 +323,7 @@ static irqreturn_t twl6040_audio_handler(int irq, void *data) static int twl6040_soc_dapm_put_vibra_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; @@ -472,7 +472,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(twl6040_power_mode_enum, static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct twl6040_data *priv = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = priv->hs_power_mode; @@ -483,7 +483,7 @@ static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct twl6040_data *priv = snd_soc_component_get_drvdata(component); int high_perf = ucontrol->value.enumerated.item[0]; int ret = 0; @@ -500,7 +500,7 @@ static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct twl6040_data *priv = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = priv->pll_power_mode; @@ -511,7 +511,7 @@ static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, static int twl6040_pll_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct twl6040_data *priv = snd_soc_component_get_drvdata(component); priv->pll_power_mode = ucontrol->value.enumerated.item[0]; @@ -521,7 +521,7 @@ static int twl6040_pll_put_enum(struct snd_kcontrol *kcontrol, int twl6040_get_dl1_gain(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); if (snd_soc_dapm_get_pin_status(dapm, "EP")) return -1; /* -1dB */ @@ -1097,6 +1097,7 @@ static struct snd_soc_dai_driver twl6040_dai[] = { static int twl6040_probe(struct snd_soc_component *component) { struct twl6040_data *priv; + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct platform_device *pdev = to_platform_device(component->dev); int ret = 0; @@ -1125,7 +1126,7 @@ static int twl6040_probe(struct snd_soc_component *component) return ret; } - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); twl6040_init_chip(component); return 0; diff --git a/sound/soc/codecs/uda1334.c b/sound/soc/codecs/uda1334.c index 296caad5d026..f799772ff747 100644 --- a/sound/soc/codecs/uda1334.c +++ b/sound/soc/codecs/uda1334.c @@ -42,7 +42,7 @@ static const struct snd_soc_dapm_route uda1334_dapm_routes[] = { static int uda1334_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct uda1334_priv *uda1334 = snd_soc_component_get_drvdata(component); int deemph = ucontrol->value.integer.value[0]; @@ -57,7 +57,7 @@ static int uda1334_put_deemph(struct snd_kcontrol *kcontrol, static int uda1334_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct uda1334_priv *uda1334 = snd_soc_component_get_drvdata(component); int ret; diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index c179d865b938..9e9c540a45ca 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -588,6 +588,7 @@ static void uda1380_pcm_shutdown(struct snd_pcm_substream *substream, static int uda1380_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int pm = uda1380_read_reg_cache(component, UDA1380_PM); int reg; struct uda1380_platform_data *pdata = component->dev->platform_data; @@ -599,7 +600,7 @@ static int uda1380_set_bias_level(struct snd_soc_component *component, uda1380_write(component, UDA1380_PM, R02_PON_BIAS | pm); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { if (gpio_is_valid(pdata->gpio_power)) { gpio_set_value(pdata->gpio_power, 1); mdelay(1); diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c index 1c050b8c19de..640e43ee1975 100644 --- a/sound/soc/codecs/wcd9335.c +++ b/sound/soc/codecs/wcd9335.c @@ -1260,8 +1260,9 @@ static const struct snd_kcontrol_new sb_tx8_mux = static int slim_rx_mux_get(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc); - struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); + struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_to_widget(kc); + struct device *dev = snd_soc_dapm_to_dev(w->dapm); + struct wcd9335_codec *wcd = dev_get_drvdata(dev); u32 port_id = w->shift; ucontrol->value.enumerated.item[0] = wcd->rx_port_value[port_id]; @@ -1272,8 +1273,9 @@ static int slim_rx_mux_get(struct snd_kcontrol *kc, static int slim_rx_mux_put(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc); - struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); + struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_to_widget(kc); + struct device *dev = snd_soc_dapm_to_dev(w->dapm); + struct wcd9335_codec *wcd = dev_get_drvdata(dev); struct soc_enum *e = (struct soc_enum *)kc->private_value; struct snd_soc_dapm_update *update = NULL; u32 port_id = w->shift; @@ -1323,9 +1325,10 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc); - struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev); - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kc); + struct device *dev = snd_soc_dapm_to_dev(dapm); + struct wcd9335_codec *wcd = dev_get_drvdata(dev); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kc); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kc->private_value; int dai_id = widget->shift; @@ -1340,8 +1343,9 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc); - struct wcd9335_codec *wcd = dev_get_drvdata(widget->dapm->dev); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kc); + struct device *dev = snd_soc_dapm_to_dev(widget->dapm); + struct wcd9335_codec *wcd = dev_get_drvdata(dev); struct snd_soc_dapm_update *update = NULL; struct soc_mixer_control *mixer = (struct soc_mixer_control *)kc->private_value; @@ -1474,7 +1478,7 @@ static const struct snd_kcontrol_new aif3_cap_mixer[] = { static int wcd9335_put_dec_enum(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kc); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); struct soc_enum *e = (struct soc_enum *)kc->private_value; unsigned int val, reg, sel; @@ -1529,7 +1533,7 @@ static int wcd9335_int_dem_inp_mux_put(struct snd_kcontrol *kc, struct snd_soc_component *component; int reg, val; - component = snd_soc_dapm_kcontrol_component(kc); + component = snd_soc_dapm_kcontrol_to_component(kc); val = ucontrol->value.enumerated.item[0]; if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0) @@ -2177,7 +2181,7 @@ static int wcd9335_get_compander(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct snd_soc_component *component = snd_kcontrol_chip(kc); int comp = ((struct soc_mixer_control *)kc->private_value)->shift; struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); @@ -2188,7 +2192,7 @@ static int wcd9335_get_compander(struct snd_kcontrol *kc, static int wcd9335_set_compander(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct snd_soc_component *component = snd_kcontrol_chip(kc); struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); int comp = ((struct soc_mixer_control *) kc->private_value)->shift; int value = ucontrol->value.integer.value[0]; @@ -2227,7 +2231,7 @@ static int wcd9335_set_compander(struct snd_kcontrol *kc, static int wcd9335_rx_hph_mode_get(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct snd_soc_component *component = snd_kcontrol_chip(kc); struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); ucontrol->value.enumerated.item[0] = wcd->hph_mode; @@ -2238,7 +2242,7 @@ static int wcd9335_rx_hph_mode_get(struct snd_kcontrol *kc, static int wcd9335_rx_hph_mode_put(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct snd_soc_component *component = snd_kcontrol_chip(kc); struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); u32 mode_val; diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 3c22f7149af8..c8db33f78a1b 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -2909,7 +2909,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { static int wcd934x_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd934x_codec *wcd = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd->mbhc); @@ -2923,7 +2923,7 @@ static int wcd934x_hph_impedance_get(struct snd_kcontrol *kcontrol, uint32_t zl, zr; bool hphr; struct soc_mixer_control *mc; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd934x_codec *wcd = snd_soc_component_get_drvdata(component); mc = (struct soc_mixer_control *)(kcontrol->private_value); @@ -3102,8 +3102,7 @@ static int wcd934x_put_iir_band_audio_mixer( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd_iir_filter_ctl *ctl = (struct wcd_iir_filter_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -3131,8 +3130,7 @@ static int wcd934x_put_iir_band_audio_mixer( static int wcd934x_get_iir_band_audio_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd_iir_filter_ctl *ctl = (struct wcd_iir_filter_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -3167,7 +3165,7 @@ static int wcd934x_iir_filter_info(struct snd_kcontrol *kcontrol, static int wcd934x_compander_get(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct snd_soc_component *component = snd_kcontrol_chip(kc); int comp = ((struct soc_mixer_control *)kc->private_value)->shift; struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); @@ -3179,7 +3177,7 @@ static int wcd934x_compander_get(struct snd_kcontrol *kc, static int wcd934x_compander_set(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct snd_soc_component *component = snd_kcontrol_chip(kc); struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); int comp = ((struct soc_mixer_control *)kc->private_value)->shift; int value = ucontrol->value.integer.value[0]; @@ -3220,7 +3218,7 @@ static int wcd934x_compander_set(struct snd_kcontrol *kc, static int wcd934x_rx_hph_mode_get(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct snd_soc_component *component = snd_kcontrol_chip(kc); struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); ucontrol->value.enumerated.item[0] = wcd->hph_mode; @@ -3231,7 +3229,7 @@ static int wcd934x_rx_hph_mode_get(struct snd_kcontrol *kc, static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct snd_soc_component *component = snd_kcontrol_chip(kc); struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); u32 mode_val; @@ -3252,9 +3250,10 @@ static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc, static int slim_rx_mux_get(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc); - struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc); - struct wcd934x_codec *wcd = dev_get_drvdata(dapm->dev); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kc); + struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_to_widget(kc); + struct device *dev = snd_soc_dapm_to_dev(dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(dev); ucontrol->value.enumerated.item[0] = wcd->rx_port_value[w->shift]; @@ -3289,8 +3288,9 @@ static int slim_rx_mux_to_dai_id(int mux) static int slim_rx_mux_put(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc); - struct wcd934x_codec *wcd = dev_get_drvdata(w->dapm->dev); + struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_to_widget(kc); + struct device *dev = snd_soc_dapm_to_dev(w->dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(dev); struct soc_enum *e = (struct soc_enum *)kc->private_value; struct snd_soc_dapm_update *update = NULL; struct wcd934x_slim_ch *ch, *c; @@ -3357,7 +3357,7 @@ static int wcd934x_int_dem_inp_mux_put(struct snd_kcontrol *kc, struct snd_soc_component *component; int reg, val; - component = snd_soc_dapm_kcontrol_component(kc); + component = snd_soc_dapm_kcontrol_to_component(kc); val = ucontrol->value.enumerated.item[0]; if (e->reg == WCD934X_CDC_RX0_RX_PATH_SEC0) reg = WCD934X_CDC_RX0_RX_PATH_CFG0; @@ -3390,7 +3390,7 @@ static int wcd934x_dec_enum_put(struct snd_kcontrol *kcontrol, u16 mic_sel_reg = 0; u8 mic_sel; - comp = snd_soc_dapm_kcontrol_component(kcontrol); + comp = snd_soc_dapm_kcontrol_to_component(kcontrol); val = ucontrol->value.enumerated.item[0]; if (val > e->items - 1) @@ -3769,8 +3769,9 @@ static const struct snd_kcontrol_new cdc_if_tx13_inp1_mux = static int slim_tx_mixer_get(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc); - struct wcd934x_codec *wcd = dev_get_drvdata(dapm->dev); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kc); + struct device *dev = snd_soc_dapm_to_dev(dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(dev); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kc->private_value; int port_id = mixer->shift; @@ -3783,8 +3784,9 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kc, static int slim_tx_mixer_put(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc); - struct wcd934x_codec *wcd = dev_get_drvdata(widget->dapm->dev); + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_to_widget(kc); + struct device *dev = snd_soc_dapm_to_dev(widget->dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(dev); struct snd_soc_dapm_update *update = NULL; struct soc_mixer_control *mixer = (struct soc_mixer_control *)kc->private_value; diff --git a/sound/soc/codecs/wcd937x.c b/sound/soc/codecs/wcd937x.c index 421ec7a2d6bd..f1dced57a59b 100644 --- a/sound/soc/codecs/wcd937x.c +++ b/sound/soc/codecs/wcd937x.c @@ -1208,7 +1208,7 @@ static int wcd937x_connect_port(struct wcd937x_sdw_priv *wcd, u8 port_idx, u8 ch static int wcd937x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd937x->hph_mode; @@ -1218,8 +1218,7 @@ static int wcd937x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, static int wcd937x_rx_hph_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); u32 mode_val; @@ -1251,7 +1250,7 @@ static int wcd937x_rx_hph_mode_put(struct snd_kcontrol *kcontrol, static int wcd937x_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc; bool hphr; @@ -1267,7 +1266,7 @@ static int wcd937x_get_compander(struct snd_kcontrol *kcontrol, static int wcd937x_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); struct wcd937x_sdw_priv *wcd = wcd937x->sdw_priv[AIF1_PB]; int value = ucontrol->value.integer.value[0]; @@ -1304,7 +1303,7 @@ static int wcd937x_get_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(comp); struct wcd937x_sdw_priv *wcd; int dai_id = mixer->shift; @@ -1323,7 +1322,7 @@ static int wcd937x_set_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(comp); struct wcd937x_sdw_priv *wcd; int dai_id = mixer->shift; @@ -1951,7 +1950,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { static int wcd937x_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd937x->wcd_mbhc); @@ -1965,8 +1964,7 @@ static int wcd937x_hph_impedance_get(struct snd_kcontrol *kcontrol, u32 zl, zr; bool hphr; struct soc_mixer_control *mc; - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); mc = (struct soc_mixer_control *)(kcontrol->private_value); @@ -2475,7 +2473,7 @@ static int wcd937x_irq_init(struct wcd937x_priv *wcd, struct device *dev) static int wcd937x_soc_codec_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); struct sdw_slave *tx_sdw_dev = wcd937x->tx_sdw_dev; struct device *dev = component->dev; @@ -2748,7 +2746,8 @@ static int wcd937x_bind(struct device *dev) wcd937x->rxdev = of_sdw_find_device_by_node(wcd937x->rxnode); if (!wcd937x->rxdev) { dev_err(dev, "could not find slave with matching of node\n"); - return -EINVAL; + ret = -EINVAL; + goto err_component_unbind; } wcd937x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd937x->rxdev); @@ -2757,7 +2756,8 @@ static int wcd937x_bind(struct device *dev) wcd937x->txdev = of_sdw_find_device_by_node(wcd937x->txnode); if (!wcd937x->txdev) { dev_err(dev, "could not find txslave with matching of node\n"); - return -EINVAL; + ret = -EINVAL; + goto err_put_rxdev; } wcd937x->sdw_priv[AIF1_CAP] = dev_get_drvdata(wcd937x->txdev); @@ -2765,7 +2765,8 @@ static int wcd937x_bind(struct device *dev) wcd937x->tx_sdw_dev = dev_to_sdw_dev(wcd937x->txdev); if (!wcd937x->tx_sdw_dev) { dev_err(dev, "could not get txslave with matching of dev\n"); - return -EINVAL; + ret = -EINVAL; + goto err_put_txdev; } /* @@ -2775,31 +2776,35 @@ static int wcd937x_bind(struct device *dev) if (!device_link_add(wcd937x->rxdev, wcd937x->txdev, DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME)) { dev_err(dev, "Could not devlink TX and RX\n"); - return -EINVAL; + ret = -EINVAL; + goto err_put_txdev; } if (!device_link_add(dev, wcd937x->txdev, DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME)) { dev_err(dev, "Could not devlink WCD and TX\n"); - return -EINVAL; + ret = -EINVAL; + goto err_remove_link1; } if (!device_link_add(dev, wcd937x->rxdev, DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME)) { dev_err(dev, "Could not devlink WCD and RX\n"); - return -EINVAL; + ret = -EINVAL; + goto err_remove_link2; } wcd937x->regmap = wcd937x->sdw_priv[AIF1_CAP]->regmap; if (!wcd937x->regmap) { dev_err(dev, "could not get TX device regmap\n"); - return -EINVAL; + ret = -EINVAL; + goto err_remove_link3; } ret = wcd937x_irq_init(wcd937x, dev); if (ret) { dev_err(dev, "IRQ init failed: %d\n", ret); - return ret; + goto err_remove_link3; } wcd937x->sdw_priv[AIF1_PB]->slave_irq = wcd937x->virq; @@ -2809,10 +2814,26 @@ static int wcd937x_bind(struct device *dev) ret = snd_soc_register_component(dev, &soc_codec_dev_wcd937x, wcd937x_dais, ARRAY_SIZE(wcd937x_dais)); - if (ret) + if (ret) { dev_err(dev, "Codec registration failed\n"); + goto err_remove_link3; + } return ret; + +err_remove_link3: + device_link_remove(dev, wcd937x->rxdev); +err_remove_link2: + device_link_remove(dev, wcd937x->txdev); +err_remove_link1: + device_link_remove(wcd937x->rxdev, wcd937x->txdev); +err_put_txdev: + put_device(wcd937x->txdev); +err_put_rxdev: + put_device(wcd937x->rxdev); +err_component_unbind: + component_unbind_all(dev, wcd937x); + return ret; } static void wcd937x_unbind(struct device *dev) @@ -2825,6 +2846,8 @@ static void wcd937x_unbind(struct device *dev) device_link_remove(wcd937x->rxdev, wcd937x->txdev); component_unbind_all(dev, wcd937x); mutex_destroy(&wcd937x->micb_lock); + put_device(wcd937x->txdev); + put_device(wcd937x->rxdev); } static const struct component_master_ops wcd937x_comp_ops = { diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index e1a4783b984c..f5b7de2bc896 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -1479,7 +1479,7 @@ static int wcd938x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w, static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; @@ -1492,7 +1492,7 @@ static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol, static int wcd938x_tx_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; @@ -1508,7 +1508,7 @@ static int wcd938x_tx_mode_put(struct snd_kcontrol *kcontrol, static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wcd938x->hph_mode; @@ -1519,7 +1519,7 @@ static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, static int wcd938x_rx_hph_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); if (wcd938x->hph_mode == ucontrol->value.enumerated.item[0]) @@ -1533,7 +1533,7 @@ static int wcd938x_rx_hph_mode_put(struct snd_kcontrol *kcontrol, static int wcd938x_ear_pa_put_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); if (wcd938x->comp1_enable) { @@ -1552,7 +1552,7 @@ static int wcd938x_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc; bool hphr; @@ -1571,7 +1571,7 @@ static int wcd938x_get_compander(struct snd_kcontrol *kcontrol, static int wcd938x_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); struct wcd938x_sdw_priv *wcd; int value = ucontrol->value.integer.value[0]; @@ -1602,7 +1602,7 @@ static int wcd938x_set_compander(struct snd_kcontrol *kcontrol, static int wcd938x_ldoh_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd938x->ldoh; @@ -1613,7 +1613,7 @@ static int wcd938x_ldoh_get(struct snd_kcontrol *kcontrol, static int wcd938x_ldoh_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); if (wcd938x->ldoh == ucontrol->value.integer.value[0]) @@ -1843,7 +1843,7 @@ static const struct snd_kcontrol_new wcd9385_snd_controls[] = { static int wcd938x_get_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(comp); struct wcd938x_sdw_priv *wcd; struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; @@ -1862,7 +1862,7 @@ static int wcd938x_get_swr_port(struct snd_kcontrol *kcontrol, static int wcd938x_set_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(comp); struct wcd938x_sdw_priv *wcd; struct soc_mixer_control *mixer = @@ -2506,7 +2506,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { static int wcd938x_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd938x->wcd_mbhc); @@ -2520,8 +2520,7 @@ static int wcd938x_hph_impedance_get(struct snd_kcontrol *kcontrol, uint32_t zl, zr; bool hphr; struct soc_mixer_control *mc; - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); mc = (struct soc_mixer_control *)(kcontrol->private_value); diff --git a/sound/soc/codecs/wcd939x-sdw.c b/sound/soc/codecs/wcd939x-sdw.c index d369100a2457..da342a0c95a5 100644 --- a/sound/soc/codecs/wcd939x-sdw.c +++ b/sound/soc/codecs/wcd939x-sdw.c @@ -1400,12 +1400,18 @@ static int wcd9390_probe(struct sdw_slave *pdev, const struct sdw_device_id *id) ret = component_add(dev, &wcd_sdw_component_ops); if (ret) - return ret; + goto err_free_regmap; /* Set suspended until aggregate device is bind */ pm_runtime_set_suspended(dev); return 0; + +err_free_regmap: + if (wcd->regmap) + regmap_exit(wcd->regmap); + + return ret; } static int wcd9390_remove(struct sdw_slave *pdev) diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c index e74e6f013131..7c5dd0484384 100644 --- a/sound/soc/codecs/wcd939x.c +++ b/sound/soc/codecs/wcd939x.c @@ -1433,7 +1433,7 @@ static int wcd939x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w, static int wcd939x_tx_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; @@ -1446,7 +1446,7 @@ static int wcd939x_tx_mode_get(struct snd_kcontrol *kcontrol, static int wcd939x_tx_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; @@ -1464,7 +1464,7 @@ static int wcd939x_tx_mode_put(struct snd_kcontrol *kcontrol, static int wcd939x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd939x->hph_mode; @@ -1475,7 +1475,7 @@ static int wcd939x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, static int wcd939x_rx_hph_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); u32 mode_val; @@ -1520,7 +1520,7 @@ static int wcd939x_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)(kcontrol->private_value); - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); if (mc->shift) @@ -1535,7 +1535,7 @@ static int wcd939x_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)(kcontrol->private_value); - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[AIF1_PB]; bool value = !!ucontrol->value.integer.value[0]; @@ -1557,7 +1557,7 @@ static int wcd939x_set_compander(struct snd_kcontrol *kcontrol, static int wcd939x_ldoh_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd939x->ldoh ? 1 : 0; @@ -1568,7 +1568,7 @@ static int wcd939x_ldoh_get(struct snd_kcontrol *kcontrol, static int wcd939x_ldoh_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); if (wcd939x->ldoh == !!ucontrol->value.integer.value[0]) @@ -1789,7 +1789,7 @@ static int wcd939x_get_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(comp); struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[mixer->shift]; unsigned int portidx = wcd->ch_info[mixer->reg].port_num; @@ -1816,7 +1816,7 @@ static int wcd939x_set_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(comp); struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[mixer->shift]; unsigned int portidx = wcd->ch_info[mixer->reg].port_num; @@ -2432,7 +2432,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { static int wcd939x_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd939x->wcd_mbhc); @@ -2444,7 +2444,7 @@ static int wcd939x_hph_impedance_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct soc_mixer_control *mc = (struct soc_mixer_control *)(kcontrol->private_value); - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); bool hphr = mc->shift; u32 zl, zr; diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 9e67fbfc2cca..7511c71695c6 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c @@ -723,16 +723,17 @@ static int wm0010_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_PREPARE) wm0010_boot(component); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_PREPARE) { mutex_lock(&wm0010->lock); wm0010_halt(component); mutex_unlock(&wm0010->lock); diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index a07a443ba196..126be2a2a8f3 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -598,7 +598,7 @@ static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); ucontrol->value.integer.value[0] = wm2000->anc_active; @@ -609,7 +609,7 @@ static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); unsigned int anc_active = ucontrol->value.integer.value[0]; int ret; @@ -631,7 +631,7 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); ucontrol->value.integer.value[0] = wm2000->spk_ena; @@ -642,7 +642,7 @@ static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); unsigned int val = ucontrol->value.integer.value[0]; int ret; diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index 2d0a20f2fd8c..96fd098a9d36 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c @@ -2101,7 +2101,7 @@ static void wm5100_micd_irq(struct wm5100_priv *wm5100) int wm5100_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); if (jack) { wm5100->jack = jack; @@ -2329,7 +2329,7 @@ static void wm5100_free_gpio(struct i2c_client *i2c) static int wm5100_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct i2c_client *i2c = to_i2c_client(component->dev); struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int ret, i; diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 9fc7a8325724..b4d4137c05b4 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -664,7 +664,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct arizona *arizona = dev_get_drvdata(component->dev->parent); mutex_lock(&arizona->dac_comp_lock); @@ -678,7 +678,7 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct arizona *arizona = dev_get_drvdata(component->dev->parent); uint16_t dac_comp_coeff = get_unaligned_be16(ucontrol->value.bytes.data); int ret = 0; @@ -696,7 +696,7 @@ static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol, static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct arizona *arizona = dev_get_drvdata(component->dev->parent); mutex_lock(&arizona->dac_comp_lock); @@ -709,7 +709,7 @@ static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol, static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int ret = 0; @@ -1949,7 +1949,7 @@ static irqreturn_t wm5102_adsp2_irq(int irq, void *data) static int wm5102_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm5102_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int ret; @@ -1971,7 +1971,7 @@ static int wm5102_component_probe(struct snd_soc_component *component) arizona_init_gpio(component); - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); priv->core.arizona->dapm = dapm; diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 212eca675f27..7a311c869bd3 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -402,8 +402,8 @@ static int wm5110_clear_pga_volume(struct arizona *arizona, int output) static int wm5110_put_dre(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -467,8 +467,8 @@ err: static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; /* @@ -487,8 +487,8 @@ static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol, static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; /* @@ -2297,7 +2297,7 @@ static irqreturn_t wm5110_adsp2_irq(int irq, void *data) static int wm5110_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm5110_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int i, ret; @@ -2324,7 +2324,7 @@ static int wm5110_component_probe(struct snd_soc_component *component) if (ret) goto err_adsp2_codec_probe; - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); return 0; diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index b1fe6f4e0c10..ad68ff1790e0 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -297,7 +297,7 @@ static int pga_event(struct snd_soc_dapm_widget *w, static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8350_data *wm8350_priv = snd_soc_component_get_drvdata(component); struct wm8350_output *out = NULL; struct soc_mixer_control *mc = @@ -340,7 +340,7 @@ static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8350_data *wm8350_priv = snd_soc_component_get_drvdata(component); struct wm8350_output *out1 = &wm8350_priv->out1; struct wm8350_output *out2 = &wm8350_priv->out2; @@ -1075,6 +1075,7 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai, static int wm8350_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350; struct wm8350_audio_platform_data *platform = @@ -1099,7 +1100,7 @@ static int wm8350_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret != 0) diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 5ad6d5b63ffc..0eecc8657a38 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -82,7 +82,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; @@ -318,6 +318,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); u32 reg_shift = mc->shift; int ret = 0; u16 reg; @@ -326,7 +327,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) : reg = snd_soc_component_read(component, WM8400_OUTPUT_MIXER1); if (reg & WM8400_LDLO) { - printk(KERN_WARNING + dev_warn(wm8400->wm8400->dev, "Cannot set as Output Mixer 1 LDLO Set\n"); ret = -1; } @@ -334,7 +335,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8): reg = snd_soc_component_read(component, WM8400_OUTPUT_MIXER2); if (reg & WM8400_RDRO) { - printk(KERN_WARNING + dev_warn(wm8400->wm8400->dev, "Cannot set as Output Mixer 2 RDRO Set\n"); ret = -1; } @@ -342,7 +343,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8): reg = snd_soc_component_read(component, WM8400_SPEAKER_MIXER); if (reg & WM8400_LDSPK) { - printk(KERN_WARNING + dev_warn(wm8400->wm8400->dev, "Cannot set as Speaker Mixer LDSPK Set\n"); ret = -1; } @@ -350,7 +351,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8): reg = snd_soc_component_read(component, WM8400_SPEAKER_MIXER); if (reg & WM8400_RDSPK) { - printk(KERN_WARNING + dev_warn(wm8400->wm8400->dev, "Cannot set as Speaker Mixer RDSPK Set\n"); ret = -1; } @@ -1110,6 +1111,7 @@ static int wm8400_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 val; int ret; @@ -1125,7 +1127,7 @@ static int wm8400_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(power), &power[0]); if (ret != 0) { diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 79adbcc90d4a..bebee333d3fd 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c @@ -504,6 +504,7 @@ static int wm8510_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8510_priv *wm8510 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 power1 = snd_soc_component_read(component, WM8510_POWER1) & ~0x3; switch (level) { @@ -516,7 +517,7 @@ static int wm8510_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_STANDBY: power1 |= WM8510_POWER1_BIASEN | WM8510_POWER1_BUFIOEN; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_sync(wm8510->regmap); /* Initial cap charge at VMID 5k */ diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index 6671e13c320c..f003f19766e2 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c @@ -317,6 +317,7 @@ static int wm8523_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -330,7 +331,7 @@ static int wm8523_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); if (ret != 0) { diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index ba4a08456e78..2be265bb0751 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -258,7 +258,7 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; @@ -820,13 +820,15 @@ static int wm8580_mute(struct snd_soc_dai *codec_dai, int mute, int direction) static int wm8580_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Power up and get individual control of the DACs */ snd_soc_component_update_bits(component, WM8580_PWRDN1, WM8580_PWRDN1_PWDN | @@ -907,7 +909,7 @@ static struct snd_soc_dai_driver wm8580_dai[] = { static int wm8580_probe(struct snd_soc_component *component) { struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret = 0; switch (wm8580->drvdata->num_dacs) { diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c index 481088987742..2bab9d189519 100644 --- a/sound/soc/codecs/wm8711.c +++ b/sound/soc/codecs/wm8711.c @@ -298,6 +298,7 @@ static int wm8711_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8711_priv *wm8711 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 reg = snd_soc_component_read(component, WM8711_PWR) & 0xff7f; switch (level) { @@ -307,7 +308,7 @@ static int wm8711_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) regcache_sync(wm8711->regmap); snd_soc_component_write(component, WM8711_PWR, reg | 0x0040); diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index ea0a588da40f..4c1a80561f06 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c @@ -161,13 +161,14 @@ static int wm8728_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8728_priv *wm8728 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 reg; switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Power everything up... */ reg = snd_soc_component_read(component, WM8728_DACCTL); snd_soc_component_write(component, WM8728_DACCTL, reg & ~0x4); diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index efc160c75f40..a03bbde5d852 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -96,7 +96,7 @@ static int wm8731_set_deemph(struct snd_soc_component *component) static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8731->deemph; @@ -107,7 +107,7 @@ static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; int ret = 0; @@ -362,7 +362,7 @@ static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { struct snd_soc_component *component = codec_dai->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); switch (clk_id) { @@ -465,6 +465,7 @@ static int wm8731_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; u16 reg; @@ -479,7 +480,7 @@ static int wm8731_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); if (ret != 0) diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c index f7e48f27649d..fee8a37ed1df 100644 --- a/sound/soc/codecs/wm8737.c +++ b/sound/soc/codecs/wm8737.c @@ -452,6 +452,7 @@ static int wm8737_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -465,7 +466,7 @@ static int wm8737_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); if (ret != 0) { @@ -537,6 +538,7 @@ static struct snd_soc_dai_driver wm8737_dai = { static int wm8737_probe(struct snd_soc_component *component) { struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies), @@ -557,7 +559,7 @@ static int wm8737_probe(struct snd_soc_component *component) snd_soc_component_update_bits(component, WM8737_RIGHT_PGA_VOLUME, WM8737_RVU, WM8737_RVU); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 312be0721b5d..0e1d3ebb15c4 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -621,6 +621,7 @@ static int wm8750_mute(struct snd_soc_dai *dai, int mute, int direction) static int wm8750_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 pwr_reg = snd_soc_component_read(component, WM8750_PWR1) & 0xfe3e; switch (level) { @@ -631,7 +632,7 @@ static int wm8750_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_cache_sync(component); /* Set VMID to 5k */ diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 43cc368cf3f3..a532a95e8048 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -224,7 +224,7 @@ SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase), static int wm8753_get_dai(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8753->dai_func; @@ -234,7 +234,7 @@ static int wm8753_get_dai(struct snd_kcontrol *kcontrol, static int wm8753_set_dai(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); u16 ioctl; @@ -1331,6 +1331,7 @@ static int wm8753_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 pwr_reg = snd_soc_component_read(component, WM8753_PWR1) & 0xfe3e; switch (level) { @@ -1343,7 +1344,7 @@ static int wm8753_set_bias_level(struct snd_soc_component *component, flush_delayed_work(&wm8753->charge_work); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* set vmid to 5k for quick power up */ snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x01c1); schedule_delayed_work(&wm8753->charge_work, diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c index 5685c3bb5555..d382b476c89c 100644 --- a/sound/soc/codecs/wm8770.c +++ b/sound/soc/codecs/wm8770.c @@ -497,6 +497,7 @@ static int wm8770_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { int ret; + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8770_priv *wm8770; wm8770 = snd_soc_component_get_drvdata(component); @@ -507,7 +508,7 @@ static int wm8770_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c index 7b73c825aed4..c3f340657f0c 100644 --- a/sound/soc/codecs/wm8776.c +++ b/sound/soc/codecs/wm8776.c @@ -334,6 +334,7 @@ static int wm8776_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -341,7 +342,7 @@ static int wm8776_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_sync(wm8776->regmap); /* Disable the global powerdown; DAPM does the rest */ diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index 48700cc25cb0..94aa3c8de0ab 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -157,8 +157,8 @@ static int wm8804_aif_event(struct snd_soc_dapm_widget *w, static int txsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val = ucontrol->value.enumerated.item[0] << e->shift_l; unsigned int mask = 1 << e->shift_l; diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 6fb25588ca81..fea629541acd 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -1023,6 +1023,7 @@ static struct snd_soc_dai_driver wm8900_dai = { static int wm8900_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 reg; switch (level) { @@ -1041,7 +1042,7 @@ static int wm8900_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_STANDBY: /* Charge capacitors if initial power up */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* STARTUP_BIAS_ENA on */ snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA); @@ -1115,6 +1116,7 @@ static int wm8900_set_bias_level(struct snd_soc_component *component, static int wm8900_suspend(struct snd_soc_component *component) { struct wm8900_priv *wm8900 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int fll_out = wm8900->fll_out; int fll_in = wm8900->fll_in; int ret; @@ -1129,7 +1131,7 @@ static int wm8900_suspend(struct snd_soc_component *component) wm8900->fll_out = fll_out; wm8900->fll_in = fll_in; - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); return 0; } @@ -1137,6 +1139,7 @@ static int wm8900_suspend(struct snd_soc_component *component) static int wm8900_resume(struct snd_soc_component *component) { struct wm8900_priv *wm8900 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; wm8900_reset(component); @@ -1147,7 +1150,7 @@ static int wm8900_resume(struct snd_soc_component *component) return ret; } - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* Restart the FLL? */ if (wm8900->fll_out) { @@ -1169,6 +1172,7 @@ static int wm8900_resume(struct snd_soc_component *component) static int wm8900_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int reg; reg = snd_soc_component_read(component, WM8900_REG_ID); @@ -1180,7 +1184,7 @@ static int wm8900_probe(struct snd_soc_component *component) wm8900_reset(component); /* Turn the chip on */ - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* Latch the volume update bits */ snd_soc_component_update_bits(component, WM8900_REG_LINVOL, 0x100, 0x100); diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index f7d726e3052c..f73f6ad06b38 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -369,7 +369,7 @@ static void wm8903_seq_notifier(struct snd_soc_component *component, static int wm8903_class_w_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); u16 reg; int ret; @@ -444,7 +444,7 @@ static int wm8903_set_deemph(struct snd_soc_component *component) static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8903->deemph; @@ -455,7 +455,7 @@ static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; int ret = 0; @@ -1099,6 +1099,8 @@ static const struct snd_soc_dapm_route wm8903_intercon[] = { static int wm8903_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_ON: break; @@ -1110,7 +1112,7 @@ static int wm8903_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_POBCTRL | WM8903_ISEL_MASK | WM8903_STARTUP_BIAS_ENA | diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 1de09ea646cf..4c73a340f25f 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -388,7 +388,7 @@ static void wm8904_set_drc(struct snd_soc_component *component) static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int value = ucontrol->value.enumerated.item[0]; @@ -406,7 +406,7 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; @@ -459,7 +459,7 @@ static void wm8904_set_retune_mobile(struct snd_soc_component *component) static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int value = ucontrol->value.enumerated.item[0]; @@ -477,7 +477,7 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; @@ -517,7 +517,7 @@ static int wm8904_set_deemph(struct snd_soc_component *component) static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8904->deemph; @@ -527,7 +527,7 @@ static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; @@ -555,7 +555,7 @@ static SOC_ENUM_SINGLE_DECL(hpf_mode, WM8904_ADC_DIGITAL_0, 5, static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int val; int ret; @@ -1246,7 +1246,7 @@ static const struct snd_soc_dapm_route wm8912_intercon[] = { static int wm8904_add_widgets(struct snd_soc_component *component) { struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_dapm_new_controls(dapm, wm8904_core_dapm_widgets, ARRAY_SIZE(wm8904_core_dapm_widgets)); @@ -1934,6 +1934,7 @@ static int wm8904_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1952,7 +1953,7 @@ static int wm8904_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); if (ret != 0) { @@ -2114,7 +2115,7 @@ static void wm8904_handle_retune_mobile_pdata(struct snd_soc_component *componen static void wm8904_handle_dmic_pdata(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; unsigned int dmic_src; @@ -2161,7 +2162,7 @@ static void wm8904_handle_dmic_pdata(struct snd_soc_component *component) static void wm8904_handle_pdata(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int ret, i; diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index 94873ea63014..2f55d0c572a4 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c @@ -476,6 +476,7 @@ static int wm8940_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 val; u16 pwr_reg = snd_soc_component_read(component, WM8940_POWER1) & 0x1F0; int ret = 0; @@ -498,7 +499,7 @@ static int wm8940_set_bias_level(struct snd_soc_component *component, ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg | 0x1); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8940->regmap); if (ret < 0) { dev_err(component->dev, "Failed to sync cache: %d\n", ret); @@ -761,6 +762,7 @@ static struct snd_soc_dai_driver wm8940_dai = { static int wm8940_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8940_setup_data *pdata = component->dev->platform_data; int ret; u16 reg; @@ -782,7 +784,7 @@ static int wm8940_probe(struct snd_soc_component *component) return ret; } - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); ret = snd_soc_component_write(component, WM8940_POWER1, 0x180); if (ret < 0) diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index bca83410b432..e1c61e026cbc 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c @@ -387,7 +387,7 @@ static int wm8955_set_deemph(struct snd_soc_component *component) static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8955->deemph; @@ -397,7 +397,7 @@ static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; @@ -764,6 +764,7 @@ static int wm8955_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -783,7 +784,7 @@ static int wm8955_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies); if (ret != 0) { @@ -866,6 +867,7 @@ static struct snd_soc_dai_driver wm8955_dai = { static int wm8955_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); struct wm8955_pdata *pdata = dev_get_platdata(component->dev); int ret, i; @@ -927,7 +929,7 @@ static int wm8955_probe(struct snd_soc_component *component) WM8955_DMEN, WM8955_DMEN); } - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies); diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index d08419b108fe..8ff0882732e7 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -453,7 +453,7 @@ static int wm8958_dsp2_busy(struct wm8994_priv *wm8994, int aif) static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; @@ -475,7 +475,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg; @@ -497,7 +497,7 @@ static int wm8958_mbc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int mbc = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc]; @@ -509,7 +509,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int mbc = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0]) @@ -543,7 +543,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; @@ -565,7 +565,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8994->vss_cfg; @@ -576,7 +576,7 @@ static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; @@ -598,7 +598,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg; @@ -620,7 +620,7 @@ static int wm8958_vss_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int vss = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8994->vss_ena[vss]; @@ -632,7 +632,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int vss = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0]) @@ -681,7 +681,7 @@ static int wm8958_hpf_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int hpf = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (hpf < 3) @@ -696,7 +696,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int hpf = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (hpf < 3) { @@ -743,7 +743,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; @@ -765,7 +765,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_enh_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8994->enh_eq_cfg; @@ -787,7 +787,7 @@ static int wm8958_enh_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8994->enh_eq_ena[eq]; @@ -799,7 +799,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0]) diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index e6525b4cedfb..384e8e703446 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -211,7 +211,7 @@ static int wm8960_set_deemph(struct snd_soc_component *component) static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8960->deemph; @@ -221,7 +221,7 @@ static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; @@ -488,7 +488,7 @@ static int wm8960_add_widgets(struct snd_soc_component *component) { struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); struct wm8960_data *pdata = &wm8960->pdata; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct snd_soc_dapm_widget *w; snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets, @@ -913,6 +913,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 pm2 = snd_soc_component_read(component, WM8960_POWER2); int ret; ktime_t tout; @@ -922,7 +923,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component, break; case SND_SOC_BIAS_PREPARE: - switch (snd_soc_component_get_bias_level(component)) { + switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_STANDBY: if (!IS_ERR(wm8960->mclk)) { ret = clk_prepare_enable(wm8960->mclk); @@ -961,7 +962,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* ensure discharge is complete */ tout = WM8960_DSCH_TOUT - ktime_ms_delta(ktime_get(), wm8960->dsch_start); if (tout > 0) @@ -1009,6 +1010,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 pm2 = snd_soc_component_read(component, WM8960_POWER2); int reg, ret; @@ -1017,7 +1019,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_component *component, break; case SND_SOC_BIAS_PREPARE: - switch (snd_soc_component_get_bias_level(component)) { + switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_STANDBY: /* Enable anti pop mode */ snd_soc_component_update_bits(component, WM8960_APOP1, @@ -1100,7 +1102,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - switch (snd_soc_component_get_bias_level(component)) { + switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_PREPARE: /* Disable HP discharge */ snd_soc_component_update_bits(component, WM8960_APOP2, diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c index 1ec7c5e8fd69..cfb8cfc91873 100644 --- a/sound/soc/codecs/wm8961.c +++ b/sound/soc/codecs/wm8961.c @@ -743,6 +743,7 @@ static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) static int wm8961_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 reg; /* This is all slightly unusual since we have no bypass paths @@ -755,7 +756,7 @@ static int wm8961_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_PREPARE: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) { /* Enable bias generation */ reg = snd_soc_component_read(component, WM8961_ANTI_POP); reg |= WM8961_BUFIOEN | WM8961_BUFDCOPEN; @@ -770,7 +771,7 @@ static int wm8961_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_PREPARE) { /* VREF off */ reg = snd_soc_component_read(component, WM8961_PWR_MGMT_1); reg &= ~WM8961_VREF; diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 08c8ec3aeb44..e9e317ce6898 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -1545,7 +1545,7 @@ static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int shift = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift); @@ -1557,7 +1557,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int shift = kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int old = wm8962->dsp2_ena; int ret = 0; @@ -1595,7 +1595,7 @@ out: static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int ret; /* Apply the update (if any) */ @@ -1625,7 +1625,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int ret; /* Apply the update (if any) */ @@ -2419,7 +2419,7 @@ static int wm8962_add_widgets(struct snd_soc_component *component) { struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); struct wm8962_pdata *pdata = &wm8962->pdata; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); snd_soc_add_component_controls(component, wm8962_snd_controls, ARRAY_SIZE(wm8962_snd_controls)); @@ -2466,6 +2466,7 @@ static const int sysclk_rates[] = { static void wm8962_configure_bclk(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int best, min_diff, diff; int dspclk, i; @@ -2505,7 +2506,7 @@ static void wm8962_configure_bclk(struct snd_soc_component *component) * So we here provisionally enable it and then disable it afterward * if current bias_level hasn't reached SND_SOC_BIAS_ON. */ - if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON) + if (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON) snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA); @@ -2519,7 +2520,7 @@ static void wm8962_configure_bclk(struct snd_soc_component *component) usleep_range(500, 1000); dspclk = snd_soc_component_read(component, WM8962_CLOCKING1); - if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON) + if (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON) snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_ENA_MASK, 0); @@ -2579,6 +2580,8 @@ static void wm8962_configure_bclk(struct snd_soc_component *component) static int wm8962_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + switch (level) { case SND_SOC_BIAS_ON: break; @@ -2596,7 +2599,7 @@ static int wm8962_set_bias_level(struct snd_soc_component *component, snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1, WM8962_VMID_SEL_MASK, 0x100); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) msleep(100); break; @@ -2629,6 +2632,7 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int i; int aif0 = 0; @@ -2679,7 +2683,7 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, dev_dbg(component->dev, "hw_params set BCLK %dHz LRCLK %dHz\n", wm8962->bclk, wm8962->lrclk); - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_ON) wm8962_configure_bclk(component); return 0; @@ -3193,7 +3197,7 @@ static irqreturn_t wm8962_irq(int irq, void *data) int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int irq_mask, enable; wm8962->jack = jack; @@ -3239,7 +3243,7 @@ static void wm8962_beep_work(struct work_struct *work) struct wm8962_priv *wm8962 = container_of(work, struct wm8962_priv, beep_work); struct snd_soc_component *component = wm8962->component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int i; int reg = 0; int best = 0; @@ -3488,7 +3492,7 @@ static void wm8962_free_gpio(struct snd_soc_component *component) static int wm8962_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int i; @@ -3543,7 +3547,7 @@ static int wm8962_probe(struct snd_soc_component *component) } if (!dmicclk || !dmicdat) { dev_dbg(component->dev, "DMIC not in use, disabling\n"); - snd_soc_dapm_nc_pin(dapm, "DMICDAT"); + snd_soc_dapm_disable_pin(dapm, "DMICDAT"); } if (dmicclk != dmicdat) dev_warn(component->dev, "DMIC GPIOs partially configured\n"); diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 62dcddeb78b3..46aa556b44fa 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -561,6 +561,7 @@ static int wm8971_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 pwr_reg = snd_soc_component_read(component, WM8971_PWR1) & 0xfe3e; switch (level) { @@ -573,7 +574,7 @@ static int wm8971_set_bias_level(struct snd_soc_component *component, flush_delayed_work(&wm8971->charge_work); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { snd_soc_component_cache_sync(component); /* charge output caps - set vmid to 5k for quick power up */ snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x01c0); diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index db16d893a235..0bb5e947f46d 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c @@ -583,6 +583,7 @@ static int wm8974_mute(struct snd_soc_dai *dai, int mute, int direction) static int wm8974_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 power1 = snd_soc_component_read(component, WM8974_POWER1) & ~0x3; switch (level) { @@ -595,7 +596,7 @@ static int wm8974_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_STANDBY: power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_sync(dev_get_regmap(component->dev, NULL)); /* Initial cap charge at VMID 5k */ diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index 8c45ba6fc4c3..935761e50865 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c @@ -853,6 +853,7 @@ static int wm8978_mute(struct snd_soc_dai *dai, int mute, int direction) static int wm8978_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 power1 = snd_soc_component_read(component, WM8978_POWER_MANAGEMENT_1) & ~3; switch (level) { @@ -865,7 +866,7 @@ static int wm8978_set_bias_level(struct snd_soc_component *component, /* bit 3: enable bias, bit 2: enable I/O tie off buffer */ power1 |= 0xc; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Initial cap charge at VMID 5k */ snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1 | 0x3); @@ -924,8 +925,9 @@ static struct snd_soc_dai_driver wm8978_dai = { static int wm8978_suspend(struct snd_soc_component *component) { struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); /* Also switch PLL off */ snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, 0); @@ -937,11 +939,12 @@ static int wm8978_suspend(struct snd_soc_component *component) static int wm8978_resume(struct snd_soc_component *component) { struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); /* Sync reg_cache with the hardware */ regcache_sync(wm8978->regmap); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); if (wm8978->f_pllout) /* Switch PLL on */ diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c index 6a83afe6400b..cd34f71cf42a 100644 --- a/sound/soc/codecs/wm8983.c +++ b/sound/soc/codecs/wm8983.c @@ -489,7 +489,7 @@ static const struct snd_soc_dapm_route wm8983_audio_map[] = { static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg; reg = snd_soc_component_read(component, WM8983_EQ1_LOW_SHELF); @@ -504,7 +504,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, static int eqmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int regpwr2, regpwr3; unsigned int reg_eq; @@ -848,6 +848,7 @@ static int wm8983_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -859,7 +860,7 @@ static int wm8983_set_bias_level(struct snd_soc_component *component, 1 << WM8983_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8983->regmap); if (ret < 0) { dev_err(component->dev, "Failed to sync cache: %d\n", ret); diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c index 2e2d07193c41..be23c0c608d1 100644 --- a/sound/soc/codecs/wm8985.c +++ b/sound/soc/codecs/wm8985.c @@ -564,7 +564,7 @@ static const struct snd_soc_dapm_route wm8985_aux_dapm_routes[] = { static int wm8985_add_widgets(struct snd_soc_component *component) { struct wm8985_priv *wm8985 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (wm8985->dev_type) { case WM8758: @@ -589,7 +589,7 @@ static int wm8985_add_widgets(struct snd_soc_component *component) static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg; reg = snd_soc_component_read(component, WM8985_EQ1_LOW_SHELF); @@ -604,7 +604,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, static int eqmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int regpwr2, regpwr3; unsigned int reg_eq; @@ -948,6 +948,7 @@ static int wm8985_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { int ret; + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8985_priv *wm8985; wm8985 = snd_soc_component_get_drvdata(component); @@ -960,7 +961,7 @@ static int wm8985_set_bias_level(struct snd_soc_component *component, 1 << WM8985_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), wm8985->supplies); if (ret) { diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index cf6d642b7bfe..9bffe7a6ccec 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c @@ -723,6 +723,7 @@ static int wm8988_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 pwr_reg = snd_soc_component_read(component, WM8988_PWR1) & ~0x1c1; switch (level) { @@ -735,7 +736,7 @@ static int wm8988_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_sync(wm8988->regmap); /* VREF, VMID=2x5k */ diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 89df406bf552..9f2b42025ec9 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -49,7 +49,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; @@ -1017,6 +1017,7 @@ static int wm8990_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8990_priv *wm8990 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1030,7 +1031,7 @@ static int wm8990_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8990->regmap); if (ret < 0) { dev_err(component->dev, "Failed to sync cache: %d\n", ret); @@ -1184,10 +1185,12 @@ static struct snd_soc_dai_driver wm8990_dai = { */ static int wm8990_probe(struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); + wm8990_reset(component); /* charge output caps */ - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); snd_soc_component_update_bits(component, WM8990_AUDIO_INTERFACE_4, WM8990_ALRCGPIO1, WM8990_ALRCGPIO1); diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index c3dd44c1dd0c..b8ed2a3e699b 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c @@ -129,7 +129,7 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_sidetone_tlv, static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int ret; u16 val; @@ -1081,6 +1081,7 @@ static int wm8991_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8991_priv *wm8991 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); u16 val; switch (level) { @@ -1095,7 +1096,7 @@ static int wm8991_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_sync(wm8991->regmap); /* Enable all output discharge bits */ snd_soc_component_write(component, WM8991_ANTIPOP1, WM8991_DIS_LLINE | diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index 75d923c2c9ca..1c9299979898 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c @@ -973,6 +973,7 @@ static int wm8993_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; wm_hubs_set_bias_level(component, level); @@ -988,7 +989,7 @@ static int wm8993_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); if (ret != 0) @@ -1482,7 +1483,7 @@ static struct snd_soc_dai_driver wm8993_dai = { static int wm8993_probe(struct snd_soc_component *component) { struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); wm8993->hubs_data.hp_startup_mode = 1; wm8993->hubs_data.dcs_codes_l = -2; @@ -1536,7 +1537,7 @@ static int wm8993_probe(struct snd_soc_component *component) * VMID as an output and can disable it. */ if (wm8993->pdata.lineout1_diff && wm8993->pdata.lineout2_diff) - dapm->idle_bias = false; + snd_soc_dapm_set_idle_bias(dapm, false); return 0; @@ -1546,6 +1547,7 @@ static int wm8993_probe(struct snd_soc_component *component) static int wm8993_suspend(struct snd_soc_component *component) { struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int fll_fout = wm8993->fll_fout; int fll_fref = wm8993->fll_fref; int ret; @@ -1560,7 +1562,7 @@ static int wm8993_suspend(struct snd_soc_component *component) wm8993->fll_fout = fll_fout; wm8993->fll_fref = fll_fref; - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); return 0; } @@ -1568,9 +1570,10 @@ static int wm8993_suspend(struct snd_soc_component *component) static int wm8993_resume(struct snd_soc_component *component) { struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* Restart the FLL? */ if (wm8993->fll_fout) { diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 128c3a59beac..1d64c7c42ed1 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -214,7 +214,7 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif) static int configure_clock(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int change, new; @@ -301,7 +301,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); int mask, ret; /* Can't enable both ADC and DAC paths simultaneously */ @@ -358,7 +358,7 @@ static int wm8994_get_drc(const char *name) static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; @@ -381,7 +381,7 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int drc = wm8994_get_drc(kcontrol->id.name); @@ -465,7 +465,7 @@ static int wm8994_get_retune_mobile_block(const char *name) static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; @@ -488,7 +488,7 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int block = wm8994_get_retune_mobile_block(kcontrol->id.name); @@ -1515,7 +1515,7 @@ SOC_DAPM_SINGLE("AIF1.1 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING, static int wm8994_put_class_w(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); int ret; ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); @@ -2615,6 +2615,7 @@ static int wm8994_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8994 *control = wm8994->wm8994; wm_hubs_set_bias_level(component, level); @@ -2637,12 +2638,12 @@ static int wm8994_set_bias_level(struct snd_soc_component *component, break; } - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) active_reference(component); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { switch (control->type) { case WM8958: if (control->revision == 0) { @@ -2666,7 +2667,7 @@ static int wm8994_set_bias_level(struct snd_soc_component *component, WM8994_LINEOUT2_DISCH); } - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_PREPARE) active_dereference(component); /* MICBIAS into bypass mode on newer devices */ @@ -2686,7 +2687,7 @@ static int wm8994_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_OFF: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_STANDBY) wm8994->cur_fw = NULL; break; } @@ -2697,7 +2698,7 @@ static int wm8994_set_bias_level(struct snd_soc_component *component, int wm8994_vmid_mode(struct snd_soc_component *component, enum wm8994_vmid_mode mode) { struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (mode) { case WM8994_VMID_NORMAL: @@ -3299,6 +3300,7 @@ static struct snd_soc_dai_driver wm8994_dai[] = { static int wm8994_component_suspend(struct snd_soc_component *component) { struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int i, ret; for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) { @@ -3310,7 +3312,7 @@ static int wm8994_component_suspend(struct snd_soc_component *component) i + 1, ret); } - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF); return 0; } @@ -3503,7 +3505,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int micbias) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994_micdet *micdet; struct wm8994 *control = wm8994->wm8994; @@ -3653,7 +3655,7 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data) /* Should be called with accdet_lock held */ static void wm1811_micd_stop(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (!wm8994->jackdet) @@ -3773,7 +3775,7 @@ static void wm1811_mic_work(struct work_struct *work) mic_work.work); struct wm8994 *control = wm8994->wm8994; struct snd_soc_component *component = wm8994->hubs.component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); pm_runtime_get_sync(component->dev); @@ -3812,7 +3814,7 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data) struct wm8994_priv *wm8994 = data; struct wm8994 *control = wm8994->wm8994; struct snd_soc_component *component = wm8994->hubs.component; - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int reg, delay; bool present; @@ -3928,7 +3930,7 @@ int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack * wm1811_micdet_cb det_cb, void *det_cb_data, wm1811_mic_id_cb id_cb, void *id_cb_data) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; u16 micd_lvl_sel; @@ -3980,7 +3982,7 @@ int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack * snd_soc_component_update_bits(component, WM8958_MIC_DETECT_2, WM8958_MICD_LVL_SEL_MASK, micd_lvl_sel); - WARN_ON(snd_soc_component_get_bias_level(component) > SND_SOC_BIAS_STANDBY); + WARN_ON(snd_soc_dapm_get_bias_level(dapm) > SND_SOC_BIAS_STANDBY); /* * If we can use jack detection start off with that, @@ -4148,7 +4150,7 @@ static irqreturn_t wm8994_temp_shut(int irq, void *data) static int wm8994_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8994 *control = dev_get_drvdata(component->dev->parent); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); unsigned int reg; @@ -4183,7 +4185,7 @@ static int wm8994_component_probe(struct snd_soc_component *component) wm8994->micdet_irq = control->pdata.micdet_irq; /* By default use idle_bias false, will override for WM8994 */ - dapm->idle_bias = false; + snd_soc_dapm_set_idle_bias(dapm, false); /* Set revision-specific configuration */ switch (control->type) { @@ -4191,7 +4193,7 @@ static int wm8994_component_probe(struct snd_soc_component *component) /* Single ended line outputs should have VMID on. */ if (!control->pdata.lineout1_diff || !control->pdata.lineout2_diff) - dapm->idle_bias = true; + snd_soc_dapm_set_idle_bias(dapm, true); switch (control->revision) { case 2: diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index a88170a3ed91..104ce09c02e0 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c @@ -547,7 +547,7 @@ static int check_clk_sys(struct snd_soc_dapm_widget *source, static int wm8995_put_class_w(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); int ret; ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); @@ -718,7 +718,7 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif) static int configure_clock(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8995_priv *wm8995; int change, new; @@ -1955,6 +1955,7 @@ static int wm8995_set_dai_sysclk(struct snd_soc_dai *dai, static int wm8995_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8995_priv *wm8995; int ret; @@ -1964,7 +1965,7 @@ static int wm8995_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); if (ret) diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index ee2040782532..2d9cbf66f7d4 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -409,7 +409,7 @@ static int wm8996_get_retune_mobile_block(const char *name) static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); struct wm8996_pdata *pdata = &wm8996->pdata; int block = wm8996_get_retune_mobile_block(kcontrol->id.name); @@ -431,7 +431,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int block = wm8996_get_retune_mobile_block(kcontrol->id.name); @@ -1572,6 +1572,7 @@ static int wm8996_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; switch (level) { @@ -1586,7 +1587,7 @@ static int wm8996_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); if (ret != 0) { @@ -2238,7 +2239,7 @@ int wm8996_detect(struct snd_soc_component *component, struct snd_soc_jack *jack wm8996_polarity_fn polarity_cb) { struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); wm8996->jack = jack; wm8996->detecting = true; @@ -2283,7 +2284,7 @@ EXPORT_SYMBOL_GPL(wm8996_detect); static void wm8996_hpdet_irq(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int val, reg, report; @@ -2343,7 +2344,7 @@ out: static void wm8996_hpdet_start(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); /* Unclamp the output, we can't measure while we're shorting it */ snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 5389c363b14e..83106523385a 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -1055,7 +1055,7 @@ static struct snd_soc_dai_driver wm8997_dai[] = { static int wm8997_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8997_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int ret; @@ -1066,7 +1066,7 @@ static int wm8997_component_probe(struct snd_soc_component *component) if (ret < 0) return ret; - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); priv->core.arizona->dapm = dapm; diff --git a/sound/soc/codecs/wm8998.c b/sound/soc/codecs/wm8998.c index b72b8a64be8f..8e6f03d00c71 100644 --- a/sound/soc/codecs/wm8998.c +++ b/sound/soc/codecs/wm8998.c @@ -101,8 +101,8 @@ static int wm8998_asrc_ev(struct snd_soc_dapm_widget *w, static int wm8998_inmux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct wm8998_priv *wm8998 = snd_soc_component_get_drvdata(component); struct arizona *arizona = wm8998->core.arizona; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -1279,7 +1279,7 @@ static int wm8998_set_fll(struct snd_soc_component *component, int fll_id, static int wm8998_component_probe(struct snd_soc_component *component) { struct wm8998_priv *priv = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct arizona *arizona = priv->core.arizona; int ret; @@ -1292,7 +1292,7 @@ static int wm8998_component_probe(struct snd_soc_component *component) arizona_init_gpio(component); - snd_soc_component_disable_pin(component, "HAPTICS"); + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); return 0; } diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 94d8571360c4..5bfe43c6c1f4 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -335,7 +335,7 @@ static SOC_ENUM_SINGLE_DECL(speaker_mode, WM9081_ANALOGUE_SPEAKER_2, 6, static int speaker_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg; reg = snd_soc_component_read(component, WM9081_ANALOGUE_SPEAKER_2); @@ -356,7 +356,7 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol, static int speaker_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); unsigned int reg_pwr = snd_soc_component_read(component, WM9081_POWER_MANAGEMENT); unsigned int reg2 = snd_soc_component_read(component, WM9081_ANALOGUE_SPEAKER_2); @@ -816,6 +816,7 @@ static int wm9081_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -833,7 +834,7 @@ static int wm9081_set_bias_level(struct snd_soc_component *component, case SND_SOC_BIAS_STANDBY: /* Initial cold start */ - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { regcache_cache_only(wm9081->regmap, false); regcache_sync(wm9081->regmap); diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c index 26191bcc161d..5182f0839b7c 100644 --- a/sound/soc/codecs/wm9090.c +++ b/sound/soc/codecs/wm9090.c @@ -409,7 +409,7 @@ static const struct snd_soc_dapm_route audio_map_in2_diff[] = { static int wm9090_add_controls(struct snd_soc_component *component) { struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int i; snd_soc_dapm_new_controls(dapm, wm9090_dapm_widgets, @@ -463,6 +463,7 @@ static int wm9090_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); switch (level) { case SND_SOC_BIAS_ON: @@ -480,7 +481,7 @@ static int wm9090_set_bias_level(struct snd_soc_component *component, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) { /* Restore the register cache */ regcache_sync(wm9090->regmap); } diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 8ff4b5f13b3a..83cd42fa0c28 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -215,7 +215,7 @@ static const unsigned int wm9712_mixer_mute_regs[] = { static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); unsigned int val = ucontrol->value.integer.value[0]; @@ -259,7 +259,7 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol, static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = @@ -611,6 +611,7 @@ static int wm9712_set_bias_level(struct snd_soc_component *component, static int wm9712_soc_resume(struct snd_soc_component *component) { struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID, @@ -618,7 +619,7 @@ static int wm9712_soc_resume(struct snd_soc_component *component) if (ret < 0) return ret; - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); if (ret == 0) snd_soc_component_cache_sync(component); diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 5f1b0f5c1a58..b3bbecf074ee 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -224,7 +224,7 @@ static const unsigned int wm9713_mixer_mute_regs[] = { static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); unsigned int val = ucontrol->value.integer.value[0]; @@ -268,7 +268,7 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol, static int wm9713_hp_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = @@ -1176,6 +1176,7 @@ static int wm9713_soc_suspend(struct snd_soc_component *component) static int wm9713_soc_resume(struct snd_soc_component *component) { struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); int ret; ret = snd_ac97_reset(wm9713->ac97, true, WM9713_VENDOR_ID, @@ -1183,7 +1184,7 @@ static int wm9713_soc_resume(struct snd_soc_component *component) if (ret < 0) return ret; - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_STANDBY); /* do we need to re-start the PLL ? */ if (wm9713->pll_in) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 8782c331e925..17cec79245d4 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -319,7 +319,7 @@ struct wm_coeff_ctl { int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); @@ -332,7 +332,7 @@ EXPORT_SYMBOL_GPL(wm_adsp_fw_get); int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); int ret = 1; @@ -936,7 +936,7 @@ EXPORT_SYMBOL_GPL(wm_adsp2_set_dspclk); int wm_adsp2_preloader_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -951,9 +951,9 @@ EXPORT_SYMBOL_GPL(wm_adsp2_preloader_get); int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct wm_adsp *dsp = &dsps[mc->shift - 1]; @@ -965,9 +965,9 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->cs_dsp.name); if (ucontrol->value.integer.value[0] || dsp->toggle_preload) - snd_soc_component_force_enable_pin(component, preload); + snd_soc_dapm_force_enable_pin(dapm, preload); else - snd_soc_component_disable_pin(component, preload); + snd_soc_dapm_disable_pin(dapm, preload); snd_soc_dapm_sync(dapm); @@ -976,7 +976,7 @@ int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, dsp->preloaded = ucontrol->value.integer.value[0]; if (dsp->toggle_preload) { - snd_soc_component_disable_pin(component, preload); + snd_soc_dapm_disable_pin(dapm, preload); snd_soc_dapm_sync(dapm); } @@ -1121,11 +1121,12 @@ EXPORT_SYMBOL_GPL(wm_adsp_event); int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); char preload[32]; if (!dsp->cs_dsp.no_core_startstop) { snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->cs_dsp.name); - snd_soc_component_disable_pin(component, preload); + snd_soc_dapm_disable_pin(dapm, preload); } cs_dsp_init_debugfs(&dsp->cs_dsp, component->debugfs_root); @@ -1560,7 +1561,7 @@ static int wm_adsp_buffer_parse_coeff(struct cs_dsp_coeff_ctl *cs_ctl) for (i = 0; i < 5; ++i) { ret = cs_dsp_coeff_read_ctrl(cs_ctl, 0, &coeff_v1, - min(cs_ctl->len, sizeof(coeff_v1))); + min((size_t)cs_ctl->len, sizeof(coeff_v1))); if (ret < 0) return ret; diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index 196ddb224e6d..f80dfc488e3c 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c @@ -331,7 +331,7 @@ static void enable_dc_servo(struct snd_soc_component *component) static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); int ret; @@ -694,7 +694,7 @@ EXPORT_SYMBOL_GPL(wm_hubs_update_class_w); static int class_w_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); int ret; ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); @@ -714,7 +714,7 @@ static int class_w_put_volsw(struct snd_kcontrol *kcontrol, static int class_w_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol); int ret; ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); @@ -1112,7 +1112,7 @@ static const struct snd_soc_dapm_route lineout2_se_routes[] = { int wm_hubs_add_analogue_controls(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); /* Latch volume update bits & default ZC on */ snd_soc_component_update_bits(component, WM8993_LEFT_LINE_INPUT_1_2_VOLUME, @@ -1156,7 +1156,7 @@ int wm_hubs_add_analogue_routes(struct snd_soc_component *component, int lineout1_diff, int lineout2_diff) { struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component); hubs->component = component; diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c index 636e59abc377..d7aca6567c2d 100644 --- a/sound/soc/codecs/wsa881x.c +++ b/sound/soc/codecs/wsa881x.c @@ -738,7 +738,7 @@ static int wsa881x_component_probe(struct snd_soc_component *comp) static int wsa881x_put_pa_gain(struct snd_kcontrol *kc, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kc); + struct snd_soc_component *comp = snd_kcontrol_chip(kc); struct soc_mixer_control *mc = (struct soc_mixer_control *)kc->private_value; int max = mc->max; @@ -783,7 +783,7 @@ static int wsa881x_put_pa_gain(struct snd_kcontrol *kc, static int wsa881x_get_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wsa881x_priv *data = snd_soc_component_get_drvdata(comp); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; @@ -815,7 +815,7 @@ static int wsa881x_boost_ctrl(struct snd_soc_component *comp, bool enable) static int wsa881x_set_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wsa881x_priv *data = snd_soc_component_get_drvdata(comp); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; @@ -1112,8 +1112,7 @@ static int wsa881x_probe(struct sdw_slave *pdev, if (!wsa881x) return -ENOMEM; - wsa881x->sd_n = devm_gpiod_get_optional(dev, "powerdown", - GPIOD_FLAGS_BIT_NONEXCLUSIVE); + wsa881x->sd_n = devm_gpiod_get_optional(dev, "powerdown", 0); if (IS_ERR(wsa881x->sd_n)) return dev_err_probe(dev, PTR_ERR(wsa881x->sd_n), "Shutdown Control GPIO not found\n"); diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c index ca4520ade79a..c3046e260cb9 100644 --- a/sound/soc/codecs/wsa883x.c +++ b/sound/soc/codecs/wsa883x.c @@ -1121,7 +1121,7 @@ static const struct sdw_slave_ops wsa883x_slave_ops = { static int wsa_dev_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wsa883x->dev_mode; @@ -1132,7 +1132,7 @@ static int wsa_dev_mode_get(struct snd_kcontrol *kcontrol, static int wsa_dev_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); if (wsa883x->dev_mode == ucontrol->value.enumerated.item[0]) @@ -1152,7 +1152,7 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(pa_gain, static int wsa883x_get_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wsa883x_priv *data = snd_soc_component_get_drvdata(comp); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; int portidx = mixer->reg; @@ -1165,7 +1165,7 @@ static int wsa883x_get_swr_port(struct snd_kcontrol *kcontrol, static int wsa883x_set_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wsa883x_priv *data = snd_soc_component_get_drvdata(comp); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; int portidx = mixer->reg; @@ -1188,7 +1188,7 @@ static int wsa883x_set_swr_port(struct snd_kcontrol *kcontrol, static int wsa883x_get_comp_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wsa883x->comp_offset; @@ -1199,7 +1199,7 @@ static int wsa883x_get_comp_offset(struct snd_kcontrol *kcontrol, static int wsa883x_set_comp_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa883x_priv *wsa883x = snd_soc_component_get_drvdata(component); if (wsa883x->comp_offset == ucontrol->value.integer.value[0]) @@ -1572,13 +1572,10 @@ static int wsa883x_get_reset(struct device *dev, struct wsa883x_priv *wsa883x) if (IS_ERR(wsa883x->sd_reset)) return dev_err_probe(dev, PTR_ERR(wsa883x->sd_reset), "Failed to get reset\n"); - /* - * if sd_reset: NULL, so use the backwards compatible way for powerdown-gpios, - * which does not handle sharing GPIO properly. - */ + + /* if sd_reset: NULL, so use the backwards compatible way for powerdown-gpios */ if (!wsa883x->sd_reset) { wsa883x->sd_n = devm_gpiod_get_optional(dev, "powerdown", - GPIOD_FLAGS_BIT_NONEXCLUSIVE | GPIOD_OUT_HIGH); if (IS_ERR(wsa883x->sd_n)) return dev_err_probe(dev, PTR_ERR(wsa883x->sd_n), diff --git a/sound/soc/codecs/wsa884x.c b/sound/soc/codecs/wsa884x.c index 2484d4b8e2d9..887edd2be705 100644 --- a/sound/soc/codecs/wsa884x.c +++ b/sound/soc/codecs/wsa884x.c @@ -1587,7 +1587,7 @@ static const struct sdw_slave_ops wsa884x_slave_ops = { static int wsa884x_dev_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wsa884x->dev_mode; @@ -1598,7 +1598,7 @@ static int wsa884x_dev_mode_get(struct snd_kcontrol *kcontrol, static int wsa884x_dev_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(component); if (wsa884x->dev_mode == ucontrol->value.enumerated.item[0]) @@ -1612,7 +1612,7 @@ static int wsa884x_dev_mode_put(struct snd_kcontrol *kcontrol, static int wsa884x_get_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(comp); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; int portidx = mixer->reg; @@ -1625,7 +1625,7 @@ static int wsa884x_get_swr_port(struct snd_kcontrol *kcontrol, static int wsa884x_set_swr_port(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol); struct wsa884x_priv *wsa884x = snd_soc_component_get_drvdata(comp); struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; int portidx = mixer->reg; |
