ASoC: Intel/SOF: use set_stream() instead of set_tdm_slots() for HDAudio
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fri, 24 Dec 2021 02:10:32 +0000 (10:10 +0800)
committerMark Brown <broonie@kernel.org>
Fri, 24 Dec 2021 14:06:48 +0000 (14:06 +0000)
Overloading the tx_mask with a linear value is asking for trouble and
only works because the codec_dai hw_params() is called before the
cpu_dai hw_params().

Move to the more generic set_stream() API to pass the hdac_stream
information.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20211224021034.26635-6-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/hdac_hda.c
sound/soc/intel/skylake/skl-pcm.c
sound/soc/sof/intel/hda-dai.c

index 390dd6c..de5955d 100644 (file)
@@ -46,9 +46,8 @@ static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
                                  struct snd_soc_dai *dai);
 static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
                                struct snd_soc_dai *dai);
-static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
-                                    unsigned int tx_mask, unsigned int rx_mask,
-                                    int slots, int slot_width);
+static int hdac_hda_dai_set_stream(struct snd_soc_dai *dai, void *stream,
+                                  int direction);
 static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,
                                                 struct snd_soc_dai *dai);
 
@@ -58,7 +57,7 @@ static const struct snd_soc_dai_ops hdac_hda_dai_ops = {
        .prepare = hdac_hda_dai_prepare,
        .hw_params = hdac_hda_dai_hw_params,
        .hw_free = hdac_hda_dai_hw_free,
-       .set_tdm_slot = hdac_hda_dai_set_tdm_slot,
+       .set_stream = hdac_hda_dai_set_stream,
 };
 
 static struct snd_soc_dai_driver hdac_hda_dais[] = {
@@ -180,21 +179,22 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = {
 
 };
 
-static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
-                                    unsigned int tx_mask, unsigned int rx_mask,
-                                    int slots, int slot_width)
+static int hdac_hda_dai_set_stream(struct snd_soc_dai *dai,
+                                  void *stream, int direction)
 {
        struct snd_soc_component *component = dai->component;
        struct hdac_hda_priv *hda_pvt;
        struct hdac_hda_pcm *pcm;
+       struct hdac_stream *hstream;
+
+       if (!stream)
+               return -EINVAL;
 
        hda_pvt = snd_soc_component_get_drvdata(component);
        pcm = &hda_pvt->pcm[dai->id];
+       hstream = (struct hdac_stream *)stream;
 
-       if (tx_mask)
-               pcm->stream_tag[SNDRV_PCM_STREAM_PLAYBACK] = tx_mask;
-       else
-               pcm->stream_tag[SNDRV_PCM_STREAM_CAPTURE] = rx_mask;
+       pcm->stream_tag[direction] = hstream->stream_tag;
 
        return 0;
 }
index 9ecaf6a..8378c18 100644 (file)
@@ -562,11 +562,8 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,
 
        stream_tag = hdac_stream(link_dev)->stream_tag;
 
-       /* set the stream tag in the codec dai dma params  */
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               snd_soc_dai_set_tdm_slot(codec_dai, stream_tag, 0, 0, 0);
-       else
-               snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0);
+       /* set the hdac_stream in the codec dai */
+       snd_soc_dai_set_stream(codec_dai, hdac_stream(link_dev), substream->stream);
 
        p_params.s_fmt = snd_pcm_format_width(params_format(params));
        p_params.ch = params_channels(params);
index 6381f2b..cd12589 100644 (file)
@@ -243,11 +243,8 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream,
        if (!link)
                return -EINVAL;
 
-       /* set the stream tag in the codec dai dma params */
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               snd_soc_dai_set_tdm_slot(codec_dai, stream_tag, 0, 0, 0);
-       else
-               snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0);
+       /* set the hdac_stream in the codec dai */
+       snd_soc_dai_set_stream(codec_dai, hdac_stream(link_dev), substream->stream);
 
        p_params.s_fmt = snd_pcm_format_width(params_format(params));
        p_params.ch = params_channels(params);