diff options
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/rl6231.c | 16 | ||||
-rw-r--r-- | sound/soc/codecs/rl6231.h | 1 | ||||
-rw-r--r-- | sound/soc/codecs/rt5640.c | 17 | ||||
-rw-r--r-- | sound/soc/codecs/rt5645.c | 17 | ||||
-rw-r--r-- | sound/soc/codecs/rt5651.c | 17 |
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 | } |
132 | EXPORT_SYMBOL_GPL(rl6231_pll_calc); | 132 | EXPORT_SYMBOL_GPL(rl6231_pll_calc); |
133 | 133 | ||
134 | int 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 | } | ||
148 | EXPORT_SYMBOL_GPL(rl6231_get_clk_info); | ||
149 | |||
134 | MODULE_DESCRIPTION("RL6231 class device shared support"); | 150 | MODULE_DESCRIPTION("RL6231 class device shared support"); |
135 | MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); | 151 | MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); |
136 | MODULE_LICENSE("GPL v2"); | 152 | MODULE_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 { | |||
29 | int rl6231_calc_dmic_clk(int rate); | 29 | int rl6231_calc_dmic_clk(int rate); |
30 | int rl6231_pll_calc(const unsigned int freq_in, | 30 | int 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); |
32 | int 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 | ||
1628 | static 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 | |||
1643 | static int rt5640_hw_params(struct snd_pcm_substream *substream, | 1628 | static 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 | ||
1789 | static 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 | |||
1804 | static int rt5645_hw_params(struct snd_pcm_substream *substream, | 1789 | static 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 | ||
1341 | static 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 | |||
1356 | static int rt5651_hw_params(struct snd_pcm_substream *substream, | 1341 | static 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"); |