summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpica
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2004-05-06 08:04:34 +0000
committernjl <njl@FreeBSD.org>2004-05-06 08:04:34 +0000
commit6fd1561ea0b11f7e8b260ee3494c5ececbf9b341 (patch)
treefe6d6d0682be1a4eb88ac8feb810ce6134ffec45 /sys/dev/acpica
parentb57e5e03fd70fac20a610e56ad7729e47f198a33 (diff)
downloadFreeBSD-src-6fd1561ea0b11f7e8b260ee3494c5ececbf9b341.zip
FreeBSD-src-6fd1561ea0b11f7e8b260ee3494c5ececbf9b341.tar.gz
Select the highest valid (i.e., S3) sleep state for the default for the
sleep button. Change the default for the lid switch to NONE. This can be overridden in /etc/sysctl.conf as desired.
Diffstat (limited to 'sys/dev/acpica')
-rw-r--r--sys/dev/acpica/acpi.c24
-rw-r--r--sys/dev/acpica/acpivar.h3
2 files changed, 16 insertions, 11 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index cdba7ca..af035f2 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -385,8 +385,9 @@ acpi_attach(device_t dev)
{
struct acpi_softc *sc;
ACPI_STATUS status;
- int error;
+ int error, state;
UINT32 flags;
+ UINT8 TypeA, TypeB;
char *env;
#ifdef ACPI_DEBUGGER
char *debugpoint;
@@ -532,15 +533,22 @@ acpi_attach(device_t dev)
sc->acpi_s4bios = 1;
/*
- * Dispatch the default sleep state to devices.
- * TBD: should be configured from userland policy manager.
+ * Dispatch the default sleep state to devices. The lid switch is set
+ * to NONE by default to avoid surprising users.
*/
- sc->acpi_power_button_sx = ACPI_POWER_BUTTON_DEFAULT_SX;
- sc->acpi_sleep_button_sx = ACPI_SLEEP_BUTTON_DEFAULT_SX;
- sc->acpi_lid_switch_sx = ACPI_LID_SWITCH_DEFAULT_SX;
+ sc->acpi_power_button_sx = ACPI_STATE_S5;
+ sc->acpi_lid_switch_sx = ACPI_S_STATES_MAX + 1;
sc->acpi_standby_sx = ACPI_STATE_S1;
sc->acpi_suspend_sx = ACPI_STATE_S3;
+ /* Pick the first valid sleep state for the sleep button default. */
+ sc->acpi_sleep_button_sx = ACPI_S_STATES_MAX + 1;
+ for (state = ACPI_STATE_S1; state < ACPI_STATE_S5; state++)
+ if (ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB))) {
+ sc->acpi_sleep_button_sx = state;
+ break;
+ }
+
acpi_enable_fixed_events(sc);
/*
@@ -2235,7 +2243,7 @@ acpi_supported_sleep_state_sysctl(SYSCTL_HANDLER_ARGS)
UINT8 state, TypeA, TypeB;
buf[0] = '\0';
- for (state = ACPI_STATE_S1; state < ACPI_S_STATES_MAX+1; state++) {
+ for (state = ACPI_STATE_S1; state < ACPI_S_STATES_MAX + 1; state++) {
if (ACPI_SUCCESS(AcpiGetSleepTypeData(state, &TypeA, &TypeB))) {
sprintf(sleep_state, "S%d ", state);
strcat(buf, sleep_state);
@@ -2253,7 +2261,7 @@ acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS)
u_int new_state, old_state;
old_state = *(u_int *)oidp->oid_arg1;
- if (old_state > ACPI_S_STATES_MAX+1) {
+ if (old_state > ACPI_S_STATES_MAX + 1) {
strcpy(sleep_state, "unknown");
} else {
bzero(sleep_state, sizeof(sleep_state));
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 0f21db5..4961935 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -57,9 +57,6 @@ struct acpi_softc {
struct sysctl_ctx_list acpi_sysctl_ctx;
struct sysctl_oid *acpi_sysctl_tree;
-#define ACPI_POWER_BUTTON_DEFAULT_SX ACPI_STATE_S5;
-#define ACPI_SLEEP_BUTTON_DEFAULT_SX ACPI_STATE_S1;
-#define ACPI_LID_SWITCH_DEFAULT_SX ACPI_STATE_S1;
int acpi_power_button_sx;
int acpi_sleep_button_sx;
int acpi_lid_switch_sx;
OpenPOWER on IntegriCloud