Merge remote-tracking branches 'asoc/topic/intel', 'asoc/topic/io' and 'asoc/topic...
authorMark Brown <broonie@linaro.org>
Sun, 23 Mar 2014 14:00:52 +0000 (14:00 +0000)
committerMark Brown <broonie@linaro.org>
Sun, 23 Mar 2014 14:00:52 +0000 (14:00 +0000)
Documentation/devicetree/bindings/sound/armada-370db-audio.txt
sound/soc/intel/mfld_machine.c
sound/soc/kirkwood/Kconfig
sound/soc/kirkwood/armada-370-db.c
sound/soc/soc-io.c

index 3893b4d15a2021a9ca9ceb47c802c77e24527b58..bf984d238620c2cc30cbda20f48bf58135138d3f 100644 (file)
@@ -11,14 +11,17 @@ Mandatory properties:
  * marvell,audio-controller: a phandle that points to the audio
    controller of the Armada 370 SoC.
 
- * marvell,audio-codec: a phandle that points to the analog audio
-   codec connected to the Armada 370 SoC.
+ * marvell,audio-codec: a set of three phandles that points to:
+
+    1/ the analog audio codec connected to the Armada 370 SoC
+    2/ the S/PDIF transceiver
+    3/ the S/PDIF receiver
 
 Example:
 
        sound {
              compatible = "marvell,a370db-audio";
              marvell,audio-controller = <&audio_controller>;
-             marvell,audio-codec = <&audio_codec>;
+             marvell,audio-codec = <&audio_codec &spdif_out &spdif_in>;
              status = "okay";
        };
index 0cef32e9d4023ff2116cd0886b4be9e382e55b2e..031d78783fc8cb8c824f961947c640685f7f95fb 100644 (file)
@@ -53,6 +53,7 @@ enum soc_mic_bias_zones {
 
 static unsigned int    hs_switch;
 static unsigned int    lo_dac;
+static struct snd_soc_codec *mfld_codec;
 
 struct mfld_mc_private {
        void __iomem *int_base;
@@ -100,8 +101,8 @@ static int headset_get_switch(struct snd_kcontrol *kcontrol,
 static int headset_set_switch(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
-       struct snd_soc_dapm_context *dapm = &codec->dapm;
+       struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_dapm_context *dapm = &card->dapm;
 
        if (ucontrol->value.integer.value[0] == hs_switch)
                return 0;
@@ -127,10 +128,8 @@ static int headset_set_switch(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static void lo_enable_out_pins(struct snd_soc_codec *codec)
+static void lo_enable_out_pins(struct snd_soc_dapm_context *dapm)
 {
-       struct snd_soc_dapm_context *dapm = &codec->dapm;
-
        snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTL");
        snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTR");
        snd_soc_dapm_enable_pin_unlocked(dapm, "LINEOUTL");
@@ -156,8 +155,8 @@ static int lo_get_switch(struct snd_kcontrol *kcontrol,
 static int lo_set_switch(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
-       struct snd_soc_dapm_context *dapm = &codec->dapm;
+       struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_dapm_context *dapm = &card->dapm;
 
        if (ucontrol->value.integer.value[0] == lo_dac)
                return 0;
@@ -167,35 +166,35 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol,
        /* we dont want to work with last state of lineout so just enable all
         * pins and then disable pins not required
         */
-       lo_enable_out_pins(codec);
+       lo_enable_out_pins(dapm);
 
        switch (ucontrol->value.integer.value[0]) {
        case 0:
                pr_debug("set vibra path\n");
                snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT");
                snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT");
-               snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0);
+               snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0);
                break;
 
        case 1:
                pr_debug("set hs  path\n");
                snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones");
                snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT");
-               snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x22);
+               snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x22);
                break;
 
        case 2:
                pr_debug("set spkr path\n");
                snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL");
                snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR");
-               snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x44);
+               snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x44);
                break;
 
        case 3:
                pr_debug("set null path\n");
                snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL");
                snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR");
-               snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x66);
+               snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x66);
                break;
        }
 
@@ -238,26 +237,11 @@ static void mfld_jack_check(unsigned int intr_status)
 
 static int mfld_init(struct snd_soc_pcm_runtime *runtime)
 {
-       struct snd_soc_codec *codec = runtime->codec;
-       struct snd_soc_dapm_context *dapm = &codec->dapm;
+       struct snd_soc_dapm_context *dapm = &runtime->card->dapm;
        int ret_val;
 
-       /* Add jack sense widgets */
-       snd_soc_dapm_new_controls(dapm, mfld_widgets, ARRAY_SIZE(mfld_widgets));
-
-       /* Set up the map */
-       snd_soc_dapm_add_routes(dapm, mfld_map, ARRAY_SIZE(mfld_map));
+       mfld_codec = runtime->codec;
 
-       /* always connected */
-       snd_soc_dapm_enable_pin(dapm, "Headphones");
-       snd_soc_dapm_enable_pin(dapm, "Mic");
-
-       ret_val = snd_soc_add_codec_controls(codec, mfld_snd_controls,
-                               ARRAY_SIZE(mfld_snd_controls));
-       if (ret_val) {
-               pr_err("soc_add_controls failed %d", ret_val);
-               return ret_val;
-       }
        /* default is earpiece pin, userspace sets it explcitly */
        snd_soc_dapm_disable_pin(dapm, "Headphones");
        /* default is lineout NC, userspace sets it explcitly */
@@ -270,7 +254,7 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
        snd_soc_dapm_disable_pin(dapm, "LINEINR");
 
        /* Headset and button jack detection */
-       ret_val = snd_soc_jack_new(codec, "Intel(R) MID Audio Jack",
+       ret_val = snd_soc_jack_new(mfld_codec, "Intel(R) MID Audio Jack",
                        SND_JACK_HEADSET | SND_JACK_BTN_0 |
                        SND_JACK_BTN_1, &mfld_jack);
        if (ret_val) {
@@ -352,6 +336,13 @@ static struct snd_soc_card snd_soc_card_mfld = {
        .owner = THIS_MODULE,
        .dai_link = mfld_msic_dailink,
        .num_links = ARRAY_SIZE(mfld_msic_dailink),
+
+       .controls = mfld_snd_controls,
+       .num_controls = ARRAY_SIZE(mfld_snd_controls),
+       .dapm_widgets = mfld_widgets,
+       .num_dapm_widgets = ARRAY_SIZE(mfld_widgets),
+       .dapm_routes = mfld_map,
+       .num_dapm_routes = ARRAY_SIZE(mfld_map),
 };
 
 static irqreturn_t snd_mfld_jack_intr_handler(int irq, void *dev)
index 2dc3ecf34801da2e4cda44eb7de6ab8e014d8b64..49f8437665dea5d326833a4aff3ad506c6c02d56 100644 (file)
@@ -10,6 +10,7 @@ config SND_KIRKWOOD_SOC_ARMADA370_DB
        tristate "SoC Audio support for Armada 370 DB"
        depends on SND_KIRKWOOD_SOC && (ARCH_MVEBU || COMPILE_TEST) && I2C
        select SND_SOC_CS42L51
+       select SND_SOC_SPDIF
        help
          Say Y if you want to add support for SoC audio on
          the Armada 370 Development Board.
index 977639b3ffde7501ff722575b1bfd4c1850712dd..c443338492596e7c98b0842860013193cd4a0c0c 100644 (file)
@@ -67,6 +67,20 @@ static struct snd_soc_dai_link a370db_dai[] = {
        .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
        .ops = &a370db_ops,
 },
+{
+       .name = "S/PDIF out",
+       .stream_name = "spdif-out",
+       .cpu_dai_name = "spdif",
+       .codec_dai_name = "dit-hifi",
+       .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
+},
+{
+       .name = "S/PDIF in",
+       .stream_name = "spdif-in",
+       .cpu_dai_name = "spdif",
+       .codec_dai_name = "dir-hifi",
+       .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
+},
 };
 
 static struct snd_soc_card a370db = {
@@ -95,6 +109,20 @@ static int a370db_probe(struct platform_device *pdev)
                of_parse_phandle(pdev->dev.of_node,
                                 "marvell,audio-codec", 0);
 
+       a370db_dai[1].cpu_of_node = a370db_dai[0].cpu_of_node;
+       a370db_dai[1].platform_of_node = a370db_dai[0].cpu_of_node;
+
+       a370db_dai[1].codec_of_node =
+               of_parse_phandle(pdev->dev.of_node,
+                                "marvell,audio-codec", 1);
+
+       a370db_dai[2].cpu_of_node = a370db_dai[0].cpu_of_node;
+       a370db_dai[2].platform_of_node = a370db_dai[0].cpu_of_node;
+
+       a370db_dai[2].codec_of_node =
+               of_parse_phandle(pdev->dev.of_node,
+                                "marvell,audio-codec", 2);
+
        return devm_snd_soc_register_card(card->dev, card);
 }
 
index 8aa08699686676f86a5732a25e3af467c874378d..260efc8466fc352cf70d08663799c7fde0758a2e 100644 (file)
 static int hw_write(struct snd_soc_codec *codec, unsigned int reg,
                    unsigned int value)
 {
-       int ret;
-
-       if (!snd_soc_codec_volatile_register(codec, reg) &&
-           reg < codec->driver->reg_cache_size &&
-           !codec->cache_bypass) {
-               ret = snd_soc_cache_write(codec, reg, value);
-               if (ret < 0)
-                       return -1;
-       }
-
-       if (codec->cache_only) {
-               codec->cache_sync = 1;
-               return 0;
-       }
-
        return regmap_write(codec->control_data, reg, value);
 }
 
@@ -46,23 +31,11 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg)
        int ret;
        unsigned int val;
 
-       if (reg >= codec->driver->reg_cache_size ||
-           snd_soc_codec_volatile_register(codec, reg) ||
-           codec->cache_bypass) {
-               if (codec->cache_only)
-                       return -1;
-
-               ret = regmap_read(codec->control_data, reg, &val);
-               if (ret == 0)
-                       return val;
-               else
-                       return -1;
-       }
-
-       ret = snd_soc_cache_read(codec, reg, &val);
-       if (ret < 0)
+       ret = regmap_read(codec->control_data, reg, &val);
+       if (ret == 0)
+               return val;
+       else
                return -1;
-       return val;
 }
 
 /**