ASoC: odroidx2_max98090: Support audio routing specified in DT
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Thu, 12 Jun 2014 17:29:44 +0000 (19:29 +0200)
committerChanho Park <chanho61.park@samsung.com>
Thu, 7 Aug 2014 06:16:09 +0000 (15:16 +0900)
This patch adds support for specifying the audio routing in device
tree.

Change-Id: Iebbd8d4dff79afba888f4e7620cbf1f2debc81de
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Documentation/devicetree/bindings/sound/samsung,odroidx2-max98090.txt
sound/soc/samsung/odroidx2_max98090.c

index 7e1d0a7..e4bb694 100644 (file)
@@ -6,6 +6,19 @@ Required properties:
  - samsung,model : the user-visible name of this sound complex.
  - samsung,i2s-controller : the phandle of the I2S controller
  - samsung,audio-codec : the phandle of the MAX98090 audio codec
+ - samsung,audio-routing : a list of the connections between audio
+   components;  each entry is a pair of strings, the first being the
+   connection's sink, the second being the connection's source;
+   valid names for sources and sinks are the MAX98090's pins (as
+   documented in its binding), and the jacks on the board;
+   For Odroid X2:
+     * Headphone Jack
+     * Mic Jack
+     * DMIC
+
+   For Odroid U3:
+     * Headphone Jack
+     * Speakers
 
 Example:
 
index 6a83f60..e11ff25 100644 (file)
 #include <sound/pcm_params.h>
 #include "i2s.h"
 
+struct odroidx2_drv_data {
+       const struct snd_soc_dapm_widget *dapm_widgets;
+       unsigned int num_dapm_widgets;
+};
+
 /* Config I2S CDCLK output 19.2MHZ clock to Max98090 */
 #define MAX98090_MCLK 19200000
 
@@ -49,6 +54,17 @@ static struct snd_soc_ops odroidx2_ops = {
        .hw_params      = odroidx2_hw_params,
 };
 
+static const struct snd_soc_dapm_widget odroidx2_dapm_widgets[] = {
+       SND_SOC_DAPM_HP("Headphone Jack", NULL),
+       SND_SOC_DAPM_MIC("Mic Jack", NULL),
+       SND_SOC_DAPM_MIC("DMIC", NULL),
+};
+
+static const struct snd_soc_dapm_widget odroidu3_dapm_widgets[] = {
+       SND_SOC_DAPM_HP("Headphone Jack", NULL),
+       SND_SOC_DAPM_SPK("Speakers", NULL),
+};
+
 static struct snd_soc_dai_link odroidx2_dai[] = {
        {
                .name           = "MAX98090",
@@ -73,20 +89,55 @@ static struct snd_soc_card odroidx2 = {
        .owner          = THIS_MODULE,
        .dai_link       = odroidx2_dai,
        .num_links      = ARRAY_SIZE(odroidx2_dai),
+       .fully_routed   = true,
+};
+
+struct odroidx2_drv_data odroidx2_drvdata = {
+       .dapm_widgets           = odroidx2_dapm_widgets,
+       .num_dapm_widgets       = ARRAY_SIZE(odroidx2_dapm_widgets),
+};
+
+struct odroidx2_drv_data odroidu3_drvdata = {
+       .dapm_widgets           = odroidu3_dapm_widgets,
+       .num_dapm_widgets       = ARRAY_SIZE(odroidu3_dapm_widgets),
+};
+
+static const struct of_device_id odroidx2_audio_of_match[] = {
+       {
+               .compatible     = "samsung,odroidx2-audio",
+               .data           = &odroidx2_drvdata,
+       }, {
+               .compatible     = "samsung,odroidu3-audio",
+               .data           = &odroidu3_drvdata,
+       },
+       { },
 };
+MODULE_DEVICE_TABLE(of, odroid_audio_of_match);
 
 static int odroidx2_audio_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct snd_soc_card *card = &odroidx2;
+       struct odroidx2_drv_data *dd;
+       const struct of_device_id *of_id;
        int ret;
 
        card->dev = &pdev->dev;
 
+       of_id = of_match_node(odroidx2_audio_of_match, np);
+       dd = (struct odroidx2_drv_data *)of_id->data;
+
+       card->dapm_widgets = dd->dapm_widgets;
+       card->num_dapm_widgets = dd->num_dapm_widgets;
+
        ret = snd_soc_of_parse_card_name(card, "samsung,model");
        if (ret < 0)
                return ret;
 
+       ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing");
+       if (ret < 0)
+               return ret;
+
        odroidx2_dai[0].codec_of_node = of_parse_phandle(np,
                                                "samsung,audio-codec", 0);
        if (!odroidx2_dai[0].codec_of_node) {
@@ -136,13 +187,6 @@ static int odroidx2_audio_remove(struct platform_device *pdev)
        return 0;
 }
 
-static const struct of_device_id odroidx2_audio_of_match[] = {
-       { .compatible = "samsung,odroidx2-audio", },
-       { .compatible = "samsung,odroidu3-audio", },
-       { },
-};
-MODULE_DEVICE_TABLE(of, odroid_audio_of_match);
-
 static struct platform_driver odroidx2_audio_driver = {
        .driver = {
                .name           = "odroidx2-audio",