From owner-svn-src-stable@FreeBSD.ORG Thu Feb 23 22:03:20 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E888E106564A; Thu, 23 Feb 2012 22:03:20 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BDD318FC12; Thu, 23 Feb 2012 22:03:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1NM3Ke6025368; Thu, 23 Feb 2012 22:03:20 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1NM3Kb6025366; Thu, 23 Feb 2012 22:03:20 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201202232203.q1NM3Kb6025366@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 23 Feb 2012 22:03:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232082 - stable/9/sys/amd64/acpica X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2012 22:03:21 -0000 Author: jkim Date: Thu Feb 23 22:03:20 2012 New Revision: 232082 URL: http://svn.freebsd.org/changeset/base/232082 Log: MFC: r231791, r231840 Set up an event handler to turn off speaker if user requested it. Speaker will stop beeping after all device drivers are resumed. Use proper API to "acquire" and "release" PIC timer2 for consistency and correctness. Modified: stable/9/sys/amd64/acpica/acpi_wakeup.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/acpica/acpi_wakeup.c ============================================================================== --- stable/9/sys/amd64/acpica/acpi_wakeup.c Thu Feb 23 22:00:31 2012 (r232081) +++ stable/9/sys/amd64/acpica/acpi_wakeup.c Thu Feb 23 22:03:20 2012 (r232082) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -40,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -92,11 +94,12 @@ static void acpi_wakeup_cpus(struct acp *addr = val; \ } while (0) -/* Turn off bits 1&2 of the PIT, stopping the beep. */ static void acpi_stop_beep(void *arg) { - outb(0x61, inb(0x61) & ~0x3); + + if (acpi_resume_beep != 0) + timer_spkr_release(); } #ifdef SMP @@ -234,6 +237,9 @@ acpi_sleep_machdep(struct acpi_softc *sc CPU_CLR(PCPU_GET(cpuid), &wakeup_cpus); #endif + if (acpi_resume_beep != 0) + timer_spkr_acquire(); + AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc)); rf = intr_disable(); @@ -312,10 +318,6 @@ out: mem_range_softc.mr_op->reinit != NULL) mem_range_softc.mr_op->reinit(&mem_range_softc); - /* If we beeped, turn it off after a delay. */ - if (acpi_resume_beep) - timeout(acpi_stop_beep, NULL, 3 * hz); - return (ret); } @@ -338,6 +340,12 @@ acpi_alloc_wakeup_handler(void) printf("%s: can't alloc wake memory\n", __func__); return (NULL); } + if (EVENTHANDLER_REGISTER(power_resume, acpi_stop_beep, NULL, + EVENTHANDLER_PRI_LAST) == NULL) { + printf("%s: can't register event handler\n", __func__); + contigfree(wakeaddr, 4 * PAGE_SIZE, M_DEVBUF); + return (NULL); + } susppcbs = malloc(mp_ncpus * sizeof(*susppcbs), M_DEVBUF, M_WAITOK); suspfpusave = malloc(mp_ncpus * sizeof(void *), M_DEVBUF, M_WAITOK); for (i = 0; i < mp_ncpus; i++) {