Explorar o código

sound: oxygen: reset DMA when stream is closed

When a PCM stream is closed, flush the corresponding DMA channel.
Otherwise, the DMA controller would continue to output the last sample
which would result in a DC offset on the output.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Clemens Ladisch %!s(int64=16) %!d(string=hai) anos
pai
achega
345c03ef0f
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      sound/pci/oxygen/oxygen_pcm.c

+ 5 - 1
sound/pci/oxygen/oxygen_pcm.c

@@ -487,10 +487,14 @@ static int oxygen_hw_free(struct snd_pcm_substream *substream)
 {
 {
 	struct oxygen *chip = snd_pcm_substream_chip(substream);
 	struct oxygen *chip = snd_pcm_substream_chip(substream);
 	unsigned int channel = oxygen_substream_channel(substream);
 	unsigned int channel = oxygen_substream_channel(substream);
+	unsigned int channel_mask = 1 << channel;
 
 
 	spin_lock_irq(&chip->reg_lock);
 	spin_lock_irq(&chip->reg_lock);
-	chip->interrupt_mask &= ~(1 << channel);
+	chip->interrupt_mask &= ~channel_mask;
 	oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
 	oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
+
+	oxygen_set_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask);
+	oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask);
 	spin_unlock_irq(&chip->reg_lock);
 	spin_unlock_irq(&chip->reg_lock);
 
 
 	return snd_pcm_lib_free_pages(substream);
 	return snd_pcm_lib_free_pages(substream);