sound/soc/atmel/atmel-pdmic.c
Source file repositories/reference/linux-study-clean/sound/soc/atmel/atmel-pdmic.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/atmel/atmel-pdmic.c- Extension
.c- Size
- 20408 bytes
- Lines
- 703
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/of.hlinux/clk.hlinux/module.hlinux/platform_device.hlinux/regmap.hsound/core.hsound/dmaengine_pcm.hsound/pcm_params.hsound/tlv.hatmel-pdmic.h
Detected Declarations
struct atmel_pdmic_pdatastruct atmel_pdmicstruct mic_gainfunction atmel_pdmic_cpu_dai_startupfunction atmel_pdmic_cpu_dai_shutdownfunction atmel_pdmic_cpu_dai_preparefunction atmel_pdmic_platform_configure_dmafunction pdmic_get_mic_volswfunction pdmic_put_mic_volswfunction atmel_pdmic_component_probefunction atmel_pdmic_cpu_dai_hw_paramsfunction atmel_pdmic_cpu_dai_triggerfunction atmel_pdmic_asoc_card_initfunction atmel_pdmic_get_sample_ratefunction atmel_pdmic_interruptfunction atmel_pdmic_probe
Annotated Snippet
struct atmel_pdmic_pdata {
u32 mic_min_freq;
u32 mic_max_freq;
s32 mic_offset;
const char *card_name;
};
struct atmel_pdmic {
dma_addr_t phy_base;
struct regmap *regmap;
struct clk *pclk;
struct clk *gclk;
struct device *dev;
int irq;
struct snd_pcm_substream *substream;
const struct atmel_pdmic_pdata *pdata;
};
static const struct of_device_id atmel_pdmic_of_match[] = {
{
.compatible = "atmel,sama5d2-pdmic",
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, atmel_pdmic_of_match);
#define PDMIC_OFFSET_MAX_VAL S16_MAX
#define PDMIC_OFFSET_MIN_VAL S16_MIN
static struct atmel_pdmic_pdata *atmel_pdmic_dt_init(struct device *dev)
{
struct device_node *np = dev->of_node;
struct atmel_pdmic_pdata *pdata;
if (!np) {
dev_err(dev, "device node not found\n");
return ERR_PTR(-EINVAL);
}
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
if (of_property_read_string(np, "atmel,model", &pdata->card_name))
pdata->card_name = "PDMIC";
if (of_property_read_u32(np, "atmel,mic-min-freq",
&pdata->mic_min_freq)) {
dev_err(dev, "failed to get mic-min-freq\n");
return ERR_PTR(-EINVAL);
}
if (of_property_read_u32(np, "atmel,mic-max-freq",
&pdata->mic_max_freq)) {
dev_err(dev, "failed to get mic-max-freq\n");
return ERR_PTR(-EINVAL);
}
if (pdata->mic_max_freq < pdata->mic_min_freq) {
dev_err(dev,
"mic-max-freq should not be less than mic-min-freq\n");
return ERR_PTR(-EINVAL);
}
if (of_property_read_s32(np, "atmel,mic-offset", &pdata->mic_offset))
pdata->mic_offset = 0;
if (pdata->mic_offset > PDMIC_OFFSET_MAX_VAL) {
dev_warn(dev,
"mic-offset value %d is larger than the max value %d, the max value is specified\n",
pdata->mic_offset, PDMIC_OFFSET_MAX_VAL);
pdata->mic_offset = PDMIC_OFFSET_MAX_VAL;
} else if (pdata->mic_offset < PDMIC_OFFSET_MIN_VAL) {
dev_warn(dev,
"mic-offset value %d is less than the min value %d, the min value is specified\n",
pdata->mic_offset, PDMIC_OFFSET_MIN_VAL);
pdata->mic_offset = PDMIC_OFFSET_MIN_VAL;
}
return pdata;
}
/* cpu dai component */
static int atmel_pdmic_cpu_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct atmel_pdmic *dd = snd_soc_card_get_drvdata(rtd->card);
int ret;
Annotation
- Immediate include surface: `linux/of.h`, `linux/clk.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`, `sound/core.h`, `sound/dmaengine_pcm.h`, `sound/pcm_params.h`.
- Detected declarations: `struct atmel_pdmic_pdata`, `struct atmel_pdmic`, `struct mic_gain`, `function atmel_pdmic_cpu_dai_startup`, `function atmel_pdmic_cpu_dai_shutdown`, `function atmel_pdmic_cpu_dai_prepare`, `function atmel_pdmic_platform_configure_dma`, `function pdmic_get_mic_volsw`, `function pdmic_put_mic_volsw`, `function atmel_pdmic_component_probe`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.