diff options
| author | Mark Brown <broonie@linaro.org> | 2014-01-20 06:50:41 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@linaro.org> | 2014-01-20 06:50:41 -0500 |
| commit | ac6d7c48e3a5e82e876114b9ca0b489e96997743 (patch) | |
| tree | d51ab23d4d59248c969c25bb2fc14f45158ff5ae | |
| parent | 31824e6554a4f96a9830fc9d4a15de8a6539857a (diff) | |
| parent | 2a99ef0fdb35a0f8d6b56ccc5d9d821e9ff100c1 (diff) | |
Merge remote-tracking branch 'asoc/topic/compress' into asoc-next
| -rw-r--r-- | include/sound/soc-dpcm.h | 22 | ||||
| -rw-r--r-- | include/sound/soc.h | 1 | ||||
| -rw-r--r-- | sound/soc/soc-compress.c | 301 | ||||
| -rw-r--r-- | sound/soc/soc-pcm.c | 29 |
4 files changed, 335 insertions, 18 deletions
diff --git a/include/sound/soc-dpcm.h b/include/sound/soc-dpcm.h index 047d657c331c..2883a7a6f9f3 100644 --- a/include/sound/soc-dpcm.h +++ b/include/sound/soc-dpcm.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #ifndef __LINUX_SND_SOC_DPCM_H | 11 | #ifndef __LINUX_SND_SOC_DPCM_H |
| 12 | #define __LINUX_SND_SOC_DPCM_H | 12 | #define __LINUX_SND_SOC_DPCM_H |
| 13 | 13 | ||
| 14 | #include <linux/slab.h> | ||
| 14 | #include <linux/list.h> | 15 | #include <linux/list.h> |
| 15 | #include <sound/pcm.h> | 16 | #include <sound/pcm.h> |
| 16 | 17 | ||
| @@ -135,4 +136,25 @@ int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute); | |||
| 135 | int soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd); | 136 | int soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd); |
| 136 | int soc_dpcm_runtime_update(struct snd_soc_card *); | 137 | int soc_dpcm_runtime_update(struct snd_soc_card *); |
| 137 | 138 | ||
| 139 | int dpcm_path_get(struct snd_soc_pcm_runtime *fe, | ||
| 140 | int stream, struct snd_soc_dapm_widget_list **list_); | ||
| 141 | int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, | ||
| 142 | int stream, struct snd_soc_dapm_widget_list **list, int new); | ||
| 143 | int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream); | ||
| 144 | int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream); | ||
| 145 | void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream); | ||
| 146 | void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream); | ||
| 147 | int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream); | ||
| 148 | int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int tream); | ||
| 149 | int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int cmd); | ||
| 150 | int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream); | ||
| 151 | int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, | ||
| 152 | int event); | ||
| 153 | |||
| 154 | static inline void dpcm_path_put(struct snd_soc_dapm_widget_list **list) | ||
| 155 | { | ||
| 156 | kfree(*list); | ||
| 157 | } | ||
| 158 | |||
| 159 | |||
| 138 | #endif | 160 | #endif |
diff --git a/include/sound/soc.h b/include/sound/soc.h index 03ce45bf8ade..9a001472b96a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
| @@ -1042,6 +1042,7 @@ struct snd_soc_pcm_runtime { | |||
| 1042 | 1042 | ||
| 1043 | /* Dynamic PCM BE runtime data */ | 1043 | /* Dynamic PCM BE runtime data */ |
| 1044 | struct snd_soc_dpcm_runtime dpcm[2]; | 1044 | struct snd_soc_dpcm_runtime dpcm[2]; |
| 1045 | int fe_compr; | ||
| 1045 | 1046 | ||
| 1046 | long pmdown_time; | 1047 | long pmdown_time; |
| 1047 | unsigned char pop_wait:1; | 1048 | unsigned char pop_wait:1; |
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 53c9ecdd119f..5e9690c85d8f 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <sound/compress_driver.h> | 24 | #include <sound/compress_driver.h> |
| 25 | #include <sound/soc.h> | 25 | #include <sound/soc.h> |
| 26 | #include <sound/initval.h> | 26 | #include <sound/initval.h> |
| 27 | #include <sound/soc-dpcm.h> | ||
| 27 | 28 | ||
| 28 | static int soc_compr_open(struct snd_compr_stream *cstream) | 29 | static int soc_compr_open(struct snd_compr_stream *cstream) |
| 29 | { | 30 | { |
| @@ -75,6 +76,98 @@ out: | |||
| 75 | return ret; | 76 | return ret; |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 79 | static int soc_compr_open_fe(struct snd_compr_stream *cstream) | ||
| 80 | { | ||
| 81 | struct snd_soc_pcm_runtime *fe = cstream->private_data; | ||
| 82 | struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; | ||
| 83 | struct snd_soc_platform *platform = fe->platform; | ||
| 84 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; | ||
| 85 | struct snd_soc_dai *codec_dai = fe->codec_dai; | ||
| 86 | struct snd_soc_dpcm *dpcm; | ||
| 87 | struct snd_soc_dapm_widget_list *list; | ||
| 88 | int stream; | ||
| 89 | int ret = 0; | ||
| 90 | |||
| 91 | if (cstream->direction == SND_COMPRESS_PLAYBACK) | ||
| 92 | stream = SNDRV_PCM_STREAM_PLAYBACK; | ||
| 93 | else | ||
| 94 | stream = SNDRV_PCM_STREAM_CAPTURE; | ||
| 95 | |||
| 96 | mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); | ||
| 97 | |||
| 98 | if (platform->driver->compr_ops && platform->driver->compr_ops->open) { | ||
| 99 | ret = platform->driver->compr_ops->open(cstream); | ||
| 100 | if (ret < 0) { | ||
| 101 | pr_err("compress asoc: can't open platform %s\n", platform->name); | ||
| 102 | goto out; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->startup) { | ||
| 107 | ret = fe->dai_link->compr_ops->startup(cstream); | ||
| 108 | if (ret < 0) { | ||
| 109 | pr_err("compress asoc: %s startup failed\n", fe->dai_link->name); | ||
| 110 | goto machine_err; | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | fe->dpcm[stream].runtime = fe_substream->runtime; | ||
| 115 | |||
| 116 | if (dpcm_path_get(fe, stream, &list) <= 0) { | ||
| 117 | dev_dbg(fe->dev, "ASoC: %s no valid %s route\n", | ||
| 118 | fe->dai_link->name, stream ? "capture" : "playback"); | ||
| 119 | } | ||
| 120 | |||
| 121 | /* calculate valid and active FE <-> BE dpcms */ | ||
| 122 | dpcm_process_paths(fe, stream, &list, 1); | ||
| 123 | |||
| 124 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; | ||
| 125 | |||
| 126 | ret = dpcm_be_dai_startup(fe, stream); | ||
| 127 | if (ret < 0) { | ||
| 128 | /* clean up all links */ | ||
| 129 | list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) | ||
| 130 | dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; | ||
| 131 | |||
| 132 | dpcm_be_disconnect(fe, stream); | ||
| 133 | fe->dpcm[stream].runtime = NULL; | ||
| 134 | goto fe_err; | ||
| 135 | } | ||
| 136 | |||
| 137 | dpcm_clear_pending_state(fe, stream); | ||
| 138 | dpcm_path_put(&list); | ||
| 139 | |||
| 140 | fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; | ||
| 141 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; | ||
| 142 | |||
| 143 | if (cstream->direction == SND_COMPRESS_PLAYBACK) { | ||
| 144 | cpu_dai->playback_active++; | ||
| 145 | codec_dai->playback_active++; | ||
| 146 | } else { | ||
| 147 | cpu_dai->capture_active++; | ||
| 148 | codec_dai->capture_active++; | ||
| 149 | } | ||
| 150 | |||
| 151 | cpu_dai->active++; | ||
| 152 | codec_dai->active++; | ||
| 153 | fe->codec->active++; | ||
| 154 | |||
| 155 | mutex_unlock(&fe->card->mutex); | ||
| 156 | |||
| 157 | return 0; | ||
| 158 | |||
| 159 | fe_err: | ||
| 160 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) | ||
| 161 | fe->dai_link->compr_ops->shutdown(cstream); | ||
| 162 | machine_err: | ||
| 163 | if (platform->driver->compr_ops && platform->driver->compr_ops->free) | ||
| 164 | platform->driver->compr_ops->free(cstream); | ||
| 165 | out: | ||
| 166 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; | ||
| 167 | mutex_unlock(&fe->card->mutex); | ||
| 168 | return ret; | ||
| 169 | } | ||
| 170 | |||
| 78 | /* | 171 | /* |
| 79 | * Power down the audio subsystem pmdown_time msecs after close is called. | 172 | * Power down the audio subsystem pmdown_time msecs after close is called. |
| 80 | * This is to ensure there are no pops or clicks in between any music tracks | 173 | * This is to ensure there are no pops or clicks in between any music tracks |
| @@ -164,6 +257,65 @@ static int soc_compr_free(struct snd_compr_stream *cstream) | |||
| 164 | return 0; | 257 | return 0; |
| 165 | } | 258 | } |
| 166 | 259 | ||
| 260 | static int soc_compr_free_fe(struct snd_compr_stream *cstream) | ||
| 261 | { | ||
| 262 | struct snd_soc_pcm_runtime *fe = cstream->private_data; | ||
| 263 | struct snd_soc_platform *platform = fe->platform; | ||
| 264 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; | ||
| 265 | struct snd_soc_dai *codec_dai = fe->codec_dai; | ||
| 266 | struct snd_soc_dpcm *dpcm; | ||
| 267 | int stream, ret; | ||
| 268 | |||
| 269 | mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); | ||
| 270 | |||
| 271 | if (cstream->direction == SND_COMPRESS_PLAYBACK) { | ||
| 272 | stream = SNDRV_PCM_STREAM_PLAYBACK; | ||
| 273 | cpu_dai->playback_active--; | ||
| 274 | codec_dai->playback_active--; | ||
| 275 | } else { | ||
| 276 | stream = SNDRV_PCM_STREAM_CAPTURE; | ||
| 277 | cpu_dai->capture_active--; | ||
| 278 | codec_dai->capture_active--; | ||
| 279 | } | ||
| 280 | |||
| 281 | cpu_dai->active--; | ||
| 282 | codec_dai->active--; | ||
| 283 | fe->codec->active--; | ||
| 284 | |||
| 285 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; | ||
| 286 | |||
| 287 | ret = dpcm_be_dai_hw_free(fe, stream); | ||
| 288 | if (ret < 0) | ||
| 289 | dev_err(fe->dev, "compressed hw_free failed %d\n", ret); | ||
| 290 | |||
| 291 | ret = dpcm_be_dai_shutdown(fe, stream); | ||
| 292 | |||
| 293 | /* mark FE's links ready to prune */ | ||
| 294 | list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) | ||
| 295 | dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; | ||
| 296 | |||
| 297 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 298 | dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); | ||
| 299 | else | ||
| 300 | dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); | ||
| 301 | |||
| 302 | fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; | ||
| 303 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; | ||
| 304 | |||
| 305 | dpcm_be_disconnect(fe, stream); | ||
| 306 | |||
| 307 | fe->dpcm[stream].runtime = NULL; | ||
| 308 | |||
| 309 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) | ||
| 310 | fe->dai_link->compr_ops->shutdown(cstream); | ||
| 311 | |||
| 312 | if (platform->driver->compr_ops && platform->driver->compr_ops->free) | ||
| 313 | platform->driver->compr_ops->free(cstream); | ||
| 314 | |||
| 315 | mutex_unlock(&fe->card->mutex); | ||
| 316 | return 0; | ||
| 317 | } | ||
| 318 | |||
| 167 | static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) | 319 | static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) |
| 168 | { | 320 | { |
| 169 | 321 | ||
| @@ -194,6 +346,59 @@ out: | |||
| 194 | return ret; | 346 | return ret; |
| 195 | } | 347 | } |
| 196 | 348 | ||
| 349 | static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) | ||
| 350 | { | ||
| 351 | struct snd_soc_pcm_runtime *fe = cstream->private_data; | ||
| 352 | struct snd_soc_platform *platform = fe->platform; | ||
| 353 | int ret = 0, stream; | ||
| 354 | |||
| 355 | if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN || | ||
| 356 | cmd == SND_COMPR_TRIGGER_DRAIN) { | ||
| 357 | |||
| 358 | if (platform->driver->compr_ops && | ||
| 359 | platform->driver->compr_ops->trigger) | ||
| 360 | return platform->driver->compr_ops->trigger(cstream, cmd); | ||
| 361 | } | ||
| 362 | |||
| 363 | if (cstream->direction == SND_COMPRESS_PLAYBACK) | ||
| 364 | stream = SNDRV_PCM_STREAM_PLAYBACK; | ||
| 365 | else | ||
| 366 | stream = SNDRV_PCM_STREAM_CAPTURE; | ||
| 367 | |||
| 368 | |||
| 369 | mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); | ||
| 370 | |||
| 371 | if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) { | ||
| 372 | ret = platform->driver->compr_ops->trigger(cstream, cmd); | ||
| 373 | if (ret < 0) | ||
| 374 | goto out; | ||
| 375 | } | ||
| 376 | |||
| 377 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; | ||
| 378 | |||
| 379 | ret = dpcm_be_dai_trigger(fe, stream, cmd); | ||
| 380 | |||
| 381 | switch (cmd) { | ||
| 382 | case SNDRV_PCM_TRIGGER_START: | ||
| 383 | case SNDRV_PCM_TRIGGER_RESUME: | ||
| 384 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
| 385 | fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; | ||
| 386 | break; | ||
| 387 | case SNDRV_PCM_TRIGGER_STOP: | ||
| 388 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
| 389 | fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; | ||
| 390 | break; | ||
| 391 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
| 392 | fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; | ||
| 393 | break; | ||
| 394 | } | ||
| 395 | |||
| 396 | out: | ||
| 397 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; | ||
| 398 | mutex_unlock(&fe->card->mutex); | ||
| 399 | return ret; | ||
| 400 | } | ||
| 401 | |||
| 197 | static int soc_compr_set_params(struct snd_compr_stream *cstream, | 402 | static int soc_compr_set_params(struct snd_compr_stream *cstream, |
| 198 | struct snd_compr_params *params) | 403 | struct snd_compr_params *params) |
| 199 | { | 404 | { |
| @@ -241,6 +446,64 @@ err: | |||
| 241 | return ret; | 446 | return ret; |
| 242 | } | 447 | } |
| 243 | 448 | ||
| 449 | static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, | ||
| 450 | struct snd_compr_params *params) | ||
| 451 | { | ||
| 452 | struct snd_soc_pcm_runtime *fe = cstream->private_data; | ||
| 453 | struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream; | ||
| 454 | struct snd_soc_platform *platform = fe->platform; | ||
| 455 | int ret = 0, stream; | ||
| 456 | |||
| 457 | if (cstream->direction == SND_COMPRESS_PLAYBACK) | ||
| 458 | stream = SNDRV_PCM_STREAM_PLAYBACK; | ||
| 459 | else | ||
| 460 | stream = SNDRV_PCM_STREAM_CAPTURE; | ||
| 461 | |||
| 462 | mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); | ||
| 463 | |||
| 464 | if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) { | ||
| 465 | ret = platform->driver->compr_ops->set_params(cstream, params); | ||
| 466 | if (ret < 0) | ||
| 467 | goto out; | ||
| 468 | } | ||
| 469 | |||
| 470 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->set_params) { | ||
| 471 | ret = fe->dai_link->compr_ops->set_params(cstream); | ||
| 472 | if (ret < 0) | ||
| 473 | goto out; | ||
| 474 | } | ||
| 475 | |||
| 476 | /* | ||
| 477 | * Create an empty hw_params for the BE as the machine driver must | ||
| 478 | * fix this up to match DSP decoder and ASRC configuration. | ||
| 479 | * I.e. machine driver fixup for compressed BE is mandatory. | ||
| 480 | */ | ||
| 481 | memset(&fe->dpcm[fe_substream->stream].hw_params, 0, | ||
| 482 | sizeof(struct snd_pcm_hw_params)); | ||
| 483 | |||
| 484 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; | ||
| 485 | |||
| 486 | ret = dpcm_be_dai_hw_params(fe, stream); | ||
| 487 | if (ret < 0) | ||
| 488 | goto out; | ||
| 489 | |||
| 490 | ret = dpcm_be_dai_prepare(fe, stream); | ||
| 491 | if (ret < 0) | ||
| 492 | goto out; | ||
| 493 | |||
| 494 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 495 | dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START); | ||
| 496 | else | ||
| 497 | dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START); | ||
| 498 | |||
| 499 | fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; | ||
| 500 | |||
| 501 | out: | ||
| 502 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; | ||
| 503 | mutex_unlock(&fe->card->mutex); | ||
| 504 | return ret; | ||
| 505 | } | ||
| 506 | |||
| 244 | static int soc_compr_get_params(struct snd_compr_stream *cstream, | 507 | static int soc_compr_get_params(struct snd_compr_stream *cstream, |
| 245 | struct snd_codec *params) | 508 | struct snd_codec *params) |
| 246 | { | 509 | { |
| @@ -360,6 +623,7 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, | |||
| 360 | 623 | ||
| 361 | return ret; | 624 | return ret; |
| 362 | } | 625 | } |
| 626 | |||
| 363 | /* ASoC Compress operations */ | 627 | /* ASoC Compress operations */ |
| 364 | static struct snd_compr_ops soc_compr_ops = { | 628 | static struct snd_compr_ops soc_compr_ops = { |
| 365 | .open = soc_compr_open, | 629 | .open = soc_compr_open, |
| @@ -375,6 +639,21 @@ static struct snd_compr_ops soc_compr_ops = { | |||
| 375 | .get_codec_caps = soc_compr_get_codec_caps | 639 | .get_codec_caps = soc_compr_get_codec_caps |
| 376 | }; | 640 | }; |
| 377 | 641 | ||
| 642 | /* ASoC Dynamic Compress operations */ | ||
| 643 | static struct snd_compr_ops soc_compr_dyn_ops = { | ||
| 644 | .open = soc_compr_open_fe, | ||
| 645 | .free = soc_compr_free_fe, | ||
| 646 | .set_params = soc_compr_set_params_fe, | ||
| 647 | .get_params = soc_compr_get_params, | ||
| 648 | .set_metadata = soc_compr_set_metadata, | ||
| 649 | .get_metadata = soc_compr_get_metadata, | ||
| 650 | .trigger = soc_compr_trigger_fe, | ||
| 651 | .pointer = soc_compr_pointer, | ||
| 652 | .ack = soc_compr_ack, | ||
| 653 | .get_caps = soc_compr_get_caps, | ||
| 654 | .get_codec_caps = soc_compr_get_codec_caps | ||
| 655 | }; | ||
| 656 | |||
| 378 | /* create a new compress */ | 657 | /* create a new compress */ |
| 379 | int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | 658 | int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) |
| 380 | { | 659 | { |
| @@ -383,6 +662,7 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | |||
| 383 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 662 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 384 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 663 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 385 | struct snd_compr *compr; | 664 | struct snd_compr *compr; |
| 665 | struct snd_pcm *be_pcm; | ||
| 386 | char new_name[64]; | 666 | char new_name[64]; |
| 387 | int ret = 0, direction = 0; | 667 | int ret = 0, direction = 0; |
| 388 | 668 | ||
| @@ -410,7 +690,26 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | |||
| 410 | ret = -ENOMEM; | 690 | ret = -ENOMEM; |
| 411 | goto compr_err; | 691 | goto compr_err; |
| 412 | } | 692 | } |
| 413 | memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); | 693 | |
| 694 | if (rtd->dai_link->dynamic) { | ||
| 695 | snprintf(new_name, sizeof(new_name), "(%s)", | ||
| 696 | rtd->dai_link->stream_name); | ||
| 697 | |||
| 698 | ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, | ||
| 699 | 1, 0, &be_pcm); | ||
| 700 | if (ret < 0) { | ||
| 701 | dev_err(rtd->card->dev, "ASoC: can't create compressed for %s\n", | ||
| 702 | rtd->dai_link->name); | ||
| 703 | goto compr_err; | ||
| 704 | } | ||
| 705 | |||
| 706 | rtd->pcm = be_pcm; | ||
| 707 | rtd->fe_compr = 1; | ||
| 708 | be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; | ||
| 709 | be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; | ||
| 710 | memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops)); | ||
| 711 | } else | ||
| 712 | memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); | ||
| 414 | 713 | ||
| 415 | /* Add copy callback for not memory mapped DSPs */ | 714 | /* Add copy callback for not memory mapped DSPs */ |
| 416 | if (platform->driver->compr_ops && platform->driver->compr_ops->copy) | 715 | if (platform->driver->compr_ops && platform->driver->compr_ops->copy) |
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 5932971cf54d..47e1ce771e65 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
| @@ -58,7 +58,7 @@ int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, | |||
| 58 | EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams); | 58 | EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams); |
| 59 | 59 | ||
| 60 | /* DPCM stream event, send event to FE and all active BEs. */ | 60 | /* DPCM stream event, send event to FE and all active BEs. */ |
| 61 | static int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, | 61 | int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, |
| 62 | int event) | 62 | int event) |
| 63 | { | 63 | { |
| 64 | struct snd_soc_dpcm *dpcm; | 64 | struct snd_soc_dpcm *dpcm; |
| @@ -885,7 +885,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, | |||
| 885 | } | 885 | } |
| 886 | 886 | ||
| 887 | /* disconnect a BE and FE */ | 887 | /* disconnect a BE and FE */ |
| 888 | static void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) | 888 | void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) |
| 889 | { | 889 | { |
| 890 | struct snd_soc_dpcm *dpcm, *d; | 890 | struct snd_soc_dpcm *dpcm, *d; |
| 891 | 891 | ||
| @@ -981,7 +981,7 @@ static int widget_in_list(struct snd_soc_dapm_widget_list *list, | |||
| 981 | return 0; | 981 | return 0; |
| 982 | } | 982 | } |
| 983 | 983 | ||
| 984 | static int dpcm_path_get(struct snd_soc_pcm_runtime *fe, | 984 | int dpcm_path_get(struct snd_soc_pcm_runtime *fe, |
| 985 | int stream, struct snd_soc_dapm_widget_list **list_) | 985 | int stream, struct snd_soc_dapm_widget_list **list_) |
| 986 | { | 986 | { |
| 987 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; | 987 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; |
| @@ -1003,11 +1003,6 @@ static int dpcm_path_get(struct snd_soc_pcm_runtime *fe, | |||
| 1003 | return paths; | 1003 | return paths; |
| 1004 | } | 1004 | } |
| 1005 | 1005 | ||
| 1006 | static inline void dpcm_path_put(struct snd_soc_dapm_widget_list **list) | ||
| 1007 | { | ||
| 1008 | kfree(*list); | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, | 1006 | static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, |
| 1012 | struct snd_soc_dapm_widget_list **list_) | 1007 | struct snd_soc_dapm_widget_list **list_) |
| 1013 | { | 1008 | { |
| @@ -1077,7 +1072,7 @@ static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, | |||
| 1077 | continue; | 1072 | continue; |
| 1078 | 1073 | ||
| 1079 | /* don't connect if FE is not running */ | 1074 | /* don't connect if FE is not running */ |
| 1080 | if (!fe->dpcm[stream].runtime) | 1075 | if (!fe->dpcm[stream].runtime && !fe->fe_compr) |
| 1081 | continue; | 1076 | continue; |
| 1082 | 1077 | ||
| 1083 | /* newly connected FE and BE */ | 1078 | /* newly connected FE and BE */ |
| @@ -1102,7 +1097,7 @@ static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, | |||
| 1102 | * Find the corresponding BE DAIs that source or sink audio to this | 1097 | * Find the corresponding BE DAIs that source or sink audio to this |
| 1103 | * FE substream. | 1098 | * FE substream. |
| 1104 | */ | 1099 | */ |
| 1105 | static int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, | 1100 | int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, |
| 1106 | int stream, struct snd_soc_dapm_widget_list **list, int new) | 1101 | int stream, struct snd_soc_dapm_widget_list **list, int new) |
| 1107 | { | 1102 | { |
| 1108 | if (new) | 1103 | if (new) |
| @@ -1111,7 +1106,7 @@ static int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, | |||
| 1111 | return dpcm_prune_paths(fe, stream, list); | 1106 | return dpcm_prune_paths(fe, stream, list); |
| 1112 | } | 1107 | } |
| 1113 | 1108 | ||
| 1114 | static void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) | 1109 | void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) |
| 1115 | { | 1110 | { |
| 1116 | struct snd_soc_dpcm *dpcm; | 1111 | struct snd_soc_dpcm *dpcm; |
| 1117 | 1112 | ||
| @@ -1149,7 +1144,7 @@ static void dpcm_be_dai_startup_unwind(struct snd_soc_pcm_runtime *fe, | |||
| 1149 | } | 1144 | } |
| 1150 | } | 1145 | } |
| 1151 | 1146 | ||
| 1152 | static int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) | 1147 | int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) |
| 1153 | { | 1148 | { |
| 1154 | struct snd_soc_dpcm *dpcm; | 1149 | struct snd_soc_dpcm *dpcm; |
| 1155 | int err, count = 0; | 1150 | int err, count = 0; |
| @@ -1301,7 +1296,7 @@ be_err: | |||
| 1301 | return ret; | 1296 | return ret; |
| 1302 | } | 1297 | } |
| 1303 | 1298 | ||
| 1304 | static int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream) | 1299 | int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream) |
| 1305 | { | 1300 | { |
| 1306 | struct snd_soc_dpcm *dpcm; | 1301 | struct snd_soc_dpcm *dpcm; |
| 1307 | 1302 | ||
| @@ -1362,7 +1357,7 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream) | |||
| 1362 | return 0; | 1357 | return 0; |
| 1363 | } | 1358 | } |
| 1364 | 1359 | ||
| 1365 | static int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) | 1360 | int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) |
| 1366 | { | 1361 | { |
| 1367 | struct snd_soc_dpcm *dpcm; | 1362 | struct snd_soc_dpcm *dpcm; |
| 1368 | 1363 | ||
| @@ -1427,7 +1422,7 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream) | |||
| 1427 | return 0; | 1422 | return 0; |
| 1428 | } | 1423 | } |
| 1429 | 1424 | ||
| 1430 | static int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) | 1425 | int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) |
| 1431 | { | 1426 | { |
| 1432 | struct snd_soc_dpcm *dpcm; | 1427 | struct snd_soc_dpcm *dpcm; |
| 1433 | int ret; | 1428 | int ret; |
| @@ -1557,7 +1552,7 @@ static int dpcm_do_trigger(struct snd_soc_dpcm *dpcm, | |||
| 1557 | return ret; | 1552 | return ret; |
| 1558 | } | 1553 | } |
| 1559 | 1554 | ||
| 1560 | static int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, | 1555 | int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, |
| 1561 | int cmd) | 1556 | int cmd) |
| 1562 | { | 1557 | { |
| 1563 | struct snd_soc_dpcm *dpcm; | 1558 | struct snd_soc_dpcm *dpcm; |
| @@ -1725,7 +1720,7 @@ out: | |||
| 1725 | return ret; | 1720 | return ret; |
| 1726 | } | 1721 | } |
| 1727 | 1722 | ||
| 1728 | static int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) | 1723 | int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) |
| 1729 | { | 1724 | { |
| 1730 | struct snd_soc_dpcm *dpcm; | 1725 | struct snd_soc_dpcm *dpcm; |
| 1731 | int ret = 0; | 1726 | int ret = 0; |
