sound/soc/mediatek/mt8189/mt8189-dai-tdm.c

Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8189/mt8189-dai-tdm.c

File Facts

System
Linux kernel
Corpus path
sound/soc/mediatek/mt8189/mt8189-dai-tdm.c
Extension
.c
Size
17047 bytes
Lines
673
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 mtk_afe_tdm_priv {
	int bck_id;
	int bck_rate;

	int mclk_id;
	int mclk_multiple; /* according to sample rate */
	int mclk_rate;
	int mclk_apll;
};

static unsigned int get_tdm_wlen(snd_pcm_format_t format)
{
	return snd_pcm_format_physical_width(format) <= 16 ?
	       TDM_WLEN_16_BIT : TDM_WLEN_32_BIT;
}

static unsigned int get_tdm_channel_bck(snd_pcm_format_t format)
{
	return snd_pcm_format_physical_width(format) <= 16 ?
	       TDM_CHANNEL_BCK_16 : TDM_CHANNEL_BCK_32;
}

static unsigned int get_tdm_lrck_width(snd_pcm_format_t format)
{
	return snd_pcm_format_physical_width(format) - 1;
}

static unsigned int get_tdm_ch(unsigned int ch)
{
	switch (ch) {
	case 1:
	case 2:
		return TDM_CHANNEL_NUM_2;
	case 3:
	case 4:
		return TDM_CHANNEL_NUM_4;
	case 5:
	case 6:
	case 7:
	case 8:
	default:
		return TDM_CHANNEL_NUM_8;
	}
}

static unsigned int get_dptx_ch_enable_mask(unsigned int ch)
{
	switch (ch) {
	case 1:
	case 2:
		return DPTX_CH_EN_MASK_2CH;
	case 3:
	case 4:
		return DPTX_CH_EN_MASK_4CH;
	case 5:
	case 6:
		return DPTX_CH_EN_MASK_6CH;
	case 7:
	case 8:
		return DPTX_CH_EN_MASK_8CH;
	default:
		return DPTX_CH_EN_MASK_2CH;
	}
}

static unsigned int get_dptx_ch(unsigned int ch)
{
	if (ch == 2)
		return DPTX_CHANNEL_2;

	return DPTX_CHANNEL_8;
}

static unsigned int get_dptx_wlen(snd_pcm_format_t format)
{
	return snd_pcm_format_physical_width(format) <= 16 ?
	       DPTX_WLEN_16_BIT : DPTX_WLEN_24_BIT;
}

/* interconnection */
enum {
	HDMI_CONN_CH0,
	HDMI_CONN_CH1,
	HDMI_CONN_CH2,
	HDMI_CONN_CH3,
	HDMI_CONN_CH4,
	HDMI_CONN_CH5,
	HDMI_CONN_CH6,
	HDMI_CONN_CH7,
};

Annotation

Implementation Notes