Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1332095

[PATCH 3.12 01/64] ALSA: rme96: Fix unexpected volume reset after rate changes

From Jiri Slaby <jslaby@suse.cz>
Newsgroups linux.kernel
Subject [PATCH 3.12 01/64] ALSA: rme96: Fix unexpected volume reset after rate changes
Date 2016-02-11 15:40 +0100
Message-ID <r0ZWP-17m-23@gated-at.bofh.it> (permalink)
References <r0ZWO-17m-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Takashi Iwai <tiwai@suse.de>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

commit a74a821624c0c75388a193337babd17a8c02c740 upstream.

rme96 driver needs to reset DAC depending on the sample rate, and this
results in resetting to the max volume suddenly.  It's because of the
missing call of snd_rme96_apply_dac_volume().

However, calling this function right after the DAC reset still may not
work, and we need some delay before this call.  Since the DAC reset
and the procedure after that are performed in the spinlock, we delay
the DAC volume restore at the end after the spinlock.

Reported-and-tested-by: Sylvain LABOISNE <maeda1@free.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 sound/pci/rme96.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index bb9ebc5543d7..2da24272e6a5 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -744,10 +744,11 @@ snd_rme96_playback_setrate(struct rme96 *rme96,
 	{
 		/* change to/from double-speed: reset the DAC (if available) */
 		snd_rme96_reset_dac(rme96);
+		return 1; /* need to restore volume */
 	} else {
 		writel(rme96->wcreg, rme96->iobase + RME96_IO_CONTROL_REGISTER);
+		return 0;
 	}
-	return 0;
 }
 
 static int
@@ -985,6 +986,7 @@ snd_rme96_playback_hw_params(struct snd_pcm_substream *substream,
 	struct rme96 *rme96 = snd_pcm_substream_chip(substream);
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	int err, rate, dummy;
+	bool apply_dac_volume = false;
 
 	runtime->dma_area = (void __force *)(rme96->iobase +
 					     RME96_IO_PLAY_BUFFER);
@@ -998,24 +1000,26 @@ snd_rme96_playback_hw_params(struct snd_pcm_substream *substream,
 	{
                 /* slave clock */
                 if ((int)params_rate(params) != rate) {
-			spin_unlock_irq(&rme96->lock);
-			return -EIO;                    
-                }
-	} else if ((err = snd_rme96_playback_setrate(rme96, params_rate(params))) < 0) {
-		spin_unlock_irq(&rme96->lock);
-		return err;
-	}
-	if ((err = snd_rme96_playback_setformat(rme96, params_format(params))) < 0) {
-		spin_unlock_irq(&rme96->lock);
-		return err;
+			err = -EIO;
+			goto error;
+		}
+	} else {
+		err = snd_rme96_playback_setrate(rme96, params_rate(params));
+		if (err < 0)
+			goto error;
+		apply_dac_volume = err > 0; /* need to restore volume later? */
 	}
+
+	err = snd_rme96_playback_setformat(rme96, params_format(params));
+	if (err < 0)
+		goto error;
 	snd_rme96_setframelog(rme96, params_channels(params), 1);
 	if (rme96->capture_periodsize != 0) {
 		if (params_period_size(params) << rme96->playback_frlog !=
 		    rme96->capture_periodsize)
 		{
-			spin_unlock_irq(&rme96->lock);
-			return -EBUSY;
+			err = -EBUSY;
+			goto error;
 		}
 	}
 	rme96->playback_periodsize =
@@ -1026,9 +1030,16 @@ snd_rme96_playback_hw_params(struct snd_pcm_substream *substream,
 		rme96->wcreg &= ~(RME96_WCR_PRO | RME96_WCR_DOLBY | RME96_WCR_EMP);
 		writel(rme96->wcreg |= rme96->wcreg_spdif_stream, rme96->iobase + RME96_IO_CONTROL_REGISTER);
 	}
+
+	err = 0;
+ error:
 	spin_unlock_irq(&rme96->lock);
-		
-	return 0;
+	if (apply_dac_volume) {
+		usleep_range(3000, 10000);
+		snd_rme96_apply_dac_volume(rme96);
+	}
+
+	return err;
 }
 
 static int
-- 
2.7.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.12 00/64] 3.12.54-stable review Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:00 +0100
  Re: [PATCH 3.12 00/64] 3.12.54-stable review Nikolay Borisov <kernel@kyup.com> - 2016-02-11 15:10 +0100
    Re: [PATCH 3.12 00/64] 3.12.54-stable review Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:20 +0100
      Re: [PATCH 3.12 00/64] 3.12.54-stable review Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:20 +0100
  [PATCH 3.12 65/65] dm thin: fix race condition when destroying thin pool workqueue Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:20 +0100
  [PATCH 3.12 01/64] ALSA: rme96: Fix unexpected volume reset after rate changes Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:40 +0100
    [PATCH 3.12 19/64] USB: cp210x: add ID for ELV Marble Sound Board 1 Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:40 +0100
    [PATCH 3.12 03/64] ALSA: hda - Set SKL+ hda controller power at freeze() and thaw() Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:50 +0100
    [PATCH 3.12 11/64] ALSA: pcm: Fix snd_pcm_hw_params struct copy in compat mode Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:50 +0100
    [PATCH 3.12 07/64] ALSA: timer: Harden slave timer list handling Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:50 +0100
    [PATCH 3.12 12/64] ALSA: hrtimer: Fix stall by hrtimer_cancel() Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:50 +0100
    [PATCH 3.12 04/64] ALSA: hda/realtek - Fix silent headphone output on MacPro 4,1 (v2) Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:50 +0100
    [PATCH 3.12 06/64] ALSA: seq: Fix race at timer setup and close Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:50 +0100
    [PATCH 3.12 05/64] ALSA: seq: Fix missing NULL check at remove_events ioctl Jiri Slaby <jslaby@suse.cz> - 2016-02-11 15:50 +0100
  Re: [PATCH 3.12 00/64] 3.12.54-stable review Guenter Roeck <linux@roeck-us.net> - 2016-02-11 19:20 +0100
  Re: [PATCH 3.12 00/64] 3.12.54-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2016-02-11 20:30 +0100
    Re: [PATCH 3.12 00/64] 3.12.54-stable review Jiri Slaby <jslaby@suse.cz> - 2016-02-15 16:30 +0100
      RE: [PATCH 3.12 00/64] 3.12.54-stable review "Winkler, Tomas" <tomas.winkler@intel.com> - 2016-02-15 17:20 +0100

csiph-web