From owner-svn-src-all@FreeBSD.ORG Tue Jan 13 16:27:04 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DDCFD106566B; Tue, 13 Jan 2009 16:27:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CAD828FC34; Tue, 13 Jan 2009 16:27:04 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0DGR4mQ008501; Tue, 13 Jan 2009 16:27:04 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0DGR4Xu008500; Tue, 13 Jan 2009 16:27:04 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200901131627.n0DGR4Xu008500@svn.freebsd.org> From: Alexander Motin Date: Tue, 13 Jan 2009 16:27:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187154 - head/sys/dev/sound/pci/hda X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2009 16:27:05 -0000 Author: mav Date: Tue Jan 13 16:27:04 2009 New Revision: 187154 URL: http://svn.freebsd.org/changeset/base/187154 Log: Change configuration order to enable output only after codec is configured. Mute all mixer controllable amplifiers initially to let mixer to unmute only some of them later. This should reduce clicks and noises during boot. Modified: head/sys/dev/sound/pci/hda/hdac.c Modified: head/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdac.c Tue Jan 13 16:19:58 2009 (r187153) +++ head/sys/dev/sound/pci/hda/hdac.c Tue Jan 13 16:27:04 2009 (r187154) @@ -83,7 +83,7 @@ #include "mixer_if.h" -#define HDA_DRV_TEST_REV "20090110_0123" +#define HDA_DRV_TEST_REV "20090113_0124" SND_DECLARE_FILE("$FreeBSD$"); @@ -6111,6 +6111,29 @@ hdac_audio_prepare_pin_ctrl(struct hdac_ } static void +hdac_audio_ctl_commit(struct hdac_devinfo *devinfo) +{ + struct hdac_audio_ctl *ctl; + int i, z; + + i = 0; + while ((ctl = hdac_audio_ctl_each(devinfo, &i)) != NULL) { + if (ctl->enable == 0 || ctl->ossmask != 0) { + /* Mute disabled and mixer controllable controls. + * Last will be initialized by mixer_init(). + * This expected to reduce click on startup. */ + hdac_audio_ctl_amp_set(ctl, HDA_AMP_MUTE_ALL, 0, 0); + continue; + } + /* Init fixed controls to 0dB amplification. */ + z = ctl->offset; + if (z > ctl->step) + z = ctl->step; + hdac_audio_ctl_amp_set(ctl, HDA_AMP_MUTE_NONE, z, z); + } +} + +static void hdac_audio_commit(struct hdac_devinfo *devinfo) { struct hdac_softc *sc = devinfo->codec->sc; @@ -6126,11 +6149,41 @@ hdac_audio_commit(struct hdac_devinfo *d hdac_command(sc, HDA_CMD_12BIT(cad, devinfo->nid, 0x7e7, 0), cad); + /* Commit controls. */ + hdac_audio_ctl_commit(devinfo); + + /* Commit selectors, pins and EAPD. */ + for (i = 0; i < devinfo->nodecnt; i++) { + w = &devinfo->widget[i]; + if (w == NULL) + continue; + if (w->selconn == -1) + w->selconn = 0; + if (w->nconns > 0) + hdac_widget_connection_select(w, w->selconn); + if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) { + hdac_command(sc, + HDA_CMD_SET_PIN_WIDGET_CTRL(cad, w->nid, + w->wclass.pin.ctrl), cad); + } + if (w->param.eapdbtl != HDAC_INVALID) { + uint32_t val; + + val = w->param.eapdbtl; + if (devinfo->function.audio.quirks & + HDA_QUIRK_EAPDINV) + val ^= HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD; + hdac_command(sc, + HDA_CMD_SET_EAPD_BTL_ENABLE(cad, w->nid, + val), cad); + } + } + + /* Commit GPIOs. */ gdata = 0; gmask = 0; gdir = 0; commitgpio = 0; - numgpio = HDA_PARAM_GPIO_COUNT_NUM_GPIO( devinfo->function.audio.gpio); @@ -6185,54 +6238,6 @@ hdac_audio_commit(struct hdac_devinfo *d HDA_CMD_SET_GPIO_DATA(cad, devinfo->nid, gdata), cad); } - - for (i = 0; i < devinfo->nodecnt; i++) { - w = &devinfo->widget[i]; - if (w == NULL) - continue; - if (w->selconn == -1) - w->selconn = 0; - if (w->nconns > 0) - hdac_widget_connection_select(w, w->selconn); - if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) { - hdac_command(sc, - HDA_CMD_SET_PIN_WIDGET_CTRL(cad, w->nid, - w->wclass.pin.ctrl), cad); - } - if (w->param.eapdbtl != HDAC_INVALID) { - uint32_t val; - - val = w->param.eapdbtl; - if (devinfo->function.audio.quirks & - HDA_QUIRK_EAPDINV) - val ^= HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD; - hdac_command(sc, - HDA_CMD_SET_EAPD_BTL_ENABLE(cad, w->nid, - val), cad); - - } - } -} - -static void -hdac_audio_ctl_commit(struct hdac_devinfo *devinfo) -{ - struct hdac_audio_ctl *ctl; - int i, z; - - i = 0; - while ((ctl = hdac_audio_ctl_each(devinfo, &i)) != NULL) { - if (ctl->enable == 0) { - /* Mute disabled controls. */ - hdac_audio_ctl_amp_set(ctl, HDA_AMP_MUTE_ALL, 0, 0); - continue; - } - /* Init controls to 0dB amplification. */ - z = ctl->offset; - if (z > ctl->step) - z = ctl->step; - hdac_audio_ctl_amp_set(ctl, HDA_AMP_MUTE_NONE, z, z); - } } static void @@ -7477,10 +7482,6 @@ hdac_attach2(void *arg) ); hdac_audio_commit(devinfo); HDA_BOOTHVERBOSE( - device_printf(sc->dev, "Ctls commit...\n"); - ); - hdac_audio_ctl_commit(devinfo); - HDA_BOOTHVERBOSE( device_printf(sc->dev, "HP switch init...\n"); ); hdac_hp_switch_init(devinfo); @@ -7730,10 +7731,6 @@ hdac_resume(device_t dev) ); hdac_audio_commit(devinfo); HDA_BOOTHVERBOSE( - device_printf(dev, "Ctls commit...\n"); - ); - hdac_audio_ctl_commit(devinfo); - HDA_BOOTHVERBOSE( device_printf(dev, "HP switch init...\n"); ); hdac_hp_switch_init(devinfo);