aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc-dapm.h1
-rw-r--r--include/sound/soc.h3
-rw-r--r--sound/soc/soc-core.c23
-rw-r--r--sound/soc/soc-dapm.c23
4 files changed, 38 insertions, 12 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index b9d586442518..4158cbaa0f25 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -199,6 +199,7 @@ void snd_soc_dapm_free(struct snd_soc_device *socdev);
199/* dapm events */ 199/* dapm events */
200int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream, 200int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream,
201 int event); 201 int event);
202int snd_soc_dapm_device_event(struct snd_soc_device *socdev, int event);
202 203
203/* dapm sys fs - used by the core */ 204/* dapm sys fs - used by the core */
204int snd_soc_dapm_sys_add(struct device *dev); 205int snd_soc_dapm_sys_add(struct device *dev);
diff --git a/include/sound/soc.h b/include/sound/soc.h
index c22c65650405..add5f948e383 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -425,6 +425,9 @@ struct snd_soc_machine {
425 int (*resume_pre)(struct platform_device *pdev); 425 int (*resume_pre)(struct platform_device *pdev);
426 int (*resume_post)(struct platform_device *pdev); 426 int (*resume_post)(struct platform_device *pdev);
427 427
428 /* callbacks */
429 int (*dapm_event)(struct snd_soc_machine *, int event);
430
428 /* CPU <--> Codec DAI links */ 431 /* CPU <--> Codec DAI links */
429 struct snd_soc_dai_link *dai_link; 432 struct snd_soc_dai_link *dai_link;
430 int num_links; 433 int num_links;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 94075256638c..bd656db347ee 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -288,15 +288,16 @@ static void close_delayed_work(struct work_struct *work)
288 if (codec_dai->pop_wait == 1) { 288 if (codec_dai->pop_wait == 1) {
289 289
290 codec_dai->pop_wait = 0; 290 codec_dai->pop_wait = 0;
291 snd_soc_dapm_stream_event(codec, codec_dai->playback.stream_name, 291 snd_soc_dapm_stream_event(codec,
292 codec_dai->playback.stream_name,
292 SND_SOC_DAPM_STREAM_STOP); 293 SND_SOC_DAPM_STREAM_STOP);
293 294
294 /* power down the codec power domain if no longer active */ 295 /* power down the codec power domain if no longer active */
295 if (codec->active == 0) { 296 if (codec->active == 0) {
296 dbg("pop wq D3 %s %s\n", codec->name, 297 dbg("pop wq D3 %s %s\n", codec->name,
297 codec_dai->playback.stream_name); 298 codec_dai->playback.stream_name);
298 if (codec->dapm_event) 299 snd_soc_dapm_device_event(socdev,
299 codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot); 300 SNDRV_CTL_POWER_D3hot);
300 } 301 }
301 } 302 }
302 } 303 }
@@ -352,12 +353,12 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
352 } else { 353 } else {
353 /* capture streams can be powered down now */ 354 /* capture streams can be powered down now */
354 snd_soc_dapm_stream_event(codec, 355 snd_soc_dapm_stream_event(codec,
355 codec_dai->capture.stream_name, SND_SOC_DAPM_STREAM_STOP); 356 codec_dai->capture.stream_name,
357 SND_SOC_DAPM_STREAM_STOP);
356 358
357 if (codec->active == 0 && codec_dai->pop_wait == 0){ 359 if (codec->active == 0 && codec_dai->pop_wait == 0)
358 if (codec->dapm_event) 360 snd_soc_dapm_device_event(socdev,
359 codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot); 361 SNDRV_CTL_POWER_D3hot);
360 }
361 } 362 }
362 363
363 mutex_unlock(&pcm_mutex); 364 mutex_unlock(&pcm_mutex);
@@ -432,8 +433,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
432 /* no delayed work - do we need to power up codec */ 433 /* no delayed work - do we need to power up codec */
433 if (codec->dapm_state != SNDRV_CTL_POWER_D0) { 434 if (codec->dapm_state != SNDRV_CTL_POWER_D0) {
434 435
435 if (codec->dapm_event) 436 snd_soc_dapm_device_event(socdev, SNDRV_CTL_POWER_D1);
436 codec->dapm_event(codec, SNDRV_CTL_POWER_D1);
437 437
438 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 438 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
439 snd_soc_dapm_stream_event(codec, 439 snd_soc_dapm_stream_event(codec,
@@ -444,8 +444,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
444 codec_dai->capture.stream_name, 444 codec_dai->capture.stream_name,
445 SND_SOC_DAPM_STREAM_START); 445 SND_SOC_DAPM_STREAM_START);
446 446
447 if (codec->dapm_event) 447 snd_soc_dapm_device_event(socdev, SNDRV_CTL_POWER_D0);
448 codec->dapm_event(codec, SNDRV_CTL_POWER_D0);
449 if (codec_dai->dai_ops.digital_mute) 448 if (codec_dai->dai_ops.digital_mute)
450 codec_dai->dai_ops.digital_mute(codec_dai, 0); 449 codec_dai->dai_ops.digital_mute(codec_dai, 0);
451 450
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 3b8f94af7e27..16ebb60ed3d4 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1279,6 +1279,29 @@ int snd_soc_dapm_stream_event(struct snd_soc_codec *codec,
1279EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event); 1279EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
1280 1280
1281/** 1281/**
1282 * snd_soc_dapm_device_event - send a device event to the dapm core
1283 * @socdev: audio device
1284 * @event: device event
1285 *
1286 * Sends a device event to the dapm core. The core then makes any
1287 * necessary machine or codec power changes..
1288 *
1289 * Returns 0 for success else error.
1290 */
1291int snd_soc_dapm_device_event(struct snd_soc_device *socdev, int event)
1292{
1293 struct snd_soc_codec *codec = socdev->codec;
1294 struct snd_soc_machine *machine = socdev->machine;
1295
1296 if (machine->dapm_event)
1297 machine->dapm_event(machine, event);
1298 if (codec->dapm_event)
1299 codec->dapm_event(codec, event);
1300 return 0;
1301}
1302EXPORT_SYMBOL_GPL(snd_soc_dapm_device_event);
1303
1304/**
1282 * snd_soc_dapm_set_endpoint - set audio endpoint status 1305 * snd_soc_dapm_set_endpoint - set audio endpoint status
1283 * @codec: audio codec 1306 * @codec: audio codec
1284 * @endpoint: audio signal endpoint (or start point) 1307 * @endpoint: audio signal endpoint (or start point)