Lines Matching full:stream
66 int stream) in snd_soc_dpcm_stream_lock_irq() argument
68 snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream)); in snd_soc_dpcm_stream_lock_irq()
71 #define snd_soc_dpcm_stream_lock_irqsave_nested(rtd, stream, flags) \ argument
72 snd_pcm_stream_lock_irqsave_nested(snd_soc_dpcm_get_substream(rtd, stream), flags)
75 int stream) in snd_soc_dpcm_stream_unlock_irq() argument
77 snd_pcm_stream_unlock_irq(snd_soc_dpcm_get_substream(rtd, stream)); in snd_soc_dpcm_stream_unlock_irq()
80 #define snd_soc_dpcm_stream_unlock_irqrestore(rtd, stream, flags) \ argument
81 snd_pcm_stream_unlock_irqrestore(snd_soc_dpcm_get_substream(rtd, stream), flags)
124 int stream, char *buf, size_t size) in dpcm_show_state() argument
126 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
133 stream ? "Capture" : "Playback"); 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()
165 dpcm_state_string(be->dpcm[stream].state)); in dpcm_show_state()
167 if ((be->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
168 (be->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
185 int stream; in dpcm_state_read_file() local
199 for_each_pcm_streams(stream) 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()
233 static void dpcm_create_debugfs_state(struct snd_soc_dpcm *dpcm, int stream) in dpcm_create_debugfs_state() argument
238 stream ? "capture" : "playback"); in dpcm_create_debugfs_state()
255 int stream) in dpcm_create_debugfs_state() argument
264 /* Set FE's runtime_update state; the state is protected via PCM stream lock
271 int stream, enum snd_soc_dpcm_update state) 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()
287 int stream, enum snd_soc_dpcm_update state) in dpcm_set_be_update_state() argument
289 be->dpcm[stream].runtime_update = state; in dpcm_set_be_update_state()
296 * @stream: Direction of the PCM stream
297 * @action: Activate stream if 1. Deactivate if -1.
301 * Should typically be called when a stream is opened.
306 int stream, int action) in snd_soc_runtime_action() argument
314 snd_soc_dai_action(dai, stream, action); in snd_soc_runtime_action()
358 /* DPCM stream event, send event to FE and all active BEs. */
506 int stream = substream->stream; in soc_pcm_apply_msb() local
511 struct snd_soc_pcm_stream *pcm_codec = snd_soc_dai_get_pcm_stream(codec_dai, stream); in soc_pcm_apply_msb()
521 struct snd_soc_pcm_stream *pcm_cpu = snd_soc_dai_get_pcm_stream(cpu_dai, stream); in soc_pcm_apply_msb()
571 * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
574 * @stream: Direction of the PCM stream
576 * Calculates the subset of stream parameters supported by all DAIs
577 * associated with the PCM stream.
580 struct snd_pcm_hardware *hw, int stream) in snd_soc_runtime_calc_hw() argument
595 * Skip CPUs which don't support the current stream type. in snd_soc_runtime_calc_hw()
600 if (!snd_soc_dai_stream_valid(cpu_dai, stream)) in snd_soc_runtime_calc_hw()
603 cpu_stream = snd_soc_dai_get_pcm_stream(cpu_dai, stream); in snd_soc_runtime_calc_hw()
616 * Skip CODECs which don't support the current stream type. in snd_soc_runtime_calc_hw()
621 if (!snd_soc_dai_stream_valid(codec_dai, stream)) in snd_soc_runtime_calc_hw()
624 codec_stream = snd_soc_dai_get_pcm_stream(codec_dai, stream); in snd_soc_runtime_calc_hw()
660 snd_soc_runtime_calc_hw(rtd, hw, substream->stream); in soc_pcm_init_runtime_hw()
713 snd_soc_runtime_deactivate(rtd, substream->stream); in soc_pcm_clean()
842 /* Symmetry only applies if we've already got an active stream. */ in __soc_pcm_open()
849 snd_soc_runtime_activate(rtd, substream->stream); in __soc_pcm_open()
895 /* cancel any delayed stream shutdown that is pending */ in __soc_pcm_prepare()
896 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in __soc_pcm_prepare()
902 snd_soc_dapm_stream_event(rtd, substream->stream, in __soc_pcm_prepare()
906 snd_soc_dai_digital_mute(dai, 0, substream->stream); in __soc_pcm_prepare()
948 if (snd_soc_dai_stream_active(dai, substream->stream) == 1) in soc_pcm_hw_clean()
949 snd_soc_dai_digital_mute(dai, 1, substream->stream); in soc_pcm_hw_clean()
952 /* run the stream event */ in soc_pcm_hw_clean()
953 snd_soc_dapm_stream_stop(rtd, substream->stream); in soc_pcm_hw_clean()
963 if (snd_soc_dai_stream_valid(dai, substream->stream)) in soc_pcm_hw_clean()
1017 * Skip CODECs which don't support the current stream type, in __soc_pcm_hw_params()
1030 if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) in __soc_pcm_hw_params()
1037 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in __soc_pcm_hw_params()
1042 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && in __soc_pcm_hw_params()
1058 * Skip CPUs which don't support the current stream in __soc_pcm_hw_params()
1061 if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) in __soc_pcm_hw_params()
1189 struct snd_soc_pcm_runtime *be, int stream) in dpcm_be_connect() argument
1198 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_connect()
1203 fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_connect()
1204 be_substream = snd_soc_dpcm_get_substream(be, stream); 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()
1226 list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); in dpcm_be_connect()
1227 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_be_connect()
1230 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_connect()
1231 stream ? "<-" : "->", be->dai_link->name); in dpcm_be_connect()
1233 dpcm_create_debugfs_state(dpcm, stream); in dpcm_be_connect()
1240 struct snd_soc_pcm_runtime *be, int stream) in dpcm_be_reparent() argument
1246 if (!be->dpcm[stream].users) in dpcm_be_reparent()
1249 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_reparent()
1253 for_each_dpcm_fe(be, stream, dpcm) { in dpcm_be_reparent()
1258 stream ? "capture" : "playback", in dpcm_be_reparent()
1260 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_reparent()
1262 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1269 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
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()
1279 stream ? "capture" : "playback", in dpcm_be_disconnect()
1286 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_disconnect()
1287 stream ? "<-" : "->", dpcm->be->dai_link->name); 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()
1306 /* get BE for DAI widget and stream */
1308 struct snd_soc_dapm_widget *widget, int stream) in dpcm_get_be() argument
1322 if (!snd_soc_dpcm_get_substream(be, stream)) in dpcm_get_be()
1326 w = snd_soc_dai_get_widget(dai, stream); in dpcm_get_be()
1357 int stream; in dpcm_end_walk_at_be() local
1359 /* adjust dir to stream */ in dpcm_end_walk_at_be()
1361 stream = SNDRV_PCM_STREAM_PLAYBACK; in dpcm_end_walk_at_be()
1363 stream = SNDRV_PCM_STREAM_CAPTURE; in dpcm_end_walk_at_be()
1365 rtd = dpcm_get_be(card, widget, stream); in dpcm_end_walk_at_be()
1374 int stream, struct snd_soc_dapm_widget_list **list) in dpcm_path_get() argument
1386 paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, list, in dpcm_path_get()
1392 stream ? "capture" : "playback"); in dpcm_path_get()
1395 stream ? "capture" : "playback"); in dpcm_path_get()
1405 static bool dpcm_be_is_active(struct snd_soc_dpcm *dpcm, int stream, in dpcm_be_is_active() argument
1413 struct snd_soc_dapm_widget *widget = snd_soc_dai_get_widget(dai, stream); in dpcm_be_is_active()
1426 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1433 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1434 if (dpcm_be_is_active(dpcm, stream, *list_)) in dpcm_prune_paths()
1438 stream ? "capture" : "playback", in dpcm_prune_paths()
1441 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_prune_paths()
1449 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1459 if (!fe->dpcm[stream].runtime && !fe->fe_compr) in dpcm_add_paths()
1467 if (stream != SNDRV_PCM_STREAM_PLAYBACK) in dpcm_add_paths()
1471 if (stream != SNDRV_PCM_STREAM_CAPTURE) in dpcm_add_paths()
1479 be = dpcm_get_be(card, widget, stream); in dpcm_add_paths()
1492 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_add_paths()
1493 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_add_paths()
1497 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1506 dpcm_set_be_update_state(be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_add_paths()
1519 int stream, struct snd_soc_dapm_widget_list **list, int new) 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()
1532 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_NO); 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()
1544 snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_stop()
1550 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_stop()
1553 if (be->dpcm[stream].users == 0) { in dpcm_be_dai_stop()
1555 stream ? "capture" : "playback", in dpcm_be_dai_stop()
1556 be->dpcm[stream].state); in dpcm_be_dai_stop()
1560 if (--be->dpcm[stream].users != 0) in dpcm_be_dai_stop()
1563 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) { in dpcm_be_dai_stop()
1567 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) { in dpcm_be_dai_stop()
1569 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_stop()
1575 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; 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
1586 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1590 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_startup()
1593 dev_err(be->dev, "ASoC: no backend %s stream\n", in dpcm_be_dai_startup()
1594 stream ? "capture" : "playback"); in dpcm_be_dai_startup()
1599 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1603 if (be->dpcm[stream].users == DPCM_MAX_BE_USERS) { in dpcm_be_dai_startup()
1605 stream ? "capture" : "playback", in dpcm_be_dai_startup()
1606 be->dpcm[stream].state); in dpcm_be_dai_startup()
1610 if (be->dpcm[stream].users++ != 0) in dpcm_be_dai_startup()
1613 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_be_dai_startup()
1614 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_be_dai_startup()
1618 stream ? "capture" : "playback", be->dai_link->name); in dpcm_be_dai_startup()
1620 be_substream->runtime = be->dpcm[stream].runtime; in dpcm_be_dai_startup()
1623 be->dpcm[stream].users--; in dpcm_be_dai_startup()
1624 if (be->dpcm[stream].users < 0) in dpcm_be_dai_startup()
1626 stream ? "capture" : "playback", in dpcm_be_dai_startup()
1627 be->dpcm[stream].state); in dpcm_be_dai_startup()
1629 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_startup()
1632 be->dpcm[stream].be_start = 0; in dpcm_be_dai_startup()
1633 be->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_be_dai_startup()
1640 dpcm_be_dai_startup_rollback(fe, stream, dpcm); in dpcm_be_dai_startup()
1651 int stream = substream->stream; in dpcm_runtime_setup_fe() local
1660 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_fe()
1663 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_fe()
1666 cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_fe()
1682 int stream = substream->stream; in dpcm_runtime_setup_be_format() local
1692 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_format()
1699 * Skip CODECs which don't support the current stream in dpcm_runtime_setup_be_format()
1702 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_format()
1705 codec_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_format()
1718 int stream = substream->stream; in dpcm_runtime_setup_be_chan() local
1728 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_chan()
1736 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_be_chan()
1739 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_chan()
1742 cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_chan()
1753 asoc_rtd_to_codec(be, 0), stream); in dpcm_runtime_setup_be_chan()
1766 int stream = substream->stream; in dpcm_runtime_setup_be_rate() local
1776 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_rate()
1784 * Skip DAIs which don't support the current stream in dpcm_runtime_setup_be_rate()
1787 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_rate()
1790 pcm = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_rate()
1798 int stream) in dpcm_apply_symmetry() argument
1810 /* Symmetry only applies if we've got an active stream. */ in dpcm_apply_symmetry()
1817 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1820 snd_soc_dpcm_get_substream(be, stream); in dpcm_apply_symmetry()
1834 /* Symmetry only applies if we've got an active stream. */ in dpcm_apply_symmetry()
1848 int stream = fe_substream->stream, ret = 0; 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()
1863 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
1871 ret = dpcm_apply_symmetry(fe_substream, stream); 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()
1885 int stream = substream->stream; in dpcm_fe_dai_shutdown() local
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()
1899 /* run the stream stop event */ 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()
1917 snd_soc_dpcm_get_substream(be, stream); 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()
1928 if (be->dpcm[stream].users > 1) in dpcm_be_dai_hw_free()
1931 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_free()
1932 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_hw_free()
1933 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_free()
1934 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) && in dpcm_be_dai_hw_free()
1935 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_hw_free()
1936 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_hw_free()
1944 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_hw_free()
1951 int stream = substream->stream; in dpcm_fe_dai_hw_free() local
1954 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); 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()
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()
1981 be_substream = snd_soc_dpcm_get_substream(be, stream); 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()
1997 memcpy(&be->dpcm[stream].hw_params, &dpcm->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()
2004 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2005 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2006 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE)) in dpcm_be_dai_hw_params()
2016 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_be_dai_hw_params()
2025 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2027 be_substream = snd_soc_dpcm_get_substream(be, stream); 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()
2036 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2037 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2038 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_params()
2039 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) in dpcm_be_dai_hw_params()
2052 int ret, stream = substream->stream; in dpcm_fe_dai_hw_params() local
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()
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()
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()
2094 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_trigger()
2096 snd_soc_dpcm_stream_lock_irqsave_nested(be, stream, flags); in dpcm_be_dai_trigger()
2099 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_trigger()
2107 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2108 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_trigger()
2109 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_trigger()
2110 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2113 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2114 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2117 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_PAUSED) in dpcm_be_dai_trigger()
2124 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2128 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2131 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_trigger()
2134 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2135 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2140 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2144 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2147 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2148 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2149 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2152 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2153 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2155 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2156 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2161 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2165 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2168 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2169 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2172 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2173 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2175 if (be->dpcm[stream].be_start != 0) 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()
2182 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2185 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2191 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2192 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2194 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2195 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2200 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2201 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2203 be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_be_dai_trigger()
2207 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2210 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2211 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2216 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2220 be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND; in dpcm_be_dai_trigger()
2223 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2226 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2227 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2229 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2230 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2235 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2239 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2243 snd_soc_dpcm_stream_unlock_irqrestore(be, stream, flags); in dpcm_be_dai_trigger()
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()
2286 int stream = substream->stream; 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()
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()
2373 int stream = substream->stream; in dpcm_fe_dai_trigger() local
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()
2396 snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_prepare()
2399 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_prepare()
2402 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_prepare()
2403 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_prepare()
2404 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) && in dpcm_be_dai_prepare()
2405 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_prepare()
2415 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_be_dai_prepare()
2424 int stream = substream->stream, ret = 0; in dpcm_fe_dai_prepare() local
2430 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2433 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2440 ret = dpcm_be_dai_prepare(fe, stream); 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()
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()
2466 stream ? "capture" : "playback", 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()
2485 /* run the stream event for each BE */ in dpcm_run_update_shutdown()
2486 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); 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()
2500 stream ? "capture" : "playback", fe->dai_link->name); 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()
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()
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()
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()
2532 /* run the stream event for each BE */ in dpcm_run_update_startup()
2533 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); 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()
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()
2573 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE || in dpcm_run_update_startup()
2574 be->dpcm[stream].state == SND_SOC_DPCM_STATE_NEW) in dpcm_run_update_startup()
2584 int stream; in soc_dpcm_fe_runtime_update() local
2604 for_each_pcm_streams(stream) { 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()
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()
2673 int stream = fe_substream->stream; in dpcm_fe_dai_cleanup() local
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()
2705 int stream = fe_substream->stream; in dpcm_fe_dai_open() local
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()
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()
2741 int stream; in soc_get_playback_capture() local
2744 stream = SNDRV_PCM_STREAM_PLAYBACK; in soc_get_playback_capture()
2747 if (snd_soc_dai_stream_valid(cpu_dai, stream)) { in soc_get_playback_capture()
2754 "No CPU DAIs support playback for stream %s\n", in soc_get_playback_capture()
2760 stream = SNDRV_PCM_STREAM_CAPTURE; in soc_get_playback_capture()
2763 if (snd_soc_dai_stream_valid(cpu_dai, stream)) { in soc_get_playback_capture()
2771 "No CPU DAIs support capture for stream %s\n", in soc_get_playback_capture()
2779 /* Adapt stream for codec2codec links */ in soc_get_playback_capture()
2876 /* DAPM dai link stream work */ in soc_new_pcm()
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()
2961 struct snd_soc_pcm_runtime *be, int stream) 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()
2965 be->dpcm[stream].runtime_update)) in snd_soc_dpcm_be_can_update()
2973 snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_get_substream() argument
2975 return be->pcm->streams[stream].substream; in snd_soc_dpcm_get_substream()
2981 int stream, in snd_soc_dpcm_check_state() argument
2990 for_each_dpcm_fe(be, stream, dpcm) { in snd_soc_dpcm_check_state()
2995 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
3010 * are not running, paused or suspended for the specified stream direction.
3013 struct snd_soc_pcm_runtime *be, int stream) 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()
3027 * running, paused or suspended for the specified stream direction.
3030 struct snd_soc_pcm_runtime *be, int stream) 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()