Index: acpi.c =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v retrieving revision 1.305.2.7 diff -u -r1.305.2.7 acpi.c --- acpi.c 1 Jun 2012 12:47:13 -0000 1.305.2.7 +++ acpi.c 2 Jun 2012 13:08:40 -0000 @@ -55,6 +55,7 @@ #endif #include #include +#include #include #include #include @@ -293,6 +294,61 @@ SYSCTL_INT(_debug_acpi, OID_AUTO, suspend_bounce, CTLFLAG_RW, &acpi_susp_bounce, 0, "Don't actually suspend, just test devices."); +static int acpi_sleep_beep; +TUNABLE_INT("debug.acpi.sleep_beep", &acpi_sleep_beep); +SYSCTL_INT(_debug_acpi, OID_AUTO, sleep_beep, CTLFLAG_RW, + &acpi_sleep_beep, 0, "Enable debug beep during suspend/resume."); + +void +acpi_debug_beep(int reset) +{ +#ifdef HAS_TIMER_SPKR + +#define DEBUG_BEEP_MELODY_DOREMI + + static unsigned int melody[] = { +#ifdef DEBUG_BEEP_MELODY_DOREMI + /* Do Re Mi Fa So La Ti */ + 262, 294, 330, 349, 392, 440, 494, + /* Do Re Mi Fa So La Ti */ + 523, 587, 659, 698, 784, 880, 988, +#endif + 0}; + static unsigned int index = 0; + static unsigned int spkr_acquired = 0; + unsigned int thz; + + if (acpi_sleep_beep != 0) { + if (reset == 1) { + DELAY(acpi_sleep_beep * 100000); /* >= 100 ms */ + timer_spkr_release(); + index = 0; + spkr_acquired = 0; + return; + } + + if (melody[index] == 0) { + index = 0; + } + + thz = melody[index]; + if (thz == 0) { + return; + } + + index++; + + if (spkr_acquired == 0) { + timer_spkr_acquire(); + spkr_acquired = 1; + } + + timer_spkr_setfreq(thz); + DELAY(acpi_sleep_beep * 100000); /* >= 100 ms */ + } +#endif +} + /* * ACPI can only be loaded as a module by the loader; activating it after * system bootstrap time is not useful, and can be fatal to the system. Index: acpivar.h =================================================================== RCS file: /home/ncvs/src/sys/dev/acpica/acpivar.h,v retrieving revision 1.125.2.4 diff -u -r1.125.2.4 acpivar.h --- acpivar.h 23 Feb 2012 22:26:14 -0000 1.125.2.4 +++ acpivar.h 28 May 2012 23:50:29 -0000 @@ -283,6 +283,16 @@ return (end - start); } +void acpi_debug_beep(int); + +#define ACPI_SLEEP_DEBUG_PRINT(sc, x) do { \ + if (acpi_get_verbose(sc)) \ + device_printf(sc->acpi_dev, "Executing: %s\n", x); \ + acpi_debug_beep(0); \ +} while (0) + +#define ACPI_SLEEP_DEBUG_RESET(sc) do {acpi_debug_beep(1);} while (0) + #ifdef ACPI_DEBUGGER void acpi_EnterDebugger(void); #endif