sound/soc/codecs/tfa989x.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/tfa989x.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/tfa989x.c- Extension
.c- Size
- 12543 bytes
- Lines
- 426
- 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/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/regmap.hlinux/regulator/consumer.hsound/soc.h
Detected Declarations
struct tfa989x_revstruct tfa989xfunction tfa989x_writeable_regfunction tfa989x_volatile_regfunction tfa989x_put_modefunction tfa989x_probefunction tfa989x_find_sample_ratefunction tfa989x_hw_paramsfunction tfa9890_initfunction tfa9895_initfunction tfa9897_initfunction configurationfunction tfa989x_regulator_disablefunction tfa989x_i2c_probe
Annotated Snippet
struct tfa989x_rev {
unsigned int rev;
int (*init)(struct regmap *regmap);
};
struct tfa989x {
const struct tfa989x_rev *rev;
struct regulator *vddd_supply;
struct gpio_desc *rcv_gpiod;
};
static bool tfa989x_writeable_reg(struct device *dev, unsigned int reg)
{
return reg > TFA989X_REVISIONNUMBER;
}
static bool tfa989x_volatile_reg(struct device *dev, unsigned int reg)
{
return reg < TFA989X_REVISIONNUMBER;
}
static const struct regmap_config tfa989x_regmap = {
.reg_bits = 8,
.val_bits = 16,
.writeable_reg = tfa989x_writeable_reg,
.volatile_reg = tfa989x_volatile_reg,
.cache_type = REGCACHE_RBTREE,
};
static const char * const chsa_text[] = { "Left", "Right", /* "DSP" */ };
static SOC_ENUM_SINGLE_DECL(chsa_enum, TFA989X_I2SREG, TFA989X_I2SREG_CHSA, chsa_text);
static const struct snd_kcontrol_new chsa_mux = SOC_DAPM_ENUM("Amp Input", chsa_enum);
static const struct snd_soc_dapm_widget tfa989x_dapm_widgets[] = {
SND_SOC_DAPM_OUTPUT("OUT"),
SND_SOC_DAPM_SUPPLY("POWER", TFA989X_SYS_CTRL, TFA989X_SYS_CTRL_PWDN, 1, NULL, 0),
SND_SOC_DAPM_OUT_DRV("AMPE", TFA989X_SYS_CTRL, TFA989X_SYS_CTRL_AMPE, 0, NULL, 0),
SND_SOC_DAPM_MUX("Amp Input", SND_SOC_NOPM, 0, 0, &chsa_mux),
SND_SOC_DAPM_AIF_IN("AIFINL", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("AIFINR", "HiFi Playback", 1, SND_SOC_NOPM, 0, 0),
};
static const struct snd_soc_dapm_route tfa989x_dapm_routes[] = {
{"OUT", NULL, "AMPE"},
{"AMPE", NULL, "POWER"},
{"AMPE", NULL, "Amp Input"},
{"Amp Input", "Left", "AIFINL"},
{"Amp Input", "Right", "AIFINR"},
};
static int tfa989x_put_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct tfa989x *tfa989x = snd_soc_component_get_drvdata(component);
gpiod_set_value_cansleep(tfa989x->rcv_gpiod, ucontrol->value.enumerated.item[0]);
return snd_soc_put_enum_double(kcontrol, ucontrol);
}
static const char * const mode_text[] = { "Speaker", "Receiver" };
static SOC_ENUM_SINGLE_DECL(mode_enum, TFA989X_I2SREG, TFA989X_I2SREG_RCV, mode_text);
static const struct snd_kcontrol_new tfa989x_mode_controls[] = {
SOC_ENUM_EXT("Mode", mode_enum, snd_soc_get_enum_double, tfa989x_put_mode),
};
static int tfa989x_probe(struct snd_soc_component *component)
{
struct tfa989x *tfa989x = snd_soc_component_get_drvdata(component);
if (tfa989x->rev->rev == TFA9897_REVISION)
return snd_soc_add_component_controls(component, tfa989x_mode_controls,
ARRAY_SIZE(tfa989x_mode_controls));
return 0;
}
static const struct snd_soc_component_driver tfa989x_component = {
.probe = tfa989x_probe,
.dapm_widgets = tfa989x_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tfa989x_dapm_widgets),
.dapm_routes = tfa989x_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(tfa989x_dapm_routes),
.use_pmdown_time = 1,
.endianness = 1,
};
static const unsigned int tfa989x_rates[] = {
Annotation
- Immediate include surface: `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/consumer.h`, `sound/soc.h`.
- Detected declarations: `struct tfa989x_rev`, `struct tfa989x`, `function tfa989x_writeable_reg`, `function tfa989x_volatile_reg`, `function tfa989x_put_mode`, `function tfa989x_probe`, `function tfa989x_find_sample_rate`, `function tfa989x_hw_params`, `function tfa9890_init`, `function tfa9895_init`.
- 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.