ALSA: asoc: core - refactored DAPM pin control API.
authorLiam Girdwood <lg@opensource.wolfsonmicro.com>
Mon, 7 Jul 2008 12:35:17 +0000 (13:35 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 10 Jul 2008 07:32:30 +0000 (09:32 +0200)
Refactored snd_soc_dapm_set_endpoint() to snd_soc_dapm_enable_pin() and
snd_soc_dapm_disable_pin().

Renamed snd_soc_dapm_sync_endpoints() to snd_soc_dapm_sync().
Renamed snd_soc_dapm_get_endpoint_status() to
snd_soc_dapm_get_pin_status().

Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
12 files changed:
include/sound/soc-dapm.h
sound/soc/at91/eti_b1_wm8731.c
sound/soc/codecs/tlv320aic3x.c
sound/soc/davinci/davinci-evm.c
sound/soc/omap/n810.c
sound/soc/pxa/corgi.c
sound/soc/pxa/poodle.c
sound/soc/pxa/spitz.c
sound/soc/pxa/tosa.c
sound/soc/s3c24xx/neo1973_wm8753.c
sound/soc/sh/sh7760-ac97.c
sound/soc/soc-dapm.c

index b2849538cbfe33b7983e62e52ba45547d018badb..3030fdc6981d05b804ccb5e31d5d7d3fafd7565e 100644 (file)
@@ -234,16 +234,11 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
 /* dapm sys fs - used by the core */
 int snd_soc_dapm_sys_add(struct device *dev);
 
-/* event handler for register modifier widget - used by the soc-dapm */
-int dapm_reg_event(struct snd_soc_dapm_widget *w,
-                  struct snd_kcontrol *kcontrol, int event);
-
-/* dapm audio endpoint control */
-int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
-       char *pin, int status);
-int snd_soc_dapm_get_endpoint_status(struct snd_soc_codec *codec,
-       char *pin);
-int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec);
+/* dapm audio pin control and status */
+int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, char *pin);
+int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, char *pin);
+int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, char *pin);
+int snd_soc_dapm_sync(struct snd_soc_codec *codec);
 
 /* dapm widget types */
 enum snd_soc_dapm_type {
index 4a383a4a0ff127381eb97ee3969b330a4e46e4f2..ad971e7061fe21cfad9fbb2211d95d7c74cd9a6c 100644 (file)
@@ -216,14 +216,14 @@ static int eti_b1_wm8731_init(struct snd_soc_codec *codec)
        snd_soc_dapm_add_route(codec, intercon, ARRAY_SIZE(intercon));
 
        /* not connected */
-       snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
-       snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
+       snd_soc_dapm_disable_pin(codec, "RLINEIN");
+       snd_soc_dapm_disable_pin(codec, "LLINEIN");
 
        /* always connected */
-       snd_soc_dapm_set_endpoint(codec, "Int Mic", 1);
-       snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1);
+       snd_soc_dapm_enable_pin(codec, "Int Mic");
+       snd_soc_dapm_enable_pin(codec, "Ext Spk");
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 
        return 0;
 }
index d13830623db1ff5f95a2c42f9ec2df4eeaed49ce..954d39b7c040909d611e0ab6f8ae0eba6d2bf6bf 100644 (file)
@@ -29,7 +29,7 @@
  *  ---------------------------------------
  *
  *  Hence the machine layer should disable unsupported inputs/outputs by
- *  snd_soc_dapm_set_endpoint(codec, "MONO_LOUT", 0), etc.
+ *  snd_soc_dapm_disable_pin(codec, "MONO_LOUT"), etc.
  */
 
 #include <linux/module.h>
@@ -206,7 +206,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,
                }
 
                if (found)
-                       snd_soc_dapm_sync_endpoints(widget->codec);
+                       snd_soc_dapm_sync(widget->codec);
        }
 
        ret = snd_soc_update_bits(widget->codec, reg, val_mask, val);
index 4c70a0ed339727b4c7f78f5fca5efc8885280c2c..091eae3a9631bc093ae9523ac7a575a4afebbab3 100644 (file)
@@ -103,17 +103,17 @@ static int evm_aic3x_init(struct snd_soc_codec *codec)
        snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
 
        /* not connected */
-       snd_soc_dapm_set_endpoint(codec, "MONO_LOUT", 0);
-       snd_soc_dapm_set_endpoint(codec, "HPLCOM", 0);
-       snd_soc_dapm_set_endpoint(codec, "HPRCOM", 0);
+       snd_soc_dapm_disable_pin(codec, "MONO_LOUT");
+       snd_soc_dapm_disable_pin(codec, "HPLCOM");
+       snd_soc_dapm_disable_pin(codec, "HPRCOM");
 
        /* always connected */
-       snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1);
-       snd_soc_dapm_set_endpoint(codec, "Line Out", 1);
-       snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1);
-       snd_soc_dapm_set_endpoint(codec, "Line In", 1);
+       snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+       snd_soc_dapm_enable_pin(codec, "Line Out");
+       snd_soc_dapm_enable_pin(codec, "Mic Jack");
+       snd_soc_dapm_enable_pin(codec, "Line In");
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 
        return 0;
 }
index 767b39f339a8362be9ab6aee60e8e75598a56a45..74f4599b4d7e03a91678b399775469aab3c15e55 100644 (file)
@@ -50,11 +50,22 @@ static int n810_dmic_func;
 
 static void n810_ext_control(struct snd_soc_codec *codec)
 {
-       snd_soc_dapm_set_endpoint(codec, "Ext Spk", n810_spk_func);
-       snd_soc_dapm_set_endpoint(codec, "Headphone Jack", n810_jack_func);
-       snd_soc_dapm_set_endpoint(codec, "DMic", n810_dmic_func);
+       if (n810_spk_func)
+               snd_soc_dapm_enable_pin(codec, "Ext Spk");
+       else
+               snd_soc_dapm_disable_pin(codec, "Ext Spk");
+
+       if (n810_jack_func)
+               snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+       else
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+
+       if (n810_dmic_func)
+               snd_soc_dapm_enable_pin(codec, "DMic");
+       else
+               snd_soc_dapm_disable_pin(codec, "DMic);
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 }
 
 static int n810_startup(struct snd_pcm_substream *substream)
@@ -236,9 +247,9 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
        int i, err;
 
        /* Not connected */
-       snd_soc_dapm_set_endpoint(codec, "MONO_LOUT", 0);
-       snd_soc_dapm_set_endpoint(codec, "HPLCOM", 0);
-       snd_soc_dapm_set_endpoint(codec, "HPRCOM", 0);
+       snd_soc_dapm_disable_pin(codec, "MONO_LOUT");
+       snd_soc_dapm_disable_pin(codec, "HPLCOM");
+       snd_soc_dapm_disable_pin(codec, "HPRCOM");
 
        /* Add N810 specific controls */
        for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) {
@@ -255,7 +266,7 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
        /* Set up N810 specific audio path audio_map */
        snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 
        return 0;
 }
index edeea63e80e83ff5f7e645d885ffff9bc615fe48..db18ef68b691726c6caf8b3d310f0a66f949e984 100644 (file)
@@ -50,47 +50,51 @@ static int corgi_spk_func;
 
 static void corgi_ext_control(struct snd_soc_codec *codec)
 {
-       int spk = 0, mic = 0, line = 0, hp = 0, hs = 0;
-
        /* set up jack connection */
        switch (corgi_jack_func) {
        case CORGI_HP:
-               hp = 1;
                /* set = unmute headphone */
                set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
                set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               snd_soc_dapm_disable_pin(codec, "Mic Jack");
+               snd_soc_dapm_disable_pin(codec, "Line Jack");
+               snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
                break;
        case CORGI_MIC:
-               mic = 1;
                /* reset = mute headphone */
                reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
                reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               snd_soc_dapm_enable_pin(codec, "Mic Jack");
+               snd_soc_dapm_disable_pin(codec, "Line Jack");
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
                break;
        case CORGI_LINE:
-               line = 1;
                reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
                reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               snd_soc_dapm_disable_pin(codec, "Mic Jack");
+               snd_soc_dapm_enable_pin(codec, "Line Jack");
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
                break;
        case CORGI_HEADSET:
-               hs = 1;
-               mic = 1;
                reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_L);
                set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MUTE_R);
+               snd_soc_dapm_enable_pin(codec, "Mic Jack");
+               snd_soc_dapm_disable_pin(codec, "Line Jack");
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_enable_pin(codec, "Headset Jack");
                break;
        }
 
        if (corgi_spk_func == CORGI_SPK_ON)
-               spk = 1;
-
-       /* set the enpoints to their new connetion states */
-       snd_soc_dapm_set_endpoint(codec, "Ext Spk", spk);
-       snd_soc_dapm_set_endpoint(codec, "Mic Jack", mic);
-       snd_soc_dapm_set_endpoint(codec, "Line Jack", line);
-       snd_soc_dapm_set_endpoint(codec, "Headphone Jack", hp);
-       snd_soc_dapm_set_endpoint(codec, "Headset Jack", hs);
+               snd_soc_dapm_enable_pin(codec, "Ext Spk");
+       else
+               snd_soc_dapm_disable_pin(codec, "Ext Spk");
 
        /* signal a DAPM event */
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 }
 
 static int corgi_startup(struct snd_pcm_substream *substream)
@@ -285,8 +289,8 @@ static int corgi_wm8731_init(struct snd_soc_codec *codec)
 {
        int i, err;
 
-       snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
-       snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
+       snd_soc_dapm_disable_pin(codec, "LLINEIN");
+       snd_soc_dapm_disable_pin(codec, "RLINEIN");
 
        /* Add corgi specific controls */
        for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) {
@@ -303,7 +307,7 @@ static int corgi_wm8731_init(struct snd_soc_codec *codec)
        /* Set up corgi specific audio path audio_map */
        snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
        return 0;
 }
 
index 810f1fe158ab54337ed26740e9e2c73cac0acd89..36cbf69f5f82b647f727644a141758d5ba1be858 100644 (file)
@@ -48,8 +48,6 @@ static int poodle_spk_func;
 
 static void poodle_ext_control(struct snd_soc_codec *codec)
 {
-       int spk = 0;
-
        /* set up jack connection */
        if (poodle_jack_func == POODLE_HP) {
                /* set = unmute headphone */
@@ -57,23 +55,23 @@ static void poodle_ext_control(struct snd_soc_codec *codec)
                        POODLE_LOCOMO_GPIO_MUTE_L, 1);
                locomo_gpio_write(&poodle_locomo_device.dev,
                        POODLE_LOCOMO_GPIO_MUTE_R, 1);
-               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1);
+               snd_soc_dapm_enable_pin(codec, "Headphone Jack");
        } else {
                locomo_gpio_write(&poodle_locomo_device.dev,
                        POODLE_LOCOMO_GPIO_MUTE_L, 0);
                locomo_gpio_write(&poodle_locomo_device.dev,
                        POODLE_LOCOMO_GPIO_MUTE_R, 0);
-               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
        }
 
-       if (poodle_spk_func == POODLE_SPK_ON)
-               spk = 1;
-
        /* set the enpoints to their new connetion states */
-       snd_soc_dapm_set_endpoint(codec, "Ext Spk", spk);
+       if (poodle_spk_func == POODLE_SPK_ON)
+               snd_soc_dapm_enable_pin(codec, "Ext Spk");
+       else
+               snd_soc_dapm_disable_pin(codec, "Ext Spk");
 
        /* signal a DAPM event */
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 }
 
 static int poodle_startup(struct snd_pcm_substream *substream)
@@ -248,9 +246,9 @@ static int poodle_wm8731_init(struct snd_soc_codec *codec)
 {
        int i, err;
 
-       snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0);
-       snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0);
-       snd_soc_dapm_set_endpoint(codec, "MICIN", 1);
+       snd_soc_dapm_disable_pin(codec, "LLINEIN");
+       snd_soc_dapm_disable_pin(codec, "RLINEIN");
+       snd_soc_dapm_enable_pin(codec, "MICIN");
 
        /* Add poodle specific controls */
        for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) {
@@ -267,7 +265,7 @@ static int poodle_wm8731_init(struct snd_soc_codec *codec)
        /* Set up poodle specific audio path audio_map */
        snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
        return 0;
 }
 
index 092b5c776b404afc451a7d1a44fca7ebd3d9c368..ec18163fddddd63e38af9475636a2979492cc980 100644 (file)
@@ -51,60 +51,60 @@ static int spitz_spk_func;
 static void spitz_ext_control(struct snd_soc_codec *codec)
 {
        if (spitz_spk_func == SPITZ_SPK_ON)
-               snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1);
+               snd_soc_dapm_enable_pin(codec, "Ext Spk");
        else
-               snd_soc_dapm_set_endpoint(codec, "Ext Spk", 0);
+               snd_soc_dapm_disable_pin(codec, "Ext Spk");
 
        /* set up jack connection */
        switch (spitz_jack_func) {
        case SPITZ_HP:
                /* enable and unmute hp jack, disable mic bias */
-               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Line Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 1);
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
+               snd_soc_dapm_disable_pin(codec, "Mic Jack");
+               snd_soc_dapm_disable_pin(codec, "Line Jack");
+               snd_soc_dapm_enable_pin(codec, "Headphone Jack");
                set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
                set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
                break;
        case SPITZ_MIC:
                /* enable mic jack and bias, mute hp */
-               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Line Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1);
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
+               snd_soc_dapm_disable_pin(codec, "Line Jack");
+               snd_soc_dapm_enable_pin(codec, "Mic Jack");
                reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
                reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
                break;
        case SPITZ_LINE:
                /* enable line jack, disable mic bias and mute hp */
-               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Line Jack", 1);
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
+               snd_soc_dapm_disable_pin(codec, "Mic Jack");
+               snd_soc_dapm_enable_pin(codec, "Line Jack");
                reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
                reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
                break;
        case SPITZ_HEADSET:
                /* enable and unmute headset jack enable mic bias, mute L hp */
-               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 1);
-               snd_soc_dapm_set_endpoint(codec, "Line Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 1);
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_enable_pin(codec, "Mic Jack");
+               snd_soc_dapm_disable_pin(codec, "Line Jack");
+               snd_soc_dapm_enable_pin(codec, "Headset Jack");
                reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
                set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
                break;
        case SPITZ_HP_OFF:
 
                /* jack removed, everything off */
-               snd_soc_dapm_set_endpoint(codec, "Headphone Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Mic Jack", 0);
-               snd_soc_dapm_set_endpoint(codec, "Line Jack", 0);
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
+               snd_soc_dapm_disable_pin(codec, "Mic Jack");
+               snd_soc_dapm_disable_pin(codec, "Line Jack");
                reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_L);
                reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_MUTE_R);
                break;
        }
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 }
 
 static int spitz_startup(struct snd_pcm_substream *substream)
@@ -291,13 +291,13 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec)
        int i, err;
 
        /* NC codec pins */
-       snd_soc_dapm_set_endpoint(codec, "RINPUT1", 0);
-       snd_soc_dapm_set_endpoint(codec, "LINPUT2", 0);
-       snd_soc_dapm_set_endpoint(codec, "RINPUT2", 0);
-       snd_soc_dapm_set_endpoint(codec, "LINPUT3", 0);
-       snd_soc_dapm_set_endpoint(codec, "RINPUT3", 0);
-       snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
-       snd_soc_dapm_set_endpoint(codec, "MONO", 0);
+       snd_soc_dapm_disable_pin(codec, "RINPUT1");
+       snd_soc_dapm_disable_pin(codec, "LINPUT2");
+       snd_soc_dapm_disable_pin(codec, "RINPUT2");
+       snd_soc_dapm_disable_pin(codec, "LINPUT3");
+       snd_soc_dapm_disable_pin(codec, "RINPUT3");
+       snd_soc_dapm_disable_pin(codec, "OUT3");
+       snd_soc_dapm_disable_pin(codec, "MONO");
 
        /* Add spitz specific controls */
        for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) {
@@ -314,7 +314,7 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec)
        /* Set up spitz specific audio paths */
        snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
        return 0;
 }
 
index 465ff0f458ef70300d6bd79e21757e5299e989e3..dba7689c50802d1bde3f95e5ddb10fe114c9078d 100644 (file)
@@ -52,29 +52,31 @@ static int tosa_spk_func;
 
 static void tosa_ext_control(struct snd_soc_codec *codec)
 {
-       int spk = 0, mic_int = 0, hp = 0, hs = 0;
-
        /* set up jack connection */
        switch (tosa_jack_func) {
        case TOSA_HP:
-               hp = 1;
+               snd_soc_dapm_disable_pin(codec, "Mic (Internal)");
+               snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
                break;
        case TOSA_MIC_INT:
-               mic_int = 1;
+               snd_soc_dapm_enable_pin(codec, "Mic (Internal)");
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_disable_pin(codec, "Headset Jack");
                break;
        case TOSA_HEADSET:
-               hs = 1;
+               snd_soc_dapm_disable_pin(codec, "Mic (Internal)");
+               snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+               snd_soc_dapm_enable_pin(codec, "Headset Jack");
                break;
        }
 
        if (tosa_spk_func == TOSA_SPK_ON)
-               spk = 1;
+               snd_soc_dapm_enable_pin(codec, "Speaker");
+       else
+               snd_soc_dapm_disable_pin(codec, "Speaker");
 
-       snd_soc_dapm_set_endpoint(codec, "Speaker", spk);
-       snd_soc_dapm_set_endpoint(codec, "Mic (Internal)", mic_int);
-       snd_soc_dapm_set_endpoint(codec, "Headphone Jack", hp);
-       snd_soc_dapm_set_endpoint(codec, "Headset Jack", hs);
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 }
 
 static int tosa_startup(struct snd_pcm_substream *substream)
@@ -191,8 +193,8 @@ static int tosa_ac97_init(struct snd_soc_codec *codec)
 {
        int i, err;
 
-       snd_soc_dapm_set_endpoint(codec, "OUT3", 0);
-       snd_soc_dapm_set_endpoint(codec, "MONOOUT", 0);
+       snd_soc_dapm_disable_pin(codec, "OUT3");
+       snd_soc_dapm_disable_pin(codec, "MONOOUT");
 
        /* add tosa specific controls */
        for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) {
@@ -209,7 +211,7 @@ static int tosa_ac97_init(struct snd_soc_codec *codec)
        /* set up tosa specific audio path audio_map */
        snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
        return 0;
 }
 
index 34851238dea0b29d0003f321408871a2b229b053..f053e85ff608d56da2b12b0e6d54e7b280e0213d 100644 (file)
@@ -250,77 +250,77 @@ static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario)
 
        switch (neo1973_scenario) {
        case NEO_AUDIO_OFF:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  0);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     0);
+               snd_soc_dapm_disable_pin(codec, "Audio Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line In");
+               snd_soc_dapm_disable_pin(codec, "Headset Mic");
+               snd_soc_dapm_disable_pin(codec, "Call Mic");
                break;
        case NEO_GSM_CALL_AUDIO_HANDSET:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    1);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 1);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  1);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  0);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     1);
+               snd_soc_dapm_enable_pin(codec, "Audio Out");
+               snd_soc_dapm_enable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_enable_pin(codec, "GSM Line In");
+               snd_soc_dapm_disable_pin(codec, "Headset Mic");
+               snd_soc_dapm_enable_pin(codec, "Call Mic");
                break;
        case NEO_GSM_CALL_AUDIO_HEADSET:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    1);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 1);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  1);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  1);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     0);
+               snd_soc_dapm_enable_pin(codec, "Audio Out");
+               snd_soc_dapm_enable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_enable_pin(codec, "GSM Line In");
+               snd_soc_dapm_enable_pin(codec, "Headset Mic");
+               snd_soc_dapm_disable_pin(codec, "Call Mic");
                break;
        case NEO_GSM_CALL_AUDIO_BLUETOOTH:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 1);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  1);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  0);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     0);
+               snd_soc_dapm_disable_pin(codec, "Audio Out");
+               snd_soc_dapm_enable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_enable_pin(codec, "GSM Line In");
+               snd_soc_dapm_disable_pin(codec, "Headset Mic");
+               snd_soc_dapm_disable_pin(codec, "Call Mic");
                break;
        case NEO_STEREO_TO_SPEAKERS:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    1);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  0);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     0);
+               snd_soc_dapm_enable_pin(codec, "Audio Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line In");
+               snd_soc_dapm_disable_pin(codec, "Headset Mic");
+               snd_soc_dapm_disable_pin(codec, "Call Mic");
                break;
        case NEO_STEREO_TO_HEADPHONES:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    1);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  0);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     0);
+               snd_soc_dapm_enable_pin(codec, "Audio Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line In");
+               snd_soc_dapm_disable_pin(codec, "Headset Mic");
+               snd_soc_dapm_disable_pin(codec, "Call Mic");
                break;
        case NEO_CAPTURE_HANDSET:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  0);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     1);
+               snd_soc_dapm_disable_pin(codec, "Audio Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line In");
+               snd_soc_dapm_disable_pin(codec, "Headset Mic");
+               snd_soc_dapm_enable_pin(codec, "Call Mic");
                break;
        case NEO_CAPTURE_HEADSET:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  1);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     0);
+               snd_soc_dapm_disable_pin(codec, "Audio Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line In");
+               snd_soc_dapm_enable_pin(codec, "Headset Mic");
+               snd_soc_dapm_disable_pin(codec, "Call Mic");
                break;
        case NEO_CAPTURE_BLUETOOTH:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  0);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     0);
+               snd_soc_dapm_disable_pin(codec, "Audio Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line In");
+               snd_soc_dapm_disable_pin(codec, "Headset Mic");
+               snd_soc_dapm_disable_pin(codec, "Call Mic");
                break;
        default:
-               snd_soc_dapm_set_endpoint(codec, "Audio Out",    0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0);
-               snd_soc_dapm_set_endpoint(codec, "GSM Line In",  0);
-               snd_soc_dapm_set_endpoint(codec, "Headset Mic",  0);
-               snd_soc_dapm_set_endpoint(codec, "Call Mic",     0);
+               snd_soc_dapm_disable_pin(codec, "Audio Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line Out");
+               snd_soc_dapm_disable_pin(codec, "GSM Line In");
+               snd_soc_dapm_disable_pin(codec, "Headset Mic");
+               snd_soc_dapm_disable_pin(codec, "Call Mic");
        }
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
 
        return 0;
 }
@@ -511,12 +511,12 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec)
        DBG("Entered %s\n", __func__);
 
        /* set up NC codec pins */
-       snd_soc_dapm_set_endpoint(codec, "LOUT2", 0);
-       snd_soc_dapm_set_endpoint(codec, "ROUT2", 0);
-       snd_soc_dapm_set_endpoint(codec, "OUT3",  0);
-       snd_soc_dapm_set_endpoint(codec, "OUT4",  0);
-       snd_soc_dapm_set_endpoint(codec, "LINE1", 0);
-       snd_soc_dapm_set_endpoint(codec, "LINE2", 0);
+       snd_soc_dapm_disable_pin(codec, "LOUT2");
+       snd_soc_dapm_disable_pin(codec, "ROUT2");
+       snd_soc_dapm_disable_pin(codec, "OUT3");
+       snd_soc_dapm_disable_pin(codec, "OUT4");
+       snd_soc_dapm_disable_pin(codec, "LINE1");
+       snd_soc_dapm_disable_pin(codec, "LINE2");
 
 
        /* set endpoints to default mode */
@@ -539,7 +539,7 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec)
        err = snd_soc_dapm_add_routes(codec, dapm_routes,
                                      ARRAY_SIZE(dapm_routes));
 
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
        return 0;
 }
 
index 2f91de84c5c762a2896c14230140c90b216d39a9..846d1b3a63055a484adebd571e9466510f85666a 100644 (file)
@@ -25,7 +25,7 @@ extern struct snd_soc_platform sh7760_soc_platform;
 
 static int machine_init(struct snd_soc_codec *codec)
 {
-       snd_soc_dapm_sync_endpoints(codec);
+       snd_soc_dapm_sync(codec);
        return 0;
 }
 
index 91cbbefefb0a09af9a1226244f7937da04efbcea..94296b5dc58f05232d13d572536e7f960a1567c2 100644 (file)
@@ -880,8 +880,25 @@ static void dapm_free_widgets(struct snd_soc_codec *codec)
        }
 }
 
+static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec,
+       char *pin, int status)
+{
+       struct snd_soc_dapm_widget *w;
+
+       list_for_each_entry(w, &codec->dapm_widgets, list) {
+               if (!strcmp(w->name, pin)) {
+                       dbg("dapm: %s: pin %s\n", codec->name, pin);
+                       w->connected = status;
+                       return 0;
+               }
+       }
+
+       dbg("dapm: %s: configuring unknown pin %s\n", codec->name, pin);
+       return -EINVAL;
+}
+
 /**
- * snd_soc_dapm_sync_endpoints - scan and power dapm paths
+ * snd_soc_dapm_sync - scan and power dapm paths
  * @codec: audio codec
  *
  * Walks all dapm audio paths and powers widgets according to their
@@ -889,11 +906,11 @@ static void dapm_free_widgets(struct snd_soc_codec *codec)
  *
  * Returns 0 for success.
  */
-int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec)
+int snd_soc_dapm_sync(struct snd_soc_codec *codec)
 {
        return dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
 }
-EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_endpoints);
+EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
 
 static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
        const char *sink, const char *control, const char *source)
@@ -1441,53 +1458,57 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
 }
 
 /**
- * snd_soc_dapm_set_endpoint - set audio endpoint status
- * @codec: audio codec
- * @endpoint: audio signal endpoint (or start point)
- * @status: point status
- *
- * Set audio endpoint status - connected or disconnected.
+ * snd_soc_dapm_enable_pin - enable pin.
+ * @snd_soc_codec: SoC codec
+ * @pin: pin name
  *
- * Returns 0 for success else error.
+ * Enables input/output pin and it's parents or children widgets iff there is
+ * a valid audio route and active audio stream.
+ * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
+ * do any widget power switching.
  */
-int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
-       char *endpoint, int status)
+int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, char *pin)
 {
-       struct snd_soc_dapm_widget *w;
-
-       list_for_each_entry(w, &codec->dapm_widgets, list) {
-               if (!strcmp(w->name, endpoint)) {
-                       w->connected = status;
-                       return 0;
-               }
-       }
+       return snd_soc_dapm_set_pin(codec, pin, 1);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
 
-       return -ENODEV;
+/**
+ * snd_soc_dapm_disable_pin - disable pin.
+ * @codec: SoC codec
+ * @pin: pin name
+ *
+ * Disables input/output pin and it's parents or children widgets.
+ * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
+ * do any widget power switching.
+ */
+int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, char *pin)
+{
+       return snd_soc_dapm_set_pin(codec, pin, 0);
 }
-EXPORT_SYMBOL_GPL(snd_soc_dapm_set_endpoint);
+EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
 
 /**
- * snd_soc_dapm_get_endpoint_status - get audio endpoint status
+ * snd_soc_dapm_get_pin_status - get audio pin status
  * @codec: audio codec
- * @endpoint: audio signal endpoint (or start point)
+ * @pin: audio signal pin endpoint (or start point)
  *
- * Get audio endpoint status - connected or disconnected.
+ * Get audio pin status - connected or disconnected.
  *
- * Returns status
+ * Returns 1 for connected otherwise 0.
  */
-int snd_soc_dapm_get_endpoint_status(struct snd_soc_codec *codec,
-       char *endpoint)
+int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, char *pin)
 {
        struct snd_soc_dapm_widget *w;
 
        list_for_each_entry(w, &codec->dapm_widgets, list) {
-               if (!strcmp(w->name, endpoint))
+               if (!strcmp(w->name, pin))
                        return w->connected;
        }
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(snd_soc_dapm_get_endpoint_status);
+EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
 
 /**
  * snd_soc_dapm_free - free dapm resources