sound/soc/mediatek/common/mtk-afe-fe-dai.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/common/mtk-afe-fe-dai.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/common/mtk-afe-fe-dai.c- Extension
.c- Size
- 16197 bytes
- Lines
- 589
- 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/io.hlinux/module.hlinux/pm_runtime.hlinux/regmap.hsound/soc.hmtk-afe-platform-driver.hsound/pcm_params.hmtk-afe-fe-dai.hmtk-base-afe.h
Detected Declarations
function Copyrightfunction mtk_regmap_writefunction mtk_afe_fe_startupfunction mtk_afe_fe_shutdownfunction mtk_afe_fe_hw_paramsfunction mtk_afe_fe_hw_freefunction mtk_afe_fe_triggerfunction mtk_afe_fe_preparefunction mtk_dynamic_irq_acquirefunction mtk_dynamic_irq_releasefunction mtk_afe_suspendfunction mtk_afe_resumefunction mtk_memif_set_enablefunction mtk_memif_set_disablefunction mtk_memif_set_addrfunction mtk_memif_set_channelfunction mtk_memif_set_rate_fsfunction mtk_memif_set_rate_substreamfunction mtk_memif_set_formatfunction mtk_memif_set_pbuf_sizeexport mtk_afe_fe_startupexport mtk_afe_fe_shutdownexport mtk_afe_fe_hw_paramsexport mtk_afe_fe_hw_freeexport mtk_afe_fe_triggerexport mtk_afe_fe_prepareexport mtk_afe_fe_opsexport mtk_dynamic_irq_acquireexport mtk_dynamic_irq_releaseexport mtk_afe_suspendexport mtk_afe_resumeexport mtk_memif_set_enableexport mtk_memif_set_disableexport mtk_memif_set_addrexport mtk_memif_set_channelexport mtk_memif_set_rate_substreamexport mtk_memif_set_formatexport mtk_memif_set_pbuf_size
Annotated Snippet
if (ret < 0) {
dev_err(afe->dev, "hw_constraint_minmax failed\n");
return ret;
}
}
ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
dev_err(afe->dev, "snd_pcm_hw_constraint_integer failed\n");
/* dynamic allocate irq to memif */
if (memif->irq_usage < 0) {
int irq_id = mtk_dynamic_irq_acquire(afe);
if (irq_id != afe->irqs_size) {
/* link */
memif->irq_usage = irq_id;
} else {
dev_err(afe->dev, "%s() error: no more asys irq\n",
__func__);
ret = -EBUSY;
}
}
return ret;
}
EXPORT_SYMBOL_GPL(mtk_afe_fe_startup);
void mtk_afe_fe_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mtk_base_afe_memif *memif = &afe->memif[snd_soc_rtd_to_cpu(rtd, 0)->id];
int irq_id;
irq_id = memif->irq_usage;
mtk_regmap_update_bits(afe->regmap, memif->data->agent_disable_reg,
1, 1, memif->data->agent_disable_shift);
if (!memif->const_irq) {
mtk_dynamic_irq_release(afe, irq_id);
memif->irq_usage = -1;
memif->substream = NULL;
}
}
EXPORT_SYMBOL_GPL(mtk_afe_fe_shutdown);
int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
int id = snd_soc_rtd_to_cpu(rtd, 0)->id;
struct mtk_base_afe_memif *memif = &afe->memif[id];
int ret;
unsigned int channels = params_channels(params);
unsigned int rate = params_rate(params);
snd_pcm_format_t format = params_format(params);
if (afe->request_dram_resource)
afe->request_dram_resource(afe->dev);
dev_dbg(afe->dev, "%s(), %s, ch %d, rate %d, fmt %d, dma_addr %pad, dma_area %p, dma_bytes 0x%zx\n",
__func__, memif->data->name,
channels, rate, format,
&substream->runtime->dma_addr,
substream->runtime->dma_area,
substream->runtime->dma_bytes);
memset_io((void __force __iomem *)substream->runtime->dma_area, 0,
substream->runtime->dma_bytes);
/* set addr */
ret = mtk_memif_set_addr(afe, id,
substream->runtime->dma_area,
substream->runtime->dma_addr,
substream->runtime->dma_bytes);
if (ret) {
dev_err(afe->dev, "%s(), error, id %d, set addr, ret %d\n",
__func__, id, ret);
return ret;
}
/* set channel */
ret = mtk_memif_set_channel(afe, id, channels);
if (ret) {
dev_err(afe->dev, "%s(), error, id %d, set channel %d, ret %d\n",
Annotation
- Immediate include surface: `linux/io.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/regmap.h`, `sound/soc.h`, `mtk-afe-platform-driver.h`, `sound/pcm_params.h`, `mtk-afe-fe-dai.h`.
- Detected declarations: `function Copyright`, `function mtk_regmap_write`, `function mtk_afe_fe_startup`, `function mtk_afe_fe_shutdown`, `function mtk_afe_fe_hw_params`, `function mtk_afe_fe_hw_free`, `function mtk_afe_fe_trigger`, `function mtk_afe_fe_prepare`, `function mtk_dynamic_irq_acquire`, `function mtk_dynamic_irq_release`.
- 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.