sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt2701/mt2701-afe-pcm.c- Extension
.c- Size
- 48577 bytes
- Lines
- 1763
- 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/delay.hlinux/module.hlinux/mfd/syscon.hlinux/of.hlinux/pm_runtime.hsound/pcm_params.hmt2701-afe-common.hmt2701-afe-clock-ctrl.h../common/mtk-afe-platform-driver.h../common/mtk-afe-fe-dai.h
Detected Declarations
struct mt2701_afe_ratefunction mt2701_dai_num_to_i2sfunction mt2701_afe_i2s_fsfunction mt2701_afe_i2s_startupfunction mt2701_afe_i2s_path_disablefunction mt2701_afe_i2s_shutdownfunction mt2701_i2s_path_enablefunction mt2701_afe_i2s_preparefunction mt2701_afe_i2s_set_sysclkfunction mt2701_btmrg_startupfunction mt2701_btmrg_hw_paramsfunction mt2701_btmrg_shutdownfunction mt2701_simple_fe_startupfunction mt2701_simple_fe_hw_paramsfunction mt2701_dlm_fe_startupfunction mt2701_dlm_fe_shutdownfunction mt2701_dlm_fe_hw_paramsfunction mt2701_dlm_fe_triggerfunction mt2701_memif_fsfunction mt2701_irq_fsfunction mt2701_afe_hdmi_startupfunction mt2701_afe_hdmi_shutdownfunction mt2701_afe_hdmi_hw_paramsfunction mt2701_afe_hdmi_triggerfunction mt2701_afe_hdmi_hw_freefunction mt2701_afe_pcm_probefunction mt2701_asys_isrfunction mt2701_afe_runtime_suspendfunction mt2701_afe_runtime_resumefunction mt2701_afe_pcm_dev_probefunction mt2701_afe_pcm_dev_remove
Annotated Snippet
struct mt2701_afe_rate {
unsigned int rate;
unsigned int regvalue;
};
static const struct mt2701_afe_rate mt2701_afe_i2s_rates[] = {
{ .rate = 8000, .regvalue = 0 },
{ .rate = 12000, .regvalue = 1 },
{ .rate = 16000, .regvalue = 2 },
{ .rate = 24000, .regvalue = 3 },
{ .rate = 32000, .regvalue = 4 },
{ .rate = 48000, .regvalue = 5 },
{ .rate = 96000, .regvalue = 6 },
{ .rate = 192000, .regvalue = 7 },
{ .rate = 384000, .regvalue = 8 },
{ .rate = 7350, .regvalue = 16 },
{ .rate = 11025, .regvalue = 17 },
{ .rate = 14700, .regvalue = 18 },
{ .rate = 22050, .regvalue = 19 },
{ .rate = 29400, .regvalue = 20 },
{ .rate = 44100, .regvalue = 21 },
{ .rate = 88200, .regvalue = 22 },
{ .rate = 176400, .regvalue = 23 },
{ .rate = 352800, .regvalue = 24 },
};
static const unsigned int mt2701_afe_backup_list[] = {
AUDIO_TOP_CON0,
AUDIO_TOP_CON3,
AUDIO_TOP_CON4,
AUDIO_TOP_CON5,
ASYS_TOP_CON,
AFE_CONN0,
AFE_CONN1,
AFE_CONN2,
AFE_CONN3,
AFE_CONN15,
AFE_CONN16,
AFE_CONN17,
AFE_CONN18,
AFE_CONN19,
AFE_CONN20,
AFE_CONN21,
AFE_CONN22,
AFE_DAC_CON0,
AFE_MEMIF_PBUF_SIZE,
AFE_HDMI_OUT_CON0,
AFE_HDMI_CONN0,
AFE_8CH_I2S_OUT_CON,
};
static int mt2701_dai_num_to_i2s(struct mtk_base_afe *afe, int num)
{
struct mt2701_afe_private *afe_priv = afe->platform_priv;
int val = num - MT2701_IO_I2S;
if (val < 0 || val >= afe_priv->soc->i2s_num) {
dev_err(afe->dev, "%s, num not available, num %d, val %d\n",
__func__, num, val);
return -EINVAL;
}
return val;
}
static int mt2701_afe_i2s_fs(unsigned int sample_rate)
{
int i;
for (i = 0; i < ARRAY_SIZE(mt2701_afe_i2s_rates); i++)
if (mt2701_afe_i2s_rates[i].rate == sample_rate)
return mt2701_afe_i2s_rates[i].regvalue;
return -EINVAL;
}
static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mt2701_afe_private *afe_priv = afe->platform_priv;
int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id);
bool mode = afe_priv->soc->has_one_heart_mode;
if (i2s_num < 0)
return i2s_num;
return mt2701_afe_enable_mclk(afe, mode ? 1 : i2s_num);
}
static int mt2701_afe_i2s_path_disable(struct mtk_base_afe *afe,
Annotation
- Immediate include surface: `linux/delay.h`, `linux/module.h`, `linux/mfd/syscon.h`, `linux/of.h`, `linux/pm_runtime.h`, `sound/pcm_params.h`, `mt2701-afe-common.h`, `mt2701-afe-clock-ctrl.h`.
- Detected declarations: `struct mt2701_afe_rate`, `function mt2701_dai_num_to_i2s`, `function mt2701_afe_i2s_fs`, `function mt2701_afe_i2s_startup`, `function mt2701_afe_i2s_path_disable`, `function mt2701_afe_i2s_shutdown`, `function mt2701_i2s_path_enable`, `function mt2701_afe_i2s_prepare`, `function mt2701_afe_i2s_set_sysclk`, `function mt2701_btmrg_startup`.
- 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.