Skip to content

Commit 5c9ff7a

Browse files
committed
ASoC/SoundWire: dai: expand 'stream' concept beyond SoundWire
The HDAudio ASoC support relies on the set_tdm_slots() helper to store the HDaudio stream tag in the tx_mask. This only works because of the pre-existing order in soc-pcm.c, where the hw_params() is handled for codec_dais *before* cpu_dais. When the order is reversed, the stream_tag is used as a mask in the codec fixup functions: /* fixup params based on TDM slot masks */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && codec_dai->tx_mask) soc_pcm_codec_params_fixup(&codec_params, codec_dai->tx_mask); As a result of this confusion, the codec_params_fixup() ends-up generating bad channel masks, depending on what stream_tag was allocated. We could add a flag to state that the tx_mask is really not a mask, but it would be quite ugly to persist in overloading concepts. Instead, this patch suggests a more generic get/set 'stream' API based on the existing model for SoundWire. We can expand the concept to store 'stream' opaque information that is specific to different DAI types. In the case of HDAudio DAIs, we only need to store a stream tag as an unsigned char pointer. The TDM rx_ and tx_masks should really only be used to store masks. Rename get_sdw_stream/set_sdw_stream callbacks and helpers as get_stream/set_stream. No functionality change beyond the rename. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
1 parent 1b0f957 commit 5c9ff7a

19 files changed

Lines changed: 43 additions & 43 deletions

File tree

drivers/soundwire/intel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,8 @@ static const struct snd_soc_dai_ops intel_pcm_dai_ops = {
10931093
.hw_free = intel_hw_free,
10941094
.trigger = intel_trigger,
10951095
.shutdown = intel_shutdown,
1096-
.set_sdw_stream = intel_pcm_set_sdw_stream,
1097-
.get_sdw_stream = intel_get_sdw_stream,
1096+
.set_stream = intel_pcm_set_sdw_stream,
1097+
.get_stream = intel_get_sdw_stream,
10981098
};
10991099

11001100
static const struct snd_soc_component_driver dai_component = {

drivers/soundwire/qcom.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,8 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,
10241024
ctrl->sruntime[dai->id] = sruntime;
10251025

10261026
for_each_rtd_codec_dais(rtd, i, codec_dai) {
1027-
ret = snd_soc_dai_set_sdw_stream(codec_dai, sruntime,
1028-
substream->stream);
1027+
ret = snd_soc_dai_set_stream(codec_dai, sruntime,
1028+
substream->stream);
10291029
if (ret < 0 && ret != -ENOTSUPP) {
10301030
dev_err(dai->dev, "Failed to set sdw stream on %s\n",
10311031
codec_dai->name);
@@ -1051,8 +1051,8 @@ static const struct snd_soc_dai_ops qcom_swrm_pdm_dai_ops = {
10511051
.hw_free = qcom_swrm_hw_free,
10521052
.startup = qcom_swrm_startup,
10531053
.shutdown = qcom_swrm_shutdown,
1054-
.set_sdw_stream = qcom_swrm_set_sdw_stream,
1055-
.get_sdw_stream = qcom_swrm_get_sdw_stream,
1054+
.set_stream = qcom_swrm_set_sdw_stream,
1055+
.get_stream = qcom_swrm_get_sdw_stream,
10561056
};
10571057

10581058
static const struct snd_soc_component_driver qcom_swrm_dai_component = {

drivers/soundwire/stream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ static int set_stream(struct snd_pcm_substream *substream,
18631863

18641864
/* Set stream pointer on all DAIs */
18651865
for_each_rtd_dais(rtd, i, dai) {
1866-
ret = snd_soc_dai_set_sdw_stream(dai, sdw_stream, substream->stream);
1866+
ret = snd_soc_dai_set_stream(dai, sdw_stream, substream->stream);
18671867
if (ret < 0) {
18681868
dev_err(rtd->dev, "failed to set stream pointer on dai %s\n", dai->name);
18691869
break;
@@ -1934,7 +1934,7 @@ void sdw_shutdown_stream(void *sdw_substream)
19341934
/* Find stream from first CPU DAI */
19351935
dai = asoc_rtd_to_cpu(rtd, 0);
19361936

1937-
sdw_stream = snd_soc_dai_get_sdw_stream(dai, substream->stream);
1937+
sdw_stream = snd_soc_dai_get_stream(dai, substream->stream);
19381938

19391939
if (IS_ERR(sdw_stream)) {
19401940
dev_err(rtd->dev, "no stream found for DAI %s\n", dai->name);

include/sound/soc-dai.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ struct snd_soc_dai_ops {
295295
unsigned int *rx_num, unsigned int *rx_slot);
296296
int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
297297

298-
int (*set_sdw_stream)(struct snd_soc_dai *dai,
299-
void *stream, int direction);
300-
void *(*get_sdw_stream)(struct snd_soc_dai *dai, int direction);
298+
int (*set_stream)(struct snd_soc_dai *dai,
299+
void *stream, int direction);
300+
void *(*get_stream)(struct snd_soc_dai *dai, int direction);
301301

302302
/*
303303
* DAI digital mute - optional.
@@ -515,42 +515,42 @@ static inline void *snd_soc_dai_get_drvdata(struct snd_soc_dai *dai)
515515
}
516516

517517
/**
518-
* snd_soc_dai_set_sdw_stream() - Configures a DAI for SDW stream operation
518+
* snd_soc_dai_set_stream() - Configures a DAI for stream operation
519519
* @dai: DAI
520-
* @stream: STREAM
520+
* @stream: STREAM (opaque structure depending on DAI type)
521521
* @direction: Stream direction(Playback/Capture)
522-
* SoundWire subsystem doesn't have a notion of direction and we reuse
522+
* Some subsystems, such as SoundWire, don't have a notion of direction and we reuse
523523
* the ASoC stream direction to configure sink/source ports.
524524
* Playback maps to source ports and Capture for sink ports.
525525
*
526526
* This should be invoked with NULL to clear the stream set previously.
527527
* Returns 0 on success, a negative error code otherwise.
528528
*/
529-
static inline int snd_soc_dai_set_sdw_stream(struct snd_soc_dai *dai,
530-
void *stream, int direction)
529+
static inline int snd_soc_dai_set_stream(struct snd_soc_dai *dai,
530+
void *stream, int direction)
531531
{
532-
if (dai->driver->ops->set_sdw_stream)
533-
return dai->driver->ops->set_sdw_stream(dai, stream, direction);
532+
if (dai->driver->ops->set_stream)
533+
return dai->driver->ops->set_stream(dai, stream, direction);
534534
else
535535
return -ENOTSUPP;
536536
}
537537

538538
/**
539-
* snd_soc_dai_get_sdw_stream() - Retrieves SDW stream from DAI
539+
* snd_soc_dai_get_stream() - Retrieves stream from DAI
540540
* @dai: DAI
541541
* @direction: Stream direction(Playback/Capture)
542542
*
543543
* This routine only retrieves that was previously configured
544-
* with snd_soc_dai_get_sdw_stream()
544+
* with snd_soc_dai_get_stream()
545545
*
546546
* Returns pointer to stream or an ERR_PTR value, e.g.
547547
* ERR_PTR(-ENOTSUPP) if callback is not supported;
548548
*/
549-
static inline void *snd_soc_dai_get_sdw_stream(struct snd_soc_dai *dai,
550-
int direction)
549+
static inline void *snd_soc_dai_get_stream(struct snd_soc_dai *dai,
550+
int direction)
551551
{
552-
if (dai->driver->ops->get_sdw_stream)
553-
return dai->driver->ops->get_sdw_stream(dai, direction);
552+
if (dai->driver->ops->get_stream)
553+
return dai->driver->ops->get_stream(dai, direction);
554554
else
555555
return ERR_PTR(-ENOTSUPP);
556556
}

sound/soc/codecs/max98373-sdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ static int max98373_sdw_set_tdm_slot(struct snd_soc_dai *dai,
741741
static const struct snd_soc_dai_ops max98373_dai_sdw_ops = {
742742
.hw_params = max98373_sdw_dai_hw_params,
743743
.hw_free = max98373_pcm_hw_free,
744-
.set_sdw_stream = max98373_set_sdw_stream,
744+
.set_stream = max98373_set_sdw_stream,
745745
.shutdown = max98373_shutdown,
746746
.set_tdm_slot = max98373_sdw_set_tdm_slot,
747747
};

sound/soc/codecs/rt1308-sdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ static const struct snd_soc_component_driver soc_component_sdw_rt1308 = {
613613
static const struct snd_soc_dai_ops rt1308_aif_dai_ops = {
614614
.hw_params = rt1308_sdw_hw_params,
615615
.hw_free = rt1308_sdw_pcm_hw_free,
616-
.set_sdw_stream = rt1308_set_sdw_stream,
616+
.set_stream = rt1308_set_sdw_stream,
617617
.shutdown = rt1308_sdw_shutdown,
618618
.set_tdm_slot = rt1308_sdw_set_tdm_slot,
619619
};

sound/soc/codecs/rt1316-sdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ static const struct snd_soc_component_driver soc_component_sdw_rt1316 = {
602602
static const struct snd_soc_dai_ops rt1316_aif_dai_ops = {
603603
.hw_params = rt1316_sdw_hw_params,
604604
.hw_free = rt1316_sdw_pcm_hw_free,
605-
.set_sdw_stream = rt1316_set_sdw_stream,
605+
.set_stream = rt1316_set_sdw_stream,
606606
.shutdown = rt1316_sdw_shutdown,
607607
};
608608

sound/soc/codecs/rt5682-sdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static int rt5682_sdw_hw_free(struct snd_pcm_substream *substream,
272272
static const struct snd_soc_dai_ops rt5682_sdw_ops = {
273273
.hw_params = rt5682_sdw_hw_params,
274274
.hw_free = rt5682_sdw_hw_free,
275-
.set_sdw_stream = rt5682_set_sdw_stream,
275+
.set_stream = rt5682_set_sdw_stream,
276276
.shutdown = rt5682_sdw_shutdown,
277277
};
278278

sound/soc/codecs/rt700.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ static int rt700_pcm_hw_free(struct snd_pcm_substream *substream,
10051005
static const struct snd_soc_dai_ops rt700_ops = {
10061006
.hw_params = rt700_pcm_hw_params,
10071007
.hw_free = rt700_pcm_hw_free,
1008-
.set_sdw_stream = rt700_set_sdw_stream,
1008+
.set_stream = rt700_set_sdw_stream,
10091009
.shutdown = rt700_shutdown,
10101010
};
10111011

sound/soc/codecs/rt711-sdca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ static int rt711_sdca_pcm_hw_free(struct snd_pcm_substream *substream,
13581358
static const struct snd_soc_dai_ops rt711_sdca_ops = {
13591359
.hw_params = rt711_sdca_pcm_hw_params,
13601360
.hw_free = rt711_sdca_pcm_hw_free,
1361-
.set_sdw_stream = rt711_sdca_set_sdw_stream,
1361+
.set_stream = rt711_sdca_set_sdw_stream,
13621362
.shutdown = rt711_sdca_shutdown,
13631363
};
13641364

0 commit comments

Comments
 (0)