Lines Matching full:fe
51 /* is the current PCM operation for this FE ? */
53 static int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream)
55 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE)
62 static int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_be_can_update() argument
65 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
66 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
72 static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_check_state() argument
85 if (dpcm->fe == fe) in snd_soc_dpcm_check_state()
88 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
102 * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE
105 static int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_free_stop() argument
114 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_free_stop()
118 * We can only change hw params a BE DAI if any of it's FE are not prepared,
121 static int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_params() argument
131 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_params()
135 * We can only prepare a BE DAI if any of it's FE are not prepared,
138 static int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_prepared() argument
147 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_prepared()
190 static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, in dpcm_show_state() argument
193 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
197 /* FE state */ in dpcm_show_state()
199 "[%s - %s]\n", fe->dai_link->name, in dpcm_show_state()
203 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
205 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
206 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
217 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
223 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_show_state()
250 struct snd_soc_pcm_runtime *fe = file->private_data; in dpcm_state_read_file() local
255 if (fe->dai_link->num_cpus > 1) { in dpcm_state_read_file()
256 dev_err(fe->dev, in dpcm_state_read_file()
265 snd_soc_dpcm_mutex_lock(fe); in dpcm_state_read_file()
267 if (snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream)) in dpcm_state_read_file()
268 offset += dpcm_show_state(fe, stream, in dpcm_state_read_file()
271 snd_soc_dpcm_mutex_unlock(fe); in dpcm_state_read_file()
308 name, dpcm->fe->debugfs_dpcm_root); in dpcm_create_debugfs_state()
331 /* Set FE's runtime_update state; the state is protected via PCM stream lock
337 static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe, in dpcm_set_fe_update_state() argument
341 snd_soc_dpcm_get_substream(fe, stream); in dpcm_set_fe_update_state()
344 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
346 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
347 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
349 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
418 /* DPCM stream event, send event to FE and all active BEs. */
419 int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, in dpcm_dapm_stream_event() argument
424 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_dapm_stream_event()
426 for_each_dpcm_be(fe, dir, dpcm) { in dpcm_dapm_stream_event()
440 snd_soc_dapm_stream_event(fe, dir, event); in dpcm_dapm_stream_event()
1317 /* connect a FE and BE */
1318 static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, in dpcm_be_connect() argument
1325 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_connect()
1328 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_connect()
1329 if (dpcm->be == be && dpcm->fe == fe) in dpcm_be_connect()
1333 fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_connect()
1337 dev_err(be->dev, "%s: FE is atomic but BE is nonatomic, invalid configuration\n", in dpcm_be_connect()
1342 dev_dbg(be->dev, "FE is nonatomic but BE is not, forcing BE as nonatomic\n"); in dpcm_be_connect()
1351 dpcm->fe = fe; in dpcm_be_connect()
1354 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1358 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", in dpcm_be_connect()
1359 snd_pcm_direction_name(stream), fe->dai_link->name, in dpcm_be_connect()
1367 /* reparent a BE onto another FE */
1368 static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, in dpcm_be_reparent() argument
1383 if (dpcm->fe == fe) in dpcm_be_reparent()
1386 dev_dbg(fe->dev, "reparent %s path %s %s %s\n", in dpcm_be_reparent()
1388 dpcm->fe->dai_link->name, in dpcm_be_reparent()
1391 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1397 /* disconnect a BE and FE */
1398 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
1401 struct snd_pcm_substream *substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_disconnect()
1404 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_disconnect()
1407 for_each_dpcm_be_safe(fe, stream, dpcm, d) { in dpcm_be_disconnect()
1408 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", in dpcm_be_disconnect()
1415 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", in dpcm_be_disconnect()
1416 snd_pcm_direction_name(stream), fe->dai_link->name, in dpcm_be_disconnect()
1419 /* BEs still alive need new FE */ in dpcm_be_disconnect()
1420 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1504 int dpcm_path_get(struct snd_soc_pcm_runtime *fe, in dpcm_path_get() argument
1507 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0); in dpcm_path_get()
1510 if (fe->dai_link->num_cpus > 1) { in dpcm_path_get()
1511 dev_err(fe->dev, in dpcm_path_get()
1518 fe->card->component_chaining ? in dpcm_path_get()
1522 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, in dpcm_path_get()
1525 dev_dbg(fe->dev, "ASoC: %s no valid %s path\n", fe->dai_link->name, in dpcm_path_get()
1557 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1563 /* Destroy any old FE <--> BE connections */ in dpcm_prune_paths()
1564 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1568 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", in dpcm_prune_paths()
1570 dpcm->be->dai_link->name, fe->dai_link->name); in dpcm_prune_paths()
1576 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune); in dpcm_prune_paths()
1580 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1583 struct snd_soc_card *card = fe->card; in dpcm_add_paths()
1587 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_add_paths()
1590 /* don't connect if FE is not running */ in dpcm_add_paths()
1591 if (!fe_substream->runtime && !fe->fe_compr) in dpcm_add_paths()
1594 /* Create any new FE <--> BE connections */ in dpcm_add_paths()
1613 dev_dbg(fe->dev, "ASoC: no BE found for %s\n", in dpcm_add_paths()
1623 if (fe->card->component_chaining && in dpcm_add_paths()
1628 /* newly connected FE and BE */ in dpcm_add_paths()
1629 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1631 dev_err(fe->dev, "ASoC: can't connect %s\n", in dpcm_add_paths()
1642 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new); in dpcm_add_paths()
1648 * FE substream.
1650 int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, in dpcm_process_paths() argument
1654 return dpcm_add_paths(fe, stream, list); in dpcm_process_paths()
1656 return dpcm_prune_paths(fe, stream, list); in dpcm_process_paths()
1659 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_clear_pending_state() argument
1663 for_each_dpcm_be(fe, stream, dpcm) in dpcm_clear_pending_state()
1667 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_stop() argument
1673 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_stop()
1682 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_stop()
1711 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_startup() argument
1713 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_dai_startup()
1718 /* only startup BE DAIs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_startup()
1719 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1732 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1773 dpcm_be_dai_startup_rollback(fe, stream, dpcm); in dpcm_be_dai_startup()
1775 return soc_pcm_ret(fe, err); in dpcm_be_dai_startup()
1780 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_fe() local
1793 for_each_rtd_cpu_dais(fe, i, dai) { in dpcm_runtime_setup_fe()
1815 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_format() local
1822 if (!fe->dai_link->dpcm_merged_format) in dpcm_runtime_setup_be_format()
1827 * if FE want to use it (= dpcm_merged_format) in dpcm_runtime_setup_be_format()
1830 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_format()
1853 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_chan() local
1859 if (!fe->dai_link->dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1864 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1867 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_chan()
1901 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_rate() local
1907 if (!fe->dai_link->dpcm_merged_rate) in dpcm_runtime_setup_be_rate()
1912 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_rate()
1915 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_rate()
1940 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_apply_symmetry() local
1945 /* apply symmetry for FE */ in dpcm_apply_symmetry()
1948 for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) { in dpcm_apply_symmetry()
1956 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1981 return soc_pcm_ret(fe, err); in dpcm_apply_symmetry()
1986 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_startup() local
1989 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_startup()
1991 ret = dpcm_be_dai_startup(fe, stream); in dpcm_fe_dai_startup()
1995 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); in dpcm_fe_dai_startup()
1998 ret = __soc_pcm_open(fe, fe_substream); in dpcm_fe_dai_startup()
2002 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
2014 dpcm_be_dai_startup_unwind(fe, stream); in dpcm_fe_dai_startup()
2016 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_startup()
2018 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_startup()
2023 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_shutdown() local
2026 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_shutdown()
2028 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_shutdown()
2031 dpcm_be_dai_shutdown(fe, stream); in dpcm_fe_dai_shutdown()
2033 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); in dpcm_fe_dai_shutdown()
2036 __soc_pcm_close(fe, substream); in dpcm_fe_dai_shutdown()
2039 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in dpcm_fe_dai_shutdown()
2041 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
2042 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_shutdown()
2046 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_free() argument
2052 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_free()
2059 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_free()
2063 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_free()
2066 /* do not free hw if this BE is used by other FE */ in dpcm_be_dai_hw_free()
2089 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_hw_free() local
2092 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_free()
2093 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_free()
2095 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); in dpcm_fe_dai_hw_free()
2098 soc_pcm_hw_clean(fe, substream, 0); in dpcm_fe_dai_hw_free()
2102 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_free()
2104 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
2105 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_free()
2107 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_free()
2111 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_params() argument
2118 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2125 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2129 memcpy(&hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2142 if (!snd_soc_dpcm_can_be_params(fe, be, stream)) in dpcm_be_dai_hw_params()
2162 dev_dbg(fe->dev, "ASoC: %s() failed at %s (%d)\n", in dpcm_be_dai_hw_params()
2166 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2170 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2174 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_params()
2192 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_hw_params() local
2195 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_params()
2196 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_params()
2198 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2200 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_fe_dai_hw_params()
2204 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n", in dpcm_fe_dai_hw_params()
2205 fe->dai_link->name, params_rate(params), in dpcm_fe_dai_hw_params()
2209 ret = __soc_pcm_hw_params(fe, substream, params); in dpcm_fe_dai_hw_params()
2211 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_params()
2213 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2216 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_params()
2217 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_params()
2219 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_hw_params()
2222 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_trigger() argument
2231 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_trigger()
2240 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_trigger()
2293 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2320 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2322 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2335 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2367 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2388 return soc_pcm_ret(fe, ret); in dpcm_be_dai_trigger()
2395 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_dai_trigger_fe_be() local
2400 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2401 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2407 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2412 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2416 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2417 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2426 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_do_trigger() local
2429 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2431 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2471 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd, in dpcm_fe_dai_do_trigger()
2472 fe->dai_link->name); in dpcm_fe_dai_do_trigger()
2478 dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n", in dpcm_fe_dai_do_trigger()
2487 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2491 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2494 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2499 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2505 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_trigger() local
2508 /* if FE's runtime_update is already set, we're in race; in dpcm_fe_dai_trigger()
2511 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2512 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2520 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_prepare() argument
2525 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_prepare()
2532 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_prepare()
2535 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream)) in dpcm_be_dai_prepare()
2565 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_prepare() local
2568 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_prepare()
2570 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); in dpcm_fe_dai_prepare()
2572 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2574 /* there is no point preparing this FE if there are no BEs */ in dpcm_fe_dai_prepare()
2575 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2577 …dev_err_once(fe->dev, "ASoC: no backend DAIs enabled for %s, possibly missing ALSA mixer-based rou… in dpcm_fe_dai_prepare()
2578 fe->dai_link->name); in dpcm_fe_dai_prepare()
2579 dev_dbg(fe->dev, "ASoC: no backend DAIs enabled for %s\n", in dpcm_fe_dai_prepare()
2580 fe->dai_link->name); in dpcm_fe_dai_prepare()
2585 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_fe_dai_prepare()
2590 ret = __soc_pcm_prepare(fe, substream); in dpcm_fe_dai_prepare()
2594 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2597 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_prepare()
2598 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_prepare()
2609 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_shutdown() argument
2613 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n", in dpcm_run_update_shutdown()
2614 snd_pcm_direction_name(stream), fe->dai_link->name); in dpcm_run_update_shutdown()
2616 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); in dpcm_run_update_shutdown()
2618 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_shutdown()
2620 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_shutdown()
2623 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_shutdown()
2625 return soc_pcm_ret(fe, err); in dpcm_run_update_shutdown()
2628 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_startup() argument
2633 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", in dpcm_run_update_startup()
2634 snd_pcm_direction_name(stream), fe->dai_link->name); in dpcm_run_update_startup()
2636 /* Only start the BE if the FE is ready */ in dpcm_run_update_startup()
2637 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2638 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) { in dpcm_run_update_startup()
2639 dev_err(fe->dev, "ASoC: FE %s is not ready %d\n", in dpcm_run_update_startup()
2640 fe->dai_link->name, fe->dpcm[stream].state); in dpcm_run_update_startup()
2646 ret = dpcm_be_dai_startup(fe, stream); in dpcm_run_update_startup()
2650 /* keep going if FE state is > open */ in dpcm_run_update_startup()
2651 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2654 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_run_update_startup()
2658 /* keep going if FE state is > hw_params */ in dpcm_run_update_startup()
2659 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2662 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_run_update_startup()
2667 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_startup()
2669 /* keep going if FE state is > prepare */ in dpcm_run_update_startup()
2670 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2671 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2674 ret = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_START); in dpcm_run_update_startup()
2681 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_startup()
2683 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_startup()
2686 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_run_update_startup()
2690 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_run_update_startup()
2698 return soc_pcm_ret(fe, ret); in dpcm_run_update_startup()
2701 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new) in soc_dpcm_fe_runtime_update() argument
2707 if (!fe->dai_link->dynamic) in soc_dpcm_fe_runtime_update()
2710 if (fe->dai_link->num_cpus > 1) { in soc_dpcm_fe_runtime_update()
2711 dev_err(fe->dev, in soc_dpcm_fe_runtime_update()
2717 if (!snd_soc_dai_active(snd_soc_rtd_to_cpu(fe, 0))) in soc_dpcm_fe_runtime_update()
2721 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n", in soc_dpcm_fe_runtime_update()
2722 new ? "new" : "old", fe->dai_link->name); in soc_dpcm_fe_runtime_update()
2726 /* skip if FE doesn't have playback/capture capability */ in soc_dpcm_fe_runtime_update()
2727 if (!snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2728 !snd_soc_dai_stream_valid(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2731 /* skip if FE isn't currently playing/capturing */ in soc_dpcm_fe_runtime_update()
2732 if (!snd_soc_dai_stream_active(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2733 !snd_soc_dai_stream_active(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2736 paths = dpcm_path_get(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2741 count = dpcm_process_paths(fe, stream, &list, new); in soc_dpcm_fe_runtime_update()
2743 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE); in soc_dpcm_fe_runtime_update()
2745 dpcm_run_update_startup(fe, stream); in soc_dpcm_fe_runtime_update()
2747 dpcm_run_update_shutdown(fe, stream); in soc_dpcm_fe_runtime_update()
2748 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in soc_dpcm_fe_runtime_update()
2750 dpcm_clear_pending_state(fe, stream); in soc_dpcm_fe_runtime_update()
2751 dpcm_be_disconnect(fe, stream); in soc_dpcm_fe_runtime_update()
2765 struct snd_soc_pcm_runtime *fe; in snd_soc_dpcm_runtime_update() local
2770 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2771 ret = soc_dpcm_fe_runtime_update(fe, 0); in snd_soc_dpcm_runtime_update()
2777 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2778 ret = soc_dpcm_fe_runtime_update(fe, 1); in snd_soc_dpcm_runtime_update()
2791 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_cleanup() local
2795 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_cleanup()
2797 /* mark FE's links ready to prune */ in dpcm_fe_dai_cleanup()
2798 for_each_dpcm_be(fe, stream, dpcm) in dpcm_fe_dai_cleanup()
2801 dpcm_be_disconnect(fe, stream); in dpcm_fe_dai_cleanup()
2806 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_close() local
2809 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_close()
2814 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_close()
2820 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_open() local
2825 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_open()
2827 ret = dpcm_path_get(fe, stream, &list); in dpcm_fe_dai_open()
2831 /* calculate valid and active FE <-> BE dpcms */ in dpcm_fe_dai_open()
2832 dpcm_process_paths(fe, stream, &list, 1); in dpcm_fe_dai_open()
2838 dpcm_clear_pending_state(fe, stream); in dpcm_fe_dai_open()
2841 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_open()