X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sound%2Fsoc%2Fcodecs%2Frt5645.c;h=caa55199eb87afdb4938808ba3b66d8ad1e2c206;hb=49ef7925c237a2f9da327ea3481dd5bba54693e8;hp=ab97d722e15d8ae0644fb1c8a983acf4faeb6086;hpb=15f78ea67fa712392daebc262821d9fe29705cfa;p=deliverable%2Flinux.git diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index ab97d722e15d..caa55199eb87 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -26,6 +26,7 @@ #include #include +#include "rl6231.h" #include "rt5645.h" #define RT5645_DEVICE_ID 0x6308 @@ -519,30 +520,15 @@ static const struct snd_kcontrol_new rt5645_snd_controls[] = { * @kcontrol: The kcontrol of this widget. * @event: Event id. * - * Choose dmic clock between 1MHz and 3MHz. - * It is better for clock to approximate 3MHz. */ static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); - int div[] = {2, 3, 4, 6, 8, 12}; - int idx = -EINVAL, i; - int rate, red, bound, temp; - - rate = rt5645->sysclk; - red = 3000000 * 12; - for (i = 0; i < ARRAY_SIZE(div); i++) { - bound = div[i] * 3000000; - if (rate > bound) - continue; - temp = bound - rate; - if (temp < red) { - red = temp; - idx = i; - } - } + int idx = -EINVAL; + + idx = rl6231_calc_dmic_clk(rt5645->sysclk); if (idx < 0) dev_err(codec->dev, "Failed to set DMIC clock\n");