CHROMIUM: ASoC: samsung i2s - Don't setup if already active.
authorDylan Reid <dgreid@chromium.org>
Fri, 7 Sep 2012 02:10:13 +0000 (19:10 -0700)
committerGerrit <chrome-bot@google.com>
Mon, 17 Sep 2012 16:34:51 +0000 (09:34 -0700)
If the dai is already running when setup is called, skip setup.  Setting
up again caused set_sysclk to set rclk_srcrate to other->rclk_srcrate,
other would often be set to the default of 44.1.  Playing a 48k stream
then adding a 48k capture stream would lead to both streams set to 44.1
(The value of other->rclk_srcrate).

Similarly in shutdown, if either playback or capture are still active,
return instead of turning off the clocks.

BUG=chrome-os-partner:13769, 13749
TEST=aplay -Dhw:0 <any 48k wav file>, then arecord -Dhw:0 -f dat
/tmp/asdf.wav.  Make sure audio continues from aplay and is captured by
arecord, before this change aplay would stop and arecord would capture
silence.
Gmail settings, make sure microphone progress bar moves when you talk.

Change-Id: I1dd02854e234d23ac25ad686c7603e4bc9265b4e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32477
Reviewed-by: Olof Johansson <olofj@chromium.org>
sound/soc/samsung/i2s.c

index 0416341..3a11e96 100644 (file)
@@ -718,6 +718,10 @@ static int i2s_startup(struct snd_pcm_substream *substream,
 
        pm_runtime_ctl(i2s, true);
 
+       /* Check not already running. */
+       if (dai->playback_active || dai->capture_active)
+               return 0;
+
        spin_lock_irqsave(&lock, flags);
 
        i2s->mode |= DAI_OPENED;
@@ -745,6 +749,10 @@ static void i2s_shutdown(struct snd_pcm_substream *substream,
        struct i2s_dai *other = i2s->pri_dai ? : i2s->sec_dai;
        unsigned long flags;
 
+       /* Check not still running. */
+       if (dai->playback_active || dai->capture_active)
+               return;
+
        spin_lock_irqsave(&lock, flags);
 
        i2s->mode &= ~DAI_OPENED;