f4f0887a2e8ddd3ae27b968e47966f30d0348648
[openwrt/staging/blogic.git] /
1 From deb60e65648c23cb373324ac2272c6468d21fe96 Mon Sep 17 00:00:00 2001
2 From: Annaliese McDermond <nh6z@nh6z.net>
3 Date: Mon, 18 Mar 2019 20:37:44 -0700
4 Subject: [PATCH 397/782] ASoC: tlv320aic32x4: Break out clock setting into
5 separate function
6
7 commit bf31cbfbe25001036e1e096b1c260bf871766ea5 upstream.
8
9 Break the clock setting logic out from the main hw_params. It's
10 rather large and unweildy and makes for a large function. This
11 also better enables some of the following changes to the clock
12 tree access in the driver.
13
14 Signed-off-by: Annaliese McDermond <nh6z@nh6z.net>
15 Signed-off-by: Mark Brown <broonie@kernel.org>
16 ---
17 sound/soc/codecs/tlv320aic32x4.c | 26 ++++++++++++++++++--------
18 1 file changed, 18 insertions(+), 8 deletions(-)
19
20 --- a/sound/soc/codecs/tlv320aic32x4.c
21 +++ b/sound/soc/codecs/tlv320aic32x4.c
22 @@ -698,17 +698,13 @@ static int aic32x4_set_dai_fmt(struct sn
23 return 0;
24 }
25
26 -static int aic32x4_hw_params(struct snd_pcm_substream *substream,
27 - struct snd_pcm_hw_params *params,
28 - struct snd_soc_dai *dai)
29 +static int aic32x4_setup_clocks(struct snd_soc_component *component,
30 + unsigned int sample_rate,
31 + unsigned int parent_rate)
32 {
33 - struct snd_soc_component *component = dai->component;
34 - struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component);
35 - u8 iface1_reg = 0;
36 - u8 dacsetup_reg = 0;
37 int i;
38
39 - i = aic32x4_get_divs(aic32x4->sysclk, params_rate(params));
40 + i = aic32x4_get_divs(parent_rate, sample_rate);
41 if (i < 0) {
42 printk(KERN_ERR "aic32x4: sampling rate not supported\n");
43 return i;
44 @@ -765,6 +761,20 @@ static int aic32x4_hw_params(struct snd_
45 snd_soc_component_update_bits(component, AIC32X4_BCLKN,
46 AIC32X4_BCLK_MASK, aic32x4_divs[i].blck_N);
47
48 + return 0;
49 +}
50 +
51 +static int aic32x4_hw_params(struct snd_pcm_substream *substream,
52 + struct snd_pcm_hw_params *params,
53 + struct snd_soc_dai *dai)
54 +{
55 + struct snd_soc_component *component = dai->component;
56 + struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component);
57 + u8 iface1_reg = 0;
58 + u8 dacsetup_reg = 0;
59 +
60 + aic32x4_setup_clocks(component, params_rate(params), aic32x4->sysclk);
61 +
62 switch (params_width(params)) {
63 case 16:
64 iface1_reg |= (AIC32X4_WORD_LEN_16BITS <<