Module Name: src Committed By: gsutre Date: Thu Oct 28 21:45:02 UTC 2010
Modified Files: src/share/man/man4: acpivga.4 src/sys/dev/acpi: acpi_display.c Log Message: Simplify the sysctl variable for BIOS switch policy, and document it in acpivga(4). The previous hw.acpi.acpivga0.policy variable is renamed into bios_policy for consistency, and is for ACPI_DEBUG only. ok jruoho@ To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/acpivga.4 cvs rdiff -u -r1.3 -r1.4 src/sys/dev/acpi/acpi_display.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man4/acpivga.4 diff -u src/share/man/man4/acpivga.4:1.2 src/share/man/man4/acpivga.4:1.3 --- src/share/man/man4/acpivga.4:1.2 Thu Oct 28 14:36:04 2010 +++ src/share/man/man4/acpivga.4 Thu Oct 28 21:45:02 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: acpivga.4,v 1.2 2010/10/28 14:36:04 jruoho Exp $ +.\" $NetBSD: acpivga.4,v 1.3 2010/10/28 21:45:02 gsutre Exp $ .\" .\" Copyright (c) 2010 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -47,22 +47,29 @@ .Tn ACPI BIOS. .Pp -The driver handles brightness hotkeys and output switch hotkeys. +The driver handles brightness hotkeys and display switch hotkeys. In addition, the following .Xr sysctl 8 read/write variables are provided (when hardware support is available): .Bl -tag -width Ds -.It Va hw.acpi.acpivga0.policy -BIOS switch policy. -Accepted values range from 0 to 7. -For more information, refer to the documentation of the _DOS method, -in Section B.4.1 of the -.Tn ACPI -specification (revision 4.0a). +.It Va hw.acpi.acpivga0.bios_switch +BIOS output switching policy. +This boolean variable controls the behavior of the BIOS when a display +switch hotkey is pressed. +.Bl -tag -width xxx -compact +.It Sy 1 +the BIOS should automatically switch outputs, with no interaction from +.Nm . +.It Sy 0 +the BIOS should only notify +.Nm +of the desired output state changes. +.El .It Va hw.acpi.acpiout0.brightness Brightness level. -Typical values range from 0 to 100, but any integer value is accepted (the -driver uses the closest brightness level supported by the device). +This integer variable typically ranges from 0 to 100, but any integer value +is accepted (the driver uses the closest brightness level supported by the +device). .El .Pp Please note, however, that future versions of @@ -99,7 +106,17 @@ BIOSes implement only part of the .Tn ACPI video extensions. -In particular, display output switching often does not work. +In particular, display output switching via these extensions often does not +work. +For this reason, +.Nm +enables +.Va hw.acpi.acpivga0.bios_switch +by default. +If the display switch hotkey does not work with this default setting, try +setting +.Va hw.acpi.acpivga0.bios_switch +to 0. .Pp Brightness level should be controlled via .Xr wsconsctl 8 Index: src/sys/dev/acpi/acpi_display.c diff -u src/sys/dev/acpi/acpi_display.c:1.3 src/sys/dev/acpi/acpi_display.c:1.4 --- src/sys/dev/acpi/acpi_display.c:1.3 Tue Oct 26 22:27:44 2010 +++ src/sys/dev/acpi/acpi_display.c Thu Oct 28 21:45:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_display.c,v 1.3 2010/10/26 22:27:44 gsutre Exp $ */ +/* $NetBSD: acpi_display.c,v 1.4 2010/10/28 21:45:02 gsutre Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.3 2010/10/26 22:27:44 gsutre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.4 2010/10/28 21:45:02 gsutre Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -347,7 +347,10 @@ static void acpidisp_vga_sysctl_setup(struct acpidisp_vga_softc *); static void acpidisp_out_sysctl_setup(struct acpidisp_out_softc *); +#ifdef ACPI_DEBUG static int acpidisp_vga_sysctl_policy(SYSCTLFN_PROTO); +#endif +static int acpidisp_vga_sysctl_policy_output(SYSCTLFN_PROTO); #ifdef ACPI_DISP_SWITCH_SYSCTLS static int acpidisp_out_sysctl_status(SYSCTLFN_PROTO); static int acpidisp_out_sysctl_state(SYSCTLFN_PROTO); @@ -1114,11 +1117,19 @@ CTL_CREATE, CTL_EOL)) != 0) goto fail; +#ifdef ACPI_DEBUG (void)sysctl_createv(&asc->sc_log, 0, &rnode, NULL, - CTLFLAG_READWRITE | CTLFLAG_HEX, CTLTYPE_INT, "policy", - SYSCTL_DESCR("Current BIOS switch policy"), + CTLFLAG_READWRITE | CTLFLAG_HEX, CTLTYPE_INT, "bios_policy", + SYSCTL_DESCR("Current BIOS switch policies (debug)"), acpidisp_vga_sysctl_policy, 0, asc, 0, CTL_CREATE, CTL_EOL); +#endif + + (void)sysctl_createv(&asc->sc_log, 0, &rnode, NULL, + CTLFLAG_READWRITE, CTLTYPE_BOOL, "bios_switch", + SYSCTL_DESCR("Current BIOS output switching policy"), + acpidisp_vga_sysctl_policy_output, 0, asc, 0, + CTL_CREATE, CTL_EOL); } return; @@ -1202,6 +1213,7 @@ * Sysctl callbacks. */ +#ifdef ACPI_DEBUG static int acpidisp_vga_sysctl_policy(SYSCTLFN_ARGS) { @@ -1232,6 +1244,38 @@ return error; } +#endif + +static int +acpidisp_vga_sysctl_policy_output(SYSCTLFN_ARGS) +{ + struct sysctlnode node; + struct acpidisp_vga_softc *asc; + bool val; + int error; + + node = *rnode; + asc = (struct acpidisp_vga_softc *)node.sysctl_data; + + mutex_enter(&asc->sc_mtx); + val = (asc->sc_policy.fmt.output == ACPI_DISP_POLICY_OUTPUT_AUTO); + mutex_exit(&asc->sc_mtx); + + node.sysctl_data = &val; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + if (error || newp == NULL) + return error; + + mutex_enter(&asc->sc_mtx); + if (val) + asc->sc_policy.fmt.output = ACPI_DISP_POLICY_OUTPUT_AUTO; + else + asc->sc_policy.fmt.output = ACPI_DISP_POLICY_OUTPUT_NORMAL; + error = acpidisp_set_policy(asc, asc->sc_policy.raw); + mutex_exit(&asc->sc_mtx); + + return error; +} #ifdef ACPI_DISP_SWITCH_SYSCTLS static int