sound/soc/atmel/mchp-pdmc.c
Source file repositories/reference/linux-study-clean/sound/soc/atmel/mchp-pdmc.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/atmel/mchp-pdmc.c- Extension
.c- Size
- 30523 bytes
- Lines
- 1157
- 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 user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
dt-bindings/sound/microchip,pdmc.hlinux/bitfield.hlinux/clk.hlinux/module.hlinux/of.hlinux/pm_runtime.hlinux/regmap.hsound/core.hsound/dmaengine_pcm.hsound/pcm_params.hsound/tlv.h
Detected Declarations
struct mic_mapstruct mchp_pdmc_chmapstruct mchp_pdmcfunction mchp_pdmc_sinc_order_getfunction mchp_pdmc_sinc_order_putfunction mchp_pdmc_af_getfunction mchp_pdmc_af_putfunction mchp_pdmc_chmap_ctl_infofunction mchp_pdmc_chmap_substreamfunction mchp_pdmc_chmap_ctl_getfunction mchp_pdmc_chmap_ctl_putfunction mchp_pdmc_chmap_ctl_private_freefunction mchp_pdmc_chmap_ctl_tlvfunction mchp_pdmc_startupfunction mchp_pdmc_dai_probefunction mchp_pdmc_set_fmtfunction mchp_pdmc_mr_set_osrfunction mchp_pdmc_period_to_maxburstfunction mchp_pdmc_hw_paramsfunction mchp_pdmc_noise_filter_workaroundfunction mchp_pdmc_triggerfunction mchp_pdmc_add_chmap_ctlsfunction mchp_pdmc_pcm_newfunction mchp_pdmc_interruptfunction mchp_pdmc_readable_regfunction mchp_pdmc_writeable_regfunction mchp_pdmc_volatile_regfunction mchp_pdmc_precious_regfunction mchp_pdmc_dt_initfunction mchp_pdmc_processfunction mchp_pdmc_runtime_suspendfunction mchp_pdmc_runtime_resumefunction mchp_pdmc_probefunction mchp_pdmc_remove
Annotated Snippet
struct mic_map {
int ds_pos;
int clk_edge;
};
struct mchp_pdmc_chmap {
struct snd_pcm_chmap_elem *chmap;
struct mchp_pdmc *dd;
struct snd_pcm *pcm;
struct snd_kcontrol *kctl;
};
struct mchp_pdmc {
struct mic_map channel_mic_map[MCHP_PDMC_MAX_CHANNELS];
struct device *dev;
struct snd_dmaengine_dai_dma_data addr;
struct regmap *regmap;
struct clk *pclk;
struct clk *gclk;
u32 pdmcen;
u32 suspend_irq;
u32 startup_delay_us;
int mic_no;
int sinc_order;
bool audio_filter_en;
atomic_t busy_stream;
};
static const char *const mchp_pdmc_sinc_filter_order_text[] = {
"1", "2", "3", "4", "5"
};
static const unsigned int mchp_pdmc_sinc_filter_order_values[] = {
1, 2, 3, 4, 5,
};
static const struct soc_enum mchp_pdmc_sinc_filter_order_enum = {
.items = ARRAY_SIZE(mchp_pdmc_sinc_filter_order_text),
.texts = mchp_pdmc_sinc_filter_order_text,
.values = mchp_pdmc_sinc_filter_order_values,
};
static int mchp_pdmc_sinc_order_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *uvalue)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct mchp_pdmc *dd = snd_soc_component_get_drvdata(component);
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int item;
item = snd_soc_enum_val_to_item(e, dd->sinc_order);
uvalue->value.enumerated.item[0] = item;
return 0;
}
static int mchp_pdmc_sinc_order_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *uvalue)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct mchp_pdmc *dd = snd_soc_component_get_drvdata(component);
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
unsigned int *item = uvalue->value.enumerated.item;
unsigned int val;
if (item[0] >= e->items)
return -EINVAL;
val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l;
if (atomic_read(&dd->busy_stream))
return -EBUSY;
if (val == dd->sinc_order)
return 0;
dd->sinc_order = val;
return 1;
}
static int mchp_pdmc_af_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *uvalue)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct mchp_pdmc *dd = snd_soc_component_get_drvdata(component);
uvalue->value.integer.value[0] = !!dd->audio_filter_en;
return 0;
Annotation
- Immediate include surface: `dt-bindings/sound/microchip,pdmc.h`, `linux/bitfield.h`, `linux/clk.h`, `linux/module.h`, `linux/of.h`, `linux/pm_runtime.h`, `linux/regmap.h`, `sound/core.h`.
- Detected declarations: `struct mic_map`, `struct mchp_pdmc_chmap`, `struct mchp_pdmc`, `function mchp_pdmc_sinc_order_get`, `function mchp_pdmc_sinc_order_put`, `function mchp_pdmc_af_get`, `function mchp_pdmc_af_put`, `function mchp_pdmc_chmap_ctl_info`, `function mchp_pdmc_chmap_substream`, `function mchp_pdmc_chmap_ctl_get`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.