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 static int hci_hotkey_quickstart = -1;
63 … "Call HCI_HOTKEY_EVENT with value 0x5 for quickstart button support (-1 = auto, 0 = no, 1 = yes");
65 #define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100"
67 /* Scan code for Fn key on TOS1900 models */
148 #define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS)
313 return (status == AE_OK) ? 0 : -EIO; in write_acpi_int()
339 status = acpi_evaluate_object(dev->acpi_dev->handle, in tci_raw()
340 (char *)dev->method_hci, ¶ms, in tci_raw()
342 if ((status == AE_OK) && (out_objs->package.count <= TCI_WORDS)) { in tci_raw()
343 for (i = 0; i < out_objs->package.count; ++i) in tci_raw()
344 out[i] = out_objs->package.elements[i].integer.value; in tci_raw()
470 dev->illumination_supported = 0; in toshiba_illumination_available()
485 dev->illumination_supported = 1; in toshiba_illumination_available()
539 dev->kbd_illum_supported = 0; in toshiba_kbd_illum_available()
540 dev->kbd_event_generated = false; in toshiba_kbd_illum_available()
562 dev->kbd_type = 2; in toshiba_kbd_illum_available()
564 dev->kbd_type = 1; in toshiba_kbd_illum_available()
566 dev->kbd_mode = out[2] & SCI_KBD_MODE_MASK; in toshiba_kbd_illum_available()
567 /* Get the current time (1-60 seconds) */ in toshiba_kbd_illum_available()
568 dev->kbd_time = out[2] >> HCI_MISC_SHIFT; in toshiba_kbd_illum_available()
570 dev->kbd_illum_supported = 1; in toshiba_kbd_illum_available()
578 return -EIO; in toshiba_kbd_illum_status_set()
585 return -ENODEV; in toshiba_kbd_illum_status_set()
587 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_kbd_illum_status_set()
595 return -EIO; in toshiba_kbd_illum_status_get()
602 return -ENODEV; in toshiba_kbd_illum_status_get()
604 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_kbd_illum_status_get()
647 return -EIO; in toshiba_touchpad_set()
654 return -ENODEV; in toshiba_touchpad_set()
656 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_touchpad_set()
664 return -EIO; in toshiba_touchpad_get()
671 return -ENODEV; in toshiba_touchpad_get()
673 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_touchpad_get()
683 dev->eco_supported = 0; in toshiba_eco_mode_available()
714 dev->eco_supported = 1; in toshiba_eco_mode_available()
762 dev->accelerometer_supported = 0; in toshiba_accelerometer_available()
777 dev->accelerometer_supported = 1; in toshiba_accelerometer_available()
791 return -EIO; in toshiba_accelerometer_get()
795 return -ENODEV; in toshiba_accelerometer_get()
798 return -EIO; in toshiba_accelerometer_get()
813 dev->usb_sleep_charge_supported = 0; in toshiba_usb_sleep_charge_available()
830 dev->usbsc_mode_base = out[4]; in toshiba_usb_sleep_charge_available()
843 dev->usbsc_bat_level = out[2]; in toshiba_usb_sleep_charge_available()
845 dev->usb_sleep_charge_supported = 1; in toshiba_usb_sleep_charge_available()
854 return -EIO; in toshiba_usb_sleep_charge_get()
861 return -ENODEV; in toshiba_usb_sleep_charge_get()
863 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_charge_get()
872 return -EIO; in toshiba_usb_sleep_charge_set()
879 return -ENODEV; in toshiba_usb_sleep_charge_set()
881 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_charge_set()
892 return -EIO; in toshiba_sleep_functions_status_get()
899 return -EIO; in toshiba_sleep_functions_status_get()
903 return -ENODEV; in toshiba_sleep_functions_status_get()
906 return -EIO; in toshiba_sleep_functions_status_get()
922 return -EIO; in toshiba_sleep_functions_status_set()
930 return -EIO; in toshiba_sleep_functions_status_set()
934 return -ENODEV; in toshiba_sleep_functions_status_set()
936 return out[0] == TOS_SUCCESS ? 0 : -EIO; in toshiba_sleep_functions_status_set()
947 return -EIO; in toshiba_usb_rapid_charge_get()
954 return -EIO; in toshiba_usb_rapid_charge_get()
958 return -ENODEV; in toshiba_usb_rapid_charge_get()
961 return -EIO; in toshiba_usb_rapid_charge_get()
976 return -EIO; in toshiba_usb_rapid_charge_set()
984 return -EIO; in toshiba_usb_rapid_charge_set()
988 return -ENODEV; in toshiba_usb_rapid_charge_set()
990 return (out[0] == TOS_SUCCESS || out[0] == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_rapid_charge_set()
998 return -EIO; in toshiba_usb_sleep_music_get()
1005 return -ENODEV; in toshiba_usb_sleep_music_get()
1007 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_music_get()
1015 return -EIO; in toshiba_usb_sleep_music_set()
1022 return -ENODEV; in toshiba_usb_sleep_music_set()
1024 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_music_set()
1033 return -EIO; in toshiba_function_keys_get()
1040 return -ENODEV; in toshiba_function_keys_get()
1042 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_function_keys_get()
1050 return -EIO; in toshiba_function_keys_set()
1057 return -ENODEV; in toshiba_function_keys_set()
1059 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_function_keys_set()
1068 return -EIO; in toshiba_panel_power_on_get()
1075 return -ENODEV; in toshiba_panel_power_on_get()
1077 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_panel_power_on_get()
1085 return -EIO; in toshiba_panel_power_on_set()
1092 return -ENODEV; in toshiba_panel_power_on_set()
1094 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_panel_power_on_set()
1103 return -EIO; in toshiba_usb_three_get()
1110 return -ENODEV; in toshiba_usb_three_get()
1112 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_three_get()
1120 return -EIO; in toshiba_usb_three_set()
1127 return -ENODEV; in toshiba_usb_three_set()
1129 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_three_set()
1143 return -EIO; in toshiba_hotkey_event_type_get()
1147 return -ENODEV; in toshiba_hotkey_event_type_get()
1150 return -EIO; in toshiba_hotkey_event_type_get()
1169 return -EIO; in toshiba_wireless_status()
1173 return -ENODEV; in toshiba_wireless_status()
1176 return -EIO; in toshiba_wireless_status()
1178 dev->killswitch = !!(out[2] & HCI_WIRELESS_STATUS); in toshiba_wireless_status()
1190 dev->wwan_supported = 0; in toshiba_wwan_available()
1212 dev->wwan_supported = (out[2] == HCI_WIRELESS_WWAN_STATUS); in toshiba_wwan_available()
1225 return -EIO; in toshiba_wwan_set()
1229 return -ENODEV; in toshiba_wwan_set()
1232 return -EIO; in toshiba_wwan_set()
1243 return -EIO; in toshiba_wwan_set()
1247 return -ENODEV; in toshiba_wwan_set()
1249 return out[0] == TOS_SUCCESS ? 0 : -EIO; in toshiba_wwan_set()
1259 dev->cooling_method_supported = 0; in toshiba_cooling_method_available()
1260 dev->max_cooling_method = 0; in toshiba_cooling_method_available()
1271 dev->cooling_method_supported = 1; in toshiba_cooling_method_available()
1272 dev->max_cooling_method = out[3]; in toshiba_cooling_method_available()
1283 return -ENODEV; in toshiba_cooling_method_get()
1285 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_cooling_method_get()
1296 return -ENODEV; in toshiba_cooling_method_set()
1298 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_cooling_method_set()
1308 dev->battery_charge_mode_supported = 0; in toshiba_battery_charge_mode_available()
1319 dev->battery_charge_mode_supported = 1; in toshiba_battery_charge_mode_available()
1339 return -ENODEV; in toshiba_battery_charge_mode_get()
1341 retries--; in toshiba_battery_charge_mode_get()
1344 return -EIO; in toshiba_battery_charge_mode_get()
1348 return -EIO; in toshiba_battery_charge_mode_get()
1359 return -ENODEV; in toshiba_battery_charge_mode_set()
1361 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_battery_charge_mode_set()
1372 return -ENODEV; in get_tr_backlight_status()
1374 return result == TOS_SUCCESS ? 0 : -EIO; in get_tr_backlight_status()
1384 return -ENODEV; in set_tr_backlight_status()
1386 return result == TOS_SUCCESS ? 0 : -EIO; in set_tr_backlight_status()
1398 if (dev->tr_backlight_supported) { in __get_lcd_brightness()
1412 return -ENODEV; in __get_lcd_brightness()
1416 -EIO; in __get_lcd_brightness()
1428 struct toshiba_acpi_dev *dev = m->private; in lcd_proc_show()
1432 if (!dev->backlight_dev) in lcd_proc_show()
1433 return -ENODEV; in lcd_proc_show()
1435 levels = dev->backlight_dev->props.max_brightness + 1; in lcd_proc_show()
1436 value = get_lcd_brightness(dev->backlight_dev); in lcd_proc_show()
1457 if (dev->tr_backlight_supported) { in set_lcd_brightness()
1463 value--; in set_lcd_brightness()
1471 return -ENODEV; in set_lcd_brightness()
1473 return result == TOS_SUCCESS ? 0 : -EIO; in set_lcd_brightness()
1480 return set_lcd_brightness(dev, bd->props.brightness); in set_lcd_status()
1492 len = min(count, sizeof(cmd) - 1); in lcd_proc_write()
1494 return -EFAULT; in lcd_proc_write()
1497 levels = dev->backlight_dev->props.max_brightness + 1; in lcd_proc_write()
1500 return -EINVAL; in lcd_proc_write()
1503 return -EIO; in lcd_proc_write()
1516 /* Video-Out */
1522 pr_err("ACPI call to get Video-Out failed\n"); in get_video_status()
1524 return -ENODEV; in get_video_status()
1526 return result == TOS_SUCCESS ? 0 : -EIO; in get_video_status()
1531 struct toshiba_acpi_dev *dev = m->private; in video_proc_show()
1536 return -EIO; in video_proc_show()
1560 int lcd_out = -1, crt_out = -1, tv_out = -1; in video_proc_write()
1586 --remain; in video_proc_write()
1587 } while (remain && *(buffer - 1) != ';'); in video_proc_write()
1596 if (lcd_out != -1) in video_proc_write()
1598 if (crt_out != -1) in video_proc_write()
1600 if (tv_out != -1) in video_proc_write()
1610 return ret ? -EIO : count; in video_proc_write()
1629 return -ENODEV; in get_fan_status()
1631 return result == TOS_SUCCESS ? 0 : -EIO; in get_fan_status()
1641 return -ENODEV; in set_fan_status()
1643 return result == TOS_SUCCESS ? 0 : -EIO; in set_fan_status()
1648 struct toshiba_acpi_dev *dev = m->private; in fan_proc_show()
1652 return -EIO; in fan_proc_show()
1655 seq_printf(m, "force_on: %d\n", dev->force_fan); in fan_proc_show()
1673 len = min(count, sizeof(cmd) - 1); in fan_proc_write()
1675 return -EFAULT; in fan_proc_write()
1680 return -EINVAL; in fan_proc_write()
1683 return -EIO; in fan_proc_write()
1685 dev->force_fan = value; in fan_proc_write()
1707 return -EIO; in get_fan_rpm()
1711 return -ENODEV; in get_fan_rpm()
1718 return -EIO; in get_fan_rpm()
1723 struct toshiba_acpi_dev *dev = m->private; in keys_proc_show()
1725 seq_printf(m, "hotkey_ready: %d\n", dev->key_event_valid); in keys_proc_show()
1726 seq_printf(m, "hotkey: 0x%04x\n", dev->last_key_event); in keys_proc_show()
1744 len = min(count, sizeof(cmd) - 1); in keys_proc_write()
1746 return -EFAULT; in keys_proc_write()
1750 dev->key_event_valid = 0; in keys_proc_write()
1752 return -EINVAL; in keys_proc_write()
1780 if (dev->backlight_dev) in create_toshiba_proc_entries()
1783 if (dev->video_supported) in create_toshiba_proc_entries()
1786 if (dev->fan_supported) in create_toshiba_proc_entries()
1789 if (dev->hotkey_dev) in create_toshiba_proc_entries()
1798 if (dev->backlight_dev) in remove_toshiba_proc_entries()
1800 if (dev->video_supported) in remove_toshiba_proc_entries()
1802 if (dev->fan_supported) in remove_toshiba_proc_entries()
1804 if (dev->hotkey_dev) in remove_toshiba_proc_entries()
1843 return -EINVAL; in fan_store()
1881 if (toshiba->kbd_type == 1) { in kbd_backlight_mode_store()
1884 return -EINVAL; in kbd_backlight_mode_store()
1885 } else if (toshiba->kbd_type == 2) { in kbd_backlight_mode_store()
1889 return -EINVAL; in kbd_backlight_mode_store()
1894 * Auto - KBD backlight turns off automatically in given time in kbd_backlight_mode_store()
1895 * FN-Z - KBD backlight "toggles" when hotkey pressed in kbd_backlight_mode_store()
1896 * ON - KBD backlight is always on in kbd_backlight_mode_store()
1897 * OFF - KBD backlight is always off in kbd_backlight_mode_store()
1901 if (toshiba->kbd_mode != mode) { in kbd_backlight_mode_store()
1903 int time = toshiba->kbd_time << HCI_MISC_SHIFT; in kbd_backlight_mode_store()
1906 if (toshiba->kbd_type == 1) { in kbd_backlight_mode_store()
1908 time |= toshiba->kbd_mode; in kbd_backlight_mode_store()
1909 } else if (toshiba->kbd_type == 2) { in kbd_backlight_mode_store()
1918 toshiba->kbd_mode = mode; in kbd_backlight_mode_store()
1919 toshiba_acpi->kbd_mode = mode; in kbd_backlight_mode_store()
1935 if (toshiba->kbd_type == 2 && in kbd_backlight_mode_store()
1936 !toshiba->kbd_event_generated) in kbd_backlight_mode_store()
1951 return -EIO; in kbd_backlight_mode_show()
1962 return sprintf(buf, "%d\n", toshiba->kbd_type); in kbd_type_show()
1972 if (toshiba->kbd_type == 1) in available_kbd_modes_show()
1994 if (toshiba->kbd_type == 1) { in kbd_backlight_timeout_store()
1996 return -EINVAL; in kbd_backlight_timeout_store()
1997 } else if (toshiba->kbd_type == 2) { in kbd_backlight_timeout_store()
1999 return -EINVAL; in kbd_backlight_timeout_store()
2005 if (toshiba->kbd_time != time) { in kbd_backlight_timeout_store()
2009 if (toshiba->kbd_type == 1) in kbd_backlight_timeout_store()
2011 else if (toshiba->kbd_type == 2) in kbd_backlight_timeout_store()
2018 toshiba->kbd_time = time >> HCI_MISC_SHIFT; in kbd_backlight_timeout_store()
2032 return -EIO; in kbd_backlight_timeout_show()
2046 /* Set the TouchPad on/off, 0 - Disable | 1 - Enable */ in touchpad_store()
2051 return -EINVAL; in touchpad_store()
2103 * 0 - Disabled in usb_sleep_charge_store()
2104 * 1 - Alternate (Non USB conformant devices that require more power) in usb_sleep_charge_store()
2105 * 2 - Auto (USB conformant devices) in usb_sleep_charge_store()
2106 * 3 - Typical in usb_sleep_charge_store()
2109 return -EINVAL; in usb_sleep_charge_store()
2112 mode = toshiba->usbsc_mode_base; in usb_sleep_charge_store()
2144 /* Determine the status: 0x4 - Enabled | 0x1 - Disabled */ in sleep_functions_on_battery_show()
2169 * 0 - Disabled in sleep_functions_on_battery_store()
2170 * 1-100 - Enabled in sleep_functions_on_battery_store()
2173 return -EINVAL; in sleep_functions_on_battery_store()
2176 tmp = toshiba->usbsc_bat_level << HCI_MISC_SHIFT; in sleep_functions_on_battery_store()
2186 toshiba->usbsc_bat_level = status >> HCI_MISC_SHIFT; in sleep_functions_on_battery_store()
2218 return -EINVAL; in usb_rapid_charge_store()
2254 return -EINVAL; in usb_sleep_music_store()
2291 * 0 - Normal operation (F{1-12} as usual and hotkeys via FN-F{1-12}) in kbd_function_keys_store()
2292 * 1 - Special functions (Opposite of the above setting) in kbd_function_keys_store()
2295 return -EINVAL; in kbd_function_keys_store()
2333 return -EINVAL; in panel_power_on_store()
2372 * 0 - Disabled (Acts like a USB 2 port, saving power) in usb_three_store()
2373 * 1 - Enabled in usb_three_store()
2376 return -EINVAL; in usb_three_store()
2399 return sprintf(buf, "%d %d\n", state, toshiba->max_cooling_method); in cooling_method_show()
2417 * 0 - Maximum Performance in cooling_method_store()
2418 * 1 - Battery Optimized in cooling_method_store()
2421 * 0 - Maximum Performance in cooling_method_store()
2422 * 1 - Performance in cooling_method_store()
2423 * 2 - Battery Optimized in cooling_method_store()
2425 if (state < 0 || state > toshiba->max_cooling_method) in cooling_method_store()
2426 return -EINVAL; in cooling_method_store()
2463 exists = (drv->fan_supported) ? true : false; in toshiba_sysfs_is_visible()
2465 exists = (drv->kbd_illum_supported) ? true : false; in toshiba_sysfs_is_visible()
2467 exists = (drv->kbd_mode == SCI_KBD_MODE_AUTO) ? true : false; in toshiba_sysfs_is_visible()
2469 exists = (drv->touchpad_supported) ? true : false; in toshiba_sysfs_is_visible()
2471 exists = (drv->usb_sleep_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2473 exists = (drv->usb_sleep_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2475 exists = (drv->usb_rapid_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2477 exists = (drv->usb_sleep_music_supported) ? true : false; in toshiba_sysfs_is_visible()
2479 exists = (drv->kbd_function_keys_supported) ? true : false; in toshiba_sysfs_is_visible()
2481 exists = (drv->panel_power_on_supported) ? true : false; in toshiba_sysfs_is_visible()
2483 exists = (drv->usb_three_supported) ? true : false; in toshiba_sysfs_is_visible()
2485 exists = (drv->cooling_method_supported) ? true : false; in toshiba_sysfs_is_visible()
2487 return exists ? attr->mode : 0; in toshiba_sysfs_is_visible()
2498 if (sysfs_update_group(&toshiba_acpi->acpi_dev->dev.kobj, in toshiba_acpi_kbd_bl_work()
2503 if (toshiba_acpi->kbd_type == 2 && in toshiba_acpi_kbd_bl_work()
2504 toshiba_acpi->kbd_mode != SCI_KBD_MODE_AUTO) in toshiba_acpi_kbd_bl_work()
2505 led_classdev_notify_brightness_hw_changed(&toshiba_acpi->kbd_led, in toshiba_acpi_kbd_bl_work()
2506 (toshiba_acpi->kbd_mode == SCI_KBD_MODE_ON) ? in toshiba_acpi_kbd_bl_work()
2510 acpi_bus_generate_netlink_event(toshiba_acpi->acpi_dev->pnp.device_class, in toshiba_acpi_kbd_bl_work()
2511 dev_name(&toshiba_acpi->acpi_dev->dev), in toshiba_acpi_kbd_bl_work()
2537 -(xyval & HCI_ACCEL_MASK) : xyval & HCI_ACCEL_MASK; in toshiba_iio_accel_get_axis()
2540 -((xyval >> HCI_MISC_SHIFT) & HCI_ACCEL_MASK) : in toshiba_iio_accel_get_axis()
2544 -(zval & HCI_ACCEL_MASK) : zval & HCI_ACCEL_MASK; in toshiba_iio_accel_get_axis()
2558 ret = toshiba_iio_accel_get_axis(chan->channel); in toshiba_iio_accel_read_raw()
2559 if (ret == -EIO || ret == -ENODEV) in toshiba_iio_accel_read_raw()
2567 return -EINVAL; in toshiba_iio_accel_read_raw()
2594 u32 in[TCI_WORDS] = { regs->eax, regs->ebx, regs->ecx, in toshiba_acpi_smm_bridge()
2595 regs->edx, regs->esi, regs->edi }; in toshiba_acpi_smm_bridge()
2602 return -EIO; in toshiba_acpi_smm_bridge()
2606 regs->eax = out[0]; in toshiba_acpi_smm_bridge()
2607 regs->ebx = out[1]; in toshiba_acpi_smm_bridge()
2608 regs->ecx = out[2]; in toshiba_acpi_smm_bridge()
2609 regs->edx = out[3]; in toshiba_acpi_smm_bridge()
2610 regs->esi = out[4]; in toshiba_acpi_smm_bridge()
2611 regs->edi = out[5]; in toshiba_acpi_smm_bridge()
2624 return -EINVAL; in toshiba_acpi_ioctl()
2629 return -EFAULT; in toshiba_acpi_ioctl()
2634 return -EFAULT; in toshiba_acpi_ioctl()
2638 return -EFAULT; in toshiba_acpi_ioctl()
2641 return -EINVAL; in toshiba_acpi_ioctl()
2643 return -EIO; in toshiba_acpi_ioctl()
2649 return -EFAULT; in toshiba_acpi_ioctl()
2652 return -EINVAL; in toshiba_acpi_ioctl()
2676 if (!dev->killswitch) in toshiba_acpi_wwan_set_block()
2689 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_wwan_poll()
2704 dev->wwan_rfk = rfkill_alloc("Toshiba WWAN", in toshiba_acpi_setup_wwan_rfkill()
2705 &dev->acpi_dev->dev, in toshiba_acpi_setup_wwan_rfkill()
2709 if (!dev->wwan_rfk) { in toshiba_acpi_setup_wwan_rfkill()
2711 return -ENOMEM; in toshiba_acpi_setup_wwan_rfkill()
2714 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_setup_wwan_rfkill()
2716 ret = rfkill_register(dev->wwan_rfk); in toshiba_acpi_setup_wwan_rfkill()
2719 rfkill_destroy(dev->wwan_rfk); in toshiba_acpi_setup_wwan_rfkill()
2733 status = acpi_evaluate_object(dev->acpi_dev->handle, in toshiba_acpi_enable_hotkeys()
2736 return -ENODEV; in toshiba_acpi_enable_hotkeys()
2747 else if (dev->kbd_function_keys_supported && dev->special_functions) in toshiba_acpi_enable_hotkeys()
2754 return -EIO; in toshiba_acpi_enable_hotkeys()
2756 return -ENODEV; in toshiba_acpi_enable_hotkeys()
2771 schedule_work(&toshiba_acpi->hotkey_work); in toshiba_acpi_i8042_filter()
2799 status = acpi_evaluate_integer(dev->acpi_dev->handle, "INFO", in toshiba_acpi_query_hotkey()
2803 return -EIO; in toshiba_acpi_query_hotkey()
2819 if (!sparse_keymap_report_event(dev->hotkey_dev, scancode, 1, true)) in toshiba_acpi_report_hotkey()
2825 if (dev->info_supported) { in toshiba_acpi_process_hotkeys()
2832 dev->key_event_valid = 1; in toshiba_acpi_process_hotkeys()
2833 dev->last_key_event = scancode; in toshiba_acpi_process_hotkeys()
2835 } else if (dev->system_event_supported) { in toshiba_acpi_process_hotkeys()
2845 dev->key_event_valid = 1; in toshiba_acpi_process_hotkeys()
2846 dev->last_key_event = value; in toshiba_acpi_process_hotkeys()
2856 pr_notice("Re-enabled hotkeys\n"); in toshiba_acpi_process_hotkeys()
2859 retries--; in toshiba_acpi_process_hotkeys()
2868 const struct key_entry *keymap = toshiba_acpi_keymap; in toshiba_acpi_setup_keyboard() local
2886 if (toshiba_hotkey_event_type_get(dev, &dev->hotkey_event_type)) in toshiba_acpi_setup_keyboard()
2889 dev->hotkey_dev = input_allocate_device(); in toshiba_acpi_setup_keyboard()
2890 if (!dev->hotkey_dev) in toshiba_acpi_setup_keyboard()
2891 return -ENOMEM; in toshiba_acpi_setup_keyboard()
2893 dev->hotkey_dev->name = "Toshiba input device"; in toshiba_acpi_setup_keyboard()
2894 dev->hotkey_dev->phys = "toshiba_acpi/input0"; in toshiba_acpi_setup_keyboard()
2895 dev->hotkey_dev->id.bustype = BUS_HOST; in toshiba_acpi_setup_keyboard()
2896 dev->hotkey_dev->dev.parent = &dev->acpi_dev->dev; in toshiba_acpi_setup_keyboard()
2898 if (dev->hotkey_event_type == HCI_SYSTEM_TYPE1 || in toshiba_acpi_setup_keyboard()
2899 !dev->kbd_function_keys_supported) in toshiba_acpi_setup_keyboard()
2900 keymap = toshiba_acpi_keymap; in toshiba_acpi_setup_keyboard()
2901 else if (dev->hotkey_event_type == HCI_SYSTEM_TYPE2 || in toshiba_acpi_setup_keyboard()
2902 dev->kbd_function_keys_supported) in toshiba_acpi_setup_keyboard()
2903 keymap = toshiba_acpi_alt_keymap; in toshiba_acpi_setup_keyboard()
2906 dev->hotkey_event_type); in toshiba_acpi_setup_keyboard()
2907 error = sparse_keymap_setup(dev->hotkey_dev, keymap, NULL); in toshiba_acpi_setup_keyboard()
2914 * whenever the Fn key is pressed using the NTFY method, if in toshiba_acpi_setup_keyboard()
2920 INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work); in toshiba_acpi_setup_keyboard()
2928 dev->ntfy_supported = 1; in toshiba_acpi_setup_keyboard()
2935 if (acpi_has_method(dev->acpi_dev->handle, "INFO")) in toshiba_acpi_setup_keyboard()
2936 dev->info_supported = 1; in toshiba_acpi_setup_keyboard()
2938 dev->system_event_supported = 1; in toshiba_acpi_setup_keyboard()
2940 if (!dev->info_supported && !dev->system_event_supported) { in toshiba_acpi_setup_keyboard()
2942 error = -EINVAL; in toshiba_acpi_setup_keyboard()
2946 error = input_register_device(dev->hotkey_dev); in toshiba_acpi_setup_keyboard()
2955 if (dev->ntfy_supported) in toshiba_acpi_setup_keyboard()
2958 input_free_device(dev->hotkey_dev); in toshiba_acpi_setup_keyboard()
2959 dev->hotkey_dev = NULL; in toshiba_acpi_setup_keyboard()
2971 * others support it read-only. Either of these is pretty useless, in toshiba_acpi_setup_backlight()
2984 if (dev->tr_backlight_supported && brightness == 0) in toshiba_acpi_setup_backlight()
2988 pr_debug("Backlight method is read-only, disabling backlight support\n"); in toshiba_acpi_setup_backlight()
2997 props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; in toshiba_acpi_setup_backlight()
3000 if (dev->tr_backlight_supported) in toshiba_acpi_setup_backlight()
3003 dev->backlight_dev = backlight_device_register("toshiba", in toshiba_acpi_setup_backlight()
3004 &dev->acpi_dev->dev, in toshiba_acpi_setup_backlight()
3008 if (IS_ERR(dev->backlight_dev)) { in toshiba_acpi_setup_backlight()
3009 ret = PTR_ERR(dev->backlight_dev); in toshiba_acpi_setup_backlight()
3011 dev->backlight_dev = NULL; in toshiba_acpi_setup_backlight()
3015 dev->backlight_dev->props.brightness = brightness; in toshiba_acpi_setup_backlight()
3048 return -EOPNOTSUPP; in toshiba_acpi_hwmon_read()
3077 return -ENODEV; in charge_control_end_threshold_show()
3101 return -ENODEV; in charge_control_end_threshold_store()
3109 return -EINVAL; in charge_control_end_threshold_store()
3131 return -ENODEV; in toshiba_acpi_battery_add()
3133 if (!toshiba_acpi->battery_charge_mode_supported) in toshiba_acpi_battery_add()
3134 return -ENODEV; in toshiba_acpi_battery_add()
3135 if (device_add_groups(&battery->dev, toshiba_acpi_battery_groups)) in toshiba_acpi_battery_add()
3136 return -ENODEV; in toshiba_acpi_battery_add()
3142 device_remove_groups(&battery->dev, toshiba_acpi_battery_groups); in toshiba_acpi_battery_remove()
3156 if (dev->hotkey_dev) in print_supported_features()
3158 if (dev->backlight_dev) in print_supported_features()
3160 if (dev->video_supported) in print_supported_features()
3161 pr_cont(" video-out"); in print_supported_features()
3162 if (dev->fan_supported) in print_supported_features()
3164 if (dev->fan_rpm_supported) in print_supported_features()
3165 pr_cont(" fan-rpm"); in print_supported_features()
3166 if (dev->tr_backlight_supported) in print_supported_features()
3167 pr_cont(" transflective-backlight"); in print_supported_features()
3168 if (dev->illumination_supported) in print_supported_features()
3170 if (dev->kbd_illum_supported) in print_supported_features()
3171 pr_cont(" keyboard-backlight"); in print_supported_features()
3172 if (dev->touchpad_supported) in print_supported_features()
3174 if (dev->eco_supported) in print_supported_features()
3175 pr_cont(" eco-led"); in print_supported_features()
3176 if (dev->accelerometer_supported) in print_supported_features()
3177 pr_cont(" accelerometer-axes"); in print_supported_features()
3178 if (dev->usb_sleep_charge_supported) in print_supported_features()
3179 pr_cont(" usb-sleep-charge"); in print_supported_features()
3180 if (dev->usb_rapid_charge_supported) in print_supported_features()
3181 pr_cont(" usb-rapid-charge"); in print_supported_features()
3182 if (dev->usb_sleep_music_supported) in print_supported_features()
3183 pr_cont(" usb-sleep-music"); in print_supported_features()
3184 if (dev->kbd_function_keys_supported) in print_supported_features()
3185 pr_cont(" special-function-keys"); in print_supported_features()
3186 if (dev->panel_power_on_supported) in print_supported_features()
3187 pr_cont(" panel-power-on"); in print_supported_features()
3188 if (dev->usb_three_supported) in print_supported_features()
3190 if (dev->wwan_supported) in print_supported_features()
3192 if (dev->cooling_method_supported) in print_supported_features()
3193 pr_cont(" cooling-method"); in print_supported_features()
3194 if (dev->battery_charge_mode_supported) in print_supported_features()
3195 pr_cont(" battery-charge-mode"); in print_supported_features()
3204 misc_deregister(&dev->miscdev); in toshiba_acpi_remove()
3209 if (dev->hwmon_device) in toshiba_acpi_remove()
3210 hwmon_device_unregister(dev->hwmon_device); in toshiba_acpi_remove()
3213 if (dev->accelerometer_supported && dev->indio_dev) { in toshiba_acpi_remove()
3214 iio_device_unregister(dev->indio_dev); in toshiba_acpi_remove()
3215 iio_device_free(dev->indio_dev); in toshiba_acpi_remove()
3218 if (dev->sysfs_created) in toshiba_acpi_remove()
3219 sysfs_remove_group(&dev->acpi_dev->dev.kobj, in toshiba_acpi_remove()
3222 if (dev->ntfy_supported) { in toshiba_acpi_remove()
3224 cancel_work_sync(&dev->hotkey_work); in toshiba_acpi_remove()
3227 if (dev->hotkey_dev) in toshiba_acpi_remove()
3228 input_unregister_device(dev->hotkey_dev); in toshiba_acpi_remove()
3230 backlight_device_unregister(dev->backlight_dev); in toshiba_acpi_remove()
3232 led_classdev_unregister(&dev->led_dev); in toshiba_acpi_remove()
3233 led_classdev_unregister(&dev->kbd_led); in toshiba_acpi_remove()
3234 led_classdev_unregister(&dev->eco_led); in toshiba_acpi_remove()
3236 if (dev->wwan_rfk) { in toshiba_acpi_remove()
3237 rfkill_unregister(dev->wwan_rfk); in toshiba_acpi_remove()
3238 rfkill_destroy(dev->wwan_rfk); in toshiba_acpi_remove()
3241 if (dev->battery_charge_mode_supported) in toshiba_acpi_remove()
3262 * Some Toshibas have a broken acpi-video interface for brightness control,
3317 return -EBUSY; in toshiba_acpi_add()
3322 hci_method = find_hci_method(acpi_dev->handle); in toshiba_acpi_add()
3325 return -ENODEV; in toshiba_acpi_add()
3330 return -ENOMEM; in toshiba_acpi_add()
3331 dev->acpi_dev = acpi_dev; in toshiba_acpi_add()
3332 dev->method_hci = hci_method; in toshiba_acpi_add()
3333 dev->miscdev.minor = MISC_DYNAMIC_MINOR; in toshiba_acpi_add()
3334 dev->miscdev.name = "toshiba_acpi"; in toshiba_acpi_add()
3335 dev->miscdev.fops = &toshiba_acpi_fops; in toshiba_acpi_add()
3337 ret = misc_register(&dev->miscdev); in toshiba_acpi_add()
3344 acpi_dev->driver_data = dev; in toshiba_acpi_add()
3345 dev_set_drvdata(&acpi_dev->dev, dev); in toshiba_acpi_add()
3352 * determine the keymap layout to use. in toshiba_acpi_add()
3354 ret = toshiba_function_keys_get(dev, &dev->special_functions); in toshiba_acpi_add()
3355 dev->kbd_function_keys_supported = !ret; in toshiba_acpi_add()
3357 dev->hotkey_event_type = 0; in toshiba_acpi_add()
3363 dev->tr_backlight_supported = !ret; in toshiba_acpi_add()
3370 if (dev->illumination_supported) { in toshiba_acpi_add()
3371 dev->led_dev.name = "toshiba::illumination"; in toshiba_acpi_add()
3372 dev->led_dev.max_brightness = 1; in toshiba_acpi_add()
3373 dev->led_dev.brightness_set = toshiba_illumination_set; in toshiba_acpi_add()
3374 dev->led_dev.brightness_get = toshiba_illumination_get; in toshiba_acpi_add()
3375 led_classdev_register(&acpi_dev->dev, &dev->led_dev); in toshiba_acpi_add()
3379 if (dev->eco_supported) { in toshiba_acpi_add()
3380 dev->eco_led.name = "toshiba::eco_mode"; in toshiba_acpi_add()
3381 dev->eco_led.max_brightness = 1; in toshiba_acpi_add()
3382 dev->eco_led.brightness_set = toshiba_eco_mode_set_status; in toshiba_acpi_add()
3383 dev->eco_led.brightness_get = toshiba_eco_mode_get_status; in toshiba_acpi_add()
3384 led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led); in toshiba_acpi_add()
3390 * and the keyboard backlight operation mode is set to FN-Z in toshiba_acpi_add()
3393 if (dev->kbd_illum_supported && in toshiba_acpi_add()
3394 (dev->kbd_mode == SCI_KBD_MODE_FNZ || dev->kbd_type == 2)) { in toshiba_acpi_add()
3395 dev->kbd_led.name = "toshiba::kbd_backlight"; in toshiba_acpi_add()
3396 dev->kbd_led.flags = LED_BRIGHT_HW_CHANGED; in toshiba_acpi_add()
3397 dev->kbd_led.max_brightness = 1; in toshiba_acpi_add()
3398 dev->kbd_led.brightness_set = toshiba_kbd_backlight_set; in toshiba_acpi_add()
3399 dev->kbd_led.brightness_get = toshiba_kbd_backlight_get; in toshiba_acpi_add()
3400 led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led); in toshiba_acpi_add()
3404 dev->touchpad_supported = !ret; in toshiba_acpi_add()
3407 if (dev->accelerometer_supported) { in toshiba_acpi_add()
3408 dev->indio_dev = iio_device_alloc(&acpi_dev->dev, sizeof(*dev)); in toshiba_acpi_add()
3409 if (!dev->indio_dev) { in toshiba_acpi_add()
3416 dev->indio_dev->info = &toshiba_iio_accel_info; in toshiba_acpi_add()
3417 dev->indio_dev->name = "Toshiba accelerometer"; in toshiba_acpi_add()
3418 dev->indio_dev->modes = INDIO_DIRECT_MODE; in toshiba_acpi_add()
3419 dev->indio_dev->channels = toshiba_iio_accel_channels; in toshiba_acpi_add()
3420 dev->indio_dev->num_channels = in toshiba_acpi_add()
3423 ret = iio_device_register(dev->indio_dev); in toshiba_acpi_add()
3426 iio_device_free(dev->indio_dev); in toshiba_acpi_add()
3434 dev->usb_rapid_charge_supported = !ret; in toshiba_acpi_add()
3437 dev->usb_sleep_music_supported = !ret; in toshiba_acpi_add()
3440 dev->panel_power_on_supported = !ret; in toshiba_acpi_add()
3443 dev->usb_three_supported = !ret; in toshiba_acpi_add()
3446 dev->video_supported = !ret; in toshiba_acpi_add()
3449 dev->fan_supported = !ret; in toshiba_acpi_add()
3452 dev->fan_rpm_supported = !ret; in toshiba_acpi_add()
3455 if (dev->fan_rpm_supported) { in toshiba_acpi_add()
3456 dev->hwmon_device = hwmon_device_register_with_info( in toshiba_acpi_add()
3457 &dev->acpi_dev->dev, "toshiba_acpi_sensors", NULL, in toshiba_acpi_add()
3459 if (IS_ERR(dev->hwmon_device)) { in toshiba_acpi_add()
3460 dev->hwmon_device = NULL; in toshiba_acpi_add()
3467 if (dev->wwan_supported) in toshiba_acpi_add()
3476 ret = sysfs_create_group(&dev->acpi_dev->dev.kobj, in toshiba_acpi_add()
3479 dev->sysfs_created = 0; in toshiba_acpi_add()
3482 dev->sysfs_created = !ret; in toshiba_acpi_add()
3492 if (dev->battery_charge_mode_supported) in toshiba_acpi_add()
3534 dev->kbd_event_generated = true; in toshiba_acpi_notify()
3536 if (sysfs_update_group(&acpi_dev->dev.kobj, in toshiba_acpi_notify()
3540 if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) in toshiba_acpi_notify()
3541 led_classdev_notify_brightness_hw_changed(&dev->kbd_led, in toshiba_acpi_notify()
3542 (dev->kbd_mode == SCI_KBD_MODE_ON) ? in toshiba_acpi_notify()
3555 acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, in toshiba_acpi_notify()
3556 dev_name(&acpi_dev->dev), in toshiba_acpi_notify()
3558 dev->last_key_event : 0); in toshiba_acpi_notify()
3566 if (dev->hotkey_dev) { in toshiba_acpi_suspend()
3581 if (dev->hotkey_dev) { in toshiba_acpi_resume()
3583 pr_info("Unable to re-enable hotkeys\n"); in toshiba_acpi_resume()
3586 if (dev->wwan_rfk) { in toshiba_acpi_resume()
3588 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_resume()
3621 quirks = (long)dmi_id->driver_data; in toshiba_dmi_init()
3623 if (turn_on_panel_on_resume == -1) in toshiba_dmi_init()
3626 if (hci_hotkey_quickstart == -1) in toshiba_dmi_init()
3638 return -ENODEV; in toshiba_acpi_init()