Skip to content

Commit 6958866

Browse files
committed
ASoC: Intel/SOF: use set_stream() instead of set_tdm_slots() for HDAudio
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>
1 parent 5c9ff7a commit 6958866

3 files changed

Lines changed: 15 additions & 21 deletions

File tree

sound/soc/codecs/hdac_hda.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
4646
struct snd_soc_dai *dai);
4747
static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
4848
struct snd_soc_dai *dai);
49-
static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
50-
unsigned int tx_mask, unsigned int rx_mask,
51-
int slots, int slot_width);
49+
static int hdac_hda_dai_set_stream(struct snd_soc_dai *dai, void *stream,
50+
int direction);
5251
static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,
5352
struct snd_soc_dai *dai);
5453

@@ -58,7 +57,7 @@ static const struct snd_soc_dai_ops hdac_hda_dai_ops = {
5857
.prepare = hdac_hda_dai_prepare,
5958
.hw_params = hdac_hda_dai_hw_params,
6059
.hw_free = hdac_hda_dai_hw_free,
61-
.set_tdm_slot = hdac_hda_dai_set_tdm_slot,
60+
.set_stream = hdac_hda_dai_set_stream,
6261
};
6362

6463
static struct snd_soc_dai_driver hdac_hda_dais[] = {
@@ -180,21 +179,22 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = {
180179

181180
};
182181

183-
static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
184-
unsigned int tx_mask, unsigned int rx_mask,
185-
int slots, int slot_width)
182+
static int hdac_hda_dai_set_stream(struct snd_soc_dai *dai,
183+
void *stream, int direction)
186184
{
187185
struct snd_soc_component *component = dai->component;
188186
struct hdac_hda_priv *hda_pvt;
189187
struct hdac_hda_pcm *pcm;
188+
struct hdac_stream *hstream;
189+
190+
if (!stream)
191+
return -EINVAL;
190192

191193
hda_pvt = snd_soc_component_get_drvdata(component);
192194
pcm = &hda_pvt->pcm[dai->id];
195+
hstream = (struct hdac_stream *)stream;
193196

194-
if (tx_mask)
195-
pcm->stream_tag[SNDRV_PCM_STREAM_PLAYBACK] = tx_mask;
196-
else
197-
pcm->stream_tag[SNDRV_PCM_STREAM_CAPTURE] = rx_mask;
197+
pcm->stream_tag[direction] = hstream->stream_tag;
198198

199199
return 0;
200200
}

sound/soc/intel/skylake/skl-pcm.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,8 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,
562562

563563
stream_tag = hdac_stream(link_dev)->stream_tag;
564564

565-
/* set the stream tag in the codec dai dma params */
566-
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
567-
snd_soc_dai_set_tdm_slot(codec_dai, stream_tag, 0, 0, 0);
568-
else
569-
snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0);
565+
/* set the hdac_stream in the codec dai */
566+
snd_soc_dai_set_stream(codec_dai, hdac_stream(link_dev), substream->stream);
570567

571568
p_params.s_fmt = snd_pcm_format_width(params_format(params));
572569
p_params.ch = params_channels(params);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,8 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream,
252252
if (!link)
253253
return -EINVAL;
254254

255-
/* set the stream tag in the codec dai dma params */
256-
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
257-
snd_soc_dai_set_tdm_slot(codec_dai, stream_tag, 0, 0, 0);
258-
else
259-
snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0);
255+
/* set the hdac_stream in the codec dai */
256+
snd_soc_dai_set_stream(codec_dai, hdac_stream(hext_stream), substream->stream);
260257

261258
p_params.s_fmt = snd_pcm_format_width(params_format(params));
262259
p_params.ch = params_channels(params);

0 commit comments

Comments
 (0)