sound/soc/codecs/pcm3060.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/pcm3060.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/pcm3060.c- Extension
.c- Size
- 8330 bytes
- Lines
- 348
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hsound/pcm_params.hsound/soc.hsound/tlv.hpcm3060.h
Detected Declarations
function pcm3060_set_sysclkfunction pcm3060_set_fmtfunction pcm3060_hw_paramsfunction pcm3060_reg_writeablefunction pcm3060_reg_readablefunction pcm3060_reg_volatilefunction pcm3060_parse_dtfunction pcm3060_probeexport pcm3060_regmapexport pcm3060_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
//
// PCM3060 codec driver
//
// Copyright (C) 2018 Kirill Marinushkin <k.marinushkin@gmail.com>
#include <linux/module.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include "pcm3060.h"
/* dai */
static int pcm3060_set_sysclk(struct snd_soc_dai *dai, int clk_id,
unsigned int freq, int dir)
{
struct snd_soc_component *comp = dai->component;
struct pcm3060_priv *priv = snd_soc_component_get_drvdata(comp);
unsigned int reg;
unsigned int val;
if (dir != SND_SOC_CLOCK_IN) {
dev_err(comp->dev, "unsupported sysclock dir: %d\n", dir);
return -EINVAL;
}
switch (clk_id) {
case PCM3060_CLK_DEF:
val = 0;
break;
case PCM3060_CLK1:
val = (dai->id == PCM3060_DAI_ID_DAC ? PCM3060_REG_CSEL : 0);
break;
case PCM3060_CLK2:
val = (dai->id == PCM3060_DAI_ID_DAC ? 0 : PCM3060_REG_CSEL);
break;
default:
dev_err(comp->dev, "unsupported sysclock id: %d\n", clk_id);
return -EINVAL;
}
if (dai->id == PCM3060_DAI_ID_DAC)
reg = PCM3060_REG67;
else
reg = PCM3060_REG72;
regmap_update_bits(priv->regmap, reg, PCM3060_REG_CSEL, val);
priv->dai[dai->id].sclk_freq = freq;
return 0;
}
static int pcm3060_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct snd_soc_component *comp = dai->component;
struct pcm3060_priv *priv = snd_soc_component_get_drvdata(comp);
unsigned int reg;
unsigned int val;
if ((fmt & SND_SOC_DAIFMT_INV_MASK) != SND_SOC_DAIFMT_NB_NF) {
dev_err(comp->dev, "unsupported DAI polarity: 0x%x\n", fmt);
return -EINVAL;
}
switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
case SND_SOC_DAIFMT_CBP_CFP:
priv->dai[dai->id].is_provider = true;
break;
case SND_SOC_DAIFMT_CBC_CFC:
priv->dai[dai->id].is_provider = false;
break;
default:
dev_err(comp->dev, "unsupported DAI mode: 0x%x\n", fmt);
return -EINVAL;
}
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
val = PCM3060_REG_FMT_I2S;
break;
case SND_SOC_DAIFMT_RIGHT_J:
val = PCM3060_REG_FMT_RJ;
break;
case SND_SOC_DAIFMT_LEFT_J:
Annotation
- Immediate include surface: `linux/module.h`, `sound/pcm_params.h`, `sound/soc.h`, `sound/tlv.h`, `pcm3060.h`.
- Detected declarations: `function pcm3060_set_sysclk`, `function pcm3060_set_fmt`, `function pcm3060_hw_params`, `function pcm3060_reg_writeable`, `function pcm3060_reg_readable`, `function pcm3060_reg_volatile`, `function pcm3060_parse_dt`, `function pcm3060_probe`, `export pcm3060_regmap`, `export pcm3060_probe`.
- 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.