Lines Matching full:stream

53 						int stream)  in snd_soc_dpcm_stream_lock_irq()  argument
55 snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream)); in snd_soc_dpcm_stream_lock_irq()
58 #define snd_soc_dpcm_stream_lock_irqsave_nested(rtd, stream, flags) \ argument
59 snd_pcm_stream_lock_irqsave_nested(snd_soc_dpcm_get_substream(rtd, stream), flags)
62 int stream) in snd_soc_dpcm_stream_unlock_irq() argument
64 snd_pcm_stream_unlock_irq(snd_soc_dpcm_get_substream(rtd, stream)); in snd_soc_dpcm_stream_unlock_irq()
67 #define snd_soc_dpcm_stream_unlock_irqrestore(rtd, stream, flags) \ argument
68 snd_pcm_stream_unlock_irqrestore(snd_soc_dpcm_get_substream(rtd, stream), flags)
111 int stream, char *buf, size_t size) in dpcm_show_state() argument
113 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; in dpcm_show_state()
120 stream ? "Capture" : "Playback"); in dpcm_show_state()
123 dpcm_state_string(fe->dpcm[stream].state)); in dpcm_show_state()
125 if ((fe->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
126 (fe->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
137 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_show_state()
143 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_show_state()
145 params = &be->dpcm[stream].hw_params; in dpcm_show_state()
152 dpcm_state_string(be->dpcm[stream].state)); in dpcm_show_state()
154 if ((be->dpcm[stream].state >= SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_show_state()
155 (be->dpcm[stream].state <= SND_SOC_DPCM_STATE_STOP)) in dpcm_show_state()
172 int stream; in dpcm_state_read_file() local
186 for_each_pcm_streams(stream) in dpcm_state_read_file()
187 if (snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream)) in dpcm_state_read_file()
188 offset += dpcm_show_state(fe, stream, in dpcm_state_read_file()
220 static void dpcm_create_debugfs_state(struct snd_soc_dpcm *dpcm, int stream) in dpcm_create_debugfs_state() argument
225 stream ? "capture" : "playback"); in dpcm_create_debugfs_state()
242 int stream) in dpcm_create_debugfs_state() argument
251 /* Set FE's runtime_update state; the state is protected via PCM stream lock
258 int stream, enum snd_soc_dpcm_update state) in dpcm_set_fe_update_state() argument
261 snd_soc_dpcm_get_substream(fe, stream); in dpcm_set_fe_update_state()
263 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_set_fe_update_state()
264 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) { in dpcm_set_fe_update_state()
266 fe->dpcm[stream].trigger_pending - 1); in dpcm_set_fe_update_state()
267 fe->dpcm[stream].trigger_pending = 0; in dpcm_set_fe_update_state()
269 fe->dpcm[stream].runtime_update = state; in dpcm_set_fe_update_state()
270 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_set_fe_update_state()
274 int stream, enum snd_soc_dpcm_update state) in dpcm_set_be_update_state() argument
276 be->dpcm[stream].runtime_update = state; in dpcm_set_be_update_state()
283 * @stream: Direction of the PCM stream
284 * @action: Activate stream if 1. Deactivate if -1.
288 * Should typically be called when a stream is opened.
293 int stream, int action) in snd_soc_runtime_action() argument
302 snd_soc_dai_action(dai, stream, action); in snd_soc_runtime_action()
353 /* DPCM stream event, send event to FE and all active BEs. */
501 int stream = substream->stream; in soc_pcm_apply_msb() local
506 struct snd_soc_pcm_stream *pcm_codec = snd_soc_dai_get_pcm_stream(codec_dai, stream); in soc_pcm_apply_msb()
516 struct snd_soc_pcm_stream *pcm_cpu = snd_soc_dai_get_pcm_stream(cpu_dai, stream); in soc_pcm_apply_msb()
572 * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream
575 * @stream: Direction of the PCM stream
577 * Calculates the subset of stream parameters supported by all DAIs
578 * associated with the PCM stream.
581 struct snd_pcm_hardware *hw, int stream) in snd_soc_runtime_calc_hw() argument
596 * Skip CPUs which don't support the current stream type. in snd_soc_runtime_calc_hw()
601 if (!snd_soc_dai_stream_valid(cpu_dai, stream)) in snd_soc_runtime_calc_hw()
604 cpu_stream = snd_soc_dai_get_pcm_stream(cpu_dai, stream); in snd_soc_runtime_calc_hw()
618 * Skip CODECs which don't support the current stream type. in snd_soc_runtime_calc_hw()
623 if (!snd_soc_dai_stream_valid(codec_dai, stream)) in snd_soc_runtime_calc_hw()
626 codec_stream = snd_soc_dai_get_pcm_stream(codec_dai, stream); in snd_soc_runtime_calc_hw()
663 snd_soc_runtime_calc_hw(rtd, hw, substream->stream); in soc_pcm_init_runtime_hw()
716 snd_soc_runtime_deactivate(rtd, substream->stream); in soc_pcm_clean()
853 /* Symmetry only applies if we've already got an active stream. */ in __soc_pcm_open()
860 snd_soc_runtime_activate(rtd, substream->stream); in __soc_pcm_open()
906 /* cancel any delayed stream shutdown that is pending */ in __soc_pcm_prepare()
907 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in __soc_pcm_prepare()
913 snd_soc_dapm_stream_event(rtd, substream->stream, in __soc_pcm_prepare()
918 snd_soc_dai_digital_mute(dai, 0, substream->stream); in __soc_pcm_prepare()
961 if (snd_soc_dai_stream_active(dai, substream->stream) == 1) { in soc_pcm_hw_clean()
963 snd_soc_dai_digital_mute(dai, 1, substream->stream); in soc_pcm_hw_clean()
967 /* run the stream event */ in soc_pcm_hw_clean()
968 snd_soc_dapm_stream_stop(rtd, substream->stream); in soc_pcm_hw_clean()
978 if (snd_soc_dai_stream_valid(dai, substream->stream)) in soc_pcm_hw_clean()
1030 unsigned int tdm_mask = snd_soc_dai_tdm_mask_get(codec_dai, substream->stream); in __soc_pcm_hw_params()
1033 * Skip CODECs which don't support the current stream type, in __soc_pcm_hw_params()
1046 if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) in __soc_pcm_hw_params()
1071 * Skip CPUs which don't support the current stream in __soc_pcm_hw_params()
1074 if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream)) in __soc_pcm_hw_params()
1240 struct snd_soc_pcm_runtime *be, int stream) in dpcm_be_connect() argument
1249 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_connect()
1254 fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_connect()
1255 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_connect()
1274 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_be_connect()
1275 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); in dpcm_be_connect()
1276 list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); in dpcm_be_connect()
1277 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_be_connect()
1280 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_connect()
1281 stream ? "<-" : "->", be->dai_link->name); in dpcm_be_connect()
1283 dpcm_create_debugfs_state(dpcm, stream); in dpcm_be_connect()
1290 struct snd_soc_pcm_runtime *be, int stream) in dpcm_be_reparent() argument
1296 if (!be->dpcm[stream].users) in dpcm_be_reparent()
1299 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_reparent()
1303 for_each_dpcm_fe(be, stream, dpcm) { in dpcm_be_reparent()
1308 stream ? "capture" : "playback", in dpcm_be_reparent()
1310 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_reparent()
1312 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, stream); in dpcm_be_reparent()
1319 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_disconnect() argument
1326 snd_soc_dpcm_stream_lock_irq(fe, stream); in dpcm_be_disconnect()
1327 for_each_dpcm_be_safe(fe, stream, dpcm, d) { in dpcm_be_disconnect()
1329 stream ? "capture" : "playback", in dpcm_be_disconnect()
1336 stream ? "capture" : "playback", fe->dai_link->name, in dpcm_be_disconnect()
1337 stream ? "<-" : "->", dpcm->be->dai_link->name); in dpcm_be_disconnect()
1340 dpcm_be_reparent(fe, dpcm->be, stream); in dpcm_be_disconnect()
1345 snd_soc_dpcm_stream_unlock_irq(fe, stream); in dpcm_be_disconnect()
1356 /* get BE for DAI widget and stream */
1358 struct snd_soc_dapm_widget *widget, int stream) in dpcm_get_be() argument
1372 if (!snd_soc_dpcm_get_substream(be, stream)) in dpcm_get_be()
1376 w = snd_soc_dai_get_widget(dai, stream); in dpcm_get_be()
1408 int stream; in dpcm_end_walk_at_be() local
1410 /* adjust dir to stream */ in dpcm_end_walk_at_be()
1412 stream = SNDRV_PCM_STREAM_PLAYBACK; in dpcm_end_walk_at_be()
1414 stream = SNDRV_PCM_STREAM_CAPTURE; in dpcm_end_walk_at_be()
1416 rtd = dpcm_get_be(card, widget, stream); in dpcm_end_walk_at_be()
1425 int stream, struct snd_soc_dapm_widget_list **list) in dpcm_path_get() argument
1437 paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, list, in dpcm_path_get()
1443 stream ? "capture" : "playback"); in dpcm_path_get()
1446 stream ? "capture" : "playback"); in dpcm_path_get()
1456 static bool dpcm_be_is_active(struct snd_soc_dpcm *dpcm, int stream, in dpcm_be_is_active() argument
1464 struct snd_soc_dapm_widget *widget = snd_soc_dai_get_widget(dai, stream); in dpcm_be_is_active()
1477 static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_prune_paths() argument
1484 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_prune_paths()
1485 if (dpcm_be_is_active(dpcm, stream, *list_)) in dpcm_prune_paths()
1489 stream ? "capture" : "playback", in dpcm_prune_paths()
1492 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_prune_paths()
1500 static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_add_paths() argument
1507 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_add_paths()
1519 if (stream != SNDRV_PCM_STREAM_PLAYBACK) in dpcm_add_paths()
1523 if (stream != SNDRV_PCM_STREAM_CAPTURE) in dpcm_add_paths()
1531 be = dpcm_get_be(card, widget, stream); in dpcm_add_paths()
1544 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_add_paths()
1545 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_add_paths()
1549 err = dpcm_be_connect(fe, be, stream); in dpcm_add_paths()
1558 dpcm_set_be_update_state(be, stream, SND_SOC_DPCM_UPDATE_BE); in dpcm_add_paths()
1571 int stream, struct snd_soc_dapm_widget_list **list, int new) in dpcm_process_paths() argument
1574 return dpcm_add_paths(fe, stream, list); in dpcm_process_paths()
1576 return dpcm_prune_paths(fe, stream, list); in dpcm_process_paths()
1579 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_clear_pending_state() argument
1583 for_each_dpcm_be(fe, stream, dpcm) in dpcm_clear_pending_state()
1584 dpcm_set_be_update_state(dpcm->be, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_clear_pending_state()
1587 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_stop() argument
1593 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_stop()
1596 snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_stop()
1602 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_stop()
1605 if (be->dpcm[stream].users == 0) { in dpcm_be_dai_stop()
1607 stream ? "capture" : "playback", in dpcm_be_dai_stop()
1608 be->dpcm[stream].state); in dpcm_be_dai_stop()
1612 if (--be->dpcm[stream].users != 0) in dpcm_be_dai_stop()
1615 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) { in dpcm_be_dai_stop()
1619 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) { in dpcm_be_dai_stop()
1621 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_stop()
1627 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_stop()
1631 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_startup() argument
1633 struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); in dpcm_be_dai_startup()
1639 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_startup()
1643 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_startup()
1646 dev_err(be->dev, "ASoC: no backend %s stream\n", in dpcm_be_dai_startup()
1647 stream ? "capture" : "playback"); in dpcm_be_dai_startup()
1652 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_startup()
1656 if (be->dpcm[stream].users == DPCM_MAX_BE_USERS) { in dpcm_be_dai_startup()
1658 stream ? "capture" : "playback", in dpcm_be_dai_startup()
1659 be->dpcm[stream].state); in dpcm_be_dai_startup()
1663 if (be->dpcm[stream].users++ != 0) in dpcm_be_dai_startup()
1666 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_NEW) && in dpcm_be_dai_startup()
1667 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) in dpcm_be_dai_startup()
1671 stream ? "capture" : "playback", be->dai_link->name); in dpcm_be_dai_startup()
1676 be->dpcm[stream].users--; in dpcm_be_dai_startup()
1677 if (be->dpcm[stream].users < 0) in dpcm_be_dai_startup()
1679 stream ? "capture" : "playback", in dpcm_be_dai_startup()
1680 be->dpcm[stream].state); in dpcm_be_dai_startup()
1682 be->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_be_dai_startup()
1685 be->dpcm[stream].be_start = 0; in dpcm_be_dai_startup()
1686 be->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_be_dai_startup()
1693 dpcm_be_dai_startup_rollback(fe, stream, dpcm); in dpcm_be_dai_startup()
1704 int stream = substream->stream; in dpcm_runtime_setup_fe() local
1717 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_fe()
1720 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_fe()
1723 cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_fe()
1740 int stream = substream->stream; in dpcm_runtime_setup_be_format() local
1750 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_format()
1757 * Skip CODECs which don't support the current stream in dpcm_runtime_setup_be_format()
1760 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_format()
1763 codec_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_format()
1777 int stream = substream->stream; in dpcm_runtime_setup_be_chan() local
1787 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_chan()
1795 * Skip CPUs which don't support the current stream in dpcm_runtime_setup_be_chan()
1798 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_chan()
1801 cpu_stream = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_chan()
1812 snd_soc_rtd_to_codec(be, 0), stream); in dpcm_runtime_setup_be_chan()
1825 int stream = substream->stream; in dpcm_runtime_setup_be_rate() local
1835 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_runtime_setup_be_rate()
1843 * Skip DAIs which don't support the current stream in dpcm_runtime_setup_be_rate()
1846 if (!snd_soc_dai_stream_valid(dai, stream)) in dpcm_runtime_setup_be_rate()
1849 pcm = snd_soc_dai_get_pcm_stream(dai, stream); in dpcm_runtime_setup_be_rate()
1857 int stream) in dpcm_apply_symmetry() argument
1869 /* Symmetry only applies if we've got an active stream. */ in dpcm_apply_symmetry()
1876 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_apply_symmetry()
1879 snd_soc_dpcm_get_substream(be, stream); in dpcm_apply_symmetry()
1893 /* Symmetry only applies if we've got an active stream. */ in dpcm_apply_symmetry()
1907 int stream = fe_substream->stream, ret = 0; in dpcm_fe_dai_startup() local
1909 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_startup()
1911 ret = dpcm_be_dai_startup(fe, stream); in dpcm_fe_dai_startup()
1922 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in dpcm_fe_dai_startup()
1930 ret = dpcm_apply_symmetry(fe_substream, stream); in dpcm_fe_dai_startup()
1934 dpcm_be_dai_startup_unwind(fe, stream); in dpcm_fe_dai_startup()
1936 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_startup()
1944 int stream = substream->stream; in dpcm_fe_dai_shutdown() local
1948 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_shutdown()
1951 dpcm_be_dai_shutdown(fe, stream); in dpcm_fe_dai_shutdown()
1958 /* run the stream stop event */ in dpcm_fe_dai_shutdown()
1959 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in dpcm_fe_dai_shutdown()
1961 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in dpcm_fe_dai_shutdown()
1962 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_shutdown()
1966 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_free() argument
1972 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_free()
1976 snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_hw_free()
1979 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_free()
1983 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_free()
1987 if (be->dpcm[stream].users > 1) in dpcm_be_dai_hw_free()
1990 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_free()
1991 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_hw_free()
1992 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_free()
1993 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) && in dpcm_be_dai_hw_free()
1994 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_hw_free()
1995 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_hw_free()
2003 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_be_dai_hw_free()
2010 int stream = substream->stream; in dpcm_fe_dai_hw_free() local
2013 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_free()
2022 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_free()
2024 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; in dpcm_fe_dai_hw_free()
2025 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_free()
2031 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_hw_params() argument
2038 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2042 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_hw_params()
2045 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2049 memcpy(&hw_params, &fe->dpcm[stream].hw_params, in dpcm_be_dai_hw_params()
2058 memcpy(&be->dpcm[stream].hw_params, &hw_params, in dpcm_be_dai_hw_params()
2062 if (!snd_soc_dpcm_can_be_params(fe, be, stream)) in dpcm_be_dai_hw_params()
2065 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2066 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2067 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE)) in dpcm_be_dai_hw_params()
2077 be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_be_dai_hw_params()
2086 for_each_dpcm_be_rollback(fe, stream, dpcm) { in dpcm_be_dai_hw_params()
2088 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_hw_params()
2090 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_hw_params()
2094 if (!snd_soc_dpcm_can_be_free_stop(fe, be, stream)) in dpcm_be_dai_hw_params()
2097 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN) && in dpcm_be_dai_hw_params()
2098 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_hw_params()
2099 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && in dpcm_be_dai_hw_params()
2100 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) in dpcm_be_dai_hw_params()
2113 int ret, stream = substream->stream; in dpcm_fe_dai_hw_params() local
2116 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_hw_params()
2118 memcpy(&fe->dpcm[stream].hw_params, params, in dpcm_fe_dai_hw_params()
2120 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_fe_dai_hw_params()
2131 dpcm_be_dai_hw_free(fe, stream); in dpcm_fe_dai_hw_params()
2133 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; in dpcm_fe_dai_hw_params()
2136 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_hw_params()
2142 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, in dpcm_be_dai_trigger() argument
2151 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_trigger()
2155 be_substream = snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_trigger()
2157 snd_soc_dpcm_stream_lock_irqsave_nested(be, stream, flags); in dpcm_be_dai_trigger()
2160 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_trigger()
2168 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2169 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && in dpcm_be_dai_trigger()
2170 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_trigger()
2171 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2174 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2175 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2178 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_PAUSED) in dpcm_be_dai_trigger()
2185 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2189 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2192 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND)) in dpcm_be_dai_trigger()
2195 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2196 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2201 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2205 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2208 if (!be->dpcm[stream].be_start && in dpcm_be_dai_trigger()
2209 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2210 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2213 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2214 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2216 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2217 if (be->dpcm[stream].be_start != 1) in dpcm_be_dai_trigger()
2222 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2226 be->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_be_dai_trigger()
2229 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) && in dpcm_be_dai_trigger()
2230 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_trigger()
2233 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2234 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2236 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2240 if (fe->dpcm[stream].fe_pause) { in dpcm_be_dai_trigger()
2242 fe->dpcm[stream].fe_pause = false; in dpcm_be_dai_trigger()
2243 be->dpcm[stream].be_pause--; in dpcm_be_dai_trigger()
2246 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2252 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2253 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2255 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2256 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2261 if (be->dpcm[stream].be_pause != 0) in dpcm_be_dai_trigger()
2262 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2264 be->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_be_dai_trigger()
2268 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2271 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2272 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2277 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2281 be->dpcm[stream].state = SND_SOC_DPCM_STATE_SUSPEND; in dpcm_be_dai_trigger()
2284 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) in dpcm_be_dai_trigger()
2287 fe->dpcm[stream].fe_pause = true; in dpcm_be_dai_trigger()
2288 be->dpcm[stream].be_pause++; in dpcm_be_dai_trigger()
2290 be->dpcm[stream].be_start--; in dpcm_be_dai_trigger()
2291 if (be->dpcm[stream].be_start != 0) in dpcm_be_dai_trigger()
2296 be->dpcm[stream].be_start++; in dpcm_be_dai_trigger()
2300 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_be_dai_trigger()
2304 snd_soc_dpcm_stream_unlock_irqrestore(be, stream, flags); in dpcm_be_dai_trigger()
2327 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2332 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); in dpcm_dai_trigger_fe_be()
2347 int stream = substream->stream; in dpcm_fe_dai_do_trigger() local
2349 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_fe_dai_do_trigger()
2351 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in dpcm_fe_dai_do_trigger()
2415 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in dpcm_fe_dai_do_trigger()
2419 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in dpcm_fe_dai_do_trigger()
2422 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in dpcm_fe_dai_do_trigger()
2427 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in dpcm_fe_dai_do_trigger()
2434 int stream = substream->stream; in dpcm_fe_dai_trigger() local
2439 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) { in dpcm_fe_dai_trigger()
2440 fe->dpcm[stream].trigger_pending = cmd + 1; in dpcm_fe_dai_trigger()
2448 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_be_dai_prepare() argument
2453 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_be_dai_prepare()
2457 snd_soc_dpcm_get_substream(be, stream); in dpcm_be_dai_prepare()
2460 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_be_dai_prepare()
2463 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream)) in dpcm_be_dai_prepare()
2466 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && in dpcm_be_dai_prepare()
2467 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) && in dpcm_be_dai_prepare()
2468 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) && in dpcm_be_dai_prepare()
2469 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED)) in dpcm_be_dai_prepare()
2479 be->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_be_dai_prepare()
2488 int stream = substream->stream, ret = 0; in dpcm_fe_dai_prepare() local
2494 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE); in dpcm_fe_dai_prepare()
2497 if (list_empty(&fe->dpcm[stream].be_clients)) { in dpcm_fe_dai_prepare()
2507 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_fe_dai_prepare()
2516 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in dpcm_fe_dai_prepare()
2519 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in dpcm_fe_dai_prepare()
2525 static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_shutdown() argument
2528 snd_soc_dpcm_get_substream(fe, stream); in dpcm_run_update_shutdown()
2529 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_shutdown()
2533 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_shutdown()
2545 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); in dpcm_run_update_shutdown()
2548 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_shutdown()
2550 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_shutdown()
2552 /* run the stream event for each BE */ in dpcm_run_update_shutdown()
2553 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_shutdown()
2558 static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream) in dpcm_run_update_startup() argument
2561 snd_soc_dpcm_get_substream(fe, stream); in dpcm_run_update_startup()
2563 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; in dpcm_run_update_startup()
2567 stream ? "capture" : "playback", fe->dai_link->name); in dpcm_run_update_startup()
2570 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_FREE || in dpcm_run_update_startup()
2571 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE) { in dpcm_run_update_startup()
2573 fe->dai_link->name, fe->dpcm[stream].state); in dpcm_run_update_startup()
2579 ret = dpcm_be_dai_startup(fe, stream); in dpcm_run_update_startup()
2584 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_OPEN) in dpcm_run_update_startup()
2587 ret = dpcm_be_dai_hw_params(fe, stream); in dpcm_run_update_startup()
2592 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_HW_PARAMS) in dpcm_run_update_startup()
2595 ret = dpcm_be_dai_prepare(fe, stream); in dpcm_run_update_startup()
2599 /* run the stream event for each BE */ in dpcm_run_update_startup()
2600 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); in dpcm_run_update_startup()
2603 if (fe->dpcm[stream].state == SND_SOC_DPCM_STATE_PREPARE || in dpcm_run_update_startup()
2604 fe->dpcm[stream].state == SND_SOC_DPCM_STATE_STOP) in dpcm_run_update_startup()
2619 ret = dpcm_be_dai_trigger(fe, stream, in dpcm_run_update_startup()
2628 dpcm_be_dai_hw_free(fe, stream); in dpcm_run_update_startup()
2630 dpcm_be_dai_shutdown(fe, stream); in dpcm_run_update_startup()
2633 for_each_dpcm_be(fe, stream, dpcm) { in dpcm_run_update_startup()
2637 if (!snd_soc_dpcm_be_can_update(fe, be, stream)) in dpcm_run_update_startup()
2640 if (be->dpcm[stream].state == SND_SOC_DPCM_STATE_CLOSE || in dpcm_run_update_startup()
2641 be->dpcm[stream].state == SND_SOC_DPCM_STATE_NEW) in dpcm_run_update_startup()
2651 int stream; in soc_dpcm_fe_runtime_update() local
2671 for_each_pcm_streams(stream) { in soc_dpcm_fe_runtime_update()
2674 if (!snd_soc_dai_stream_valid(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2675 !snd_soc_dai_stream_valid(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2679 if (!snd_soc_dai_stream_active(snd_soc_rtd_to_cpu(fe, 0), stream) || in soc_dpcm_fe_runtime_update()
2680 !snd_soc_dai_stream_active(snd_soc_rtd_to_codec(fe, 0), stream)) in soc_dpcm_fe_runtime_update()
2683 paths = dpcm_path_get(fe, stream, &list); in soc_dpcm_fe_runtime_update()
2688 count = dpcm_process_paths(fe, stream, &list, new); in soc_dpcm_fe_runtime_update()
2690 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE); in soc_dpcm_fe_runtime_update()
2692 dpcm_run_update_startup(fe, stream); in soc_dpcm_fe_runtime_update()
2694 dpcm_run_update_shutdown(fe, stream); in soc_dpcm_fe_runtime_update()
2695 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); in soc_dpcm_fe_runtime_update()
2697 dpcm_clear_pending_state(fe, stream); in soc_dpcm_fe_runtime_update()
2698 dpcm_be_disconnect(fe, stream); in soc_dpcm_fe_runtime_update()
2740 int stream = fe_substream->stream; in dpcm_fe_dai_cleanup() local
2745 for_each_dpcm_be(fe, stream, dpcm) in dpcm_fe_dai_cleanup()
2748 dpcm_be_disconnect(fe, stream); in dpcm_fe_dai_cleanup()
2770 int stream = fe_substream->stream; in dpcm_fe_dai_open() local
2774 ret = dpcm_path_get(fe, stream, &list); in dpcm_fe_dai_open()
2779 dpcm_process_paths(fe, stream, &list, 1); in dpcm_fe_dai_open()
2785 dpcm_clear_pending_state(fe, stream); in dpcm_fe_dai_open()
2807 int stream; in soc_get_playback_capture() local
2810 stream = SNDRV_PCM_STREAM_PLAYBACK; in soc_get_playback_capture()
2813 if (snd_soc_dai_stream_valid(cpu_dai, stream)) { in soc_get_playback_capture()
2820 "No CPU DAIs support playback for stream %s\n", in soc_get_playback_capture()
2826 stream = SNDRV_PCM_STREAM_CAPTURE; in soc_get_playback_capture()
2829 if (snd_soc_dai_stream_valid(cpu_dai, stream)) { in soc_get_playback_capture()
2837 "No CPU DAIs support capture for stream %s\n", in soc_get_playback_capture()
2846 /* Adapt stream for codec2codec links */ in soc_get_playback_capture()
2944 /* DAPM dai link stream work */ in soc_new_pcm()
3019 int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream) in snd_soc_dpcm_fe_can_update() argument
3021 if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) in snd_soc_dpcm_fe_can_update()
3029 struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_be_can_update() argument
3031 if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || in snd_soc_dpcm_be_can_update()
3032 ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && in snd_soc_dpcm_be_can_update()
3033 be->dpcm[stream].runtime_update)) in snd_soc_dpcm_be_can_update()
3041 snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_get_substream() argument
3043 return be->pcm->streams[stream].substream; in snd_soc_dpcm_get_substream()
3049 int stream, in snd_soc_dpcm_check_state() argument
3058 for_each_dpcm_fe(be, stream, dpcm) { in snd_soc_dpcm_check_state()
3063 state = dpcm->fe->dpcm[stream].state; in snd_soc_dpcm_check_state()
3078 * are not running, paused or suspended for the specified stream direction.
3081 struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_can_be_free_stop() argument
3089 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_free_stop()
3095 * running, paused or suspended for the specified stream direction.
3098 struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_can_be_params() argument
3107 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_params()
3113 * running or paused for the specified stream direction.
3116 struct snd_soc_pcm_runtime *be, int stream) in snd_soc_dpcm_can_be_prepared() argument
3124 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); in snd_soc_dpcm_can_be_prepared()