diff options
author | Dan Murphy <dmurphy@ti.com> | 2014-08-01 11:57:04 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-08-16 18:06:49 -0400 |
commit | a7a8e994ddd004fbabfcf04c26c204297b5f826d (patch) | |
tree | 0fddf4d7ba1a0fedfcfe5b71491ec73b2deccdd1 /sound | |
parent | 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff) |
ASoC: tas2552: Add DAPM calls for amp and PLL
Add DAPM calls to enable/disable the Class D amp.
Also add a DAPM call to turn off the PLL upon
the stream completing.
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/tas2552.c | 68 |
1 files changed, 48 insertions, 20 deletions
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c index 23b32960ff1d..1ed57a7e57b6 100644 --- a/sound/soc/codecs/tas2552.c +++ b/sound/soc/codecs/tas2552.c | |||
@@ -78,6 +78,43 @@ struct tas2552_data { | |||
78 | unsigned int mclk; | 78 | unsigned int mclk; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /* Input mux controls */ | ||
82 | static const char *tas2552_input_texts[] = { | ||
83 | "Digital", "Analog" | ||
84 | }; | ||
85 | |||
86 | static SOC_ENUM_SINGLE_DECL(tas2552_input_mux_enum, TAS2552_CFG_3, 7, | ||
87 | tas2552_input_texts); | ||
88 | |||
89 | static const struct snd_kcontrol_new tas2552_input_mux_control[] = { | ||
90 | SOC_DAPM_ENUM("Input selection", tas2552_input_mux_enum) | ||
91 | }; | ||
92 | |||
93 | static const struct snd_soc_dapm_widget tas2552_dapm_widgets[] = | ||
94 | { | ||
95 | SND_SOC_DAPM_INPUT("IN"), | ||
96 | |||
97 | /* MUX Controls */ | ||
98 | SND_SOC_DAPM_MUX("Input selection", SND_SOC_NOPM, 0, 0, | ||
99 | tas2552_input_mux_control), | ||
100 | |||
101 | SND_SOC_DAPM_AIF_IN("DAC IN", "DAC Playback", 0, SND_SOC_NOPM, 0, 0), | ||
102 | SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0), | ||
103 | SND_SOC_DAPM_OUT_DRV("ClassD", TAS2552_CFG_2, 7, 0, NULL, 0), | ||
104 | SND_SOC_DAPM_SUPPLY("PLL", TAS2552_CFG_2, 3, 0, NULL, 0), | ||
105 | |||
106 | SND_SOC_DAPM_OUTPUT("OUT") | ||
107 | }; | ||
108 | |||
109 | static const struct snd_soc_dapm_route tas2552_audio_map[] = { | ||
110 | {"DAC", NULL, "DAC IN"}, | ||
111 | {"Input selection", "Digital", "DAC"}, | ||
112 | {"Input selection", "Analog", "IN"}, | ||
113 | {"ClassD", NULL, "Input selection"}, | ||
114 | {"OUT", NULL, "ClassD"}, | ||
115 | {"ClassD", NULL, "PLL"}, | ||
116 | }; | ||
117 | |||
81 | static void tas2552_sw_shutdown(struct tas2552_data *tas_data, int sw_shutdown) | 118 | static void tas2552_sw_shutdown(struct tas2552_data *tas_data, int sw_shutdown) |
82 | { | 119 | { |
83 | u8 cfg1_reg; | 120 | u8 cfg1_reg; |
@@ -101,10 +138,6 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, | |||
101 | int d; | 138 | int d; |
102 | u8 p, j; | 139 | u8 p, j; |
103 | 140 | ||
104 | /* Turn on Class D amplifier */ | ||
105 | snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_CLASSD_EN_MASK, | ||
106 | TAS2552_CLASSD_EN); | ||
107 | |||
108 | if (!tas2552->mclk) | 141 | if (!tas2552->mclk) |
109 | return -EINVAL; | 142 | return -EINVAL; |
110 | 143 | ||
@@ -147,9 +180,6 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, | |||
147 | 180 | ||
148 | } | 181 | } |
149 | 182 | ||
150 | snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, | ||
151 | TAS2552_PLL_ENABLE); | ||
152 | |||
153 | return 0; | 183 | return 0; |
154 | } | 184 | } |
155 | 185 | ||
@@ -269,19 +299,10 @@ static const struct dev_pm_ops tas2552_pm = { | |||
269 | NULL) | 299 | NULL) |
270 | }; | 300 | }; |
271 | 301 | ||
272 | static void tas2552_shutdown(struct snd_pcm_substream *substream, | ||
273 | struct snd_soc_dai *dai) | ||
274 | { | ||
275 | struct snd_soc_codec *codec = dai->codec; | ||
276 | |||
277 | snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, 0); | ||
278 | } | ||
279 | |||
280 | static struct snd_soc_dai_ops tas2552_speaker_dai_ops = { | 302 | static struct snd_soc_dai_ops tas2552_speaker_dai_ops = { |
281 | .hw_params = tas2552_hw_params, | 303 | .hw_params = tas2552_hw_params, |
282 | .set_sysclk = tas2552_set_dai_sysclk, | 304 | .set_sysclk = tas2552_set_dai_sysclk, |
283 | .set_fmt = tas2552_set_dai_fmt, | 305 | .set_fmt = tas2552_set_dai_fmt, |
284 | .shutdown = tas2552_shutdown, | ||
285 | .digital_mute = tas2552_mute, | 306 | .digital_mute = tas2552_mute, |
286 | }; | 307 | }; |
287 | 308 | ||
@@ -294,7 +315,7 @@ static struct snd_soc_dai_driver tas2552_dai[] = { | |||
294 | { | 315 | { |
295 | .name = "tas2552-amplifier", | 316 | .name = "tas2552-amplifier", |
296 | .playback = { | 317 | .playback = { |
297 | .stream_name = "Speaker", | 318 | .stream_name = "Playback", |
298 | .channels_min = 2, | 319 | .channels_min = 2, |
299 | .channels_max = 2, | 320 | .channels_max = 2, |
300 | .rates = SNDRV_PCM_RATE_8000_192000, | 321 | .rates = SNDRV_PCM_RATE_8000_192000, |
@@ -312,6 +333,7 @@ static DECLARE_TLV_DB_SCALE(dac_tlv, -7, 100, 24); | |||
312 | static const struct snd_kcontrol_new tas2552_snd_controls[] = { | 333 | static const struct snd_kcontrol_new tas2552_snd_controls[] = { |
313 | SOC_SINGLE_TLV("Speaker Driver Playback Volume", | 334 | SOC_SINGLE_TLV("Speaker Driver Playback Volume", |
314 | TAS2552_PGA_GAIN, 0, 0x1f, 1, dac_tlv), | 335 | TAS2552_PGA_GAIN, 0, 0x1f, 1, dac_tlv), |
336 | SOC_DAPM_SINGLE("Playback AMP", SND_SOC_NOPM, 0, 1, 0), | ||
315 | }; | 337 | }; |
316 | 338 | ||
317 | static const struct reg_default tas2552_init_regs[] = { | 339 | static const struct reg_default tas2552_init_regs[] = { |
@@ -321,6 +343,7 @@ static const struct reg_default tas2552_init_regs[] = { | |||
321 | static int tas2552_codec_probe(struct snd_soc_codec *codec) | 343 | static int tas2552_codec_probe(struct snd_soc_codec *codec) |
322 | { | 344 | { |
323 | struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); | 345 | struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); |
346 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
324 | int ret; | 347 | int ret; |
325 | 348 | ||
326 | tas2552->codec = codec; | 349 | tas2552->codec = codec; |
@@ -362,9 +385,14 @@ static int tas2552_codec_probe(struct snd_soc_codec *codec) | |||
362 | goto patch_fail; | 385 | goto patch_fail; |
363 | } | 386 | } |
364 | 387 | ||
365 | snd_soc_write(codec, TAS2552_CFG_2, TAS2552_CLASSD_EN | | 388 | snd_soc_write(codec, TAS2552_CFG_2, TAS2552_BOOST_EN | |
366 | TAS2552_BOOST_EN | TAS2552_APT_EN | | 389 | TAS2552_APT_EN | TAS2552_LIM_EN); |
367 | TAS2552_LIM_EN); | 390 | |
391 | snd_soc_dapm_new_controls(dapm, tas2552_dapm_widgets, | ||
392 | ARRAY_SIZE(tas2552_dapm_widgets)); | ||
393 | snd_soc_dapm_add_routes(dapm, tas2552_audio_map, | ||
394 | ARRAY_SIZE(tas2552_audio_map)); | ||
395 | |||
368 | return 0; | 396 | return 0; |
369 | 397 | ||
370 | patch_fail: | 398 | patch_fail: |