sound/soc/codecs/pcm1754.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/pcm1754.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/pcm1754.c- Extension
.c- Size
- 4636 bytes
- Lines
- 186
- 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/module.hlinux/regulator/consumer.hsound/pcm_params.hsound/soc.h
Detected Declarations
struct pcm1754_privfunction pcm1754_set_dai_fmtfunction pcm1754_hw_paramsfunction pcm1754_mute_streamfunction pcm1754_probe
Annotated Snippet
struct pcm1754_priv {
unsigned int format;
struct gpio_desc *gpiod_mute;
struct gpio_desc *gpiod_format;
};
static int pcm1754_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int format)
{
struct snd_soc_component *component = codec_dai->component;
struct pcm1754_priv *priv = snd_soc_component_get_drvdata(component);
priv->format = format;
return 0;
}
static int pcm1754_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *codec_dai)
{
struct snd_soc_component *component = codec_dai->component;
struct pcm1754_priv *priv = snd_soc_component_get_drvdata(component);
int format;
switch (priv->format & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_RIGHT_J:
switch (params_width(params)) {
case 16:
format = 1;
break;
default:
return -EINVAL;
}
break;
case SND_SOC_DAIFMT_I2S:
switch (params_width(params)) {
case 16:
fallthrough;
case 24:
format = 0;
break;
default:
return -EINVAL;
}
break;
default:
dev_err(component->dev, "Invalid DAI format\n");
return -EINVAL;
}
gpiod_set_value_cansleep(priv->gpiod_format, format);
return 0;
}
static int pcm1754_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
{
struct pcm1754_priv *priv = snd_soc_component_get_drvdata(dai->component);
gpiod_set_value_cansleep(priv->gpiod_mute, mute);
return 0;
}
static const struct snd_soc_dai_ops pcm1754_dai_ops = {
.set_fmt = pcm1754_set_dai_fmt,
.hw_params = pcm1754_hw_params,
.mute_stream = pcm1754_mute_stream,
};
static const struct snd_soc_dai_driver pcm1754_dai = {
.name = "pcm1754",
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 5000,
.rate_max = 200000,
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE
},
.ops = &pcm1754_dai_ops,
};
static const struct snd_soc_dapm_widget pcm1754_dapm_widgets[] = {
SND_SOC_DAPM_REGULATOR_SUPPLY("VCC", 0, 0),
SND_SOC_DAPM_DAC("DAC1", "Channel 1 Playback", SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_DAC("DAC2", "Channel 2 Playback", SND_SOC_NOPM, 0, 0),
Annotation
- Immediate include surface: `linux/gpio/consumer.h`, `linux/module.h`, `linux/regulator/consumer.h`, `sound/pcm_params.h`, `sound/soc.h`.
- Detected declarations: `struct pcm1754_priv`, `function pcm1754_set_dai_fmt`, `function pcm1754_hw_params`, `function pcm1754_mute_stream`, `function pcm1754_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.