sound/soc/amd/acp/acp-sdw-legacy-mach.c

Source file repositories/reference/linux-study-clean/sound/soc/amd/acp/acp-sdw-legacy-mach.c

File Facts

System
Linux kernel
Corpus path
sound/soc/amd/acp/acp-sdw-legacy-mach.c
Extension
.c
Size
16040 bytes
Lines
605
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source 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 (soc_end->name_prefix) {
			(*codec_conf)->dlc.name = soc_end->codec_name;
			(*codec_conf)->name_prefix = soc_end->name_prefix;
			(*codec_conf)++;
		}

		if (soc_end->include_sidecar) {
			ret = soc_end->codec_info->add_sidecar(card, dai_links, codec_conf);
			if (ret)
				return ret;
		}
	}

	for_each_pcm_streams(stream) {
		static const char * const sdw_stream_name[] = {
			"SDW%d-PIN%d-PLAYBACK",
			"SDW%d-PIN%d-CAPTURE",
			"SDW%d-PIN%d-PLAYBACK-%s",
			"SDW%d-PIN%d-CAPTURE-%s",
		};
		struct snd_soc_dai_link_ch_map *codec_maps;
		struct snd_soc_dai_link_component *codecs;
		struct snd_soc_dai_link_component *cpus;
		int num_cpus = hweight32(soc_dai->link_mask[stream]);
		int num_codecs = soc_dai->num_devs[stream];
		int playback, capture;
		int j = 0;
		char *name;

		if (!soc_dai->num_devs[stream])
			continue;

		soc_end = list_first_entry(&soc_dai->endpoints,
					   struct asoc_sdw_endpoint, list);

		*be_id = soc_end->dai_info->dailink[stream];
		if (*be_id < 0) {
			dev_err(dev, "Invalid dailink id %d\n", *be_id);
			return -EINVAL;
		}

		switch (amd_ctx->acp_rev) {
		case ACP63_PCI_REV:
			ret = get_acp63_cpu_pin_id(ffs(soc_end->link_mask - 1),
						   *be_id, &cpu_pin_id, dev);
			if (ret)
				return ret;
			break;
		case ACP70_PCI_REV:
		case ACP71_PCI_REV:
		case ACP72_PCI_REV:
			ret = get_acp70_cpu_pin_id(ffs(soc_end->link_mask - 1),
						   *be_id, &cpu_pin_id, dev);
			if (ret)
				return ret;
			break;
		default:
			return -EINVAL;
		}
		/* create stream name according to first link id */
		if (ctx->append_dai_type) {
			name = devm_kasprintf(dev, GFP_KERNEL,
					      sdw_stream_name[stream + 2],
					      ffs(soc_end->link_mask) - 1,
					      cpu_pin_id,
					      type_strings[soc_end->dai_info->dai_type]);
		} else {
			name = devm_kasprintf(dev, GFP_KERNEL,
					      sdw_stream_name[stream],
					      ffs(soc_end->link_mask) - 1,
					      cpu_pin_id);
		}
		if (!name)
			return -ENOMEM;

		cpus = devm_kcalloc(dev, num_cpus, sizeof(*cpus), GFP_KERNEL);
		if (!cpus)
			return -ENOMEM;

		codecs = devm_kcalloc(dev, num_codecs, sizeof(*codecs), GFP_KERNEL);
		if (!codecs)
			return -ENOMEM;

		codec_maps = devm_kcalloc(dev, num_codecs, sizeof(*codec_maps), GFP_KERNEL);
		if (!codec_maps)
			return -ENOMEM;

		list_for_each_entry(soc_end, &soc_dai->endpoints, list) {
			if (!soc_end->dai_info->direction[stream])
				continue;

Annotation

Implementation Notes