sound/soc/codecs/tas2770.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/tas2770.c
Extension
.c
Size
25559 bytes
Lines
987
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

if (ret < 0) {
			regcache_cache_only(tas2770->regmap, false);
			regcache_sync(tas2770->regmap);
			return ret;
		}

		ret = 0;
	}

	return ret;
}

static int tas2770_codec_resume(struct snd_soc_component *component)
{
	struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component);
	int ret;

	if (tas2770->sdz_gpio) {
		gpiod_set_value_cansleep(tas2770->sdz_gpio, 1);
		usleep_range(1000, 2000);
	} else {
		ret = tas2770_update_pwr_ctrl(tas2770);
		if (ret < 0)
			return ret;
	}

	regcache_cache_only(tas2770->regmap, false);

	return regcache_sync(tas2770->regmap);
}
#else
#define tas2770_codec_suspend NULL
#define tas2770_codec_resume NULL
#endif

static const char * const tas2770_ASI1_src[] = {
	"I2C offset", "Left", "Right", "LeftRightDiv2",
};

static SOC_ENUM_SINGLE_DECL(
	tas2770_ASI1_src_enum, TAS2770_TDM_CFG_REG2,
	4, tas2770_ASI1_src);

static const struct snd_kcontrol_new tas2770_asi1_mux =
	SOC_DAPM_ENUM("ASI1 Source", tas2770_ASI1_src_enum);

static int tas2770_dac_event(struct snd_soc_dapm_widget *w,
			     struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_component *component =
			snd_soc_dapm_to_component(w->dapm);
	struct tas2770_priv *tas2770 =
			snd_soc_component_get_drvdata(component);
	int ret;

	switch (event) {
	case SND_SOC_DAPM_POST_PMU:
		tas2770->dac_powered = 1;
		ret = tas2770_update_pwr_ctrl(tas2770);
		break;
	case SND_SOC_DAPM_PRE_PMD:
		tas2770->dac_powered = 0;
		ret = tas2770_update_pwr_ctrl(tas2770);
		break;
	default:
		dev_err(tas2770->dev, "Not supported evevt\n");
		return -EINVAL;
	}

	return ret;
}

static const struct snd_kcontrol_new isense_switch =
	SOC_DAPM_SINGLE("Switch", TAS2770_PWR_CTRL, 3, 1, 1);
static const struct snd_kcontrol_new vsense_switch =
	SOC_DAPM_SINGLE("Switch", TAS2770_PWR_CTRL, 2, 1, 1);

static int sense_event(struct snd_soc_dapm_widget *w,
			struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
	struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component);

	/*
	 * Powering up ISENSE/VSENSE requires a trip through the shutdown state.
	 * Do that here to ensure that our changes are applied properly, otherwise
	 * we might end up with non-functional IVSENSE if playback started earlier,
	 * which would break software speaker protection.
	 */
	switch (event) {

Annotation

Implementation Notes