sound/soc/mediatek/mt8195/mt8195-dai-etdm.c

Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c

File Facts

System
Linux kernel
Corpus path
sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
Extension
.c
Size
79700 bytes
Lines
2755
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.

Dependency Surface

Detected Declarations

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 clock_mode;
	unsigned int data_mode;
	bool slave_mode;
	bool lrck_inv;
	bool bck_inv;
	unsigned int format;
	unsigned int slots;
	unsigned int lrck_width;
	unsigned int mclk_freq;
	unsigned int mclk_apll;
	unsigned int mclk_dir;
	int cowork_source_id; //dai id
	unsigned int cowork_slv_count;
	int cowork_slv_id[MT8195_AFE_IO_ETDM_NUM - 1]; //dai_id
	bool in_disable_ch[MT8195_ETDM_MAX_CHANNELS];
	unsigned int en_ref_cnt;
};

static const struct mtk_dai_etdm_rate mt8195_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 bool mt8195_afe_etdm_is_valid(int id)
{
	switch (id) {
	case MT8195_AFE_IO_ETDM1_IN:
		fallthrough;
	case MT8195_AFE_IO_ETDM2_IN:
		fallthrough;
	case MT8195_AFE_IO_ETDM1_OUT:
		fallthrough;
	case MT8195_AFE_IO_ETDM2_OUT:
		fallthrough;
	case MT8195_AFE_IO_DPTX:
		fallthrough;
	case MT8195_AFE_IO_ETDM3_OUT:
		return true;
	default:
		return false;
	}
}

static bool mt8195_afe_hdmitx_dptx_is_valid(int id)
{
	switch (id) {
	case MT8195_AFE_IO_DPTX:
		fallthrough;
	case MT8195_AFE_IO_ETDM3_OUT:
		return true;
	default:
		return false;
	}
}

static int get_etdm_fs_timing(unsigned int rate)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(mt8195_etdm_rates); i++)
		if (mt8195_etdm_rates[i].rate == rate)
			return mt8195_etdm_rates[i].reg_value;

Annotation

Implementation Notes