sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8188/mt8188-afe-pcm.c- Extension
.c- Size
- 100068 bytes
- Lines
- 3400
- 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.
- 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
linux/arm-smccc.hlinux/delay.hlinux/dma-mapping.hlinux/module.hlinux/mfd/syscon.hlinux/of.hlinux/of_address.hlinux/of_platform.hlinux/of_reserved_mem.hlinux/pm_runtime.hlinux/soc/mediatek/infracfg.hlinux/reset.hsound/pcm_params.hmt8188-afe-common.hmt8188-afe-clk.hmt8188-reg.h../common/mtk-afe-platform-driver.h../common/mtk-afe-fe-dai.h
Detected Declarations
struct mtk_dai_memif_privstruct mt8188_afe_ratestruct mt8188_afe_channel_mergefunction mt8188_afe_fs_timingfunction mt8188_memif_fsfunction mt8188_irq_fsfunction mt8188_afe_memif_is_ulfunction mt8188_afe_found_cmfunction mt8188_afe_config_cmfunction mt8188_afe_enable_cmfunction mt8188_afe_fe_startupfunction mt8188_afe_fe_shutdownfunction mt8188_afe_fe_hw_paramsfunction mt8188_afe_fe_triggerfunction mt8188_memif_1x_en_sel_putfunction mt8188_asys_irq_1x_en_sel_putfunction mt8188_memif_fs_timing_sel_getfunction mt8188_memif_fs_timing_sel_putfunction mt8188_is_volatile_regfunction mt8188_afe_irq_handlerfunction mt8188_afe_runtime_suspendfunction mt8188_afe_runtime_resumefunction init_memif_priv_datafunction mt8188_dai_memif_registerfunction mt8188_afe_init_registersfunction mt8188_afe_parse_offunction bus_protect_enablefunction bus_protect_disablefunction mt8188_afe_pcm_dev_probe
Annotated Snippet
struct mtk_dai_memif_priv {
unsigned int asys_timing_sel;
unsigned int fs_timing;
};
static const struct snd_pcm_hardware mt8188_afe_hardware = {
.info = SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_MMAP_VALID,
.formats = SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE,
.period_bytes_min = 64,
.period_bytes_max = 256 * 1024,
.periods_min = 2,
.periods_max = 256,
.buffer_bytes_max = 256 * 2 * 1024,
};
struct mt8188_afe_rate {
unsigned int rate;
unsigned int reg_value;
};
static const struct mt8188_afe_rate mt8188_afe_rates[] = {
{ .rate = 8000, .reg_value = 0, },
{ .rate = 12000, .reg_value = 1, },
{ .rate = 16000, .reg_value = 2, },
{ .rate = 24000, .reg_value = 3, },
{ .rate = 32000, .reg_value = 4, },
{ .rate = 48000, .reg_value = 5, },
{ .rate = 96000, .reg_value = 6, },
{ .rate = 192000, .reg_value = 7, },
{ .rate = 384000, .reg_value = 8, },
{ .rate = 7350, .reg_value = 16, },
{ .rate = 11025, .reg_value = 17, },
{ .rate = 14700, .reg_value = 18, },
{ .rate = 22050, .reg_value = 19, },
{ .rate = 29400, .reg_value = 20, },
{ .rate = 44100, .reg_value = 21, },
{ .rate = 88200, .reg_value = 22, },
{ .rate = 176400, .reg_value = 23, },
{ .rate = 352800, .reg_value = 24, },
};
int mt8188_afe_fs_timing(unsigned int rate)
{
int i;
for (i = 0; i < ARRAY_SIZE(mt8188_afe_rates); i++)
if (mt8188_afe_rates[i].rate == rate)
return mt8188_afe_rates[i].reg_value;
return -EINVAL;
}
static int mt8188_memif_fs(struct snd_pcm_substream *substream,
unsigned int rate)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_component *component = NULL;
struct mtk_base_afe *afe = NULL;
struct mt8188_afe_private *afe_priv = NULL;
struct mtk_base_afe_memif *memif = NULL;
struct mtk_dai_memif_priv *memif_priv = NULL;
int fs = mt8188_afe_fs_timing(rate);
int id = snd_soc_rtd_to_cpu(rtd, 0)->id;
if (id < 0)
return -EINVAL;
component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
if (!component)
return -EINVAL;
afe = snd_soc_component_get_drvdata(component);
memif = &afe->memif[id];
switch (memif->data->id) {
case MT8188_AFE_MEMIF_DL10:
fs = MT8188_ETDM_OUT3_1X_EN;
break;
case MT8188_AFE_MEMIF_UL8:
fs = MT8188_ETDM_IN1_NX_EN;
break;
case MT8188_AFE_MEMIF_UL3:
fs = MT8188_ETDM_IN2_NX_EN;
break;
default:
afe_priv = afe->platform_priv;
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/module.h`, `linux/mfd/syscon.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_platform.h`.
- Detected declarations: `struct mtk_dai_memif_priv`, `struct mt8188_afe_rate`, `struct mt8188_afe_channel_merge`, `function mt8188_afe_fs_timing`, `function mt8188_memif_fs`, `function mt8188_irq_fs`, `function mt8188_afe_memif_is_ul`, `function mt8188_afe_found_cm`, `function mt8188_afe_config_cm`, `function mt8188_afe_enable_cm`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- 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.