|
35 | 35 | #define MICFIL_AUDIO_PLL2 1 |
36 | 36 | #define MICFIL_CLK_EXT3 2 |
37 | 37 |
|
| 38 | +static const unsigned int fsl_micfil_rates[] = { |
| 39 | + 8000, 11025, 16000, 22050, 32000, 44100, 48000, |
| 40 | +}; |
| 41 | + |
| 42 | +static const struct snd_pcm_hw_constraint_list fsl_micfil_rate_constraints = { |
| 43 | + .count = ARRAY_SIZE(fsl_micfil_rates), |
| 44 | + .list = fsl_micfil_rates, |
| 45 | +}; |
| 46 | + |
38 | 47 | enum quality { |
39 | 48 | QUALITY_HIGH, |
40 | 49 | QUALITY_MEDIUM, |
@@ -486,29 +495,12 @@ static int fsl_micfil_startup(struct snd_pcm_substream *substream, |
486 | 495 | struct snd_soc_dai *dai) |
487 | 496 | { |
488 | 497 | struct fsl_micfil *micfil = snd_soc_dai_get_drvdata(dai); |
489 | | - unsigned int rates[MICFIL_NUM_RATES] = {8000, 11025, 16000, 22050, 32000, 44100, 48000}; |
490 | | - int i, j, k = 0; |
491 | | - u64 clk_rate; |
492 | 498 |
|
493 | 499 | if (!micfil) { |
494 | 500 | dev_err(dai->dev, "micfil dai priv_data not set\n"); |
495 | 501 | return -EINVAL; |
496 | 502 | } |
497 | 503 |
|
498 | | - micfil->constraint_rates.list = micfil->constraint_rates_list; |
499 | | - micfil->constraint_rates.count = 0; |
500 | | - |
501 | | - for (j = 0; j < MICFIL_NUM_RATES; j++) { |
502 | | - for (i = 0; i < MICFIL_CLK_SRC_NUM; i++) { |
503 | | - clk_rate = clk_get_rate(micfil->clk_src[i]); |
504 | | - if (clk_rate != 0 && do_div(clk_rate, rates[j]) == 0) { |
505 | | - micfil->constraint_rates_list[k++] = rates[j]; |
506 | | - micfil->constraint_rates.count++; |
507 | | - break; |
508 | | - } |
509 | | - } |
510 | | - } |
511 | | - |
512 | 504 | if (micfil->constraint_rates.count > 0) |
513 | 505 | snd_pcm_hw_constraint_list(substream->runtime, 0, |
514 | 506 | SNDRV_PCM_HW_PARAM_RATE, |
@@ -1239,6 +1231,13 @@ static int fsl_micfil_probe(struct platform_device *pdev) |
1239 | 1231 | if (IS_ERR(micfil->clk_src[MICFIL_CLK_EXT3])) |
1240 | 1232 | micfil->clk_src[MICFIL_CLK_EXT3] = NULL; |
1241 | 1233 |
|
| 1234 | + fsl_asoc_constrain_rates(&micfil->constraint_rates, |
| 1235 | + &fsl_micfil_rate_constraints, |
| 1236 | + micfil->clk_src[MICFIL_AUDIO_PLL1], |
| 1237 | + micfil->clk_src[MICFIL_AUDIO_PLL2], |
| 1238 | + micfil->clk_src[MICFIL_CLK_EXT3], |
| 1239 | + micfil->constraint_rates_list); |
| 1240 | + |
1242 | 1241 | /* init regmap */ |
1243 | 1242 | regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); |
1244 | 1243 | if (IS_ERR(regs)) |
|
0 commit comments