Lines Matching +full:brightness +full:- +full:levels

1 /*-
2 * Copyright (c) 2002-2003 Taku YAMAMOTO <taku@cent.saitama-u.ac.jp>
152 (((1 << DOD_HEAD_ID_BITS) - 1) << DOD_HEAD_ID_SHIFT)
201 * (the video "bus"). The 'video_output' lock protects per-output
315 sc->evdev = evdev_alloc(); in acpi_video_attach()
316 evdev_set_name(sc->evdev, device_get_desc(dev)); in acpi_video_attach()
317 evdev_set_phys(sc->evdev, device_get_nameunit(dev)); in acpi_video_attach()
318 evdev_set_id(sc->evdev, BUS_HOST, 0, 0, 1); in acpi_video_attach()
319 evdev_support_event(sc->evdev, EV_SYN); in acpi_video_attach()
320 evdev_support_event(sc->evdev, EV_KEY); in acpi_video_attach()
322 evdev_support_key(sc->evdev, acpi_video_evdev_map[i].key); in acpi_video_attach()
324 if (evdev_register(sc->evdev) != 0) in acpi_video_attach()
331 SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO, in acpi_video_attach()
337 sc->device = dev; in acpi_video_attach()
338 sc->handle = acpi_get_handle(dev); in acpi_video_attach()
339 STAILQ_INIT(&sc->vid_outputs); in acpi_video_attach()
341 AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, in acpi_video_attach()
343 sc->vid_pwr_evh = EVENTHANDLER_REGISTER(power_profile_change, in acpi_video_attach()
352 * brightness levels. in acpi_video_attach()
354 vid_set_switch_policy(sc->handle, DOS_SWITCH_BY_OSPM | in acpi_video_attach()
370 vid_set_switch_policy(sc->handle, DOS_SWITCH_BY_BIOS); in acpi_video_detach()
371 EVENTHANDLER_DEREGISTER(power_profile_change, sc->vid_pwr_evh); in acpi_video_detach()
372 AcpiRemoveNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, in acpi_video_detach()
376 STAILQ_FOREACH_SAFE(vo, &sc->vid_outputs, vo_next, vn) { in acpi_video_detach()
382 evdev_free(sc->evdev); in acpi_video_detach()
397 /* Restore brightness level */ in acpi_video_resume()
400 STAILQ_FOREACH_SAFE(vo, &sc->vid_outputs, vo_next, vn) { in acpi_video_resume()
401 if ((vo->adr & DOD_DEVID_MASK_FULL) != DOD_DEVID_LCD && in acpi_video_resume()
402 (vo->adr & DOD_DEVID_MASK) != DOD_DEVID_INTDFP) in acpi_video_resume()
405 if ((vo_get_device_status(vo->handle) & DCS_ACTIVE) == 0) in acpi_video_resume()
409 if (level != -1) in acpi_video_resume()
424 vid_set_switch_policy(sc->handle, DOS_SWITCH_BY_BIOS); in acpi_video_shutdown()
451 STAILQ_FOREACH(vo, &sc->vid_outputs, vo_next) { in acpi_video_notify_handler()
452 dss = vo_get_graphics_state(vo->handle); in acpi_video_notify_handler()
453 dcs = vo_get_device_status(vo->handle); in acpi_video_notify_handler()
461 lasthand = vo->handle; in acpi_video_notify_handler()
471 STAILQ_FOREACH(vo, &sc->vid_outputs, vo_next) in acpi_video_notify_handler()
472 vo->handle = NULL; in acpi_video_notify_handler()
474 STAILQ_FOREACH_SAFE(vo, &sc->vid_outputs, vo_next, vo_tmp) { in acpi_video_notify_handler()
475 if (vo->handle == NULL) { in acpi_video_notify_handler()
476 STAILQ_REMOVE(&sc->vid_outputs, vo, in acpi_video_notify_handler()
488 device_printf(sc->device, "unknown notify event 0x%x\n", in acpi_video_notify_handler()
495 acpi_video_push_evdev_event(sc->evdev, notify); in acpi_video_notify_handler()
515 STAILQ_FOREACH(vo, &sc->vid_outputs, vo_next) { in acpi_video_power_profile()
516 if (vo->vo_levels != NULL && vo->vo_brightness == -1) in acpi_video_power_profile()
519 vo->vo_economy : vo->vo_fullpower); in acpi_video_power_profile()
534 STAILQ_FOREACH(vo, &sc->vid_outputs, vo_next) { in acpi_video_bind_outputs_subr()
535 if (vo->adr == adr) { in acpi_video_bind_outputs_subr()
543 vo->evdev = sc->evdev; in acpi_video_bind_outputs_subr()
546 STAILQ_INSERT_TAIL(&sc->vid_outputs, vo, vo_next); in acpi_video_bind_outputs_subr()
555 vid_enum_outputs(sc->handle, acpi_video_bind_outputs_subr, sc); in acpi_video_bind_outputs()
583 desc = "TV/HDTV or Analog-Video Monitor"; in acpi_video_vo_init()
606 if (vn->vo_unit.num != n) in acpi_video_vo_init()
616 vo->handle = NULL; in acpi_video_vo_init()
617 vo->adr = adr; in acpi_video_vo_init()
618 vo->vo_unit.num = n; in acpi_video_vo_init()
619 vo->vo_hasbqc = -1; in acpi_video_vo_init()
620 vo->vo_level = -1; in acpi_video_vo_init()
621 vo->vo_brightness = -1; in acpi_video_vo_init()
622 vo->vo_fullpower = -1; /* TODO: override with tunables */ in acpi_video_vo_init()
623 vo->vo_economy = -1; in acpi_video_vo_init()
624 vo->vo_numlevels = 0; in acpi_video_vo_init()
625 vo->vo_levels = NULL; in acpi_video_vo_init()
628 vo->vo_fullpower = x; in acpi_video_vo_init()
631 vo->vo_economy = x; in acpi_video_vo_init()
633 sysctl_ctx_init(&vo->vo_sysctl_ctx); in acpi_video_vo_init()
639 vo->vo_sysctl_tree = in acpi_video_vo_init()
640 SYSCTL_ADD_NODE(&vo->vo_sysctl_ctx, in acpi_video_vo_init()
644 if (vo->vo_sysctl_tree != NULL) { in acpi_video_vo_init()
645 SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx, in acpi_video_vo_init()
646 SYSCTL_CHILDREN(vo->vo_sysctl_tree), in acpi_video_vo_init()
651 SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx, in acpi_video_vo_init()
652 SYSCTL_CHILDREN(vo->vo_sysctl_tree), in acpi_video_vo_init()
653 OID_AUTO, "brightness", in acpi_video_vo_init()
656 "current brightness level"); in acpi_video_vo_init()
657 SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx, in acpi_video_vo_init()
658 SYSCTL_CHILDREN(vo->vo_sysctl_tree), in acpi_video_vo_init()
664 SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx, in acpi_video_vo_init()
665 SYSCTL_CHILDREN(vo->vo_sysctl_tree), in acpi_video_vo_init()
671 SYSCTL_ADD_PROC(&vo->vo_sysctl_ctx, in acpi_video_vo_init()
672 SYSCTL_CHILDREN(vo->vo_sysctl_tree), in acpi_video_vo_init()
673 OID_AUTO, "levels", in acpi_video_vo_init()
676 "supported brightness levels"); in acpi_video_vo_init()
689 printf(" (Non-VGA output device whose power " in acpi_video_vo_init()
702 if (vo->vo_levels != NULL) { in acpi_video_vo_bind()
703 AcpiRemoveNotifyHandler(vo->handle, ACPI_DEVICE_NOTIFY, in acpi_video_vo_bind()
705 AcpiOsFree(vo->vo_levels); in acpi_video_vo_bind()
706 vo->vo_levels = NULL; in acpi_video_vo_bind()
708 vo->handle = handle; in acpi_video_vo_bind()
709 vo->vo_numlevels = vo_get_brightness_levels(handle, &vo->vo_levels); in acpi_video_vo_bind()
710 if (vo->vo_numlevels >= 2) { in acpi_video_vo_bind()
711 if (vo->vo_fullpower == -1 || in acpi_video_vo_bind()
712 acpi_video_vo_check_level(vo, vo->vo_fullpower) != 0) { in acpi_video_vo_bind()
713 /* XXX - can't deal with rebinding... */ in acpi_video_vo_bind()
714 vo->vo_fullpower = vo->vo_levels[BCL_FULLPOWER]; in acpi_video_vo_bind()
716 if (vo->vo_economy == -1 || in acpi_video_vo_bind()
717 acpi_video_vo_check_level(vo, vo->vo_economy) != 0) { in acpi_video_vo_bind()
718 /* XXX - see above. */ in acpi_video_vo_bind()
719 vo->vo_economy = vo->vo_levels[BCL_ECONOMY]; in acpi_video_vo_bind()
733 if (vo->vo_sysctl_tree != NULL) { in acpi_video_vo_destroy()
734 vo->vo_sysctl_tree = NULL; in acpi_video_vo_destroy()
735 sysctl_ctx_free(&vo->vo_sysctl_ctx); in acpi_video_vo_destroy()
737 if (vo->vo_levels != NULL) { in acpi_video_vo_destroy()
738 AcpiRemoveNotifyHandler(vo->handle, ACPI_DEVICE_NOTIFY, in acpi_video_vo_destroy()
740 AcpiOsFree(vo->vo_levels); in acpi_video_vo_destroy()
743 switch (vo->adr & DOD_DEVID_MASK) { in acpi_video_vo_destroy()
745 if ((vo->adr & DOD_DEVID_MASK_FULL) == DOD_DEVID_LCD) in acpi_video_vo_destroy()
772 if (vo->vo_levels == NULL) in acpi_video_vo_check_level()
774 for (i = 0; i < vo->vo_numlevels; i++) in acpi_video_vo_check_level()
775 if (vo->vo_levels[i] == level) in acpi_video_vo_check_level()
788 if (vo->handle != handle) in acpi_video_vo_notify_handler()
793 if (vo->vo_numlevels <= 3) in acpi_video_vo_notify_handler()
800 if (vo->vo_levels == NULL) in acpi_video_vo_notify_handler()
815 for (i = 2; i < vo->vo_numlevels; i++) in acpi_video_vo_notify_handler()
816 if (vo->vo_levels[i] == level) { in acpi_video_vo_notify_handler()
817 new_level = vo->vo_numlevels > i + 1 ? in acpi_video_vo_notify_handler()
818 vo->vo_levels[i + 1] : vo->vo_levels[2]; in acpi_video_vo_notify_handler()
824 for (i = 0; i < vo->vo_numlevels; i++) { in acpi_video_vo_notify_handler()
825 j = vo->vo_levels[i]; in acpi_video_vo_notify_handler()
838 for (i = 0; i < vo->vo_numlevels; i++) in acpi_video_vo_notify_handler()
839 if (vo->vo_levels[i] == 0) { in acpi_video_vo_notify_handler()
850 vo->vo_brightness = new_level; in acpi_video_vo_notify_handler()
853 acpi_video_push_evdev_event(vo->evdev, notify); in acpi_video_vo_notify_handler()
871 if (vo->handle == NULL) in acpi_video_vo_active_sysctl()
874 state = (vo_get_device_status(vo->handle) & DCS_ACTIVE) ? 1 : 0; in acpi_video_vo_active_sysctl()
876 if (err != 0 || req->newptr == NULL) in acpi_video_vo_active_sysctl()
878 vo_set_device_state(vo->handle, in acpi_video_vo_active_sysctl()
894 if (vo->handle == NULL) { in acpi_video_vo_bright_sysctl()
898 if (vo->vo_levels == NULL) { in acpi_video_vo_bright_sysctl()
904 vo->vo_economy : vo->vo_fullpower; in acpi_video_vo_bright_sysctl()
905 level = vo->vo_brightness; in acpi_video_vo_bright_sysctl()
906 if (level == -1) in acpi_video_vo_bright_sysctl()
910 if (err != 0 || req->newptr == NULL) in acpi_video_vo_bright_sysctl()
912 if (level < -1 || level > 100) { in acpi_video_vo_bright_sysctl()
917 if (level != -1 && (err = acpi_video_vo_check_level(vo, level))) in acpi_video_vo_bright_sysctl()
919 vo->vo_brightness = level; in acpi_video_vo_bright_sysctl()
920 vo_set_brightness(vo, (level == -1) ? preset : level); in acpi_video_vo_bright_sysctl()
935 if (vo->handle == NULL) { in acpi_video_vo_presets_sysctl()
939 if (vo->vo_levels == NULL) { in acpi_video_vo_presets_sysctl()
944 &vo->vo_economy : &vo->vo_fullpower; in acpi_video_vo_presets_sysctl()
947 if (err != 0 || req->newptr == NULL) in acpi_video_vo_presets_sysctl()
949 if (level < -1 || level > 100) { in acpi_video_vo_presets_sysctl()
953 if (level == -1) { in acpi_video_vo_presets_sysctl()
956 level = vo->vo_levels[i]; in acpi_video_vo_presets_sysctl()
960 if (vo->vo_brightness == -1 && (power_profile_get_state() == arg2)) in acpi_video_vo_presets_sysctl()
978 if (vo->vo_levels == NULL) { in acpi_video_vo_levels_sysctl()
982 if (req->newptr != NULL) { in acpi_video_vo_levels_sysctl()
986 err = sysctl_handle_opaque(oidp, vo->vo_levels, in acpi_video_vo_levels_sysctl()
987 vo->vo_numlevels * sizeof(*vo->vo_levels), req); in acpi_video_vo_levels_sysctl()
1001 printf("can't evaluate %s._DOS - %s\n", in vid_set_switch_policy()
1027 for (i = 0; i < argset->dod_pkg->Package.Count; i++) { in vid_enum_outputs_subr()
1028 if (acpi_PkgInt32(argset->dod_pkg, i, &val) == 0 && in vid_enum_outputs_subr()
1031 argset->callback(handle, val, argset->context); in vid_enum_outputs_subr()
1032 argset->count++; in vid_enum_outputs_subr()
1054 printf("can't evaluate %s._DOD - %s\n", in vid_enum_outputs()
1056 argset.count = -1; in vid_enum_outputs()
1063 argset.count = -1; in vid_enum_outputs()
1067 argset.count = res->Package.Count; in vid_enum_outputs()
1077 printf("failed walking down %s - %s\n", in vid_enum_outputs()
1091 int num, i, n, *levels; in vo_get_brightness_levels() local
1098 printf("can't evaluate %s._BCL - %s\n", in vo_get_brightness_levels()
1108 num = res->Package.Count; in vo_get_brightness_levels()
1111 levels = AcpiOsAllocate(num * sizeof(*levels)); in vo_get_brightness_levels()
1112 if (levels == NULL) in vo_get_brightness_levels()
1115 if (acpi_PkgInt32(res, i, &levels[n]) == 0) in vo_get_brightness_levels()
1118 AcpiOsFree(levels); in vo_get_brightness_levels()
1121 *levelp = levels; in vo_get_brightness_levels()
1135 switch (vo->vo_hasbqc) { in vo_get_bqc()
1137 case -1: in vo_get_bqc()
1138 status = acpi_GetInteger(vo->handle, "_BQC", level); in vo_get_bqc()
1139 if (vo->vo_hasbqc == 1) in vo_get_bqc()
1141 vo->vo_hasbqc = status != AE_NOT_FOUND; in vo_get_bqc()
1142 if (vo->vo_hasbqc == 1) in vo_get_bqc()
1146 KASSERT(vo->vo_hasbqc == 0, in vo_get_bqc()
1147 ("bad vo_hasbqc state %d", vo->vo_hasbqc)); in vo_get_bqc()
1148 *level = vo->vo_level; in vo_get_bqc()
1163 printf("can't evaluate %s._BQC - %s\n", acpi_name(vo->handle), in vo_get_brightness()
1165 return (-1); in vo_get_brightness()
1168 return (-1); in vo_get_brightness()
1180 status = acpi_SetInteger(vo->handle, "_BCM", level); in vo_set_brightness()
1182 printf("can't evaluate %s._BCM - %s\n", in vo_set_brightness()
1183 acpi_name(vo->handle), AcpiFormatException(status)); in vo_set_brightness()
1185 vo->vo_level = level; in vo_set_brightness()
1188 devctl_notify("ACPI", "Video", "brightness", notify_buf); in vo_set_brightness()
1206 printf("can't evaluate %s._DCS - %s\n", in vo_get_device_status()
1230 printf("can't evaluate %s._DGS - %s\n", in vo_get_graphics_state()
1248 printf("can't evaluate %s._DSS - %s\n", in vo_set_device_state()