Skip to content

Commit 7b4c93a

Browse files
ujfalusitiwai
authored andcommitted
ALSA: hda: intel-nhlt: Ignore vbps when looking for DMIC 32 bps format
When looking up DMIC blob from the NHLT table and the format is 32 bits, ignore the vbps matching for 32 bps for DMIC since some NHLT table have the vbps as 24, some have it as 32. The DMIC hardware supports only one type of 32 bit sample size, which is 24 bit sampling on the MSB side and bits[1:0] is used for indicating the channel number. Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 732c678 commit 7b4c93a

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

sound/hda/intel-nhlt.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ EXPORT_SYMBOL(intel_nhlt_ssp_mclk_mask);
238238

239239
static struct nhlt_specific_cfg *
240240
nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch,
241-
u32 rate, u8 vbps, u8 bps)
241+
u32 rate, u8 vbps, u8 bps, bool ignore_vbps)
242242
{
243243
struct nhlt_fmt_cfg *cfg = fmt->fmt_config;
244244
struct wav_fmt *wfmt;
@@ -255,8 +255,12 @@ nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch,
255255
dev_dbg(dev, "Endpoint format: ch=%d fmt=%d/%d rate=%d\n",
256256
wfmt->channels, _vbps, _bps, wfmt->samples_per_sec);
257257

258+
/*
259+
* When looking for exact match of configuration ignore the vbps
260+
* from NHLT table when ignore_vbps is true
261+
*/
258262
if (wfmt->channels == num_ch && wfmt->samples_per_sec == rate &&
259-
vbps == _vbps && bps == _bps)
263+
(ignore_vbps || vbps == _vbps) && bps == _bps)
260264
return &cfg->config;
261265

262266
cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps + cfg->config.size);
@@ -289,6 +293,7 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
289293
{
290294
struct nhlt_specific_cfg *cfg;
291295
struct nhlt_endpoint *epnt;
296+
bool ignore_vbps = false;
292297
struct nhlt_fmt *fmt;
293298
int i;
294299

@@ -298,7 +303,26 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
298303
dev_dbg(dev, "Looking for configuration:\n");
299304
dev_dbg(dev, " vbus_id=%d link_type=%d dir=%d, dev_type=%d\n",
300305
bus_id, link_type, dir, dev_type);
301-
dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate);
306+
if (link_type == NHLT_LINK_DMIC && bps == 32 && (vbps == 24 || vbps == 32)) {
307+
/*
308+
* The DMIC hardware supports only one type of 32 bits sample
309+
* size, which is 24 bit sampling on the MSB side and bits[1:0]
310+
* are used for indicating the channel number.
311+
* It has been observed that some NHLT tables have the vbps
312+
* specified as 32 while some uses 24.
313+
* The format these variations describe are identical, the
314+
* hardware is configured and behaves the same way.
315+
* Note: when the samples assumed to be vbps=32 then the 'noise'
316+
* introduced by the lower two bits (channel number) have no
317+
* real life implication on audio quality.
318+
*/
319+
dev_dbg(dev,
320+
" ch=%d fmt=%d rate=%d (vbps is ignored for DMIC 32bit format)\n",
321+
num_ch, bps, rate);
322+
ignore_vbps = true;
323+
} else {
324+
dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate);
325+
}
302326
dev_dbg(dev, "Endpoint count=%d\n", nhlt->endpoint_count);
303327

304328
epnt = (struct nhlt_endpoint *)nhlt->desc;
@@ -307,7 +331,8 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
307331
if (nhlt_check_ep_match(dev, epnt, bus_id, link_type, dir, dev_type)) {
308332
fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size);
309333

310-
cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate, vbps, bps);
334+
cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate,
335+
vbps, bps, ignore_vbps);
311336
if (cfg)
312337
return cfg;
313338
}

0 commit comments

Comments
 (0)