sound/soc/mediatek/mt8186/mt8186-dai-tdm.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8186/mt8186-dai-tdm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8186/mt8186-dai-tdm.c- Extension
.c- Size
- 18471 bytes
- Lines
- 644
- 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/regmap.hsound/pcm_params.hmt8186-afe-clk.hmt8186-afe-common.hmt8186-afe-gpio.hmt8186-interconnection.h
Detected Declarations
struct mtk_afe_tdm_privfunction get_tdm_lrck_widthfunction get_tdm_ch_fixupfunction get_tdm_ch_per_sdatafunction get_tdm_id_by_namefunction mtk_tdm_en_eventfunction mtk_tdm_mck_en_eventfunction mtk_afe_tdm_mclk_connectfunction mtk_afe_tdm_mclk_apll_connectfunction mtk_afe_tdm_hd_connectfunction mtk_afe_tdm_apll_connectfunction mt8186_tdm_hd_getfunction mt8186_tdm_hd_setfunction mtk_dai_tdm_cal_mclkfunction mtk_dai_tdm_hw_paramsfunction mtk_dai_tdm_set_sysclkfunction mtk_dai_tdm_set_fmtfunction mtk_dai_tdm_set_tdm_slotfunction mt8186_dai_tdm_register
Annotated Snippet
struct mtk_afe_tdm_priv {
unsigned int id;
unsigned int rate; /* for determine which apll to use */
unsigned int bck_invert;
unsigned int lck_invert;
unsigned int lrck_width;
unsigned int mclk_id;
unsigned int mclk_multiple; /* according to sample rate */
unsigned int mclk_rate;
unsigned int mclk_apll;
unsigned int tdm_mode;
unsigned int data_mode;
unsigned int slave_mode;
unsigned int low_jitter_en;
};
enum {
TDM_IN_I2S = 0,
TDM_IN_LJ = 1,
TDM_IN_RJ = 2,
TDM_IN_DSP_A = 4,
TDM_IN_DSP_B = 5,
};
enum {
TDM_DATA_ONE_PIN = 0,
TDM_DATA_MULTI_PIN,
};
enum {
TDM_BCK_NON_INV = 0,
TDM_BCK_INV = 1,
};
enum {
TDM_LCK_NON_INV = 0,
TDM_LCK_INV = 1,
};
static unsigned int get_tdm_lrck_width(snd_pcm_format_t format,
unsigned int mode)
{
if (mode == TDM_IN_DSP_A || mode == TDM_IN_DSP_B)
return 0;
return snd_pcm_format_physical_width(format) - 1;
}
static unsigned int get_tdm_ch_fixup(unsigned int channels)
{
if (channels > 4)
return 8;
else if (channels > 2)
return 4;
return 2;
}
static unsigned int get_tdm_ch_per_sdata(unsigned int mode,
unsigned int channels)
{
if (mode == TDM_IN_DSP_A || mode == TDM_IN_DSP_B)
return get_tdm_ch_fixup(channels);
return 2;
}
enum {
SUPPLY_SEQ_APLL,
SUPPLY_SEQ_TDM_MCK_EN,
SUPPLY_SEQ_TDM_HD_EN,
SUPPLY_SEQ_TDM_EN,
};
static int get_tdm_id_by_name(const char *name)
{
return MT8186_DAI_TDM_IN;
}
static int mtk_tdm_en_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);
struct mt8186_afe_private *afe_priv = afe->platform_priv;
int dai_id = get_tdm_id_by_name(w->name);
struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id];
dev_dbg(cmpnt->dev, "%s(), name %s, event 0x%x\n",
Annotation
- Immediate include surface: `linux/regmap.h`, `sound/pcm_params.h`, `mt8186-afe-clk.h`, `mt8186-afe-common.h`, `mt8186-afe-gpio.h`, `mt8186-interconnection.h`.
- Detected declarations: `struct mtk_afe_tdm_priv`, `function get_tdm_lrck_width`, `function get_tdm_ch_fixup`, `function get_tdm_ch_per_sdata`, `function get_tdm_id_by_name`, `function mtk_tdm_en_event`, `function mtk_tdm_mck_en_event`, `function mtk_afe_tdm_mclk_connect`, `function mtk_afe_tdm_mclk_apll_connect`, `function mtk_afe_tdm_hd_connect`.
- 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.