sound/soc/mediatek/mt8365/mt8365-dai-dmic.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8365/mt8365-dai-dmic.c- Extension
.c- Size
- 8106 bytes
- Lines
- 311
- 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.
- 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/bitops.hlinux/regmap.hsound/pcm_params.hmt8365-afe-clk.hmt8365-afe-common.h
Detected Declarations
struct mt8365_dmic_datafunction get_chan_regfunction audio_dmic_adda_enablefunction audio_dmic_adda_disablefunction mt8365_dai_enable_dmicfunction mt8365_dai_disable_dmicfunction mt8365_dai_configure_dmicfunction mt8365_dai_dmic_startupfunction mt8365_dai_dmic_shutdownfunction mt8365_dai_dmic_preparefunction init_dmic_priv_datafunction mt8365_dai_dmic_register
Annotated Snippet
struct mt8365_dmic_data {
bool two_wire_mode;
unsigned int clk_phase_sel_ch1;
unsigned int clk_phase_sel_ch2;
bool iir_on;
unsigned int irr_mode;
unsigned int dmic_mode;
unsigned int dmic_channel;
};
static int get_chan_reg(unsigned int channel)
{
switch (channel) {
case 8:
fallthrough;
case 7:
return AFE_DMIC3_UL_SRC_CON0;
case 6:
fallthrough;
case 5:
return AFE_DMIC2_UL_SRC_CON0;
case 4:
fallthrough;
case 3:
return AFE_DMIC1_UL_SRC_CON0;
case 2:
fallthrough;
case 1:
return AFE_DMIC0_UL_SRC_CON0;
default:
return -EINVAL;
}
}
/* DAI Drivers */
static void audio_dmic_adda_enable(struct mtk_base_afe *afe)
{
mt8365_dai_enable_adda_on(afe);
regmap_update_bits(afe->regmap, AFE_ADDA_UL_DL_CON0,
AFE_ADDA_UL_DL_DMIC_CLKDIV_ON,
AFE_ADDA_UL_DL_DMIC_CLKDIV_ON);
}
static void audio_dmic_adda_disable(struct mtk_base_afe *afe)
{
regmap_update_bits(afe->regmap, AFE_ADDA_UL_DL_CON0,
AFE_ADDA_UL_DL_DMIC_CLKDIV_ON,
~AFE_ADDA_UL_DL_DMIC_CLKDIV_ON);
mt8365_dai_disable_adda_on(afe);
}
static void mt8365_dai_enable_dmic(struct mtk_base_afe *afe,
struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct mt8365_afe_private *afe_priv = afe->platform_priv;
struct mt8365_dmic_data *dmic_data = afe_priv->dai_priv[MT8365_AFE_IO_DMIC];
unsigned int val_mask;
int reg = get_chan_reg(dmic_data->dmic_channel);
if (reg < 0)
return;
/* val and mask will be always same to enable */
val_mask = DMIC_TOP_CON_CH1_ON |
DMIC_TOP_CON_CH2_ON |
DMIC_TOP_CON_SRC_ON;
regmap_update_bits(afe->regmap, reg, val_mask, val_mask);
}
static void mt8365_dai_disable_dmic(struct mtk_base_afe *afe,
struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct mt8365_afe_private *afe_priv = afe->platform_priv;
struct mt8365_dmic_data *dmic_data = afe_priv->dai_priv[MT8365_AFE_IO_DMIC];
unsigned int mask;
int reg = get_chan_reg(dmic_data->dmic_channel);
if (reg < 0)
return;
dev_dbg(afe->dev, "%s dmic_channel %d\n", __func__, dmic_data->dmic_channel);
mask = DMIC_TOP_CON_CH1_ON |
DMIC_TOP_CON_CH2_ON |
DMIC_TOP_CON_SRC_ON |
DMIC_TOP_CON_SDM3_LEVEL_MODE;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/regmap.h`, `sound/pcm_params.h`, `mt8365-afe-clk.h`, `mt8365-afe-common.h`.
- Detected declarations: `struct mt8365_dmic_data`, `function get_chan_reg`, `function audio_dmic_adda_enable`, `function audio_dmic_adda_disable`, `function mt8365_dai_enable_dmic`, `function mt8365_dai_disable_dmic`, `function mt8365_dai_configure_dmic`, `function mt8365_dai_dmic_startup`, `function mt8365_dai_dmic_shutdown`, `function mt8365_dai_dmic_prepare`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source 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.