diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2011-05-08 12:24:45 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-05-08 19:45:17 -0400 |
commit | 2a43801a76893286ead35e742e486591e75803a2 (patch) | |
tree | c12e83dba662f702bc92e5fc9623ce00092efed2 | |
parent | 7dcf2760bf9d127e6b582977d72316ca58612854 (diff) |
ASoC: SSM2602: Model power supply for the digital core as a DAPM widget
Model the power supply for the digital core as a DAPM_SUPPLY widget. This allows
to cleanup the code a bit.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/ssm2602.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index d8287219eeab..763d392f12a1 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c | |||
@@ -126,6 +126,8 @@ SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SSM2602_PWR, 3, 1), | |||
126 | SND_SOC_DAPM_ADC("ADC", "HiFi Capture", SSM2602_PWR, 2, 1), | 126 | SND_SOC_DAPM_ADC("ADC", "HiFi Capture", SSM2602_PWR, 2, 1), |
127 | SND_SOC_DAPM_PGA("Line Input", SSM2602_PWR, 0, 1, NULL, 0), | 127 | SND_SOC_DAPM_PGA("Line Input", SSM2602_PWR, 0, 1, NULL, 0), |
128 | 128 | ||
129 | SND_SOC_DAPM_SUPPLY("Digital Core Power", SSM2602_ACTIVE, 0, 0, 0, 0), | ||
130 | |||
129 | SND_SOC_DAPM_OUTPUT("LOUT"), | 131 | SND_SOC_DAPM_OUTPUT("LOUT"), |
130 | SND_SOC_DAPM_OUTPUT("ROUT"), | 132 | SND_SOC_DAPM_OUTPUT("ROUT"), |
131 | SND_SOC_DAPM_INPUT("RLINEIN"), | 133 | SND_SOC_DAPM_INPUT("RLINEIN"), |
@@ -152,6 +154,9 @@ SND_SOC_DAPM_MIXER("Output Mixer", SND_SOC_NOPM, 0, 0, | |||
152 | }; | 154 | }; |
153 | 155 | ||
154 | static const struct snd_soc_dapm_route ssm260x_routes[] = { | 156 | static const struct snd_soc_dapm_route ssm260x_routes[] = { |
157 | {"DAC", NULL, "Digital Core Power"}, | ||
158 | {"ADC", NULL, "Digital Core Power"}, | ||
159 | |||
155 | {"Output Mixer", "Line Bypass Switch", "Line Input"}, | 160 | {"Output Mixer", "Line Bypass Switch", "Line Input"}, |
156 | {"Output Mixer", "HiFi Playback Switch", "DAC"}, | 161 | {"Output Mixer", "HiFi Playback Switch", "DAC"}, |
157 | 162 | ||
@@ -252,7 +257,6 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream, | |||
252 | if (srate < 0) | 257 | if (srate < 0) |
253 | return srate; | 258 | return srate; |
254 | 259 | ||
255 | snd_soc_write(codec, SSM2602_ACTIVE, 0); | ||
256 | snd_soc_write(codec, SSM2602_SRATE, srate); | 260 | snd_soc_write(codec, SSM2602_SRATE, srate); |
257 | 261 | ||
258 | /* bit size */ | 262 | /* bit size */ |
@@ -270,7 +274,6 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream, | |||
270 | break; | 274 | break; |
271 | } | 275 | } |
272 | snd_soc_write(codec, SSM2602_IFACE, iface); | 276 | snd_soc_write(codec, SSM2602_IFACE, iface); |
273 | snd_soc_write(codec, SSM2602_ACTIVE, ACTIVE_ACTIVATE_CODEC); | ||
274 | return 0; | 277 | return 0; |
275 | } | 278 | } |
276 | 279 | ||
@@ -312,17 +315,6 @@ static int ssm2602_startup(struct snd_pcm_substream *substream, | |||
312 | return 0; | 315 | return 0; |
313 | } | 316 | } |
314 | 317 | ||
315 | static int ssm2602_pcm_prepare(struct snd_pcm_substream *substream, | ||
316 | struct snd_soc_dai *dai) | ||
317 | { | ||
318 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
319 | struct snd_soc_codec *codec = rtd->codec; | ||
320 | /* set active */ | ||
321 | snd_soc_write(codec, SSM2602_ACTIVE, ACTIVE_ACTIVATE_CODEC); | ||
322 | |||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | static void ssm2602_shutdown(struct snd_pcm_substream *substream, | 318 | static void ssm2602_shutdown(struct snd_pcm_substream *substream, |
327 | struct snd_soc_dai *dai) | 319 | struct snd_soc_dai *dai) |
328 | { | 320 | { |
@@ -330,16 +322,13 @@ static void ssm2602_shutdown(struct snd_pcm_substream *substream, | |||
330 | struct snd_soc_codec *codec = rtd->codec; | 322 | struct snd_soc_codec *codec = rtd->codec; |
331 | struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); | 323 | struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); |
332 | 324 | ||
333 | /* deactivate */ | ||
334 | if (!codec->active) | ||
335 | snd_soc_write(codec, SSM2602_ACTIVE, 0); | ||
336 | |||
337 | if (ssm2602->master_substream == substream) | 325 | if (ssm2602->master_substream == substream) |
338 | ssm2602->master_substream = ssm2602->slave_substream; | 326 | ssm2602->master_substream = ssm2602->slave_substream; |
339 | 327 | ||
340 | ssm2602->slave_substream = NULL; | 328 | ssm2602->slave_substream = NULL; |
341 | } | 329 | } |
342 | 330 | ||
331 | |||
343 | static int ssm2602_mute(struct snd_soc_dai *dai, int mute) | 332 | static int ssm2602_mute(struct snd_soc_dai *dai, int mute) |
344 | { | 333 | { |
345 | struct snd_soc_codec *codec = dai->codec; | 334 | struct snd_soc_codec *codec = dai->codec; |
@@ -446,7 +435,6 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec, | |||
446 | break; | 435 | break; |
447 | case SND_SOC_BIAS_OFF: | 436 | case SND_SOC_BIAS_OFF: |
448 | /* everything off, dac mute, inactive */ | 437 | /* everything off, dac mute, inactive */ |
449 | snd_soc_write(codec, SSM2602_ACTIVE, 0); | ||
450 | snd_soc_write(codec, SSM2602_PWR, 0xffff); | 438 | snd_soc_write(codec, SSM2602_PWR, 0xffff); |
451 | break; | 439 | break; |
452 | 440 | ||
@@ -464,7 +452,6 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec, | |||
464 | 452 | ||
465 | static struct snd_soc_dai_ops ssm2602_dai_ops = { | 453 | static struct snd_soc_dai_ops ssm2602_dai_ops = { |
466 | .startup = ssm2602_startup, | 454 | .startup = ssm2602_startup, |
467 | .prepare = ssm2602_pcm_prepare, | ||
468 | .hw_params = ssm2602_hw_params, | 455 | .hw_params = ssm2602_hw_params, |
469 | .shutdown = ssm2602_shutdown, | 456 | .shutdown = ssm2602_shutdown, |
470 | .digital_mute = ssm2602_mute, | 457 | .digital_mute = ssm2602_mute, |