• Home
  • Raw
  • Download

Lines Matching full:fe

61 static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,  in dpcm_show_state()  argument
64 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
69 /* FE state */ in dpcm_show_state()
71 "[%s - %s]\n", fe->dai_link->name, in dpcm_show_state()
75 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
77 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
78 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
89 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
95 spin_lock_irqsave(&fe->card->dpcm_lock, flags); in dpcm_show_state()
96 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_show_state()
116 spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); in dpcm_show_state()
124 struct snd_soc_pcm_runtime *fe = file->private_data; in dpcm_state_read_file() local
129 if (fe->num_cpus > 1) { in dpcm_state_read_file()
130 dev_err(fe->dev, in dpcm_state_read_file()
140 if (snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream)) in dpcm_state_read_file()
141 offset += dpcm_show_state(fe, stream, in dpcm_state_read_file()
183 name, dpcm->fe->debugfs_dpcm_root); in dpcm_create_debugfs_state()
279 /* DPCM stream event, send event to FE and all active BEs. */
280 int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, in dpcm_dapm_stream_event() argument
285 for_each_dpcm_be(fe, dir, dpcm) { in dpcm_dapm_stream_event()
299 snd_soc_dapm_stream_event(fe, dir, event); in dpcm_dapm_stream_event()
1110 /* connect a FE and BE */
1111 static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, in dpcm_be_connect() argument
1118 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_connect()
1119 if (dpcm->be == be && dpcm->fe == fe) in dpcm_be_connect()
1128 dpcm->fe = fe; in dpcm_be_connect()
1129 be->dpcm[stream].runtime = fe->dpcm[stream].runtime; in dpcm_be_connect()
1131 spin_lock_irqsave(&fe->card->dpcm_lock, flags); in dpcm_be_connect()
1132 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1134 spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); in dpcm_be_connect()
1136 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", in dpcm_be_connect()
1137 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_connect()
1145 /* reparent a BE onto another FE */
1146 static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, in dpcm_be_reparent() argument
1161 if (dpcm->fe == fe) in dpcm_be_reparent()
1164 dev_dbg(fe->dev, "reparent %s path %s %s %s\n", in dpcm_be_reparent()
1166 dpcm->fe->dai_link->name, in dpcm_be_reparent()
1169 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1175 /* disconnect a BE and FE */
1176 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
1181 for_each_dpcm_be_safe(fe, stream, dpcm, d) { in dpcm_be_disconnect()
1182 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", in dpcm_be_disconnect()
1189 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", in dpcm_be_disconnect()
1190 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_disconnect()
1193 /* BEs still alive need new FE */ in dpcm_be_disconnect()
1194 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1198 spin_lock_irqsave(&fe->card->dpcm_lock, flags); in dpcm_be_disconnect()
1201 spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); in dpcm_be_disconnect()
1270 int dpcm_path_get(struct snd_soc_pcm_runtime *fe, in dpcm_path_get() argument
1273 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0); in dpcm_path_get()
1276 if (fe->num_cpus > 1) { in dpcm_path_get()
1277 dev_err(fe->dev, in dpcm_path_get()
1286 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, in dpcm_path_get()
1319 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1325 /* Destroy any old FE <--> BE connections */ in dpcm_prune_paths()
1326 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1330 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", in dpcm_prune_paths()
1332 dpcm->be->dai_link->name, fe->dai_link->name); in dpcm_prune_paths()
1338 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune); in dpcm_prune_paths()
1342 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1345 struct snd_soc_card *card = fe->card; in dpcm_add_paths()
1351 /* Create any new FE <--> BE connections */ in dpcm_add_paths()
1370 dev_err(fe->dev, "ASoC: no BE found for %s\n", in dpcm_add_paths()
1375 /* don't connect if FE is not running */ in dpcm_add_paths()
1376 if (!fe->dpcm[stream].runtime && !fe->fe_compr) in dpcm_add_paths()
1379 /* newly connected FE and BE */ in dpcm_add_paths()
1380 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1382 dev_err(fe->dev, "ASoC: can't connect %s\n", in dpcm_add_paths()
1393 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new); in dpcm_add_paths()
1399 * FE substream.
1401 int dpcm_process_paths(struct snd_soc_pcm_runtime *fe, in dpcm_process_paths() argument
1405 return dpcm_add_paths(fe, stream, list); in dpcm_process_paths()
1407 return dpcm_prune_paths(fe, stream, list); in dpcm_process_paths()
1410 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_clear_pending_state() argument
1415 spin_lock_irqsave(&fe->card->dpcm_lock, flags); in dpcm_clear_pending_state()
1416 for_each_dpcm_be(fe, stream, dpcm) in dpcm_clear_pending_state()
1419 spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); in dpcm_clear_pending_state()
1422 static void dpcm_be_dai_startup_unwind(struct snd_soc_pcm_runtime *fe, in dpcm_be_dai_startup_unwind() argument
1428 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup_unwind()
1451 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_startup() argument
1456 /* only startup BE DAIs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_startup()
1457 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1470 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1511 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_startup()
1516 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1555 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_merge_format() local
1560 if (!fe->dai_link->dpcm_merged_format) in dpcm_runtime_merge_format()
1565 * if FE want to use it (= dpcm_merged_format) in dpcm_runtime_merge_format()
1568 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_merge_format()
1592 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_merge_chan() local
1596 if (!fe->dai_link->dpcm_merged_chan) in dpcm_runtime_merge_chan()
1601 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_merge_chan()
1604 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_merge_chan()
1647 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_runtime_merge_rate() local
1651 if (!fe->dai_link->dpcm_merged_rate) in dpcm_runtime_merge_rate()
1656 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_merge_rate()
1659 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_merge_rate()
1711 /* Set FE's runtime_update state; the state is protected via PCM stream lock
1716 static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe, in dpcm_set_fe_update_state() argument
1720 snd_soc_dpcm_get_substream(fe, stream); in dpcm_set_fe_update_state()
1723 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
1725 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
1726 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
1728 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
1736 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_apply_symmetry() local
1741 /* apply symmetry for FE */ in dpcm_apply_symmetry()
1745 for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) { in dpcm_apply_symmetry()
1755 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1789 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_startup() local
1793 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_startup()
1795 ret = dpcm_be_dai_startup(fe, stream); in dpcm_fe_dai_startup()
1797 dev_err(fe->dev,"ASoC: failed to start some BEs %d\n", ret); in dpcm_fe_dai_startup()
1801 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); in dpcm_fe_dai_startup()
1806 dev_err(fe->dev,"ASoC: failed to start FE %d\n", ret); in dpcm_fe_dai_startup()
1810 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
1817 dev_err(fe->dev, "ASoC: failed to apply dpcm symmetry %d\n", in dpcm_fe_dai_startup()
1822 dpcm_be_dai_startup_unwind(fe, stream); in dpcm_fe_dai_startup()
1824 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_startup()
1828 int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_shutdown() argument
1832 /* only shutdown BEs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_shutdown()
1833 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_shutdown()
1840 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_shutdown()
1870 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_shutdown() local
1873 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_shutdown()
1876 dpcm_be_dai_shutdown(fe, stream); in dpcm_fe_dai_shutdown()
1878 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); in dpcm_fe_dai_shutdown()
1884 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in dpcm_fe_dai_shutdown()
1886 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
1887 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_shutdown()
1891 int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_free() argument
1897 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_free()
1904 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_free()
1908 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_free()
1911 /* do not free hw if this BE is used by other FE */ in dpcm_be_dai_hw_free()
1936 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_hw_free() local
1939 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); in dpcm_fe_dai_hw_free()
1940 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_free()
1942 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); in dpcm_fe_dai_hw_free()
1947 dev_err(fe->dev,"ASoC: hw_free FE %s failed\n", in dpcm_fe_dai_hw_free()
1948 fe->dai_link->name); in dpcm_fe_dai_hw_free()
1952 err = dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_free()
1954 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
1955 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_free()
1957 mutex_unlock(&fe->card->mutex); in dpcm_fe_dai_hw_free()
1961 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_params() argument
1966 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
1973 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
1977 memcpy(&dpcm->hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
1990 if (!snd_soc_dpcm_can_be_params(fe, be, stream)) in dpcm_be_dai_hw_params()
2014 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2019 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2023 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_params()
2041 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_hw_params() local
2044 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); in dpcm_fe_dai_hw_params()
2045 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_params()
2047 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2049 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_fe_dai_hw_params()
2051 dev_err(fe->dev,"ASoC: hw_params BE failed %d\n", ret); in dpcm_fe_dai_hw_params()
2055 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n", in dpcm_fe_dai_hw_params()
2056 fe->dai_link->name, params_rate(params), in dpcm_fe_dai_hw_params()
2062 dev_err(fe->dev,"ASoC: hw_params FE failed %d\n", ret); in dpcm_fe_dai_hw_params()
2063 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_params()
2065 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2068 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_params()
2069 mutex_unlock(&fe->card->mutex); in dpcm_fe_dai_hw_params()
2088 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_trigger() argument
2094 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_trigger()
2101 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_trigger()
2142 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_trigger()
2155 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_trigger()
2168 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_trigger()
2187 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_dai_trigger_fe_be() local
2192 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2193 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2199 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2204 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2208 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2209 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2218 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_do_trigger() local
2221 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2223 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2263 /* bespoke trigger() - handles both FE and BEs */ in dpcm_fe_dai_do_trigger()
2265 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd %d\n", in dpcm_fe_dai_do_trigger()
2266 fe->dai_link->name, cmd); in dpcm_fe_dai_do_trigger()
2271 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd, in dpcm_fe_dai_do_trigger()
2272 fe->dai_link->name); in dpcm_fe_dai_do_trigger()
2278 dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n", in dpcm_fe_dai_do_trigger()
2287 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2291 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2294 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2299 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2305 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_trigger() local
2308 /* if FE's runtime_update is already set, we're in race; in dpcm_fe_dai_trigger()
2311 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2312 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2320 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_prepare() argument
2325 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_prepare()
2332 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_prepare()
2335 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream)) in dpcm_be_dai_prepare()
2361 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(substream); in dpcm_fe_dai_prepare() local
2364 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); in dpcm_fe_dai_prepare()
2366 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); in dpcm_fe_dai_prepare()
2368 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2370 /* there is no point preparing this FE if there are no BEs */ in dpcm_fe_dai_prepare()
2371 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2372 dev_err(fe->dev, "ASoC: no backend DAIs enabled for %s\n", in dpcm_fe_dai_prepare()
2373 fe->dai_link->name); in dpcm_fe_dai_prepare()
2378 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_fe_dai_prepare()
2385 dev_err(fe->dev,"ASoC: prepare FE %s failed\n", in dpcm_fe_dai_prepare()
2386 fe->dai_link->name); in dpcm_fe_dai_prepare()
2391 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START); in dpcm_fe_dai_prepare()
2392 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2395 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_prepare()
2396 mutex_unlock(&fe->card->mutex); in dpcm_fe_dai_prepare()
2401 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_shutdown() argument
2404 snd_soc_dpcm_get_substream(fe, stream); in dpcm_run_update_shutdown()
2405 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_shutdown()
2408 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n", in dpcm_run_update_shutdown()
2409 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_shutdown()
2412 /* call bespoke trigger - FE takes care of all BE triggers */ in dpcm_run_update_shutdown()
2413 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2414 fe->dai_link->name); in dpcm_run_update_shutdown()
2418 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", err); in dpcm_run_update_shutdown()
2420 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd stop\n", in dpcm_run_update_shutdown()
2421 fe->dai_link->name); in dpcm_run_update_shutdown()
2423 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); in dpcm_run_update_shutdown()
2425 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", err); in dpcm_run_update_shutdown()
2428 err = dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_shutdown()
2430 dev_err(fe->dev,"ASoC: hw_free FE failed %d\n", err); in dpcm_run_update_shutdown()
2432 err = dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_shutdown()
2434 dev_err(fe->dev,"ASoC: shutdown FE failed %d\n", err); in dpcm_run_update_shutdown()
2437 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_shutdown()
2442 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_startup() argument
2445 snd_soc_dpcm_get_substream(fe, stream); in dpcm_run_update_startup()
2447 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_startup()
2451 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", in dpcm_run_update_startup()
2452 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_startup()
2454 /* Only start the BE if the FE is ready */ in dpcm_run_update_startup()
2455 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2456 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) in dpcm_run_update_startup()
2460 ret = dpcm_be_dai_startup(fe, stream); in dpcm_run_update_startup()
2464 /* keep going if FE state is > open */ in dpcm_run_update_startup()
2465 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2468 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_run_update_startup()
2472 /* keep going if FE state is > hw_params */ in dpcm_run_update_startup()
2473 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2477 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_run_update_startup()
2482 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_startup()
2484 /* keep going if FE state is > prepare */ in dpcm_run_update_startup()
2485 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2486 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2490 /* call trigger on the frontend - FE takes care of all BE triggers */ in dpcm_run_update_startup()
2491 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd start\n", in dpcm_run_update_startup()
2492 fe->dai_link->name); in dpcm_run_update_startup()
2496 dev_err(fe->dev,"ASoC: bespoke trigger FE failed %d\n", ret); in dpcm_run_update_startup()
2500 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd start\n", in dpcm_run_update_startup()
2501 fe->dai_link->name); in dpcm_run_update_startup()
2503 ret = dpcm_be_dai_trigger(fe, stream, in dpcm_run_update_startup()
2506 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", ret); in dpcm_run_update_startup()
2514 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_startup()
2516 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_startup()
2519 spin_lock_irqsave(&fe->card->dpcm_lock, flags); in dpcm_run_update_startup()
2520 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_run_update_startup()
2525 spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); in dpcm_run_update_startup()
2530 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new) in soc_dpcm_fe_runtime_update() argument
2537 if (!fe->dai_link->dynamic) in soc_dpcm_fe_runtime_update()
2540 if (fe->num_cpus > 1) { in soc_dpcm_fe_runtime_update()
2541 dev_err(fe->dev, in soc_dpcm_fe_runtime_update()
2547 if (!snd_soc_dai_active(asoc_rtd_to_cpu(fe, 0))) in soc_dpcm_fe_runtime_update()
2551 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n", in soc_dpcm_fe_runtime_update()
2552 new ? "new" : "old", fe->dai_link->name); in soc_dpcm_fe_runtime_update()
2556 /* skip if FE doesn't have playback/capture capability */ in soc_dpcm_fe_runtime_update()
2557 if (!snd_soc_dai_stream_valid(asoc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2558 !snd_soc_dai_stream_valid(asoc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2561 /* skip if FE isn't currently playing/capturing */ in soc_dpcm_fe_runtime_update()
2562 if (!snd_soc_dai_stream_active(asoc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2563 !snd_soc_dai_stream_active(asoc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2566 paths = dpcm_path_get(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2568 dev_warn(fe->dev, "ASoC: %s no valid %s path\n", in soc_dpcm_fe_runtime_update()
2569 fe->dai_link->name, in soc_dpcm_fe_runtime_update()
2576 count = dpcm_process_paths(fe, stream, &list, new); in soc_dpcm_fe_runtime_update()
2578 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE); in soc_dpcm_fe_runtime_update()
2580 ret = dpcm_run_update_startup(fe, stream); in soc_dpcm_fe_runtime_update()
2582 ret = dpcm_run_update_shutdown(fe, stream); in soc_dpcm_fe_runtime_update()
2584 dev_err(fe->dev, "ASoC: failed to shutdown some BEs\n"); in soc_dpcm_fe_runtime_update()
2585 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in soc_dpcm_fe_runtime_update()
2587 dpcm_clear_pending_state(fe, stream); in soc_dpcm_fe_runtime_update()
2588 dpcm_be_disconnect(fe, stream); in soc_dpcm_fe_runtime_update()
2602 struct snd_soc_pcm_runtime *fe; in snd_soc_dpcm_runtime_update() local
2607 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2608 ret = soc_dpcm_fe_runtime_update(fe, 0); in snd_soc_dpcm_runtime_update()
2614 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2615 ret = soc_dpcm_fe_runtime_update(fe, 1); in snd_soc_dpcm_runtime_update()
2628 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_cleanup() local
2632 /* mark FE's links ready to prune */ in dpcm_fe_dai_cleanup()
2633 for_each_dpcm_be(fe, stream, dpcm) in dpcm_fe_dai_cleanup()
2636 dpcm_be_disconnect(fe, stream); in dpcm_fe_dai_cleanup()
2638 fe->dpcm[stream].runtime = NULL; in dpcm_fe_dai_cleanup()
2643 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_close() local
2646 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); in dpcm_fe_dai_close()
2651 mutex_unlock(&fe->card->mutex); in dpcm_fe_dai_close()
2657 struct snd_soc_pcm_runtime *fe = asoc_substream_to_rtd(fe_substream); in dpcm_fe_dai_open() local
2662 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); in dpcm_fe_dai_open()
2663 fe->dpcm[stream].runtime = fe_substream->runtime; in dpcm_fe_dai_open()
2665 ret = dpcm_path_get(fe, stream, &list); in dpcm_fe_dai_open()
2669 dev_dbg(fe->dev, "ASoC: %s no valid %s route\n", in dpcm_fe_dai_open()
2670 fe->dai_link->name, stream ? "capture" : "playback"); in dpcm_fe_dai_open()
2673 /* calculate valid and active FE <-> BE dpcms */ in dpcm_fe_dai_open()
2674 dpcm_process_paths(fe, stream, &list, 1); in dpcm_fe_dai_open()
2680 dpcm_clear_pending_state(fe, stream); in dpcm_fe_dai_open()
2683 mutex_unlock(&fe->card->mutex); in dpcm_fe_dai_open()
2883 /* is the current PCM operation for this FE ? */
2884 int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream) in snd_soc_dpcm_fe_can_update() argument
2886 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) in snd_soc_dpcm_fe_can_update()
2893 int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_be_can_update() argument
2896 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
2897 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
2912 static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_check_state() argument
2924 spin_lock_irqsave(&fe->card->dpcm_lock, flags); in snd_soc_dpcm_check_state()
2927 if (dpcm->fe == fe) in snd_soc_dpcm_check_state()
2930 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
2938 spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); in snd_soc_dpcm_check_state()
2945 * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE
2948 int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_free_stop() argument
2957 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_free_stop()
2962 * We can only change hw params a BE DAI if any of it's FE are not prepared,
2965 int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_params() argument
2975 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_params()
2980 * We can only prepare a BE DAI if any of it's FE are not prepared,
2983 int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_prepared() argument
2992 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_prepared()