Lines Matching +full:dual +full:- +full:direction
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
3 // This file is provided under a dual BSD/GPLv2 license. When using or
13 #include "../sof-priv.h"
14 #include "../sof-audio.h"
46 fe_substream = snd_soc_dpcm_get_substream(dpcm->fe, dir); in hda_check_fes()
47 fe_hstream = fe_substream->runtime->private_data; in hda_check_fes()
48 if (fe_hstream->stream_tag == stream_tag) in hda_check_fes()
64 int stream_dir = substream->stream; in hda_link_stream_assign()
66 if (!bus->ppcap) { in hda_link_stream_assign()
67 dev_err(bus->dev, "stream type not supported\n"); in hda_link_stream_assign()
71 list_for_each_entry(stream, &bus->stream_list, list) { in hda_link_stream_assign()
74 if (stream->direction != substream->stream) in hda_link_stream_assign()
80 if (!hstream->link_locked) { in hda_link_stream_assign()
81 if (stream->opened) { in hda_link_stream_assign()
87 stream->stream_tag)) { in hda_link_stream_assign()
98 hda_stream->host_reserved = 1; in hda_link_stream_assign()
109 if (!res->decoupled) in hda_link_stream_assign()
111 spin_lock_irq(&bus->reg_lock); in hda_link_stream_assign()
112 res->link_locked = 1; in hda_link_stream_assign()
113 res->link_substream = substream; in hda_link_stream_assign()
114 spin_unlock_irq(&bus->reg_lock); in hda_link_stream_assign()
123 struct hdac_stream *hstream = &stream->hstream; in hda_link_dma_params()
124 unsigned char stream_tag = hstream->stream_tag; in hda_link_dma_params()
125 struct hdac_bus *bus = hstream->bus; in hda_link_dma_params()
132 format_val = snd_hdac_calc_stream_format(params->s_freq, params->ch, in hda_link_dma_params()
133 params->format, in hda_link_dma_params()
134 params->link_bps, 0); in hda_link_dma_params()
136 dev_dbg(bus->dev, "format_val=%d, rate=%d, ch=%d, format=%d\n", in hda_link_dma_params()
137 format_val, params->s_freq, params->ch, params->format); in hda_link_dma_params()
141 if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) { in hda_link_dma_params()
142 list_for_each_entry(link, &bus->hlink_list, list) { in hda_link_dma_params()
143 if (link->index == params->link_index) in hda_link_dma_params()
149 stream->link_prepared = 1; in hda_link_dma_params()
154 /* Send DAI_CONFIG IPC to the DAI that matches the dai_name and direction */
163 list_for_each_entry(sof_dai, &hda_stream->sdev->dai_list, list) { in hda_link_config_ipc()
164 if (!sof_dai->cpu_dai_name) in hda_link_config_ipc()
167 if (!strcmp(dai_name, sof_dai->cpu_dai_name) && in hda_link_config_ipc()
168 dir == sof_dai->comp_dai.direction) { in hda_link_config_ipc()
169 config = sof_dai->dai_config; in hda_link_config_ipc()
172 dev_err(hda_stream->sdev->dev, in hda_link_config_ipc()
174 sof_dai->name); in hda_link_config_ipc()
175 return -EINVAL; in hda_link_config_ipc()
179 config->hda.link_dma_ch = channel; in hda_link_config_ipc()
182 ret = sof_ipc_tx_message(hda_stream->sdev->ipc, in hda_link_config_ipc()
183 config->hdr.cmd, in hda_link_config_ipc()
185 config->hdr.size, in hda_link_config_ipc()
189 dev_err(hda_stream->sdev->dev, in hda_link_config_ipc()
191 sof_dai->name); in hda_link_config_ipc()
196 return -EINVAL; in hda_link_config_ipc()
203 struct hdac_stream *hstream = substream->runtime->private_data; in hda_link_hw_params()
204 struct hdac_bus *bus = hstream->bus; in hda_link_hw_params()
219 return -EBUSY; in hda_link_hw_params()
224 stream_tag = hdac_stream(link_dev)->stream_tag; in hda_link_hw_params()
229 ret = hda_link_config_ipc(hda_stream, dai->name, stream_tag - 1, in hda_link_hw_params()
230 substream->stream); in hda_link_hw_params()
234 link = snd_hdac_ext_bus_get_link(bus, codec_dai->component->name); in hda_link_hw_params()
236 return -EINVAL; in hda_link_hw_params()
239 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in hda_link_hw_params()
247 p_params.stream = substream->stream; in hda_link_hw_params()
248 p_params.link_dma_id = stream_tag - 1; in hda_link_hw_params()
249 p_params.link_index = link->index; in hda_link_hw_params()
252 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in hda_link_hw_params()
253 p_params.link_bps = codec_dai->driver->playback.sig_bits; in hda_link_hw_params()
255 p_params.link_bps = codec_dai->driver->capture.sig_bits; in hda_link_hw_params()
266 snd_soc_component_get_drvdata(dai->component); in hda_link_pcm_prepare()
268 int stream = substream->stream; in hda_link_pcm_prepare()
270 if (link_dev->link_prepared) in hda_link_pcm_prepare()
273 dev_dbg(sdev->dev, "hda: prepare stream dir %d\n", substream->stream); in hda_link_pcm_prepare()
275 return hda_link_hw_params(substream, &rtd->dpcm[stream].hw_params, in hda_link_pcm_prepare()
292 hstream = substream->runtime->private_data; in hda_link_pcm_trigger()
293 bus = hstream->bus; in hda_link_pcm_trigger()
296 link = snd_hdac_ext_bus_get_link(bus, asoc_rtd_to_codec(rtd, 0)->component->name); in hda_link_pcm_trigger()
298 return -EINVAL; in hda_link_pcm_trigger()
302 dev_dbg(dai->dev, "In %s cmd=%d\n", __func__, cmd); in hda_link_pcm_trigger()
308 dev_err(dai->dev, in hda_link_pcm_trigger()
324 ret = hda_link_config_ipc(hda_stream, dai->name, in hda_link_pcm_trigger()
325 DMA_CHAN_INVALID, substream->stream); in hda_link_pcm_trigger()
329 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in hda_link_pcm_trigger()
330 stream_tag = hdac_stream(link_dev)->stream_tag; in hda_link_pcm_trigger()
334 link_dev->link_prepared = 0; in hda_link_pcm_trigger()
341 return -EINVAL; in hda_link_pcm_trigger()
358 hstream = substream->runtime->private_data; in hda_link_hw_free()
359 bus = hstream->bus; in hda_link_hw_free()
364 dev_dbg(dai->dev, in hda_link_hw_free()
366 return -EINVAL; in hda_link_hw_free()
372 ret = hda_link_config_ipc(hda_stream, dai->name, DMA_CHAN_INVALID, in hda_link_hw_free()
373 substream->stream); in hda_link_hw_free()
377 link = snd_hdac_ext_bus_get_link(bus, asoc_rtd_to_codec(rtd, 0)->component->name); in hda_link_hw_free()
379 return -EINVAL; in hda_link_hw_free()
381 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in hda_link_hw_free()
382 stream_tag = hdac_stream(link_dev)->stream_tag; in hda_link_hw_free()
388 link_dev->link_prepared = 0; in hda_link_hw_free()
391 hda_stream->host_reserved = 0; in hda_link_hw_free()