sound/soc/mediatek/mt8188/mt8188-dai-adda.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8188/mt8188-dai-adda.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8188/mt8188-dai-adda.c- Extension
.c- Size
- 14467 bytes
- Lines
- 513
- 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/bitfield.hlinux/delay.hlinux/regmap.hmt8188-afe-clk.hmt8188-afe-common.hmt8188-reg.h../common/mtk-dai-adda-common.h
Detected Declarations
struct mtk_dai_adda_privfunction mt8188_adda_mtkaif_initfunction mtk_adda_mtkaif_cfg_eventfunction mtk_adda_dl_eventfunction mtk_adda_ul_mictypefunction mtk_adda_ul_eventfunction mtk_afe_adda_hires_connectfunction mt8188_adda_dmic_getfunction mt8188_adda_dmic_setfunction mtk_dai_da_configurefunction mtk_dai_ad_configurefunction mtk_dai_adda_hw_paramsfunction init_adda_priv_datafunction mt8188_dai_adda_register
Annotated Snippet
struct mtk_dai_adda_priv {
bool hires_required;
};
static int mt8188_adda_mtkaif_init(struct mtk_base_afe *afe)
{
struct mt8188_afe_private *afe_priv = afe->platform_priv;
struct mtkaif_param *param = &afe_priv->mtkaif_params;
int delay_data;
int delay_cycle;
unsigned int mask = 0;
unsigned int val = 0;
/* set rx protocol 2 & mtkaif_rxif_clkinv_adc inverse */
regmap_set_bits(afe->regmap, AFE_ADDA_MTKAIF_CFG0,
MTKAIF_RXIF_CLKINV_ADC | MTKAIF_RXIF_PROTOCOL2);
regmap_set_bits(afe->regmap, AFE_AUD_PAD_TOP, RG_RX_PROTOCOL2);
if (!param->mtkaif_calibration_ok) {
dev_info(afe->dev, "%s(), calibration fail\n", __func__);
return 0;
}
/* set delay for ch1, ch2 */
if (param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_0] >=
param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_1]) {
delay_data = DELAY_DATA_MISO1;
delay_cycle =
param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_0] -
param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_1];
} else {
delay_data = DELAY_DATA_MISO0;
delay_cycle =
param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_1] -
param->mtkaif_phase_cycle[MT8188_MTKAIF_MISO_0];
}
mask = (MTKAIF_RXIF_DELAY_DATA | MTKAIF_RXIF_DELAY_CYCLE_MASK);
val |= FIELD_PREP(MTKAIF_RXIF_DELAY_CYCLE_MASK, delay_cycle);
val |= FIELD_PREP(MTKAIF_RXIF_DELAY_DATA, delay_data);
regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG2, mask, val);
return 0;
}
static int mtk_adda_mtkaif_cfg_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{
struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm);
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt);
dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n",
__func__, w->name, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
mt8188_adda_mtkaif_init(afe);
break;
default:
break;
}
return 0;
}
static int mtk_adda_dl_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{
struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm);
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt);
dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n",
__func__, w->name, event);
switch (event) {
case SND_SOC_DAPM_POST_PMD:
/* should delayed 1/fs(smallest is 8k) = 125us before afe off */
usleep_range(125, 135);
break;
default:
break;
}
return 0;
}
static void mtk_adda_ul_mictype(struct mtk_base_afe *afe, bool dmic)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/regmap.h`, `mt8188-afe-clk.h`, `mt8188-afe-common.h`, `mt8188-reg.h`, `../common/mtk-dai-adda-common.h`.
- Detected declarations: `struct mtk_dai_adda_priv`, `function mt8188_adda_mtkaif_init`, `function mtk_adda_mtkaif_cfg_event`, `function mtk_adda_dl_event`, `function mtk_adda_ul_mictype`, `function mtk_adda_ul_event`, `function mtk_afe_adda_hires_connect`, `function mt8188_adda_dmic_get`, `function mt8188_adda_dmic_set`, `function mtk_dai_da_configure`.
- 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.