sound/soc/mediatek/mt8183/mt8183-dai-i2s.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8183/mt8183-dai-i2s.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8183/mt8183-dai-i2s.c- Extension
.c- Size
- 32189 bytes
- Lines
- 1059
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.hmt8183-afe-clk.hmt8183-afe-common.hmt8183-interconnection.hmt8183-reg.h
Detected Declarations
struct mtk_afe_i2s_privfunction get_i2s_wlenfunction get_i2s_id_by_namefunction mt8183_i2s_hd_getfunction mt8183_i2s_hd_setfunction mtk_apll_eventfunction mtk_mclk_en_eventfunction mtk_afe_i2s_share_connectfunction mtk_afe_i2s_hd_connectfunction mtk_afe_i2s_apll_connectfunction mtk_afe_i2s_mclk_connectfunction mtk_afe_mclk_apll_connectfunction mtk_dai_i2s_configfunction mtk_dai_i2s_hw_paramsfunction mtk_dai_i2s_set_sysclkfunction mtk_dai_i2s_set_fmtfunction mt8183_dai_i2s_set_sharefunction mt8183_dai_i2s_set_privfunction mt8183_dai_i2s_registerexport mt8183_dai_i2s_set_share
Annotated Snippet
struct mtk_afe_i2s_priv {
int id;
int rate; /* for determine which apll to use */
int low_jitter_en;
int share_i2s_id;
int mclk_id;
int mclk_rate;
int mclk_apll;
int use_eiaj;
};
static unsigned int get_i2s_wlen(snd_pcm_format_t format)
{
return snd_pcm_format_physical_width(format) <= 16 ?
I2S_WLEN_16_BIT : I2S_WLEN_32_BIT;
}
#define MTK_AFE_I2S0_KCONTROL_NAME "I2S0_HD_Mux"
#define MTK_AFE_I2S1_KCONTROL_NAME "I2S1_HD_Mux"
#define MTK_AFE_I2S2_KCONTROL_NAME "I2S2_HD_Mux"
#define MTK_AFE_I2S3_KCONTROL_NAME "I2S3_HD_Mux"
#define MTK_AFE_I2S5_KCONTROL_NAME "I2S5_HD_Mux"
#define I2S0_HD_EN_W_NAME "I2S0_HD_EN"
#define I2S1_HD_EN_W_NAME "I2S1_HD_EN"
#define I2S2_HD_EN_W_NAME "I2S2_HD_EN"
#define I2S3_HD_EN_W_NAME "I2S3_HD_EN"
#define I2S5_HD_EN_W_NAME "I2S5_HD_EN"
#define I2S0_MCLK_EN_W_NAME "I2S0_MCLK_EN"
#define I2S1_MCLK_EN_W_NAME "I2S1_MCLK_EN"
#define I2S2_MCLK_EN_W_NAME "I2S2_MCLK_EN"
#define I2S3_MCLK_EN_W_NAME "I2S3_MCLK_EN"
#define I2S5_MCLK_EN_W_NAME "I2S5_MCLK_EN"
static int get_i2s_id_by_name(struct mtk_base_afe *afe,
const char *name)
{
if (strncmp(name, "I2S0", 4) == 0)
return MT8183_DAI_I2S_0;
else if (strncmp(name, "I2S1", 4) == 0)
return MT8183_DAI_I2S_1;
else if (strncmp(name, "I2S2", 4) == 0)
return MT8183_DAI_I2S_2;
else if (strncmp(name, "I2S3", 4) == 0)
return MT8183_DAI_I2S_3;
else if (strncmp(name, "I2S5", 4) == 0)
return MT8183_DAI_I2S_5;
else
return -EINVAL;
}
static struct mtk_afe_i2s_priv *get_i2s_priv_by_name(struct mtk_base_afe *afe,
const char *name)
{
struct mt8183_afe_private *afe_priv = afe->platform_priv;
int dai_id = get_i2s_id_by_name(afe, name);
if (dai_id < 0)
return NULL;
return afe_priv->dai_priv[dai_id];
}
/* low jitter control */
static const char * const mt8183_i2s_hd_str[] = {
"Normal", "Low_Jitter"
};
static const struct soc_enum mt8183_i2s_enum[] = {
SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(mt8183_i2s_hd_str),
mt8183_i2s_hd_str),
};
static int mt8183_i2s_hd_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *cmpnt = snd_kcontrol_chip(kcontrol);
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt);
struct mtk_afe_i2s_priv *i2s_priv;
i2s_priv = get_i2s_priv_by_name(afe, kcontrol->id.name);
if (!i2s_priv) {
dev_warn(afe->dev, "%s(), i2s_priv == NULL", __func__);
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/regmap.h`, `sound/pcm_params.h`, `mt8183-afe-clk.h`, `mt8183-afe-common.h`, `mt8183-interconnection.h`, `mt8183-reg.h`.
- Detected declarations: `struct mtk_afe_i2s_priv`, `function get_i2s_wlen`, `function get_i2s_id_by_name`, `function mt8183_i2s_hd_get`, `function mt8183_i2s_hd_set`, `function mtk_apll_event`, `function mtk_mclk_en_event`, `function mtk_afe_i2s_share_connect`, `function mtk_afe_i2s_hd_connect`, `function mtk_afe_i2s_apll_connect`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.