sound/soc/codecs/tas5086.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/tas5086.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/tas5086.c- Extension
.c- Size
- 28630 bytes
- Lines
- 992
- 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/slab.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/regmap.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/of.hlinux/of_device.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/tlv.hsound/tas5086.h
Detected Declarations
struct tas5086_privatefunction tas5086_register_sizefunction tas5086_accessible_regfunction tas5086_volatile_regfunction tas5086_writeable_regfunction tas5086_reg_writefunction tas5086_reg_readfunction tas5086_set_deemphfunction tas5086_get_deemphfunction tas5086_put_deemphfunction tas5086_set_dai_sysclkfunction tas5086_set_dai_fmtfunction index_in_arrayfunction tas5086_hw_paramsfunction set_dai_fmtfunction tas5086_mute_streamfunction tas5086_resetfunction tas5086_initfunction tas5086_soc_suspendfunction tas5086_soc_resumefunction tas5086_probefunction tas5086_removefunction tas5086_i2c_probe
Annotated Snippet
struct tas5086_private {
struct regmap *regmap;
unsigned int mclk, sclk;
unsigned int format;
bool deemph;
unsigned int charge_period;
unsigned int pwm_start_mid_z;
/* Current sample rate for de-emphasis control */
int rate;
/* GPIO driving Reset pin, if any */
struct gpio_desc *reset;
struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
};
static int tas5086_deemph[] = { 0, 32000, 44100, 48000 };
static int tas5086_set_deemph(struct snd_soc_component *component)
{
struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
int i, val = 0;
if (priv->deemph) {
for (i = 0; i < ARRAY_SIZE(tas5086_deemph); i++) {
if (tas5086_deemph[i] == priv->rate) {
val = i;
break;
}
}
}
return regmap_update_bits(priv->regmap, TAS5086_SYS_CONTROL_1,
TAS5086_DEEMPH_MASK, val);
}
static int tas5086_get_deemph(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = priv->deemph;
return 0;
}
static int tas5086_put_deemph(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
priv->deemph = ucontrol->value.integer.value[0];
return tas5086_set_deemph(component);
}
static int tas5086_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{
struct snd_soc_component *component = codec_dai->component;
struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
switch (clk_id) {
case TAS5086_CLK_IDX_MCLK:
priv->mclk = freq;
break;
case TAS5086_CLK_IDX_SCLK:
priv->sclk = freq;
break;
}
return 0;
}
static int tas5086_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int format)
{
struct snd_soc_component *component = codec_dai->component;
struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
/* The TAS5086 can only be slave to all clocks */
if ((format & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) != SND_SOC_DAIFMT_CBC_CFC) {
dev_err(component->dev, "Invalid clocking mode\n");
return -EINVAL;
}
/* we need to refer to the data format from hw_params() */
priv->format = format;
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/regulator/consumer.h`, `linux/spi/spi.h`.
- Detected declarations: `struct tas5086_private`, `function tas5086_register_size`, `function tas5086_accessible_reg`, `function tas5086_volatile_reg`, `function tas5086_writeable_reg`, `function tas5086_reg_write`, `function tas5086_reg_read`, `function tas5086_set_deemph`, `function tas5086_get_deemph`, `function tas5086_put_deemph`.
- 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.