sound/soc/mediatek/mt8188/mt8188-dai-etdm.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8188/mt8188-dai-etdm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8188/mt8188-dai-etdm.c- Extension
.c- Size
- 80100 bytes
- Lines
- 2713
- 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/pm_runtime.hlinux/regmap.hsound/pcm_params.hmt8188-afe-clk.hmt8188-afe-common.hmt8188-reg.h
Detected Declarations
struct etdm_con_regstruct mtk_dai_etdm_ratestruct mtk_dai_etdm_privfunction get_etdm_fs_timingfunction get_etdm_ch_fixupfunction get_etdm_regfunction get_etdm_dirfunction get_etdm_wlenfunction is_valid_etdm_daifunction is_cowork_modefunction sync_to_dai_idfunction get_etdm_cowork_master_idfunction mtk_dai_etdm_get_cg_id_by_dai_idfunction mtk_dai_etdm_get_clk_id_by_dai_idfunction mtk_dai_etdm_get_clkdiv_id_by_dai_idfunction get_etdm_id_by_namefunction mtk_dai_etdm_enable_mclkfunction mtk_dai_etdm_disable_mclkfunction mtk_afe_etdm_apll_connectfunction mtk_afe_mclk_apll_connectfunction mtk_etdm_mclk_connectfunction mtk_etdm_cowork_connectfunction mtk_apll_eventfunction mtk_etdm_mclk_eventfunction mtk_dptx_mclk_eventfunction mtk_etdm_cg_eventfunction mtk_etdm3_cg_eventfunction mt8188_etdm_clk_src_sel_putfunction mt8188_etdm_clk_src_sel_getfunction etdm_cowork_slv_selfunction etdm_cowork_sync_selfunction mt8188_etdm_sync_mode_slvfunction mt8188_etdm_sync_mode_mstfunction mt8188_etdm_sync_mode_configurefunction mtk_dai_etdm_fifo_modefunction mtk_dai_etdm_in_configurefunction mtk_dai_etdm_out_configurefunction mtk_dai_etdm_configurefunction mtk_dai_etdm_hw_paramsfunction mtk_dai_etdm_cal_mclkfunction mtk_dai_etdm_set_sysclkfunction mtk_dai_etdm_set_tdm_slotfunction mtk_dai_etdm_set_fmtfunction mtk_dai_get_dptx_ch_enfunction mtk_dai_get_dptx_chfunction mtk_dai_get_dptx_wlenfunction mtk_dai_hdmitx_dptx_hw_paramsfunction mtk_dai_hdmitx_dptx_set_sysclk
Annotated Snippet
struct etdm_con_reg {
unsigned int con0;
unsigned int con1;
unsigned int con2;
unsigned int con3;
unsigned int con4;
unsigned int con5;
};
struct mtk_dai_etdm_rate {
unsigned int rate;
unsigned int reg_value;
};
struct mtk_dai_etdm_priv {
unsigned int data_mode;
bool slave_mode;
bool lrck_inv;
bool bck_inv;
unsigned int rate;
unsigned int format;
unsigned int slots;
unsigned int lrck_width;
unsigned int mclk_freq;
unsigned int mclk_fixed_apll;
unsigned int mclk_apll;
unsigned int mclk_dir;
int cowork_source_id; //dai id
unsigned int cowork_slv_count;
int cowork_slv_id[MT8188_AFE_IO_ETDM_NUM - 1]; //dai_id
bool in_disable_ch[MT8188_ETDM_MAX_CHANNELS];
};
static const struct mtk_dai_etdm_rate mt8188_etdm_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 = 7, },
{ .rate = 192000, .reg_value = 9, },
{ .rate = 384000, .reg_value = 11, },
{ .rate = 11025, .reg_value = 16, },
{ .rate = 22050, .reg_value = 17, },
{ .rate = 44100, .reg_value = 18, },
{ .rate = 88200, .reg_value = 19, },
{ .rate = 176400, .reg_value = 20, },
{ .rate = 352800, .reg_value = 21, },
};
static int get_etdm_fs_timing(unsigned int rate)
{
int i;
for (i = 0; i < ARRAY_SIZE(mt8188_etdm_rates); i++)
if (mt8188_etdm_rates[i].rate == rate)
return mt8188_etdm_rates[i].reg_value;
return -EINVAL;
}
static unsigned int get_etdm_ch_fixup(unsigned int channels)
{
if (channels > 16)
return 24;
else if (channels > 8)
return 16;
else if (channels > 4)
return 8;
else if (channels > 2)
return 4;
else
return 2;
}
static int get_etdm_reg(unsigned int dai_id, struct etdm_con_reg *etdm_reg)
{
switch (dai_id) {
case MT8188_AFE_IO_ETDM1_IN:
etdm_reg->con0 = ETDM_IN1_CON0;
etdm_reg->con1 = ETDM_IN1_CON1;
etdm_reg->con2 = ETDM_IN1_CON2;
etdm_reg->con3 = ETDM_IN1_CON3;
etdm_reg->con4 = ETDM_IN1_CON4;
etdm_reg->con5 = ETDM_IN1_CON5;
break;
case MT8188_AFE_IO_ETDM2_IN:
etdm_reg->con0 = ETDM_IN2_CON0;
etdm_reg->con1 = ETDM_IN2_CON1;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/pm_runtime.h`, `linux/regmap.h`, `sound/pcm_params.h`, `mt8188-afe-clk.h`, `mt8188-afe-common.h`, `mt8188-reg.h`.
- Detected declarations: `struct etdm_con_reg`, `struct mtk_dai_etdm_rate`, `struct mtk_dai_etdm_priv`, `function get_etdm_fs_timing`, `function get_etdm_ch_fixup`, `function get_etdm_reg`, `function get_etdm_dir`, `function get_etdm_wlen`, `function is_valid_etdm_dai`, `function is_cowork_mode`.
- 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.