On Wed, Jul 05, 2017 at 03:32:23PM +0200, Alexandre Ratchov wrote:
> On Wed, Jun 28, 2017 at 04:17:30PM +0200, Manuel Giraud wrote:
> > Hi,
> > 
> > This patch removes noises in speaker (or headphone) when rebooting
> > (tested on only one Conexant CX20724 chip)
> > 
> 
> Thanks.  Works for me and seems useful in many cases.
> 
> > Index: azalia.c
> > ===================================================================
> > RCS file: /cvs/src/sys/dev/pci/azalia.c,v
> > retrieving revision 1.235
> > diff -u -p -r1.235 azalia.c
> > --- azalia.c        11 Apr 2017 14:43:49 -0000      1.235
> > +++ azalia.c        28 Jun 2017 13:44:26 -0000
> > @@ -697,12 +697,25 @@ azalia_shutdown(void *v)
> >  {
> >     azalia_t *az = (azalia_t *)v;
> >     uint32_t gctl;
> > +   codec_t *codec;
> > +   int i;
> >  
> >     /* disable unsolicited response */
> >     gctl = AZ_READ_4(az, GCTL);
> >     AZ_WRITE_4(az, GCTL, gctl & ~(HDA_GCTL_UNSOL));
> >  
> >     timeout_del(&az->unsol_to);
> > +
> > +   /* power off all codecs */
> > +   for (i = 0; i < az->ncodecs; i++) {
> > +           codec = &az->codecs[i];
> > +           if (codec->audiofunc < 0)
> > +                   continue;
> > +           azalia_comresp(codec, codec->audiofunc,
> > +                          CORB_SET_POWER_STATE, CORB_PS_D3, NULL);
> 
> small style nit: long parameter lists are wrapped with four spaces.
> 
> > +           DELAY(100);
> 
> the proper delays are already part of azalia_comresp().  Since the
> CORB_SET_POWER_STATE command is acknowledged, there's no reason to
> wait.
> 
> > +           azalia_codec_delete(codec);
> 
> the DVACT_POWERDOWN is not intended to cleanup and/or free
> resources as system is about to go down, so this isn't necessary.
> 

Here's a diff that takes these comments into account. I've been running
with this since quite some time and it silences the annoying noises.

Can we get this in?

Index: azalia.c
===================================================================
RCS file: /var/cvs/src/sys/dev/pci/azalia.c,v
retrieving revision 1.235
diff -u -p -r1.235 azalia.c
--- azalia.c    11 Apr 2017 14:43:49 -0000      1.235
+++ azalia.c    10 Aug 2017 13:45:55 -0000
@@ -697,12 +697,23 @@ azalia_shutdown(void *v)
 {
        azalia_t *az = (azalia_t *)v;
        uint32_t gctl;
+       codec_t *codec;
+       int i;
 
        /* disable unsolicited response */
        gctl = AZ_READ_4(az, GCTL);
        AZ_WRITE_4(az, GCTL, gctl & ~(HDA_GCTL_UNSOL));
 
        timeout_del(&az->unsol_to);
+
+       /* power off all codecs */
+       for (i = 0; i < az->ncodecs; i++) {
+               codec = &az->codecs[i];
+               if (codec->audiofunc < 0)
+                       continue;
+               azalia_comresp(codec, codec->audiofunc, CORB_SET_POWER_STATE,
+                   CORB_PS_D3, NULL);
+       }
 
        /* halt CORB/RIRB */
        azalia_halt_corb(az);

Reply via email to