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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/err.hlinux/pm.hlinux/i2c.hlinux/gpio/consumer.hlinux/regmap.hlinux/of.hsound/soc.hsound/pcm.hsound/pcm_params.hsound/tlv.htas2780.h
Detected Declarations
struct tas2780_privfunction tas2780_resetfunction tas2780_codec_suspendfunction tas2780_codec_resumefunction tas2780_mutefunction tas2780_set_bitwidthfunction tas2780_set_sampleratefunction tas2780_hw_paramsfunction tas2780_set_fmtfunction tas2780_set_dai_tdm_slotfunction tas2780_codec_probefunction tas2780_parse_dtfunction tas2780_i2c_probe
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
- Immediate include surface: `linux/module.h`, `linux/err.h`, `linux/pm.h`, `linux/i2c.h`, `linux/gpio/consumer.h`, `linux/regmap.h`, `linux/of.h`, `sound/soc.h`.
- Detected declarations: `struct tas2780_priv`, `function tas2780_reset`, `function tas2780_codec_suspend`, `function tas2780_codec_resume`, `function tas2780_mute`, `function tas2780_set_bitwidth`, `function tas2780_set_samplerate`, `function tas2780_hw_params`, `function tas2780_set_fmt`, `function tas2780_set_dai_tdm_slot`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.