sound/soc/codecs/tfa9879.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/tfa9879.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/tfa9879.c- Extension
.c- Size
- 8791 bytes
- Lines
- 324
- 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/init.hlinux/i2c.hlinux/regmap.hsound/soc.hsound/tlv.hsound/pcm_params.htfa9879.h
Detected Declarations
struct tfa9879_privfunction tfa9879_hw_paramsfunction tfa9879_mute_streamfunction tfa9879_set_fmtfunction tfa9879_volatile_regfunction tfa9879_i2c_probe
Annotated Snippet
struct tfa9879_priv {
struct regmap *regmap;
int lsb_justified;
};
static int tfa9879_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct tfa9879_priv *tfa9879 = snd_soc_component_get_drvdata(component);
int fs;
int i2s_set = 0;
switch (params_rate(params)) {
case 8000:
fs = TFA9879_I2S_FS_8000;
break;
case 11025:
fs = TFA9879_I2S_FS_11025;
break;
case 12000:
fs = TFA9879_I2S_FS_12000;
break;
case 16000:
fs = TFA9879_I2S_FS_16000;
break;
case 22050:
fs = TFA9879_I2S_FS_22050;
break;
case 24000:
fs = TFA9879_I2S_FS_24000;
break;
case 32000:
fs = TFA9879_I2S_FS_32000;
break;
case 44100:
fs = TFA9879_I2S_FS_44100;
break;
case 48000:
fs = TFA9879_I2S_FS_48000;
break;
case 64000:
fs = TFA9879_I2S_FS_64000;
break;
case 88200:
fs = TFA9879_I2S_FS_88200;
break;
case 96000:
fs = TFA9879_I2S_FS_96000;
break;
default:
return -EINVAL;
}
switch (params_width(params)) {
case 16:
i2s_set = TFA9879_I2S_SET_LSB_J_16;
break;
case 24:
i2s_set = TFA9879_I2S_SET_LSB_J_24;
break;
default:
return -EINVAL;
}
if (tfa9879->lsb_justified)
snd_soc_component_update_bits(component,
TFA9879_SERIAL_INTERFACE_1,
TFA9879_I2S_SET_MASK,
i2s_set << TFA9879_I2S_SET_SHIFT);
snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1,
TFA9879_I2S_FS_MASK,
fs << TFA9879_I2S_FS_SHIFT);
return 0;
}
static int tfa9879_mute_stream(struct snd_soc_dai *dai, int mute, int direction)
{
struct snd_soc_component *component = dai->component;
snd_soc_component_update_bits(component, TFA9879_MISC_CONTROL,
TFA9879_S_MUTE_MASK,
!!mute << TFA9879_S_MUTE_SHIFT);
return 0;
}
static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/i2c.h`, `linux/regmap.h`, `sound/soc.h`, `sound/tlv.h`, `sound/pcm_params.h`, `tfa9879.h`.
- Detected declarations: `struct tfa9879_priv`, `function tfa9879_hw_params`, `function tfa9879_mute_stream`, `function tfa9879_set_fmt`, `function tfa9879_volatile_reg`, `function tfa9879_i2c_probe`.
- 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.