sound/soc/sdw_utils/soc_sdw_ti_amp.c

Source file repositories/reference/linux-study-clean/sound/soc/sdw_utils/soc_sdw_ti_amp.c

File Facts

System
Linux kernel
Corpus path
sound/soc/sdw_utils/soc_sdw_ti_amp.c
Extension
.c
Size
6364 bytes
Lines
230
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 (!strncmp(prefix, "tas2783-1", strlen("tas2783-1"))) {
			strscpy(speaker, "Left Spk", sizeof(speaker));
		} else if (!strncmp(prefix, "tas2783-2", strlen("tas2783-2"))) {
			strscpy(speaker, "Right Spk", sizeof(speaker));
		} else if (!strncmp(prefix, "tas2783-3", strlen("tas2783-3"))) {
			strscpy(speaker, "Left Spk2", sizeof(speaker));
		} else if (!strncmp(prefix, "tas2783-4", strlen("tas2783-4"))) {
			strscpy(speaker, "Right Spk2", sizeof(speaker));
		} else {
			ret = -EINVAL;
			dev_err(card->dev, "unhandled prefix %s", prefix);
			break;
		}

		snprintf(widget_name, sizeof(widget_name), "%s SPK", prefix);
		ret = asoc_sdw_ti_amp_initial_settings(card, prefix);
		if (ret)
			return ret;

		ret = snd_soc_dapm_add_routes(dapm, &route, 1);
		if (ret)
			return ret;
	}

	return ret;
}
EXPORT_SYMBOL_NS(asoc_sdw_ti_spk_rtd_init, "SND_SOC_SDW_UTILS");

int asoc_sdw_ti_amp_init(struct snd_soc_card *card,
			 struct snd_soc_dai_link *dai_links,
			 struct asoc_sdw_codec_info *info,
			 bool playback)
{
	if (!playback)
		return 0;

	info->amp_num++;

	return 0;
}
EXPORT_SYMBOL_NS(asoc_sdw_ti_amp_init, "SND_SOC_SDW_UTILS");

static int asoc_sdw_ti_add_tac5xx2_routes(struct snd_soc_dapm_context *dapm,
					  const char *name_prefix)
{
	struct snd_soc_dapm_route routes[2];
	char left_widget[TAC5XX2_WIDGET_NAME_MAX];
	char right_widget[TAC5XX2_WIDGET_NAME_MAX];

	if (strlen(name_prefix) > (TAC5XX2_WIDGET_NAME_MAX - 7))
		return -ENAMETOOLONG;

	scnprintf(left_widget, sizeof(left_widget), "%s SPK_L", name_prefix);
	scnprintf(right_widget, sizeof(right_widget), "%s SPK_R", name_prefix);

	routes[0] = (struct snd_soc_dapm_route){"Left Spk", NULL, left_widget};
	routes[1] = (struct snd_soc_dapm_route){"Right Spk", NULL, right_widget};

	return snd_soc_dapm_add_routes(dapm, routes, ARRAY_SIZE(routes));
}

int asoc_sdw_ti_tac5xx2_spk_rtd_init(struct snd_soc_pcm_runtime *rtd,
				     struct snd_soc_dai *dai)
{
	struct snd_soc_card *card = rtd->card;
	struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
	int ret, i;
	struct snd_soc_dai *codec_dai;
	const char *prefix;

	for_each_rtd_codec_dais(rtd, i, codec_dai) {
		if (!strstr(codec_dai->name, "tac5") &&
		    !strstr(codec_dai->name, "tas2883"))
			continue;

		prefix = codec_dai->component->name_prefix;
		if (!prefix) {
			dev_warn(card->dev,
				 "No name prefix found for codec DAI: %s\n",
				codec_dai->name);
			continue;
		}
		ret = asoc_sdw_ti_add_tac5xx2_routes(dapm, prefix);
		if (ret) {
			dev_err(card->dev, "Failed to add routes for %s: %d\n",
				prefix, ret);
			return ret;
		}
	}

Annotation

Implementation Notes