coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
dmic.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <soc/nhlt.h>
4 
5 static const struct nhlt_format_config dmic_1ch_formats[] = {
6  /* 48 KHz 16-bits per sample. */
7  {
8  .num_channels = 1,
9  .sample_freq_khz = 48,
10  .container_bits_per_sample = 16,
11  .valid_bits_per_sample = 16,
12  .speaker_mask = SPEAKER_FRONT_CENTER,
13  .settings_file = "dmic-1ch-48khz-16b.bin",
14  },
15 };
16 
17 static const struct nhlt_dmic_array_config dmic_1ch_mic_config = {
18  .tdm_config = {
20  },
21  .array_type = NHLT_MIC_ARRAY_VENDOR_DEFINED,
22 };
23 
24 static const struct nhlt_endp_descriptor dmic_1ch_descriptors[] = {
25  {
27  .device = NHLT_PDM_DEV_CAVS15,
28  .direction = NHLT_DIR_CAPTURE,
29  .vid = NHLT_VID,
30  .did = NHLT_DID_DMIC,
31  .cfg = &dmic_1ch_mic_config,
32  .cfg_size = sizeof(dmic_1ch_mic_config),
35  },
36 };
37 
38 static const struct nhlt_format_config dmic_2ch_formats[] = {
39  /* 48 KHz 16-bits per sample. */
40  {
41  .num_channels = 2,
42  .sample_freq_khz = 48,
43  .container_bits_per_sample = 16,
44  .valid_bits_per_sample = 16,
45  .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
46  .settings_file = "dmic-2ch-48khz-16b.bin",
47  },
48  /* 48 KHz 32-bits per sample. */
49  {
50  .num_channels = 2,
51  .sample_freq_khz = 48,
52  .container_bits_per_sample = 32,
53  .valid_bits_per_sample = 32,
54  .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
55  .settings_file = "dmic-2ch-48khz-32b.bin",
56  },
57 };
58 
59 static const struct nhlt_dmic_array_config dmic_2ch_mic_config = {
60  .tdm_config = {
62  },
63  .array_type = NHLT_MIC_ARRAY_2CH_SMALL,
64 };
65 
66 static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = {
67  {
69  .device = NHLT_PDM_DEV_CAVS15,
70  .direction = NHLT_DIR_CAPTURE,
71  .vid = NHLT_VID,
72  .did = NHLT_DID_DMIC,
73  .cfg = &dmic_2ch_mic_config,
74  .cfg_size = sizeof(dmic_2ch_mic_config),
77  },
78 };
79 
80 static const struct nhlt_format_config dmic_4ch_formats[] = {
81  /* 48 KHz 16-bits per sample. */
82  {
83  .num_channels = 4,
84  .sample_freq_khz = 48,
85  .container_bits_per_sample = 16,
86  .valid_bits_per_sample = 16,
87  .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT |
89  .settings_file = "dmic-4ch-48khz-16b.bin",
90  },
91  /* 48 KHz 32-bits per sample. */
92  {
93  .num_channels = 4,
94  .sample_freq_khz = 48,
95  .container_bits_per_sample = 32,
96  .valid_bits_per_sample = 32,
97  .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT |
99  .settings_file = "dmic-4ch-48khz-32b.bin",
100  },
101 };
102 
103 static const struct nhlt_dmic_array_config dmic_4ch_mic_config = {
104  .tdm_config = {
106  },
107  .array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED,
108 };
109 
110 static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = {
111  {
112  .link = NHLT_LINK_PDM,
113  .device = NHLT_PDM_DEV_CAVS15,
114  .direction = NHLT_DIR_CAPTURE,
115  .vid = NHLT_VID,
116  .did = NHLT_DID_DMIC,
117  .cfg = &dmic_4ch_mic_config,
118  .cfg_size = sizeof(dmic_4ch_mic_config),
121  },
122 };
123 
124 int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels)
125 {
126  switch (num_channels) {
127  case 1:
130  case 2:
133  case 4:
136  default:
137  return -1;
138  }
139 }
#define ARRAY_SIZE(a)
Definition: helpers.h:12
static const struct nhlt_format_config dmic_4ch_formats[]
Definition: dmic.c:80
int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels)
Definition: dmic.c:124
static const struct nhlt_endp_descriptor dmic_4ch_descriptors[]
Definition: dmic.c:110
static const struct nhlt_endp_descriptor dmic_1ch_descriptors[]
Definition: dmic.c:24
static const struct nhlt_dmic_array_config dmic_1ch_mic_config
Definition: dmic.c:17
static const struct nhlt_endp_descriptor dmic_2ch_descriptors[]
Definition: dmic.c:66
static const struct nhlt_dmic_array_config dmic_2ch_mic_config
Definition: dmic.c:59
static const struct nhlt_format_config dmic_1ch_formats[]
Definition: dmic.c:5
static const struct nhlt_format_config dmic_2ch_formats[]
Definition: dmic.c:38
static const struct nhlt_dmic_array_config dmic_4ch_mic_config
Definition: dmic.c:103
@ NHLT_LINK_PDM
Definition: nhlt.h:175
@ NHLT_TDM_BASIC
Definition: nhlt.h:300
@ NHLT_TDM_MIC_ARRAY
Definition: nhlt.h:301
@ NHLT_MIC_ARRAY_4CH_L_SHAPED
Definition: nhlt.h:317
@ NHLT_MIC_ARRAY_2CH_SMALL
Definition: nhlt.h:314
@ NHLT_MIC_ARRAY_VENDOR_DEFINED
Definition: nhlt.h:319
@ NHLT_PDM_DEV_CAVS15
Definition: nhlt.h:190
@ SPEAKER_FRONT_LEFT
Definition: nhlt.h:203
@ SPEAKER_BACK_LEFT
Definition: nhlt.h:207
@ SPEAKER_FRONT_RIGHT
Definition: nhlt.h:204
@ SPEAKER_FRONT_CENTER
Definition: nhlt.h:205
@ SPEAKER_BACK_RIGHT
Definition: nhlt.h:208
@ NHLT_DIR_CAPTURE
Definition: nhlt.h:196
int nhlt_add_endpoints(struct nhlt *nhlt, const struct nhlt_endp_descriptor *epds, size_t num_epds)
Definition: nhlt.c:459
#define NHLT_VID
Definition: nhlt.h:8
#define NHLT_DID_DMIC
Definition: nhlt.h:9
struct nhlt_tdm_config tdm_config
Definition: nhlt.h:305
const struct nhlt_format_config * formats
Definition: nhlt.h:63
size_t num_formats
Definition: nhlt.h:64
int num_channels
Definition: nhlt.h:260
uint8_t config_type
Definition: nhlt.h:296
Definition: nhlt.h:287