sound/soc/mediatek/common/mtk-dsp-sof-common.c

Source file repositories/reference/linux-study-clean/sound/soc/mediatek/common/mtk-dsp-sof-common.c

File Facts

System
Linux kernel
Corpus path
sound/soc/mediatek/common/mtk-dsp-sof-common.c
Extension
.c
Size
7712 bytes
Lines
275
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

for_each_card_rtds(card, runtime) {
			if (strcmp(runtime->dai_link->name, conn->sof_link))
				continue;

			for_each_rtd_cpu_dais(runtime, j, cpu_dai) {
				if (snd_soc_dai_stream_active(cpu_dai, conn->stream_dir) > 0) {
					sof_dai_link = runtime->dai_link;
					break;
				}
			}
			break;
		}

		if (sof_dai_link && sof_dai_link->be_hw_params_fixup)
			ret = sof_dai_link->be_hw_params_fixup(runtime, params);

		break;
	}

	return ret;
}
EXPORT_SYMBOL_GPL(mtk_sof_dai_link_fixup);

int mtk_sof_card_probe(struct snd_soc_card *card)
{
	int i;
	struct snd_soc_dai_link *dai_link;
	struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);

	/* Set stream_name to help sof bind widgets */
	for_each_card_prelinks(card, i, dai_link) {
		if (dai_link->no_pcm && !dai_link->stream_name && dai_link->name)
			dai_link->stream_name = dai_link->name;
	}

	INIT_LIST_HEAD(&soc_card_data->sof_dai_link_list);

	return 0;
}
EXPORT_SYMBOL_GPL(mtk_sof_card_probe);

static struct snd_soc_pcm_runtime *mtk_sof_find_tplg_be(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_card *card = rtd->card;
	struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);
	const struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv;
	struct snd_soc_pcm_runtime *fe;
	struct snd_soc_pcm_runtime *be;
	struct snd_soc_dpcm *dpcm;
	int i, stream;

	for_each_pcm_streams(stream) {
		fe = NULL;
		for_each_dpcm_fe(rtd, stream, dpcm) {
			fe = dpcm->fe;
			if (fe)
				break;
		}

		if (!fe)
			continue;

		for_each_dpcm_be(fe, stream, dpcm) {
			be = dpcm->be;
			if (be == rtd)
				continue;

			for (i = 0; i < sof_priv->num_streams; i++) {
				const struct sof_conn_stream *conn = &sof_priv->conn_streams[i];

				if (!strcmp(be->dai_link->name, conn->sof_link))
					return be;
			}
		}
	}

	return NULL;
}

/* fixup the BE DAI link to match any values from topology */
static int mtk_sof_check_tplg_be_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
						struct snd_pcm_hw_params *params)
{
	struct snd_soc_card *card = rtd->card;
	struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);
	const struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv;
	struct snd_soc_pcm_runtime *sof_be;
	struct mtk_dai_link *dai_link;
	int ret = 0;

Annotation

Implementation Notes