sound/soc/sdca/sdca_functions.c

Source file repositories/reference/linux-study-clean/sound/soc/sdca/sdca_functions.c

File Facts

System
Linux kernel
Corpus path
sound/soc/sdca/sdca_functions.c
Extension
.c
Size
73196 bytes
Lines
2349
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

struct raw_init_write {
	__le32 addr;
	u8 val;
} __packed;

static int find_sdca_init_table(struct device *dev,
				struct fwnode_handle *function_node,
				struct sdca_function_data *function)
{
	struct raw_init_write *raw __free(kfree) = NULL;
	struct sdca_init_write *init_write;
	int i, num_init_writes;

	num_init_writes = fwnode_property_count_u8(function_node,
						   "mipi-sdca-function-initialization-table");
	if (!num_init_writes || num_init_writes == -EINVAL) {
		return 0;
	} else if (num_init_writes < 0) {
		dev_err(dev, "%pfwP: failed to read initialization table: %d\n",
			function_node, num_init_writes);
		return num_init_writes;
	} else if (num_init_writes % sizeof(*raw) != 0) {
		dev_err(dev, "%pfwP: init table size invalid\n", function_node);
		return -EINVAL;
	}

	raw = kzalloc(num_init_writes, GFP_KERNEL);
	if (!raw)
		return -ENOMEM;

	fwnode_property_read_u8_array(function_node,
				      "mipi-sdca-function-initialization-table",
				      (u8 *)raw, num_init_writes);

	num_init_writes /= sizeof(*raw);

	init_write = devm_kcalloc(dev, num_init_writes, sizeof(*init_write), GFP_KERNEL);
	if (!init_write)
		return -ENOMEM;

	for (i = 0; i < num_init_writes; i++) {
		init_write[i].addr = le32_to_cpu(raw[i].addr);
		init_write[i].val = raw[i].val;
	}

	function->num_init_table = num_init_writes;
	function->init_table = init_write;

	return 0;
}

static const char *find_sdca_control_label(struct device *dev,
					   const struct sdca_entity *entity,
					   const struct sdca_control *control)
{
	switch (SDCA_CTL_TYPE(entity->type, control->sel)) {
	case SDCA_CTL_TYPE_S(IT, MIC_BIAS):
		return SDCA_CTL_MIC_BIAS_NAME;
	case SDCA_CTL_TYPE_S(IT, USAGE):
	case SDCA_CTL_TYPE_S(OT, USAGE):
		return SDCA_CTL_USAGE_NAME;
	case SDCA_CTL_TYPE_S(IT, LATENCY):
	case SDCA_CTL_TYPE_S(OT, LATENCY):
	case SDCA_CTL_TYPE_S(MU, LATENCY):
	case SDCA_CTL_TYPE_S(SU, LATENCY):
	case SDCA_CTL_TYPE_S(FU, LATENCY):
	case SDCA_CTL_TYPE_S(XU, LATENCY):
	case SDCA_CTL_TYPE_S(CRU, LATENCY):
	case SDCA_CTL_TYPE_S(UDMPU, LATENCY):
	case SDCA_CTL_TYPE_S(MFPU, LATENCY):
	case SDCA_CTL_TYPE_S(SMPU, LATENCY):
	case SDCA_CTL_TYPE_S(SAPU, LATENCY):
	case SDCA_CTL_TYPE_S(PPU, LATENCY):
		return SDCA_CTL_LATENCY_NAME;
	case SDCA_CTL_TYPE_S(IT, CLUSTERINDEX):
	case SDCA_CTL_TYPE_S(CRU, CLUSTERINDEX):
	case SDCA_CTL_TYPE_S(UDMPU, CLUSTERINDEX):
	case SDCA_CTL_TYPE_S(MFPU, CLUSTERINDEX):
		return SDCA_CTL_CLUSTERINDEX_NAME;
	case SDCA_CTL_TYPE_S(IT, DATAPORT_SELECTOR):
	case SDCA_CTL_TYPE_S(OT, DATAPORT_SELECTOR):
		return SDCA_CTL_DATAPORT_SELECTOR_NAME;
	case SDCA_CTL_TYPE_S(IT, MATCHING_GUID):
	case SDCA_CTL_TYPE_S(OT, MATCHING_GUID):
	case SDCA_CTL_TYPE_S(ENTITY_0, MATCHING_GUID):
		return SDCA_CTL_MATCHING_GUID_NAME;
	case SDCA_CTL_TYPE_S(IT, KEEP_ALIVE):
	case SDCA_CTL_TYPE_S(OT, KEEP_ALIVE):
		return SDCA_CTL_KEEP_ALIVE_NAME;
	case SDCA_CTL_TYPE_S(IT, NDAI_STREAM):

Annotation

Implementation Notes