diff options
Diffstat (limited to 'sound/soc/codecs/lm49453.c')
| -rw-r--r-- | sound/soc/codecs/lm49453.c | 120 |
1 files changed, 56 insertions, 64 deletions
diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c index 8d413c2677cc..043030509795 100644 --- a/sound/soc/codecs/lm49453.c +++ b/sound/soc/codecs/lm49453.c @@ -1,12 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * lm49453.c - LM49453 ALSA Soc Audio driver * * Copyright (c) 2012 Texas Instruments, Inc * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * * Initially based on sound/soc/codecs/wm8350.c */ @@ -1110,7 +1107,7 @@ static int lm49453_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 snd_soc_component *component = dai->component; u16 clk_div = 0; /* Setting DAC clock dividers based on substream sample rate. */ @@ -1134,32 +1131,32 @@ static int lm49453_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_write(codec, LM49453_P0_ADC_CLK_DIV_REG, clk_div); - snd_soc_write(codec, LM49453_P0_DAC_HP_CLK_DIV_REG, clk_div); + snd_soc_component_write(component, LM49453_P0_ADC_CLK_DIV_REG, clk_div); + snd_soc_component_write(component, LM49453_P0_DAC_HP_CLK_DIV_REG, clk_div); return 0; } static int lm49453_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; u16 aif_val; int mode = 0; int clk_phase = 0; int clk_shift = 0; - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: + switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { + case SND_SOC_DAIFMT_CBC_CFC: aif_val = 0; break; - case SND_SOC_DAIFMT_CBS_CFM: + case SND_SOC_DAIFMT_CBC_CFP: aif_val = LM49453_AUDIO_PORT1_BASIC_SYNC_MS; break; - case SND_SOC_DAIFMT_CBM_CFS: + case SND_SOC_DAIFMT_CBP_CFC: aif_val = LM49453_AUDIO_PORT1_BASIC_CLK_MS; break; - case SND_SOC_DAIFMT_CBM_CFM: + case SND_SOC_DAIFMT_CBP_CFP: aif_val = LM49453_AUDIO_PORT1_BASIC_CLK_MS | LM49453_AUDIO_PORT1_BASIC_SYNC_MS; break; @@ -1185,11 +1182,11 @@ static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, LM49453_P0_AUDIO_PORT1_BASIC_REG, + snd_soc_component_update_bits(component, LM49453_P0_AUDIO_PORT1_BASIC_REG, LM49453_AUDIO_PORT1_BASIC_FMT_MASK|BIT(0)|BIT(5), (aif_val | mode | clk_phase)); - snd_soc_write(codec, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift); + snd_soc_component_write(component, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift); return 0; } @@ -1197,7 +1194,7 @@ static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int lm49453_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 pll_clk = 0; switch (freq) { @@ -1209,57 +1206,56 @@ static int lm49453_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, break; case 48000: case 32576: - /* fll clk slection */ - pll_clk = BIT(4); return 0; default: return -EINVAL; } - snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG, BIT(4), pll_clk); + snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG, BIT(4), pll_clk); return 0; } -static int lm49453_hp_mute(struct snd_soc_dai *dai, int mute) +static int lm49453_hp_mute(struct snd_soc_dai *dai, int mute, int direction) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(1)|BIT(0), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(1)|BIT(0), (mute ? (BIT(1)|BIT(0)) : 0)); return 0; } -static int lm49453_lo_mute(struct snd_soc_dai *dai, int mute) +static int lm49453_lo_mute(struct snd_soc_dai *dai, int mute, int direction) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(3)|BIT(2), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(3)|BIT(2), (mute ? (BIT(3)|BIT(2)) : 0)); return 0; } -static int lm49453_ls_mute(struct snd_soc_dai *dai, int mute) +static int lm49453_ls_mute(struct snd_soc_dai *dai, int mute, int direction) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(5)|BIT(4), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(5)|BIT(4), (mute ? (BIT(5)|BIT(4)) : 0)); return 0; } -static int lm49453_ep_mute(struct snd_soc_dai *dai, int mute) +static int lm49453_ep_mute(struct snd_soc_dai *dai, int mute, int direction) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(4), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(4), (mute ? BIT(4) : 0)); return 0; } -static int lm49453_ha_mute(struct snd_soc_dai *dai, int mute) +static int lm49453_ha_mute(struct snd_soc_dai *dai, int mute, int direction) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(7)|BIT(6), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(7)|BIT(6), (mute ? (BIT(7)|BIT(6)) : 0)); return 0; } -static int lm49453_set_bias_level(struct snd_soc_codec *codec, +static int lm49453_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct lm49453_priv *lm49453 = snd_soc_codec_get_drvdata(codec); + 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: @@ -1267,15 +1263,15 @@ static int lm49453_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_dapm_get_bias_level(dapm) == SND_SOC_BIAS_OFF) regcache_sync(lm49453->regmap); - snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG, + snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG, LM49453_PMC_SETUP_CHIP_EN, LM49453_CHIP_EN); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG, + snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG, LM49453_PMC_SETUP_CHIP_EN, 0); break; } @@ -1291,35 +1287,40 @@ static const struct snd_soc_dai_ops lm49453_headset_dai_ops = { .hw_params = lm49453_hw_params, .set_sysclk = lm49453_set_dai_sysclk, .set_fmt = lm49453_set_dai_fmt, - .digital_mute = lm49453_hp_mute, + .mute_stream = lm49453_hp_mute, + .no_capture_mute = 1, }; static const struct snd_soc_dai_ops lm49453_speaker_dai_ops = { .hw_params = lm49453_hw_params, .set_sysclk = lm49453_set_dai_sysclk, .set_fmt = lm49453_set_dai_fmt, - .digital_mute = lm49453_ls_mute, + .mute_stream = lm49453_ls_mute, + .no_capture_mute = 1, }; static const struct snd_soc_dai_ops lm49453_haptic_dai_ops = { .hw_params = lm49453_hw_params, .set_sysclk = lm49453_set_dai_sysclk, .set_fmt = lm49453_set_dai_fmt, - .digital_mute = lm49453_ha_mute, + .mute_stream = lm49453_ha_mute, + .no_capture_mute = 1, }; static const struct snd_soc_dai_ops lm49453_ep_dai_ops = { .hw_params = lm49453_hw_params, .set_sysclk = lm49453_set_dai_sysclk, .set_fmt = lm49453_set_dai_fmt, - .digital_mute = lm49453_ep_mute, + .mute_stream = lm49453_ep_mute, + .no_capture_mute = 1, }; static const struct snd_soc_dai_ops lm49453_lineout_dai_ops = { .hw_params = lm49453_hw_params, .set_sysclk = lm49453_set_dai_sysclk, .set_fmt = lm49453_set_dai_fmt, - .digital_mute = lm49453_lo_mute, + .mute_stream = lm49453_lo_mute, + .no_capture_mute = 1, }; /* LM49453 dai structure. */ @@ -1341,7 +1342,7 @@ static struct snd_soc_dai_driver lm49453_dai[] = { .formats = LM49453_FORMATS, }, .ops = &lm49453_headset_dai_ops, - .symmetric_rates = 1, + .symmetric_rate = 1, }, { .name = "LM49453 Speaker", @@ -1389,17 +1390,16 @@ static struct snd_soc_dai_driver lm49453_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_lm49453 = { - .set_bias_level = lm49453_set_bias_level, - .component_driver = { - .controls = lm49453_snd_controls, - .num_controls = ARRAY_SIZE(lm49453_snd_controls), - .dapm_widgets = lm49453_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(lm49453_dapm_widgets), - .dapm_routes = lm49453_audio_map, - .num_dapm_routes = ARRAY_SIZE(lm49453_audio_map), - }, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_lm49453 = { + .set_bias_level = lm49453_set_bias_level, + .controls = lm49453_snd_controls, + .num_controls = ARRAY_SIZE(lm49453_snd_controls), + .dapm_widgets = lm49453_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(lm49453_dapm_widgets), + .dapm_routes = lm49453_audio_map, + .num_dapm_routes = ARRAY_SIZE(lm49453_audio_map), + .use_pmdown_time = 1, + .endianness = 1, }; static const struct regmap_config lm49453_regmap_config = { @@ -1412,8 +1412,7 @@ static const struct regmap_config lm49453_regmap_config = { .cache_type = REGCACHE_RBTREE, }; -static int lm49453_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) +static int lm49453_i2c_probe(struct i2c_client *i2c) { struct lm49453_priv *lm49453; int ret = 0; @@ -1434,23 +1433,17 @@ static int lm49453_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_lm49453, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_lm49453, lm49453_dai, ARRAY_SIZE(lm49453_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; } -static int lm49453_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id lm49453_i2c_id[] = { - { "lm49453", 0 }, + { "lm49453" }, { } }; MODULE_DEVICE_TABLE(i2c, lm49453_i2c_id); @@ -1460,7 +1453,6 @@ static struct i2c_driver lm49453_i2c_driver = { .name = "lm49453", }, .probe = lm49453_i2c_probe, - .remove = lm49453_i2c_remove, .id_table = lm49453_i2c_id, }; |
