sound/soc/qcom/sdw.c

Source file repositories/reference/linux-study-clean/sound/soc/qcom/sdw.c

File Facts

System
Linux kernel
Corpus path
sound/soc/qcom/sdw.c
Extension
.c
Size
5639 bytes
Lines
217
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (ret < 0 && ret != -ENOTSUPP) {
			dev_err(rtd->dev, "Failed to set sdw stream on %s\n", codec_dai->name);
			goto err_set_stream;
		} else if (ret == -ENOTSUPP) {
			/* Ignore unsupported */
			continue;
		}

		ret = snd_soc_dai_get_channel_map(codec_dai, &tx_ch_cnt, tx_ch,
						  &rx_ch_cnt, rx_ch);
		if (ret != 0 && ret != -ENOTSUPP) {
			dev_err(rtd->dev, "Failed to get codec chan map %s\n", codec_dai->name);
			goto err_set_stream;
		} else if (ret == -ENOTSUPP) {
			/* Ignore unsupported */
			continue;
		}
	}

	switch (cpu_dai->id) {
	case RX_CODEC_DMA_RX_0:
	case TX_CODEC_DMA_TX_3:
		if (tx_ch_cnt || rx_ch_cnt) {
			for_each_rtd_codec_dais(rtd, j, codec_dai) {
				ret = snd_soc_dai_set_channel_map(codec_dai,
								  tx_ch_cnt, tx_ch,
								  rx_ch_cnt, rx_ch);
				if (ret != 0 && ret != -ENOTSUPP)
					goto err_set_stream;
			}
		}
	}

	return 0;

err_set_stream:
	sdw_release_stream(sruntime);

	return ret;
}
EXPORT_SYMBOL_GPL(qcom_snd_sdw_startup);

int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream,
			 bool *stream_prepared)
{
	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
	struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
	struct sdw_stream_runtime *sruntime;
	int ret;


	if (!qcom_snd_is_sdw_dai(cpu_dai->id))
		return 0;

	sruntime = qcom_snd_sdw_get_stream(substream);
	if (!sruntime)
		return 0;

	if (*stream_prepared)
		return 0;

	ret = sdw_prepare_stream(sruntime);
	if (ret)
		return ret;

	/**
	 * NOTE: there is a strict hw requirement about the ordering of port
	 * enables and actual WSA881x PA enable. PA enable should only happen
	 * after soundwire ports are enabled if not DC on the line is
	 * accumulated resulting in Click/Pop Noise
	 * PA enable/mute are handled as part of codec DAPM and digital mute.
	 */

	ret = sdw_enable_stream(sruntime);
	if (ret) {
		sdw_deprepare_stream(sruntime);
		return ret;
	}
	*stream_prepared  = true;

	return ret;
}
EXPORT_SYMBOL_GPL(qcom_snd_sdw_prepare);

struct sdw_stream_runtime *qcom_snd_sdw_get_stream(struct snd_pcm_substream *substream)
{
	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
	struct snd_soc_dai *codec_dai;
	struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
	struct sdw_stream_runtime *sruntime;

Annotation

Implementation Notes