sound/soc/sdca/sdca_asoc.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/sdca/sdca_asoc.c
Extension
.c
Size
49298 bytes
Lines
1781
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

switch (entity->type) {
		case SDCA_ENTITY_TYPE_IT:
		case SDCA_ENTITY_TYPE_OT:
			*num_routes += !!entity->iot.clock;
			*num_routes += !!entity->iot.is_dataport;
			*num_controls += !entity->iot.is_dataport;
			*num_dais += !!entity->iot.is_dataport;
			break;
		case SDCA_ENTITY_TYPE_PDE:
			*num_routes += entity->pde.num_managed;
			break;
		case SDCA_ENTITY_TYPE_GE:
			*num_routes += ge_count_routes(entity);
			skip_primary_routes = true;
			break;
		case SDCA_ENTITY_TYPE_SU:
			control = sdca_selector_find_control(dev, entity, SDCA_CTL_SU_SELECTOR);
			if (!control)
				return -EINVAL;

			skip_primary_routes = (control->layers == SDCA_ACCESS_LAYER_DEVICE);
			break;
		default:
			break;
		}

		if (entity->group)
			(*num_routes)++;

		/* Add primary entity connections from DisCo */
		if (!skip_primary_routes)
			*num_routes += entity->num_sources;

		for (j = 0; j < entity->num_controls; j++) {
			if (exported_control(entity, &entity->controls[j]))
				(*num_controls)++;
		}
	}

	return 0;
}
EXPORT_SYMBOL_NS(sdca_asoc_count_component, "SND_SOC_SDCA");

static int ge_put_enum_double(struct snd_kcontrol *kcontrol,
			      struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol);
	struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
	struct device *dev = component->dev;
	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
	unsigned int *item = ucontrol->value.enumerated.item;
	unsigned int reg = e->reg;
	int ret;

	reg &= ~SDW_SDCA_CTL_CSEL(0x3F);
	reg |= SDW_SDCA_CTL_CSEL(SDCA_CTL_GE_DETECTED_MODE);

	ret = pm_runtime_resume_and_get(dev);
	if (ret < 0) {
		dev_err(dev, "failed to resume writing %s: %d\n",
			kcontrol->id.name, ret);
		return ret;
	}

	ret = snd_soc_component_read(component, reg);
	pm_runtime_put(dev);
	if (ret < 0)
		return ret;
	else if (ret <= SDCA_DETECTED_MODE_DETECTION_IN_PROGRESS)
		return -EBUSY;

	ret = snd_soc_enum_item_to_val(e, item[0]);
	if (ret <= SDCA_DETECTED_MODE_DETECTION_IN_PROGRESS)
		return -EINVAL;

	return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
}

static int entity_early_parse_ge(struct device *dev,
				 struct sdca_function_data *function,
				 struct sdca_entity *entity)
{
	struct sdca_control_range *range;
	struct sdca_control *control;
	struct snd_kcontrol_new *kctl;
	struct soc_enum *soc_enum;
	const char *control_name;
	unsigned int *values;
	const char **texts;
	int i;

Annotation

Implementation Notes