Lines Matching full:fe
37 /* is the current PCM operation for this FE ? */
39 static int snd_soc_dpcm_can_fe_update(struct snd_soc_pcm_runtime *fe, int stream)
41 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE)
48 static int snd_soc_dpcm_can_be_update(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_update() argument
51 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_can_be_update()
52 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_can_be_update()
58 static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_check_state() argument
71 if (dpcm->fe == fe) in snd_soc_dpcm_check_state()
74 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
88 * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE
91 static int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_free_stop() argument
100 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_free_stop()
104 * We can only change hw params a BE DAI if any of it's FE are not prepared,
107 static int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_params() argument
117 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_params()
121 * We can only prepare a BE DAI if any of it's FE are not prepared,
124 static int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe, in snd_soc_dpcm_can_be_prepared() argument
133 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_prepared()
176 static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, in dpcm_show_state() argument
179 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
183 /* FE state */ in dpcm_show_state()
185 "[%s - %s]\n", fe->dai_link->name, in dpcm_show_state()
189 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
191 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
192 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
203 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
209 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_show_state()
236 struct snd_soc_pcm_runtime *fe = file->private_data; in dpcm_state_read_file() local
241 if (fe->dai_link->num_cpus > 1) in dpcm_state_read_file()
242 return snd_soc_ret(fe->dev, -EINVAL, in dpcm_state_read_file()
249 snd_soc_dpcm_mutex_lock(fe); in dpcm_state_read_file()
251 if (snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream)) in dpcm_state_read_file()
252 offset += dpcm_show_state(fe, stream, in dpcm_state_read_file()
255 snd_soc_dpcm_mutex_unlock(fe); in dpcm_state_read_file()
292 name, dpcm->fe->debugfs_dpcm_root); in dpcm_create_debugfs_state()
315 /* Set FE's runtime_update state; the state is protected via PCM stream lock
321 static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe, in dpcm_set_fe_update_state() argument
325 snd_soc_dpcm_get_substream(fe, stream); in dpcm_set_fe_update_state()
328 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
330 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
331 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
333 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
402 /* DPCM stream event, send event to FE and all active BEs. */
403 void dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, int event) in dpcm_dapm_stream_event() argument
407 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_dapm_stream_event()
409 for_each_dpcm_be(fe, dir, dpcm) { in dpcm_dapm_stream_event()
423 snd_soc_dapm_stream_event(fe, dir, event); in dpcm_dapm_stream_event()
1286 /* connect a FE and BE */
1287 static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, in dpcm_be_connect() argument
1294 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_connect()
1297 for_each_dpcm_be(fe, stream, dpcm) in dpcm_be_connect()
1301 fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_connect()
1307 __func__, fe->dai_link->name, be->dai_link->name); in dpcm_be_connect()
1310 dev_dbg(be->dev, "FE is nonatomic but BE is not, forcing BE as nonatomic\n"); in dpcm_be_connect()
1319 dpcm->fe = fe; in dpcm_be_connect()
1322 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1326 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", in dpcm_be_connect()
1327 snd_pcm_direction_name(stream), fe->dai_link->name, in dpcm_be_connect()
1335 /* reparent a BE onto another FE */
1336 static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, in dpcm_be_reparent() argument
1351 if (dpcm->fe == fe) in dpcm_be_reparent()
1354 dev_dbg(fe->dev, "reparent %s path %s %s %s\n", in dpcm_be_reparent()
1356 dpcm->fe->dai_link->name, in dpcm_be_reparent()
1359 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1365 /* disconnect a BE and FE */
1366 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
1369 struct snd_pcm_substream *substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_disconnect()
1372 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_be_disconnect()
1375 for_each_dpcm_be_safe(fe, stream, dpcm, d) { in dpcm_be_disconnect()
1376 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", in dpcm_be_disconnect()
1383 dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", in dpcm_be_disconnect()
1384 snd_pcm_direction_name(stream), fe->dai_link->name, in dpcm_be_disconnect()
1387 /* BEs still alive need new FE */ in dpcm_be_disconnect()
1388 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1472 int dpcm_path_get(struct snd_soc_pcm_runtime *fe, in dpcm_path_get() argument
1475 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0); in dpcm_path_get()
1478 if (fe->dai_link->num_cpus > 1) in dpcm_path_get()
1479 return snd_soc_ret(fe->dev, -EINVAL, in dpcm_path_get()
1484 fe->card->component_chaining ? in dpcm_path_get()
1488 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths, in dpcm_path_get()
1491 dev_dbg(fe->dev, "ASoC: %s no valid %s path\n", fe->dai_link->name, in dpcm_path_get()
1523 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1529 /* Destroy any old FE <--> BE connections */ in dpcm_prune_paths()
1530 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1534 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", in dpcm_prune_paths()
1536 dpcm->be->dai_link->name, fe->dai_link->name); in dpcm_prune_paths()
1542 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune); in dpcm_prune_paths()
1546 int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1549 struct snd_soc_card *card = fe->card; in dpcm_add_paths()
1553 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_add_paths()
1556 /* don't connect if FE is not running */ in dpcm_add_paths()
1557 if (!fe_substream->runtime && !fe->fe_compr) in dpcm_add_paths()
1560 /* Create any new FE <--> BE connections */ in dpcm_add_paths()
1579 dev_dbg(fe->dev, "ASoC: no BE found for %s\n", in dpcm_add_paths()
1590 if (fe->card->component_chaining && in dpcm_add_paths()
1597 /* newly connected FE and BE */ in dpcm_add_paths()
1598 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1600 dev_err(fe->dev, "ASoC: can't connect %s\n", in dpcm_add_paths()
1611 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new); in dpcm_add_paths()
1615 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_clear_pending_state() argument
1619 for_each_dpcm_be(fe, stream, dpcm) in dpcm_clear_pending_state()
1623 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_stop() argument
1629 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_stop()
1638 if (!snd_soc_dpcm_can_be_update(fe, be, stream)) in dpcm_be_dai_stop()
1667 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_startup() argument
1669 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_dai_startup()
1674 /* only startup BE DAIs that are either sinks or sources to this FE DAI */ in dpcm_be_dai_startup()
1675 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1688 if (!snd_soc_dpcm_can_be_update(fe, be, stream)) in dpcm_be_dai_startup()
1729 dpcm_be_dai_startup_rollback(fe, stream, dpcm); in dpcm_be_dai_startup()
1731 return soc_pcm_ret(fe, err); in dpcm_be_dai_startup()
1736 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_fe() local
1749 for_each_rtd_cpu_dais(fe, i, dai) { in dpcm_runtime_setup_fe()
1770 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_format() local
1777 if (!fe->dai_link->dpcm_merged_format) in dpcm_runtime_setup_be_format()
1782 * if FE want to use it (= dpcm_merged_format) in dpcm_runtime_setup_be_format()
1785 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_format()
1807 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_chan() local
1813 if (!fe->dai_link->dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1818 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_chan()
1821 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_chan()
1855 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_runtime_setup_be_rate() local
1861 if (!fe->dai_link->dpcm_merged_rate) in dpcm_runtime_setup_be_rate()
1866 * if FE want to use it (= dpcm_merged_chan) in dpcm_runtime_setup_be_rate()
1869 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_rate()
1894 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_apply_symmetry() local
1899 /* apply symmetry for FE */ in dpcm_apply_symmetry()
1902 for_each_rtd_cpu_dais (fe, i, fe_cpu_dai) { in dpcm_apply_symmetry()
1910 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1935 return soc_pcm_ret(fe, err); in dpcm_apply_symmetry()
1940 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_startup() local
1943 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_startup()
1945 ret = dpcm_be_dai_startup(fe, stream); in dpcm_fe_dai_startup()
1949 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name); in dpcm_fe_dai_startup()
1952 ret = __soc_pcm_open(fe, fe_substream); in dpcm_fe_dai_startup()
1956 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
1968 dpcm_be_dai_startup_unwind(fe, stream); in dpcm_fe_dai_startup()
1970 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_startup()
1972 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_startup()
1977 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_shutdown() local
1980 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_shutdown()
1982 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_shutdown()
1985 dpcm_be_dai_shutdown(fe, stream); in dpcm_fe_dai_shutdown()
1987 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name); in dpcm_fe_dai_shutdown()
1990 __soc_pcm_close(fe, substream); in dpcm_fe_dai_shutdown()
1993 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in dpcm_fe_dai_shutdown()
1995 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
1996 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_shutdown()
2000 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_free() argument
2006 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_free()
2013 if (!snd_soc_dpcm_can_be_update(fe, be, stream)) in dpcm_be_dai_hw_free()
2017 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_free()
2020 /* do not free hw if this BE is used by other FE */ in dpcm_be_dai_hw_free()
2043 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_hw_free() local
2046 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_free()
2047 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_free()
2049 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); in dpcm_fe_dai_hw_free()
2052 soc_pcm_hw_clean(fe, substream, 0); in dpcm_fe_dai_hw_free()
2056 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_free()
2058 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
2059 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_free()
2061 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_free()
2065 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_params() argument
2072 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2079 if (!snd_soc_dpcm_can_be_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2083 memcpy(&hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2096 if (!snd_soc_dpcm_can_be_params(fe, be, stream)) in dpcm_be_dai_hw_params()
2116 dev_dbg(fe->dev, "ASoC: %s() failed at %s (%d)\n", in dpcm_be_dai_hw_params()
2120 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2124 if (!snd_soc_dpcm_can_be_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2128 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_params()
2146 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_hw_params() local
2149 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_hw_params()
2150 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_params()
2152 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2154 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_fe_dai_hw_params()
2158 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n", in dpcm_fe_dai_hw_params()
2159 fe->dai_link->name, params_rate(params), in dpcm_fe_dai_hw_params()
2165 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_params()
2167 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2170 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_params()
2171 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_hw_params()
2173 return soc_pcm_ret(fe, ret); in dpcm_fe_dai_hw_params()
2176 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_trigger() argument
2185 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_trigger()
2194 if (!snd_soc_dpcm_can_be_update(fe, be, stream)) in dpcm_be_dai_trigger()
2247 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2274 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2276 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2289 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2321 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2342 return soc_pcm_ret(fe, ret); in dpcm_be_dai_trigger()
2349 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_dai_trigger_fe_be() local
2354 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2355 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2361 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2365 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2369 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", in dpcm_dai_trigger_fe_be()
2370 fe->dai_link->name, cmd); in dpcm_dai_trigger_fe_be()
2375 return snd_soc_ret(fe->dev, ret, "trigger FE cmd: %d failed\n", cmd); in dpcm_dai_trigger_fe_be()
2380 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_do_trigger() local
2384 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2386 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2396 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd, in dpcm_fe_dai_do_trigger()
2397 fe->dai_link->name); in dpcm_fe_dai_do_trigger()
2426 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2430 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2433 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2438 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2444 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_trigger() local
2447 /* if FE's runtime_update is already set, we're in race; in dpcm_fe_dai_trigger()
2450 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2451 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2459 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_prepare() argument
2464 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_prepare()
2471 if (!snd_soc_dpcm_can_be_update(fe, be, stream)) in dpcm_be_dai_prepare()
2474 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream)) in dpcm_be_dai_prepare()
2504 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(substream); in dpcm_fe_dai_prepare() local
2507 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_prepare()
2509 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); in dpcm_fe_dai_prepare()
2511 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2513 /* there is no point preparing this FE if there are no BEs */ in dpcm_fe_dai_prepare()
2514 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2516 …dev_err_once(fe->dev, "ASoC: no backend DAIs enabled for %s, possibly missing ALSA mixer-based rou… in dpcm_fe_dai_prepare()
2517 fe->dai_link->name); in dpcm_fe_dai_prepare()
2518 dev_dbg(fe->dev, "ASoC: no backend DAIs enabled for %s\n", in dpcm_fe_dai_prepare()
2519 fe->dai_link->name); in dpcm_fe_dai_prepare()
2524 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_fe_dai_prepare()
2529 ret = __soc_pcm_prepare(fe, substream); in dpcm_fe_dai_prepare()
2533 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2536 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_prepare()
2537 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_prepare()
2548 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_shutdown() argument
2552 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n", in dpcm_run_update_shutdown()
2553 snd_pcm_direction_name(stream), fe->dai_link->name); in dpcm_run_update_shutdown()
2555 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); in dpcm_run_update_shutdown()
2557 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_shutdown()
2559 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_shutdown()
2562 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_shutdown()
2564 return soc_pcm_ret(fe, err); in dpcm_run_update_shutdown()
2567 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_startup() argument
2572 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", in dpcm_run_update_startup()
2573 snd_pcm_direction_name(stream), 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 %s\n", in dpcm_run_update_startup()
2579 fe->dai_link->name, dpcm_state_string(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()
2613 ret = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_START); in dpcm_run_update_startup()
2620 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_startup()
2622 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_startup()
2625 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_run_update_startup()
2629 if (!snd_soc_dpcm_can_be_update(fe, be, stream)) in dpcm_run_update_startup()
2637 return soc_pcm_ret(fe, ret); in dpcm_run_update_startup()
2640 static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new) in soc_dpcm_fe_runtime_update() argument
2646 if (!fe->dai_link->dynamic) in soc_dpcm_fe_runtime_update()
2649 if (fe->dai_link->num_cpus > 1) in soc_dpcm_fe_runtime_update()
2650 return snd_soc_ret(fe->dev, -EINVAL, in soc_dpcm_fe_runtime_update()
2654 if (!snd_soc_dai_active(snd_soc_rtd_to_cpu(fe, 0))) in soc_dpcm_fe_runtime_update()
2658 dev_dbg(fe->dev, "ASoC: DPCM %s runtime update for FE %s\n", in soc_dpcm_fe_runtime_update()
2659 new ? "new" : "old", fe->dai_link->name); in soc_dpcm_fe_runtime_update()
2663 /* skip if FE doesn't have playback/capture capability */ in soc_dpcm_fe_runtime_update()
2664 if (!snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2665 !snd_soc_dai_stream_valid(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2668 /* skip if FE isn't currently playing/capturing */ in soc_dpcm_fe_runtime_update()
2669 if (!snd_soc_dai_stream_active(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2670 !snd_soc_dai_stream_active(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2673 paths = dpcm_path_get(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2680 * FE substream. in soc_dpcm_fe_runtime_update()
2683 count = dpcm_add_paths(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2685 count = dpcm_prune_paths(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2687 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE); in soc_dpcm_fe_runtime_update()
2689 dpcm_run_update_startup(fe, stream); in soc_dpcm_fe_runtime_update()
2691 dpcm_run_update_shutdown(fe, stream); in soc_dpcm_fe_runtime_update()
2692 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in soc_dpcm_fe_runtime_update()
2694 dpcm_clear_pending_state(fe, stream); in soc_dpcm_fe_runtime_update()
2695 dpcm_be_disconnect(fe, stream); in soc_dpcm_fe_runtime_update()
2709 struct snd_soc_pcm_runtime *fe; in snd_soc_dpcm_runtime_update() local
2714 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2715 ret = soc_dpcm_fe_runtime_update(fe, 0); in snd_soc_dpcm_runtime_update()
2721 for_each_card_rtds(card, fe) { in snd_soc_dpcm_runtime_update()
2722 ret = soc_dpcm_fe_runtime_update(fe, 1); in snd_soc_dpcm_runtime_update()
2736 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_cleanup() local
2740 snd_soc_dpcm_mutex_assert_held(fe); in dpcm_fe_dai_cleanup()
2742 /* mark FE's links ready to prune */ in dpcm_fe_dai_cleanup()
2743 for_each_dpcm_be(fe, stream, dpcm) in dpcm_fe_dai_cleanup()
2746 dpcm_be_disconnect(fe, stream); in dpcm_fe_dai_cleanup()
2751 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_close() local
2754 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_close()
2759 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_close()
2765 struct snd_soc_pcm_runtime *fe = snd_soc_substream_to_rtd(fe_substream); in dpcm_fe_dai_open() local
2770 snd_soc_dpcm_mutex_lock(fe); in dpcm_fe_dai_open()
2772 ret = dpcm_path_get(fe, stream, &list); in dpcm_fe_dai_open()
2776 /* calculate valid and active FE <-> BE dpcms */ in dpcm_fe_dai_open()
2777 dpcm_add_paths(fe, stream, &list); in dpcm_fe_dai_open()
2783 dpcm_clear_pending_state(fe, stream); in dpcm_fe_dai_open()
2786 snd_soc_dpcm_mutex_unlock(fe); in dpcm_fe_dai_open()