xref: /aosp_15_r20/external/coreboot/src/soc/intel/skylake/nhlt/rt5514.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <commonlib/bsd/helpers.h>
4 #include <soc/nhlt.h>
5 
6 static const struct nhlt_format_config rt5514_4ch_formats[] = {
7 	/* 48 KHz 16-bits per sample. */
8 	{
9 		.num_channels = 4,
10 		.sample_freq_khz = 48,
11 		.container_bits_per_sample = 16,
12 		.valid_bits_per_sample = 16,
13 		.speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT |
14 				SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT,
15 		.settings_file = "rt5514-capture-4ch-48khz-16b.bin",
16 	},
17 };
18 
19 static struct nhlt_dmic_array_config rt5514_4ch_mic_config = {
20 	.tdm_config = {
21 		.virtual_slot = 0x1,
22 		.config_type = NHLT_TDM_MIC_ARRAY,
23 	},
24 	.array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED,
25 };
26 
27 static struct nhlt_endp_descriptor rt5514_4ch_descriptors[] = {
28 	{
29 		.link = NHLT_LINK_SSP,
30 		.device = NHLT_SSP_DEV_I2S,
31 		.direction = NHLT_DIR_CAPTURE,
32 		.vid = NHLT_VID,
33 		.did = NHLT_DID_SSP,
34 		.cfg = &rt5514_4ch_mic_config,
35 		.cfg_size = sizeof(rt5514_4ch_mic_config),
36 		.formats = rt5514_4ch_formats,
37 		.num_formats = ARRAY_SIZE(rt5514_4ch_formats),
38 	},
39 };
40 
nhlt_soc_add_rt5514(struct nhlt * nhlt,int hwlink,int num_channels,int virtual_slot)41 int nhlt_soc_add_rt5514(struct nhlt *nhlt, int hwlink, int num_channels, int virtual_slot)
42 {
43 	rt5514_4ch_mic_config.tdm_config.virtual_slot = virtual_slot;
44 
45 	switch (num_channels) {
46 	case 4:
47 		return nhlt_add_ssp_endpoints(nhlt, hwlink,
48 			      rt5514_4ch_descriptors,
49 			      ARRAY_SIZE(rt5514_4ch_descriptors));
50 	default:
51 		return -1;
52 	}
53 }
54