1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <commonlib/bsd/helpers.h>
4 #include <soc/nhlt.h>
5
6 /*
7 * The same DSP firmware settings are used for both the capture and
8 * render endpoints.
9 */
10 static const struct nhlt_format_config rt5663_formats[] = {
11 /* 48 KHz 24-bits per sample. */
12 {
13 .num_channels = 2,
14 .sample_freq_khz = 48,
15 .container_bits_per_sample = 32,
16 .valid_bits_per_sample = 24,
17 .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
18 .settings_file = "rt5663-2ch-48khz-24b.bin",
19 },
20 };
21
22 /*
23 * The rt5663 just has headphones and a mic. Both the capture and render
24 * endpoints occupy the same virtual slot.
25 */
26 static const struct nhlt_tdm_config tdm_config = {
27 .virtual_slot = 0,
28 .config_type = NHLT_TDM_BASIC,
29 };
30
31 static const struct nhlt_endp_descriptor rt5663_descriptors[] = {
32 /* Render Endpoint */
33 {
34 .link = NHLT_LINK_SSP,
35 .device = NHLT_SSP_DEV_I2S,
36 .direction = NHLT_DIR_RENDER,
37 .vid = NHLT_VID,
38 .did = NHLT_DID_SSP,
39 .cfg = &tdm_config,
40 .cfg_size = sizeof(tdm_config),
41 .formats = rt5663_formats,
42 .num_formats = ARRAY_SIZE(rt5663_formats),
43 },
44 /* Capture Endpoint */
45 {
46 .link = NHLT_LINK_SSP,
47 .device = NHLT_SSP_DEV_I2S,
48 .direction = NHLT_DIR_CAPTURE,
49 .vid = NHLT_VID,
50 .did = NHLT_DID_SSP,
51 .cfg = &tdm_config,
52 .cfg_size = sizeof(tdm_config),
53 .formats = rt5663_formats,
54 .num_formats = ARRAY_SIZE(rt5663_formats),
55 },
56 };
57
nhlt_soc_add_rt5663(struct nhlt * nhlt,int hwlink)58 int nhlt_soc_add_rt5663(struct nhlt *nhlt, int hwlink)
59 {
60 /* Virtual bus id of SSP links are the hardware port ids proper. */
61 return nhlt_add_ssp_endpoints(nhlt, hwlink, rt5663_descriptors,
62 ARRAY_SIZE(rt5663_descriptors));
63 }
64