Lines Matching +full:dmic +full:- +full:sample +full:- +full:rate
1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2015-2019 Intel Corporation
5 #include <sound/intel-nhlt.h>
42 if (nhlt->header.length <= sizeof(struct acpi_table_header)) { in intel_nhlt_get_dmic_geo()
43 dev_warn(dev, "Invalid DMIC description table\n"); in intel_nhlt_get_dmic_geo()
47 for (j = 0, epnt = nhlt->desc; j < nhlt->endpoint_count; j++, in intel_nhlt_get_dmic_geo()
48 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length)) { in intel_nhlt_get_dmic_geo()
50 if (epnt->linktype != NHLT_LINK_DMIC) in intel_nhlt_get_dmic_geo()
53 cfg = (struct nhlt_dmic_array_config *)(epnt->config.caps); in intel_nhlt_get_dmic_geo()
54 fmt_configs = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size); in intel_nhlt_get_dmic_geo()
57 if (fmt_configs->fmt_count) { in intel_nhlt_get_dmic_geo()
58 struct nhlt_fmt_cfg *fmt_cfg = fmt_configs->fmt_config; in intel_nhlt_get_dmic_geo()
61 fmt_configs->fmt_count); in intel_nhlt_get_dmic_geo()
63 for (i = 0; i < fmt_configs->fmt_count; i++) { in intel_nhlt_get_dmic_geo()
66 fmt_ext = &fmt_cfg->fmt_ext; in intel_nhlt_get_dmic_geo()
68 if (fmt_ext->fmt.channels > max_ch) in intel_nhlt_get_dmic_geo()
69 max_ch = fmt_ext->fmt.channels; in intel_nhlt_get_dmic_geo()
72 fmt_cfg = (struct nhlt_fmt_cfg *)(fmt_cfg->config.caps + in intel_nhlt_get_dmic_geo()
73 fmt_cfg->config.size); in intel_nhlt_get_dmic_geo()
80 if (cfg->device_config.config_type != NHLT_CONFIG_TYPE_MIC_ARRAY) { in intel_nhlt_get_dmic_geo()
83 switch (cfg->array_type) { in intel_nhlt_get_dmic_geo()
96 dmic_geo = cfg_vendor->nb_mics; in intel_nhlt_get_dmic_geo()
99 dev_warn(dev, "%s: undefined DMIC array_type 0x%0x\n", in intel_nhlt_get_dmic_geo()
100 __func__, cfg->array_type); in intel_nhlt_get_dmic_geo()
107 dev_dbg(dev, "max channels %d exceed dmic number %d\n", in intel_nhlt_get_dmic_geo()
113 dev_dbg(dev, "dmic number %d max_ch %d\n", dmic_geo, max_ch); in intel_nhlt_get_dmic_geo()
127 epnt = (struct nhlt_endpoint *)nhlt->desc; in intel_nhlt_has_endpoint_type()
128 for (i = 0; i < nhlt->endpoint_count; i++) { in intel_nhlt_has_endpoint_type()
129 if (epnt->linktype == link_type) in intel_nhlt_has_endpoint_type()
132 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); in intel_nhlt_has_endpoint_type()
147 epnt = (struct nhlt_endpoint *)nhlt->desc; in intel_nhlt_ssp_endpoint_mask()
148 for (i = 0; i < nhlt->endpoint_count; i++) { in intel_nhlt_ssp_endpoint_mask()
149 if (epnt->linktype == NHLT_LINK_SSP && epnt->device_type == device_type) { in intel_nhlt_ssp_endpoint_mask()
151 ssp_mask |= BIT(epnt->virtual_bus_id); in intel_nhlt_ssp_endpoint_mask()
153 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); in intel_nhlt_ssp_endpoint_mask()
182 epnt = (struct nhlt_endpoint *)nhlt->desc; in intel_nhlt_ssp_mclk_mask()
183 for (i = 0; i < nhlt->endpoint_count; i++) { in intel_nhlt_ssp_mclk_mask()
186 if (epnt->linktype == NHLT_LINK_SSP && in intel_nhlt_ssp_mclk_mask()
187 epnt->device_type == NHLT_DEVICE_I2S && in intel_nhlt_ssp_mclk_mask()
188 epnt->virtual_bus_id == ssp_num) { in intel_nhlt_ssp_mclk_mask()
190 fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size); in intel_nhlt_ssp_mclk_mask()
191 cfg = fmt->fmt_config; in intel_nhlt_ssp_mclk_mask()
195 * double-check that the configuration is consistent in intel_nhlt_ssp_mclk_mask()
197 for (j = 0; j < fmt->fmt_count; j++) { in intel_nhlt_ssp_mclk_mask()
203 if (cfg->config.size < 8) in intel_nhlt_ssp_mclk_mask()
204 return -EINVAL; in intel_nhlt_ssp_mclk_mask()
206 blob = (u32 *)cfg->config.caps; in intel_nhlt_ssp_mclk_mask()
220 if (cfg->config.size < size) in intel_nhlt_ssp_mclk_mask()
221 return -EINVAL; in intel_nhlt_ssp_mclk_mask()
225 cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps + cfg->config.size); in intel_nhlt_ssp_mclk_mask()
228 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); in intel_nhlt_ssp_mclk_mask()
233 return -EINVAL; in intel_nhlt_ssp_mclk_mask()
241 u32 rate, u8 vbps, u8 bps) in nhlt_get_specific_cfg() argument
243 struct nhlt_fmt_cfg *cfg = fmt->fmt_config; in nhlt_get_specific_cfg()
248 dev_dbg(dev, "Endpoint format count=%d\n", fmt->fmt_count); in nhlt_get_specific_cfg()
250 for (i = 0; i < fmt->fmt_count; i++) { in nhlt_get_specific_cfg()
251 wfmt = &cfg->fmt_ext.fmt; in nhlt_get_specific_cfg()
252 _bps = wfmt->bits_per_sample; in nhlt_get_specific_cfg()
253 _vbps = cfg->fmt_ext.sample.valid_bits_per_sample; in nhlt_get_specific_cfg()
255 dev_dbg(dev, "Endpoint format: ch=%d fmt=%d/%d rate=%d\n", in nhlt_get_specific_cfg()
256 wfmt->channels, _vbps, _bps, wfmt->samples_per_sec); in nhlt_get_specific_cfg()
258 if (wfmt->channels == num_ch && wfmt->samples_per_sec == rate && in nhlt_get_specific_cfg()
260 return &cfg->config; in nhlt_get_specific_cfg()
262 cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps + cfg->config.size); in nhlt_get_specific_cfg()
272 epnt->virtual_bus_id, epnt->linktype, in nhlt_check_ep_match()
273 epnt->direction, epnt->device_type); in nhlt_check_ep_match()
275 if ((epnt->virtual_bus_id != bus_id) || in nhlt_check_ep_match()
276 (epnt->linktype != link_type) || in nhlt_check_ep_match()
277 (epnt->direction != dir)) in nhlt_check_ep_match()
280 /* link of type DMIC bypasses device_type check */ in nhlt_check_ep_match()
281 return epnt->linktype == NHLT_LINK_DMIC || in nhlt_check_ep_match()
282 epnt->device_type == dev_type; in nhlt_check_ep_match()
288 u8 num_ch, u32 rate, u8 dir, u8 dev_type) in intel_nhlt_get_endpoint_blob() argument
301 dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate); in intel_nhlt_get_endpoint_blob()
302 dev_dbg(dev, "Endpoint count=%d\n", nhlt->endpoint_count); in intel_nhlt_get_endpoint_blob()
304 epnt = (struct nhlt_endpoint *)nhlt->desc; in intel_nhlt_get_endpoint_blob()
306 for (i = 0; i < nhlt->endpoint_count; i++) { in intel_nhlt_get_endpoint_blob()
308 fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size); in intel_nhlt_get_endpoint_blob()
310 cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate, vbps, bps); in intel_nhlt_get_endpoint_blob()
315 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); in intel_nhlt_get_endpoint_blob()