Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[safe/jmp/linux-2.6] / sound / soc / soc-core.c
index c0e7066..1d70829 100644 (file)
@@ -299,7 +299,6 @@ static void close_delayed_work(struct work_struct *work)
 {
        struct snd_soc_card *card = container_of(work, struct snd_soc_card,
                                                 delayed_work.work);
-       struct snd_soc_device *socdev = card->socdev;
        struct snd_soc_codec *codec = card->codec;
        struct snd_soc_dai *codec_dai;
        int i;
@@ -315,27 +314,10 @@ static void close_delayed_work(struct work_struct *work)
 
                /* are we waiting on this codec DAI stream */
                if (codec_dai->pop_wait == 1) {
-
-                       /* Reduce power if no longer active */
-                       if (codec->active == 0) {
-                               pr_debug("pop wq D1 %s %s\n", codec->name,
-                                        codec_dai->playback.stream_name);
-                               snd_soc_dapm_set_bias_level(socdev,
-                                       SND_SOC_BIAS_PREPARE);
-                       }
-
                        codec_dai->pop_wait = 0;
                        snd_soc_dapm_stream_event(codec,
                                codec_dai->playback.stream_name,
                                SND_SOC_DAPM_STREAM_STOP);
-
-                       /* Fall into standby if no longer active */
-                       if (codec->active == 0) {
-                               pr_debug("pop wq D3 %s %s\n", codec->name,
-                                        codec_dai->playback.stream_name);
-                               snd_soc_dapm_set_bias_level(socdev,
-                                       SND_SOC_BIAS_STANDBY);
-                       }
                }
        }
        mutex_unlock(&pcm_mutex);
@@ -399,10 +381,6 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
                snd_soc_dapm_stream_event(codec,
                        codec_dai->capture.stream_name,
                        SND_SOC_DAPM_STREAM_STOP);
-
-               if (codec->active == 0 && codec_dai->pop_wait == 0)
-                       snd_soc_dapm_set_bias_level(socdev,
-                                               SND_SOC_BIAS_STANDBY);
        }
 
        mutex_unlock(&pcm_mutex);
@@ -467,36 +445,16 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
                cancel_delayed_work(&card->delayed_work);
        }
 
-       /* do we need to power up codec */
-       if (codec->bias_level != SND_SOC_BIAS_ON) {
-               snd_soc_dapm_set_bias_level(socdev,
-                                           SND_SOC_BIAS_PREPARE);
-
-               if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-                       snd_soc_dapm_stream_event(codec,
-                                       codec_dai->playback.stream_name,
-                                       SND_SOC_DAPM_STREAM_START);
-               else
-                       snd_soc_dapm_stream_event(codec,
-                                       codec_dai->capture.stream_name,
-                                       SND_SOC_DAPM_STREAM_START);
-
-               snd_soc_dapm_set_bias_level(socdev, SND_SOC_BIAS_ON);
-               snd_soc_dai_digital_mute(codec_dai, 0);
-
-       } else {
-               /* codec already powered - power on widgets */
-               if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-                       snd_soc_dapm_stream_event(codec,
-                                       codec_dai->playback.stream_name,
-                                       SND_SOC_DAPM_STREAM_START);
-               else
-                       snd_soc_dapm_stream_event(codec,
-                                       codec_dai->capture.stream_name,
-                                       SND_SOC_DAPM_STREAM_START);
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               snd_soc_dapm_stream_event(codec,
+                                         codec_dai->playback.stream_name,
+                                         SND_SOC_DAPM_STREAM_START);
+       else
+               snd_soc_dapm_stream_event(codec,
+                                         codec_dai->capture.stream_name,
+                                         SND_SOC_DAPM_STREAM_START);
 
-               snd_soc_dai_digital_mute(codec_dai, 0);
-       }
+       snd_soc_dai_digital_mute(codec_dai, 0);
 
 out:
        mutex_unlock(&pcm_mutex);
@@ -670,6 +628,12 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
        struct snd_soc_codec *codec = card->codec;
        int i;
 
+       /* If the initialization of this soc device failed, there is no codec
+        * associated with it. Just bail out in this case.
+        */
+       if (!codec)
+               return 0;
+
        /* Due to the resume being scheduled into a workqueue we could
        * suspend before that's finished - wait for it to complete.
         */
@@ -1372,6 +1336,7 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
                return ret;
        }
 
+       codec->socdev = socdev;
        codec->card->dev = socdev->dev;
        codec->card->private_data = codec;
        strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver));
@@ -1424,6 +1389,9 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
        snprintf(codec->card->longname, sizeof(codec->card->longname),
                 "%s (%s)", card->name, codec->name);
 
+       /* Make sure all DAPM widgets are instantiated */
+       snd_soc_dapm_new_widgets(codec);
+
        ret = snd_card_register(codec->card);
        if (ret < 0) {
                printk(KERN_ERR "asoc: failed to register soundcard for %s\n",