Lines Matching refs:fe

110 static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
113 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params;
119 "[%s - %s]\n", fe->dai_link->name,
123 dpcm_state_string(fe->dpcm[stream].state));
125 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) &&
126 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP))
137 if (list_empty(&fe->dpcm[stream].be_clients)) {
143 for_each_dpcm_be(fe, stream, dpcm) {
170 struct snd_soc_pcm_runtime *fe = file->private_data;
175 if (fe->dai_link->num_cpus > 1) {
176 dev_err(fe->dev,
185 snd_soc_dpcm_mutex_lock(fe);
187 if (snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream))
188 offset += dpcm_show_state(fe, stream,
191 snd_soc_dpcm_mutex_unlock(fe);
228 name, dpcm->fe->debugfs_dpcm_root);
257 static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe,
261 snd_soc_dpcm_get_substream(fe, stream);
263 snd_soc_dpcm_stream_lock_irq(fe, stream);
264 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) {
266 fe->dpcm[stream].trigger_pending - 1);
267 fe->dpcm[stream].trigger_pending = 0;
269 fe->dpcm[stream].runtime_update = state;
270 snd_soc_dpcm_stream_unlock_irq(fe, stream);
346 int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
351 snd_soc_dpcm_mutex_assert_held(fe);
353 for_each_dpcm_be(fe, dir, dpcm) {
367 snd_soc_dapm_stream_event(fe, dir, event);
1223 static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
1230 snd_soc_dpcm_mutex_assert_held(fe);
1233 for_each_dpcm_be(fe, stream, dpcm) {
1234 if (dpcm->be == be && dpcm->fe == fe)
1238 fe_substream = snd_soc_dpcm_get_substream(fe, stream);
1256 dpcm->fe = fe;
1258 snd_soc_dpcm_stream_lock_irq(fe, stream);
1259 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients);
1261 snd_soc_dpcm_stream_unlock_irq(fe, stream);
1263 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n",
1264 stream ? "capture" : "playback", fe->dai_link->name,
1273 static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe,
1288 if (dpcm->fe == fe)
1291 dev_dbg(fe->dev, "reparent %s path %s %s %s\n",
1293 dpcm->fe->dai_link->name,
1296 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream);
1303 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
1308 snd_soc_dpcm_mutex_assert_held(fe);
1310 snd_soc_dpcm_stream_lock_irq(fe, stream);
1311 for_each_dpcm_be_safe(fe, stream, dpcm, d) {
1312 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n",
1319 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n",
1320 stream ? "capture" : "playback", fe->dai_link->name,
1324 dpcm_be_reparent(fe, dpcm->be, stream);
1329 snd_soc_dpcm_stream_unlock_irq(fe, stream);
1408 int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
1411 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
1414 if (fe->dai_link->num_cpus > 1) {
1415 dev_err(fe->dev,
1422 fe->card->component_chaining ?
1426 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths,
1429 dev_dbg(fe->dev, "ASoC: %s no valid %s path\n", fe->dai_link->name,
1461 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,
1468 for_each_dpcm_be(fe, stream, dpcm) {
1472 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n",
1474 dpcm->be->dai_link->name, fe->dai_link->name);
1480 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune);
1484 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream,
1487 struct snd_soc_card *card = fe->card;
1491 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream);
1495 if (!fe_substream->runtime && !fe->fe_compr)
1517 dev_dbg(fe->dev, "ASoC: no BE found for %s\n",
1527 if (fe->card->component_chaining &&
1533 err = dpcm_be_connect(fe, be, stream);
1535 dev_err(fe->dev, "ASoC: can't connect %s\n",
1546 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new);
1554 int dpcm_process_paths(struct snd_soc_pcm_runtime *fe,
1558 return dpcm_add_paths(fe, stream, list);
1560 return dpcm_prune_paths(fe, stream, list);
1563 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream)
1567 for_each_dpcm_be(fe, stream, dpcm)
1571 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream,
1577 for_each_dpcm_be(fe, stream, dpcm) {
1586 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
1615 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
1617 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream);
1623 for_each_dpcm_be(fe, stream, dpcm) {
1636 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
1677 dpcm_be_dai_startup_rollback(fe, stream, dpcm);
1679 return soc_pcm_ret(fe, err);
1684 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
1697 for_each_rtd_cpu_dais(fe, i, dai) {
1718 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
1725 if (!fe->dai_link->dpcm_merged_format)
1733 for_each_dpcm_be(fe, stream, dpcm) {
1755 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
1761 if (!fe->dai_link->dpcm_merged_chan)
1769 for_each_dpcm_be(fe, stream, dpcm) {
1803 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
1809 if (!fe->dai_link->dpcm_merged_rate)
1817 for_each_dpcm_be(fe, stream, dpcm) {
1842 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
1850 for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) {
1858 for_each_dpcm_be(fe, stream, dpcm) {
1883 return soc_pcm_ret(fe, err);
1888 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
1891 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
1893 ret = dpcm_be_dai_startup(fe, stream);
1897 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name);
1900 ret = __soc_pcm_open(fe, fe_substream);
1904 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN;
1916 dpcm_be_dai_startup_unwind(fe, stream);
1918 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
1920 return soc_pcm_ret(fe, ret);
1925 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
1928 snd_soc_dpcm_mutex_assert_held(fe);
1930 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
1933 dpcm_be_dai_shutdown(fe, stream);
1935 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name);
1938 __soc_pcm_close(fe, substream);
1941 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP);
1943 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
1944 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
1948 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream)
1954 for_each_dpcm_be(fe, stream, dpcm) {
1961 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
1965 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream))
1991 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
1994 snd_soc_dpcm_mutex_lock(fe);
1995 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
1997 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name);
2000 soc_pcm_hw_clean(fe, substream, 0);
2004 dpcm_be_dai_hw_free(fe, stream);
2006 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE;
2007 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
2009 snd_soc_dpcm_mutex_unlock(fe);
2013 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream)
2020 for_each_dpcm_be(fe, stream, dpcm) {
2027 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
2031 memcpy(&hw_params, &fe->dpcm[stream].hw_params,
2044 if (!snd_soc_dpcm_can_be_params(fe, be, stream))
2064 dev_dbg(fe->dev, "ASoC: %s() failed at %s (%d)\n",
2068 for_each_dpcm_be_rollback(fe, stream, dpcm) {
2072 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
2076 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream))
2094 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
2097 snd_soc_dpcm_mutex_lock(fe);
2098 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
2100 memcpy(&fe->dpcm[stream].hw_params, params,
2102 ret = dpcm_be_dai_hw_params(fe, stream);
2106 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n",
2107 fe->dai_link->name, params_rate(params),
2111 ret = __soc_pcm_hw_params(fe, substream, params);
2113 dpcm_be_dai_hw_free(fe, stream);
2115 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS;
2118 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
2119 snd_soc_dpcm_mutex_unlock(fe);
2121 return soc_pcm_ret(fe, ret);
2124 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
2133 for_each_dpcm_be(fe, stream, dpcm) {
2142 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
2195 fe->dpcm[stream].fe_pause = false;
2222 if (fe->dpcm[stream].fe_pause) {
2224 fe->dpcm[stream].fe_pause = false;
2237 fe->dpcm[stream].fe_pause = true;
2269 fe->dpcm[stream].fe_pause = true;
2290 return soc_pcm_ret(fe, ret);
2297 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
2302 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n",
2303 fe->dai_link->name, cmd);
2309 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd);
2314 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd);
2318 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n",
2319 fe->dai_link->name, cmd);
2328 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
2331 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
2333 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
2375 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd %d\n",
2376 fe->dai_link->name, cmd);
2381 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd,
2382 fe->dai_link->name);
2388 dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n",
2397 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
2401 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
2404 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
2409 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
2415 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
2421 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) {
2422 fe->dpcm[stream].trigger_pending = cmd + 1;
2430 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream)
2435 for_each_dpcm_be(fe, stream, dpcm) {
2442 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
2445 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream))
2464 return soc_pcm_ret(fe, ret);
2469 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream);
2472 snd_soc_dpcm_mutex_lock(fe);
2474 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name);
2476 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
2479 if (list_empty(&fe->dpcm[stream].be_clients)) {
2481 dev_err_once(fe->dev, "ASoC: no backend DAIs enabled for %s, possibly missing ALSA mixer-based routing or UCM profile\n",
2482 fe->dai_link->name);
2483 dev_dbg(fe->dev, "ASoC: no backend DAIs enabled for %s\n",
2484 fe->dai_link->name);
2489 ret = dpcm_be_dai_prepare(fe, stream);
2494 ret = __soc_pcm_prepare(fe, substream);
2498 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
2501 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
2502 snd_soc_dpcm_mutex_unlock(fe);
2504 return soc_pcm_ret(fe, ret);
2507 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream)
2510 snd_soc_dpcm_get_substream(fe, stream);
2511 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
2514 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n",
2515 stream ? "capture" : "playback", fe->dai_link->name);
2519 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd stop\n",
2520 fe->dai_link->name);
2524 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd stop\n",
2525 fe->dai_link->name);
2527 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP);
2530 dpcm_be_dai_hw_free(fe, stream);
2532 dpcm_be_dai_shutdown(fe, stream);
2535 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP);
2537 return soc_pcm_ret(fe, err);
2540 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
2543 snd_soc_dpcm_get_substream(fe, stream);
2545 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
2548 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n",
2549 stream ? "capture" : "playback", fe->dai_link->name);
2552 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE ||
2553 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) {
2554 dev_err(fe->dev, "ASoC: FE %s is not ready %d\n",
2555 fe->dai_link->name, fe->dpcm[stream].state);
2561 ret = dpcm_be_dai_startup(fe, stream);
2566 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN)
2569 ret = dpcm_be_dai_hw_params(fe, stream);
2574 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS)
2577 ret = dpcm_be_dai_prepare(fe, stream);
2582 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP);
2585 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE ||
2586 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP)
2591 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd start\n",
2592 fe->dai_link->name);
2598 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd start\n",
2599 fe->dai_link->name);
2601 ret = dpcm_be_dai_trigger(fe, stream,
2610 dpcm_be_dai_hw_free(fe, stream);
2612 dpcm_be_dai_shutdown(fe, stream);
2615 for_each_dpcm_be(fe, stream, dpcm) {
2619 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
2627 return soc_pcm_ret(fe, ret);
2630 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)
2636 if (!fe->dai_link->dynamic)
2639 if (fe->dai_link->num_cpus > 1) {
2640 dev_err(fe->dev,
2646 if (!snd_soc_dai_active(asoc_rtd_to_cpu(fe, 0)))
2650 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n",
2651 new ? "new" : "old", fe->dai_link->name);
2656 if (!snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream) ||
2657 !snd_soc_dai_stream_valid(asoc_rtd_to_codec(fe, 0), stream))
2661 if (!snd_soc_dai_stream_active(asoc_rtd_to_cpu(fe, 0), stream) ||
2662 !snd_soc_dai_stream_active(asoc_rtd_to_codec(fe, 0), stream))
2665 paths = dpcm_path_get(fe, stream, &list);
2670 count = dpcm_process_paths(fe, stream, &list, new);
2672 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE);
2674 dpcm_run_update_startup(fe, stream);
2676 dpcm_run_update_shutdown(fe, stream);
2677 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
2679 dpcm_clear_pending_state(fe, stream);
2680 dpcm_be_disconnect(fe, stream);
2694 struct snd_soc_pcm_runtime *fe;
2699 for_each_card_rtds(card, fe) {
2700 ret = soc_dpcm_fe_runtime_update(fe, 0);
2706 for_each_card_rtds(card, fe) {
2707 ret = soc_dpcm_fe_runtime_update(fe, 1);
2720 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
2724 snd_soc_dpcm_mutex_assert_held(fe);
2727 for_each_dpcm_be(fe, stream, dpcm)
2730 dpcm_be_disconnect(fe, stream);
2735 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
2738 snd_soc_dpcm_mutex_lock(fe);
2743 snd_soc_dpcm_mutex_unlock(fe);
2749 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream);
2754 snd_soc_dpcm_mutex_lock(fe);
2756 ret = dpcm_path_get(fe, stream, &list);
2761 dpcm_process_paths(fe, stream, &list, 1);
2767 dpcm_clear_pending_state(fe, stream);
2770 snd_soc_dpcm_mutex_unlock(fe);
3016 int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream)
3018 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE)
3025 int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe,
3028 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) ||
3029 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) &&
3044 static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe,
3057 if (dpcm->fe == fe)
3060 state = dpcm->fe->dpcm[stream].state;
3077 int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
3086 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state));
3094 int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
3104 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state));
3112 int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe,
3121 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state));