sound/soc/mediatek/mt6797/mt6797-dai-adda.c

Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt6797/mt6797-dai-adda.c

File Facts

System
Linux kernel
Corpus path
sound/soc/mediatek/mt6797/mt6797-dai-adda.c
Extension
.c
Size
9266 bytes
Lines
324
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

switch (rate) {
		case 192000:
			dl_src2_con0 |= (0x1 << 24); /* UP_SAMPLING_RATE_X2 */
			dl_src2_con0 |= 1 << 14;
			break;
		case 96000:
			dl_src2_con0 |= (0x2 << 24); /* UP_SAMPLING_RATE_X4 */
			dl_src2_con0 |= 1 << 14;
			break;
		default:
			dl_src2_con0 |= (0x3 << 24); /* UP_SAMPLING_RATE_X8 */
			break;
		}

		/* turn off mute function */
		dl_src2_con0 |= (0x03 << 11);

		/* set voice input data if input sample rate is 8k or 16k */
		if (rate == 8000 || rate == 16000)
			dl_src2_con0 |= 0x01 << 5;

		if (rate < 96000) {
			/* SA suggest apply -0.3db to audio/speech path */
			dl_src2_con1 = 0xf74f0000;
		} else {
			/* SA suggest apply -0.3db to audio/speech path
			 * with DL gain set to half,
			 * 0xFFFF = 0dB -> 0x8000 = 0dB when 96k, 192k
			 */
			dl_src2_con1 = 0x7ba70000;
		}

		/* turn on down-link gain */
		dl_src2_con0 = dl_src2_con0 | (0x01 << 1);

		regmap_write(afe->regmap, AFE_ADDA_DL_SRC2_CON0, dl_src2_con0);
		regmap_write(afe->regmap, AFE_ADDA_DL_SRC2_CON1, dl_src2_con1);
	} else {
		unsigned int voice_mode = 0;
		unsigned int ul_src_con0 = 0;	/* default value */

		/* Using Internal ADC */
		regmap_update_bits(afe->regmap,
				   AFE_ADDA_TOP_CON0,
				   0x1 << 0,
				   0x0 << 0);

		voice_mode = mtk_adda_ul_rate_transform(afe, rate);

		ul_src_con0 |= (voice_mode << 17) & (0x7 << 17);

		/* up8x txif sat on */
		regmap_write(afe->regmap, AFE_ADDA_NEWIF_CFG0, 0x03F87201);

		if (rate >= 96000) {	/* hires */
			/* use hires format [1 0 23] */
			regmap_update_bits(afe->regmap,
					   AFE_ADDA_NEWIF_CFG0,
					   0x1 << 5,
					   0x1 << 5);

			regmap_update_bits(afe->regmap,
					   AFE_ADDA_NEWIF_CFG2,
					   0xf << 28,
					   voice_mode << 28);
		} else {	/* normal 8~48k */
			/* use fixed 260k anc path */
			regmap_update_bits(afe->regmap,
					   AFE_ADDA_NEWIF_CFG2,
					   0xf << 28,
					   8 << 28);

			/* ul_use_cic_out */
			ul_src_con0 |= 0x1 << 20;
		}

		regmap_update_bits(afe->regmap,
				   AFE_ADDA_NEWIF_CFG2,
				   0xf << 28,
				   8 << 28);

		regmap_update_bits(afe->regmap,
				   AFE_ADDA_UL_SRC_CON0,
				   0xfffffffe,
				   ul_src_con0);
	}

	return 0;
}

Annotation

Implementation Notes