Lines Matching +full:rate +full:- +full:ati +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ideapad-laptop.c - Lenovo IdeaPad ACPI Extras
23 #include <linux/input/sparse-keymap.h>
35 #include "ideapad-laptop.h"
39 #include <dt-bindings/leds/common.h>
119 * These correspond to the number of supported states - 1
200 "Enable DYTC version 4 platform-profile support. "
201 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
207 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
212 "Enable driver based updates of the fn-lock LED on fn-lock changes. "
213 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
218 "Enable driver based PS/2 aux port en-/dis-abling on touchpad on/off toggle. "
219 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
224 "Enable registering a 'touchpad' sysfs-attribute which can be used to manually "
230 "Enable EC triggering work-around to force emitting tablet mode events. "
231 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
250 dev_warn(&priv->adev->dev, "found multiple platform devices\n"); in ideapad_shared_init()
251 ret = -EINVAL; in ideapad_shared_init()
268 #define IDEAPAD_EC_TIMEOUT 200 /* in ms */
277 return -EIO; in eval_int()
299 return -EIO; in eval_int_with_arg()
311 return ACPI_FAILURE(status) ? -EIO : 0; in exec_simple_method()
369 return -EIO; in eval_vpcw()
398 return -ETIMEDOUT; in read_ec_data()
429 return -ETIMEDOUT; in write_ec_cmd()
437 struct ideapad_private *priv = s->private; in debugfs_status_show()
440 guard(mutex)(&priv->vpc_mutex); in debugfs_status_show()
442 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value)) in debugfs_status_show()
444 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) in debugfs_status_show()
446 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value)) in debugfs_status_show()
451 if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value)) in debugfs_status_show()
453 if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value)) in debugfs_status_show()
455 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value)) in debugfs_status_show()
457 if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value)) in debugfs_status_show()
462 if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) in debugfs_status_show()
464 if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value)) in debugfs_status_show()
469 if (!eval_gbmd(priv->adev->handle, &value)) in debugfs_status_show()
471 if (!eval_hals(priv->adev->handle, &value)) in debugfs_status_show()
480 struct ideapad_private *priv = s->private; in debugfs_cfg_show()
482 seq_printf(s, "_CFG: %#010lx\n\n", priv->cfg); in debugfs_cfg_show()
485 if (test_bit(CFG_CAP_BT_BIT, &priv->cfg)) in debugfs_cfg_show()
487 if (test_bit(CFG_CAP_3G_BIT, &priv->cfg)) in debugfs_cfg_show()
489 if (test_bit(CFG_CAP_WIFI_BIT, &priv->cfg)) in debugfs_cfg_show()
491 if (test_bit(CFG_CAP_CAM_BIT, &priv->cfg)) in debugfs_cfg_show()
496 if (test_bit(CFG_OSD_NUMLK_BIT, &priv->cfg)) in debugfs_cfg_show()
497 seq_puts(s, " num-lock"); in debugfs_cfg_show()
498 if (test_bit(CFG_OSD_CAPSLK_BIT, &priv->cfg)) in debugfs_cfg_show()
499 seq_puts(s, " caps-lock"); in debugfs_cfg_show()
500 if (test_bit(CFG_OSD_MICMUTE_BIT, &priv->cfg)) in debugfs_cfg_show()
501 seq_puts(s, " mic-mute"); in debugfs_cfg_show()
502 if (test_bit(CFG_OSD_TOUCHPAD_BIT, &priv->cfg)) in debugfs_cfg_show()
504 if (test_bit(CFG_OSD_CAM_BIT, &priv->cfg)) in debugfs_cfg_show()
509 switch (priv->cfg & 0x700) { in debugfs_cfg_show()
514 seq_puts(s, "ATI"); in debugfs_cfg_show()
520 seq_puts(s, "Intel and ATI"); in debugfs_cfg_show()
537 priv->debug = dir; in ideapad_debugfs_init()
545 debugfs_remove_recursive(priv->debug); in ideapad_debugfs_exit()
546 priv->debug = NULL; in ideapad_debugfs_exit()
560 scoped_guard(mutex, &priv->vpc_mutex) { in camera_power_show()
561 err = read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result); in camera_power_show()
581 scoped_guard(mutex, &priv->vpc_mutex) { in camera_power_store()
582 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state); in camera_power_store()
600 err = eval_gbmd(priv->adev->handle, &result); in conservation_mode_show()
619 err = exec_sbmc(priv->adev->handle, state ? SBMC_CONSERVATION_ON : SBMC_CONSERVATION_OFF); in conservation_mode_store()
636 scoped_guard(mutex, &priv->vpc_mutex) { in fan_mode_show()
637 err = read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result); in fan_mode_show()
658 return -EINVAL; in fan_mode_store()
660 scoped_guard(mutex, &priv->vpc_mutex) { in fan_mode_store()
661 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state); in fan_mode_store()
676 err = eval_hals(priv->adev->handle, &hals); in ideapad_fn_lock_get()
685 return exec_sals(priv->adev->handle, in ideapad_fn_lock_set()
691 if (!priv->fn_lock.initialized) in ideapad_fn_lock_led_notify()
694 if (brightness == priv->fn_lock.last_brightness) in ideapad_fn_lock_led_notify()
697 priv->fn_lock.last_brightness = brightness; in ideapad_fn_lock_led_notify()
699 led_classdev_notify_brightness_hw_changed(&priv->fn_lock.led, brightness); in ideapad_fn_lock_led_notify()
747 scoped_guard(mutex, &priv->vpc_mutex) { in touchpad_show()
748 err = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result); in touchpad_show()
753 priv->r_touchpad_val = result; in touchpad_show()
770 scoped_guard(mutex, &priv->vpc_mutex) { in touchpad_store()
771 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state); in touchpad_store()
776 priv->r_touchpad_val = state; in touchpad_store()
791 err = eval_hals(priv->adev->handle, &hals); in usb_charging_show()
810 err = exec_sals(priv->adev->handle, state ? SALS_USB_CHARGING_ON : SALS_USB_CHARGING_OFF); in usb_charging_store()
838 supported = test_bit(CFG_CAP_CAM_BIT, &priv->cfg); in ideapad_is_visible()
840 supported = priv->features.conservation_mode; in ideapad_is_visible()
842 supported = priv->features.fan_mode; in ideapad_is_visible()
844 supported = priv->features.fn_lock; in ideapad_is_visible()
846 supported = priv->features.touchpad_ctrl_via_ec; in ideapad_is_visible()
848 supported = priv->features.usb_charging; in ideapad_is_visible()
850 return supported ? attr->mode : 0; in ideapad_is_visible()
861 #define DYTC_CMD_QUERY 0 /* To get DYTC status - enable/revision */
866 #define DYTC_QUERY_ENABLE_BIT 8 /* Bit 8 - 0 = disabled, 1 = enabled */
867 #define DYTC_QUERY_SUBREV_BIT 16 /* Bits 16 - 27 - sub revision */
868 #define DYTC_QUERY_REV_BIT 28 /* Bits 28 - 31 - revision */
870 #define DYTC_GET_FUNCTION_BIT 8 /* Bits 8-11 - function setting */
871 #define DYTC_GET_MODE_BIT 12 /* Bits 12-15 - mode setting */
873 #define DYTC_SET_FUNCTION_BIT 12 /* Bits 12-15 - function setting */
874 #define DYTC_SET_MODE_BIT 16 /* Bits 16-19 - mode setting */
875 #define DYTC_SET_VALID_BIT 20 /* Bit 20 - 1 = on, 0 = off */
907 return -EINVAL; in convert_dytc_to_profile()
926 return -EOPNOTSUPP; in convert_profile_to_dytc()
941 *profile = dytc->current_profile; in dytc_profile_get()
946 * Helper function - check if we are in CQL mode and if we are
947 * - disable CQL,
948 * - run the command
949 * - enable CQL
958 err = eval_dytc(priv->adev->handle, DYTC_CMD_GET, output); in dytc_cql_command()
968 err = eval_dytc(priv->adev->handle, DYTC_DISABLE_CQL, NULL); in dytc_cql_command()
973 cmd_err = eval_dytc(priv->adev->handle, cmd, output); in dytc_cql_command()
977 err = eval_dytc(priv->adev->handle, DYTC_ENABLE_CQL, NULL); in dytc_cql_command()
993 struct ideapad_private *priv = dytc->priv; in dytc_profile_set()
997 scoped_guard(mutex_intr, &dytc->mutex) { in dytc_profile_set()
1000 err = eval_dytc(priv->adev->handle, DYTC_CMD_RESET, NULL); in dytc_profile_set()
1018 /* Success - update current profile */ in dytc_profile_set()
1019 dytc->current_profile = profile; in dytc_profile_set()
1023 return -EINTR; in dytc_profile_set()
1032 scoped_guard(mutex, &priv->dytc->mutex) in dytc_profile_refresh()
1042 if (profile != priv->dytc->current_profile) { in dytc_profile_refresh()
1043 priv->dytc->current_profile = profile; in dytc_profile_refresh()
1071 if (!priv->features.dytc) in ideapad_dytc_profile_init()
1072 return -ENODEV; in ideapad_dytc_profile_init()
1074 err = eval_dytc(priv->adev->handle, DYTC_CMD_QUERY, &output); in ideapad_dytc_profile_init()
1081 dev_info(&priv->platform_device->dev, "DYTC_QUERY_ENABLE_BIT returned false\n"); in ideapad_dytc_profile_init()
1082 return -ENODEV; in ideapad_dytc_profile_init()
1088 dev_info(&priv->platform_device->dev, "DYTC_VERSION < 4 is not supported\n"); in ideapad_dytc_profile_init()
1089 return -ENODEV; in ideapad_dytc_profile_init()
1094 dev_info(&priv->platform_device->dev, in ideapad_dytc_profile_init()
1096 return -ENODEV; in ideapad_dytc_profile_init()
1099 priv->dytc = kzalloc(sizeof(*priv->dytc), GFP_KERNEL); in ideapad_dytc_profile_init()
1100 if (!priv->dytc) in ideapad_dytc_profile_init()
1101 return -ENOMEM; in ideapad_dytc_profile_init()
1103 mutex_init(&priv->dytc->mutex); in ideapad_dytc_profile_init()
1105 priv->dytc->priv = priv; in ideapad_dytc_profile_init()
1106 priv->dytc->pprof.profile_get = dytc_profile_get; in ideapad_dytc_profile_init()
1107 priv->dytc->pprof.profile_set = dytc_profile_set; in ideapad_dytc_profile_init()
1110 set_bit(PLATFORM_PROFILE_LOW_POWER, priv->dytc->pprof.choices); in ideapad_dytc_profile_init()
1111 set_bit(PLATFORM_PROFILE_BALANCED, priv->dytc->pprof.choices); in ideapad_dytc_profile_init()
1112 set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices); in ideapad_dytc_profile_init()
1115 err = platform_profile_register(&priv->dytc->pprof); in ideapad_dytc_profile_init()
1125 mutex_destroy(&priv->dytc->mutex); in ideapad_dytc_profile_init()
1126 kfree(priv->dytc); in ideapad_dytc_profile_init()
1127 priv->dytc = NULL; in ideapad_dytc_profile_init()
1134 if (!priv->dytc) in ideapad_dytc_profile_exit()
1138 mutex_destroy(&priv->dytc->mutex); in ideapad_dytc_profile_exit()
1139 kfree(priv->dytc); in ideapad_dytc_profile_exit()
1141 priv->dytc = NULL; in ideapad_dytc_profile_exit()
1163 int opcode = ideapad_rfk_data[priv->dev].opcode; in ideapad_rfk_set()
1165 guard(mutex)(&priv->priv->vpc_mutex); in ideapad_rfk_set()
1167 return write_ec_cmd(priv->priv->adev->handle, opcode, !blocked); in ideapad_rfk_set()
1179 if (priv->features.hw_rfkill_switch) { in ideapad_sync_rfk_state()
1180 guard(mutex)(&priv->vpc_mutex); in ideapad_sync_rfk_state()
1182 if (read_ec_data(priv->adev->handle, VPCCMD_R_RF, &hw_blocked)) in ideapad_sync_rfk_state()
1188 if (priv->rfk[i]) in ideapad_sync_rfk_state()
1189 rfkill_set_hw_state(priv->rfk[i], hw_blocked); in ideapad_sync_rfk_state()
1199 write_ec_cmd(priv->adev->handle, ideapad_rfk_data[dev].opcode, 1); in ideapad_register_rfkill()
1203 priv->rfk_priv[dev].dev = dev; in ideapad_register_rfkill()
1204 priv->rfk_priv[dev].priv = priv; in ideapad_register_rfkill()
1206 priv->rfk[dev] = rfkill_alloc(ideapad_rfk_data[dev].name, in ideapad_register_rfkill()
1207 &priv->platform_device->dev, in ideapad_register_rfkill()
1210 &priv->rfk_priv[dev]); in ideapad_register_rfkill()
1211 if (!priv->rfk[dev]) in ideapad_register_rfkill()
1212 return -ENOMEM; in ideapad_register_rfkill()
1214 err = read_ec_data(priv->adev->handle, ideapad_rfk_data[dev].opcode - 1, &rf_enabled); in ideapad_register_rfkill()
1218 rfkill_init_sw_state(priv->rfk[dev], !rf_enabled); in ideapad_register_rfkill()
1220 err = rfkill_register(priv->rfk[dev]); in ideapad_register_rfkill()
1222 rfkill_destroy(priv->rfk[dev]); in ideapad_register_rfkill()
1229 if (!priv->rfk[dev]) in ideapad_unregister_rfkill()
1232 rfkill_unregister(priv->rfk[dev]); in ideapad_unregister_rfkill()
1233 rfkill_destroy(priv->rfk[dev]); in ideapad_unregister_rfkill()
1241 return device_add_group(&priv->platform_device->dev, in ideapad_sysfs_init()
1247 device_remove_group(&priv->platform_device->dev, in ideapad_sysfs_exit()
1285 /* Refresh Rate Toggle (Fn+R) */
1295 /* Refresh Rate Toggle */
1311 return -ENOMEM; in ideapad_input_init()
1313 inputdev->name = "Ideapad extra buttons"; in ideapad_input_init()
1314 inputdev->phys = "ideapad/input0"; in ideapad_input_init()
1315 inputdev->id.bustype = BUS_HOST; in ideapad_input_init()
1316 inputdev->dev.parent = &priv->platform_device->dev; in ideapad_input_init()
1320 dev_err(&priv->platform_device->dev, in ideapad_input_init()
1327 dev_err(&priv->platform_device->dev, in ideapad_input_init()
1332 priv->inputdev = inputdev; in ideapad_input_init()
1344 input_unregister_device(priv->inputdev); in ideapad_input_exit()
1345 priv->inputdev = NULL; in ideapad_input_exit()
1351 sparse_keymap_report_event(priv->inputdev, scancode, 1, true); in ideapad_input_report()
1358 scoped_guard(mutex, &priv->vpc_mutex) in ideapad_input_novokey()
1359 if (read_ec_data(priv->adev->handle, VPCCMD_R_NOVO, &long_pressed)) in ideapad_input_novokey()
1372 scoped_guard(mutex, &priv->vpc_mutex) in ideapad_check_special_buttons()
1373 if (read_ec_data(priv->adev->handle, VPCCMD_R_SPECIAL_BUTTONS, &value)) in ideapad_check_special_buttons()
1381 if (priv->dytc) in ideapad_check_special_buttons()
1391 dev_info(&priv->platform_device->dev, in ideapad_check_special_buttons()
1407 guard(mutex)(&priv->vpc_mutex); in ideapad_backlight_get_brightness()
1409 err = read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); in ideapad_backlight_get_brightness()
1421 guard(mutex)(&priv->vpc_mutex); in ideapad_backlight_update_status()
1423 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL, in ideapad_backlight_update_status()
1424 blightdev->props.brightness); in ideapad_backlight_update_status()
1428 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL_POWER, in ideapad_backlight_update_status()
1429 blightdev->props.power != BACKLIGHT_POWER_OFF); in ideapad_backlight_update_status()
1448 err = read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &max); in ideapad_backlight_init()
1452 err = read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); in ideapad_backlight_init()
1456 err = read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power); in ideapad_backlight_init()
1466 &priv->platform_device->dev, in ideapad_backlight_init()
1472 dev_err(&priv->platform_device->dev, in ideapad_backlight_init()
1477 priv->blightdev = blightdev; in ideapad_backlight_init()
1478 blightdev->props.brightness = now; in ideapad_backlight_init()
1479 blightdev->props.power = power ? BACKLIGHT_POWER_ON : BACKLIGHT_POWER_OFF; in ideapad_backlight_init()
1488 backlight_device_unregister(priv->blightdev); in ideapad_backlight_exit()
1489 priv->blightdev = NULL; in ideapad_backlight_exit()
1494 struct backlight_device *blightdev = priv->blightdev; in ideapad_backlight_notify_power()
1500 guard(mutex)(&priv->vpc_mutex); in ideapad_backlight_notify_power()
1502 if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power)) in ideapad_backlight_notify_power()
1505 blightdev->props.power = power ? BACKLIGHT_POWER_ON : BACKLIGHT_POWER_OFF; in ideapad_backlight_notify_power()
1513 if (!priv->blightdev) in ideapad_backlight_notify_brightness()
1514 scoped_guard(mutex, &priv->vpc_mutex) in ideapad_backlight_notify_brightness()
1515 read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); in ideapad_backlight_notify_brightness()
1517 backlight_force_update(priv->blightdev, BACKLIGHT_UPDATE_HOTKEY); in ideapad_backlight_notify_brightness()
1533 if (ideapad_kbd_bl_check_tristate(priv->kbd_bl.type)) { in ideapad_kbd_bl_brightness_get()
1534 err = eval_kblc(priv->adev->handle, in ideapad_kbd_bl_brightness_get()
1535 FIELD_PREP(KBD_BL_COMMAND_TYPE, priv->kbd_bl.type) | in ideapad_kbd_bl_brightness_get()
1546 if (value <= priv->kbd_bl.led.max_brightness) in ideapad_kbd_bl_brightness_get()
1550 if (value == priv->kbd_bl.led.max_brightness + 1) in ideapad_kbd_bl_brightness_get()
1554 dev_warn(&priv->platform_device->dev, in ideapad_kbd_bl_brightness_get()
1556 return -EINVAL; in ideapad_kbd_bl_brightness_get()
1559 err = eval_hals(priv->adev->handle, &value); in ideapad_kbd_bl_brightness_get()
1577 int type = priv->kbd_bl.type; in ideapad_kbd_bl_brightness_set()
1580 if (brightness > priv->kbd_bl.led.max_brightness) in ideapad_kbd_bl_brightness_set()
1581 return -EINVAL; in ideapad_kbd_bl_brightness_set()
1586 err = exec_kblc(priv->adev->handle, value); in ideapad_kbd_bl_brightness_set()
1588 err = exec_sals(priv->adev->handle, brightness ? SALS_KBD_BL_ON : SALS_KBD_BL_OFF); in ideapad_kbd_bl_brightness_set()
1594 priv->kbd_bl.last_brightness = brightness; in ideapad_kbd_bl_brightness_set()
1611 if (!priv->kbd_bl.initialized) in ideapad_kbd_bl_notify()
1618 if (brightness == priv->kbd_bl.last_brightness) in ideapad_kbd_bl_notify()
1621 priv->kbd_bl.last_brightness = brightness; in ideapad_kbd_bl_notify()
1623 led_classdev_notify_brightness_hw_changed(&priv->kbd_bl.led, brightness); in ideapad_kbd_bl_notify()
1630 if (!priv->features.kbd_bl) in ideapad_kbd_bl_init()
1631 return -ENODEV; in ideapad_kbd_bl_init()
1633 if (WARN_ON(priv->kbd_bl.initialized)) in ideapad_kbd_bl_init()
1634 return -EEXIST; in ideapad_kbd_bl_init()
1636 if (ideapad_kbd_bl_check_tristate(priv->kbd_bl.type)) { in ideapad_kbd_bl_init()
1637 priv->kbd_bl.led.max_brightness = 2; in ideapad_kbd_bl_init()
1639 priv->kbd_bl.led.max_brightness = 1; in ideapad_kbd_bl_init()
1646 priv->kbd_bl.last_brightness = brightness; in ideapad_kbd_bl_init()
1647 priv->kbd_bl.led.name = "platform::" LED_FUNCTION_KBD_BACKLIGHT; in ideapad_kbd_bl_init()
1648 priv->kbd_bl.led.brightness_get = ideapad_kbd_bl_led_cdev_brightness_get; in ideapad_kbd_bl_init()
1649 priv->kbd_bl.led.brightness_set_blocking = ideapad_kbd_bl_led_cdev_brightness_set; in ideapad_kbd_bl_init()
1650 priv->kbd_bl.led.flags = LED_BRIGHT_HW_CHANGED; in ideapad_kbd_bl_init()
1652 err = led_classdev_register(&priv->platform_device->dev, &priv->kbd_bl.led); in ideapad_kbd_bl_init()
1656 priv->kbd_bl.initialized = true; in ideapad_kbd_bl_init()
1663 if (!priv->kbd_bl.initialized) in ideapad_kbd_bl_exit()
1666 priv->kbd_bl.initialized = false; in ideapad_kbd_bl_exit()
1668 led_classdev_unregister(&priv->kbd_bl.led); in ideapad_kbd_bl_exit()
1693 if (!priv->features.fn_lock) in ideapad_fn_lock_led_init()
1694 return -ENODEV; in ideapad_fn_lock_led_init()
1696 if (WARN_ON(priv->fn_lock.initialized)) in ideapad_fn_lock_led_init()
1697 return -EEXIST; in ideapad_fn_lock_led_init()
1699 priv->fn_lock.led.max_brightness = 1; in ideapad_fn_lock_led_init()
1705 priv->fn_lock.last_brightness = brightness; in ideapad_fn_lock_led_init()
1706 priv->fn_lock.led.name = "platform::" LED_FUNCTION_FNLOCK; in ideapad_fn_lock_led_init()
1707 priv->fn_lock.led.brightness_get = ideapad_fn_lock_led_cdev_get; in ideapad_fn_lock_led_init()
1708 priv->fn_lock.led.brightness_set_blocking = ideapad_fn_lock_led_cdev_set; in ideapad_fn_lock_led_init()
1709 priv->fn_lock.led.flags = LED_BRIGHT_HW_CHANGED; in ideapad_fn_lock_led_init()
1711 err = led_classdev_register(&priv->platform_device->dev, &priv->fn_lock.led); in ideapad_fn_lock_led_init()
1715 priv->fn_lock.initialized = true; in ideapad_fn_lock_led_init()
1722 if (!priv->fn_lock.initialized) in ideapad_fn_lock_led_exit()
1725 priv->fn_lock.initialized = false; in ideapad_fn_lock_led_exit()
1727 led_classdev_unregister(&priv->fn_lock.led); in ideapad_fn_lock_led_exit()
1740 scoped_guard(mutex, &priv->vpc_mutex) in ideapad_sync_touchpad_state()
1741 ret = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value); in ideapad_sync_touchpad_state()
1746 * Some IdeaPads don't really turn off touchpad - they only in ideapad_sync_touchpad_state()
1751 if (priv->features.ctrl_ps2_aux_port) in ideapad_sync_touchpad_state()
1757 * an acpi-notify with VPC bit 5 set on resume, so this function get in ideapad_sync_touchpad_state()
1761 if (send_events && value != priv->r_touchpad_val) { in ideapad_sync_touchpad_state()
1763 sysfs_notify(&priv->platform_device->dev.kobj, NULL, "touchpad"); in ideapad_sync_touchpad_state()
1766 priv->r_touchpad_val = value; in ideapad_sync_touchpad_state()
1798 if (!priv->features.ymc_ec_trigger) in ideapad_laptop_trigger_ec()
1801 scoped_guard(mutex, &priv->vpc_mutex) in ideapad_laptop_trigger_ec()
1802 ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_YMC, 1); in ideapad_laptop_trigger_ec()
1804 dev_warn(&priv->platform_device->dev, "Could not write YMC: %d\n", ret); in ideapad_laptop_trigger_ec()
1848 scoped_guard(mutex, &priv->vpc_mutex) { in ideapad_acpi_notify()
1869 * This event gets send on a Yoga 300-11IBR when the EC in ideapad_acpi_notify()
1873 * windows service calling a DSM on the DUAL250E ACPI- in ideapad_acpi_notify()
1909 dev_info(&priv->platform_device->dev, in ideapad_acpi_notify()
1936 * switch causing ideapad_laptop to wrongly report all radios as hw-blocked.
1939 * More importantly wrongly reporting the wifi radio as hw-blocked, results in
1940 * non working wifi. Whereas not reporting it hw-blocked, when it actually is
1941 * hw-blocked results in an empty SSID list, which is a much more benign
1971 acpi_handle handle = priv->adev->handle; in ideapad_check_features()
1974 priv->features.set_fn_lock_led = in ideapad_check_features()
1976 priv->features.hw_rfkill_switch = in ideapad_check_features()
1978 priv->features.ctrl_ps2_aux_port = in ideapad_check_features()
1980 priv->features.touchpad_ctrl_via_ec = touchpad_ctrl_via_ec; in ideapad_check_features()
1981 priv->features.ymc_ec_trigger = in ideapad_check_features()
1985 priv->features.fan_mode = true; in ideapad_check_features()
1988 priv->features.conservation_mode = true; in ideapad_check_features()
1991 priv->features.dytc = true; in ideapad_check_features()
1996 priv->features.fn_lock = true; in ideapad_check_features()
1999 priv->features.kbd_bl = true; in ideapad_check_features()
2000 priv->kbd_bl.type = KBD_BL_STANDARD; in ideapad_check_features()
2004 priv->features.usb_charging = true; in ideapad_check_features()
2009 if (!eval_kblc(priv->adev->handle, KBD_BL_QUERY_TYPE, &val)) { in ideapad_check_features()
2011 priv->features.kbd_bl = true; in ideapad_check_features()
2012 priv->kbd_bl.type = KBD_BL_TRISTATE; in ideapad_check_features()
2014 priv->features.kbd_bl = true; in ideapad_check_features()
2015 priv->kbd_bl.type = KBD_BL_TRISTATE_AUTO; in ideapad_check_features()
2017 dev_warn(&priv->platform_device->dev, in ideapad_check_features()
2042 wpriv = devm_kzalloc(&wdev->dev, sizeof(*wpriv), GFP_KERNEL); in ideapad_wmi_probe()
2044 return -ENOMEM; in ideapad_wmi_probe()
2048 dev_set_drvdata(&wdev->dev, wpriv); in ideapad_wmi_probe()
2054 struct ideapad_wmi_private *wpriv = dev_get_drvdata(&wdev->dev); in ideapad_wmi_notify()
2063 switch (wpriv->event) { in ideapad_wmi_notify()
2068 if (priv->features.set_fn_lock_led) { in ideapad_wmi_notify()
2077 if (data->type != ACPI_TYPE_INTEGER) { in ideapad_wmi_notify()
2078 dev_warn(&wdev->dev, in ideapad_wmi_notify()
2083 dev_dbg(&wdev->dev, "WMI fn-key event: 0x%llx\n", in ideapad_wmi_notify()
2084 data->integer.value); in ideapad_wmi_notify()
2087 if (data->integer.value == 0x02 || data->integer.value == 0x03) in ideapad_wmi_notify()
2088 ideapad_fn_lock_led_notify(priv, data->integer.value == 0x02); in ideapad_wmi_notify()
2091 data->integer.value | IDEAPAD_WMI_KEY); in ideapad_wmi_notify()
2106 { "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6", &ideapad_wmi_context_esc }, /* Yoga 3 */
2107 { "56322276-8493-4CE8-A783-98C991274F5E", &ideapad_wmi_context_esc }, /* Yoga 700 */
2108 { "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294", &ideapad_wmi_context_fn_keys }, /* Legion 5 */
2142 struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); in ideapad_acpi_add()
2148 if (!adev || eval_int(adev->handle, "_CFG", &cfg)) in ideapad_acpi_add()
2149 return -ENODEV; in ideapad_acpi_add()
2151 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in ideapad_acpi_add()
2153 return -ENOMEM; in ideapad_acpi_add()
2155 dev_set_drvdata(&pdev->dev, priv); in ideapad_acpi_add()
2157 priv->cfg = cfg; in ideapad_acpi_add()
2158 priv->adev = adev; in ideapad_acpi_add()
2159 priv->platform_device = pdev; in ideapad_acpi_add()
2161 err = devm_mutex_init(&pdev->dev, &priv->vpc_mutex); in ideapad_acpi_add()
2179 if (err != -ENODEV) in ideapad_acpi_add()
2180 dev_warn(&pdev->dev, "Could not set up keyboard backlight LED: %d\n", err); in ideapad_acpi_add()
2182 dev_info(&pdev->dev, "Keyboard backlight control not available\n"); in ideapad_acpi_add()
2187 if (err != -ENODEV) in ideapad_acpi_add()
2188 dev_warn(&pdev->dev, "Could not set up FnLock LED: %d\n", err); in ideapad_acpi_add()
2190 dev_info(&pdev->dev, "FnLock control not available\n"); in ideapad_acpi_add()
2194 * On some models without a hw-switch (the yoga 2 13 at least) in ideapad_acpi_add()
2197 if (!priv->features.hw_rfkill_switch) in ideapad_acpi_add()
2198 write_ec_cmd(priv->adev->handle, VPCCMD_W_RF, 1); in ideapad_acpi_add()
2201 if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg)) in ideapad_acpi_add()
2209 if (err != -ENODEV) in ideapad_acpi_add()
2210 dev_warn(&pdev->dev, "Could not set up DYTC interface: %d\n", err); in ideapad_acpi_add()
2212 dev_info(&pdev->dev, "DYTC interface is not available\n"); in ideapad_acpi_add()
2217 if (err && err != -ENODEV) in ideapad_acpi_add()
2221 status = acpi_install_notify_handler(adev->handle, in ideapad_acpi_add()
2225 err = -EIO; in ideapad_acpi_add()
2238 acpi_remove_notify_handler(priv->adev->handle, in ideapad_acpi_add()
2264 struct ideapad_private *priv = dev_get_drvdata(&pdev->dev); in ideapad_acpi_remove()
2271 acpi_remove_notify_handler(priv->adev->handle, in ideapad_acpi_remove()
2296 if (priv->dytc) in ideapad_acpi_resume()