Lines Matching +full:battery +full:- +full:profile

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ideapad-laptop.c - Lenovo IdeaPad ACPI Extras
23 #include <linux/input/sparse-keymap.h>
34 #include "ideapad-laptop.h"
38 #include <dt-bindings/leds/common.h>
90 * These correspond to the number of supported states - 1
164 "Enable DYTC version 4 platform-profile support. "
165 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
171 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
176 "Enable driver based updates of the fn-lock LED on fn-lock changes. "
177 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
182 "Enable driver based PS/2 aux port en-/dis-abling on touchpad on/off toggle. "
183 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
188 "Enable registering a 'touchpad' sysfs-attribute which can be used to manually "
208 dev_warn(&priv->adev->dev, "found multiple platform devices\n"); in ideapad_shared_init()
209 ret = -EINVAL; in ideapad_shared_init()
238 return -EIO; in eval_int()
249 return ACPI_FAILURE(status) ? -EIO : 0; in exec_simple_method()
292 struct ideapad_private *priv = s->private; in debugfs_status_show()
295 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value)) in debugfs_status_show()
297 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) in debugfs_status_show()
299 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value)) in debugfs_status_show()
304 if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value)) in debugfs_status_show()
306 if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value)) in debugfs_status_show()
308 if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value)) in debugfs_status_show()
310 if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value)) in debugfs_status_show()
315 if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) in debugfs_status_show()
317 if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value)) in debugfs_status_show()
322 if (!eval_gbmd(priv->adev->handle, &value)) in debugfs_status_show()
324 if (!eval_hals(priv->adev->handle, &value)) in debugfs_status_show()
333 struct ideapad_private *priv = s->private; in debugfs_cfg_show()
335 seq_printf(s, "_CFG: %#010lx\n\n", priv->cfg); in debugfs_cfg_show()
338 if (test_bit(CFG_CAP_BT_BIT, &priv->cfg)) in debugfs_cfg_show()
340 if (test_bit(CFG_CAP_3G_BIT, &priv->cfg)) in debugfs_cfg_show()
342 if (test_bit(CFG_CAP_WIFI_BIT, &priv->cfg)) in debugfs_cfg_show()
344 if (test_bit(CFG_CAP_CAM_BIT, &priv->cfg)) in debugfs_cfg_show()
349 if (test_bit(CFG_OSD_NUMLK_BIT, &priv->cfg)) in debugfs_cfg_show()
350 seq_puts(s, " num-lock"); in debugfs_cfg_show()
351 if (test_bit(CFG_OSD_CAPSLK_BIT, &priv->cfg)) in debugfs_cfg_show()
352 seq_puts(s, " caps-lock"); in debugfs_cfg_show()
353 if (test_bit(CFG_OSD_MICMUTE_BIT, &priv->cfg)) in debugfs_cfg_show()
354 seq_puts(s, " mic-mute"); in debugfs_cfg_show()
355 if (test_bit(CFG_OSD_TOUCHPAD_BIT, &priv->cfg)) in debugfs_cfg_show()
357 if (test_bit(CFG_OSD_CAM_BIT, &priv->cfg)) in debugfs_cfg_show()
362 switch (priv->cfg & 0x700) { in debugfs_cfg_show()
390 priv->debug = dir; in ideapad_debugfs_init()
398 debugfs_remove_recursive(priv->debug); in ideapad_debugfs_exit()
399 priv->debug = NULL; in ideapad_debugfs_exit()
413 err = read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result); in camera_power_show()
432 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state); in camera_power_store()
449 err = eval_gbmd(priv->adev->handle, &result); in conservation_mode_show()
468 err = exec_sbmc(priv->adev->handle, state ? SBMC_CONSERVATION_ON : SBMC_CONSERVATION_OFF); in conservation_mode_store()
485 err = read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result); in fan_mode_show()
505 return -EINVAL; in fan_mode_store()
507 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state); in fan_mode_store()
524 err = eval_hals(priv->adev->handle, &hals); in fn_lock_show()
543 err = exec_sals(priv->adev->handle, state ? SALS_FNLOCK_ON : SALS_FNLOCK_OFF); in fn_lock_store()
560 err = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result); in touchpad_show()
564 priv->r_touchpad_val = result; in touchpad_show()
581 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state); in touchpad_store()
585 priv->r_touchpad_val = state; in touchpad_store()
600 err = eval_hals(priv->adev->handle, &hals); in usb_charging_show()
619 err = exec_sals(priv->adev->handle, state ? SALS_USB_CHARGING_ON : SALS_USB_CHARGING_OFF); in usb_charging_store()
647 supported = test_bit(CFG_CAP_CAM_BIT, &priv->cfg); in ideapad_is_visible()
649 supported = priv->features.conservation_mode; in ideapad_is_visible()
651 supported = priv->features.fan_mode; in ideapad_is_visible()
653 supported = priv->features.fn_lock; in ideapad_is_visible()
655 supported = priv->features.touchpad_ctrl_via_ec; in ideapad_is_visible()
657 supported = priv->features.usb_charging; in ideapad_is_visible()
659 return supported ? attr->mode : 0; in ideapad_is_visible()
668 * DYTC Platform profile
670 #define DYTC_CMD_QUERY 0 /* To get DYTC status - enable/revision */
675 #define DYTC_QUERY_ENABLE_BIT 8 /* Bit 8 - 0 = disabled, 1 = enabled */
676 #define DYTC_QUERY_SUBREV_BIT 16 /* Bits 16 - 27 - sub revision */
677 #define DYTC_QUERY_REV_BIT 28 /* Bits 28 - 31 - revision */
679 #define DYTC_GET_FUNCTION_BIT 8 /* Bits 8-11 - function setting */
680 #define DYTC_GET_MODE_BIT 12 /* Bits 12-15 - mode setting */
682 #define DYTC_SET_FUNCTION_BIT 12 /* Bits 12-15 - function setting */
683 #define DYTC_SET_MODE_BIT 16 /* Bits 16-19 - mode setting */
684 #define DYTC_SET_VALID_BIT 20 /* Bit 20 - 1 = on, 0 = off */
703 static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *profile) in convert_dytc_to_profile() argument
707 *profile = PLATFORM_PROFILE_LOW_POWER; in convert_dytc_to_profile()
710 *profile = PLATFORM_PROFILE_BALANCED; in convert_dytc_to_profile()
713 *profile = PLATFORM_PROFILE_PERFORMANCE; in convert_dytc_to_profile()
716 return -EINVAL; in convert_dytc_to_profile()
722 static int convert_profile_to_dytc(enum platform_profile_option profile, int *perfmode) in convert_profile_to_dytc() argument
724 switch (profile) { in convert_profile_to_dytc()
734 default: /* Unknown profile */ in convert_profile_to_dytc()
735 return -EOPNOTSUPP; in convert_profile_to_dytc()
743 * handler. Returns current platform profile.
746 enum platform_profile_option *profile) in dytc_profile_get() argument
750 *profile = dytc->current_profile; in dytc_profile_get()
755 * Helper function - check if we are in CQL mode and if we are
756 * - disable CQL,
757 * - run the command
758 * - enable CQL
767 err = eval_dytc(priv->adev->handle, DYTC_CMD_GET, output); in dytc_cql_command()
777 err = eval_dytc(priv->adev->handle, DYTC_DISABLE_CQL, NULL); in dytc_cql_command()
782 cmd_err = eval_dytc(priv->adev->handle, cmd, output); in dytc_cql_command()
786 err = eval_dytc(priv->adev->handle, DYTC_ENABLE_CQL, NULL); in dytc_cql_command()
796 * handler. Sets current platform profile.
799 enum platform_profile_option profile) in dytc_profile_set() argument
802 struct ideapad_private *priv = dytc->priv; in dytc_profile_set()
806 err = mutex_lock_interruptible(&dytc->mutex); in dytc_profile_set()
810 if (profile == PLATFORM_PROFILE_BALANCED) { in dytc_profile_set()
812 err = eval_dytc(priv->adev->handle, DYTC_CMD_RESET, NULL); in dytc_profile_set()
818 err = convert_profile_to_dytc(profile, &perfmode); in dytc_profile_set()
829 /* Success - update current profile */ in dytc_profile_set()
830 dytc->current_profile = profile; in dytc_profile_set()
833 mutex_unlock(&dytc->mutex); in dytc_profile_set()
840 enum platform_profile_option profile; in dytc_profile_refresh() local
844 mutex_lock(&priv->dytc->mutex); in dytc_profile_refresh()
846 mutex_unlock(&priv->dytc->mutex); in dytc_profile_refresh()
852 if (convert_dytc_to_profile(perfmode, &profile)) in dytc_profile_refresh()
855 if (profile != priv->dytc->current_profile) { in dytc_profile_refresh()
856 priv->dytc->current_profile = profile; in dytc_profile_refresh()
884 if (!priv->features.dytc) in ideapad_dytc_profile_init()
885 return -ENODEV; in ideapad_dytc_profile_init()
887 err = eval_dytc(priv->adev->handle, DYTC_CMD_QUERY, &output); in ideapad_dytc_profile_init()
894 dev_info(&priv->platform_device->dev, "DYTC_QUERY_ENABLE_BIT returned false\n"); in ideapad_dytc_profile_init()
895 return -ENODEV; in ideapad_dytc_profile_init()
901 dev_info(&priv->platform_device->dev, "DYTC_VERSION < 4 is not supported\n"); in ideapad_dytc_profile_init()
902 return -ENODEV; in ideapad_dytc_profile_init()
907 dev_info(&priv->platform_device->dev, in ideapad_dytc_profile_init()
909 return -ENODEV; in ideapad_dytc_profile_init()
912 priv->dytc = kzalloc(sizeof(*priv->dytc), GFP_KERNEL); in ideapad_dytc_profile_init()
913 if (!priv->dytc) in ideapad_dytc_profile_init()
914 return -ENOMEM; in ideapad_dytc_profile_init()
916 mutex_init(&priv->dytc->mutex); in ideapad_dytc_profile_init()
918 priv->dytc->priv = priv; in ideapad_dytc_profile_init()
919 priv->dytc->pprof.profile_get = dytc_profile_get; in ideapad_dytc_profile_init()
920 priv->dytc->pprof.profile_set = dytc_profile_set; in ideapad_dytc_profile_init()
923 set_bit(PLATFORM_PROFILE_LOW_POWER, priv->dytc->pprof.choices); in ideapad_dytc_profile_init()
924 set_bit(PLATFORM_PROFILE_BALANCED, priv->dytc->pprof.choices); in ideapad_dytc_profile_init()
925 set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices); in ideapad_dytc_profile_init()
928 err = platform_profile_register(&priv->dytc->pprof); in ideapad_dytc_profile_init()
938 mutex_destroy(&priv->dytc->mutex); in ideapad_dytc_profile_init()
939 kfree(priv->dytc); in ideapad_dytc_profile_init()
940 priv->dytc = NULL; in ideapad_dytc_profile_init()
947 if (!priv->dytc) in ideapad_dytc_profile_exit()
951 mutex_destroy(&priv->dytc->mutex); in ideapad_dytc_profile_exit()
952 kfree(priv->dytc); in ideapad_dytc_profile_exit()
954 priv->dytc = NULL; in ideapad_dytc_profile_exit()
976 int opcode = ideapad_rfk_data[priv->dev].opcode; in ideapad_rfk_set()
978 return write_ec_cmd(priv->priv->adev->handle, opcode, !blocked); in ideapad_rfk_set()
990 if (priv->features.hw_rfkill_switch) { in ideapad_sync_rfk_state()
991 if (read_ec_data(priv->adev->handle, VPCCMD_R_RF, &hw_blocked)) in ideapad_sync_rfk_state()
997 if (priv->rfk[i]) in ideapad_sync_rfk_state()
998 rfkill_set_hw_state(priv->rfk[i], hw_blocked); in ideapad_sync_rfk_state()
1008 write_ec_cmd(priv->adev->handle, ideapad_rfk_data[dev].opcode, 1); in ideapad_register_rfkill()
1012 priv->rfk_priv[dev].dev = dev; in ideapad_register_rfkill()
1013 priv->rfk_priv[dev].priv = priv; in ideapad_register_rfkill()
1015 priv->rfk[dev] = rfkill_alloc(ideapad_rfk_data[dev].name, in ideapad_register_rfkill()
1016 &priv->platform_device->dev, in ideapad_register_rfkill()
1019 &priv->rfk_priv[dev]); in ideapad_register_rfkill()
1020 if (!priv->rfk[dev]) in ideapad_register_rfkill()
1021 return -ENOMEM; in ideapad_register_rfkill()
1023 err = read_ec_data(priv->adev->handle, ideapad_rfk_data[dev].opcode - 1, &rf_enabled); in ideapad_register_rfkill()
1027 rfkill_init_sw_state(priv->rfk[dev], !rf_enabled); in ideapad_register_rfkill()
1029 err = rfkill_register(priv->rfk[dev]); in ideapad_register_rfkill()
1031 rfkill_destroy(priv->rfk[dev]); in ideapad_register_rfkill()
1038 if (!priv->rfk[dev]) in ideapad_unregister_rfkill()
1041 rfkill_unregister(priv->rfk[dev]); in ideapad_unregister_rfkill()
1042 rfkill_destroy(priv->rfk[dev]); in ideapad_unregister_rfkill()
1050 return device_add_group(&priv->platform_device->dev, in ideapad_sysfs_init()
1056 device_remove_group(&priv->platform_device->dev, in ideapad_sysfs_exit()
1096 /* Sound profile switch */
1115 return -ENOMEM; in ideapad_input_init()
1117 inputdev->name = "Ideapad extra buttons"; in ideapad_input_init()
1118 inputdev->phys = "ideapad/input0"; in ideapad_input_init()
1119 inputdev->id.bustype = BUS_HOST; in ideapad_input_init()
1120 inputdev->dev.parent = &priv->platform_device->dev; in ideapad_input_init()
1124 dev_err(&priv->platform_device->dev, in ideapad_input_init()
1131 dev_err(&priv->platform_device->dev, in ideapad_input_init()
1136 priv->inputdev = inputdev; in ideapad_input_init()
1148 input_unregister_device(priv->inputdev); in ideapad_input_exit()
1149 priv->inputdev = NULL; in ideapad_input_exit()
1155 sparse_keymap_report_event(priv->inputdev, scancode, 1, true); in ideapad_input_report()
1162 if (read_ec_data(priv->adev->handle, VPCCMD_R_NOVO, &long_pressed)) in ideapad_input_novokey()
1175 if (read_ec_data(priv->adev->handle, VPCCMD_R_SPECIAL_BUTTONS, &value)) in ideapad_check_special_buttons()
1190 dev_info(&priv->platform_device->dev, in ideapad_check_special_buttons()
1206 err = read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); in ideapad_backlight_get_brightness()
1218 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL, in ideapad_backlight_update_status()
1219 blightdev->props.brightness); in ideapad_backlight_update_status()
1223 err = write_ec_cmd(priv->adev->handle, VPCCMD_W_BL_POWER, in ideapad_backlight_update_status()
1224 blightdev->props.power != FB_BLANK_POWERDOWN); in ideapad_backlight_update_status()
1243 err = read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &max); in ideapad_backlight_init()
1247 err = read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); in ideapad_backlight_init()
1251 err = read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power); in ideapad_backlight_init()
1261 &priv->platform_device->dev, in ideapad_backlight_init()
1267 dev_err(&priv->platform_device->dev, in ideapad_backlight_init()
1272 priv->blightdev = blightdev; in ideapad_backlight_init()
1273 blightdev->props.brightness = now; in ideapad_backlight_init()
1274 blightdev->props.power = power ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; in ideapad_backlight_init()
1283 backlight_device_unregister(priv->blightdev); in ideapad_backlight_exit()
1284 priv->blightdev = NULL; in ideapad_backlight_exit()
1289 struct backlight_device *blightdev = priv->blightdev; in ideapad_backlight_notify_power()
1295 if (read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &power)) in ideapad_backlight_notify_power()
1298 blightdev->props.power = power ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; in ideapad_backlight_notify_power()
1306 if (!priv->blightdev) in ideapad_backlight_notify_brightness()
1307 read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now); in ideapad_backlight_notify_brightness()
1309 backlight_force_update(priv->blightdev, BACKLIGHT_UPDATE_HOTKEY); in ideapad_backlight_notify_brightness()
1325 if (ideapad_kbd_bl_check_tristate(priv->kbd_bl.type)) { in ideapad_kbd_bl_brightness_get()
1326 err = eval_kblc(priv->adev->handle, in ideapad_kbd_bl_brightness_get()
1327 FIELD_PREP(KBD_BL_COMMAND_TYPE, priv->kbd_bl.type) | in ideapad_kbd_bl_brightness_get()
1338 if (value <= priv->kbd_bl.led.max_brightness) in ideapad_kbd_bl_brightness_get()
1342 if (value == priv->kbd_bl.led.max_brightness + 1) in ideapad_kbd_bl_brightness_get()
1346 dev_warn(&priv->platform_device->dev, in ideapad_kbd_bl_brightness_get()
1348 return -EINVAL; in ideapad_kbd_bl_brightness_get()
1351 err = eval_hals(priv->adev->handle, &value); in ideapad_kbd_bl_brightness_get()
1369 int type = priv->kbd_bl.type; in ideapad_kbd_bl_brightness_set()
1372 if (brightness > priv->kbd_bl.led.max_brightness) in ideapad_kbd_bl_brightness_set()
1373 return -EINVAL; in ideapad_kbd_bl_brightness_set()
1378 err = exec_kblc(priv->adev->handle, value); in ideapad_kbd_bl_brightness_set()
1380 err = exec_sals(priv->adev->handle, brightness ? SALS_KBD_BL_ON : SALS_KBD_BL_OFF); in ideapad_kbd_bl_brightness_set()
1386 priv->kbd_bl.last_brightness = brightness; in ideapad_kbd_bl_brightness_set()
1403 if (!priv->kbd_bl.initialized) in ideapad_kbd_bl_notify()
1410 if (brightness == priv->kbd_bl.last_brightness) in ideapad_kbd_bl_notify()
1413 priv->kbd_bl.last_brightness = brightness; in ideapad_kbd_bl_notify()
1415 led_classdev_notify_brightness_hw_changed(&priv->kbd_bl.led, brightness); in ideapad_kbd_bl_notify()
1422 if (!priv->features.kbd_bl) in ideapad_kbd_bl_init()
1423 return -ENODEV; in ideapad_kbd_bl_init()
1425 if (WARN_ON(priv->kbd_bl.initialized)) in ideapad_kbd_bl_init()
1426 return -EEXIST; in ideapad_kbd_bl_init()
1432 priv->kbd_bl.last_brightness = brightness; in ideapad_kbd_bl_init()
1434 if (ideapad_kbd_bl_check_tristate(priv->kbd_bl.type)) { in ideapad_kbd_bl_init()
1435 priv->kbd_bl.led.max_brightness = 2; in ideapad_kbd_bl_init()
1437 priv->kbd_bl.led.max_brightness = 1; in ideapad_kbd_bl_init()
1440 priv->kbd_bl.led.name = "platform::" LED_FUNCTION_KBD_BACKLIGHT; in ideapad_kbd_bl_init()
1441 priv->kbd_bl.led.brightness_get = ideapad_kbd_bl_led_cdev_brightness_get; in ideapad_kbd_bl_init()
1442 priv->kbd_bl.led.brightness_set_blocking = ideapad_kbd_bl_led_cdev_brightness_set; in ideapad_kbd_bl_init()
1443 priv->kbd_bl.led.flags = LED_BRIGHT_HW_CHANGED; in ideapad_kbd_bl_init()
1445 err = led_classdev_register(&priv->platform_device->dev, &priv->kbd_bl.led); in ideapad_kbd_bl_init()
1449 priv->kbd_bl.initialized = true; in ideapad_kbd_bl_init()
1456 if (!priv->kbd_bl.initialized) in ideapad_kbd_bl_exit()
1459 priv->kbd_bl.initialized = false; in ideapad_kbd_bl_exit()
1461 led_classdev_unregister(&priv->kbd_bl.led); in ideapad_kbd_bl_exit()
1474 ret = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value); in ideapad_sync_touchpad_state()
1479 * Some IdeaPads don't really turn off touchpad - they only in ideapad_sync_touchpad_state()
1484 if (priv->features.ctrl_ps2_aux_port) in ideapad_sync_touchpad_state()
1490 * an acpi-notify with VPC bit 5 set on resume, so this function get in ideapad_sync_touchpad_state()
1494 if (send_events && value != priv->r_touchpad_val) { in ideapad_sync_touchpad_state()
1496 sysfs_notify(&priv->platform_device->dev.kobj, NULL, "touchpad"); in ideapad_sync_touchpad_state()
1499 priv->r_touchpad_val = value; in ideapad_sync_touchpad_state()
1526 * This event gets send on a Yoga 300-11IBR when the EC in ideapad_acpi_notify()
1530 * windows service calling a DSM on the DUAL250E ACPI- in ideapad_acpi_notify()
1555 * seconds while on battery power; some in ideapad_acpi_notify()
1566 dev_info(&priv->platform_device->dev, in ideapad_acpi_notify()
1593 * switch causing ideapad_laptop to wrongly report all radios as hw-blocked.
1596 * More importantly wrongly reporting the wifi radio as hw-blocked, results in
1597 * non working wifi. Whereas not reporting it hw-blocked, when it actually is
1598 * hw-blocked results in an empty SSID list, which is a much more benign
1628 acpi_handle handle = priv->adev->handle; in ideapad_check_features()
1631 priv->features.set_fn_lock_led = in ideapad_check_features()
1633 priv->features.hw_rfkill_switch = in ideapad_check_features()
1635 priv->features.ctrl_ps2_aux_port = in ideapad_check_features()
1637 priv->features.touchpad_ctrl_via_ec = touchpad_ctrl_via_ec; in ideapad_check_features()
1640 priv->features.fan_mode = true; in ideapad_check_features()
1643 priv->features.conservation_mode = true; in ideapad_check_features()
1646 priv->features.dytc = true; in ideapad_check_features()
1651 priv->features.fn_lock = true; in ideapad_check_features()
1654 priv->features.kbd_bl = true; in ideapad_check_features()
1655 priv->kbd_bl.type = KBD_BL_STANDARD; in ideapad_check_features()
1659 priv->features.usb_charging = true; in ideapad_check_features()
1664 if (!eval_kblc(priv->adev->handle, KBD_BL_QUERY_TYPE, &val)) { in ideapad_check_features()
1666 priv->features.kbd_bl = true; in ideapad_check_features()
1667 priv->kbd_bl.type = KBD_BL_TRISTATE; in ideapad_check_features()
1669 priv->features.kbd_bl = true; in ideapad_check_features()
1670 priv->kbd_bl.type = KBD_BL_TRISTATE_AUTO; in ideapad_check_features()
1672 dev_warn(&priv->platform_device->dev, in ideapad_check_features()
1697 wpriv = devm_kzalloc(&wdev->dev, sizeof(*wpriv), GFP_KERNEL); in ideapad_wmi_probe()
1699 return -ENOMEM; in ideapad_wmi_probe()
1703 dev_set_drvdata(&wdev->dev, wpriv); in ideapad_wmi_probe()
1709 struct ideapad_wmi_private *wpriv = dev_get_drvdata(&wdev->dev); in ideapad_wmi_notify()
1719 switch (wpriv->event) { in ideapad_wmi_notify()
1724 if (priv->features.set_fn_lock_led && in ideapad_wmi_notify()
1725 !eval_hals(priv->adev->handle, &result)) { in ideapad_wmi_notify()
1728 exec_sals(priv->adev->handle, state ? SALS_FNLOCK_ON : SALS_FNLOCK_OFF); in ideapad_wmi_notify()
1731 if (data->type != ACPI_TYPE_INTEGER) { in ideapad_wmi_notify()
1732 dev_warn(&wdev->dev, in ideapad_wmi_notify()
1737 dev_dbg(&wdev->dev, "WMI fn-key event: 0x%llx\n", in ideapad_wmi_notify()
1738 data->integer.value); in ideapad_wmi_notify()
1741 data->integer.value | IDEAPAD_WMI_KEY); in ideapad_wmi_notify()
1758 { "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6", &ideapad_wmi_context_esc }, /* Yoga 3 */
1759 { "56322276-8493-4CE8-A783-98C991274F5E", &ideapad_wmi_context_esc }, /* Yoga 700 */
1760 { "8FC0DE0C-B4E4-43FD-B0F3-8871711C1294", &ideapad_wmi_context_fn_keys }, /* Legion 5 */
1794 struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); in ideapad_acpi_add()
1800 if (!adev || eval_int(adev->handle, "_CFG", &cfg)) in ideapad_acpi_add()
1801 return -ENODEV; in ideapad_acpi_add()
1803 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in ideapad_acpi_add()
1805 return -ENOMEM; in ideapad_acpi_add()
1807 dev_set_drvdata(&pdev->dev, priv); in ideapad_acpi_add()
1809 priv->cfg = cfg; in ideapad_acpi_add()
1810 priv->adev = adev; in ideapad_acpi_add()
1811 priv->platform_device = pdev; in ideapad_acpi_add()
1827 if (err != -ENODEV) in ideapad_acpi_add()
1828 dev_warn(&pdev->dev, "Could not set up keyboard backlight LED: %d\n", err); in ideapad_acpi_add()
1830 dev_info(&pdev->dev, "Keyboard backlight control not available\n"); in ideapad_acpi_add()
1834 * On some models without a hw-switch (the yoga 2 13 at least) in ideapad_acpi_add()
1837 if (!priv->features.hw_rfkill_switch) in ideapad_acpi_add()
1838 write_ec_cmd(priv->adev->handle, VPCCMD_W_RF, 1); in ideapad_acpi_add()
1841 if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg)) in ideapad_acpi_add()
1849 if (err != -ENODEV) in ideapad_acpi_add()
1850 dev_warn(&pdev->dev, "Could not set up DYTC interface: %d\n", err); in ideapad_acpi_add()
1852 dev_info(&pdev->dev, "DYTC interface is not available\n"); in ideapad_acpi_add()
1857 if (err && err != -ENODEV) in ideapad_acpi_add()
1861 status = acpi_install_notify_handler(adev->handle, in ideapad_acpi_add()
1865 err = -EIO; in ideapad_acpi_add()
1876 acpi_remove_notify_handler(priv->adev->handle, in ideapad_acpi_add()
1901 struct ideapad_private *priv = dev_get_drvdata(&pdev->dev); in ideapad_acpi_remove()
1906 acpi_remove_notify_handler(priv->adev->handle, in ideapad_acpi_remove()
1930 if (priv->dytc) in ideapad_acpi_resume()