include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / sound / soc / soc-dapm.c
index de22c2f..7c28f40 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/jiffies.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc-dapm.h>
 #include <sound/initval.h>
 
-/* debug */
-#ifdef DEBUG
-#define dump_dapm(codec, action) dbg_dump_dapm(codec, action)
-#else
-#define dump_dapm(codec, action)
-#endif
-
 /* dapm power sequences - make this per codec in the future */
 static int dapm_up_seq[] = {
        [snd_soc_dapm_pre] = 0,
@@ -1019,13 +1013,28 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
                        sys_power = 0;
                        break;
                case SND_SOC_DAPM_STREAM_NOP:
-                       sys_power = codec->bias_level != SND_SOC_BIAS_STANDBY;
+                       switch (codec->bias_level) {
+                               case SND_SOC_BIAS_STANDBY:
+                               case SND_SOC_BIAS_OFF:
+                                       sys_power = 0;
+                                       break;
+                               default:
+                                       sys_power = 1;
+                                       break;
+                       }
                        break;
                default:
                        break;
                }
        }
 
+       if (sys_power && codec->bias_level == SND_SOC_BIAS_OFF) {
+               ret = snd_soc_dapm_set_bias_level(socdev,
+                                                 SND_SOC_BIAS_STANDBY);
+               if (ret != 0)
+                       pr_err("Failed to turn on bias: %d\n", ret);
+       }
+
        /* If we're changing to all on or all off then prepare */
        if ((sys_power && codec->bias_level == SND_SOC_BIAS_STANDBY) ||
            (!sys_power && codec->bias_level == SND_SOC_BIAS_ON)) {
@@ -1049,6 +1058,14 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
                        pr_err("Failed to apply standby bias: %d\n", ret);
        }
 
+       /* If we're in standby and can support bias off then do that */
+       if (codec->bias_level == SND_SOC_BIAS_STANDBY &&
+           codec->idle_bias_off) {
+               ret = snd_soc_dapm_set_bias_level(socdev, SND_SOC_BIAS_OFF);
+               if (ret != 0)
+                       pr_err("Failed to turn off bias: %d\n", ret);
+       }
+
        /* If we just powered up then move to active bias */
        if (codec->bias_level == SND_SOC_BIAS_PREPARE && sys_power) {
                ret = snd_soc_dapm_set_bias_level(socdev,
@@ -1063,66 +1080,6 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
        return 0;
 }
 
-#ifdef DEBUG
-static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action)
-{
-       struct snd_soc_dapm_widget *w;
-       struct snd_soc_dapm_path *p = NULL;
-       int in, out;
-
-       printk("DAPM %s %s\n", codec->name, action);
-
-       list_for_each_entry(w, &codec->dapm_widgets, list) {
-
-               /* only display widgets that effect routing */
-               switch (w->id) {
-               case snd_soc_dapm_pre:
-               case snd_soc_dapm_post:
-               case snd_soc_dapm_vmid:
-                       continue;
-               case snd_soc_dapm_mux:
-               case snd_soc_dapm_value_mux:
-               case snd_soc_dapm_output:
-               case snd_soc_dapm_input:
-               case snd_soc_dapm_switch:
-               case snd_soc_dapm_hp:
-               case snd_soc_dapm_mic:
-               case snd_soc_dapm_spk:
-               case snd_soc_dapm_line:
-               case snd_soc_dapm_micbias:
-               case snd_soc_dapm_dac:
-               case snd_soc_dapm_adc:
-               case snd_soc_dapm_pga:
-               case snd_soc_dapm_mixer:
-               case snd_soc_dapm_mixer_named_ctl:
-               case snd_soc_dapm_supply:
-               case snd_soc_dapm_aif_in:
-               case snd_soc_dapm_aif_out:
-                       if (w->name) {
-                               in = is_connected_input_ep(w);
-                               dapm_clear_walk(w->codec);
-                               out = is_connected_output_ep(w);
-                               dapm_clear_walk(w->codec);
-                               printk("%s: %s  in %d out %d\n", w->name,
-                                       w->power ? "On":"Off",in, out);
-
-                               list_for_each_entry(p, &w->sources, list_sink) {
-                                       if (p->connect)
-                                               printk(" in  %s %s\n", p->name ? p->name : "static",
-                                                       p->source->name);
-                               }
-                               list_for_each_entry(p, &w->sinks, list_source) {
-                                       if (p->connect)
-                                               printk(" out %s %s\n", p->name ? p->name : "static",
-                                                       p->sink->name);
-                               }
-                       }
-               break;
-               }
-       }
-}
-#endif
-
 #ifdef CONFIG_DEBUG_FS
 static int dapm_widget_power_open_file(struct inode *inode, struct file *file)
 {
@@ -1254,10 +1211,8 @@ static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
                        path->connect = 0; /* old connection must be powered down */
        }
 
-       if (found) {
+       if (found)
                dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP);
-               dump_dapm(widget->codec, "mux power update");
-       }
 
        return 0;
 }
@@ -1285,10 +1240,8 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
                break;
        }
 
-       if (found) {
+       if (found)
                dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP);
-               dump_dapm(widget->codec, "mixer power update");
-       }
 
        return 0;
 }
@@ -1404,9 +1357,7 @@ static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec,
  */
 int snd_soc_dapm_sync(struct snd_soc_codec *codec)
 {
-       int ret = dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
-       dump_dapm(codec, "sync");
-       return ret;
+       return dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
 
@@ -2163,7 +2114,6 @@ int snd_soc_dapm_stream_event(struct snd_soc_codec *codec,
 
        dapm_power_widgets(codec, event);
        mutex_unlock(&codec->mutex);
-       dump_dapm(codec, __func__);
        return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);