sound/soc/qcom/qdsp6/topology.c

Source file repositories/reference/linux-study-clean/sound/soc/qcom/qdsp6/topology.c

File Facts

System
Linux kernel
Corpus path
sound/soc/qcom/qdsp6/topology.c
Extension
.c
Size
36415 bytes
Lines
1343
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 snd_ar_control {
	u32 graph_id; /* Graph ID */
	u32 sgid; /* Sub Graph ID */
	u32 module_instance_id; /* Connected Module Instance ID */
	struct snd_soc_dapm_widget *w;
	struct list_head node;
	struct snd_soc_component *scomp;
};

static struct audioreach_graph_info *audioreach_tplg_alloc_graph_info(struct q6apm *apm,
								      uint32_t graph_id,
								      bool *found)
{
	struct audioreach_graph_info *info;
	int ret;

	mutex_lock(&apm->lock);
	info = idr_find(&apm->graph_info_idr, graph_id);
	mutex_unlock(&apm->lock);

	if (info) {
		*found = true;
		return info;
	}

	*found = false;
	info = kzalloc_obj(*info);
	if (!info)
		return ERR_PTR(-ENOMEM);

	INIT_LIST_HEAD(&info->sg_list);

	mutex_lock(&apm->lock);
	ret = idr_alloc_u32(&apm->graph_info_idr, info, &graph_id, graph_id, GFP_KERNEL);
	mutex_unlock(&apm->lock);

	if (ret < 0) {
		dev_err(apm->dev, "Failed to allocate Graph ID (%x)\n", graph_id);
		kfree(info);
		return ERR_PTR(ret);
	}

	info->id = graph_id;

	return info;
}

static void audioreach_tplg_add_sub_graph(struct audioreach_sub_graph *sg,
					  struct audioreach_graph_info *info)
{
	list_add_tail(&sg->node, &info->sg_list);
	sg->info = info;
	info->num_sub_graphs++;
}

static struct audioreach_sub_graph *audioreach_tplg_alloc_sub_graph(struct q6apm *apm,
								    uint32_t sub_graph_id,
								    bool *found)
{
	struct audioreach_sub_graph *sg;
	int ret;

	if (!sub_graph_id)
		return ERR_PTR(-EINVAL);

	/* Find if there is already a matching sub-graph */
	mutex_lock(&apm->lock);
	sg = idr_find(&apm->sub_graphs_idr, sub_graph_id);
	mutex_unlock(&apm->lock);

	if (sg) {
		*found = true;
		return sg;
	}

	*found = false;
	sg = kzalloc_obj(*sg);
	if (!sg)
		return ERR_PTR(-ENOMEM);

	INIT_LIST_HEAD(&sg->container_list);

	mutex_lock(&apm->lock);
	ret = idr_alloc_u32(&apm->sub_graphs_idr, sg, &sub_graph_id, sub_graph_id, GFP_KERNEL);
	mutex_unlock(&apm->lock);

	if (ret < 0) {
		dev_err(apm->dev, "Failed to allocate Sub-Graph Instance ID (%x)\n", sub_graph_id);
		kfree(sg);
		return ERR_PTR(ret);

Annotation

Implementation Notes