Thu Oct 28 21:45:02 2010 UTC ()
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@


(gsutre)
diff -r1.2 -r1.3 src/share/man/man4/acpivga.4
diff -r1.3 -r1.4 src/sys/dev/acpi/acpi_display.c

cvs diff -r1.2 -r1.3 src/share/man/man4/acpivga.4 (expand / switch to unified diff)

--- src/share/man/man4/acpivga.4 2010/10/28 14:36:04 1.2
+++ src/share/man/man4/acpivga.4 2010/10/28 21:45:02 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: acpivga.4,v 1.2 2010/10/28 14:36:04 jruoho Exp $ 1.\" $NetBSD: acpivga.4,v 1.3 2010/10/28 21:45:02 gsutre Exp $
2.\" 2.\"
3.\" Copyright (c) 2010 The NetBSD Foundation, Inc. 3.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 14.\"
@@ -37,42 +37,49 @@ @@ -37,42 +37,49 @@
37The 37The
38.Nm 38.Nm
39driver provides generic support for brightness control and output switching, 39driver provides generic support for brightness control and output switching,
40through 40through
41.Tn ACPI 41.Tn ACPI
42video extensions. 42video extensions.
43The 43The
44.Tn ACPI 44.Tn ACPI
45specification requires that systems containing a built-in display adapter 45specification requires that systems containing a built-in display adapter
46implement these extensions in their 46implement these extensions in their
47.Tn ACPI 47.Tn ACPI
48BIOS. 48BIOS.
49.Pp 49.Pp
50The driver handles brightness hotkeys and output switch hotkeys. 50The driver handles brightness hotkeys and display switch hotkeys.
51In addition, the following 51In addition, the following
52.Xr sysctl 8 52.Xr sysctl 8
53read/write variables are provided (when hardware support is available): 53read/write variables are provided (when hardware support is available):
54.Bl -tag -width Ds 54.Bl -tag -width Ds
55.It Va hw.acpi.acpivga0.policy 55.It Va hw.acpi.acpivga0.bios_switch
56BIOS switch policy. 56BIOS output switching policy.
57Accepted values range from 0 to 7. 57This boolean variable controls the behavior of the BIOS when a display
58For more information, refer to the documentation of the _DOS method, 58switch hotkey is pressed.
59in Section B.4.1 of the 59.Bl -tag -width xxx -compact
60.Tn ACPI 60.It Sy 1
61specification (revision 4.0a). 61the BIOS should automatically switch outputs, with no interaction from
 62.Nm .
 63.It Sy 0
 64the BIOS should only notify
 65.Nm
 66of the desired output state changes.
 67.El
62.It Va hw.acpi.acpiout0.brightness 68.It Va hw.acpi.acpiout0.brightness
63Brightness level. 69Brightness level.
64Typical values range from 0 to 100, but any integer value is accepted (the 70This integer variable typically ranges from 0 to 100, but any integer value
65driver uses the closest brightness level supported by the device). 71is accepted (the driver uses the closest brightness level supported by the
 72device).
66.El 73.El
67.Pp 74.Pp
68Please note, however, that future versions of 75Please note, however, that future versions of
69.Nm 76.Nm
70may remove these 77may remove these
71.Xr sysctl 8 78.Xr sysctl 8
72variables without prior notice. 79variables without prior notice.
73.Sh SEE ALSO 80.Sh SEE ALSO
74.Xr acpi 4 , 81.Xr acpi 4 ,
75.Xr vga 4 , 82.Xr vga 4 ,
76.Xr sysctl 8 83.Xr sysctl 8
77.Rs 84.Rs
78.%A Microsoft Corporation 85.%A Microsoft Corporation
@@ -89,19 +96,29 @@ driver appeared in @@ -89,19 +96,29 @@ driver appeared in
89.Sh AUTHORS 96.Sh AUTHORS
90.An Gr\('egoire Sutre 97.An Gr\('egoire Sutre
91.Aq gsutre@NetBSD.org 98.Aq gsutre@NetBSD.org
92.Sh CAVEATS 99.Sh CAVEATS
93The 100The
94.Nm 101.Nm
95driver only supports PCI/PCI-X/PCI-E display adapters. 102driver only supports PCI/PCI-X/PCI-E display adapters.
96.Pp 103.Pp
97Many 104Many
98.Tn ACPI 105.Tn ACPI
99BIOSes implement only part of the 106BIOSes implement only part of the
100.Tn ACPI 107.Tn ACPI
101video extensions. 108video extensions.
102In particular, display output switching often does not work. 109In particular, display output switching via these extensions often does not
 110work.
 111For this reason,
 112.Nm
 113enables
 114.Va hw.acpi.acpivga0.bios_switch
 115by default.
 116If the display switch hotkey does not work with this default setting, try
 117setting
 118.Va hw.acpi.acpivga0.bios_switch
 119to 0.
103.Pp 120.Pp
104Brightness level should be controlled via 121Brightness level should be controlled via
105.Xr wsconsctl 8 122.Xr wsconsctl 8
106instead of 123instead of
107.Xr sysctl 8 . 124.Xr sysctl 8 .

cvs diff -r1.3 -r1.4 src/sys/dev/acpi/acpi_display.c (expand / switch to unified diff)

--- src/sys/dev/acpi/acpi_display.c 2010/10/26 22:27:44 1.3
+++ src/sys/dev/acpi/acpi_display.c 2010/10/28 21:45:02 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_display.c,v 1.3 2010/10/26 22:27:44 gsutre Exp $ */ 1/* $NetBSD: acpi_display.c,v 1.4 2010/10/28 21:45:02 gsutre Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Gregoire Sutre. 8 * by Gregoire Sutre.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -56,27 +56,27 @@ @@ -56,27 +56,27 @@
56 * (sysctl). The ACPI display adapter's mutex is shared with all ACPI display 56 * (sysctl). The ACPI display adapter's mutex is shared with all ACPI display
57 * output devices attached to it. 57 * output devices attached to it.
58 * 58 *
59 * The mutex only prevents undesired interleavings of ACPI notify handlers, 59 * The mutex only prevents undesired interleavings of ACPI notify handlers,
60 * sysctl callbacks, and pmf(9) suspend/resume routines. Race conditions with 60 * sysctl callbacks, and pmf(9) suspend/resume routines. Race conditions with
61 * autoconf(9) detachment routines could, in theory, still occur. 61 * autoconf(9) detachment routines could, in theory, still occur.
62 * 62 *
63 * The array of connected output devices (sc_odinfo) is, after attachment, only 63 * The array of connected output devices (sc_odinfo) is, after attachment, only
64 * used in ACPI notify handler callbacks. Since two such callbacks cannot be 64 * used in ACPI notify handler callbacks. Since two such callbacks cannot be
65 * running simultaneously, this information does not need protection. 65 * running simultaneously, this information does not need protection.
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.3 2010/10/26 22:27:44 gsutre Exp $"); 69__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.4 2010/10/28 21:45:02 gsutre Exp $");
70 70
71#include <sys/param.h> 71#include <sys/param.h>
72#include <sys/device.h> 72#include <sys/device.h>
73#include <sys/kmem.h> 73#include <sys/kmem.h>
74#include <sys/module.h> 74#include <sys/module.h>
75#include <sys/mutex.h> 75#include <sys/mutex.h>
76#include <sys/sysctl.h> 76#include <sys/sysctl.h>
77#include <sys/systm.h> 77#include <sys/systm.h>
78 78
79#include <dev/pci/pcireg.h> 79#include <dev/pci/pcireg.h>
80#include <dev/pci/pcidevs.h> 80#include <dev/pci/pcidevs.h>
81 81
82#include <dev/acpi/acpireg.h> 82#include <dev/acpi/acpireg.h>
@@ -337,27 +337,30 @@ static void acpidisp_out_print_capabilit @@ -337,27 +337,30 @@ static void acpidisp_out_print_capabilit
337 337
338static void acpidisp_vga_notify_handler(ACPI_HANDLE, uint32_t, void *); 338static void acpidisp_vga_notify_handler(ACPI_HANDLE, uint32_t, void *);
339static void acpidisp_out_notify_handler(ACPI_HANDLE, uint32_t, void *); 339static void acpidisp_out_notify_handler(ACPI_HANDLE, uint32_t, void *);
340 340
341static void acpidisp_vga_cycle_output_device_callback(void *); 341static void acpidisp_vga_cycle_output_device_callback(void *);
342static void acpidisp_vga_output_device_change_callback(void *); 342static void acpidisp_vga_output_device_change_callback(void *);
343static void acpidisp_out_increase_brightness_callback(void *); 343static void acpidisp_out_increase_brightness_callback(void *);
344static void acpidisp_out_decrease_brightness_callback(void *); 344static void acpidisp_out_decrease_brightness_callback(void *);
345static void acpidisp_out_cycle_brightness_callback(void *); 345static void acpidisp_out_cycle_brightness_callback(void *);
346static void acpidisp_out_zero_brightness_callback(void *); 346static void acpidisp_out_zero_brightness_callback(void *);
347 347
348static void acpidisp_vga_sysctl_setup(struct acpidisp_vga_softc *); 348static void acpidisp_vga_sysctl_setup(struct acpidisp_vga_softc *);
349static void acpidisp_out_sysctl_setup(struct acpidisp_out_softc *); 349static void acpidisp_out_sysctl_setup(struct acpidisp_out_softc *);
 350#ifdef ACPI_DEBUG
350static int acpidisp_vga_sysctl_policy(SYSCTLFN_PROTO); 351static int acpidisp_vga_sysctl_policy(SYSCTLFN_PROTO);
 352#endif
 353static int acpidisp_vga_sysctl_policy_output(SYSCTLFN_PROTO);
351#ifdef ACPI_DISP_SWITCH_SYSCTLS 354#ifdef ACPI_DISP_SWITCH_SYSCTLS
352static int acpidisp_out_sysctl_status(SYSCTLFN_PROTO); 355static int acpidisp_out_sysctl_status(SYSCTLFN_PROTO);
353static int acpidisp_out_sysctl_state(SYSCTLFN_PROTO); 356static int acpidisp_out_sysctl_state(SYSCTLFN_PROTO);
354#endif 357#endif
355static int acpidisp_out_sysctl_brightness(SYSCTLFN_PROTO); 358static int acpidisp_out_sysctl_brightness(SYSCTLFN_PROTO);
356 359
357static struct acpidisp_odinfo * 360static struct acpidisp_odinfo *
358 acpidisp_init_odinfo(const struct acpidisp_vga_softc *); 361 acpidisp_init_odinfo(const struct acpidisp_vga_softc *);
359static void acpidisp_vga_bind_outdevs(struct acpidisp_vga_softc *); 362static void acpidisp_vga_bind_outdevs(struct acpidisp_vga_softc *);
360static struct acpidisp_brctl * 363static struct acpidisp_brctl *
361 acpidisp_init_brctl(const struct acpidisp_out_softc *); 364 acpidisp_init_brctl(const struct acpidisp_out_softc *);
362 365
363static int acpidisp_set_policy(const struct acpidisp_vga_softc *, 366static int acpidisp_set_policy(const struct acpidisp_vga_softc *,
@@ -1104,31 +1107,39 @@ acpidisp_vga_sysctl_setup(struct acpidis @@ -1104,31 +1107,39 @@ acpidisp_vga_sysctl_setup(struct acpidis
1104 if ((sysctl_createv(&asc->sc_log, 0, &rnode, &rnode, 1107 if ((sysctl_createv(&asc->sc_log, 0, &rnode, &rnode,
1105 0, CTLTYPE_NODE, "acpi", NULL, 1108 0, CTLTYPE_NODE, "acpi", NULL,
1106 NULL, 0, NULL, 0, 1109 NULL, 0, NULL, 0,
1107 CTL_CREATE, CTL_EOL)) != 0) 1110 CTL_CREATE, CTL_EOL)) != 0)
1108 goto fail; 1111 goto fail;
1109 1112
1110 if ((sysctl_createv(&asc->sc_log, 0, &rnode, &rnode, 1113 if ((sysctl_createv(&asc->sc_log, 0, &rnode, &rnode,
1111 0, CTLTYPE_NODE, device_xname(asc->sc_dev), 1114 0, CTLTYPE_NODE, device_xname(asc->sc_dev),
1112 SYSCTL_DESCR("ACPI display adapter controls"), 1115 SYSCTL_DESCR("ACPI display adapter controls"),
1113 NULL, 0, NULL, 0, 1116 NULL, 0, NULL, 0,
1114 CTL_CREATE, CTL_EOL)) != 0) 1117 CTL_CREATE, CTL_EOL)) != 0)
1115 goto fail; 1118 goto fail;
1116 1119
 1120#ifdef ACPI_DEBUG
1117 (void)sysctl_createv(&asc->sc_log, 0, &rnode, NULL, 1121 (void)sysctl_createv(&asc->sc_log, 0, &rnode, NULL,
1118 CTLFLAG_READWRITE | CTLFLAG_HEX, CTLTYPE_INT, "policy", 1122 CTLFLAG_READWRITE | CTLFLAG_HEX, CTLTYPE_INT, "bios_policy",
1119 SYSCTL_DESCR("Current BIOS switch policy"), 1123 SYSCTL_DESCR("Current BIOS switch policies (debug)"),
1120 acpidisp_vga_sysctl_policy, 0, asc, 0, 1124 acpidisp_vga_sysctl_policy, 0, asc, 0,
1121 CTL_CREATE, CTL_EOL); 1125 CTL_CREATE, CTL_EOL);
 1126#endif
 1127
 1128 (void)sysctl_createv(&asc->sc_log, 0, &rnode, NULL,
 1129 CTLFLAG_READWRITE, CTLTYPE_BOOL, "bios_switch",
 1130 SYSCTL_DESCR("Current BIOS output switching policy"),
 1131 acpidisp_vga_sysctl_policy_output, 0, asc, 0,
 1132 CTL_CREATE, CTL_EOL);
1122 } 1133 }
1123 1134
1124 return; 1135 return;
1125 1136
1126 fail: 1137 fail:
1127 aprint_error_dev(asc->sc_dev, "couldn't add sysctl nodes\n"); 1138 aprint_error_dev(asc->sc_dev, "couldn't add sysctl nodes\n");
1128} 1139}
1129 1140
1130static void 1141static void
1131acpidisp_out_sysctl_setup(struct acpidisp_out_softc *osc) 1142acpidisp_out_sysctl_setup(struct acpidisp_out_softc *osc)
1132{ 1143{
1133 const struct sysctlnode *rnode; 1144 const struct sysctlnode *rnode;
1134 1145
@@ -1192,26 +1203,27 @@ acpidisp_out_sysctl_setup(struct acpidis @@ -1192,26 +1203,27 @@ acpidisp_out_sysctl_setup(struct acpidis
1192 } 1203 }
1193#endif 1204#endif
1194 1205
1195 return; 1206 return;
1196 1207
1197 fail: 1208 fail:
1198 aprint_error_dev(osc->sc_dev, "couldn't add sysctl nodes\n"); 1209 aprint_error_dev(osc->sc_dev, "couldn't add sysctl nodes\n");
1199} 1210}
1200 1211
1201/* 1212/*
1202 * Sysctl callbacks. 1213 * Sysctl callbacks.
1203 */ 1214 */
1204 1215
 1216#ifdef ACPI_DEBUG
1205static int 1217static int
1206acpidisp_vga_sysctl_policy(SYSCTLFN_ARGS) 1218acpidisp_vga_sysctl_policy(SYSCTLFN_ARGS)
1207{ 1219{
1208 struct sysctlnode node; 1220 struct sysctlnode node;
1209 struct acpidisp_vga_softc *asc; 1221 struct acpidisp_vga_softc *asc;
1210 uint32_t val; 1222 uint32_t val;
1211 int error; 1223 int error;
1212 1224
1213 node = *rnode; 1225 node = *rnode;
1214 asc = (struct acpidisp_vga_softc *)node.sysctl_data; 1226 asc = (struct acpidisp_vga_softc *)node.sysctl_data;
1215 1227
1216 mutex_enter(&asc->sc_mtx); 1228 mutex_enter(&asc->sc_mtx);
1217 val = (uint32_t)asc->sc_policy.raw; 1229 val = (uint32_t)asc->sc_policy.raw;
@@ -1222,26 +1234,58 @@ acpidisp_vga_sysctl_policy(SYSCTLFN_ARGS @@ -1222,26 +1234,58 @@ acpidisp_vga_sysctl_policy(SYSCTLFN_ARGS
1222 if (error || newp == NULL) 1234 if (error || newp == NULL)
1223 return error; 1235 return error;
1224 1236
1225 if (val > 0x7) 1237 if (val > 0x7)
1226 return EINVAL; 1238 return EINVAL;
1227 1239
1228 mutex_enter(&asc->sc_mtx); 1240 mutex_enter(&asc->sc_mtx);
1229 asc->sc_policy.raw = (uint8_t)val; 1241 asc->sc_policy.raw = (uint8_t)val;
1230 error = acpidisp_set_policy(asc, asc->sc_policy.raw); 1242 error = acpidisp_set_policy(asc, asc->sc_policy.raw);
1231 mutex_exit(&asc->sc_mtx); 1243 mutex_exit(&asc->sc_mtx);
1232 1244
1233 return error; 1245 return error;
1234} 1246}
 1247#endif
 1248
 1249static int
 1250acpidisp_vga_sysctl_policy_output(SYSCTLFN_ARGS)
 1251{
 1252 struct sysctlnode node;
 1253 struct acpidisp_vga_softc *asc;
 1254 bool val;
 1255 int error;
 1256
 1257 node = *rnode;
 1258 asc = (struct acpidisp_vga_softc *)node.sysctl_data;
 1259
 1260 mutex_enter(&asc->sc_mtx);
 1261 val = (asc->sc_policy.fmt.output == ACPI_DISP_POLICY_OUTPUT_AUTO);
 1262 mutex_exit(&asc->sc_mtx);
 1263
 1264 node.sysctl_data = &val;
 1265 error = sysctl_lookup(SYSCTLFN_CALL(&node));
 1266 if (error || newp == NULL)
 1267 return error;
 1268
 1269 mutex_enter(&asc->sc_mtx);
 1270 if (val)
 1271 asc->sc_policy.fmt.output = ACPI_DISP_POLICY_OUTPUT_AUTO;
 1272 else
 1273 asc->sc_policy.fmt.output = ACPI_DISP_POLICY_OUTPUT_NORMAL;
 1274 error = acpidisp_set_policy(asc, asc->sc_policy.raw);
 1275 mutex_exit(&asc->sc_mtx);
 1276
 1277 return error;
 1278}
1235 1279
1236#ifdef ACPI_DISP_SWITCH_SYSCTLS 1280#ifdef ACPI_DISP_SWITCH_SYSCTLS
1237static int 1281static int
1238acpidisp_out_sysctl_status(SYSCTLFN_ARGS) 1282acpidisp_out_sysctl_status(SYSCTLFN_ARGS)
1239{ 1283{
1240 struct sysctlnode node; 1284 struct sysctlnode node;
1241 struct acpidisp_out_softc *osc; 1285 struct acpidisp_out_softc *osc;
1242 uint32_t val; 1286 uint32_t val;
1243 int error; 1287 int error;
1244 1288
1245 node = *rnode; 1289 node = *rnode;
1246 osc = (struct acpidisp_out_softc *)node.sysctl_data; 1290 osc = (struct acpidisp_out_softc *)node.sysctl_data;
1247 1291