Skip to content

Commit

Permalink
Topology: NHLT: Intel: Fix mono DMIC configure for MTL platform
Browse files Browse the repository at this point in the history
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.
The previous code version hard-codes the FIFO packer to stereo
mode without support for mono.

As a fix if only one microphone is enabled for dmic0 or dmic1,
then the corresponding IPM_SOURCE_MODE in OUTCONTROL0 or OUTCONTROL1
is set to 0. Otherwise it is set to 1 for stereo mode.

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu committed Jan 10, 2025
1 parent 4efe03b commit d94ed97
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions topology/nhlt/intel/dmic/dmic-process.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,21 @@ 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 i, j;
int swap_check;
int ret = 0;

for (i = 0; i < DMIC_HW_FIFOS; i++) {
ipmsm[i] = 0;
for (j = 0; j < DMIC_HW_CONTROLLERS; j++) {
if (dmic->dmic_prm[i].pdm[j].enable_mic_a && dmic->dmic_prm[i].pdm[j].enable_mic_b)
ipmsm[i] = 1;
}
}

for (i = 0; i < DMIC_HW_CONTROLLERS; i++) {
cnt = 0;
if (dmic->dmic_prm[0].pdm[i].enable_mic_a ||
Expand Down Expand Up @@ -654,6 +662,8 @@ 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];
int ipmsm[DMIC_HW_FIFOS];
uint32_t val = 0;
int32_t ci;
uint32_t cu;
Expand All @@ -678,7 +688,6 @@ static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_
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
Expand Down Expand Up @@ -762,6 +771,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);
Expand Down Expand Up @@ -803,7 +818,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[0]) |
OUTCONTROL0_TH(th);
} else {
ipm_helper2(dmic, source, &ipm);
Expand All @@ -818,19 +833,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[1]) |
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) |
Expand Down

0 comments on commit d94ed97

Please sign in to comment.