sound/soc/codecs/tas5720.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/tas5720.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/tas5720.c- Extension
.c- Size
- 24000 bytes
- Lines
- 828
- 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/errno.hlinux/device.hlinux/i2c.hlinux/regmap.hlinux/slab.hlinux/regulator/consumer.hlinux/delay.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/tlv.htas5720.h
Detected Declarations
struct tas5720_dataenum tas572x_typefunction tas5720_hw_paramsfunction tas5720_set_dai_fmtfunction tas5720_set_dai_tdm_slotfunction selectionfunction tas5720_mute_soc_componentfunction tas5720_mutefunction tas5720_fault_check_workfunction tas5720_codec_probefunction tas5720_codec_removefunction tas5720_dac_eventfunction tas5720_suspendfunction tas5720_resumefunction tas5720_is_volatile_regfunction tas5722_volume_getfunction tas5722_volume_setfunction tas5720_probe
Annotated Snippet
struct tas5720_data {
struct snd_soc_component *component;
struct regmap *regmap;
enum tas572x_type devtype;
struct regulator_bulk_data supplies[TAS5720_NUM_SUPPLIES];
struct delayed_work fault_check_work;
unsigned int last_fault;
};
static int tas5720_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;
unsigned int rate = params_rate(params);
bool ssz_ds;
int ret;
switch (rate) {
case 44100:
case 48000:
ssz_ds = false;
break;
case 88200:
case 96000:
ssz_ds = true;
break;
default:
dev_err(component->dev, "unsupported sample rate: %u\n", rate);
return -EINVAL;
}
ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG,
TAS5720_SSZ_DS, ssz_ds);
if (ret < 0) {
dev_err(component->dev, "error setting sample rate: %d\n", ret);
return ret;
}
return 0;
}
static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct snd_soc_component *component = dai->component;
u8 serial_format;
int ret;
if ((fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) != SND_SOC_DAIFMT_CBC_CFC) {
dev_vdbg(component->dev, "DAI clocking invalid\n");
return -EINVAL;
}
switch (fmt & (SND_SOC_DAIFMT_FORMAT_MASK |
SND_SOC_DAIFMT_INV_MASK)) {
case (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF):
/* 1st data bit occur one BCLK cycle after the frame sync */
serial_format = TAS5720_SAIF_I2S;
break;
case (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF):
/*
* Note that although the TAS5720 does not have a dedicated DSP
* mode it doesn't care about the LRCLK duty cycle during TDM
* operation. Therefore we can use the device's I2S mode with
* its delaying of the 1st data bit to receive DSP_A formatted
* data. See device datasheet for additional details.
*/
serial_format = TAS5720_SAIF_I2S;
break;
case (SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF):
/*
* Similar to DSP_A, we can use the fact that the TAS5720 does
* not care about the LRCLK duty cycle during TDM to receive
* DSP_B formatted data in LEFTJ mode (no delaying of the 1st
* data bit).
*/
serial_format = TAS5720_SAIF_LEFTJ;
break;
case (SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF):
/* No delay after the frame sync */
serial_format = TAS5720_SAIF_LEFTJ;
break;
default:
dev_vdbg(component->dev, "DAI Format is not found\n");
return -EINVAL;
}
ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG,
TAS5720_SAIF_FORMAT_MASK,
serial_format);
Annotation
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/device.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/slab.h`, `linux/regulator/consumer.h`, `linux/delay.h`.
- Detected declarations: `struct tas5720_data`, `enum tas572x_type`, `function tas5720_hw_params`, `function tas5720_set_dai_fmt`, `function tas5720_set_dai_tdm_slot`, `function selection`, `function tas5720_mute_soc_component`, `function tas5720_mute`, `function tas5720_fault_check_work`, `function tas5720_codec_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.