ALSA: hda: intel-nhlt: Ignore vbps when looking for DMIC 32 bps format

[ Upstream commit 7b4c93a50a ]

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 <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20231127111658.17275-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Peter Ujfalusi 2023-11-27 13:16:58 +02:00 committed by Greg Kroah-Hartman
parent 08f6de7b3f
commit a37096b079

View File

@ -238,7 +238,7 @@ EXPORT_SYMBOL(intel_nhlt_ssp_mclk_mask);
static struct nhlt_specific_cfg *
nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch,
u32 rate, u8 vbps, u8 bps)
u32 rate, u8 vbps, u8 bps, bool ignore_vbps)
{
struct nhlt_fmt_cfg *cfg = fmt->fmt_config;
struct wav_fmt *wfmt;
@ -255,8 +255,12 @@ nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch,
dev_dbg(dev, "Endpoint format: ch=%d fmt=%d/%d rate=%d\n",
wfmt->channels, _vbps, _bps, wfmt->samples_per_sec);
/*
* When looking for exact match of configuration ignore the vbps
* from NHLT table when ignore_vbps is true
*/
if (wfmt->channels == num_ch && wfmt->samples_per_sec == rate &&
vbps == _vbps && bps == _bps)
(ignore_vbps || vbps == _vbps) && bps == _bps)
return &cfg->config;
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,
{
struct nhlt_specific_cfg *cfg;
struct nhlt_endpoint *epnt;
bool ignore_vbps = false;
struct nhlt_fmt *fmt;
int i;
@ -298,7 +303,26 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
dev_dbg(dev, "Looking for configuration:\n");
dev_dbg(dev, " vbus_id=%d link_type=%d dir=%d, dev_type=%d\n",
bus_id, link_type, dir, dev_type);
dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate);
if (link_type == NHLT_LINK_DMIC && bps == 32 && (vbps == 24 || vbps == 32)) {
/*
* The DMIC hardware supports only one type of 32 bits sample
* size, which is 24 bit sampling on the MSB side and bits[1:0]
* are used for indicating the channel number.
* It has been observed that some NHLT tables have the vbps
* specified as 32 while some uses 24.
* The format these variations describe are identical, the
* hardware is configured and behaves the same way.
* Note: when the samples assumed to be vbps=32 then the 'noise'
* introduced by the lower two bits (channel number) have no
* real life implication on audio quality.
*/
dev_dbg(dev,
" ch=%d fmt=%d rate=%d (vbps is ignored for DMIC 32bit format)\n",
num_ch, bps, rate);
ignore_vbps = true;
} else {
dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate);
}
dev_dbg(dev, "Endpoint count=%d\n", nhlt->endpoint_count);
epnt = (struct nhlt_endpoint *)nhlt->desc;
@ -307,7 +331,8 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
if (nhlt_check_ep_match(dev, epnt, bus_id, link_type, dir, dev_type)) {
fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size);
cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate, vbps, bps);
cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate,
vbps, bps, ignore_vbps);
if (cfg)
return cfg;
}