sound/soc/codecs/pcm1789.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/pcm1789.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/pcm1789.c- Extension
.c- Size
- 6852 bytes
- Lines
- 272
- 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/gpio/consumer.hlinux/module.hlinux/workqueue.hsound/pcm_params.hsound/soc.hsound/tlv.hpcm1789.h
Detected Declarations
struct pcm1789_privatefunction pcm1789_accessible_regfunction pcm1789_writeable_regfunction pcm1789_set_dai_fmtfunction pcm1789_mutefunction pcm1789_hw_paramsfunction pcm1789_work_queuefunction pcm1789_triggerfunction pcm1789_common_initfunction pcm1789_common_exitexport pcm1789_regmap_configexport pcm1789_common_initexport pcm1789_common_exit
Annotated Snippet
struct pcm1789_private {
struct regmap *regmap;
unsigned int format;
unsigned int rate;
struct gpio_desc *reset;
struct work_struct work;
struct device *dev;
};
static const struct reg_default pcm1789_reg_defaults[] = {
{ PCM1789_FMT_CONTROL, 0x00 },
{ PCM1789_SOFT_MUTE, 0x00 },
{ PCM1789_DAC_VOL_LEFT, 0xff },
{ PCM1789_DAC_VOL_RIGHT, 0xff },
};
static bool pcm1789_accessible_reg(struct device *dev, unsigned int reg)
{
return reg >= PCM1789_MUTE_CONTROL && reg <= PCM1789_DAC_VOL_RIGHT;
}
static bool pcm1789_writeable_reg(struct device *dev, unsigned int reg)
{
return pcm1789_accessible_reg(dev, reg);
}
static int pcm1789_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int format)
{
struct snd_soc_component *component = codec_dai->component;
struct pcm1789_private *priv = snd_soc_component_get_drvdata(component);
priv->format = format;
return 0;
}
static int pcm1789_mute(struct snd_soc_dai *codec_dai, int mute, int direction)
{
struct snd_soc_component *component = codec_dai->component;
struct pcm1789_private *priv = snd_soc_component_get_drvdata(component);
return regmap_update_bits(priv->regmap, PCM1789_SOFT_MUTE,
PCM1789_MUTE_MASK,
mute ? 0 : PCM1789_MUTE_MASK);
}
static int pcm1789_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 pcm1789_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:
val = 2;
break;
case 16:
val = 3;
break;
default:
return -EINVAL;
}
break;
case SND_SOC_DAIFMT_I2S:
switch (params_width(params)) {
case 16:
case 24:
case 32:
val = 0;
break;
default:
return -EINVAL;
}
break;
case SND_SOC_DAIFMT_LEFT_J:
switch (params_width(params)) {
case 16:
case 24:
case 32:
val = 1;
break;
default:
return -EINVAL;
Annotation
- Immediate include surface: `linux/gpio/consumer.h`, `linux/module.h`, `linux/workqueue.h`, `sound/pcm_params.h`, `sound/soc.h`, `sound/tlv.h`, `pcm1789.h`.
- Detected declarations: `struct pcm1789_private`, `function pcm1789_accessible_reg`, `function pcm1789_writeable_reg`, `function pcm1789_set_dai_fmt`, `function pcm1789_mute`, `function pcm1789_hw_params`, `function pcm1789_work_queue`, `function pcm1789_trigger`, `function pcm1789_common_init`, `function pcm1789_common_exit`.
- 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.