Lines Matching full:fe

109 static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,  in dpcm_show_state()  argument
112 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
116 /* FE state */ in dpcm_show_state()
118 "[%s - %s]\n", fe->dai_link->name, in dpcm_show_state()
122 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
124 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
125 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
136 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
142 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_show_state()
169 struct snd_soc_pcm_runtime *fe = file->private_data; in dpcm_state_read_file() local
174 if (fe->dai_link->num_cpus > 1) { in dpcm_state_read_file()
175 dev_err(fe->dev, in dpcm_state_read_file()
184 snd_soc_dpcm_mutex_lock(fe); in dpcm_state_read_file()
186 if (snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream)) in dpcm_state_read_file()
187 offset += dpcm_show_state(fe, stream, in dpcm_state_read_file()
190 snd_soc_dpcm_mutex_unlock(fe); in dpcm_state_read_file()
227 name, dpcm->fe->debugfs_dpcm_root); in dpcm_create_debugfs_state()
250 /* Set FE's runtime_update state; the state is protected via PCM stream lock
256 static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe, in dpcm_set_fe_update_state() argument
260 snd_soc_dpcm_get_substream(fe, stream); in dpcm_set_fe_update_state()
262 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_set_fe_update_state()
263 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
265 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
266 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
268 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
269 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_set_fe_update_state()
344 /* DPCM stream event, send event to FE and all active BEs. */
345 int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, in dpcm_dapm_stream_event() argument
350 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_dapm_stream_event()
352 for_each_dpcm_be(fe, dir, dpcm) { in dpcm_dapm_stream_event()
366 snd_soc_dapm_stream_event(fe, dir, event); in dpcm_dapm_stream_event()
1234 /* connect a FE and BE */
1235 static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, in dpcm_be_connect() argument
1242 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_connect()
1245 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_connect()
1246 if (dpcm->be == be && dpcm->fe == fe) in dpcm_be_connect()
1250 fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_connect()
1254 dev_err(be->dev, "%s: FE is atomic but BE is nonatomic, invalid configuration\n", in dpcm_be_connect()
1259 dev_dbg(be->dev, "FE is nonatomic but BE is not, forcing BE as nonatomic\n"); in dpcm_be_connect()
1268 dpcm->fe = fe; in dpcm_be_connect()
1270 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_be_connect()
1271 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1273 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_be_connect()
1275 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", in dpcm_be_connect()
1276 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_connect()
1284 /* reparent a BE onto another FE */
1285 static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, in dpcm_be_reparent() argument
1300 if (dpcm->fe == fe) in dpcm_be_reparent()
1303 dev_dbg(fe->dev, "reparent %s path %s %s %s\n", in dpcm_be_reparent()
1305 dpcm->fe->dai_link->name, in dpcm_be_reparent()
1308 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1314 /* disconnect a BE and FE */
1315 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
1320 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_disconnect()
1322 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_be_disconnect()
1323 for_each_dpcm_be_safe(fe, stream, dpcm, d) { in dpcm_be_disconnect()
1324 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", in dpcm_be_disconnect()
1331 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", in dpcm_be_disconnect()
1332 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_disconnect()
1335 /* BEs still alive need new FE */ in dpcm_be_disconnect()
1336 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1341 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_be_disconnect()
1420 int dpcm_path_get(struct snd_soc_pcm_runtime *fe, in dpcm_path_get() argument
1423 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0); in dpcm_path_get()
1426 if (fe->dai_link->num_cpus > 1) { in dpcm_path_get()
1427 dev_err(fe->dev, in dpcm_path_get()
1434 fe->card->component_chaining ? in dpcm_path_get()
1438 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, in dpcm_path_get()
1441 dev_dbg(fe->dev, "ASoC: %s no valid %s path\n", fe->dai_link->name, in dpcm_path_get()
1473 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1479 /* Destroy any old FE <--> BE connections */ in dpcm_prune_paths()
1480 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1484 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", in dpcm_prune_paths()
1486 dpcm->be->dai_link->name, fe->dai_link->name); in dpcm_prune_paths()
1492 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune); in dpcm_prune_paths()
1496 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1499 struct snd_soc_card *card = fe->card; in dpcm_add_paths()
1503 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_add_paths()
1506 /* don't connect if FE is not running */ in dpcm_add_paths()
1507 if (!fe_substream->runtime && !fe->fe_compr) in dpcm_add_paths()
1510 /* Create any new FE <--> BE connections */ in dpcm_add_paths()
1529 dev_dbg(fe->dev, "ASoC: no BE found for %s\n", in dpcm_add_paths()
1539 if (fe->card->component_chaining && in dpcm_add_paths()
1544 /* newly connected FE and BE */ in dpcm_add_paths()
1545 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1547 dev_err(fe->dev, "ASoC: can't connect %s\n", in dpcm_add_paths()
1558 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new); in dpcm_add_paths()
1564 * FE substream.
1566 int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, in dpcm_process_paths() argument
1570 return dpcm_add_paths(fe, stream, list); in dpcm_process_paths()
1572 return dpcm_prune_paths(fe, stream, list); in dpcm_process_paths()
1575 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_clear_pending_state() argument
1579 for_each_dpcm_be(fe, stream, dpcm) in dpcm_clear_pending_state()
1583 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_stop() argument
1589 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_stop()
1598 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_stop()
1627 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_startup() argument
1629 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_dai_startup()
1634 /* only startup BE DAIs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_startup()
1635 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1648 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1689 dpcm_be_dai_startup_rollback(fe, stream, dpcm); in dpcm_be_dai_startup()
1691 return soc_pcm_ret(fe, err); in dpcm_be_dai_startup()
1696 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_setup_fe() local
1709 for_each_rtd_cpu_dais(fe, i, dai) { in dpcm_runtime_setup_fe()
1730 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_setup_be_format() local
1737 if (!fe->dai_link->dpcm_merged_format) in dpcm_runtime_setup_be_format()
1742 * if FE want to use it (= dpcm_merged_format) in dpcm_runtime_setup_be_format()
1745 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_format()
1767 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_setup_be_chan() local
1773 if (!fe->dai_link->dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1778 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1781 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_chan()
1815 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_setup_be_rate() local
1821 if (!fe->dai_link->dpcm_merged_rate) in dpcm_runtime_setup_be_rate()
1826 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_rate()
1829 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_rate()
1854 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_apply_symmetry() local
1859 /* apply symmetry for FE */ in dpcm_apply_symmetry()
1862 for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) { in dpcm_apply_symmetry()
1870 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1895 return soc_pcm_ret(fe, err); in dpcm_apply_symmetry()
1900 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_startup() local
1903 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_startup()
1905 ret = dpcm_be_dai_startup(fe, stream); in dpcm_fe_dai_startup()
1909 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); in dpcm_fe_dai_startup()
1912 ret = __soc_pcm_open(fe, fe_substream); in dpcm_fe_dai_startup()
1916 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
1928 dpcm_be_dai_startup_unwind(fe, stream); in dpcm_fe_dai_startup()
1930 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_startup()
1932 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_startup()
1937 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_shutdown() local
1940 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_shutdown()
1942 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_shutdown()
1945 dpcm_be_dai_shutdown(fe, stream); in dpcm_fe_dai_shutdown()
1947 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); in dpcm_fe_dai_shutdown()
1950 __soc_pcm_close(fe, substream); in dpcm_fe_dai_shutdown()
1953 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in dpcm_fe_dai_shutdown()
1955 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
1956 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_shutdown()
1960 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_free() argument
1966 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_free()
1973 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_free()
1977 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_free()
1980 /* do not free hw if this BE is used by other FE */ in dpcm_be_dai_hw_free()
2003 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_hw_free() local
2006 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_free()
2007 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_free()
2009 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); in dpcm_fe_dai_hw_free()
2012 soc_pcm_hw_clean(fe, substream, 0); in dpcm_fe_dai_hw_free()
2016 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_free()
2018 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
2019 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_free()
2021 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_free()
2025 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_params() argument
2032 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2039 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2043 memcpy(&hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2056 if (!snd_soc_dpcm_can_be_params(fe, be, stream)) in dpcm_be_dai_hw_params()
2076 dev_dbg(fe->dev, "ASoC: %s() failed at %s (%d)\n", in dpcm_be_dai_hw_params()
2080 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2084 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2088 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_params()
2106 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_hw_params() local
2109 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_params()
2110 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_params()
2112 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2114 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_fe_dai_hw_params()
2118 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n", in dpcm_fe_dai_hw_params()
2119 fe->dai_link->name, params_rate(params), in dpcm_fe_dai_hw_params()
2123 ret = __soc_pcm_hw_params(fe, substream, params); in dpcm_fe_dai_hw_params()
2125 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_params()
2127 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2130 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_params()
2131 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_params()
2133 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_hw_params()
2136 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_trigger() argument
2145 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_trigger()
2154 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_trigger()
2207 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2234 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2236 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2249 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2281 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2302 return soc_pcm_ret(fe, ret); in dpcm_be_dai_trigger()
2309 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_dai_trigger_fe_be() local
2314 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2315 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2321 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2326 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2330 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2331 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2340 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_do_trigger() local
2343 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2345 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2385 /* bespoke trigger() - handles both FE and BEs */ in dpcm_fe_dai_do_trigger()
2387 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd %d\n", in dpcm_fe_dai_do_trigger()
2388 fe->dai_link->name, cmd); in dpcm_fe_dai_do_trigger()
2393 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd, in dpcm_fe_dai_do_trigger()
2394 fe->dai_link->name); in dpcm_fe_dai_do_trigger()
2400 dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n", in dpcm_fe_dai_do_trigger()
2409 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2413 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2416 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2421 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2427 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_trigger() local
2430 /* if FE's runtime_update is already set, we're in race; in dpcm_fe_dai_trigger()
2433 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2434 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2442 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_prepare() argument
2447 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_prepare()
2454 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_prepare()
2457 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream)) in dpcm_be_dai_prepare()
2487 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_prepare() local
2490 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_prepare()
2492 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); in dpcm_fe_dai_prepare()
2494 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2496 /* there is no point preparing this FE if there are no BEs */ in dpcm_fe_dai_prepare()
2497 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2499 …dev_err_once(fe->dev, "ASoC: no backend DAIs enabled for %s, possibly missing ALSA mixer-based rou… in dpcm_fe_dai_prepare()
2500 fe->dai_link->name); in dpcm_fe_dai_prepare()
2501 dev_dbg(fe->dev, "ASoC: no backend DAIs enabled for %s\n", in dpcm_fe_dai_prepare()
2502 fe->dai_link->name); in dpcm_fe_dai_prepare()
2507 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_fe_dai_prepare()
2512 ret = __soc_pcm_prepare(fe, substream); in dpcm_fe_dai_prepare()
2516 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2519 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_prepare()
2520 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_prepare()
2531 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_shutdown() argument
2534 snd_soc_dpcm_get_substream(fe, stream); in dpcm_run_update_shutdown()
2535 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_shutdown()
2538 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n", in dpcm_run_update_shutdown()
2539 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_shutdown()
2542 /* call bespoke trigger - FE takes care of all BE triggers */ in dpcm_run_update_shutdown()
2543 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2544 fe->dai_link->name); in dpcm_run_update_shutdown()
2548 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2549 fe->dai_link->name); in dpcm_run_update_shutdown()
2551 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); in dpcm_run_update_shutdown()
2554 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_shutdown()
2556 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_shutdown()
2559 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_shutdown()
2561 return soc_pcm_ret(fe, err); in dpcm_run_update_shutdown()
2564 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_startup() argument
2567 snd_soc_dpcm_get_substream(fe, stream); in dpcm_run_update_startup()
2569 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_startup()
2572 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", in dpcm_run_update_startup()
2573 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_startup()
2575 /* Only start the BE if the FE is ready */ in dpcm_run_update_startup()
2576 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2577 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) { in dpcm_run_update_startup()
2578 dev_err(fe->dev, "ASoC: FE %s is not ready %d\n", in dpcm_run_update_startup()
2579 fe->dai_link->name, fe->dpcm[stream].state); in dpcm_run_update_startup()
2585 ret = dpcm_be_dai_startup(fe, stream); in dpcm_run_update_startup()
2589 /* keep going if FE state is > open */ in dpcm_run_update_startup()
2590 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2593 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_run_update_startup()
2597 /* keep going if FE state is > hw_params */ in dpcm_run_update_startup()
2598 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2601 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_run_update_startup()
2606 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_startup()
2608 /* keep going if FE state is > prepare */ in dpcm_run_update_startup()
2609 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2610 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2614 /* call trigger on the frontend - FE takes care of all BE triggers */ in dpcm_run_update_startup()
2615 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd start\n", in dpcm_run_update_startup()
2616 fe->dai_link->name); in dpcm_run_update_startup()
2622 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd start\n", in dpcm_run_update_startup()
2623 fe->dai_link->name); in dpcm_run_update_startup()
2625 ret = dpcm_be_dai_trigger(fe, stream, in dpcm_run_update_startup()
2634 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_startup()
2636 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_startup()
2639 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_run_update_startup()
2643 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_run_update_startup()
2651 return soc_pcm_ret(fe, ret); in dpcm_run_update_startup()
2654 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new) in soc_dpcm_fe_runtime_update() argument
2660 if (!fe->dai_link->dynamic) in soc_dpcm_fe_runtime_update()
2663 if (fe->dai_link->num_cpus > 1) { in soc_dpcm_fe_runtime_update()
2664 dev_err(fe->dev, in soc_dpcm_fe_runtime_update()
2670 if (!snd_soc_dai_active(asoc_rtd_to_cpu(fe, 0))) in soc_dpcm_fe_runtime_update()
2674 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n", in soc_dpcm_fe_runtime_update()
2675 new ? "new" : "old", fe->dai_link->name); in soc_dpcm_fe_runtime_update()
2679 /* skip if FE doesn't have playback/capture capability */ in soc_dpcm_fe_runtime_update()
2680 if (!snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2681 !snd_soc_dai_stream_valid(asoc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2684 /* skip if FE isn't currently playing/capturing */ in soc_dpcm_fe_runtime_update()
2685 if (!snd_soc_dai_stream_active(asoc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2686 !snd_soc_dai_stream_active(asoc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2689 paths = dpcm_path_get(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2694 count = dpcm_process_paths(fe, stream, &list, new); in soc_dpcm_fe_runtime_update()
2696 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE); in soc_dpcm_fe_runtime_update()
2698 dpcm_run_update_startup(fe, stream); in soc_dpcm_fe_runtime_update()
2700 dpcm_run_update_shutdown(fe, stream); in soc_dpcm_fe_runtime_update()
2701 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in soc_dpcm_fe_runtime_update()
2703 dpcm_clear_pending_state(fe, stream); in soc_dpcm_fe_runtime_update()
2704 dpcm_be_disconnect(fe, stream); in soc_dpcm_fe_runtime_update()
2718 struct snd_soc_pcm_runtime *fe; in snd_soc_dpcm_runtime_update() local
2723 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2724 ret = soc_dpcm_fe_runtime_update(fe, 0); in snd_soc_dpcm_runtime_update()
2730 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2731 ret = soc_dpcm_fe_runtime_update(fe, 1); in snd_soc_dpcm_runtime_update()
2744 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_cleanup() local
2748 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_cleanup()
2750 /* mark FE's links ready to prune */ in dpcm_fe_dai_cleanup()
2751 for_each_dpcm_be(fe, stream, dpcm) in dpcm_fe_dai_cleanup()
2754 dpcm_be_disconnect(fe, stream); in dpcm_fe_dai_cleanup()
2759 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_close() local
2762 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_close()
2767 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_close()
2773 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_open() local
2778 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_open()
2780 ret = dpcm_path_get(fe, stream, &list); in dpcm_fe_dai_open()
2784 /* calculate valid and active FE <-> BE dpcms */ in dpcm_fe_dai_open()
2785 dpcm_process_paths(fe, stream, &list, 1); in dpcm_fe_dai_open()
2791 dpcm_clear_pending_state(fe, stream); in dpcm_fe_dai_open()
2794 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_open()
3039 /* is the current PCM operation for this FE ? */
3040 int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream) in snd_soc_dpcm_fe_can_update() argument
3042 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) in snd_soc_dpcm_fe_can_update()
3049 int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_be_can_update() argument
3052 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
3053 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
3068 static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_check_state() argument
3081 if (dpcm->fe == fe) in snd_soc_dpcm_check_state()
3084 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
3098 * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE
3101 int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_free_stop() argument
3110 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_free_stop()
3115 * We can only change hw params a BE DAI if any of it's FE are not prepared,
3118 int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_params() argument
3128 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_params()
3133 * We can only prepare a BE DAI if any of it's FE are not prepared,
3136 int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_prepared() argument
3145 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_prepared()