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

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

File Facts

System
Linux kernel
Corpus path
sound/soc/mediatek/mt8196/mt8196-dai-tdm.c
Extension
.c
Size
17123 bytes
Lines
676
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;
};

enum {
	TDM_WLEN_8_BIT,
	TDM_WLEN_16_BIT,
	TDM_WLEN_24_BIT,
	TDM_WLEN_32_BIT,
};

enum {
	TDM_CHANNEL_BCK_16,
	TDM_CHANNEL_BCK_24,
	TDM_CHANNEL_BCK_32,
};

enum {
	TDM_CHANNEL_NUM_2,
	TDM_CHANNEL_NUM_4,
	TDM_CHANNEL_NUM_8,
};

enum  {
	TDM_CH_START_O30_O31,
	TDM_CH_START_O32_O33,
	TDM_CH_START_O34_O35,
	TDM_CH_START_O36_O37,
	TDM_CH_ZERO,
};

enum {
	DPTX_CHANNEL_2,
	DPTX_CHANNEL_8,
};

enum {
	DPTX_WLEN_24_BIT,
	DPTX_WLEN_16_BIT,
};

#define DPTX_CH_EN_MASK_2CH (0x3)
#define DPTX_CH_EN_MASK_4CH (0xf)
#define DPTX_CH_EN_MASK_6CH (0x3f)
#define DPTX_CH_EN_MASK_8CH (0xff)

static unsigned int get_tdm_wlen(snd_pcm_format_t format)
{
	return (snd_pcm_format_physical_width(format) / 8) - 1;
}

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(struct device *dev, unsigned int ch)
{
	switch (ch) {
	case 1:

Annotation

Implementation Notes