diff options
-rw-r--r-- | sound/soc/codecs/Kconfig | 3 | ||||
-rw-r--r-- | sound/soc/codecs/max9850.c | 80 | ||||
-rw-r--r-- | sound/soc/codecs/max9860.c | 70 | ||||
-rw-r--r-- | sound/soc/codecs/max9867.c | 91 | ||||
-rw-r--r-- | sound/soc/codecs/max9867.h | 1 | ||||
-rw-r--r-- | sound/soc/codecs/max98925.c | 72 | ||||
-rw-r--r-- | sound/soc/codecs/max98925.h | 2 | ||||
-rw-r--r-- | sound/soc/codecs/max98926.c | 56 | ||||
-rw-r--r-- | sound/soc/codecs/max98926.h | 2 |
9 files changed, 177 insertions, 200 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index def80fe48843..0314a9faae36 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -641,7 +641,8 @@ config SND_SOC_MAX98504 depends on I2C config SND_SOC_MAX9867 - tristate + tristate "Maxim MAX9867 CODEC" + depends on I2C config SND_SOC_MAX98925 tristate diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c index a3dfc918c278..74d7f52c7e73 100644 --- a/sound/soc/codecs/max9850.c +++ b/sound/soc/codecs/max9850.c @@ -130,8 +130,8 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); u64 lrclk_div; u8 sf, da; @@ -139,14 +139,14 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */ - sf = (snd_soc_read(codec, MAX9850_CLOCK) >> 2) + 1; + sf = (snd_soc_component_read32(component, MAX9850_CLOCK) >> 2) + 1; lrclk_div = (1 << 22); lrclk_div *= params_rate(params); lrclk_div *= sf; do_div(lrclk_div, max9850->sysclk); - snd_soc_write(codec, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); - snd_soc_write(codec, MAX9850_LRCLK_LSB, lrclk_div & 0xff); + snd_soc_component_write(component, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); + snd_soc_component_write(component, MAX9850_LRCLK_LSB, lrclk_div & 0xff); switch (params_width(params)) { case 16: @@ -161,7 +161,7 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_update_bits(codec, MAX9850_DIGITAL_AUDIO, 0x3, da); + snd_soc_component_update_bits(component, MAX9850_DIGITAL_AUDIO, 0x3, da); return 0; } @@ -169,16 +169,16 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); /* calculate mclk -> iclk divider */ if (freq <= 13000000) - snd_soc_write(codec, MAX9850_CLOCK, 0x0); + snd_soc_component_write(component, MAX9850_CLOCK, 0x0); else if (freq <= 26000000) - snd_soc_write(codec, MAX9850_CLOCK, 0x4); + snd_soc_component_write(component, MAX9850_CLOCK, 0x4); else if (freq <= 40000000) - snd_soc_write(codec, MAX9850_CLOCK, 0x8); + snd_soc_component_write(component, MAX9850_CLOCK, 0x8); else return -EINVAL; @@ -188,7 +188,7 @@ static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 da = 0; /* set master/slave audio interface */ @@ -234,15 +234,15 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) } /* set da */ - snd_soc_write(codec, MAX9850_DIGITAL_AUDIO, da); + snd_soc_component_write(component, MAX9850_DIGITAL_AUDIO, da); return 0; } -static int max9850_set_bias_level(struct snd_soc_codec *codec, +static int max9850_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); + struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -251,10 +251,10 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(max9850->regmap); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } @@ -289,31 +289,32 @@ static struct snd_soc_dai_driver max9850_dai = { .ops = &max9850_dai_ops, }; -static int max9850_probe(struct snd_soc_codec *codec) +static int max9850_probe(struct snd_soc_component *component) { /* enable zero-detect */ - snd_soc_update_bits(codec, MAX9850_GENERAL_PURPOSE, 1, 1); + snd_soc_component_update_bits(component, MAX9850_GENERAL_PURPOSE, 1, 1); /* enable slew-rate control */ - snd_soc_update_bits(codec, MAX9850_VOLUME, 0x40, 0x40); + snd_soc_component_update_bits(component, MAX9850_VOLUME, 0x40, 0x40); /* set slew-rate 125ms */ - snd_soc_update_bits(codec, MAX9850_CHARGE_PUMP, 0xff, 0xc0); + snd_soc_component_update_bits(component, MAX9850_CHARGE_PUMP, 0xff, 0xc0); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_max9850 = { - .probe = max9850_probe, - .set_bias_level = max9850_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = max9850_controls, - .num_controls = ARRAY_SIZE(max9850_controls), - .dapm_widgets = max9850_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), - .dapm_routes = max9850_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_max9850 = { + .probe = max9850_probe, + .set_bias_level = max9850_set_bias_level, + .controls = max9850_controls, + .num_controls = ARRAY_SIZE(max9850_controls), + .dapm_widgets = max9850_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), + .dapm_routes = max9850_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int max9850_i2c_probe(struct i2c_client *i2c, @@ -333,17 +334,11 @@ static int max9850_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, max9850); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_max9850, &max9850_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max9850, &max9850_dai, 1); return ret; } -static int max9850_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max9850_i2c_id[] = { { "max9850", 0 }, { } @@ -355,7 +350,6 @@ static struct i2c_driver max9850_i2c_driver = { .name = "max9850", }, .probe = max9850_i2c_probe, - .remove = max9850_i2c_remove, .id_table = max9850_i2c_id, }; diff --git a/sound/soc/codecs/max9860.c b/sound/soc/codecs/max9860.c index a2dc6a47f466..5bbf889ad98e 100644 --- a/sound/soc/codecs/max9860.c +++ b/sound/soc/codecs/max9860.c @@ -261,8 +261,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9860_priv *max9860 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9860_priv *max9860 = snd_soc_component_get_drvdata(component); u8 master; u8 ifc1a = 0; u8 ifc1b = 0; @@ -270,7 +270,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, unsigned long n; int ret; - dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n", + dev_dbg(component->dev, "hw_params %u Hz, %u channels\n", params_rate(params), params_channels(params)); @@ -306,7 +306,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, break; case SND_SOC_DAIFMT_DSP_A: if (params_width(params) != 16) { - dev_err(codec->dev, + dev_err(component->dev, "DSP_A works for 16 bits per sample only.\n"); return -EINVAL; } @@ -315,7 +315,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, break; case SND_SOC_DAIFMT_DSP_B: if (params_width(params) != 16) { - dev_err(codec->dev, + dev_err(component->dev, "DSP_B works for 16 bits per sample only.\n"); return -EINVAL; } @@ -352,16 +352,16 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - dev_dbg(codec->dev, "IFC1A %02x\n", ifc1a); + dev_dbg(component->dev, "IFC1A %02x\n", ifc1a); ret = regmap_write(max9860->regmap, MAX9860_IFC1A, ifc1a); if (ret) { - dev_err(codec->dev, "Failed to set IFC1A: %d\n", ret); + dev_err(component->dev, "Failed to set IFC1A: %d\n", ret); return ret; } - dev_dbg(codec->dev, "IFC1B %02x\n", ifc1b); + dev_dbg(component->dev, "IFC1B %02x\n", ifc1b); ret = regmap_write(max9860->regmap, MAX9860_IFC1B, ifc1b); if (ret) { - dev_err(codec->dev, "Failed to set IFC1B: %d\n", ret); + dev_err(component->dev, "Failed to set IFC1B: %d\n", ret); return ret; } @@ -417,33 +417,33 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, } sysclk |= max9860->psclk; - dev_dbg(codec->dev, "SYSCLK %02x\n", sysclk); + dev_dbg(component->dev, "SYSCLK %02x\n", sysclk); ret = regmap_write(max9860->regmap, MAX9860_SYSCLK, sysclk); if (ret) { - dev_err(codec->dev, "Failed to set SYSCLK: %d\n", ret); + dev_err(component->dev, "Failed to set SYSCLK: %d\n", ret); return ret; } - dev_dbg(codec->dev, "N %lu\n", n); + dev_dbg(component->dev, "N %lu\n", n); ret = regmap_write(max9860->regmap, MAX9860_AUDIOCLKHIGH, n >> 8); if (ret) { - dev_err(codec->dev, "Failed to set NHI: %d\n", ret); + dev_err(component->dev, "Failed to set NHI: %d\n", ret); return ret; } ret = regmap_write(max9860->regmap, MAX9860_AUDIOCLKLOW, n & 0xff); if (ret) { - dev_err(codec->dev, "Failed to set NLO: %d\n", ret); + dev_err(component->dev, "Failed to set NLO: %d\n", ret); return ret; } if (!master) { - dev_dbg(codec->dev, "Enable PLL\n"); + dev_dbg(component->dev, "Enable PLL\n"); ret = regmap_update_bits(max9860->regmap, MAX9860_AUDIOCLKHIGH, MAX9860_PLL, MAX9860_PLL); if (ret) { - dev_err(codec->dev, "Failed to enable PLL: %d\n", ret); + dev_err(component->dev, "Failed to enable PLL: %d\n", ret); return ret; } } @@ -453,8 +453,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, static int max9860_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct max9860_priv *max9860 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9860_priv *max9860 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -500,10 +500,10 @@ static struct snd_soc_dai_driver max9860_dai = { .symmetric_rates = 1, }; -static int max9860_set_bias_level(struct snd_soc_codec *codec, +static int max9860_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct max9860_priv *max9860 = dev_get_drvdata(codec->dev); + struct max9860_priv *max9860 = dev_get_drvdata(component->dev); int ret; switch (level) { @@ -515,7 +515,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, MAX9860_SHDN, MAX9860_SHDN); if (ret) { - dev_err(codec->dev, "Failed to remove SHDN: %d\n", ret); + dev_err(component->dev, "Failed to remove SHDN: %d\n", ret); return ret; } break; @@ -524,7 +524,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, MAX9860_SHDN, 0); if (ret) { - dev_err(codec->dev, "Failed to request SHDN: %d\n", + dev_err(component->dev, "Failed to request SHDN: %d\n", ret); return ret; } @@ -534,18 +534,17 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, return 0; } -static const struct snd_soc_codec_driver max9860_codec_driver = { - .set_bias_level = max9860_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = max9860_controls, - .num_controls = ARRAY_SIZE(max9860_controls), - .dapm_widgets = max9860_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max9860_dapm_widgets), - .dapm_routes = max9860_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(max9860_dapm_routes), - }, +static const struct snd_soc_component_driver max9860_component_driver = { + .set_bias_level = max9860_set_bias_level, + .controls = max9860_controls, + .num_controls = ARRAY_SIZE(max9860_controls), + .dapm_widgets = max9860_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max9860_dapm_widgets), + .dapm_routes = max9860_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(max9860_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; #ifdef CONFIG_PM @@ -698,7 +697,7 @@ static int max9860_probe(struct i2c_client *i2c, pm_runtime_enable(dev); pm_runtime_idle(dev); - ret = snd_soc_register_codec(dev, &max9860_codec_driver, + ret = devm_snd_soc_register_component(dev, &max9860_component_driver, &max9860_dai, 1); if (ret) { dev_err(dev, "Failed to register CODEC: %d\n", ret); @@ -719,7 +718,6 @@ static int max9860_remove(struct i2c_client *i2c) struct device *dev = &i2c->dev; struct max9860_priv *max9860 = dev_get_drvdata(dev); - snd_soc_unregister_codec(dev); pm_runtime_disable(dev); regulator_disable(max9860->dvddio); return 0; diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2f60924fe919..4ea3287162ad 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -179,8 +179,8 @@ static inline int get_ni_value(int mclk, int rate) static int max9867_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); unsigned int ni_h, ni_l; int value; @@ -227,7 +227,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, bclk_value = MAX9867_IFC1B_PCLK_16; break; default: - dev_err(codec->dev, + dev_err(component->dev, "unsupported sampling rate\n"); return -EINVAL; } @@ -239,7 +239,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, bclk_value = MAX9867_IFC1B_32BIT; break; default: - dev_err(codec->dev, "unsupported sampling rate\n"); + dev_err(component->dev, "unsupported sampling rate\n"); return -EINVAL; } regmap_update_bits(max9867->regmap, MAX9867_IFC1B, @@ -251,8 +251,8 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, static int max9867_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, MAX9867_SHTDOWN_MASK, MAX9867_SHTDOWN_MASK); @@ -261,8 +261,8 @@ static int max9867_prepare(struct snd_pcm_substream *substream, static int max9867_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); if (mute) regmap_update_bits(max9867->regmap, MAX9867_DACLEVEL, @@ -276,8 +276,8 @@ static int max9867_mute(struct snd_soc_dai *dai, int mute) static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); int value = 0; /* Set the prescaler based on the master clock frequency*/ @@ -291,7 +291,9 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, value |= MAX9867_PSCLK_40_60; max9867->pclk = freq/4; } else { - pr_err("bad clock frequency %d", freq); + dev_err(component->dev, + "Invalid clock frequency %uHz (required 10-60MHz)\n", + freq); return -EINVAL; } value = value << MAX9867_PSCLK_SHIFT; @@ -306,8 +308,8 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); u8 iface1A = 0, iface1B = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -323,10 +325,16 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - /* for i2s compatible mode */ - iface1A |= MAX9867_I2S_DLY; - /* SDOUT goes to hiz state after all data is transferred */ - iface1A |= MAX9867_SDOUT_HIZ; + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + iface1A |= MAX9867_I2S_DLY; + break; + case SND_SOC_DAIFMT_DSP_A: + iface1A |= MAX9867_TDM_MODE | MAX9867_SDOUT_HIZ; + break; + default: + return -EINVAL; + } /* Clock inversion bits, BCI and WCI */ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { @@ -367,19 +375,20 @@ static struct snd_soc_dai_driver max9867_dai[] = { .name = "max9867-aif1", .playback = { .stream_name = "HiFi Playback", - .channels_min = 1, + .channels_min = 2, .channels_max = 2, .rates = MAX9867_RATES, .formats = MAX9867_FORMATS, }, .capture = { .stream_name = "HiFi Capture", - .channels_min = 1, + .channels_min = 2, .channels_max = 2, .rates = MAX9867_RATES, .formats = MAX9867_FORMATS, }, .ops = &max9867_dai_ops, + .symmetric_rates = 1, } }; @@ -404,25 +413,17 @@ static int max9867_resume(struct device *dev) } #endif -static int max9867_probe(struct snd_soc_codec *codec) -{ - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); - - dev_dbg(codec->dev, "max98090_probe\n"); - max9867->codec = codec; - return 0; -} - -static const struct snd_soc_codec_driver max9867_codec = { - .probe = max9867_probe, - .component_driver = { - .controls = max9867_snd_controls, - .num_controls = ARRAY_SIZE(max9867_snd_controls), - .dapm_routes = max9867_audio_map, - .num_dapm_routes = ARRAY_SIZE(max9867_audio_map), - .dapm_widgets = max9867_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max9867_dapm_widgets), - }, +static const struct snd_soc_component_driver max9867_component = { + .controls = max9867_snd_controls, + .num_controls = ARRAY_SIZE(max9867_snd_controls), + .dapm_routes = max9867_audio_map, + .num_dapm_routes = ARRAY_SIZE(max9867_audio_map), + .dapm_widgets = max9867_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max9867_dapm_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static bool max9867_volatile_register(struct device *dev, unsigned int reg) @@ -486,8 +487,7 @@ static int max9867_i2c_probe(struct i2c_client *i2c, max9867->regmap = devm_regmap_init_i2c(i2c, &max9867_regmap); if (IS_ERR(max9867->regmap)) { ret = PTR_ERR(max9867->regmap); - dev_err(&i2c->dev, - "Failed to allocate regmap: %d\n", ret); + dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); return ret; } ret = regmap_read(max9867->regmap, @@ -497,21 +497,15 @@ static int max9867_i2c_probe(struct i2c_client *i2c, return ret; } dev_info(&i2c->dev, "device revision: %x\n", reg); - ret = snd_soc_register_codec(&i2c->dev, &max9867_codec, + ret = devm_snd_soc_register_component(&i2c->dev, &max9867_component, max9867_dai, ARRAY_SIZE(max9867_dai)); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } return ret; } -static int max9867_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max9867_i2c_id[] = { { "max9867", 0 }, { } @@ -535,7 +529,6 @@ static struct i2c_driver max9867_i2c_driver = { .pm = &max9867_pm_ops, }, .probe = max9867_i2c_probe, - .remove = max9867_i2c_remove, .id_table = max9867_i2c_id, }; diff --git a/sound/soc/codecs/max9867.h b/sound/soc/codecs/max9867.h index 65590b4ad62a..55cd9976ff47 100644 --- a/sound/soc/codecs/max9867.h +++ b/sound/soc/codecs/max9867.h @@ -75,7 +75,6 @@ /* codec private data */ struct max9867_priv { struct regmap *regmap; - struct snd_soc_codec *codec; unsigned int sysclk; unsigned int pclk; unsigned int master; diff --git a/sound/soc/codecs/max98925.c b/sound/soc/codecs/max98925.c index 921f95fc396d..29877730a2b0 100644 --- a/sound/soc/codecs/max98925.c +++ b/sound/soc/codecs/max98925.c @@ -99,8 +99,8 @@ 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_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -256,7 +256,7 @@ static const struct { }, }; -static inline int max98925_rate_value(struct snd_soc_codec *codec, +static inline int max98925_rate_value(struct snd_soc_component *component, int rate, int clock, int *value, int *n, int *m) { int ret = -EINVAL; @@ -297,11 +297,11 @@ static void max98925_set_sense_data(struct max98925_priv *max98925) static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); unsigned int invert = 0; - dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); + dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* set DAI to slave mode */ @@ -322,7 +322,7 @@ static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "DAI clock mode unsupported"); + dev_err(component->dev, "DAI clock mode unsupported"); return -EINVAL; } @@ -339,7 +339,7 @@ static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, invert = M98925_DAI_BCI_MASK | M98925_DAI_WCI_MASK; break; default: - dev_err(codec->dev, "DAI invert mode unsupported"); + dev_err(component->dev, "DAI invert mode unsupported"); return -EINVAL; } @@ -352,7 +352,7 @@ static int max98925_set_clock(struct max98925_priv *max98925, struct snd_pcm_hw_params *params) { unsigned int dai_sr = 0, clock, mdll, n, m; - struct snd_soc_codec *codec = max98925->codec; + struct snd_soc_component *component = max98925->component; int rate = params_rate(params); /* BCLK/LRCLK ratio calculation */ int blr_clk_ratio = params_channels(params) * max98925->ch_size; @@ -395,12 +395,12 @@ static int max98925_set_clock(struct max98925_priv *max98925, mdll = M98925_MDLL_MULT_MCLKx8; break; default: - dev_info(max98925->codec->dev, "unsupported sysclk %d\n", + dev_info(max98925->component->dev, "unsupported sysclk %d\n", max98925->sysclk); return -EINVAL; } - if (max98925_rate_value(codec, rate, clock, &dai_sr, &n, &m)) + if (max98925_rate_value(component, rate, clock, &dai_sr, &n, &m)) return -EINVAL; /* set DAI_SR to correct LRCLK frequency */ @@ -427,8 +427,8 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); switch (params_width(params)) { case 16: @@ -454,7 +454,7 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, __func__, params_format(params)); return -EINVAL; } - dev_dbg(codec->dev, "%s: format supported %d", + dev_dbg(component->dev, "%s: format supported %d", __func__, params_format(params)); return max98925_set_clock(max98925, params); } @@ -462,8 +462,8 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, static int max98925_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); switch (clk_id) { case 0: @@ -516,11 +516,11 @@ static struct snd_soc_dai_driver max98925_dai[] = { } }; -static int max98925_probe(struct snd_soc_codec *codec) +static int max98925_probe(struct snd_soc_component *component) { - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); - max98925->codec = codec; + max98925->component = component; regmap_write(max98925->regmap, MAX98925_GLOBAL_ENABLE, 0x00); /* It's not the default but we need to set DAI_DLY */ regmap_write(max98925->regmap, @@ -538,16 +538,18 @@ static int max98925_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_max98925 = { - .probe = max98925_probe, - .component_driver = { - .controls = max98925_snd_controls, - .num_controls = ARRAY_SIZE(max98925_snd_controls), - .dapm_routes = max98925_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98925_audio_map), - .dapm_widgets = max98925_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98925_dapm_widgets), - }, +static const struct snd_soc_component_driver soc_component_dev_max98925 = { + .probe = max98925_probe, + .controls = max98925_snd_controls, + .num_controls = ARRAY_SIZE(max98925_snd_controls), + .dapm_routes = max98925_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98925_audio_map), + .dapm_widgets = max98925_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98925_dapm_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98925_regmap = { @@ -612,20 +614,15 @@ static int max98925_i2c_probe(struct i2c_client *i2c, dev_info(&i2c->dev, "device version 0x%02X\n", reg); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98925, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98925, max98925_dai, ARRAY_SIZE(max98925_dai)); if (ret < 0) dev_err(&i2c->dev, - "Failed to register codec: %d\n", ret); + "Failed to register component: %d\n", ret); return ret; } -static int max98925_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98925_i2c_id[] = { { "max98925", 0 }, { } @@ -645,7 +642,6 @@ static struct i2c_driver max98925_i2c_driver = { .pm = NULL, }, .probe = max98925_i2c_probe, - .remove = max98925_i2c_remove, .id_table = max98925_i2c_id, }; diff --git a/sound/soc/codecs/max98925.h b/sound/soc/codecs/max98925.h index 3783248f2780..96f97085328d 100644 --- a/sound/soc/codecs/max98925.h +++ b/sound/soc/codecs/max98925.h @@ -821,7 +821,7 @@ struct max98925_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct max98925_pdata *pdata; unsigned int sysclk; unsigned int v_slot; diff --git a/sound/soc/codecs/max98926.c b/sound/soc/codecs/max98926.c index 7b1d1b0fa879..d9b1f68f243d 100644 --- a/sound/soc/codecs/max98926.c +++ b/sound/soc/codecs/max98926.c @@ -336,18 +336,18 @@ static void max98926_set_sense_data(struct max98926_priv *max98926) static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component); unsigned int invert = 0; - dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); + dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: max98926_set_sense_data(max98926); break; default: - dev_err(codec->dev, "DAI clock mode unsupported\n"); + dev_err(component->dev, "DAI clock mode unsupported\n"); return -EINVAL; } @@ -364,7 +364,7 @@ static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai, invert = MAX98926_DAI_BCI_MASK | MAX98926_DAI_WCI_MASK; break; default: - dev_err(codec->dev, "DAI invert mode unsupported\n"); + dev_err(component->dev, "DAI invert mode unsupported\n"); return -EINVAL; } @@ -381,8 +381,8 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, { int dai_sr = -EINVAL; int rate = params_rate(params), i; - struct snd_soc_codec *codec = dai->codec; - struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component); int blr_clk_ratio; switch (params_format(params)) { @@ -408,7 +408,7 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, max98926->ch_size = 32; break; default: - dev_dbg(codec->dev, "format unsupported %d\n", + dev_dbg(component->dev, "format unsupported %d\n", params_format(params)); return -EINVAL; } @@ -485,27 +485,29 @@ static struct snd_soc_dai_driver max98926_dai[] = { } }; -static int max98926_probe(struct snd_soc_codec *codec) +static int max98926_probe(struct snd_soc_component *component) { - struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); + struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component); - max98926->codec = codec; + max98926->component = component; /* Hi-Z all the slots */ regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG4, 0xF0); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_max98926 = { - .probe = max98926_probe, - .component_driver = { - .controls = max98926_snd_controls, - .num_controls = ARRAY_SIZE(max98926_snd_controls), - .dapm_routes = max98926_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98926_audio_map), - .dapm_widgets = max98926_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98926_dapm_widgets), - }, +static const struct snd_soc_component_driver soc_component_dev_max98926 = { + .probe = max98926_probe, + .controls = max98926_snd_controls, + .num_controls = ARRAY_SIZE(max98926_snd_controls), + .dapm_routes = max98926_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98926_audio_map), + .dapm_widgets = max98926_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98926_dapm_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98926_regmap = { @@ -563,22 +565,17 @@ static int max98926_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98926, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98926, max98926_dai, ARRAY_SIZE(max98926_dai)); if (ret < 0) dev_err(&i2c->dev, - "Failed to register codec: %d\n", ret); + "Failed to register component: %d\n", ret); dev_info(&i2c->dev, "device version: %x\n", reg); err_out: return ret; } -static int max98926_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98926_i2c_id[] = { { "max98926", 0 }, { } @@ -598,7 +595,6 @@ static struct i2c_driver max98926_i2c_driver = { .pm = NULL, }, .probe = max98926_i2c_probe, - .remove = max98926_i2c_remove, .id_table = max98926_i2c_id, }; diff --git a/sound/soc/codecs/max98926.h b/sound/soc/codecs/max98926.h index 9d7ab6df79ca..ccf2c3f66c07 100644 --- a/sound/soc/codecs/max98926.h +++ b/sound/soc/codecs/max98926.h @@ -838,7 +838,7 @@ struct max98926_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; unsigned int sysclk; unsigned int v_slot; unsigned int i_slot; |