Skip to content

Commit cb87fbe

Browse files
committed
ASoC: SOF: Intel: hda-dai: add codec_dai_set_stream callback
The existing code for HDAudio DAIs cannot be extended to other types of DAIs, specific programming sequences need to be abstracted away. Start here with hiding the stream_tag needed by the HDAudio codec_dai. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
1 parent 904ad93 commit cb87fbe

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

sound/soc/sof/intel/hda-dai-ops.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,17 @@ static void hda_reset_hext_stream(struct snd_sof_dev *sdev, struct hdac_ext_stre
155155
snd_hdac_ext_stream_reset(hext_stream);
156156
}
157157

158+
static void hda_codec_dai_set_stream(struct snd_sof_dev *sdev,
159+
struct snd_pcm_substream *substream,
160+
struct hdac_stream *hstream)
161+
{
162+
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
163+
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
164+
165+
/* set the hdac_stream in the codec dai */
166+
snd_soc_dai_set_stream(codec_dai, hstream, substream->stream);
167+
}
168+
158169
static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
159170
struct snd_pcm_substream *substream, int cmd)
160171
{
@@ -274,7 +285,8 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_dma_ops = {
274285
.reset_hext_stream = hda_reset_hext_stream,
275286
.pre_trigger = hda_ipc4_pre_trigger,
276287
.trigger = hda_trigger,
277-
.post_trigger = hda_ipc4_post_trigger
288+
.post_trigger = hda_ipc4_post_trigger,
289+
.codec_dai_set_stream = hda_codec_dai_set_stream,
278290
};
279291

280292
static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = {
@@ -284,6 +296,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = {
284296
.setup_hext_stream = hda_setup_hext_stream,
285297
.reset_hext_stream = hda_reset_hext_stream,
286298
.trigger = hda_trigger,
299+
.codec_dai_set_stream = hda_codec_dai_set_stream,
287300
};
288301

289302
static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
@@ -317,6 +330,7 @@ static const struct hda_dai_widget_dma_ops hda_ipc3_dma_ops = {
317330
.reset_hext_stream = hda_reset_hext_stream,
318331
.trigger = hda_trigger,
319332
.post_trigger = hda_ipc3_post_trigger,
333+
.codec_dai_set_stream = hda_codec_dai_set_stream,
320334
};
321335

322336
static struct hdac_ext_stream *
@@ -343,6 +357,7 @@ static void hda_dspless_setup_hext_stream(struct snd_sof_dev *sdev,
343357
static const struct hda_dai_widget_dma_ops hda_dspless_dma_ops = {
344358
.get_hext_stream = hda_dspless_get_hext_stream,
345359
.setup_hext_stream = hda_dspless_setup_hext_stream,
360+
.codec_dai_set_stream = hda_codec_dai_set_stream,
346361
};
347362

348363
#endif

sound/soc/sof/intel/hda-dai.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream,
182182
snd_hdac_ext_bus_link_set_stream_id(hlink, stream_tag);
183183

184184
/* set the hdac_stream in the codec dai */
185-
snd_soc_dai_set_stream(codec_dai, hdac_stream(hext_stream), substream->stream);
185+
if (ops->codec_dai_set_stream)
186+
ops->codec_dai_set_stream(sdev, substream, hstream);
186187

187188
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
188189
link_bps = codec_dai->driver->playback.sig_bits;

sound/soc/sof/intel/hda.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
915915
* @pre_trigger: Function pointer for DAI DMA pre-trigger actions
916916
* @trigger: Function pointer for DAI DMA trigger actions
917917
* @post_trigger: Function pointer for DAI DMA post-trigger actions
918+
* @codec_dai_set_stream: Function pointer to set codec-side stream information
918919
*/
919920
struct hda_dai_widget_dma_ops {
920921
struct hdac_ext_stream *(*get_hext_stream)(struct snd_sof_dev *sdev,
@@ -934,6 +935,9 @@ struct hda_dai_widget_dma_ops {
934935
struct snd_pcm_substream *substream, int cmd);
935936
int (*post_trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
936937
struct snd_pcm_substream *substream, int cmd);
938+
void (*codec_dai_set_stream)(struct snd_sof_dev *sdev,
939+
struct snd_pcm_substream *substream,
940+
struct hdac_stream *hstream);
937941
};
938942

939943
const struct hda_dai_widget_dma_ops *

0 commit comments

Comments
 (0)