Lines Matching +full:fn +full:- +full:keymap

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * toshiba_acpi.c - Toshiba Laptop ACPI Extras
5 * Copyright (C) 2002-2004 John Belmonte
8 * Copyright (C) 2014-2016 Azael Avalos
14 * Jonathan A. Buzzard - Toshiba HCI info, and critical tips on reverse
16 * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5
17 * Rob Miller - TV out and hotkeys help
36 #include <linux/input/sparse-keymap.h>
55 static int turn_on_panel_on_resume = -1;
58 "Call HCI_PANEL_POWER_ON on resume (-1 = auto, 0 = no, 1 = yes");
60 #define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100"
62 /* Scan code for Fn key on TOS1900 models */
142 #define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS)
307 return (status == AE_OK) ? 0 : -EIO; in write_acpi_int()
333 status = acpi_evaluate_object(dev->acpi_dev->handle, in tci_raw()
334 (char *)dev->method_hci, &params, in tci_raw()
336 if ((status == AE_OK) && (out_objs->package.count <= TCI_WORDS)) { in tci_raw()
337 for (i = 0; i < out_objs->package.count; ++i) in tci_raw()
338 out[i] = out_objs->package.elements[i].integer.value; in tci_raw()
464 dev->illumination_supported = 0; in toshiba_illumination_available()
479 dev->illumination_supported = 1; in toshiba_illumination_available()
533 dev->kbd_illum_supported = 0; in toshiba_kbd_illum_available()
534 dev->kbd_event_generated = false; in toshiba_kbd_illum_available()
556 dev->kbd_type = 2; in toshiba_kbd_illum_available()
558 dev->kbd_type = 1; in toshiba_kbd_illum_available()
560 dev->kbd_mode = out[2] & SCI_KBD_MODE_MASK; in toshiba_kbd_illum_available()
561 /* Get the current time (1-60 seconds) */ in toshiba_kbd_illum_available()
562 dev->kbd_time = out[2] >> HCI_MISC_SHIFT; in toshiba_kbd_illum_available()
564 dev->kbd_illum_supported = 1; in toshiba_kbd_illum_available()
572 return -EIO; in toshiba_kbd_illum_status_set()
579 return -ENODEV; in toshiba_kbd_illum_status_set()
581 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_kbd_illum_status_set()
589 return -EIO; in toshiba_kbd_illum_status_get()
596 return -ENODEV; in toshiba_kbd_illum_status_get()
598 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_kbd_illum_status_get()
641 return -EIO; in toshiba_touchpad_set()
648 return -ENODEV; in toshiba_touchpad_set()
650 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_touchpad_set()
658 return -EIO; in toshiba_touchpad_get()
665 return -ENODEV; in toshiba_touchpad_get()
667 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_touchpad_get()
677 dev->eco_supported = 0; in toshiba_eco_mode_available()
708 dev->eco_supported = 1; in toshiba_eco_mode_available()
756 dev->accelerometer_supported = 0; in toshiba_accelerometer_available()
771 dev->accelerometer_supported = 1; in toshiba_accelerometer_available()
785 return -EIO; in toshiba_accelerometer_get()
789 return -ENODEV; in toshiba_accelerometer_get()
792 return -EIO; in toshiba_accelerometer_get()
807 dev->usb_sleep_charge_supported = 0; in toshiba_usb_sleep_charge_available()
824 dev->usbsc_mode_base = out[4]; in toshiba_usb_sleep_charge_available()
837 dev->usbsc_bat_level = out[2]; in toshiba_usb_sleep_charge_available()
839 dev->usb_sleep_charge_supported = 1; in toshiba_usb_sleep_charge_available()
848 return -EIO; in toshiba_usb_sleep_charge_get()
855 return -ENODEV; in toshiba_usb_sleep_charge_get()
857 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_charge_get()
866 return -EIO; in toshiba_usb_sleep_charge_set()
873 return -ENODEV; in toshiba_usb_sleep_charge_set()
875 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_charge_set()
886 return -EIO; in toshiba_sleep_functions_status_get()
893 return -EIO; in toshiba_sleep_functions_status_get()
897 return -ENODEV; in toshiba_sleep_functions_status_get()
900 return -EIO; in toshiba_sleep_functions_status_get()
916 return -EIO; in toshiba_sleep_functions_status_set()
924 return -EIO; in toshiba_sleep_functions_status_set()
928 return -ENODEV; in toshiba_sleep_functions_status_set()
930 return out[0] == TOS_SUCCESS ? 0 : -EIO; in toshiba_sleep_functions_status_set()
941 return -EIO; in toshiba_usb_rapid_charge_get()
948 return -EIO; in toshiba_usb_rapid_charge_get()
952 return -ENODEV; in toshiba_usb_rapid_charge_get()
955 return -EIO; in toshiba_usb_rapid_charge_get()
970 return -EIO; in toshiba_usb_rapid_charge_set()
978 return -EIO; in toshiba_usb_rapid_charge_set()
982 return -ENODEV; in toshiba_usb_rapid_charge_set()
984 return (out[0] == TOS_SUCCESS || out[0] == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_rapid_charge_set()
992 return -EIO; in toshiba_usb_sleep_music_get()
999 return -ENODEV; in toshiba_usb_sleep_music_get()
1001 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_music_get()
1009 return -EIO; in toshiba_usb_sleep_music_set()
1016 return -ENODEV; in toshiba_usb_sleep_music_set()
1018 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_music_set()
1027 return -EIO; in toshiba_function_keys_get()
1034 return -ENODEV; in toshiba_function_keys_get()
1036 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_function_keys_get()
1044 return -EIO; in toshiba_function_keys_set()
1051 return -ENODEV; in toshiba_function_keys_set()
1053 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_function_keys_set()
1062 return -EIO; in toshiba_panel_power_on_get()
1069 return -ENODEV; in toshiba_panel_power_on_get()
1071 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_panel_power_on_get()
1079 return -EIO; in toshiba_panel_power_on_set()
1086 return -ENODEV; in toshiba_panel_power_on_set()
1088 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_panel_power_on_set()
1097 return -EIO; in toshiba_usb_three_get()
1104 return -ENODEV; in toshiba_usb_three_get()
1106 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_three_get()
1114 return -EIO; in toshiba_usb_three_set()
1121 return -ENODEV; in toshiba_usb_three_set()
1123 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_three_set()
1137 return -EIO; in toshiba_hotkey_event_type_get()
1141 return -ENODEV; in toshiba_hotkey_event_type_get()
1144 return -EIO; in toshiba_hotkey_event_type_get()
1163 return -EIO; in toshiba_wireless_status()
1167 return -ENODEV; in toshiba_wireless_status()
1170 return -EIO; in toshiba_wireless_status()
1172 dev->killswitch = !!(out[2] & HCI_WIRELESS_STATUS); in toshiba_wireless_status()
1184 dev->wwan_supported = 0; in toshiba_wwan_available()
1206 dev->wwan_supported = (out[2] == HCI_WIRELESS_WWAN_STATUS); in toshiba_wwan_available()
1219 return -EIO; in toshiba_wwan_set()
1223 return -ENODEV; in toshiba_wwan_set()
1226 return -EIO; in toshiba_wwan_set()
1237 return -EIO; in toshiba_wwan_set()
1241 return -ENODEV; in toshiba_wwan_set()
1243 return out[0] == TOS_SUCCESS ? 0 : -EIO; in toshiba_wwan_set()
1253 dev->cooling_method_supported = 0; in toshiba_cooling_method_available()
1254 dev->max_cooling_method = 0; in toshiba_cooling_method_available()
1265 dev->cooling_method_supported = 1; in toshiba_cooling_method_available()
1266 dev->max_cooling_method = out[3]; in toshiba_cooling_method_available()
1277 return -ENODEV; in toshiba_cooling_method_get()
1279 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_cooling_method_get()
1290 return -ENODEV; in toshiba_cooling_method_set()
1292 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_cooling_method_set()
1302 dev->battery_charge_mode_supported = 0; in toshiba_battery_charge_mode_available()
1313 dev->battery_charge_mode_supported = 1; in toshiba_battery_charge_mode_available()
1333 return -ENODEV; in toshiba_battery_charge_mode_get()
1335 retries--; in toshiba_battery_charge_mode_get()
1338 return -EIO; in toshiba_battery_charge_mode_get()
1342 return -EIO; in toshiba_battery_charge_mode_get()
1353 return -ENODEV; in toshiba_battery_charge_mode_set()
1355 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_battery_charge_mode_set()
1366 return -ENODEV; in get_tr_backlight_status()
1368 return result == TOS_SUCCESS ? 0 : -EIO; in get_tr_backlight_status()
1378 return -ENODEV; in set_tr_backlight_status()
1380 return result == TOS_SUCCESS ? 0 : -EIO; in set_tr_backlight_status()
1392 if (dev->tr_backlight_supported) { in __get_lcd_brightness()
1406 return -ENODEV; in __get_lcd_brightness()
1410 -EIO; in __get_lcd_brightness()
1422 struct toshiba_acpi_dev *dev = m->private; in lcd_proc_show()
1426 if (!dev->backlight_dev) in lcd_proc_show()
1427 return -ENODEV; in lcd_proc_show()
1429 levels = dev->backlight_dev->props.max_brightness + 1; in lcd_proc_show()
1430 value = get_lcd_brightness(dev->backlight_dev); in lcd_proc_show()
1451 if (dev->tr_backlight_supported) { in set_lcd_brightness()
1457 value--; in set_lcd_brightness()
1465 return -ENODEV; in set_lcd_brightness()
1467 return result == TOS_SUCCESS ? 0 : -EIO; in set_lcd_brightness()
1474 return set_lcd_brightness(dev, bd->props.brightness); in set_lcd_status()
1486 len = min(count, sizeof(cmd) - 1); in lcd_proc_write()
1488 return -EFAULT; in lcd_proc_write()
1491 levels = dev->backlight_dev->props.max_brightness + 1; in lcd_proc_write()
1494 return -EINVAL; in lcd_proc_write()
1497 return -EIO; in lcd_proc_write()
1510 /* Video-Out */
1516 pr_err("ACPI call to get Video-Out failed\n"); in get_video_status()
1518 return -ENODEV; in get_video_status()
1520 return result == TOS_SUCCESS ? 0 : -EIO; in get_video_status()
1525 struct toshiba_acpi_dev *dev = m->private; in video_proc_show()
1530 return -EIO; in video_proc_show()
1554 int lcd_out = -1, crt_out = -1, tv_out = -1; in video_proc_write()
1580 --remain; in video_proc_write()
1581 } while (remain && *(buffer - 1) != ';'); in video_proc_write()
1590 if (lcd_out != -1) in video_proc_write()
1592 if (crt_out != -1) in video_proc_write()
1594 if (tv_out != -1) in video_proc_write()
1604 return ret ? -EIO : count; in video_proc_write()
1623 return -ENODEV; in get_fan_status()
1625 return result == TOS_SUCCESS ? 0 : -EIO; in get_fan_status()
1635 return -ENODEV; in set_fan_status()
1637 return result == TOS_SUCCESS ? 0 : -EIO; in set_fan_status()
1642 struct toshiba_acpi_dev *dev = m->private; in fan_proc_show()
1646 return -EIO; in fan_proc_show()
1649 seq_printf(m, "force_on: %d\n", dev->force_fan); in fan_proc_show()
1667 len = min(count, sizeof(cmd) - 1); in fan_proc_write()
1669 return -EFAULT; in fan_proc_write()
1674 return -EINVAL; in fan_proc_write()
1677 return -EIO; in fan_proc_write()
1679 dev->force_fan = value; in fan_proc_write()
1701 return -EIO; in get_fan_rpm()
1705 return -ENODEV; in get_fan_rpm()
1712 return -EIO; in get_fan_rpm()
1717 struct toshiba_acpi_dev *dev = m->private; in keys_proc_show()
1719 seq_printf(m, "hotkey_ready: %d\n", dev->key_event_valid); in keys_proc_show()
1720 seq_printf(m, "hotkey: 0x%04x\n", dev->last_key_event); in keys_proc_show()
1738 len = min(count, sizeof(cmd) - 1); in keys_proc_write()
1740 return -EFAULT; in keys_proc_write()
1744 dev->key_event_valid = 0; in keys_proc_write()
1746 return -EINVAL; in keys_proc_write()
1774 if (dev->backlight_dev) in create_toshiba_proc_entries()
1777 if (dev->video_supported) in create_toshiba_proc_entries()
1780 if (dev->fan_supported) in create_toshiba_proc_entries()
1783 if (dev->hotkey_dev) in create_toshiba_proc_entries()
1792 if (dev->backlight_dev) in remove_toshiba_proc_entries()
1794 if (dev->video_supported) in remove_toshiba_proc_entries()
1796 if (dev->fan_supported) in remove_toshiba_proc_entries()
1798 if (dev->hotkey_dev) in remove_toshiba_proc_entries()
1837 return -EINVAL; in fan_store()
1875 if (toshiba->kbd_type == 1) { in kbd_backlight_mode_store()
1878 return -EINVAL; in kbd_backlight_mode_store()
1879 } else if (toshiba->kbd_type == 2) { in kbd_backlight_mode_store()
1883 return -EINVAL; in kbd_backlight_mode_store()
1888 * Auto - KBD backlight turns off automatically in given time in kbd_backlight_mode_store()
1889 * FN-Z - KBD backlight "toggles" when hotkey pressed in kbd_backlight_mode_store()
1890 * ON - KBD backlight is always on in kbd_backlight_mode_store()
1891 * OFF - KBD backlight is always off in kbd_backlight_mode_store()
1895 if (toshiba->kbd_mode != mode) { in kbd_backlight_mode_store()
1897 int time = toshiba->kbd_time << HCI_MISC_SHIFT; in kbd_backlight_mode_store()
1900 if (toshiba->kbd_type == 1) { in kbd_backlight_mode_store()
1902 time |= toshiba->kbd_mode; in kbd_backlight_mode_store()
1903 } else if (toshiba->kbd_type == 2) { in kbd_backlight_mode_store()
1912 toshiba->kbd_mode = mode; in kbd_backlight_mode_store()
1913 toshiba_acpi->kbd_mode = mode; in kbd_backlight_mode_store()
1929 if (toshiba->kbd_type == 2 && in kbd_backlight_mode_store()
1930 !toshiba->kbd_event_generated) in kbd_backlight_mode_store()
1945 return -EIO; in kbd_backlight_mode_show()
1956 return sprintf(buf, "%d\n", toshiba->kbd_type); in kbd_type_show()
1966 if (toshiba->kbd_type == 1) in available_kbd_modes_show()
1988 if (toshiba->kbd_type == 1) { in kbd_backlight_timeout_store()
1990 return -EINVAL; in kbd_backlight_timeout_store()
1991 } else if (toshiba->kbd_type == 2) { in kbd_backlight_timeout_store()
1993 return -EINVAL; in kbd_backlight_timeout_store()
1999 if (toshiba->kbd_time != time) { in kbd_backlight_timeout_store()
2003 if (toshiba->kbd_type == 1) in kbd_backlight_timeout_store()
2005 else if (toshiba->kbd_type == 2) in kbd_backlight_timeout_store()
2012 toshiba->kbd_time = time >> HCI_MISC_SHIFT; in kbd_backlight_timeout_store()
2026 return -EIO; in kbd_backlight_timeout_show()
2040 /* Set the TouchPad on/off, 0 - Disable | 1 - Enable */ in touchpad_store()
2045 return -EINVAL; in touchpad_store()
2097 * 0 - Disabled in usb_sleep_charge_store()
2098 * 1 - Alternate (Non USB conformant devices that require more power) in usb_sleep_charge_store()
2099 * 2 - Auto (USB conformant devices) in usb_sleep_charge_store()
2100 * 3 - Typical in usb_sleep_charge_store()
2103 return -EINVAL; in usb_sleep_charge_store()
2106 mode = toshiba->usbsc_mode_base; in usb_sleep_charge_store()
2138 /* Determine the status: 0x4 - Enabled | 0x1 - Disabled */ in sleep_functions_on_battery_show()
2163 * 0 - Disabled in sleep_functions_on_battery_store()
2164 * 1-100 - Enabled in sleep_functions_on_battery_store()
2167 return -EINVAL; in sleep_functions_on_battery_store()
2170 tmp = toshiba->usbsc_bat_level << HCI_MISC_SHIFT; in sleep_functions_on_battery_store()
2180 toshiba->usbsc_bat_level = status >> HCI_MISC_SHIFT; in sleep_functions_on_battery_store()
2212 return -EINVAL; in usb_rapid_charge_store()
2248 return -EINVAL; in usb_sleep_music_store()
2285 * 0 - Normal operation (F{1-12} as usual and hotkeys via FN-F{1-12}) in kbd_function_keys_store()
2286 * 1 - Special functions (Opposite of the above setting) in kbd_function_keys_store()
2289 return -EINVAL; in kbd_function_keys_store()
2327 return -EINVAL; in panel_power_on_store()
2366 * 0 - Disabled (Acts like a USB 2 port, saving power) in usb_three_store()
2367 * 1 - Enabled in usb_three_store()
2370 return -EINVAL; in usb_three_store()
2393 return sprintf(buf, "%d %d\n", state, toshiba->max_cooling_method); in cooling_method_show()
2411 * 0 - Maximum Performance in cooling_method_store()
2412 * 1 - Battery Optimized in cooling_method_store()
2415 * 0 - Maximum Performance in cooling_method_store()
2416 * 1 - Performance in cooling_method_store()
2417 * 2 - Battery Optimized in cooling_method_store()
2419 if (state < 0 || state > toshiba->max_cooling_method) in cooling_method_store()
2420 return -EINVAL; in cooling_method_store()
2457 exists = (drv->fan_supported) ? true : false; in toshiba_sysfs_is_visible()
2459 exists = (drv->kbd_illum_supported) ? true : false; in toshiba_sysfs_is_visible()
2461 exists = (drv->kbd_mode == SCI_KBD_MODE_AUTO) ? true : false; in toshiba_sysfs_is_visible()
2463 exists = (drv->touchpad_supported) ? true : false; in toshiba_sysfs_is_visible()
2465 exists = (drv->usb_sleep_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2467 exists = (drv->usb_sleep_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2469 exists = (drv->usb_rapid_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2471 exists = (drv->usb_sleep_music_supported) ? true : false; in toshiba_sysfs_is_visible()
2473 exists = (drv->kbd_function_keys_supported) ? true : false; in toshiba_sysfs_is_visible()
2475 exists = (drv->panel_power_on_supported) ? true : false; in toshiba_sysfs_is_visible()
2477 exists = (drv->usb_three_supported) ? true : false; in toshiba_sysfs_is_visible()
2479 exists = (drv->cooling_method_supported) ? true : false; in toshiba_sysfs_is_visible()
2481 return exists ? attr->mode : 0; in toshiba_sysfs_is_visible()
2492 if (sysfs_update_group(&toshiba_acpi->acpi_dev->dev.kobj, in toshiba_acpi_kbd_bl_work()
2497 if (toshiba_acpi->kbd_type == 2 && in toshiba_acpi_kbd_bl_work()
2498 toshiba_acpi->kbd_mode != SCI_KBD_MODE_AUTO) in toshiba_acpi_kbd_bl_work()
2499 led_classdev_notify_brightness_hw_changed(&toshiba_acpi->kbd_led, in toshiba_acpi_kbd_bl_work()
2500 (toshiba_acpi->kbd_mode == SCI_KBD_MODE_ON) ? in toshiba_acpi_kbd_bl_work()
2504 acpi_bus_generate_netlink_event(toshiba_acpi->acpi_dev->pnp.device_class, in toshiba_acpi_kbd_bl_work()
2505 dev_name(&toshiba_acpi->acpi_dev->dev), in toshiba_acpi_kbd_bl_work()
2531 -(xyval & HCI_ACCEL_MASK) : xyval & HCI_ACCEL_MASK; in toshiba_iio_accel_get_axis()
2534 -((xyval >> HCI_MISC_SHIFT) & HCI_ACCEL_MASK) : in toshiba_iio_accel_get_axis()
2538 -(zval & HCI_ACCEL_MASK) : zval & HCI_ACCEL_MASK; in toshiba_iio_accel_get_axis()
2552 ret = toshiba_iio_accel_get_axis(chan->channel); in toshiba_iio_accel_read_raw()
2553 if (ret == -EIO || ret == -ENODEV) in toshiba_iio_accel_read_raw()
2561 return -EINVAL; in toshiba_iio_accel_read_raw()
2588 u32 in[TCI_WORDS] = { regs->eax, regs->ebx, regs->ecx, in toshiba_acpi_smm_bridge()
2589 regs->edx, regs->esi, regs->edi }; in toshiba_acpi_smm_bridge()
2596 return -EIO; in toshiba_acpi_smm_bridge()
2600 regs->eax = out[0]; in toshiba_acpi_smm_bridge()
2601 regs->ebx = out[1]; in toshiba_acpi_smm_bridge()
2602 regs->ecx = out[2]; in toshiba_acpi_smm_bridge()
2603 regs->edx = out[3]; in toshiba_acpi_smm_bridge()
2604 regs->esi = out[4]; in toshiba_acpi_smm_bridge()
2605 regs->edi = out[5]; in toshiba_acpi_smm_bridge()
2618 return -EINVAL; in toshiba_acpi_ioctl()
2623 return -EFAULT; in toshiba_acpi_ioctl()
2628 return -EFAULT; in toshiba_acpi_ioctl()
2632 return -EFAULT; in toshiba_acpi_ioctl()
2635 return -EINVAL; in toshiba_acpi_ioctl()
2637 return -EIO; in toshiba_acpi_ioctl()
2643 return -EFAULT; in toshiba_acpi_ioctl()
2646 return -EINVAL; in toshiba_acpi_ioctl()
2670 if (!dev->killswitch) in toshiba_acpi_wwan_set_block()
2683 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_wwan_poll()
2698 dev->wwan_rfk = rfkill_alloc("Toshiba WWAN", in toshiba_acpi_setup_wwan_rfkill()
2699 &dev->acpi_dev->dev, in toshiba_acpi_setup_wwan_rfkill()
2703 if (!dev->wwan_rfk) { in toshiba_acpi_setup_wwan_rfkill()
2705 return -ENOMEM; in toshiba_acpi_setup_wwan_rfkill()
2708 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_setup_wwan_rfkill()
2710 ret = rfkill_register(dev->wwan_rfk); in toshiba_acpi_setup_wwan_rfkill()
2713 rfkill_destroy(dev->wwan_rfk); in toshiba_acpi_setup_wwan_rfkill()
2727 status = acpi_evaluate_object(dev->acpi_dev->handle, in toshiba_acpi_enable_hotkeys()
2730 return -ENODEV; in toshiba_acpi_enable_hotkeys()
2736 if (dev->kbd_function_keys_supported && dev->special_functions) in toshiba_acpi_enable_hotkeys()
2743 return -EIO; in toshiba_acpi_enable_hotkeys()
2745 return -ENODEV; in toshiba_acpi_enable_hotkeys()
2760 schedule_work(&toshiba_acpi->hotkey_work); in toshiba_acpi_i8042_filter()
2788 status = acpi_evaluate_integer(dev->acpi_dev->handle, "INFO", in toshiba_acpi_query_hotkey()
2792 return -EIO; in toshiba_acpi_query_hotkey()
2808 if (!sparse_keymap_report_event(dev->hotkey_dev, scancode, 1, true)) in toshiba_acpi_report_hotkey()
2814 if (dev->info_supported) { in toshiba_acpi_process_hotkeys()
2821 dev->key_event_valid = 1; in toshiba_acpi_process_hotkeys()
2822 dev->last_key_event = scancode; in toshiba_acpi_process_hotkeys()
2824 } else if (dev->system_event_supported) { in toshiba_acpi_process_hotkeys()
2834 dev->key_event_valid = 1; in toshiba_acpi_process_hotkeys()
2835 dev->last_key_event = value; in toshiba_acpi_process_hotkeys()
2845 pr_notice("Re-enabled hotkeys\n"); in toshiba_acpi_process_hotkeys()
2848 retries--; in toshiba_acpi_process_hotkeys()
2857 const struct key_entry *keymap = toshiba_acpi_keymap; in toshiba_acpi_setup_keyboard() local
2875 if (toshiba_hotkey_event_type_get(dev, &dev->hotkey_event_type)) in toshiba_acpi_setup_keyboard()
2878 dev->hotkey_dev = input_allocate_device(); in toshiba_acpi_setup_keyboard()
2879 if (!dev->hotkey_dev) in toshiba_acpi_setup_keyboard()
2880 return -ENOMEM; in toshiba_acpi_setup_keyboard()
2882 dev->hotkey_dev->name = "Toshiba input device"; in toshiba_acpi_setup_keyboard()
2883 dev->hotkey_dev->phys = "toshiba_acpi/input0"; in toshiba_acpi_setup_keyboard()
2884 dev->hotkey_dev->id.bustype = BUS_HOST; in toshiba_acpi_setup_keyboard()
2885 dev->hotkey_dev->dev.parent = &dev->acpi_dev->dev; in toshiba_acpi_setup_keyboard()
2887 if (dev->hotkey_event_type == HCI_SYSTEM_TYPE1 || in toshiba_acpi_setup_keyboard()
2888 !dev->kbd_function_keys_supported) in toshiba_acpi_setup_keyboard()
2889 keymap = toshiba_acpi_keymap; in toshiba_acpi_setup_keyboard()
2890 else if (dev->hotkey_event_type == HCI_SYSTEM_TYPE2 || in toshiba_acpi_setup_keyboard()
2891 dev->kbd_function_keys_supported) in toshiba_acpi_setup_keyboard()
2892 keymap = toshiba_acpi_alt_keymap; in toshiba_acpi_setup_keyboard()
2895 dev->hotkey_event_type); in toshiba_acpi_setup_keyboard()
2896 error = sparse_keymap_setup(dev->hotkey_dev, keymap, NULL); in toshiba_acpi_setup_keyboard()
2903 * whenever the Fn key is pressed using the NTFY method, if in toshiba_acpi_setup_keyboard()
2909 INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work); in toshiba_acpi_setup_keyboard()
2917 dev->ntfy_supported = 1; in toshiba_acpi_setup_keyboard()
2924 if (acpi_has_method(dev->acpi_dev->handle, "INFO")) in toshiba_acpi_setup_keyboard()
2925 dev->info_supported = 1; in toshiba_acpi_setup_keyboard()
2927 dev->system_event_supported = 1; in toshiba_acpi_setup_keyboard()
2929 if (!dev->info_supported && !dev->system_event_supported) { in toshiba_acpi_setup_keyboard()
2931 error = -EINVAL; in toshiba_acpi_setup_keyboard()
2935 error = input_register_device(dev->hotkey_dev); in toshiba_acpi_setup_keyboard()
2944 if (dev->ntfy_supported) in toshiba_acpi_setup_keyboard()
2947 input_free_device(dev->hotkey_dev); in toshiba_acpi_setup_keyboard()
2948 dev->hotkey_dev = NULL; in toshiba_acpi_setup_keyboard()
2960 * others support it read-only. Either of these is pretty useless, in toshiba_acpi_setup_backlight()
2973 if (dev->tr_backlight_supported && brightness == 0) in toshiba_acpi_setup_backlight()
2977 pr_debug("Backlight method is read-only, disabling backlight support\n"); in toshiba_acpi_setup_backlight()
2986 props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; in toshiba_acpi_setup_backlight()
2989 if (dev->tr_backlight_supported) in toshiba_acpi_setup_backlight()
2992 dev->backlight_dev = backlight_device_register("toshiba", in toshiba_acpi_setup_backlight()
2993 &dev->acpi_dev->dev, in toshiba_acpi_setup_backlight()
2997 if (IS_ERR(dev->backlight_dev)) { in toshiba_acpi_setup_backlight()
2998 ret = PTR_ERR(dev->backlight_dev); in toshiba_acpi_setup_backlight()
3000 dev->backlight_dev = NULL; in toshiba_acpi_setup_backlight()
3004 dev->backlight_dev->props.brightness = brightness; in toshiba_acpi_setup_backlight()
3037 return -EOPNOTSUPP; in toshiba_acpi_hwmon_read()
3066 return -ENODEV; in charge_control_end_threshold_show()
3090 return -ENODEV; in charge_control_end_threshold_store()
3098 return -EINVAL; in charge_control_end_threshold_store()
3120 return -ENODEV; in toshiba_acpi_battery_add()
3122 if (!toshiba_acpi->battery_charge_mode_supported) in toshiba_acpi_battery_add()
3123 return -ENODEV; in toshiba_acpi_battery_add()
3124 if (device_add_groups(&battery->dev, toshiba_acpi_battery_groups)) in toshiba_acpi_battery_add()
3125 return -ENODEV; in toshiba_acpi_battery_add()
3131 device_remove_groups(&battery->dev, toshiba_acpi_battery_groups); in toshiba_acpi_battery_remove()
3145 if (dev->hotkey_dev) in print_supported_features()
3147 if (dev->backlight_dev) in print_supported_features()
3149 if (dev->video_supported) in print_supported_features()
3150 pr_cont(" video-out"); in print_supported_features()
3151 if (dev->fan_supported) in print_supported_features()
3153 if (dev->fan_rpm_supported) in print_supported_features()
3154 pr_cont(" fan-rpm"); in print_supported_features()
3155 if (dev->tr_backlight_supported) in print_supported_features()
3156 pr_cont(" transflective-backlight"); in print_supported_features()
3157 if (dev->illumination_supported) in print_supported_features()
3159 if (dev->kbd_illum_supported) in print_supported_features()
3160 pr_cont(" keyboard-backlight"); in print_supported_features()
3161 if (dev->touchpad_supported) in print_supported_features()
3163 if (dev->eco_supported) in print_supported_features()
3164 pr_cont(" eco-led"); in print_supported_features()
3165 if (dev->accelerometer_supported) in print_supported_features()
3166 pr_cont(" accelerometer-axes"); in print_supported_features()
3167 if (dev->usb_sleep_charge_supported) in print_supported_features()
3168 pr_cont(" usb-sleep-charge"); in print_supported_features()
3169 if (dev->usb_rapid_charge_supported) in print_supported_features()
3170 pr_cont(" usb-rapid-charge"); in print_supported_features()
3171 if (dev->usb_sleep_music_supported) in print_supported_features()
3172 pr_cont(" usb-sleep-music"); in print_supported_features()
3173 if (dev->kbd_function_keys_supported) in print_supported_features()
3174 pr_cont(" special-function-keys"); in print_supported_features()
3175 if (dev->panel_power_on_supported) in print_supported_features()
3176 pr_cont(" panel-power-on"); in print_supported_features()
3177 if (dev->usb_three_supported) in print_supported_features()
3179 if (dev->wwan_supported) in print_supported_features()
3181 if (dev->cooling_method_supported) in print_supported_features()
3182 pr_cont(" cooling-method"); in print_supported_features()
3183 if (dev->battery_charge_mode_supported) in print_supported_features()
3184 pr_cont(" battery-charge-mode"); in print_supported_features()
3193 misc_deregister(&dev->miscdev); in toshiba_acpi_remove()
3198 if (dev->hwmon_device) in toshiba_acpi_remove()
3199 hwmon_device_unregister(dev->hwmon_device); in toshiba_acpi_remove()
3202 if (dev->accelerometer_supported && dev->indio_dev) { in toshiba_acpi_remove()
3203 iio_device_unregister(dev->indio_dev); in toshiba_acpi_remove()
3204 iio_device_free(dev->indio_dev); in toshiba_acpi_remove()
3207 if (dev->sysfs_created) in toshiba_acpi_remove()
3208 sysfs_remove_group(&dev->acpi_dev->dev.kobj, in toshiba_acpi_remove()
3211 if (dev->ntfy_supported) { in toshiba_acpi_remove()
3213 cancel_work_sync(&dev->hotkey_work); in toshiba_acpi_remove()
3216 if (dev->hotkey_dev) in toshiba_acpi_remove()
3217 input_unregister_device(dev->hotkey_dev); in toshiba_acpi_remove()
3219 backlight_device_unregister(dev->backlight_dev); in toshiba_acpi_remove()
3221 led_classdev_unregister(&dev->led_dev); in toshiba_acpi_remove()
3222 led_classdev_unregister(&dev->kbd_led); in toshiba_acpi_remove()
3223 led_classdev_unregister(&dev->eco_led); in toshiba_acpi_remove()
3225 if (dev->wwan_rfk) { in toshiba_acpi_remove()
3226 rfkill_unregister(dev->wwan_rfk); in toshiba_acpi_remove()
3227 rfkill_destroy(dev->wwan_rfk); in toshiba_acpi_remove()
3230 if (dev->battery_charge_mode_supported) in toshiba_acpi_remove()
3253 * Some Toshibas have a broken acpi-video interface for brightness control,
3297 return -EBUSY; in toshiba_acpi_add()
3302 hci_method = find_hci_method(acpi_dev->handle); in toshiba_acpi_add()
3305 return -ENODEV; in toshiba_acpi_add()
3310 return -ENOMEM; in toshiba_acpi_add()
3311 dev->acpi_dev = acpi_dev; in toshiba_acpi_add()
3312 dev->method_hci = hci_method; in toshiba_acpi_add()
3313 dev->miscdev.minor = MISC_DYNAMIC_MINOR; in toshiba_acpi_add()
3314 dev->miscdev.name = "toshiba_acpi"; in toshiba_acpi_add()
3315 dev->miscdev.fops = &toshiba_acpi_fops; in toshiba_acpi_add()
3317 ret = misc_register(&dev->miscdev); in toshiba_acpi_add()
3324 acpi_dev->driver_data = dev; in toshiba_acpi_add()
3325 dev_set_drvdata(&acpi_dev->dev, dev); in toshiba_acpi_add()
3332 * determine the keymap layout to use. in toshiba_acpi_add()
3334 ret = toshiba_function_keys_get(dev, &dev->special_functions); in toshiba_acpi_add()
3335 dev->kbd_function_keys_supported = !ret; in toshiba_acpi_add()
3337 dev->hotkey_event_type = 0; in toshiba_acpi_add()
3343 dev->tr_backlight_supported = !ret; in toshiba_acpi_add()
3350 if (dev->illumination_supported) { in toshiba_acpi_add()
3351 dev->led_dev.name = "toshiba::illumination"; in toshiba_acpi_add()
3352 dev->led_dev.max_brightness = 1; in toshiba_acpi_add()
3353 dev->led_dev.brightness_set = toshiba_illumination_set; in toshiba_acpi_add()
3354 dev->led_dev.brightness_get = toshiba_illumination_get; in toshiba_acpi_add()
3355 led_classdev_register(&acpi_dev->dev, &dev->led_dev); in toshiba_acpi_add()
3359 if (dev->eco_supported) { in toshiba_acpi_add()
3360 dev->eco_led.name = "toshiba::eco_mode"; in toshiba_acpi_add()
3361 dev->eco_led.max_brightness = 1; in toshiba_acpi_add()
3362 dev->eco_led.brightness_set = toshiba_eco_mode_set_status; in toshiba_acpi_add()
3363 dev->eco_led.brightness_get = toshiba_eco_mode_get_status; in toshiba_acpi_add()
3364 led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led); in toshiba_acpi_add()
3370 * and the keyboard backlight operation mode is set to FN-Z in toshiba_acpi_add()
3373 if (dev->kbd_illum_supported && in toshiba_acpi_add()
3374 (dev->kbd_mode == SCI_KBD_MODE_FNZ || dev->kbd_type == 2)) { in toshiba_acpi_add()
3375 dev->kbd_led.name = "toshiba::kbd_backlight"; in toshiba_acpi_add()
3376 dev->kbd_led.flags = LED_BRIGHT_HW_CHANGED; in toshiba_acpi_add()
3377 dev->kbd_led.max_brightness = 1; in toshiba_acpi_add()
3378 dev->kbd_led.brightness_set = toshiba_kbd_backlight_set; in toshiba_acpi_add()
3379 dev->kbd_led.brightness_get = toshiba_kbd_backlight_get; in toshiba_acpi_add()
3380 led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led); in toshiba_acpi_add()
3384 dev->touchpad_supported = !ret; in toshiba_acpi_add()
3387 if (dev->accelerometer_supported) { in toshiba_acpi_add()
3388 dev->indio_dev = iio_device_alloc(&acpi_dev->dev, sizeof(*dev)); in toshiba_acpi_add()
3389 if (!dev->indio_dev) { in toshiba_acpi_add()
3396 dev->indio_dev->info = &toshiba_iio_accel_info; in toshiba_acpi_add()
3397 dev->indio_dev->name = "Toshiba accelerometer"; in toshiba_acpi_add()
3398 dev->indio_dev->modes = INDIO_DIRECT_MODE; in toshiba_acpi_add()
3399 dev->indio_dev->channels = toshiba_iio_accel_channels; in toshiba_acpi_add()
3400 dev->indio_dev->num_channels = in toshiba_acpi_add()
3403 ret = iio_device_register(dev->indio_dev); in toshiba_acpi_add()
3406 iio_device_free(dev->indio_dev); in toshiba_acpi_add()
3414 dev->usb_rapid_charge_supported = !ret; in toshiba_acpi_add()
3417 dev->usb_sleep_music_supported = !ret; in toshiba_acpi_add()
3420 dev->panel_power_on_supported = !ret; in toshiba_acpi_add()
3423 dev->usb_three_supported = !ret; in toshiba_acpi_add()
3426 dev->video_supported = !ret; in toshiba_acpi_add()
3429 dev->fan_supported = !ret; in toshiba_acpi_add()
3432 dev->fan_rpm_supported = !ret; in toshiba_acpi_add()
3435 if (dev->fan_rpm_supported) { in toshiba_acpi_add()
3436 dev->hwmon_device = hwmon_device_register_with_info( in toshiba_acpi_add()
3437 &dev->acpi_dev->dev, "toshiba_acpi_sensors", NULL, in toshiba_acpi_add()
3439 if (IS_ERR(dev->hwmon_device)) { in toshiba_acpi_add()
3440 dev->hwmon_device = NULL; in toshiba_acpi_add()
3446 if (turn_on_panel_on_resume == -1) in toshiba_acpi_add()
3450 if (dev->wwan_supported) in toshiba_acpi_add()
3459 ret = sysfs_create_group(&dev->acpi_dev->dev.kobj, in toshiba_acpi_add()
3462 dev->sysfs_created = 0; in toshiba_acpi_add()
3465 dev->sysfs_created = !ret; in toshiba_acpi_add()
3475 if (dev->battery_charge_mode_supported) in toshiba_acpi_add()
3517 dev->kbd_event_generated = true; in toshiba_acpi_notify()
3519 if (sysfs_update_group(&acpi_dev->dev.kobj, in toshiba_acpi_notify()
3523 if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) in toshiba_acpi_notify()
3524 led_classdev_notify_brightness_hw_changed(&dev->kbd_led, in toshiba_acpi_notify()
3525 (dev->kbd_mode == SCI_KBD_MODE_ON) ? in toshiba_acpi_notify()
3538 acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, in toshiba_acpi_notify()
3539 dev_name(&acpi_dev->dev), in toshiba_acpi_notify()
3541 dev->last_key_event : 0); in toshiba_acpi_notify()
3549 if (dev->hotkey_dev) { in toshiba_acpi_suspend()
3564 if (dev->hotkey_dev) { in toshiba_acpi_resume()
3566 pr_info("Unable to re-enable hotkeys\n"); in toshiba_acpi_resume()
3569 if (dev->wwan_rfk) { in toshiba_acpi_resume()
3571 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_resume()
3604 return -ENODEV; in toshiba_acpi_init()