sound/soc/codecs/pcm179x.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/pcm179x.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/pcm179x.c- Extension
.c- Size
- 5689 bytes
- Lines
- 232
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/device.hsound/core.hsound/pcm.hsound/pcm_params.hsound/initval.hsound/soc.hsound/tlv.hlinux/of.hpcm179x.h
Detected Declarations
struct pcm179x_privatefunction pcm179x_accessible_regfunction pcm179x_writeable_regfunction pcm179x_set_dai_fmtfunction pcm179x_mutefunction pcm179x_hw_paramsfunction pcm179x_common_initexport pcm179x_regmap_configexport pcm179x_common_init
Annotated Snippet
struct pcm179x_private {
struct regmap *regmap;
unsigned int format;
unsigned int rate;
};
static int pcm179x_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int format)
{
struct snd_soc_component *component = codec_dai->component;
struct pcm179x_private *priv = snd_soc_component_get_drvdata(component);
priv->format = format;
return 0;
}
static int pcm179x_mute(struct snd_soc_dai *dai, int mute, int direction)
{
struct snd_soc_component *component = dai->component;
struct pcm179x_private *priv = snd_soc_component_get_drvdata(component);
int ret;
ret = regmap_update_bits(priv->regmap, PCM179X_SOFT_MUTE,
PCM179X_MUTE_MASK, !!mute);
if (ret < 0)
return ret;
return 0;
}
static int pcm179x_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 pcm179x_private *priv = snd_soc_component_get_drvdata(component);
int val = 0, ret;
priv->rate = params_rate(params);
switch (priv->format & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_RIGHT_J:
switch (params_width(params)) {
case 24:
case 32:
val = 2;
break;
case 16:
val = 0;
break;
default:
return -EINVAL;
}
break;
case SND_SOC_DAIFMT_I2S:
switch (params_width(params)) {
case 24:
case 32:
val = 5;
break;
case 16:
val = 4;
break;
default:
return -EINVAL;
}
break;
default:
dev_err(component->dev, "Invalid DAI format\n");
return -EINVAL;
}
val = val << PCM179X_FMT_SHIFT | PCM179X_ATLD_ENABLE;
ret = regmap_update_bits(priv->regmap, PCM179X_FMT_CONTROL,
PCM179X_FMT_MASK | PCM179X_ATLD_ENABLE, val);
if (ret < 0)
return ret;
return 0;
}
static const struct snd_soc_dai_ops pcm179x_dai_ops = {
.set_fmt = pcm179x_set_dai_fmt,
.hw_params = pcm179x_hw_params,
.mute_stream = pcm179x_mute,
.no_capture_mute = 1,
};
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/kernel.h`, `linux/device.h`, `sound/core.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/initval.h`.
- Detected declarations: `struct pcm179x_private`, `function pcm179x_accessible_reg`, `function pcm179x_writeable_reg`, `function pcm179x_set_dai_fmt`, `function pcm179x_mute`, `function pcm179x_hw_params`, `function pcm179x_common_init`, `export pcm179x_regmap_config`, `export pcm179x_common_init`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.