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.

To clean up the code, adding vector ipmsm[], the the local variables
in configure_registers() are sorted alphabetically by type, arrays
first.

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu committed Jan 13, 2025
1 parent 4efe03b commit e125ba1
Showing 1 changed file with 39 additions and 27 deletions.
66 changes: 39 additions & 27 deletions topology/nhlt/intel/dmic/dmic-process.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,24 @@ 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;

/* Find FIFOs those need stereo mode, ipmsm 0 is mono, 1 is stereo */
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;
break;
}
}
}

for (i = 0; i < DMIC_HW_CONTROLLERS; i++) {
cnt = 0;
if (dmic->dmic_prm[0].pdm[i].enable_mic_a ||
Expand Down Expand Up @@ -652,33 +663,34 @@ static int stereo_helper(struct intel_dmic_params *dmic, int stereo[], int swap[

static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_configuration *cfg)
{
int ipmsm[DMIC_HW_FIFOS];
int source[OUTCONTROLX_IPM_NUMSOURCES];
int stereo[DMIC_HW_CONTROLLERS];
int swap[DMIC_HW_CONTROLLERS];
uint32_t val = 0;
int32_t ci;
uint32_t cu;
int ipm;
int of0;
int of1;
uint32_t val = 0;
unsigned int i;
int array_a = 0;
int array_b = 0;
int bfth = 3; /* Should be 3 for 8 entries, 1 is 2 entries */
int chmap_bits;
int cic_mute;
int dccomp = 1;
int di = dmic->dmic_dai_index;
int edge;
int fir_decim;
int fir_length;
int length;
int edge;
int soft_reset;
int cic_mute;
int fir_mute;
unsigned int i;
int ipm;
int j;
int ret;
int length;
int mic;
int chmap_bits;
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 of0;
int of1;
int ret;
int soft_reset;
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 +774,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 +821,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 +836,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 e125ba1

Please sign in to comment.