[Sound-open-firmware] [PATCH] DMIC: Set DAI parameters from topology parameters instead of hardwired

Seppo Ingalsuo seppo.ingalsuo at linux.intel.com
Wed Jun 20 18:07:58 CEST 2018


This patch enables the 1, 2, and 4ch topologies usage with S32_LE and
S16_LE sample formats. The DMA burst length is also changed to maximum
(8) to fully utilize the DMIC FIFO.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo at linux.intel.com>
---
 src/audio/dai.c    | 36 +++++++++++++++++++++++++++++++++---
 src/drivers/dmic.c |  2 +-
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/audio/dai.c b/src/audio/dai.c
index 21a3b80..7cef5a7 100644
--- a/src/audio/dai.c
+++ b/src/audio/dai.c
@@ -645,9 +645,39 @@ static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config)
 		}
 		break;
 	case SOF_DAI_INTEL_DMIC:
-		/* TODO: No hardwired values here. */
-		dd->config.burst_elems = 2;
-		dev->frame_bytes = 8;
+		/* The frame bytes setting follows only FIFO A setting in
+		 * this DMIC driver version.
+		 */
+		trace_dai("did");
+
+		/* We can use always the largest burst length. */
+		dd->config.burst_elems = 8;
+
+		/* Set frame size in bytes to match the configuration. */
+		if (config->dmic.num_pdm_active > 1) {
+			/* For two or more controllers capture from each
+			 * controller must be stereo.
+			 */
+			dev->frame_bytes = 2 * config->dmic.num_pdm_active *
+				config->dmic.fifo_bits_a >> 3;
+		} else {
+			/* For one controller the capture can be mono or
+			 * stereo. In mono configuration only one of mic A or B
+			 * is enabled.
+			 */
+			if (config->dmic.pdm[0].enable_mic_a +
+				config->dmic.pdm[0].enable_mic_b == 1)
+				dev->frame_bytes =
+					config->dmic.fifo_bits_a >> 3;
+			else
+				dev->frame_bytes = 2 *
+					config->dmic.fifo_bits_a >> 3;
+		}
+		trace_value(config->dmic.fifo_bits_a);
+		trace_value(config->dmic.num_pdm_active);
+		trace_value(config->dmic.pdm[0].enable_mic_a);
+		trace_value(config->dmic.pdm[0].enable_mic_b);
+		trace_value(dev->frame_bytes);
 		break;
 	default:
 		/* other types of DAIs not handled for now */
diff --git a/src/drivers/dmic.c b/src/drivers/dmic.c
index 58d5e20..47c966d 100644
--- a/src/drivers/dmic.c
+++ b/src/drivers/dmic.c
@@ -828,7 +828,7 @@ static int configure_registers(struct dai *dai, struct dmic_configuration *cfg,
 	int array_b = 0;
 	int cic_mute = 1;
 	int fir_mute = 1;
-	int bfth = 1; /* Should be 3 for 8 entries, 1 is 2 entries */
+	int bfth = 3; /* Should be 3 for 8 entries, 1 is 2 entries */
 	int th = 0; /* Used with TIE=1 */
 
 	/* Normal start sequence */
-- 
2.14.1



More information about the Sound-open-firmware mailing list