From 0162116a3b2eb3fa23ee9cc63fa63c8accb5b057 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 8 Jan 2025 13:56:46 +0200 Subject: [PATCH] Topology: NHLT: Intel: Fix mono DMIC configure for MTL platform This change fixes the blob generator for mono microphone configuration. As difference to previous platforms the FIFO packer mono/stereo mode set up in OUTCONTROLx IPM_SOURCE_MODE bit-field. Signed-off-by: Seppo Ingalsuo --- topology/nhlt/intel/dmic/dmic-process.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/topology/nhlt/intel/dmic/dmic-process.c b/topology/nhlt/intel/dmic/dmic-process.c index adbec79be..4f0c9fde9 100644 --- a/topology/nhlt/intel/dmic/dmic-process.c +++ b/topology/nhlt/intel/dmic/dmic-process.c @@ -613,13 +613,14 @@ static void ipm_helper2(struct intel_dmic_params *dmic, int source[], int *ipm) * operate as stereo or mono left (A) or mono right (B) mode. Mono right mode is setup as channel * swapped mono left. */ -static int stereo_helper(struct intel_dmic_params *dmic, int stereo[], int swap[]) +static int stereo_helper(struct intel_dmic_params *dmic, int stereo[], int swap[], int *ipmsm) { int cnt; int i; int swap_check; int ret = 0; + *ipmsm = 0; for (i = 0; i < DMIC_HW_CONTROLLERS; i++) { cnt = 0; if (dmic->dmic_prm[0].pdm[i].enable_mic_a || @@ -633,6 +634,8 @@ static int stereo_helper(struct intel_dmic_params *dmic, int stereo[], int swap[ /* Set stereo mode if both mic A anc B are enabled. */ cnt >>= 1; stereo[i] = cnt; + if (cnt) + *ipmsm = 1; /* Swap channels if only mic B is used for mono processing. */ swap[i] = (dmic->dmic_prm[0].pdm[i].enable_mic_b || @@ -654,6 +657,7 @@ static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_ { int stereo[DMIC_HW_CONTROLLERS]; int swap[DMIC_HW_CONTROLLERS]; + int source[OUTCONTROLX_IPM_NUMSOURCES]; uint32_t val = 0; int32_t ci; uint32_t cu; @@ -672,13 +676,13 @@ static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_ int ret; int mic; int chmap_bits; + int ipmsm; int di = dmic->dmic_dai_index; int dccomp = 1; int array_a = 0; int array_b = 0; int bfth = 3; /* Should be 3 for 8 entries, 1 is 2 entries */ int th = 3; /* Used with TIE=1 */ - int source[OUTCONTROLX_IPM_NUMSOURCES]; /* * ts_group value describes which audio channels in the hw fifo are enabled. A 32 bit @@ -762,6 +766,12 @@ static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_ of0 = (dmic->dmic_prm[0].fifo_bits == 32) ? 2 : 0; of1 = (dmic->dmic_prm[1].fifo_bits == 32) ? 2 : 0; + ret = stereo_helper(dmic, stereo, swap, &ipmsm); + if (ret < 0) { + fprintf(stderr, "%s: enable conflict\n", __func__); + return ret; + } + if (dmic->dmic_prm[di].driver_version == 1) { if (di == 0) { ipm_helper1(dmic, &ipm); @@ -803,7 +813,7 @@ static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_ OUTCONTROL0_IPM_SOURCE_2(source[1]) | OUTCONTROL0_IPM_SOURCE_3(source[2]) | OUTCONTROL0_IPM_SOURCE_4(source[3]) | - OUTCONTROL0_IPM_SOURCE_MODE(1) | + OUTCONTROL0_IPM_SOURCE_MODE(ipmsm) | OUTCONTROL0_TH(th); } else { ipm_helper2(dmic, source, &ipm); @@ -818,19 +828,13 @@ static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_ OUTCONTROL1_IPM_SOURCE_2(source[1]) | OUTCONTROL1_IPM_SOURCE_3(source[2]) | OUTCONTROL1_IPM_SOURCE_4(source[3]) | - OUTCONTROL1_IPM_SOURCE_MODE(1) | + OUTCONTROL1_IPM_SOURCE_MODE(ipmsm) | OUTCONTROL1_TH(th); } } dmic->dmic_blob.chan_ctrl_cfg[di] = val; - ret = stereo_helper(dmic, stereo, swap); - if (ret < 0) { - fprintf(stderr, "%s: enable conflict\n", __func__); - return ret; - } - for (i = 0; i < DMIC_HW_CONTROLLERS; i++) { /* CIC */ val = CIC_CONTROL_SOFT_RESET(soft_reset) |