1 From 27053ee9edee96b33fd8a6ff0311fa9ad17bb5cc 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 398/773] ASoC: tlv320aic32x4: Break out clock setting into
7 commit bf31cbfbe25001036e1e096b1c260bf871766ea5 upstream.
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.
14 Signed-off-by: Annaliese McDermond <nh6z@nh6z.net>
15 Signed-off-by: Mark Brown <broonie@kernel.org>
17 sound/soc/codecs/tlv320aic32x4.c | 26 ++++++++++++++++++--------
18 1 file changed, 18 insertions(+), 8 deletions(-)
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
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)
33 - struct snd_soc_component *component = dai->component;
34 - struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component);
36 - u8 dacsetup_reg = 0;
39 - i = aic32x4_get_divs(aic32x4->sysclk, params_rate(params));
40 + i = aic32x4_get_divs(parent_rate, sample_rate);
42 printk(KERN_ERR "aic32x4: sampling rate not supported\n");
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);
51 +static int aic32x4_hw_params(struct snd_pcm_substream *substream,
52 + struct snd_pcm_hw_params *params,
53 + struct snd_soc_dai *dai)
55 + struct snd_soc_component *component = dai->component;
56 + struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component);
58 + u8 dacsetup_reg = 0;
60 + aic32x4_setup_clocks(component, params_rate(params), aic32x4->sysclk);
62 switch (params_width(params)) {
64 iface1_reg |= (AIC32X4_WORD_LEN_16BITS <<