aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorOder Chiou <oder_chiou@realtek.com>2014-05-20 03:01:55 -0400
committerMark Brown <broonie@linaro.org>2014-06-01 15:04:30 -0400
commitd92950e755328a0293af66e18096e0cae29996f1 (patch)
treef4f5a06ad7856bb3d34cb80663c2f3183a87359e /sound
parent71c7a2d675c8fe9b6ab284dcf586f30a7109c96c (diff)
ASoC: rt5640: Add the function "get_clk_info" to RL6231 shared support
The patch adds the function "get_clk_info" to RL6231 shared support. Signed-off-by: Oder Chiou <oder_chiou@realtek.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/rl6231.c16
-rw-r--r--sound/soc/codecs/rl6231.h1
-rw-r--r--sound/soc/codecs/rt5640.c17
-rw-r--r--sound/soc/codecs/rt5645.c17
-rw-r--r--sound/soc/codecs/rt5651.c17
5 files changed, 20 insertions, 48 deletions
diff --git a/sound/soc/codecs/rl6231.c b/sound/soc/codecs/rl6231.c
index 289024be1d40..7b82fbe0d14c 100644
--- a/sound/soc/codecs/rl6231.c
+++ b/sound/soc/codecs/rl6231.c
@@ -131,6 +131,22 @@ code_find:
131} 131}
132EXPORT_SYMBOL_GPL(rl6231_pll_calc); 132EXPORT_SYMBOL_GPL(rl6231_pll_calc);
133 133
134int rl6231_get_clk_info(int sclk, int rate)
135{
136 int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16};
137
138 if (sclk <= 0 || rate <= 0)
139 return -EINVAL;
140
141 rate = rate << 8;
142 for (i = 0; i < ARRAY_SIZE(pd); i++)
143 if (sclk == rate * pd[i])
144 return i;
145
146 return -EINVAL;
147}
148EXPORT_SYMBOL_GPL(rl6231_get_clk_info);
149
134MODULE_DESCRIPTION("RL6231 class device shared support"); 150MODULE_DESCRIPTION("RL6231 class device shared support");
135MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); 151MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>");
136MODULE_LICENSE("GPL v2"); 152MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/codecs/rl6231.h b/sound/soc/codecs/rl6231.h
index efdfc869afe9..0f7b057ed736 100644
--- a/sound/soc/codecs/rl6231.h
+++ b/sound/soc/codecs/rl6231.h
@@ -29,5 +29,6 @@ struct rl6231_pll_code {
29int rl6231_calc_dmic_clk(int rate); 29int rl6231_calc_dmic_clk(int rate);
30int rl6231_pll_calc(const unsigned int freq_in, 30int rl6231_pll_calc(const unsigned int freq_in,
31 const unsigned int freq_out, struct rl6231_pll_code *pll_code); 31 const unsigned int freq_out, struct rl6231_pll_code *pll_code);
32int rl6231_get_clk_info(int sclk, int rate);
32 33
33#endif /* __RL6231_H__ */ 34#endif /* __RL6231_H__ */
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index e945f8d0ffc5..3a09e86082aa 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -1625,21 +1625,6 @@ static int get_sdp_info(struct snd_soc_codec *codec, int dai_id)
1625 return ret; 1625 return ret;
1626} 1626}
1627 1627
1628static int get_clk_info(int sclk, int rate)
1629{
1630 int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16};
1631
1632 if (sclk <= 0 || rate <= 0)
1633 return -EINVAL;
1634
1635 rate = rate << 8;
1636 for (i = 0; i < ARRAY_SIZE(pd); i++)
1637 if (sclk == rate * pd[i])
1638 return i;
1639
1640 return -EINVAL;
1641}
1642
1643static int rt5640_hw_params(struct snd_pcm_substream *substream, 1628static int rt5640_hw_params(struct snd_pcm_substream *substream,
1644 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 1629 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
1645{ 1630{
@@ -1649,7 +1634,7 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream,
1649 int dai_sel, pre_div, bclk_ms, frame_size; 1634 int dai_sel, pre_div, bclk_ms, frame_size;
1650 1635
1651 rt5640->lrck[dai->id] = params_rate(params); 1636 rt5640->lrck[dai->id] = params_rate(params);
1652 pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); 1637 pre_div = rl6231_get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]);
1653 if (pre_div < 0) { 1638 if (pre_div < 0) {
1654 dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", 1639 dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n",
1655 rt5640->lrck[dai->id], dai->id); 1640 rt5640->lrck[dai->id], dai->id);
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index ee6db7c7c5e8..02147be2b302 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -1786,21 +1786,6 @@ static const struct snd_soc_dapm_route rt5645_dapm_routes[] = {
1786 { "SPOR", NULL, "SPK amp" }, 1786 { "SPOR", NULL, "SPK amp" },
1787}; 1787};
1788 1788
1789static int get_clk_info(int sclk, int rate)
1790{
1791 int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16};
1792
1793 if (sclk <= 0 || rate <= 0)
1794 return -EINVAL;
1795
1796 rate = rate << 8;
1797 for (i = 0; i < ARRAY_SIZE(pd); i++)
1798 if (sclk == rate * pd[i])
1799 return i;
1800
1801 return -EINVAL;
1802}
1803
1804static int rt5645_hw_params(struct snd_pcm_substream *substream, 1789static int rt5645_hw_params(struct snd_pcm_substream *substream,
1805 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 1790 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
1806{ 1791{
@@ -1810,7 +1795,7 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream,
1810 int pre_div, bclk_ms, frame_size; 1795 int pre_div, bclk_ms, frame_size;
1811 1796
1812 rt5645->lrck[dai->id] = params_rate(params); 1797 rt5645->lrck[dai->id] = params_rate(params);
1813 pre_div = get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]); 1798 pre_div = rl6231_get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]);
1814 if (pre_div < 0) { 1799 if (pre_div < 0) {
1815 dev_err(codec->dev, "Unsupported clock setting\n"); 1800 dev_err(codec->dev, "Unsupported clock setting\n");
1816 return -EINVAL; 1801 return -EINVAL;
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c
index a627a1f9dfcb..ea4b1c652a26 100644
--- a/sound/soc/codecs/rt5651.c
+++ b/sound/soc/codecs/rt5651.c
@@ -1338,21 +1338,6 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = {
1338 {"PDMR", NULL, "PDM R Mux"}, 1338 {"PDMR", NULL, "PDM R Mux"},
1339}; 1339};
1340 1340
1341static int get_clk_info(int sclk, int rate)
1342{
1343 int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16};
1344
1345 if (sclk <= 0 || rate <= 0)
1346 return -EINVAL;
1347
1348 rate = rate << 8;
1349 for (i = 0; i < ARRAY_SIZE(pd); i++)
1350 if (sclk == rate * pd[i])
1351 return i;
1352
1353 return -EINVAL;
1354}
1355
1356static int rt5651_hw_params(struct snd_pcm_substream *substream, 1341static int rt5651_hw_params(struct snd_pcm_substream *substream,
1357 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 1342 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
1358{ 1343{
@@ -1362,7 +1347,7 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream,
1362 int pre_div, bclk_ms, frame_size; 1347 int pre_div, bclk_ms, frame_size;
1363 1348
1364 rt5651->lrck[dai->id] = params_rate(params); 1349 rt5651->lrck[dai->id] = params_rate(params);
1365 pre_div = get_clk_info(rt5651->sysclk, rt5651->lrck[dai->id]); 1350 pre_div = rl6231_get_clk_info(rt5651->sysclk, rt5651->lrck[dai->id]);
1366 1351
1367 if (pre_div < 0) { 1352 if (pre_div < 0) {
1368 dev_err(codec->dev, "Unsupported clock setting\n"); 1353 dev_err(codec->dev, "Unsupported clock setting\n");