ASoC: Allow source specification for CODEC level sysclk
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 24 Aug 2011 19:09:01 +0000 (20:09 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 31 Aug 2011 08:57:35 +0000 (09:57 +0100)
Similarly to PLLs/FLLs some modern CODECs provide selectable system clock
sources. When the clock is the clock for a DAI we do not usually need to
identify which clock is being configured so can use clk_id for the source
clock but with CODEC wide system clocks we will need to specify both the
clock being configured and the source.

Add a source argument to the CODEC driver set_sysclk() operation to
reflect this. As this operation is not as widely used as the DAI
set_sysclk() operation the change is not very invasive. We probably
ought to go and make the same alternation for DAIs at some point.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
include/sound/soc.h
sound/soc/codecs/adav80x.c
sound/soc/codecs/wm9081.c
sound/soc/samsung/speyside.c
sound/soc/soc-core.c

index 0fc8f15..24e17be 100644 (file)
@@ -276,7 +276,7 @@ enum snd_soc_pcm_subclass {
 };
 
 int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
-                            unsigned int freq, int dir);
+                            int source, unsigned int freq, int dir);
 int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
                          unsigned int freq_in, unsigned int freq_out);
 
@@ -610,7 +610,7 @@ struct snd_soc_codec_driver {
 
        /* codec wide operations */
        int (*set_sysclk)(struct snd_soc_codec *codec,
-                         int clk_id, unsigned int freq, int dir);
+                         int clk_id, int source, unsigned int freq, int dir);
        int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source,
                unsigned int freq_in, unsigned int freq_out);
 
index 300c04b..f9f0894 100644 (file)
@@ -523,7 +523,8 @@ static int adav80x_hw_params(struct snd_pcm_substream *substream,
 }
 
 static int adav80x_set_sysclk(struct snd_soc_codec *codec,
-               int clk_id, unsigned int freq, int dir)
+                             int clk_id, int source,
+                             unsigned int freq, int dir)
 {
        struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
 
index a469132..f32ab1e 100644 (file)
@@ -1120,8 +1120,8 @@ static int wm9081_digital_mute(struct snd_soc_dai *codec_dai, int mute)
        return 0;
 }
 
-static int wm9081_set_sysclk(struct snd_soc_codec *codec,
-                            int clk_id, unsigned int freq, int dir)
+static int wm9081_set_sysclk(struct snd_soc_codec *codec, int clk_id,
+                            int source, unsigned int freq, int dir)
 {
        struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
 
index bfed1ff..09df8af 100644 (file)
@@ -223,7 +223,7 @@ static int speyside_wm9081_init(struct snd_soc_dapm_context *dapm)
        snd_soc_dapm_nc_pin(dapm, "LINEOUT");
 
        /* At any time the WM9081 is active it will have this clock */
-       return snd_soc_codec_set_sysclk(dapm->codec, WM9081_SYSCLK_MCLK,
+       return snd_soc_codec_set_sysclk(dapm->codec, WM9081_SYSCLK_MCLK, 0,
                                        48000 * 256, 0);
 }
 
index fc7fff3..4ec93d1 100644 (file)
@@ -2670,7 +2670,7 @@ int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
        if (dai->driver && dai->driver->ops->set_sysclk)
                return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
        else if (dai->codec && dai->codec->driver->set_sysclk)
-               return dai->codec->driver->set_sysclk(dai->codec, clk_id,
+               return dai->codec->driver->set_sysclk(dai->codec, clk_id, 0,
                                                      freq, dir);
        else
                return -EINVAL;
@@ -2681,16 +2681,18 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
  * snd_soc_codec_set_sysclk - configure CODEC system or master clock.
  * @codec: CODEC
  * @clk_id: DAI specific clock ID
+ * @source: Source for the clock
  * @freq: new clock frequency in Hz
  * @dir: new clock direction - input/output.
  *
  * Configures the CODEC master (MCLK) or system (SYSCLK) clocking.
  */
 int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
-       unsigned int freq, int dir)
+                            int source, unsigned int freq, int dir)
 {
        if (codec->driver->set_sysclk)
-               return codec->driver->set_sysclk(codec, clk_id, freq, dir);
+               return codec->driver->set_sysclk(codec, clk_id, source,
+                                                freq, dir);
        else
                return -EINVAL;
 }