Lines Matching +full:rpm +full:- +full:proc
1 /*-
31 * Driver for extra ACPI-controlled gadgets found on ThinkPad laptops.
32 * Inspired by the ibm-acpi and tpb projects which implement these features
35 * acpi-ibm: <http://ibm-acpi.sourceforge.net/>
157 /* Device-specific register flags */
161 #define ABS(x) (((x) < 0)? -(x) : (x))
274 .description = "Fan level, 0-7 (recommended max), "
275 "8 (unthrottled, full-speed)",
296 * Per-model default list of event mask.
400 if (sc->led_busy)
403 sc->led_busy = 1;
404 sc->led_state = onoff;
415 acpi_ibm_sysctl_set(sc, ACPI_IBM_METHOD_THINKLIGHT, sc->led_state);
418 sc->led_busy = 0;
431 if (sc->mic_led_handle) {
441 status = AcpiEvaluateObject(sc->handle, "MMTS", &input, NULL);
443 sc->mic_led_state = arg;
481 sc->dev = dev;
482 sc->handle = acpi_get_handle(dev);
490 if (!(sc->ec_dev = devclass_get_device(ec_devclass, 0))) {
495 sc->ec_handle = acpi_get_handle(sc->ec_dev);
498 sc->evdev = evdev_alloc();
499 evdev_set_name(sc->evdev, device_get_desc(dev));
500 evdev_set_phys(sc->evdev, device_get_nameunit(dev));
501 evdev_set_id(sc->evdev, BUS_HOST, 0, 0, 1);
502 evdev_support_event(sc->evdev, EV_SYN);
503 evdev_support_event(sc->evdev, EV_KEY);
504 evdev_support_key(sc->evdev, KEY_BRIGHTNESSUP);
505 evdev_support_key(sc->evdev, KEY_BRIGHTNESSDOWN);
507 if (evdev_register(sc->evdev) != 0)
512 sc->sysctl_ctx = device_get_sysctl_ctx(dev);
513 sc->sysctl_tree = device_get_sysctl_tree(dev);
516 sc->events_mask_supported = ACPI_SUCCESS(acpi_GetInteger(sc->handle,
517 IBM_NAME_EVENTS_MASK_GET, &sc->events_initialmask));
519 if (sc->events_mask_supported) {
520 SYSCTL_ADD_UINT(sc->sysctl_ctx,
521 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "initialmask",
522 CTLFLAG_RD, &sc->events_initialmask, 0,
525 if (ACPI_SUCCESS (acpi_GetInteger(sc->handle, "MHKV", &hkey))) {
530 if (ACPI_FAILURE(acpi_GetInteger(sc->handle,
531 IBM_NAME_EVENTS_AVAILMASK, &sc->events_availmask)))
532 sc->events_availmask = 0xffffffff;
543 sc->events_availmask = 0xffffffff;
545 if (ACPI_SUCCESS(AcpiEvaluateObject (sc->handle,
547 sc->events_availmask = out_obj.Integer.Value;
554 sc->events_availmask = 0xffffffff;
556 SYSCTL_ADD_UINT(sc->sysctl_ctx,
557 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
559 &sc->events_availmask, 0, "Mask of supported events");
562 /* Hook up proc nodes */
568 SYSCTL_ADD_PROC(sc->sysctl_ctx,
569 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
575 SYSCTL_ADD_PROC(sc->sysctl_ctx,
576 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
586 SYSCTL_ADD_PROC(sc->sysctl_ctx,
587 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "thermal",
594 SYSCTL_ADD_PROC(sc->sysctl_ctx,
595 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "handlerevents",
602 AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
606 if (sc->light_set_supported)
607 sc->led_dev = led_create_state(ibm_led, sc, "thinklight",
608 (sc->light_val ? 1 : 0));
610 /* Enable per-model events. */
648 acpi_ibm_sysctl_set(sc, ACPI_IBM_METHOD_EVENTMASK, sc->events_initialmask);
651 AcpiRemoveNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, acpi_ibm_notify);
653 if (sc->led_dev != NULL)
654 led_destroy(sc->led_dev);
657 evdev_free(sc->evdev);
684 acpi_ibm_mic_led_set(sc, sc->mic_led_state);
707 status = AcpiEvaluateObject(sc->handle,
728 sc = (struct acpi_ibm_softc *)oidp->oid_arg1;
729 function = oidp->oid_arg2;
737 if (error != 0 || req->newptr == NULL)
759 acpi_GetInteger(sc->handle, IBM_NAME_EVENTS_STATUS_GET, &val);
763 if (sc->events_mask_supported)
764 acpi_GetInteger(sc->handle, IBM_NAME_EVENTS_MASK_GET, &val);
772 * +--+--+-+-+-+-+-+-+-+-+-+-+
774 * +--+--+-+-+-+-+-+-+-+-+-+-+
776 * | | | | | | | | | | | +- Home Button
777 * | | | | | | | | | | +--- Search Button
778 * | | | | | | | | | +----- Mail Button
779 * | | | | | | | | +------- Thinkpad Button
780 * | | | | | | | +--------- Zoom (Fn + Space)
781 * | | | | | | +----------- WLAN Button
782 * | | | | | +------------- Video Button
783 * | | | | +--------------- Hibernate Button
784 * | | | +----------------- Thinklight Button
785 * | | +------------------- Screen expand (Fn + F8)
786 * | +--------------------- Brightness
787 * +------------------------ Volume/Mute
805 ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, &val_ec, 1);
810 ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
815 ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
820 if (sc->light_get_supported)
821 acpi_GetInteger(sc->ec_handle, IBM_NAME_KEYLIGHT, &val);
823 val = sc->light_val;
827 acpi_GetInteger(sc->handle, IBM_NAME_WLAN_BT_GET, &val);
828 sc->wlan_bt_flags = val;
833 acpi_GetInteger(sc->handle, IBM_NAME_WLAN_BT_GET, &val);
834 sc->wlan_bt_flags = val;
839 if (sc->fan_handle) {
840 if(ACPI_FAILURE(acpi_GetInteger(sc->fan_handle, NULL, &val)))
841 val = -1;
843 ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSPEED, &val_ec, 2);
851 * Bit 0-5 indicate the level at which the fan operates. Only
858 if (!sc->fan_handle) {
859 ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
868 if (!sc->fan_handle) {
869 ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
872 val = -1;
876 if (sc->mic_led_handle)
877 return sc->mic_led_state;
879 val = -1;
905 status = acpi_SetInteger(sc->handle, IBM_NAME_EVENTS_STATUS_SET, arg);
908 if (sc->events_mask_supported)
909 return acpi_ibm_eventmask_set(sc, sc->events_availmask);
913 if (sc->events_mask_supported)
949 if (!sc->fan_handle) {
951 ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
961 return (ACPI_EC_WRITE(sc->ec_dev, IBM_EC_FANSTATUS, val,
970 if (!sc->fan_handle) {
972 ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1);
974 return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_FANSTATUS,
995 return (sc->events_mask_supported);
1005 if (ACPI_SUCCESS(AcpiGetHandle(sc->handle, "MMTS", &sc->mic_led_handle)))
1011 sc->mic_led_handle = NULL;
1015 sc->cmos_handle = NULL;
1016 sc->light_get_supported = ACPI_SUCCESS(acpi_GetInteger(
1017 sc->ec_handle, IBM_NAME_KEYLIGHT, &sc->light_val));
1019 if ((ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\UCMS", &sc->light_handle)) ||
1020 ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\CMOS", &sc->light_handle)) ||
1021 ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\CMS", &sc->light_handle))) &&
1022 ACPI_SUCCESS(AcpiGetType(sc->light_handle, &cmos_t)) &&
1024 sc->light_cmd_on = 0x0c;
1025 sc->light_cmd_off = 0x0d;
1026 sc->cmos_handle = sc->light_handle;
1028 else if (ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\LGHT", &sc->light_handle))) {
1029 sc->light_cmd_on = 1;
1030 sc->light_cmd_off = 0;
1032 sc->light_handle = NULL;
1034 sc->light_set_supported = (sc->light_handle &&
1035 ACPI_FAILURE(AcpiGetHandle(sc->ec_handle, "LEDB", &ledb_handle)));
1037 if (sc->light_get_supported)
1040 if (sc->light_set_supported) {
1041 sc->light_val = 0;
1049 if (ACPI_SUCCESS(acpi_GetInteger(sc->handle, IBM_NAME_WLAN_BT_GET, &dummy)))
1055 * Some models report the fan speed in levels from 0-7
1058 sc->fan_levels =
1059 (ACPI_SUCCESS(AcpiGetHandle(sc->handle, "GFAN", &sc->fan_handle)) ||
1060 ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\FSPD", &sc->fan_handle)));
1067 * which report fan RPM contiguously, not in levels
1069 if (sc->fan_levels)
1074 if (ACPI_SUCCESS(acpi_GetInteger(sc->ec_handle, IBM_NAME_THERMAL_GET, &dummy))) {
1075 sc->thermal_updt_supported = ACPI_SUCCESS(acpi_GetInteger(sc->ec_handle, IBM_NAME_THERMAL_UPDT, &dummy));
1084 return (acpi_ibm_privacyguard_get(sc) != -1);
1099 sc = (struct acpi_ibm_softc *)oidp->oid_arg1;
1107 * The TMPx methods seem to return +/- 128 or 0
1110 if (ACPI_FAILURE(acpi_GetInteger(sc->ec_handle, temp_cmd,
1112 temp[i] = -1;
1113 else if (sc->thermal_updt_supported)
1115 temp[i] = (temp[i] - 2731 + 5) / 10;
1137 sc = (struct acpi_ibm_softc *)oidp->oid_arg1;
1145 if (req->newptr == NULL) {
1146 for (int i = 0; i < 8 * sizeof(sc->handler_events); i++)
1147 if (sc->handler_events & (1 << i))
1161 if (error != 0 || req->newptr == NULL)
1178 l = ep - cp;
1194 device_printf(sc->dev, "invalid event code: %s\n", cp);
1199 handler_events |= 1 << (val - 1);
1204 sc->handler_events = handler_events;
1226 status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS, &val_ec, 1);
1230 if (sc->cmos_handle) {
1239 step = (arg > val) ? 1 : -1;
1241 status = AcpiEvaluateObject(sc->cmos_handle, NULL,
1246 ACPI_EC_WRITE(sc->ec_dev,
1247 IBM_EC_BRIGHTNESS, i - step, 1);
1254 return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_BRIGHTNESS, arg, 1);
1268 val = (arg == 1) ? sc->wlan_bt_flags | IBM_NAME_MASK_BT :
1269 sc->wlan_bt_flags & (~IBM_NAME_MASK_BT);
1270 return acpi_SetInteger(sc->handle, IBM_NAME_WLAN_BT_SET, val);
1286 if (sc->light_set_supported) {
1290 Arg.Integer.Value = arg ? sc->light_cmd_on : sc->light_cmd_off;
1292 status = AcpiEvaluateObject(sc->light_handle, NULL,
1295 sc->light_val = arg;
1322 status = AcpiEvaluateObject(sc->handle,
1332 * Returns -1 if the device is not present.
1345 return (-1);
1373 status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
1377 if (sc->cmos_handle) {
1386 step = (arg > val) ? 1 : -1;
1388 status = AcpiEvaluateObject(sc->cmos_handle, NULL,
1393 val_ec = i - step +
1395 ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME,
1404 return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, val_ec, 1);
1421 status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
1425 if (sc->cmos_handle) {
1431 status = AcpiEvaluateObject(sc->cmos_handle, NULL, &Args, NULL);
1438 return ACPI_EC_WRITE(sc->ec_dev, IBM_EC_VOLUME, val_ec, 1);
1455 acpi_ibm_bluetooth_set(sc, (sc->wlan_bt_flags == 0));
1461 status = ACPI_EC_READ(sc->ec_dev, IBM_EC_BRIGHTNESS,
1467 val = (arg == IBM_EVENT_BRIGHTNESS_UP) ? val + 1 : val - 1;
1472 acpi_ibm_thinklight_set(sc, (sc->light_val == 0));
1478 status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
1483 val = (arg == IBM_EVENT_VOLUME_UP) ? val + 1 : val - 1;
1489 status = ACPI_EC_READ(sc->ec_dev, IBM_EC_VOLUME, &val_ec, 1);
1524 if (!(sc->events_availmask & (1 << (arg - 1)))) {
1530 if (sc->handler_events & (1 << (arg - 1)))
1539 evdev_push_key(sc->evdev, key, 1);
1540 evdev_sync(sc->evdev);
1541 evdev_push_key(sc->evdev, key, 0);
1542 evdev_sync(sc->evdev);