Loading sound/soc/codecs/Kconfig +2 −1 Original line number Diff line number Diff line Loading @@ -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 Loading sound/soc/codecs/max9850.c +37 −43 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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: Loading @@ -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; } Loading @@ -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; Loading @@ -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 */ Loading Loading @@ -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) { Loading @@ -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; } Loading Loading @@ -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 = { static const struct snd_soc_component_driver soc_component_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), }, .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, Loading @@ -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 }, { } Loading @@ -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, }; Loading sound/soc/codecs/max9860.c +34 −36 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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)); Loading Loading @@ -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; } Loading @@ -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; } Loading Loading @@ -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; } Loading Loading @@ -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; } } Loading @@ -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: Loading Loading @@ -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) { Loading @@ -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; Loading @@ -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; } Loading @@ -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 = { static const struct snd_soc_component_driver max9860_component_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), }, .use_pmdown_time = 1, .endianness = 1, .non_legacy_dai_naming = 1, }; #ifdef CONFIG_PM Loading Loading @@ -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); Loading @@ -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; Loading sound/soc/codecs/max9867.c +42 −49 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading @@ -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, Loading @@ -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); Loading @@ -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, Loading @@ -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*/ Loading @@ -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; Loading @@ -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) { Loading @@ -323,10 +325,16 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } /* for i2s compatible mode */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: iface1A |= MAX9867_I2S_DLY; /* SDOUT goes to hiz state after all data is transferred */ iface1A |= MAX9867_SDOUT_HIZ; 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) { Loading Loading @@ -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, } }; Loading @@ -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 = { 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) Loading Loading @@ -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, Loading @@ -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 }, { } Loading @@ -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, }; Loading sound/soc/codecs/max9867.h +0 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
sound/soc/codecs/Kconfig +2 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
sound/soc/codecs/max9850.c +37 −43 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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: Loading @@ -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; } Loading @@ -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; Loading @@ -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 */ Loading Loading @@ -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) { Loading @@ -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; } Loading Loading @@ -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 = { static const struct snd_soc_component_driver soc_component_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), }, .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, Loading @@ -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 }, { } Loading @@ -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, }; Loading
sound/soc/codecs/max9860.c +34 −36 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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)); Loading Loading @@ -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; } Loading @@ -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; } Loading Loading @@ -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; } Loading Loading @@ -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; } } Loading @@ -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: Loading Loading @@ -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) { Loading @@ -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; Loading @@ -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; } Loading @@ -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 = { static const struct snd_soc_component_driver max9860_component_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), }, .use_pmdown_time = 1, .endianness = 1, .non_legacy_dai_naming = 1, }; #ifdef CONFIG_PM Loading Loading @@ -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); Loading @@ -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; Loading
sound/soc/codecs/max9867.c +42 −49 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading @@ -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, Loading @@ -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); Loading @@ -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, Loading @@ -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*/ Loading @@ -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; Loading @@ -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) { Loading @@ -323,10 +325,16 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } /* for i2s compatible mode */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: iface1A |= MAX9867_I2S_DLY; /* SDOUT goes to hiz state after all data is transferred */ iface1A |= MAX9867_SDOUT_HIZ; 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) { Loading Loading @@ -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, } }; Loading @@ -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 = { 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) Loading Loading @@ -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, Loading @@ -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 }, { } Loading @@ -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, }; Loading
sound/soc/codecs/max9867.h +0 −1 Original line number Diff line number Diff line Loading @@ -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; Loading