sound/soc/codecs/sti-sas.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/sti-sas.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/sti-sas.c
Extension
.c
Size
12111 bytes
Lines
466
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source 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 sti_dac_audio {
	struct regmap *regmap;
	struct regmap *virt_regmap;
	int mclk;
};

struct sti_spdif_audio {
	struct regmap *regmap;
	int mclk;
};

/* device data structure */
struct sti_sas_dev_data {
	const struct regmap_config *regmap;
	const struct snd_soc_dai_ops *dac_ops;  /* DAC function callbacks */
};

/* driver data structure */
struct sti_sas_data {
	struct device *dev;
	const struct sti_sas_dev_data *dev_data;
	struct sti_dac_audio dac;
	struct sti_spdif_audio spdif;
};

/* Read a register from the sysconf reg bank */
static int sti_sas_read_reg(void *context, unsigned int reg,
			    unsigned int *value)
{
	struct sti_sas_data *drvdata = context;
	int status;
	u32 val;

	status = regmap_read(drvdata->dac.regmap, reg, &val);
	*value = (unsigned int)val;

	return status;
}

/* Read a register from the sysconf reg bank */
static int sti_sas_write_reg(void *context, unsigned int reg,
			     unsigned int value)
{
	struct sti_sas_data *drvdata = context;

	return regmap_write(drvdata->dac.regmap, reg, value);
}

static int  sti_sas_init_sas_registers(struct snd_soc_component *component,
				       struct sti_sas_data *data)
{
	int ret;
	/*
	 * DAC and SPDIF are activated by default
	 * put them in IDLE to save power
	 */

	/* Initialise bi-phase formatter to disabled */
	ret = snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL,
				  SPDIF_BIPHASE_ENABLE_MASK, 0);

	if (!ret)
		/* Initialise bi-phase formatter idle value to 0 */
		ret = snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL,
					  SPDIF_BIPHASE_IDLE_MASK, 0);
	if (ret < 0) {
		dev_err(component->dev, "Failed to update SPDIF registers\n");
		return ret;
	}

	/* Init DAC configuration */
	/* init configuration */
	ret =  snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL,
				   STIH407_DAC_STANDBY_MASK,
				   STIH407_DAC_STANDBY_MASK);

	if (!ret)
		ret = snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL,
					  STIH407_DAC_STANDBY_ANA_MASK,
					  STIH407_DAC_STANDBY_ANA_MASK);
	if (!ret)
		ret = snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL,
					  STIH407_DAC_SOFTMUTE_MASK,
					  STIH407_DAC_SOFTMUTE_MASK);

	if (ret < 0) {
		dev_err(component->dev, "Failed to update DAC registers\n");
		return ret;
	}

Annotation

Implementation Notes