Index: dev/acpi/acpi_display.c =================================================================== RCS file: /cvsroot/src/sys/dev/acpi/acpi_display.c,v retrieving revision 1.15 diff -p -u -r1.15 acpi_display.c --- dev/acpi/acpi_display.c 3 Apr 2016 10:32:47 -0000 1.15 +++ dev/acpi/acpi_display.c 29 Dec 2016 05:21:38 -0000 @@ -353,6 +353,7 @@ static int acpidisp_out_sysctl_status(SY static int acpidisp_out_sysctl_state(SYSCTLFN_PROTO); #endif static int acpidisp_out_sysctl_brightness(SYSCTLFN_PROTO); +static int acpidisp_out_sysctl_levels(SYSCTLFN_PROTO); static struct acpidisp_odinfo * acpidisp_init_odinfo(const struct acpidisp_vga_softc *); @@ -1183,6 +1184,12 @@ acpidisp_out_sysctl_setup(struct acpidis SYSCTL_DESCR("Current brightness level"), acpidisp_out_sysctl_brightness, 0, (void *)osc, 0, CTL_CREATE, CTL_EOL); + + (void)sysctl_createv(&osc->sc_log, 0, &rnode, NULL, + CTLFLAG_READONLY, CTLTYPE_STRING, "levels", + SYSCTL_DESCR("Brightness levels"), + acpidisp_out_sysctl_levels, 0, (void *)osc, 0, + CTL_CREATE, CTL_EOL); } #ifdef ACPI_DISP_SWITCH_SYSCTLS @@ -1381,6 +1388,51 @@ acpidisp_out_sysctl_brightness(SYSCTLFN_ return error; } +static int +acpidisp_out_sysctl_levels(SYSCTLFN_ARGS) +{ + struct acpidisp_out_softc *osc; + struct acpidisp_brctl *bc; + char buf[10], *where; + size_t len, left, needed; + const char *sep; + int i, error = 0; + + if (newp != NULL) + return EPERM; + if (namelen != 0 || oldlenp == NULL) + return EINVAL; + + osc = rnode->sysctl_data; + bc = osc->sc_brctl; + + if (bc == NULL) + return EINVAL; + + where = oldp; + left = *oldlenp; + needed = 0; + sep = ""; + for (i = 0; i < bc->bc_level_count; i++) { + len = snprintf(buf, sizeof(buf), "%s%u", + sep, bc->bc_level[i]); + sep = " "; + needed += len; + if (oldp == NULL || error) + continue; + if (left < len + 1) { + error = ENOMEM; + } else { + error = copyout(buf, where, len + 1); + where += len; + left -= len; + } + } + *oldlenp = needed; + + return error; +} + /* * Initialization of acpidisp_odinfo (_DOD) and acpidisp_brctl (_BCL). */