Lines Matching full:fe
123 static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, in dpcm_show_state() argument
126 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
130 /* FE state */ in dpcm_show_state()
132 "[%s - %s]\n", fe->dai_link->name, in dpcm_show_state()
136 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
138 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
139 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
150 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
156 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_show_state()
183 struct snd_soc_pcm_runtime *fe = file->private_data; in dpcm_state_read_file() local
188 if (fe->dai_link->num_cpus > 1) { in dpcm_state_read_file()
189 dev_err(fe->dev, in dpcm_state_read_file()
198 snd_soc_dpcm_mutex_lock(fe); in dpcm_state_read_file()
200 if (snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream)) in dpcm_state_read_file()
201 offset += dpcm_show_state(fe, stream, in dpcm_state_read_file()
204 snd_soc_dpcm_mutex_unlock(fe); in dpcm_state_read_file()
241 name, dpcm->fe->debugfs_dpcm_root); in dpcm_create_debugfs_state()
264 /* Set FE's runtime_update state; the state is protected via PCM stream lock
270 static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe, in dpcm_set_fe_update_state() argument
274 snd_soc_dpcm_get_substream(fe, stream); in dpcm_set_fe_update_state()
276 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_set_fe_update_state()
277 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
279 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
280 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
282 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
283 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_set_fe_update_state()
358 /* DPCM stream event, send event to FE and all active BEs. */
359 int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, in dpcm_dapm_stream_event() argument
364 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_dapm_stream_event()
366 for_each_dpcm_be(fe, dir, dpcm) { in dpcm_dapm_stream_event()
380 snd_soc_dapm_stream_event(fe, dir, event); in dpcm_dapm_stream_event()
1187 /* connect a FE and BE */
1188 static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, in dpcm_be_connect() argument
1195 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_connect()
1198 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_connect()
1199 if (dpcm->be == be && dpcm->fe == fe) in dpcm_be_connect()
1203 fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_connect()
1207 dev_err(be->dev, "%s: FE is atomic but BE is nonatomic, invalid configuration\n", in dpcm_be_connect()
1212 dev_dbg(be->dev, "FE is nonatomic but BE is not, forcing BE as nonatomic\n"); in dpcm_be_connect()
1221 dpcm->fe = fe; in dpcm_be_connect()
1222 be->dpcm[stream].runtime = fe->dpcm[stream].runtime; in dpcm_be_connect()
1224 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_be_connect()
1225 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1227 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_be_connect()
1229 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", in dpcm_be_connect()
1230 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_connect()
1238 /* reparent a BE onto another FE */
1239 static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, in dpcm_be_reparent() argument
1254 if (dpcm->fe == fe) in dpcm_be_reparent()
1257 dev_dbg(fe->dev, "reparent %s path %s %s %s\n", in dpcm_be_reparent()
1259 dpcm->fe->dai_link->name, in dpcm_be_reparent()
1262 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1268 /* disconnect a BE and FE */
1269 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
1274 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_disconnect()
1276 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_be_disconnect()
1277 for_each_dpcm_be_safe(fe, stream, dpcm, d) { in dpcm_be_disconnect()
1278 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", in dpcm_be_disconnect()
1285 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", in dpcm_be_disconnect()
1286 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_disconnect()
1289 /* BEs still alive need new FE */ in dpcm_be_disconnect()
1290 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1295 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_be_disconnect()
1373 int dpcm_path_get(struct snd_soc_pcm_runtime *fe, in dpcm_path_get() argument
1376 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0); in dpcm_path_get()
1379 if (fe->dai_link->num_cpus > 1) { in dpcm_path_get()
1380 dev_err(fe->dev, in dpcm_path_get()
1387 fe->card->component_chaining ? in dpcm_path_get()
1391 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, in dpcm_path_get()
1394 dev_dbg(fe->dev, "ASoC: %s no valid %s path\n", fe->dai_link->name, in dpcm_path_get()
1426 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1432 /* Destroy any old FE <--> BE connections */ in dpcm_prune_paths()
1433 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1437 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", in dpcm_prune_paths()
1439 dpcm->be->dai_link->name, fe->dai_link->name); in dpcm_prune_paths()
1445 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune); in dpcm_prune_paths()
1449 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1452 struct snd_soc_card *card = fe->card; in dpcm_add_paths()
1458 /* don't connect if FE is not running */ in dpcm_add_paths()
1459 if (!fe->dpcm[stream].runtime && !fe->fe_compr) in dpcm_add_paths()
1462 /* Create any new FE <--> BE connections */ in dpcm_add_paths()
1481 dev_dbg(fe->dev, "ASoC: no BE found for %s\n", in dpcm_add_paths()
1491 if (fe->card->component_chaining && in dpcm_add_paths()
1496 /* newly connected FE and BE */ in dpcm_add_paths()
1497 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1499 dev_err(fe->dev, "ASoC: can't connect %s\n", in dpcm_add_paths()
1510 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new); in dpcm_add_paths()
1516 * FE substream.
1518 int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, in dpcm_process_paths() argument
1522 return dpcm_add_paths(fe, stream, list); in dpcm_process_paths()
1524 return dpcm_prune_paths(fe, stream, list); in dpcm_process_paths()
1527 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_clear_pending_state() argument
1531 for_each_dpcm_be(fe, stream, dpcm) in dpcm_clear_pending_state()
1535 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_stop() argument
1541 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_stop()
1550 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_stop()
1579 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_startup() argument
1585 /* only startup BE DAIs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_startup()
1586 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1599 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1640 dpcm_be_dai_startup_rollback(fe, stream, dpcm); in dpcm_be_dai_startup()
1642 return soc_pcm_ret(fe, err); in dpcm_be_dai_startup()
1647 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_setup_fe() local
1656 for_each_rtd_cpu_dais(fe, i, dai) { in dpcm_runtime_setup_fe()
1677 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_setup_be_format() local
1684 if (!fe->dai_link->dpcm_merged_format) in dpcm_runtime_setup_be_format()
1689 * if FE want to use it (= dpcm_merged_format) in dpcm_runtime_setup_be_format()
1692 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_format()
1714 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_setup_be_chan() local
1720 if (!fe->dai_link->dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1725 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1728 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_chan()
1762 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_setup_be_rate() local
1768 if (!fe->dai_link->dpcm_merged_rate) in dpcm_runtime_setup_be_rate()
1773 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_rate()
1776 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_rate()
1801 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_apply_symmetry() local
1806 /* apply symmetry for FE */ in dpcm_apply_symmetry()
1809 for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) { in dpcm_apply_symmetry()
1817 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1842 return soc_pcm_ret(fe, err); in dpcm_apply_symmetry()
1847 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_startup() local
1850 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_startup()
1852 ret = dpcm_be_dai_startup(fe, stream); in dpcm_fe_dai_startup()
1856 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); in dpcm_fe_dai_startup()
1859 ret = __soc_pcm_open(fe, fe_substream); in dpcm_fe_dai_startup()
1863 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
1875 dpcm_be_dai_startup_unwind(fe, stream); in dpcm_fe_dai_startup()
1877 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_startup()
1879 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_startup()
1884 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_shutdown() local
1887 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_shutdown()
1889 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_shutdown()
1892 dpcm_be_dai_shutdown(fe, stream); in dpcm_fe_dai_shutdown()
1894 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); in dpcm_fe_dai_shutdown()
1897 __soc_pcm_close(fe, substream); in dpcm_fe_dai_shutdown()
1900 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in dpcm_fe_dai_shutdown()
1902 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
1903 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_shutdown()
1907 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_free() argument
1913 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_free()
1920 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_free()
1924 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_free()
1927 /* do not free hw if this BE is used by other FE */ in dpcm_be_dai_hw_free()
1950 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_hw_free() local
1953 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_free()
1954 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_free()
1956 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); in dpcm_fe_dai_hw_free()
1959 soc_pcm_hw_clean(fe, substream, 0); in dpcm_fe_dai_hw_free()
1963 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_free()
1965 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
1966 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_free()
1968 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_free()
1972 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_params() argument
1979 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
1984 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
1988 memcpy(&dpcm->hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2001 if (!snd_soc_dpcm_can_be_params(fe, be, stream)) in dpcm_be_dai_hw_params()
2021 dev_dbg(fe->dev, "ASoC: %s() failed at %s (%d)\n", in dpcm_be_dai_hw_params()
2025 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2029 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2033 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_params()
2051 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_hw_params() local
2054 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_params()
2055 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_params()
2057 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2059 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_fe_dai_hw_params()
2063 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n", in dpcm_fe_dai_hw_params()
2064 fe->dai_link->name, params_rate(params), in dpcm_fe_dai_hw_params()
2068 ret = __soc_pcm_hw_params(fe, substream, params); in dpcm_fe_dai_hw_params()
2070 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_params()
2072 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2075 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_params()
2076 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_params()
2078 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_hw_params()
2081 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_trigger() argument
2090 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_trigger()
2099 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_trigger()
2152 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2179 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2181 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2194 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2226 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2247 return soc_pcm_ret(fe, ret); in dpcm_be_dai_trigger()
2254 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_dai_trigger_fe_be() local
2259 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2260 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2266 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2271 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2275 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2276 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2285 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_do_trigger() local
2288 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2290 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2330 /* bespoke trigger() - handles both FE and BEs */ in dpcm_fe_dai_do_trigger()
2332 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd %d\n", in dpcm_fe_dai_do_trigger()
2333 fe->dai_link->name, cmd); in dpcm_fe_dai_do_trigger()
2338 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd, in dpcm_fe_dai_do_trigger()
2339 fe->dai_link->name); in dpcm_fe_dai_do_trigger()
2345 dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n", in dpcm_fe_dai_do_trigger()
2354 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2358 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2361 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2366 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2372 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_trigger() local
2375 /* if FE's runtime_update is already set, we're in race; in dpcm_fe_dai_trigger()
2378 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2379 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2387 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_prepare() argument
2392 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_prepare()
2399 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_prepare()
2418 return soc_pcm_ret(fe, ret); in dpcm_be_dai_prepare()
2423 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_prepare() local
2426 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_prepare()
2428 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); in dpcm_fe_dai_prepare()
2430 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2432 /* there is no point preparing this FE if there are no BEs */ in dpcm_fe_dai_prepare()
2433 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2434 dev_err(fe->dev, "ASoC: no backend DAIs enabled for %s\n", in dpcm_fe_dai_prepare()
2435 fe->dai_link->name); in dpcm_fe_dai_prepare()
2440 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_fe_dai_prepare()
2445 ret = __soc_pcm_prepare(fe, substream); in dpcm_fe_dai_prepare()
2449 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2452 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_prepare()
2453 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_prepare()
2455 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_prepare()
2458 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_shutdown() argument
2461 snd_soc_dpcm_get_substream(fe, stream); in dpcm_run_update_shutdown()
2462 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_shutdown()
2465 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n", in dpcm_run_update_shutdown()
2466 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_shutdown()
2469 /* call bespoke trigger - FE takes care of all BE triggers */ in dpcm_run_update_shutdown()
2470 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2471 fe->dai_link->name); in dpcm_run_update_shutdown()
2475 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2476 fe->dai_link->name); in dpcm_run_update_shutdown()
2478 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); in dpcm_run_update_shutdown()
2481 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_shutdown()
2483 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_shutdown()
2486 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_shutdown()
2488 return soc_pcm_ret(fe, err); in dpcm_run_update_shutdown()
2491 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_startup() argument
2494 snd_soc_dpcm_get_substream(fe, stream); in dpcm_run_update_startup()
2496 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_startup()
2499 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", in dpcm_run_update_startup()
2500 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_startup()
2502 /* Only start the BE if the FE is ready */ in dpcm_run_update_startup()
2503 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2504 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) { in dpcm_run_update_startup()
2505 dev_err(fe->dev, "ASoC: FE %s is not ready %d\n", in dpcm_run_update_startup()
2506 fe->dai_link->name, fe->dpcm[stream].state); in dpcm_run_update_startup()
2512 ret = dpcm_be_dai_startup(fe, stream); in dpcm_run_update_startup()
2516 /* keep going if FE state is > open */ in dpcm_run_update_startup()
2517 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2520 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_run_update_startup()
2524 /* keep going if FE state is > hw_params */ in dpcm_run_update_startup()
2525 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2528 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_run_update_startup()
2533 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_startup()
2535 /* keep going if FE state is > prepare */ in dpcm_run_update_startup()
2536 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2537 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2541 /* call trigger on the frontend - FE takes care of all BE triggers */ in dpcm_run_update_startup()
2542 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd start\n", in dpcm_run_update_startup()
2543 fe->dai_link->name); in dpcm_run_update_startup()
2549 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd start\n", in dpcm_run_update_startup()
2550 fe->dai_link->name); in dpcm_run_update_startup()
2552 ret = dpcm_be_dai_trigger(fe, stream, in dpcm_run_update_startup()
2561 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_startup()
2563 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_startup()
2566 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_run_update_startup()
2570 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_run_update_startup()
2578 return soc_pcm_ret(fe, ret); in dpcm_run_update_startup()
2581 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new) in soc_dpcm_fe_runtime_update() argument
2587 if (!fe->dai_link->dynamic) in soc_dpcm_fe_runtime_update()
2590 if (fe->dai_link->num_cpus > 1) { in soc_dpcm_fe_runtime_update()
2591 dev_err(fe->dev, in soc_dpcm_fe_runtime_update()
2597 if (!snd_soc_dai_active(asoc_rtd_to_cpu(fe, 0))) in soc_dpcm_fe_runtime_update()
2601 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n", in soc_dpcm_fe_runtime_update()
2602 new ? "new" : "old", fe->dai_link->name); in soc_dpcm_fe_runtime_update()
2606 /* skip if FE doesn't have playback/capture capability */ in soc_dpcm_fe_runtime_update()
2607 if (!snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2608 !snd_soc_dai_stream_valid(asoc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2611 /* skip if FE isn't currently playing/capturing */ in soc_dpcm_fe_runtime_update()
2612 if (!snd_soc_dai_stream_active(asoc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2613 !snd_soc_dai_stream_active(asoc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2616 paths = dpcm_path_get(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2621 count = dpcm_process_paths(fe, stream, &list, new); in soc_dpcm_fe_runtime_update()
2623 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE); in soc_dpcm_fe_runtime_update()
2625 dpcm_run_update_startup(fe, stream); in soc_dpcm_fe_runtime_update()
2627 dpcm_run_update_shutdown(fe, stream); in soc_dpcm_fe_runtime_update()
2628 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in soc_dpcm_fe_runtime_update()
2630 dpcm_clear_pending_state(fe, stream); in soc_dpcm_fe_runtime_update()
2631 dpcm_be_disconnect(fe, stream); in soc_dpcm_fe_runtime_update()
2645 struct snd_soc_pcm_runtime *fe; in snd_soc_dpcm_runtime_update() local
2650 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2651 ret = soc_dpcm_fe_runtime_update(fe, 0); in snd_soc_dpcm_runtime_update()
2657 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2658 ret = soc_dpcm_fe_runtime_update(fe, 1); in snd_soc_dpcm_runtime_update()
2671 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_cleanup() local
2675 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_cleanup()
2677 /* mark FE's links ready to prune */ in dpcm_fe_dai_cleanup()
2678 for_each_dpcm_be(fe, stream, dpcm) in dpcm_fe_dai_cleanup()
2681 dpcm_be_disconnect(fe, stream); in dpcm_fe_dai_cleanup()
2683 fe->dpcm[stream].runtime = NULL; in dpcm_fe_dai_cleanup()
2688 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_close() local
2691 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_close()
2696 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_close()
2702 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_open() local
2707 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_open()
2708 fe->dpcm[stream].runtime = fe_substream->runtime; in dpcm_fe_dai_open()
2710 ret = dpcm_path_get(fe, stream, &list); in dpcm_fe_dai_open()
2714 /* calculate valid and active FE <-> BE dpcms */ in dpcm_fe_dai_open()
2715 dpcm_process_paths(fe, stream, &list, 1); in dpcm_fe_dai_open()
2721 dpcm_clear_pending_state(fe, stream); in dpcm_fe_dai_open()
2724 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_open()
2950 /* is the current PCM operation for this FE ? */
2951 int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream) in snd_soc_dpcm_fe_can_update() argument
2953 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) in snd_soc_dpcm_fe_can_update()
2960 int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_be_can_update() argument
2963 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
2964 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
2979 static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_check_state() argument
2992 if (dpcm->fe == fe) in snd_soc_dpcm_check_state()
2995 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
3009 * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE
3012 int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_free_stop() argument
3021 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_free_stop()
3026 * We can only change hw params a BE DAI if any of it's FE are not prepared,
3029 int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_params() argument
3039 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_params()