| 1 |
|
| 2 |
|
| 3 |
#include <commonlib/bsd/helpers.h> |
| 4 |
#include <soc/nhlt.h> |
| 5 |
|
| 6 |
static const struct nhlt_format_config dmic_1ch_formats[] = { |
| 7 |
|
| 8 |
{ |
| 9 |
.num_channels = 1, |
| 10 |
.sample_freq_khz = 48, |
| 11 |
.container_bits_per_sample = 16, |
| 12 |
.valid_bits_per_sample = 16, |
| 13 |
.speaker_mask = SPEAKER_FRONT_CENTER, |
| 14 |
.settings_file = "dmic-1ch-48khz-16b.bin", |
| 15 |
}, |
| 16 |
}; |
| 17 |
|
| 18 |
static const struct nhlt_dmic_array_config dmic_1ch_mic_config = { |
| 19 |
.tdm_config = { |
| 20 |
.config_type = NHLT_TDM_BASIC, |
| 21 |
}, |
| 22 |
.array_type = NHLT_MIC_ARRAY_VENDOR_DEFINED, |
| 23 |
}; |
| 24 |
|
| 25 |
static const struct nhlt_endp_descriptor dmic_1ch_descriptors[] = { |
| 26 |
{ |
| 27 |
.link = NHLT_LINK_PDM, |
| 28 |
.device = NHLT_PDM_DEV_CAVS15, |
| 29 |
.direction = NHLT_DIR_CAPTURE, |
| 30 |
.vid = NHLT_VID, |
| 31 |
.did = NHLT_DID_DMIC, |
| 32 |
.cfg = &dmic_1ch_mic_config, |
| 33 |
.cfg_size = sizeof(dmic_1ch_mic_config), |
| 34 |
.formats = dmic_1ch_formats, |
| 35 |
.num_formats = ARRAY_SIZE(dmic_1ch_formats), |
| 36 |
}, |
| 37 |
}; |
| 38 |
|
| 39 |
static const struct nhlt_format_config dmic_2ch_formats[] = { |
| 40 |
|
| 41 |
{ |
| 42 |
.num_channels = 2, |
| 43 |
.sample_freq_khz = 48, |
| 44 |
.container_bits_per_sample = 16, |
| 45 |
.valid_bits_per_sample = 16, |
| 46 |
.speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT, |
| 47 |
.settings_file = "dmic-2ch-48khz-16b.bin", |
| 48 |
}, |
| 49 |
|
| 50 |
{ |
| 51 |
.num_channels = 2, |
| 52 |
.sample_freq_khz = 48, |
| 53 |
.container_bits_per_sample = 32, |
| 54 |
.valid_bits_per_sample = 32, |
| 55 |
.speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT, |
| 56 |
.settings_file = "dmic-2ch-48khz-32b.bin", |
| 57 |
}, |
| 58 |
}; |
| 59 |
|
| 60 |
static const struct nhlt_dmic_array_config dmic_2ch_mic_config = { |
| 61 |
.tdm_config = { |
| 62 |
.config_type = NHLT_TDM_MIC_ARRAY, |
| 63 |
}, |
| 64 |
.array_type = NHLT_MIC_ARRAY_2CH_SMALL, |
| 65 |
}; |
| 66 |
|
| 67 |
static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = { |
| 68 |
{ |
| 69 |
.link = NHLT_LINK_PDM, |
| 70 |
.device = NHLT_PDM_DEV_CAVS15, |
| 71 |
.direction = NHLT_DIR_CAPTURE, |
| 72 |
.vid = NHLT_VID, |
| 73 |
.did = NHLT_DID_DMIC, |
| 74 |
.cfg = &dmic_2ch_mic_config, |
| 75 |
.cfg_size = sizeof(dmic_2ch_mic_config), |
| 76 |
.formats = dmic_2ch_formats, |
| 77 |
.num_formats = ARRAY_SIZE(dmic_2ch_formats), |
| 78 |
}, |
| 79 |
}; |
| 80 |
|
| 81 |
static const struct nhlt_format_config dmic_4ch_formats[] = { |
| 82 |
|
| 83 |
{ |
| 84 |
.num_channels = 4, |
| 85 |
.sample_freq_khz = 48, |
| 86 |
.container_bits_per_sample = 16, |
| 87 |
.valid_bits_per_sample = 16, |
| 88 |
.speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | |
| 89 |
SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT, |
| 90 |
.settings_file = "dmic-4ch-48khz-16b.bin", |
| 91 |
}, |
| 92 |
|
| 93 |
{ |
| 94 |
.num_channels = 4, |
| 95 |
.sample_freq_khz = 48, |
| 96 |
.container_bits_per_sample = 32, |
| 97 |
.valid_bits_per_sample = 32, |
| 98 |
.speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | |
| 99 |
SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT, |
| 100 |
.settings_file = "dmic-4ch-48khz-32b.bin", |
| 101 |
}, |
| 102 |
}; |
| 103 |
|
| 104 |
static const struct nhlt_dmic_array_config dmic_4ch_mic_config = { |
| 105 |
.tdm_config = { |
| 106 |
.config_type = NHLT_TDM_MIC_ARRAY, |
| 107 |
}, |
| 108 |
.array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED, |
| 109 |
}; |
| 110 |
|
| 111 |
static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = { |
| 112 |
{ |
| 113 |
.link = NHLT_LINK_PDM, |
| 114 |
.device = NHLT_PDM_DEV_CAVS15, |
| 115 |
.direction = NHLT_DIR_CAPTURE, |
| 116 |
.vid = NHLT_VID, |
| 117 |
.did = NHLT_DID_DMIC, |
| 118 |
.cfg = &dmic_4ch_mic_config, |
| 119 |
.cfg_size = sizeof(dmic_4ch_mic_config), |
| 120 |
.formats = dmic_4ch_formats, |
| 121 |
.num_formats = ARRAY_SIZE(dmic_4ch_formats), |
| 122 |
}, |
| 123 |
}; |
| 124 |
|
| 125 |
int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels) |
| 126 |
{ |
| 127 |
switch (num_channels) { |
| 128 |
case 1: |
| 129 |
return nhlt_add_endpoints(nhlt, dmic_1ch_descriptors, |
| 130 |
ARRAY_SIZE(dmic_1ch_descriptors)); |
| 131 |
case 2: |
| 132 |
return nhlt_add_endpoints(nhlt, dmic_2ch_descriptors, |
| 133 |
ARRAY_SIZE(dmic_2ch_descriptors)); |
| 134 |
case 4: |
| 135 |
return nhlt_add_endpoints(nhlt, dmic_4ch_descriptors, |
| 136 |
ARRAY_SIZE(dmic_4ch_descriptors)); |
| 137 |
default: |
| 138 |
return -1; |
| 139 |
} |
| 140 |
} |