sound/soc/codecs/tas2780.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/tas2780.c
Extension
.c
Size
16565 bytes
Lines
650
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 tas2780_priv {
	struct snd_soc_component *component;
	struct gpio_desc *reset_gpio;
	struct regmap *regmap;
	struct device *dev;
	int v_sense_slot;
	int i_sense_slot;
};

static void tas2780_reset(struct tas2780_priv *tas2780)
{
	int ret = 0;

	if (tas2780->reset_gpio) {
		gpiod_set_value_cansleep(tas2780->reset_gpio, 0);
		usleep_range(2000, 2050);
		gpiod_set_value_cansleep(tas2780->reset_gpio, 1);
		usleep_range(2000, 2050);
	}

	ret = snd_soc_component_write(tas2780->component, TAS2780_SW_RST,
				TAS2780_RST);
	if (ret)
		dev_err(tas2780->dev, "%s:errCode:0x%x Reset error!\n",
			__func__, ret);
}

#ifdef CONFIG_PM
static int tas2780_codec_suspend(struct snd_soc_component *component)
{
	struct tas2780_priv *tas2780 =
		snd_soc_component_get_drvdata(component);
	int ret = 0;

	ret = snd_soc_component_update_bits(component, TAS2780_PWR_CTRL,
		TAS2780_PWR_CTRL_MASK, TAS2780_PWR_CTRL_SHUTDOWN);
	if (ret < 0) {
		dev_err(tas2780->dev, "%s:errCode:0x%0x:power down error\n",
			__func__, ret);
		goto err;
	}
	ret = 0;
	regcache_cache_only(tas2780->regmap, true);
	regcache_mark_dirty(tas2780->regmap);
err:
	return ret;
}

static int tas2780_codec_resume(struct snd_soc_component *component)
{
	struct tas2780_priv *tas2780 =
		snd_soc_component_get_drvdata(component);
	int ret;

	ret = snd_soc_component_update_bits(component, TAS2780_PWR_CTRL,
		TAS2780_PWR_CTRL_MASK, TAS2780_PWR_CTRL_ACTIVE);

	if (ret < 0) {
		dev_err(tas2780->dev, "%s:errCode:0x%0x:power down error\n",
			__func__, ret);
		goto err;
	}
	regcache_cache_only(tas2780->regmap, false);
	ret = regcache_sync(tas2780->regmap);
err:
	return ret;
}
#endif

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

static SOC_ENUM_SINGLE_DECL(
	tas2780_ASI1_src_enum, TAS2780_TDM_CFG2, 4, tas2780_ASI1_src);

static const struct snd_kcontrol_new tas2780_asi1_mux =
	SOC_DAPM_ENUM("ASI1 Source", tas2780_ASI1_src_enum);

static const struct snd_kcontrol_new isense_switch =
	SOC_DAPM_SINGLE("Switch", TAS2780_PWR_CTRL,
			TAS2780_ISENSE_POWER_EN, 1, 1);
static const struct snd_kcontrol_new vsense_switch =
	SOC_DAPM_SINGLE("Switch", TAS2780_PWR_CTRL,
			TAS2780_VSENSE_POWER_EN, 1, 1);

static const struct snd_soc_dapm_widget tas2780_dapm_widgets[] = {
	SND_SOC_DAPM_AIF_IN("ASI1", "ASI1 Playback", 0, SND_SOC_NOPM, 0, 0),
	SND_SOC_DAPM_MUX("ASI1 Sel", SND_SOC_NOPM, 0, 0, &tas2780_asi1_mux),
	SND_SOC_DAPM_SWITCH("ISENSE", TAS2780_PWR_CTRL,

Annotation

Implementation Notes