]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ASoC: bcm2835: setup clock only if CPU is clock master
authorMatthias Reichl <hias@horus.com>
Mon, 25 Apr 2016 13:39:39 +0000 (13:39 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 25 Apr 2016 16:39:11 +0000 (17:39 +0100)
We only need to enable the clock if we are a clock master.

Code ported from bcm2708-i2s driver in Raspberry Pi tree.
Original work by Zoltan Szenczi.

Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/bcm/bcm2835-i2s.c

index d2663e79ece1a2b649377e4a89460aa5a6d150b5..a0026e2d2f0afd700751b1b4fa2523585829173e 100644 (file)
@@ -276,8 +276,15 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream,
                /* otherwise calculate a fitting block ratio */
                bclk_ratio = 2 * data_length;
 
-       /* set target clock rate*/
-       clk_set_rate(dev->clk, sampling_rate * bclk_ratio);
+       /* Clock should only be set up here if CPU is clock master */
+       switch (dev->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+       case SND_SOC_DAIFMT_CBS_CFS:
+       case SND_SOC_DAIFMT_CBS_CFM:
+               clk_set_rate(dev->clk, sampling_rate * bclk_ratio);
+               break;
+       default:
+               break;
+       }
 
        /* Setup the frame format */
        format = BCM2835_I2S_CHEN;