svn commit: r231791 - head/sys/amd64/acpica
Jung-uk Kim
jkim at FreeBSD.org
Wed Feb 15 22:49:26 UTC 2012
Author: jkim
Date: Wed Feb 15 22:49:25 2012
New Revision: 231791
URL: http://svn.freebsd.org/changeset/base/231791
Log:
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:
head/sys/amd64/acpica/acpi_wakeup.c
Modified: head/sys/amd64/acpica/acpi_wakeup.c
==============================================================================
--- head/sys/amd64/acpica/acpi_wakeup.c Wed Feb 15 22:45:57 2012 (r231790)
+++ head/sys/amd64/acpica/acpi_wakeup.c Wed Feb 15 22:49:25 2012 (r231791)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/bus.h>
+#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/memrange.h>
@@ -40,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm.h>
#include <vm/pmap.h>
+#include <machine/clock.h>
#include <machine/intr_machdep.h>
#include <x86/mca.h>
#include <machine/pcb.h>
@@ -92,11 +94,11 @@ 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);
+
+ timer_spkr_release();
}
#ifdef SMP
@@ -217,6 +219,7 @@ acpi_wakeup_cpus(struct acpi_softc *sc,
int
acpi_sleep_machdep(struct acpi_softc *sc, int state)
{
+ static eventhandler_tag stop_beep = NULL;
#ifdef SMP
cpuset_t wakeup_cpus;
#endif
@@ -234,6 +237,22 @@ acpi_sleep_machdep(struct acpi_softc *sc
CPU_CLR(PCPU_GET(cpuid), &wakeup_cpus);
#endif
+ if (acpi_resume_beep == 0) {
+ if (stop_beep != NULL) {
+ EVENTHANDLER_DEREGISTER(power_resume, stop_beep);
+ stop_beep = NULL;
+ }
+ } else {
+ if (stop_beep == NULL)
+ stop_beep = EVENTHANDLER_REGISTER(power_resume,
+ acpi_stop_beep, NULL, EVENTHANDLER_PRI_LAST);
+ if (stop_beep == NULL)
+ device_printf(sc->acpi_dev,
+ "Failed to set up event handler\n");
+ else
+ timer_spkr_acquire();
+ }
+
AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc));
rf = intr_disable();
@@ -257,7 +276,7 @@ acpi_sleep_machdep(struct acpi_softc *sc
}
#endif
- WAKECODE_FIXUP(resume_beep, uint8_t, (acpi_resume_beep != 0));
+ WAKECODE_FIXUP(resume_beep, uint8_t, (stop_beep != NULL));
WAKECODE_FIXUP(reset_video, uint8_t, (acpi_reset_video != 0));
WAKECODE_FIXUP(wakeup_pcb, struct pcb *, susppcbs[0]);
@@ -311,10 +330,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);
}
More information about the svn-src-head
mailing list