ASoC: SOF: ipc4-topology: Add support for NHLT with 16-bit only DMIC blob
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Thu, 30 May 2024 11:19:14 +0000 (14:19 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 30 May 2024 11:33:28 +0000 (12:33 +0100)
The ACPI NHLT table always had 32-bit DMIC blob even if 16-bit was also
present and taken as a 'rule' which obviously got broken and there is at
least one device on the market which ships with only 16-bit DMIC
configuration blob.
This corner case has never been supported and it is going to need topology
updates for DMIC copier to support multiple formats.

As for the kernel side: if the copier supports multiple formats and the
preferred 32-bit DMIC blob is not found then we will try to get a 16-bit
DMIC configuration and look for a 16-bit copier config.

Fixes: f9209644ae76 ("ASoC: SOF: ipc4-topology: Correct DAI copier config and NHLT blob request")
Link: https://github.com/thesofproject/linux/issues/4973
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Seppo Ingalsuo <seppo.ingalsuo@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://msgid.link/r/20240530111918.21974-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ipc4-topology.c

index beff109..521b4dc 100644 (file)
@@ -1483,6 +1483,8 @@ snd_sof_get_nhlt_endpoint_data(struct snd_sof_dev *sdev, struct snd_sof_dai *dai
                                           dir, dev_type);
 
        if (!cfg) {
+               bool get_new_blob = false;
+
                if (format_change) {
                        /*
                         * The 32-bit blob was not found in NHLT table, try to
@@ -1490,7 +1492,20 @@ snd_sof_get_nhlt_endpoint_data(struct snd_sof_dev *sdev, struct snd_sof_dai *dai
                         */
                        bit_depth = params_width(params);
                        format_change = false;
+                       get_new_blob = true;
+               } else if (linktype == SOF_DAI_INTEL_DMIC && !single_format) {
+                       /*
+                        * The requested 32-bit blob (no format change for the
+                        * blob request) was not found in NHLT table, try to
+                        * look for 16-bit blob if the copier supports multiple
+                        * formats
+                        */
+                       bit_depth = 16;
+                       format_change = true;
+                       get_new_blob = true;
+               }
 
+               if (get_new_blob) {
                        cfg = intel_nhlt_get_endpoint_blob(sdev->dev, ipc4_data->nhlt,
                                                           dai_index, nhlt_type,
                                                           bit_depth, bit_depth,
@@ -1513,8 +1528,8 @@ out:
 
        if (format_change) {
                /*
-                * Update the params to reflect that we have loaded 32-bit blob
-                * instead of the 16-bit.
+                * Update the params to reflect that different blob was loaded
+                * instead of the requested bit depth (16 -> 32 or 32 -> 16).
                 * This information is going to be used by the caller to find
                 * matching copier format on the dai side.
                 */
@@ -1522,7 +1537,11 @@ out:
 
                m = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
                snd_mask_none(m);
-               snd_mask_set_format(m, SNDRV_PCM_FORMAT_S32_LE);
+               if (bit_depth == 16)
+                       snd_mask_set_format(m, SNDRV_PCM_FORMAT_S16_LE);
+               else
+                       snd_mask_set_format(m, SNDRV_PCM_FORMAT_S32_LE);
+
        }
 
        return 0;