Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0b4d221b8d56deefca4984d01b3a010107ae1f72
Commit:     0b4d221b8d56deefca4984d01b3a010107ae1f72
Parent:     7570f29a545c7fdf29e913860320e0c09e60e45b
Author:     Liam Girdwood <[EMAIL PROTECTED]>
AuthorDate: Thu Jan 10 14:36:20 2008 +0100
Committer:  Jaroslav Kysela <[EMAIL PROTECTED]>
CommitDate: Thu Jan 31 17:29:50 2008 +0100

    [ALSA] soc - Add device level DAPM event
    
    Added a device level dapm event so that both the machine and codec are 
informed
    when dapm events occur.
    
    Signed-off-by: Liam Girdwood <[EMAIL PROTECTED]>
    Signed-off-by: Mark Brown <[EMAIL PROTECTED]>
    Signed-off-by: Takashi Iwai <[EMAIL PROTECTED]>
    Signed-off-by: Jaroslav Kysela <[EMAIL PROTECTED]>
---
 include/sound/soc-dapm.h |    1 +
 include/sound/soc.h      |    3 +++
 sound/soc/soc-core.c     |   23 +++++++++++------------
 sound/soc/soc-dapm.c     |   23 +++++++++++++++++++++++
 4 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index b9d5864..4158cba 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -199,6 +199,7 @@ void snd_soc_dapm_free(struct snd_soc_device *socdev);
 /* dapm events */
 int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream,
        int event);
+int snd_soc_dapm_device_event(struct snd_soc_device *socdev, int event);
 
 /* dapm sys fs - used by the core */
 int snd_soc_dapm_sys_add(struct device *dev);
diff --git a/include/sound/soc.h b/include/sound/soc.h
index c22c656..add5f94 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -425,6 +425,9 @@ struct snd_soc_machine {
        int (*resume_pre)(struct platform_device *pdev);
        int (*resume_post)(struct platform_device *pdev);
 
+       /* callbacks */
+       int (*dapm_event)(struct snd_soc_machine *, int event);
+
        /* CPU <--> Codec DAI links  */
        struct snd_soc_dai_link *dai_link;
        int num_links;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9407525..bd656db 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -288,15 +288,16 @@ static void close_delayed_work(struct work_struct *work)
                if (codec_dai->pop_wait == 1) {
 
                        codec_dai->pop_wait = 0;
-                       snd_soc_dapm_stream_event(codec, 
codec_dai->playback.stream_name,
+                       snd_soc_dapm_stream_event(codec,
+                               codec_dai->playback.stream_name,
                                SND_SOC_DAPM_STREAM_STOP);
 
                        /* power down the codec power domain if no longer 
active */
                        if (codec->active == 0) {
                                dbg("pop wq D3 %s %s\n", codec->name,
                                        codec_dai->playback.stream_name);
-                               if (codec->dapm_event)
-                                       codec->dapm_event(codec, 
SNDRV_CTL_POWER_D3hot);
+                               snd_soc_dapm_device_event(socdev,
+                                       SNDRV_CTL_POWER_D3hot);
                        }
                }
        }
@@ -352,12 +353,12 @@ static int soc_codec_close(struct snd_pcm_substream 
*substream)
        } else {
                /* capture streams can be powered down now */
                snd_soc_dapm_stream_event(codec,
-                       codec_dai->capture.stream_name, 
SND_SOC_DAPM_STREAM_STOP);
+                       codec_dai->capture.stream_name,
+                       SND_SOC_DAPM_STREAM_STOP);
 
-               if (codec->active == 0 && codec_dai->pop_wait == 0){
-                       if (codec->dapm_event)
-                               codec->dapm_event(codec, SNDRV_CTL_POWER_D3hot);
-               }
+               if (codec->active == 0 && codec_dai->pop_wait == 0)
+                       snd_soc_dapm_device_event(socdev,
+                                               SNDRV_CTL_POWER_D3hot);
        }
 
        mutex_unlock(&pcm_mutex);
@@ -432,8 +433,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream 
*substream)
                /* no delayed work - do we need to power up codec */
                if (codec->dapm_state != SNDRV_CTL_POWER_D0) {
 
-                       if (codec->dapm_event)
-                               codec->dapm_event(codec, SNDRV_CTL_POWER_D1);
+                       snd_soc_dapm_device_event(socdev,  SNDRV_CTL_POWER_D1);
 
                        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                                snd_soc_dapm_stream_event(codec,
@@ -444,8 +444,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream 
*substream)
                                        codec_dai->capture.stream_name,
                                        SND_SOC_DAPM_STREAM_START);
 
-                       if (codec->dapm_event)
-                               codec->dapm_event(codec, SNDRV_CTL_POWER_D0);
+                       snd_soc_dapm_device_event(socdev, SNDRV_CTL_POWER_D0);
                        if (codec_dai->dai_ops.digital_mute)
                                codec_dai->dai_ops.digital_mute(codec_dai, 0);
 
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 3b8f94a..16ebb60 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1279,6 +1279,29 @@ int snd_soc_dapm_stream_event(struct snd_soc_codec 
*codec,
 EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
 
 /**
+ * snd_soc_dapm_device_event - send a device event to the dapm core
+ * @socdev: audio device
+ * @event: device event
+ *
+ * Sends a device event to the dapm core. The core then makes any
+ * necessary machine or codec power changes..
+ *
+ * Returns 0 for success else error.
+ */
+int snd_soc_dapm_device_event(struct snd_soc_device *socdev, int event)
+{
+       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_machine *machine = socdev->machine;
+
+       if (machine->dapm_event)
+                               machine->dapm_event(machine, event);
+       if (codec->dapm_event)
+                               codec->dapm_event(codec, event);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_device_event);
+
+/**
  * snd_soc_dapm_set_endpoint - set audio endpoint status
  * @codec: audio codec
  * @endpoint: audio signal endpoint (or start point)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to