Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dmic nhlt update #254

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions topology/nhlt/intel/dmic/dmic-process.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,33 @@ static void find_modes(struct intel_dmic_params *dmic, struct dmic_calc_decim_mo
/* Check for sane pdm clock, min 100 kHz, max ioclk/2 */
if (dmic->dmic_prm[di].pdmclk_max < DMIC_HW_PDM_CLK_MIN ||
dmic->dmic_prm[di].pdmclk_max > dmic->dmic_prm[di].io_clk / 2) {
fprintf(stderr, "find_modes(): pdm clock max not in range\n");
fprintf(stderr, "%s: pdm clock max %d not in range\n", __func__,
dmic->dmic_prm[di].pdmclk_max);
return;
}
if (dmic->dmic_prm[di].pdmclk_min < DMIC_HW_PDM_CLK_MIN ||
dmic->dmic_prm[di].pdmclk_min > dmic->dmic_prm[di].pdmclk_max) {
fprintf(stderr, "find_modes(): pdm clock min not in range\n");
fprintf(stderr, "%s: pdm clock min %d not in range\n", __func__,
dmic->dmic_prm[di].pdmclk_min);
return;
}

/* Check for sane duty cycle */
if (dmic->dmic_prm[di].duty_min > dmic->dmic_prm[di].duty_max) {
fprintf(stderr, "find_modes(): duty cycle min > max\n");
fprintf(stderr, "%s: duty cycle min > max: %d > %d\n", __func__,
dmic->dmic_prm[di].duty_min, dmic->dmic_prm[di].duty_max);
return;
}
if (dmic->dmic_prm[di].duty_min < DMIC_HW_DUTY_MIN ||
dmic->dmic_prm[di].duty_min > DMIC_HW_DUTY_MAX) {
fprintf(stderr, "find_modes(): pdm clock min not in range\n");
fprintf(stderr, "%s: pdm clock min %d not in range\n", __func__,
dmic->dmic_prm[di].duty_min);
return;
}
if (dmic->dmic_prm[di].duty_max < DMIC_HW_DUTY_MIN ||
dmic->dmic_prm[di].duty_max > DMIC_HW_DUTY_MAX) {
fprintf(stderr, "find_modes(): pdm clock max not in range\n");
fprintf(stderr, "%s: pdm clock max %d not in range\n", __func__,
dmic->dmic_prm[di].duty_max);
return;
}

Expand Down Expand Up @@ -428,7 +433,7 @@ static int select_mode(struct intel_dmic_params *dmic, struct dmic_calc_configur
* candidates should be sufficient.
*/
if (modes->num_of_modes == 0) {
fprintf(stderr, "select_mode(): no modes available\n");
fprintf(stderr, "%s: no modes available\n", __func__);
return -EINVAL;
}

Expand All @@ -451,7 +456,7 @@ static int select_mode(struct intel_dmic_params *dmic, struct dmic_calc_configur
}

if (!found) {
fprintf(stderr, "select_mode(): No filter for decimation found\n");
fprintf(stderr, "%s: No filter for decimation found\n", __func__);
return -EINVAL;
}
n = idx[found - 1]; /* Option with highest clock divisor and lowest mic clock rate */
Expand All @@ -468,17 +473,17 @@ static int select_mode(struct intel_dmic_params *dmic, struct dmic_calc_configur
if (cfg->mfir_a > 0) {
cfg->fir_a = get_fir(dmic, cfg, cfg->mfir_a);
if (!cfg->fir_a) {
fprintf(stderr, "select_mode(): can't find FIR coefficients, mfir_a = %d\n",
cfg->mfir_a);
fprintf(stderr, "%s: can't find FIR coefficients, mfir_a = %d\n",
__func__, cfg->mfir_a);
return -EINVAL;
}
}

if (cfg->mfir_b > 0) {
cfg->fir_b = get_fir(dmic, cfg, cfg->mfir_b);
if (!cfg->fir_b) {
fprintf(stderr, "select_mode(): can't find FIR coefficients, mfir_b = %d\n",
cfg->mfir_b);
fprintf(stderr, "%s: can't find FIR coefficients, mfir_b = %d\n",
__func__, cfg->mfir_b);
return -EINVAL;
}
}
Expand All @@ -490,7 +495,7 @@ static int select_mode(struct intel_dmic_params *dmic, struct dmic_calc_configur
g_cic = mcic * mcic * mcic * mcic * mcic;
if (g_cic < 0) {
/* Erroneous decimation factor and CIC gain */
fprintf(stderr, "select_mode(): erroneous decimation factor and CIC gain\n");
fprintf(stderr, "%s: erroneous decimation factor and CIC gain\n");
return -EINVAL;
}

Expand All @@ -515,7 +520,7 @@ static int select_mode(struct intel_dmic_params *dmic, struct dmic_calc_configur
cfg->fir_a->length, gain_to_fir);
if (ret < 0) {
/* Invalid coefficient set found, should not happen. */
fprintf(stderr, "select_mode(): invalid coefficient set found\n");
fprintf(stderr, "%s: invalid coefficient set found\n");
return -EINVAL;
}
} else {
Expand All @@ -531,7 +536,7 @@ static int select_mode(struct intel_dmic_params *dmic, struct dmic_calc_configur
cfg->fir_b->length, gain_to_fir);
if (ret < 0) {
/* Invalid coefficient set found, should not happen. */
fprintf(stderr, "select_mode(): invalid coefficient set found\n");
fprintf(stderr, "%s: invalid coefficient set found\n", __func__);
return -EINVAL;
}
} else {
Expand Down Expand Up @@ -781,7 +786,10 @@ static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_
}
}

if (dmic->dmic_prm[di].driver_version == 2 || dmic->dmic_prm[di].driver_version == 3) {
if (dmic->dmic_prm[di].driver_version >= 2) {
if (dmic->dmic_prm[di].driver_version >= 4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this saying that driver_version 4 and 5 are identical? I didn't see any other place where version 5 was checked, but it's allowed in the first patch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now 4 and 5 are identical. If we need to enable new features of platform "5" there will be later more changes.

bfth = 0;

if (di == 0) {
ipm_helper2(dmic, source, &ipm);
val = OUTCONTROL0_TIE(0) |
Expand Down Expand Up @@ -819,7 +827,7 @@ static int configure_registers(struct intel_dmic_params *dmic, struct dmic_calc_

ret = stereo_helper(dmic, stereo, swap);
if (ret < 0) {
fprintf(stderr, "configure_registers(): enable conflict\n");
fprintf(stderr, "%s: enable conflict\n", __func__);
return ret;
}

Expand Down Expand Up @@ -975,13 +983,14 @@ int dmic_calculate(struct intel_nhlt_params *nhlt)
di = dmic->dmic_dai_index;

if (di >= DMIC_HW_FIFOS) {
fprintf(stderr, "dmic_set_config(): dai->index exceeds number of FIFOs\n");
fprintf(stderr, "%s: dai->index %d exceeds number of FIFOs\n", __func__, di);
ret = -EINVAL;
goto out;
}

if (dmic->dmic_prm[di].num_pdm_active > DMIC_HW_CONTROLLERS) {
fprintf(stderr, "dmic_set_config():controller count exceeds platform capability\n");
fprintf(stderr, "%s: controller count %d exceeds platform capability\n",
__func__, dmic->dmic_prm[di].num_pdm_active);
ret = -EINVAL;
goto out;
}
Expand All @@ -993,7 +1002,8 @@ int dmic_calculate(struct intel_nhlt_params *nhlt)
case 32:
break;
default:
fprintf(stderr, "dmic_set_config(): fifo_bits EINVAL\n");
fprintf(stderr, "%s: Bad fifo_bits %d\n", __func__,
dmic->dmic_prm[di].fifo_bits);
ret = -EINVAL;
goto out;
}
Expand All @@ -1005,22 +1015,22 @@ int dmic_calculate(struct intel_nhlt_params *nhlt)
*/
find_modes(dmic, &modes_a, dmic->dmic_prm[0].fifo_fs);
if (modes_a.num_of_modes == 0 && dmic->dmic_prm[0].fifo_fs > 0) {
fprintf(stderr, "dmic_set_config(): No modes found for FIFO A\n");
fprintf(stderr, "%s: No modes found for FIFO A\n", __func__);
ret = -EINVAL;
goto out;
}

find_modes(dmic, &modes_b, dmic->dmic_prm[1].fifo_fs);
if (modes_b.num_of_modes == 0 && dmic->dmic_prm[1].fifo_fs > 0) {
fprintf(stderr, "dmic_set_config(): No modes found for FIFO B\n");
fprintf(stderr, "%s: No modes found for FIFO B\n", __func__);
ret = -EINVAL;
goto out;
}

match_modes(&modes_ab, &modes_a, &modes_b);
ret = select_mode(dmic, &cfg, &modes_ab);
if (ret < 0) {
fprintf(stderr, "dmic_set_config(): select_mode() failed\n");
fprintf(stderr, "%s: select_mode() failed %d\n", __func__, ret);
ret = -EINVAL;
goto out;
}
Expand All @@ -1030,7 +1040,7 @@ int dmic_calculate(struct intel_nhlt_params *nhlt)
*/
ret = configure_registers(dmic, &cfg);
if (ret < 0) {
fprintf(stderr, "dmic_set_config(): cannot configure registers\n");
fprintf(stderr, "%s: cannot configure registers %d\n", __func__, ret);
ret = -EINVAL;
goto out;
}
Expand Down Expand Up @@ -1232,7 +1242,12 @@ int dmic_set_params(struct intel_nhlt_params *nhlt, int dai_index, int driver_ve
return -EINVAL;

if (dai_index >= DMIC_HW_FIFOS) {
fprintf(stderr, "set_dmic_data illegal dai index\n");
fprintf(stderr, "%s: illegal dai index %d \n", __func__, dai_index);
return -EINVAL;
}

if (driver_version < 1 || driver_version > 5) {
fprintf(stderr, "%s: illegal driver version %d\n", __func__, driver_version);
return -EINVAL;
}

Expand Down Expand Up @@ -1261,7 +1276,7 @@ int dmic_set_pdm_params(struct intel_nhlt_params *nhlt, int pdm_index, int enabl
return -EINVAL;

if (pdm_index >= DMIC_HW_CONTROLLERS) {
fprintf(stderr, "set_pdm_data illegal pdm_index\n");
fprintf(stderr, "%s: illegal pdm_index %d\n", __func__, pdm_index);
return -EINVAL;
}

Expand Down
Loading