diff options
| -rw-r--r-- | Documentation/devicetree/bindings/sound/simple-card.txt | 5 | ||||
| -rw-r--r-- | sound/soc/generic/simple-card.c | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 17c13e74667d..a4c72d09cd45 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt | |||
| @@ -86,6 +86,11 @@ Optional CPU/CODEC subnodes properties: | |||
| 86 | in dai startup() and disabled with | 86 | in dai startup() and disabled with |
| 87 | clk_disable_unprepare() in dai | 87 | clk_disable_unprepare() in dai |
| 88 | shutdown(). | 88 | shutdown(). |
| 89 | If a clock is specified and a | ||
| 90 | multiplication factor is given with | ||
| 91 | mclk-fs, the clock will be set to the | ||
| 92 | calculated mclk frequency when the | ||
| 93 | stream starts. | ||
| 89 | - system-clock-direction-out : specifies clock direction as 'out' on | 94 | - system-clock-direction-out : specifies clock direction as 'out' on |
| 90 | initialization. It is useful for some aCPUs with | 95 | initialization. It is useful for some aCPUs with |
| 91 | fixed clocks. | 96 | fixed clocks. |
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 6959a74a6f49..4a516c428b3d 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
| @@ -135,6 +135,18 @@ static void asoc_simple_card_shutdown(struct snd_pcm_substream *substream) | |||
| 135 | asoc_simple_card_clk_disable(&dai_props->codec_dai); | 135 | asoc_simple_card_clk_disable(&dai_props->codec_dai); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | static int asoc_simple_set_clk_rate(struct asoc_simple_dai *simple_dai, | ||
| 139 | unsigned long rate) | ||
| 140 | { | ||
| 141 | if (!simple_dai->clk) | ||
| 142 | return 0; | ||
| 143 | |||
| 144 | if (clk_get_rate(simple_dai->clk) == rate) | ||
| 145 | return 0; | ||
| 146 | |||
| 147 | return clk_set_rate(simple_dai->clk, rate); | ||
| 148 | } | ||
| 149 | |||
| 138 | static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, | 150 | static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, |
| 139 | struct snd_pcm_hw_params *params) | 151 | struct snd_pcm_hw_params *params) |
| 140 | { | 152 | { |
| @@ -154,6 +166,15 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, | |||
| 154 | 166 | ||
| 155 | if (mclk_fs) { | 167 | if (mclk_fs) { |
| 156 | mclk = params_rate(params) * mclk_fs; | 168 | mclk = params_rate(params) * mclk_fs; |
| 169 | |||
| 170 | ret = asoc_simple_set_clk_rate(&dai_props->codec_dai, mclk); | ||
| 171 | if (ret < 0) | ||
| 172 | return ret; | ||
| 173 | |||
| 174 | ret = asoc_simple_set_clk_rate(&dai_props->cpu_dai, mclk); | ||
| 175 | if (ret < 0) | ||
| 176 | return ret; | ||
| 177 | |||
| 157 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, | 178 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, |
| 158 | SND_SOC_CLOCK_IN); | 179 | SND_SOC_CLOCK_IN); |
| 159 | if (ret && ret != -ENOTSUPP) | 180 | if (ret && ret != -ENOTSUPP) |
