1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <commonlib/bsd/helpers.h>
6 static const struct nhlt_format_config max98373_render_formats
[] = {
7 /* 48 KHz 16-bits per sample. */
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 .settings_file
= "max98373-render-2ch-48khz-16b.bin",
18 static const struct nhlt_format_config max98373_capture_formats
[] = {
19 /* 48 KHz 16-bits per sample - Quad Channel. */
22 .sample_freq_khz
= 48,
23 .container_bits_per_sample
= 32,
24 .valid_bits_per_sample
= 16,
25 .speaker_mask
= SPEAKER_FRONT_LEFT
| SPEAKER_FRONT_RIGHT
,
26 .settings_file
= "max98373-render-2ch-48khz-16b.bin",
28 /* 48 KHz 16-bits per sample - Stereo Channel */
31 .sample_freq_khz
= 48,
32 .container_bits_per_sample
= 32,
33 .valid_bits_per_sample
= 16,
34 .speaker_mask
= SPEAKER_FRONT_LEFT
| SPEAKER_FRONT_RIGHT
,
35 .settings_file
= "max98373-render-2ch-48khz-16b.bin",
39 static struct nhlt_feedback_config render_config
= {
42 .config_type
= NHLT_TDM_RENDER_FEEDBACK
,
44 .feedback_virtual_slot
= 2,
45 .feedback_channels
= 4,
46 .feedback_valid_bits_per_sample
= 16,
49 static struct nhlt_feedback_config capture_config
= {
52 .config_type
= NHLT_TDM_RENDER_FEEDBACK
,
54 .feedback_virtual_slot
= 0,
55 .feedback_channels
= 2,
56 .feedback_valid_bits_per_sample
= 16,
59 static const struct nhlt_endp_descriptor max98373_descriptors
[] = {
61 .link
= NHLT_LINK_SSP
,
62 .device
= NHLT_SSP_DEV_I2S
,
63 .direction
= NHLT_DIR_RENDER
,
66 .cfg
= &render_config
,
67 .cfg_size
= sizeof(render_config
),
68 .formats
= max98373_render_formats
,
69 .num_formats
= ARRAY_SIZE(max98373_render_formats
),
72 .link
= NHLT_LINK_SSP
,
73 .device
= NHLT_SSP_DEV_I2S
,
74 .direction
= NHLT_DIR_CAPTURE
,
77 .cfg
= &capture_config
,
78 .cfg_size
= sizeof(capture_config
),
79 .formats
= max98373_capture_formats
,
80 .num_formats
= ARRAY_SIZE(max98373_capture_formats
),
84 int nhlt_soc_add_max98373(struct nhlt
*nhlt
, int hwlink
, int render_slot
,
87 render_config
.tdm_config
.virtual_slot
= render_slot
;
88 render_config
.feedback_virtual_slot
= feedback_slot
;
89 capture_config
.tdm_config
.virtual_slot
= feedback_slot
;
90 capture_config
.feedback_virtual_slot
= render_slot
;
92 /* Virtual bus id of SSP links are the hardware port ids proper. */
93 return nhlt_add_ssp_endpoints(nhlt
, hwlink
, max98373_descriptors
,
94 ARRAY_SIZE(max98373_descriptors
));