sound/soc/intel/boards/sof_cirrus_common.c

Source file repositories/reference/linux-study-clean/sound/soc/intel/boards/sof_cirrus_common.c

File Facts

System
Linux kernel
Corpus path
sound/soc/intel/boards/sof_cirrus_common.c
Extension
.c
Size
5800 bytes
Lines
208
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) {
			dev_err(codec_dai->dev, "fail to set sysclk, ret %d\n",
				ret);
			return ret;
		}

		/* call component driver's set_sysclk() callback */
		ret = snd_soc_component_set_sysclk(codec_dai->component,
						   CS35L41_CLKID_SCLK, 0,
						   clk_freq, SND_SOC_CLOCK_IN);
		if (ret < 0) {
			dev_err(codec_dai->dev, "fail to set component sysclk, ret %d\n",
				ret);
			return ret;
		}

		/* setup channel map */
		ret = snd_soc_dai_set_channel_map(codec_dai, 0, NULL,
						  ARRAY_SIZE(cs35l41_channel_map[i].rx),
						  (unsigned int *)cs35l41_channel_map[i].rx);
		if (ret < 0) {
			dev_err(codec_dai->dev, "fail to set channel map, ret %d\n",
				ret);
			return ret;
		}
	}

	return 0;
}

static const struct snd_soc_ops cs35l41_ops = {
	.hw_params = cs35l41_hw_params,
};

static const char * const cs35l41_name_prefixes[] = { "WL", "WR", "TL", "TR" };

/*
 * Expected UIDs are integers (stored as strings).
 * UID Mapping is fixed:
 * UID 0x0 -> WL
 * UID 0x1 -> WR
 * UID 0x2 -> TL
 * UID 0x3 -> TR
 * Note: If there are less than 4 Amps, UIDs still map to WL/WR/TL/TR. Dynamic code will only create
 * dai links for UIDs which exist, and ignore non-existant ones. Only 2 or 4 amps are expected.
 * Return number of codecs found.
 */
static int cs35l41_compute_codec_conf(void)
{
	static const char * const uid_strings[] = { "0", "1", "2", "3" };
	unsigned int uid, sz = 0;
	struct acpi_device *adev;
	struct device *physdev;

	for (uid = 0; uid < CS35L41_MAX_AMPS; uid++) {
		adev = acpi_dev_get_first_match_dev(CS35L41_HID, uid_strings[uid], -1);
		if (!adev) {
			pr_devel("Cannot find match for HID %s UID %u (%s)\n", CS35L41_HID, uid,
				 cs35l41_name_prefixes[uid]);
			continue;
		}
		physdev = get_device(acpi_get_first_physical_node(adev));
		acpi_dev_put(adev);
		if (!physdev) {
			pr_devel("Cannot find physical node for HID %s UID %u (%s)\n", CS35L41_HID,
					uid, cs35l41_name_prefixes[uid]);
			return 0;
		}
		cs35l41_components[sz].name = dev_name(physdev);
		cs35l41_components[sz].dai_name = CS35L41_CODEC_DAI;
		cs35l41_codec_conf[sz].dlc.name = dev_name(physdev);
		cs35l41_codec_conf[sz].name_prefix = cs35l41_name_prefixes[uid];
		sz++;
	}

	if (sz != 2 && sz != 4)
		pr_warn("Invalid number of cs35l41 amps found: %d, expected 2 or 4\n", sz);
	return sz;
}

void cs35l41_set_dai_link(struct snd_soc_dai_link *link)
{
	link->num_codecs = cs35l41_compute_codec_conf();
	link->codecs = cs35l41_components;
	link->init = cs35l41_init;
	link->ops = &cs35l41_ops;
}
EXPORT_SYMBOL_NS(cs35l41_set_dai_link, "SND_SOC_INTEL_SOF_CIRRUS_COMMON");

void cs35l41_set_codec_conf(struct snd_soc_card *card)

Annotation

Implementation Notes