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.