Lines Matching full:stream
53 static int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream)
55 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE)
63 struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_be_can_update() argument
65 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
66 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
67 be->dpcm[stream].runtime_update)) in snd_soc_dpcm_be_can_update()
74 int stream, in snd_soc_dpcm_check_state() argument
83 for_each_dpcm_fe(be, stream, dpcm) { in snd_soc_dpcm_check_state()
88 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
103 * are not running, paused or suspended for the specified stream direction.
106 struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_can_be_free_stop() argument
114 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_free_stop()
119 * running, paused or suspended for the specified stream direction.
122 struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_can_be_params() argument
131 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_params()
136 * running or paused for the specified stream direction.
139 struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_can_be_prepared() argument
147 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_prepared()
191 int stream, char *buf, size_t size) in dpcm_show_state() argument
193 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
200 stream ? "Capture" : "Playback"); in dpcm_show_state()
203 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
205 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
206 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
217 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
223 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_show_state()
225 params = &be->dpcm[stream].hw_params; in dpcm_show_state()
232 dpcm_state_string(be->dpcm[stream].state)); in dpcm_show_state()
234 if ((be->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
235 (be->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
252 int stream; in dpcm_state_read_file() local
266 for_each_pcm_streams(stream) in dpcm_state_read_file()
267 if (snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream)) in dpcm_state_read_file()
268 offset += dpcm_show_state(fe, stream, in dpcm_state_read_file()
300 static void dpcm_create_debugfs_state(struct snd_soc_dpcm *dpcm, int stream) in dpcm_create_debugfs_state() argument
305 snd_pcm_direction_name(stream)); in dpcm_create_debugfs_state()
322 int stream) in dpcm_create_debugfs_state() argument
331 /* Set FE's runtime_update state; the state is protected via PCM stream lock
338 int stream, enum snd_soc_dpcm_update state) in dpcm_set_fe_update_state() argument
341 snd_soc_dpcm_get_substream(fe, stream); in dpcm_set_fe_update_state()
344 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
346 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
347 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
349 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
354 int stream, enum snd_soc_dpcm_update state) in dpcm_set_be_update_state() argument
356 be->dpcm[stream].runtime_update = state; in dpcm_set_be_update_state()
363 * @stream: Direction of the PCM stream
364 * @action: Activate stream if 1. Deactivate if -1.
368 * Should typically be called when a stream is opened.
373 int stream, int action) in snd_soc_runtime_action() argument
382 snd_soc_dai_action(dai, stream, action); in snd_soc_runtime_action()
418 /* DPCM stream event, send event to FE and all active BEs. */
568 int stream = substream->stream; in soc_pcm_apply_msb() local
573 const struct snd_soc_pcm_stream *pcm_codec = snd_soc_dai_get_pcm_stream(codec_dai, stream); in soc_pcm_apply_msb()
583 const struct snd_soc_pcm_stream *pcm_cpu = snd_soc_dai_get_pcm_stream(cpu_dai, stream); in soc_pcm_apply_msb()
639 * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
642 * @stream: Direction of the PCM stream
644 * Calculates the subset of stream parameters supported by all DAIs
645 * associated with the PCM stream.
648 struct snd_pcm_hardware *hw, int stream) in snd_soc_runtime_calc_hw() argument
663 * Skip CPUs which don't support the current stream type. in snd_soc_runtime_calc_hw()
668 if (!snd_soc_dai_stream_valid(cpu_dai, stream)) in snd_soc_runtime_calc_hw()
671 cpu_stream = snd_soc_dai_get_pcm_stream(cpu_dai, stream); in snd_soc_runtime_calc_hw()
685 * Skip CODECs which don't support the current stream type. in snd_soc_runtime_calc_hw()
690 if (!snd_soc_dai_stream_valid(codec_dai, stream)) in snd_soc_runtime_calc_hw()
693 codec_stream = snd_soc_dai_get_pcm_stream(codec_dai, stream); in snd_soc_runtime_calc_hw()
730 snd_soc_runtime_calc_hw(rtd, hw, substream->stream); in soc_pcm_init_runtime_hw()
783 snd_soc_runtime_deactivate(rtd, substream->stream); in soc_pcm_clean()
919 /* Symmetry only applies if we've already got an active stream. */ in __soc_pcm_open()
926 snd_soc_runtime_activate(rtd, substream->stream); in __soc_pcm_open()
972 /* cancel any delayed stream shutdown that is pending */ in __soc_pcm_prepare()
973 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in __soc_pcm_prepare()
979 snd_soc_dapm_stream_event(rtd, substream->stream, in __soc_pcm_prepare()
984 snd_soc_dai_digital_mute(dai, 0, substream->stream); in __soc_pcm_prepare()
1040 if (snd_soc_dai_stream_active(dai, substream->stream) == 1) { in soc_pcm_hw_clean()
1042 snd_soc_dai_digital_mute(dai, 1, substream->stream); in soc_pcm_hw_clean()
1046 /* run the stream event */ in soc_pcm_hw_clean()
1047 snd_soc_dapm_stream_stop(rtd, substream->stream); in soc_pcm_hw_clean()
1057 if (snd_soc_dai_stream_valid(dai, substream->stream)) in soc_pcm_hw_clean()
1109 unsigned int tdm_mask = snd_soc_dai_tdm_mask_get(codec_dai, substream->stream); in __soc_pcm_hw_params()
1112 * Skip CODECs which don't support the current stream type, in __soc_pcm_hw_params()
1125 if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) in __soc_pcm_hw_params()
1150 * Skip CPUs which don't support the current stream in __soc_pcm_hw_params()
1153 if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) in __soc_pcm_hw_params()
1319 struct snd_soc_pcm_runtime *be, int stream) in dpcm_be_connect() argument
1328 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_connect()
1333 fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_connect()
1334 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_connect()
1354 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1355 list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); in dpcm_be_connect()
1359 snd_pcm_direction_name(stream), fe->dai_link->name, in dpcm_be_connect()
1360 stream ? "<-" : "->", be->dai_link->name); in dpcm_be_connect()
1362 dpcm_create_debugfs_state(dpcm, stream); in dpcm_be_connect()
1369 struct snd_soc_pcm_runtime *be, int stream) in dpcm_be_reparent() argument
1375 if (!be->dpcm[stream].users) in dpcm_be_reparent()
1378 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_reparent()
1382 for_each_dpcm_fe(be, stream, dpcm) { in dpcm_be_reparent()
1387 snd_pcm_direction_name(stream), in dpcm_be_reparent()
1389 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_reparent()
1391 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1398 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
1401 struct snd_pcm_substream *substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_disconnect()
1407 for_each_dpcm_be_safe(fe, stream, dpcm, d) { in dpcm_be_disconnect()
1409 snd_pcm_direction_name(stream), in dpcm_be_disconnect()
1416 snd_pcm_direction_name(stream), fe->dai_link->name, in dpcm_be_disconnect()
1417 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_disconnect()
1420 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1436 /* get BE for DAI widget and stream */
1438 struct snd_soc_dapm_widget *widget, int stream) in dpcm_get_be() argument
1452 if (!snd_soc_dpcm_get_substream(be, stream)) in dpcm_get_be()
1456 w = snd_soc_dai_get_widget(dai, stream); in dpcm_get_be()
1488 int stream; in dpcm_end_walk_at_be() local
1490 /* adjust dir to stream */ in dpcm_end_walk_at_be()
1492 stream = SNDRV_PCM_STREAM_PLAYBACK; in dpcm_end_walk_at_be()
1494 stream = SNDRV_PCM_STREAM_CAPTURE; in dpcm_end_walk_at_be()
1496 rtd = dpcm_get_be(card, widget, stream); in dpcm_end_walk_at_be()
1505 int stream, struct snd_soc_dapm_widget_list **list) in dpcm_path_get() argument
1517 paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, list, in dpcm_path_get()
1523 snd_pcm_direction_name(stream)); in dpcm_path_get()
1526 snd_pcm_direction_name(stream)); in dpcm_path_get()
1536 static bool dpcm_be_is_active(struct snd_soc_dpcm *dpcm, int stream, in dpcm_be_is_active() argument
1544 struct snd_soc_dapm_widget *widget = snd_soc_dai_get_widget(dai, stream); in dpcm_be_is_active()
1557 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1564 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1565 if (dpcm_be_is_active(dpcm, stream, *list_)) in dpcm_prune_paths()
1569 snd_pcm_direction_name(stream), in dpcm_prune_paths()
1572 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_prune_paths()
1580 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1587 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_add_paths()
1599 if (stream != SNDRV_PCM_STREAM_PLAYBACK) in dpcm_add_paths()
1603 if (stream != SNDRV_PCM_STREAM_CAPTURE) in dpcm_add_paths()
1611 be = dpcm_get_be(card, widget, stream); in dpcm_add_paths()
1624 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_add_paths()
1625 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_add_paths()
1629 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1638 dpcm_set_be_update_state(be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_add_paths()
1651 int stream, struct snd_soc_dapm_widget_list **list, int new) in dpcm_process_paths() argument
1654 return dpcm_add_paths(fe, stream, list); in dpcm_process_paths()
1656 return dpcm_prune_paths(fe, stream, list); in dpcm_process_paths()
1659 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_clear_pending_state() argument
1663 for_each_dpcm_be(fe, stream, dpcm) in dpcm_clear_pending_state()
1664 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_clear_pending_state()
1667 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_stop() argument
1673 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_stop()
1676 snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_stop()
1682 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_stop()
1685 if (be->dpcm[stream].users == 0) { in dpcm_be_dai_stop()
1687 snd_pcm_direction_name(stream), in dpcm_be_dai_stop()
1688 be->dpcm[stream].state); in dpcm_be_dai_stop()
1692 if (--be->dpcm[stream].users != 0) in dpcm_be_dai_stop()
1695 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) { in dpcm_be_dai_stop()
1699 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) { in dpcm_be_dai_stop()
1701 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_stop()
1707 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_stop()
1711 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_startup() argument
1713 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_dai_startup()
1719 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1723 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_startup()
1726 dev_err(be->dev, "ASoC: no backend %s stream\n", in dpcm_be_dai_startup()
1727 snd_pcm_direction_name(stream)); in dpcm_be_dai_startup()
1732 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1736 if (be->dpcm[stream].users == DPCM_MAX_BE_USERS) { in dpcm_be_dai_startup()
1738 snd_pcm_direction_name(stream), in dpcm_be_dai_startup()
1739 be->dpcm[stream].state); in dpcm_be_dai_startup()
1743 if (be->dpcm[stream].users++ != 0) in dpcm_be_dai_startup()
1746 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_be_dai_startup()
1747 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_be_dai_startup()
1751 snd_pcm_direction_name(stream), be->dai_link->name); in dpcm_be_dai_startup()
1756 be->dpcm[stream].users--; in dpcm_be_dai_startup()
1757 if (be->dpcm[stream].users < 0) in dpcm_be_dai_startup()
1759 snd_pcm_direction_name(stream), in dpcm_be_dai_startup()
1760 be->dpcm[stream].state); in dpcm_be_dai_startup()
1762 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_startup()
1765 be->dpcm[stream].be_start = 0; in dpcm_be_dai_startup()
1766 be->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_be_dai_startup()
1773 dpcm_be_dai_startup_rollback(fe, stream, dpcm); in dpcm_be_dai_startup()
1784 int stream = substream->stream; in dpcm_runtime_setup_fe() local
1797 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_fe()
1800 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_fe()
1803 cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_fe()
1820 int stream = substream->stream; in dpcm_runtime_setup_be_format() local
1830 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_format()
1837 * Skip CODECs which don't support the current stream in dpcm_runtime_setup_be_format()
1840 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_format()
1843 codec_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_format()
1857 int stream = substream->stream; in dpcm_runtime_setup_be_chan() local
1867 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_chan()
1875 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_be_chan()
1878 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_chan()
1881 cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_chan()
1892 snd_soc_rtd_to_codec(be, 0), stream); in dpcm_runtime_setup_be_chan()
1905 int stream = substream->stream; in dpcm_runtime_setup_be_rate() local
1915 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_rate()
1923 * Skip DAIs which don't support the current stream in dpcm_runtime_setup_be_rate()
1926 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_rate()
1929 pcm = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_rate()
1937 int stream) in dpcm_apply_symmetry() argument
1949 /* Symmetry only applies if we've got an active stream. */ in dpcm_apply_symmetry()
1956 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1959 snd_soc_dpcm_get_substream(be, stream); in dpcm_apply_symmetry()
1973 /* Symmetry only applies if we've got an active stream. */ in dpcm_apply_symmetry()
1987 int stream = fe_substream->stream, ret = 0; in dpcm_fe_dai_startup() local
1989 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_startup()
1991 ret = dpcm_be_dai_startup(fe, stream); in dpcm_fe_dai_startup()
2002 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
2010 ret = dpcm_apply_symmetry(fe_substream, stream); in dpcm_fe_dai_startup()
2014 dpcm_be_dai_startup_unwind(fe, stream); in dpcm_fe_dai_startup()
2016 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_startup()
2024 int stream = substream->stream; in dpcm_fe_dai_shutdown() local
2028 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_shutdown()
2031 dpcm_be_dai_shutdown(fe, stream); in dpcm_fe_dai_shutdown()
2038 /* run the stream stop event */ in dpcm_fe_dai_shutdown()
2039 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in dpcm_fe_dai_shutdown()
2041 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
2042 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_shutdown()
2046 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_free() argument
2052 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_free()
2056 snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_hw_free()
2059 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_free()
2063 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_free()
2067 if (be->dpcm[stream].users > 1) in dpcm_be_dai_hw_free()
2070 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_free()
2071 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_hw_free()
2072 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_free()
2073 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) && in dpcm_be_dai_hw_free()
2074 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_hw_free()
2075 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_hw_free()
2083 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_hw_free()
2090 int stream = substream->stream; in dpcm_fe_dai_hw_free() local
2093 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_free()
2102 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_free()
2104 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
2105 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_free()
2111 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_params() argument
2118 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2122 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_hw_params()
2125 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2129 memcpy(&hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2138 memcpy(&be->dpcm[stream].hw_params, &hw_params, in dpcm_be_dai_hw_params()
2142 if (!snd_soc_dpcm_can_be_params(fe, be, stream)) in dpcm_be_dai_hw_params()
2145 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2146 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2147 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE)) in dpcm_be_dai_hw_params()
2157 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_be_dai_hw_params()
2166 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2168 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_hw_params()
2170 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2174 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_params()
2177 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2178 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2179 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_params()
2180 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) in dpcm_be_dai_hw_params()
2193 int ret, stream = substream->stream; in dpcm_fe_dai_hw_params() local
2196 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_params()
2198 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2200 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_fe_dai_hw_params()
2211 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_params()
2213 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2216 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_params()
2222 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_trigger() argument
2231 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_trigger()
2235 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_trigger()
2240 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_trigger()
2248 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2249 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_trigger()
2250 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_trigger()
2251 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2254 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2255 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2258 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_PAUSED) in dpcm_be_dai_trigger()
2265 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2269 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2272 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_trigger()
2275 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2276 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2281 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2285 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2288 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2289 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2290 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2293 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2294 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2296 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2297 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2302 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2306 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2309 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2310 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2313 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2314 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2316 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2320 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2322 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2323 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2326 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2332 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2333 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2335 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2336 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2341 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2342 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2344 be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_be_dai_trigger()
2348 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2351 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2352 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2357 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2361 be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND; in dpcm_be_dai_trigger()
2364 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2367 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2368 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2370 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2371 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2376 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2380 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2407 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2412 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2427 int stream = substream->stream; in dpcm_fe_dai_do_trigger() local
2429 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2431 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2487 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2491 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2494 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2499 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2506 int stream = substream->stream; in dpcm_fe_dai_trigger() local
2511 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2512 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2520 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_prepare() argument
2525 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_prepare()
2529 snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_prepare()
2532 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_prepare()
2535 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream)) in dpcm_be_dai_prepare()
2538 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_prepare()
2539 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_prepare()
2540 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) && in dpcm_be_dai_prepare()
2541 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_prepare()
2551 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_be_dai_prepare()
2566 int stream = substream->stream, ret = 0; in dpcm_fe_dai_prepare() local
2572 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2575 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2585 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_fe_dai_prepare()
2594 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2597 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_prepare()
2609 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_shutdown() argument
2614 snd_pcm_direction_name(stream), fe->dai_link->name); in dpcm_run_update_shutdown()
2616 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); in dpcm_run_update_shutdown()
2618 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_shutdown()
2620 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_shutdown()
2622 /* run the stream event for each BE */ in dpcm_run_update_shutdown()
2623 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_shutdown()
2628 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_startup() argument
2634 snd_pcm_direction_name(stream), fe->dai_link->name); in dpcm_run_update_startup()
2637 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2638 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) { in dpcm_run_update_startup()
2640 fe->dai_link->name, fe->dpcm[stream].state); in dpcm_run_update_startup()
2646 ret = dpcm_be_dai_startup(fe, stream); in dpcm_run_update_startup()
2651 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2654 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_run_update_startup()
2659 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2662 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_run_update_startup()
2666 /* run the stream event for each BE */ in dpcm_run_update_startup()
2667 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_startup()
2670 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2671 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2674 ret = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_START); in dpcm_run_update_startup()
2681 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_startup()
2683 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_startup()
2686 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_run_update_startup()
2690 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_run_update_startup()
2693 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE || in dpcm_run_update_startup()
2694 be->dpcm[stream].state == SND_SOC_DPCM_STATE_NEW) in dpcm_run_update_startup()
2704 int stream; in soc_dpcm_fe_runtime_update() local
2724 for_each_pcm_streams(stream) { in soc_dpcm_fe_runtime_update()
2727 if (!snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2728 !snd_soc_dai_stream_valid(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2732 if (!snd_soc_dai_stream_active(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2733 !snd_soc_dai_stream_active(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2736 paths = dpcm_path_get(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2741 count = dpcm_process_paths(fe, stream, &list, new); in soc_dpcm_fe_runtime_update()
2743 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE); in soc_dpcm_fe_runtime_update()
2745 dpcm_run_update_startup(fe, stream); in soc_dpcm_fe_runtime_update()
2747 dpcm_run_update_shutdown(fe, stream); in soc_dpcm_fe_runtime_update()
2748 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in soc_dpcm_fe_runtime_update()
2750 dpcm_clear_pending_state(fe, stream); in soc_dpcm_fe_runtime_update()
2751 dpcm_be_disconnect(fe, stream); in soc_dpcm_fe_runtime_update()
2793 int stream = fe_substream->stream; in dpcm_fe_dai_cleanup() local
2798 for_each_dpcm_be(fe, stream, dpcm) in dpcm_fe_dai_cleanup()
2801 dpcm_be_disconnect(fe, stream); in dpcm_fe_dai_cleanup()
2823 int stream = fe_substream->stream; in dpcm_fe_dai_open() local
2827 ret = dpcm_path_get(fe, stream, &list); in dpcm_fe_dai_open()
2832 dpcm_process_paths(fe, stream, &list, 1); in dpcm_fe_dai_open()
2838 dpcm_clear_pending_state(fe, stream); in dpcm_fe_dai_open()
2864 /* Adapt stream for codec2codec links */ in soc_get_playback_capture()
2975 /* DAPM dai link stream work */ in soc_new_pcm()
3051 snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_get_substream() argument
3053 return be->pcm->streams[stream].substream; in snd_soc_dpcm_get_substream()