Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurence Darby <ldarby@tuffmail.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH] ALSA: oxygen: Fix S/PDIF muting
Date: Sun, 5 Jul 2015 19:56:50 +0100	[thread overview]
Message-ID: <20150705195650.96c58d265a2c0118ab48bd2e@tuffmail.com> (raw)
In-Reply-To: <559264D8.9030804@ladisch.de>

On Tue, 30 Jun 2015 11:43:52 +0200 Clemens Ladisch wrote:

> Laurence Darby wrote:
> > On Sun, 28 Jun 2015 20:44:26 +0200 Clemens Ladisch wrote:
> >> Laurence Darby wrote:
> >>> The S/PDIF output was muted whenever audio wasn't playing which
> >>> resulted in a clicking noise from the DAC when resuming
> >>
> >> It indeed appears that there are too many oxygen_clear_bits32()
> >> calls. However, I don't trust the hardware; please confirm that
> >> the S/PDIF output, without an active stream, play zeros and not
> >> the last sample.
> >
> > Well, to test that I created a wav file of about a quarter of a sine
> > wave (at about -15dB), consisting of 5520 samples, so it matched the
> > alsa buffer size, otherwise aplay pads the buffer with silence.
> >
> > The chip does continue playing the last sample value, then the
> > speakers pop later when something else is played.  Is this really
> > an issue though? I just found my intel hda chip behaves the same
> > way, and that chip's driver leaves it un-muted.
> 
> The current problem is that the output gets disabled, then later, when
> the driver is about to start the new stream, it enables the output
> again (which outputs the last old sample), and then the new stream
> starts (usually with zero samples).  Going from disabled(=zero) to
> old-sample to new-sample(=zero) is an extra pop.
> 
> In any case, putting a DC offset on the speakers is a bad idea.
> 
> > If this is still going to prevent fixing the popping noise for the
> > oxygen chip, what about writing a single 0x00 sample to it in the
> > driver instead of muting it?
> 
> This is likely to work (but the zero sample has to go through DMA).

Ok, I eventually got this to work, with this in oxygen_spdif_hw_free():

	memset (runtime->dma_area, 0, runtime->dma_bytes);
	oxygen_trigger(substream,SNDRV_PCM_TRIGGER_START);
	msleep (1);
	oxygen_trigger(substream,SNDRV_PCM_TRIGGER_STOP);
	
instead of disabling OXYGEN_SPDIF_OUT_ENABLE.  The 1ms sleep is
necessary otherwise it intermittently still leaves DC on the output.

If I create a proper patch for that (it should probably use
snd_pcm_format_set_silence() instead of memset) would that be
acceptable? 

> At the moment, oxygen_hw_free() pokes at the OXYGEN_DMA_FLUSH
> register. Please check if there is an improvement if it also pokes at
> the OXYGEN_DMA_RESET register.

Unfortunately not.  I did some archeology and found your CVS commit
from 2007: http://sourceforge.net/p/alsa/mailman/message/15439076/
which has this code:

+	if (chip->CMI8788IC_revision == CMI8788IC_Revision1)
+		DMARestRegister = PCI_DMA_Reset;
+	if (chip->CMI8788IC_revision == CMI8788IC_Revision2)
+		DMARestRegister = PCI_DMA_FLUSH;
...
+		/* Reset DMA Channel*/
+		reset = snd_cmipci_read_b(chip, DMARestRegister);
+		reset |= cmi_subs->DMA_chan_reset; /* set bit */

So I understand why you asked if the RESET works :) 

Regards,
Laurence

  reply	other threads:[~2015-07-05 18:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-28 12:13 [PATCH] ALSA: oxygen: Fix S/PDIF muting Laurence Darby
2015-06-28 18:44 ` Clemens Ladisch
2015-06-29 20:01   ` Laurence Darby
2015-06-30  9:43     ` Clemens Ladisch
2015-07-05 18:56       ` Laurence Darby [this message]
2015-07-05 19:23         ` Clemens Ladisch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150705195650.96c58d265a2c0118ab48bd2e@tuffmail.com \
    --to=ldarby@tuffmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox