Lines Matching +full:fn +full:- +full:keymap
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * thinkpad_acpi.c - ThinkPad ACPI Extras
5 * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net>
6 * Copyright (C) 2006-2009 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
16 * 2007-10-20 changelog trimmed down
18 * 2007-03-27 0.14 renamed to thinkpad_acpi and moved to
21 * 2006-11-22 0.13 new maintainer
23 * not be updated further in-file.
25 * 2005-03-17 0.11 support for 600e, 770x
28 * 2005-01-16 0.9 use MODULE_VERSION
33 * 2004-11-08 0.8 fix init error case, don't return from a macro
59 #include <linux/hwmon-sysfs.h>
113 /* Misc NVRAM-related */
152 /* Hotkey-related */
153 TP_HKEY_EV_HOTKEY_BASE = 0x1001, /* first hotkey (FN+F1) */
169 /* Auto-sleep after eject request */
186 /* User-interface events */
198 /* Key-related user-interface events */
200 TP_HKEY_EV_KEY_FN = 0x6005, /* Fn key pressed? E420 */
201 TP_HKEY_EV_KEY_FN_ESC = 0x6060, /* Fn+Esc key pressed X240 */
215 /* AC-related events */
218 /* Further user-interface events */
233 #define TPACPI_URL "http://ibm-acpi.sf.net/"
234 #define TPACPI_MAIL "ibm-acpi-devel@lists.sourceforge.net"
264 * Driver-wide structs and misc. variables
353 char *ec_version_str; /* Something like 1ZHT51WW-1.04a */
361 char *nummodel_str; /* 9384A9C for a 9384-A9C model */
442 * two or three characters from the set [0-9A-Z], i.e. base 36.
494 * tpacpi_check_quirks() - search BIOS/EC version on a list
511 if ((qlist->vendor == thinkpad_id.vendor || in tpacpi_check_quirks()
512 qlist->vendor == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
513 (qlist->bios == thinkpad_id.bios_model || in tpacpi_check_quirks()
514 qlist->bios == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
515 (qlist->ec == thinkpad_id.ec_model || in tpacpi_check_quirks()
516 qlist->ec == TPACPI_MATCH_ANY)) in tpacpi_check_quirks()
517 return qlist->quirks; in tpacpi_check_quirks()
519 qlist_size--; in tpacpi_check_quirks()
561 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
687 return -ENXIO; in issue_thinkpad_cmos_command()
690 return -EIO; in issue_thinkpad_cmos_command()
780 if (!ibm || !ibm->acpi || !ibm->acpi->notify) in dispatch_acpi_notify()
783 ibm->acpi->notify(ibm, event); in dispatch_acpi_notify()
791 BUG_ON(!ibm->acpi); in setup_acpi_notify()
793 if (!*ibm->acpi->handle) in setup_acpi_notify()
797 "setting up ACPI notify for %s\n", ibm->name); in setup_acpi_notify()
799 rc = acpi_bus_get_device(*ibm->acpi->handle, &ibm->acpi->device); in setup_acpi_notify()
801 pr_err("acpi_bus_get_device(%s) failed: %d\n", ibm->name, rc); in setup_acpi_notify()
802 return -ENODEV; in setup_acpi_notify()
805 ibm->acpi->device->driver_data = ibm; in setup_acpi_notify()
806 sprintf(acpi_device_class(ibm->acpi->device), "%s/%s", in setup_acpi_notify()
808 ibm->name); in setup_acpi_notify()
810 status = acpi_install_notify_handler(*ibm->acpi->handle, in setup_acpi_notify()
811 ibm->acpi->type, dispatch_acpi_notify, ibm); in setup_acpi_notify()
815 ibm->name); in setup_acpi_notify()
818 ibm->name, acpi_format_exception(status)); in setup_acpi_notify()
820 return -ENODEV; in setup_acpi_notify()
822 ibm->flags.acpi_notify_installed = 1; in setup_acpi_notify()
836 "registering %s as an ACPI driver\n", ibm->name); in register_tpacpi_subdriver()
838 BUG_ON(!ibm->acpi); in register_tpacpi_subdriver()
840 ibm->acpi->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL); in register_tpacpi_subdriver()
841 if (!ibm->acpi->driver) { in register_tpacpi_subdriver()
842 pr_err("failed to allocate memory for ibm->acpi->driver\n"); in register_tpacpi_subdriver()
843 return -ENOMEM; in register_tpacpi_subdriver()
846 sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name); in register_tpacpi_subdriver()
847 ibm->acpi->driver->ids = ibm->acpi->hid; in register_tpacpi_subdriver()
849 ibm->acpi->driver->ops.add = &tpacpi_device_add; in register_tpacpi_subdriver()
851 rc = acpi_bus_register_driver(ibm->acpi->driver); in register_tpacpi_subdriver()
854 ibm->name, rc); in register_tpacpi_subdriver()
855 kfree(ibm->acpi->driver); in register_tpacpi_subdriver()
856 ibm->acpi->driver = NULL; in register_tpacpi_subdriver()
858 ibm->flags.acpi_driver_registered = 1; in register_tpacpi_subdriver()
874 struct ibm_struct *ibm = m->private; in dispatch_proc_show()
876 if (!ibm || !ibm->read) in dispatch_proc_show()
877 return -EINVAL; in dispatch_proc_show()
878 return ibm->read(m); in dispatch_proc_show()
894 if (!ibm || !ibm->write) in dispatch_proc_write()
895 return -EINVAL; in dispatch_proc_write()
896 if (count > PAGE_SIZE - 1) in dispatch_proc_write()
897 return -EINVAL; in dispatch_proc_write()
901 return -ENOMEM; in dispatch_proc_write()
905 return -EFAULT; in dispatch_proc_write()
909 ret = ibm->write(kernbuf); in dispatch_proc_write()
949 if (ibm->suspend) in tpacpi_suspend_handler()
950 (ibm->suspend)(); in tpacpi_suspend_handler()
963 if (ibm->resume) in tpacpi_resume_handler()
964 (ibm->resume)(); in tpacpi_resume_handler()
981 if (ibm->shutdown) in tpacpi_shutdown_handler()
982 (ibm->shutdown)(); in tpacpi_shutdown_handler()
1028 sobj->s.max_members = max_members; in create_attr_set()
1029 sobj->s.group.attrs = &sobj->a; in create_attr_set()
1030 sobj->s.group.name = name; in create_attr_set()
1032 return &sobj->s; in create_attr_set()
1038 /* not multi-threaded safe, use it in a single thread per set */
1042 return -EINVAL; in add_to_attr_set()
1044 if (s->members >= s->max_members) in add_to_attr_set()
1045 return -ENOMEM; in add_to_attr_set()
1047 s->group.attrs[s->members] = attr; in add_to_attr_set()
1048 s->members++; in add_to_attr_set()
1070 sysfs_remove_group(kobj, &s->group); in delete_attr_set()
1075 sysfs_create_group(_kobj, &_attr_set->group)
1085 return -EINVAL; in parse_strtoul()
1109 * ThinkPad-ACPI firmware handling model:
1111 * WLSW (master wireless switch) is event-driven, and is common to all
1112 * firmware-controlled radios. It cannot be controlled, just monitored,
1115 * The kernel, a masked-off hotkey, and WLSW can change the radio state
1119 * masked-off hotkeys are used.
1148 /* ThinkPad-ACPI rfkill subdriver */
1169 return -ENODEV; in tpacpi_rfk_update_swstate()
1171 status = (tp_rfk->ops->get_status)(); in tpacpi_rfk_update_swstate()
1175 rfkill_set_sw_state(tp_rfk->rfkill, in tpacpi_rfk_update_swstate()
1191 * Sync the HW-blocking state of all rfkill switches,
1202 if (rfkill_set_hw_state(tp_rfk->rfkill, in tpacpi_rfk_update_hwblock_state()
1204 /* ignore -- we track sw block */ in tpacpi_rfk_update_hwblock_state()
1239 res = (tp_rfk->ops->set_status)(blocked ? in tpacpi_rfk_hook_set_block()
1268 atp_rfk->rfkill = rfkill_alloc(name, in tpacpi_new_rfkill()
1269 &tpacpi_pdev->dev, in tpacpi_new_rfkill()
1273 if (!atp_rfk || !atp_rfk->rfkill) { in tpacpi_new_rfkill()
1276 return -ENOMEM; in tpacpi_new_rfkill()
1279 atp_rfk->id = id; in tpacpi_new_rfkill()
1280 atp_rfk->ops = tp_rfkops; in tpacpi_new_rfkill()
1282 sw_status = (tp_rfkops->get_status)(); in tpacpi_new_rfkill()
1291 rfkill_init_sw_state(atp_rfk->rfkill, sw_state); in tpacpi_new_rfkill()
1295 rfkill_set_hw_state(atp_rfk->rfkill, hw_state); in tpacpi_new_rfkill()
1297 res = rfkill_register(atp_rfk->rfkill); in tpacpi_new_rfkill()
1300 rfkill_destroy(atp_rfk->rfkill); in tpacpi_new_rfkill()
1320 rfkill_unregister(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1321 rfkill_destroy(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1333 /* sysfs <radio> enable ------------------------------------------------ */
1340 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_show()
1362 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_store()
1365 return -EINVAL; in tpacpi_rfk_sysfs_enable_store()
1367 tpacpi_disclose_usertask(attr->attr.name, "set to %ld\n", t); in tpacpi_rfk_sysfs_enable_store()
1371 return -EPERM; in tpacpi_rfk_sysfs_enable_store()
1373 res = tpacpi_rfkill_switches[id]->ops->set_status((!!t) ? in tpacpi_rfk_sysfs_enable_store()
1380 /* procfs -------------------------------------------------------------- */
1410 int status = -1; in tpacpi_rfk_procfs_write()
1414 return -ENODEV; in tpacpi_rfk_procfs_write()
1422 return -EINVAL; in tpacpi_rfk_procfs_write()
1425 if (status != -1) { in tpacpi_rfk_procfs_write()
1430 res = (tpacpi_rfkill_switches[id]->ops->set_status)(status); in tpacpi_rfk_procfs_write()
1438 * thinkpad-acpi driver attributes
1441 /* interface_version --------------------------------------------------- */
1448 /* debug_level --------------------------------------------------------- */
1460 return -EINVAL; in debug_level_store()
1468 /* version ------------------------------------------------------------- */
1476 /* --------------------------------------------------------------------- */
1480 /* wlsw_emulstate ------------------------------------------------------ */
1492 return -EINVAL; in wlsw_emulstate_store()
1503 /* bluetooth_emulstate ------------------------------------------------- */
1515 return -EINVAL; in bluetooth_emulstate_store()
1523 /* wwan_emulstate ------------------------------------------------- */
1535 return -EINVAL; in wwan_emulstate_store()
1543 /* uwb_emulstate ------------------------------------------------- */
1555 return -EINVAL; in uwb_emulstate_store()
1564 /* --------------------------------------------------------------------- */
1688 /* Numeric models ------------------ */
1700 /* A-series ------------------------- */
1714 /* G-series ------------------------- */
1719 /* R-series, T-series --------------- */
1749 /* X-series ------------------------- */
1762 /* (0) - older versions lack DMI EC fw string and functionality */
1763 /* (1) - older versions known to lack functionality */
1819 * thinkpad-acpi metadata subdriver
1854 * Unlike other classes, hotkey-class events have mask/unmask control on
1855 * non-ancient firmware. However, how it behaves changes a lot with the
1916 /* Lenovo extended keymap, starting at 0x1300 */
1929 /* Hotkey keymap size */
2081 return -ENODEV; in hotkey_get_wlsw()
2090 return -EIO; in hotkey_get_wlsw()
2184 return -EIO; in hotkey_get_tablet_mode()
2190 return -EIO; in hotkey_get_tablet_mode()
2215 return -EIO; in hotkey_mask_get()
2223 /* sync userspace-visible mask */ in hotkey_mask_get()
2261 rc = -EIO; in hotkey_mask_set()
2302 …pr_notice("please consider using the driver defaults, and refer to up-to-date thinkpad-acpi docume… in hotkey_user_mask_set()
2351 return -EIO; in hotkey_status_get()
2359 return -EIO; in hotkey_status_set()
2423 n->thinkpad_toggle = !!(d & TP_NVRAM_MASK_HKT_THINKPAD); in hotkey_read_nvram()
2424 n->zoom_toggle = !!(d & TP_NVRAM_MASK_HKT_ZOOM); in hotkey_read_nvram()
2425 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY); in hotkey_read_nvram()
2426 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE); in hotkey_read_nvram()
2430 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT); in hotkey_read_nvram()
2434 n->displayexp_toggle = in hotkey_read_nvram()
2439 n->brightness_level = (d & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) in hotkey_read_nvram()
2441 n->brightness_toggle = in hotkey_read_nvram()
2446 n->volume_level = (d & TP_NVRAM_MASK_LEVEL_VOLUME) in hotkey_read_nvram()
2448 n->mute = !!(d & TP_NVRAM_MASK_MUTE); in hotkey_read_nvram()
2449 n->volume_toggle = !!(d & TP_NVRAM_MASK_HKT_VOLUME); in hotkey_read_nvram()
2456 oldn->__member != newn->__member) \
2474 i--; in issue_volchange()
2490 i--; in issue_brightnesschange()
2516 * - Pressing MUTE issues mute hotkey message, even when already mute in hotkey_compare_and_issue_event()
2517 * - Pressing Volume up/down issues volume up/down hotkey messages, in hotkey_compare_and_issue_event()
2519 * - The act of unmuting issues volume up/down notification, in hotkey_compare_and_issue_event()
2529 if (newn->mute) { in hotkey_compare_and_issue_event()
2531 if (!oldn->mute || in hotkey_compare_and_issue_event()
2532 oldn->volume_toggle != newn->volume_toggle || in hotkey_compare_and_issue_event()
2533 oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2536 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2542 if (oldn->mute) { in hotkey_compare_and_issue_event()
2546 if (oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2547 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2549 } else if (oldn->volume_toggle != newn->volume_toggle) { in hotkey_compare_and_issue_event()
2551 if (newn->volume_level == 0) in hotkey_compare_and_issue_event()
2553 else if (newn->volume_level >= TP_NVRAM_LEVEL_VOLUME_MAX) in hotkey_compare_and_issue_event()
2559 if (oldn->brightness_level != newn->brightness_level) { in hotkey_compare_and_issue_event()
2560 issue_brightnesschange(oldn->brightness_level, in hotkey_compare_and_issue_event()
2561 newn->brightness_level, event_mask); in hotkey_compare_and_issue_event()
2562 } else if (oldn->brightness_toggle != newn->brightness_toggle) { in hotkey_compare_and_issue_event()
2564 if (newn->brightness_level == 0) in hotkey_compare_and_issue_event()
2566 else if (newn->brightness_level >= bright_maxlvl in hotkey_compare_and_issue_event()
2579 * most of them are edge-based. We only issue those requested by
2671 (poll_user_mask && tpacpi_inputdev->users > 0))) { in hotkey_poll_setup()
2726 return -EBUSY; in hotkey_inputdev_open()
2731 return -EBUSY; in hotkey_inputdev_open()
2742 /* sysfs hotkey enable ------------------------------------------------- */
2769 return -EINVAL; in hotkey_enable_store()
2772 return -EPERM; in hotkey_enable_store()
2779 /* sysfs hotkey mask --------------------------------------------------- */
2795 return -EINVAL; in hotkey_mask_store()
2798 return -ERESTARTSYS; in hotkey_mask_store()
2815 /* sysfs hotkey bios_enabled ------------------------------------------- */
2825 /* sysfs hotkey bios_mask ---------------------------------------------- */
2837 /* sysfs hotkey all_mask ----------------------------------------------- */
2848 /* sysfs hotkey all_mask ----------------------------------------------- */
2859 /* sysfs hotkey recommended_mask --------------------------------------- */
2873 /* sysfs hotkey hotkey_source_mask ------------------------------------- */
2891 return -EINVAL; in hotkey_source_mask_store()
2894 return -ERESTARTSYS; in hotkey_source_mask_store()
2924 /* sysfs hotkey hotkey_poll_freq --------------------------------------- */
2939 return -EINVAL; in hotkey_poll_freq_store()
2942 return -ERESTARTSYS; in hotkey_poll_freq_store()
2958 /* sysfs hotkey radio_sw (pollable) ------------------------------------ */
2980 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_radio_sw_notify_change()
2984 /* sysfs hotkey tablet mode (pollable) --------------------------------- */
3002 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_tablet_mode_notify_change()
3006 /* sysfs wakeup reason (pollable) -------------------------------------- */
3018 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_reason_notify_change()
3022 /* sysfs wakeup hotunplug_complete (pollable) -------------------------- */
3035 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_hotunplug_complete_notify_change()
3039 /* sysfs adaptive kbd mode --------------------------------------------- */
3073 return -EINVAL; in adaptive_kbd_mode_store()
3090 /* --------------------------------------------------------------------- */
3128 /* Sync hw blocking state first if it is hw-blocked */ in tpacpi_send_radiosw_update()
3135 /* Sync hw blocking state last if it is hw-unblocked */ in tpacpi_send_radiosw_update()
3166 delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj); in hotkey_exit()
3182 tpacpi_inputdev->keybit); in hotkey_unmap()
3189 * TPACPI_HK_Q_INIMASK: Supports FN+F3,FN+F4,FN+F12
3255 return -1; in hotkey_init_tablet_mode()
3271 * firmware at driver load time, which means the firm- in hotkey_init()
3275 * 2. You must be subscribed to the linux-thinkpad and in hotkey_init()
3276 * ibm-acpi-devel mailing lists, and you should read the in hotkey_init()
3279 * know the past history of problems with the thinkpad- in hotkey_init()
3283 * 3. Do not send thinkpad-acpi specific patches directly to in hotkey_init()
3284 * for merging, *ever*. Send them to the linux-acpi in hotkey_init()
3286 * through acpi-test and the ACPI maintainer. in hotkey_init()
3288 * If the above is too much to ask, don't change the keymap. in hotkey_init()
3289 * Ask the thinkpad-acpi maintainer to do it, instead. in hotkey_init()
3298 /* Generic keymap for IBM ThinkPads */ in hotkey_init()
3300 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */ in hotkey_init()
3306 KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ in hotkey_init()
3307 KEY_UNKNOWN, /* 0x0D: FN+INSERT */ in hotkey_init()
3308 KEY_UNKNOWN, /* 0x0E: FN+DELETE */ in hotkey_init()
3311 KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */ in hotkey_init()
3312 KEY_RESERVED, /* 0x10: FN+END (brightness down) */ in hotkey_init()
3315 KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ in hotkey_init()
3317 KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ in hotkey_init()
3318 KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ in hotkey_init()
3321 * the built-in *extra* mixer. Never map it to control in hotkey_init()
3350 /* Generic keymap for Lenovo ThinkPads */ in hotkey_init()
3352 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */ in hotkey_init()
3358 KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ in hotkey_init()
3359 KEY_UNKNOWN, /* 0x0D: FN+INSERT */ in hotkey_init()
3360 KEY_UNKNOWN, /* 0x0E: FN+DELETE */ in hotkey_init()
3362 /* These should be enabled --only-- when ACPI video in hotkey_init()
3365 KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */ in hotkey_init()
3366 KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */ in hotkey_init()
3368 KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ in hotkey_init()
3370 KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ in hotkey_init()
3371 KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ in hotkey_init()
3374 * react to it and reprograms the built-in *extra* mixer. in hotkey_init()
3378 * these over the regular keyboard, so these are no-ops, in hotkey_init()
3456 KEY_FN_RIGHT_SHIFT, /* Fn + right Shift */ in hotkey_init()
3493 BUG_ON(tpacpi_inputdev->open != NULL || in hotkey_init()
3494 tpacpi_inputdev->close != NULL); in hotkey_init()
3524 return -ENOMEM; in hotkey_init()
3532 A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking in hotkey_init()
3551 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3568 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3583 &tpacpi_pdev->dev.kobj, in hotkey_init()
3609 hotkey_all_mask = 0x080cU; /* FN+F12, FN+F4, FN+F3 */ in hotkey_init()
3650 &tpacpi_pdev->dev.kobj); in hotkey_init()
3659 "using keymap number %lu\n", keymap_id); in hotkey_init()
3665 res = -ENOMEM; in hotkey_init()
3670 tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE; in hotkey_init()
3671 tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN; in hotkey_init()
3672 tpacpi_inputdev->keycode = hotkey_keycode_map; in hotkey_init()
3699 pr_notice("Disabling thinkpad-acpi brightness events by default...\n"); in hotkey_init()
3731 if (res < 0 && res != -ENXIO) { in hotkey_init()
3741 tpacpi_inputdev->open = &hotkey_inputdev_open; in hotkey_init()
3742 tpacpi_inputdev->close = &hotkey_inputdev_close; in hotkey_init()
3749 delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj); in hotkey_init()
3750 sysfs_remove_group(&tpacpi_pdev->dev.kobj, in hotkey_init()
3759 * mode, Web conference mode, Function mode and Lay-flat mode.
3776 /* press Fn key a while second, it will switch to Function Mode. Then
3777 * release Fn key, previous mode be restored.
3788 return -EIO; in adaptive_keyboard_get_mode()
3798 return -EINVAL; in adaptive_keyboard_set_mode()
3802 return -EIO; in adaptive_keyboard_set_mode()
3811 size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1; in adaptive_keyboard_get_next_mode()
3865 TP_ACPI_HOTKEYSCAN_EXTENDED_START - in adaptive_keyboard_hotkey_notify_hotkey()
3871 keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + in adaptive_keyboard_hotkey_notify_hotkey()
3892 /* 0x1000-0x1FFF: key presses */ in hotkey_notify_hotkey()
3907 scancode--; in hotkey_notify_hotkey()
3926 scancode -= (0x300 - TP_ACPI_HOTKEYSCAN_EXTENDED_START); in hotkey_notify_hotkey()
3942 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify_wakeup()
3962 /* how to auto-heal: */ in hotkey_notify_wakeup()
3972 pr_info("woke up due to a hot-unplug request...\n"); in hotkey_notify_wakeup()
3982 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify_dockevent()
4003 * duplicates from intel-vbtn, which already emits SW_TABLET_MODE events in hotkey_notify_dockevent()
4010 * https://lore.kernel.org/platform-driver-x86/38cb8265-1e30-d547-9e12-b4ae290be737@a-kobel.de/ in hotkey_notify_dockevent()
4027 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify_usrevent()
4036 case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ in hotkey_notify_usrevent()
4037 case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ in hotkey_notify_usrevent()
4062 /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ in hotkey_notify_6xxx()
4074 /* Thermal event - pass on to event handler */ in hotkey_notify_6xxx()
4129 /* palm detected - pass on to event handler */ in hotkey_notify_6xxx()
4153 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4154 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4175 /* 0x1000-0x1FFF: key presses */ in hotkey_notify()
4180 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify()
4185 /* 0x3000-0x3FFF: bay-related wakeups */ in hotkey_notify()
4202 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify()
4207 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify()
4212 /* 0x6000-0x6FFF: thermal alarms/notices and in hotkey_notify()
4218 /* 0x7000-0x7FFF: misc */ in hotkey_notify()
4239 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4240 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4285 /* procfs -------------------------------------------------------------- */
4296 return -ERESTARTSYS; in hotkey_read()
4331 return -ENODEV; in hotkey_write()
4334 return -ERESTARTSYS; in hotkey_write()
4344 res = -EPERM; in hotkey_write()
4353 res = -EINVAL; in hotkey_write()
4408 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
4427 return -EIO; in bluetooth_get_status()
4455 return -EIO; in bluetooth_set_status()
4460 /* sysfs bluetooth enable ---------------------------------------------- */
4479 /* --------------------------------------------------------------------- */
4508 sysfs_remove_group(&tpacpi_pdev->dev.kobj, in bluetooth_exit()
4532 .ident = "ThinkPad A285 - 20MW",
4539 .ident = "ThinkPad A285 - 20MX",
4546 .ident = "ThinkPad A485 - 20MU",
4553 .ident = "ThinkPad A485 - 20MV",
4595 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ in bluetooth_init()
4629 res = sysfs_create_group(&tpacpi_pdev->dev.kobj, in bluetooth_init()
4639 /* procfs -------------------------------------------------------------- */
4683 return -EIO; in wan_get_status()
4711 return -EIO; in wan_set_status()
4716 /* sysfs wan enable ---------------------------------------------------- */
4736 /* --------------------------------------------------------------------- */
4765 sysfs_remove_group(&tpacpi_pdev->dev.kobj, in wan_exit()
4816 res = sysfs_create_group(&tpacpi_pdev->dev.kobj, in wan_init()
4827 /* procfs -------------------------------------------------------------- */
4869 return -EIO; in uwb_get_status()
4896 return -EIO; in uwb_set_status()
4901 /* --------------------------------------------------------------------- */
5059 return -EIO; in video_outputsw_get()
5064 return -EIO; in video_outputsw_get()
5068 return -EIO; in video_outputsw_get()
5075 return -EIO; in video_outputsw_get()
5081 return -EIO; in video_outputsw_get()
5085 return -EIO; in video_outputsw_get()
5090 return -ENOSYS; in video_outputsw_get()
5119 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_set()
5120 return -EIO; in video_outputsw_set()
5128 return -ENOSYS; in video_outputsw_set()
5131 return (res) ? 0 : -EIO; in video_outputsw_set()
5141 return -EIO; in video_autosw_get()
5146 return -EIO; in video_autosw_get()
5149 return -ENOSYS; in video_autosw_get()
5158 return -EIO; in video_autosw_set()
5185 return -ENOSYS; in video_outputsw_cycle()
5188 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_cycle()
5189 return -EIO; in video_outputsw_cycle()
5192 return (res) ? 0 : -EIO; in video_outputsw_cycle()
5200 0 : -EIO; in video_expand_toggle()
5203 0 : -EIO; in video_expand_toggle()
5206 0 : -EIO; in video_expand_toggle()
5208 return -ENOSYS; in video_expand_toggle()
5224 return -EPERM; in video_read()
5257 return -ENODEV; in video_write()
5261 return -EPERM; in video_write()
5298 return -EINVAL; in video_write()
5334 return -ENXIO; in kbdlight_set_level()
5339 ret = -EIO; in kbdlight_set_level()
5353 return -ENXIO; in kbdlight_get_level()
5356 return -EIO; in kbdlight_get_level()
5391 * b010100000010000000XX - ThinkPad X1 Carbon 3rd in kbdlight_is_supported()
5392 * b110100010010000000XX - ThinkPad x230 in kbdlight_is_supported()
5393 * b010100000010000000XX - ThinkPad x240 in kbdlight_is_supported()
5394 * b010100000010000000XX - ThinkPad W541 in kbdlight_is_supported()
5398 * b10100001000000000000 - ThinkPad x230 in kbdlight_is_supported()
5399 * b10110001000000000000 - ThinkPad E430 in kbdlight_is_supported()
5400 * b00000000000000000000 - ThinkPad E450 in kbdlight_is_supported()
5453 rc = led_classdev_register(&tpacpi_pdev->dev, in kbdlight_init()
5478 if (ret == 0 && !(led_cdev->flags & LED_SUSPENDED)) in kbdlight_set_level_and_update()
5479 led_cdev->brightness = level; in kbdlight_set_level_and_update()
5505 int res, level = -EINVAL; in kbdlight_write()
5508 return -ENODEV; in kbdlight_write()
5517 return -EINVAL; in kbdlight_write()
5555 TPACPI_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
5564 return -EIO; in light_get_status()
5568 return -ENXIO; in light_get_status()
5585 return (rc) ? 0 : -EIO; in light_set_status()
5588 return -ENXIO; in light_set_status()
5639 rc = led_classdev_register(&tpacpi_pdev->dev, in light_init()
5683 return -ENODEV; in light_write()
5691 return -EINVAL; in light_write()
5708 /* sysfs cmos_command -------------------------------------------------- */
5717 return -EINVAL; in cmos_command_store()
5725 /* --------------------------------------------------------------------- */
5739 res = device_create_file(&tpacpi_pdev->dev, &dev_attr_cmos_command); in cmos_init()
5748 device_remove_file(&tpacpi_pdev->dev, &dev_attr_cmos_command); in cmos_exit()
5754 R30, R31, T20-22, X20-21 */ in cmos_read()
5759 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); in cmos_read()
5775 return -EINVAL; in cmos_write()
5799 TPACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
5852 return -EIO; in led_get_status()
5861 return -ENXIO; in led_get_status()
5880 return -EINVAL; in led_set_status()
5882 return -EPERM; in led_set_status()
5885 return -EIO; in led_set_status()
5888 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ in led_set_status()
5890 return -EINVAL; in led_set_status()
5892 return -EPERM; in led_set_status()
5904 return -EINVAL; in led_set_status()
5906 return -EPERM; in led_set_status()
5909 return -EIO; in led_set_status()
5912 return -ENXIO; in led_set_status()
5930 else if (tpacpi_led_state_cache[data->led] != TPACPI_LED_BLINK) in led_sysfs_set()
5935 return led_set_status(data->led, new_state); in led_sysfs_set()
5950 return -EINVAL; in led_sysfs_blink_set()
5952 return led_set_status(data->led, TPACPI_LED_BLINK); in led_sysfs_blink_set()
5962 rc = led_get_status(data->led); in led_sysfs_get()
5996 return led_classdev_register(&tpacpi_pdev->dev, &tpacpi_leds[led].led_classdev); in tpacpi_init_led()
6024 /* (1) - may have excess leds enabled on MSB */
6054 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ in led_init_detect_mode()
6100 return -ENOMEM; in led_init()
6104 tpacpi_leds[i].led = -1; in led_init()
6139 return -EIO; in led_read()
6145 seq_printf(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); in led_read()
6157 return -ENODEV; in led_write()
6161 return -EINVAL; in led_write()
6163 if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1)) in led_write()
6164 return -ENODEV; in led_write()
6167 return -ENODEV; in led_write()
6176 return -EINVAL; in led_write()
6204 TPACPI_Q_IBM('I', 'U', TPACPI_BEEP_Q1), /* 570E - unverified */
6232 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); in beep_read()
6244 return -ENODEV; in beep_write()
6251 return -EINVAL; in beep_write()
6255 return -EIO; in beep_write()
6259 return -EIO; in beep_write()
6278 TPACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */
6279 TPACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */
6288 TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
6290 TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
6303 /* idx is zero-based */
6317 idx -= 8; in thermal_get_sensor()
6324 return -EIO; in thermal_get_sensor()
6334 return -EIO; in thermal_get_sensor()
6336 return -EIO; in thermal_get_sensor()
6337 *value = (t - 2732) * 100; in thermal_get_sensor()
6346 return -EIO; in thermal_get_sensor()
6347 if (t > 127 || t < -127) in thermal_get_sensor()
6356 return -ENOSYS; in thermal_get_sensor()
6359 return -EINVAL; in thermal_get_sensor()
6371 return -EINVAL; in thermal_get_sensors()
6377 res = thermal_get_sensor(i, &s->temp[i]); in thermal_get_sensors()
6406 /* sysfs temp##_input -------------------------------------------------- */
6414 int idx = sensor_attr->index; in thermal_temp_input_show()
6422 return -ENXIO; in thermal_temp_input_show()
6506 /* --------------------------------------------------------------------- */
6522 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for in thermal_init()
6523 * non-implemented, thermal sensors return 0x80 when in thermal_init()
6528 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7 in thermal_init()
6602 res = sysfs_create_group(&tpacpi_hwmon->kobj, thermal_attr_group); in thermal_init()
6607 res = sysfs_create_group(&tpacpi_hwmon->kobj, &temp_label_attr_group); in thermal_init()
6609 sysfs_remove_group(&tpacpi_hwmon->kobj, thermal_attr_group); in thermal_init()
6620 sysfs_remove_group(&tpacpi_hwmon->kobj, thermal_attr_group); in thermal_exit()
6623 sysfs_remove_group(&tpacpi_hwmon->kobj, &temp_label_attr_group); in thermal_exit()
6638 for (i = 0; i < (n - 1); i++) in thermal_read()
6661 * CMOS NVRAM byte 0x5E, bits 0-3.
6668 * Bit 3-0: backlight brightness level
6689 TPACPI_BRGHT_MODE_UCMS_STEP, /* UCMS step-based control */
6768 return -EIO; in tpacpi_brightness_get_raw()
6772 return -ENXIO; in tpacpi_brightness_get_raw()
6783 return -EIO; in tpacpi_brightness_set_ec()
6788 return -EIO; in tpacpi_brightness_set_ec()
6807 inc = (value > current_value) ? 1 : -1; in tpacpi_brightness_set_ucmsstep()
6811 return -EIO; in tpacpi_brightness_set_ucmsstep()
6822 return -EINVAL; in brightness_set()
6840 res = -ENXIO; in brightness_set()
6847 /* sysfs backlight class ----------------------------------------------- */
6852 (bd->props.fb_blank == FB_BLANK_UNBLANK && in brightness_update_status()
6853 bd->props.power == FB_BLANK_UNBLANK) ? in brightness_update_status()
6854 bd->props.brightness : 0; in brightness_update_status()
6894 /* --------------------------------------------------------------------- */
6912 list_for_each_entry(child, &device->children, node) { in tpacpi_query_bcl_levels()
6913 acpi_status status = acpi_evaluate_object(child->handle, "_BCL", in tpacpi_query_bcl_levels()
6921 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { in tpacpi_query_bcl_levels()
6926 rc = obj->package.count; in tpacpi_query_bcl_levels()
6950 return (bcl_levels > 2) ? (bcl_levels - 2) : 0; in tpacpi_check_std_acpi_brightness_support()
6967 TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */
7013 bright_maxlvl = b - 1; in tpacpi_detect_brightness_capabilities()
7064 return -EINVAL; in brightness_init()
7075 "driver auto-selected brightness_mode=%d\n", in brightness_init()
7083 return -EINVAL; in brightness_init()
7157 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in brightness_read()
7180 level--; in brightness_write()
7185 return -EINVAL; in brightness_write()
7199 return (rc == -EINTR) ? -ERESTARTSYS : rc; in brightness_write()
7224 * Bit 3-0: Volume
7228 * bits 3-0 (volume). Other bits in NVRAM may have other functions,
7240 * To avoid confusing userspace, we simply disable all EC-based mute
7251 #define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
7253 #define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
7284 TPACPI_VOL_MODE_UCMS_STEP, /* UCMS step-based control: N/A */
7314 * TP_NVRAM_ADDR_MIXER, as we need to do read-modify-write
7370 return -EIO; in volume_get_status_ec()
7387 return -EIO; in volume_set_status_ec()
7412 return -EINTR; in __volume_set_mute_ec()
7457 return -EINVAL; in __volume_set_volume_ec()
7460 return -EINTR; in __volume_set_volume_ec()
7484 return -ENODEV; in volume_set_software_mute()
7489 return -EIO; in volume_set_software_mute()
7498 return -EIO; in volume_set_software_mute()
7507 * startup. Just on case there are SAUM-capable ThinkPads in volume_set_software_mute()
7541 if (alsa_card && alsa_card->private_data) { in volume_alsa_notify_change()
7542 d = alsa_card->private_data; in volume_alsa_notify_change()
7543 if (d->ctl_mute_id) in volume_alsa_notify_change()
7546 d->ctl_mute_id); in volume_alsa_notify_change()
7547 if (d->ctl_vol_id) in volume_alsa_notify_change()
7550 d->ctl_vol_id); in volume_alsa_notify_change()
7557 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in volume_alsa_vol_info()
7558 uinfo->count = 1; in volume_alsa_vol_info()
7559 uinfo->value.integer.min = 0; in volume_alsa_vol_info()
7560 uinfo->value.integer.max = TP_EC_VOLUME_MAX; in volume_alsa_vol_info()
7574 ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK; in volume_alsa_vol_get()
7582 ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7583 return volume_alsa_set_volume(ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7598 ucontrol->value.integer.value[0] = in volume_alsa_mute_get()
7607 ucontrol->value.integer.value[0] ? in volume_alsa_mute_put()
7609 return volume_alsa_set_mute(!ucontrol->value.integer.value[0]); in volume_alsa_mute_put()
7671 rc = snd_card_new(&tpacpi_pdev->dev, in volume_create_alsa_mixer()
7679 BUG_ON(!card->private_data); in volume_create_alsa_mixer()
7680 data = card->private_data; in volume_create_alsa_mixer()
7681 data->card = card; in volume_create_alsa_mixer()
7683 strlcpy(card->driver, TPACPI_ALSA_DRVNAME, in volume_create_alsa_mixer()
7684 sizeof(card->driver)); in volume_create_alsa_mixer()
7685 strlcpy(card->shortname, TPACPI_ALSA_SHRTNAME, in volume_create_alsa_mixer()
7686 sizeof(card->shortname)); in volume_create_alsa_mixer()
7687 snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s", in volume_create_alsa_mixer()
7690 snprintf(card->longname, sizeof(card->longname), in volume_create_alsa_mixer()
7691 "%s at EC reg 0x%02x, fw %s", card->shortname, TP_EC_AUDIO, in volume_create_alsa_mixer()
7713 data->ctl_vol_id = &ctl_vol->id; in volume_create_alsa_mixer()
7722 data->ctl_mute_id = &ctl_mute->id; in volume_create_alsa_mixer()
7738 #define TPACPI_VOL_Q_MUTEONLY 0x0001 /* Mute-only control available */
7757 /* Whitelist mute-only on all Lenovo by default */
7779 return -EINVAL; in volume_init()
7788 return -EINVAL; in volume_init()
7824 "using user-supplied volume_capabilities=%d\n", in volume_init()
7832 "driver auto-selected volume_mode=%d\n", in volume_init()
7836 "using user-supplied volume_mode=%d\n", in volume_init()
7889 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in volume_read()
7916 return -EPERM; in volume_write()
7938 new_level--; in volume_write()
7951 return -EINVAL; in volume_write()
7966 return (rc == -EINTR) ? -ERESTARTSYS : rc; in volume_write()
8039 * Speeds up fan to 100% duty-cycle, which is far above
8042 * 5-3 unused in some models. Extra bits for fan level
8045 * 2-0 fan level (0..7 usually)
8058 * ----
8063 * This register is present on all ThinkPads with a new-style EC, and
8069 * Unfortunately a lot of ThinkPads with new-style ECs but whose firmware
8083 * ----
8095 * So far, only the firmware for the X60/X61 non-tablet versions
8096 * seem to support this (firmware TP-7M).
8130 TPACPI_FAN_LAST_LEVEL = 0x100, /* Use cached last-seen fan level */
8136 TPACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
8174 "JFNS", /* 770x-JL */
8189 * Enable for TP-1Y (T43), TP-78 (R51e), TP-76 (R52),
8190 * TP-70 (T43, R52), which are known to be buggy.
8276 return -EIO; in fan_get_status()
8286 return -EIO; in fan_get_status()
8296 return -ENXIO; in fan_get_status()
8308 return -ERESTARTSYS; in fan_get_status_safe()
8330 return -EIO; in fan_get_speed()
8333 return -EIO; in fan_get_speed()
8341 return -ENXIO; in fan_get_speed()
8356 return -EIO; in fan2_get_speed()
8361 return -EIO; in fan2_get_speed()
8369 return -ENXIO; in fan2_get_speed()
8378 return -EPERM; in fan_set_level()
8383 return -EINVAL; in fan_set_level()
8394 return -EIO; in fan_set_level()
8402 return -EINVAL; in fan_set_level()
8421 return -EIO; in fan_set_level()
8427 return -ENXIO; in fan_set_level()
8440 return -EPERM; in fan_set_level_safe()
8443 return -ERESTARTSYS; in fan_set_level_safe()
8462 return -EPERM; in fan_set_enable()
8465 return -ERESTARTSYS; in fan_set_enable()
8481 rc = -EIO; in fan_set_enable()
8499 rc = -EIO; in fan_set_enable()
8505 rc = -ENXIO; in fan_set_enable()
8522 return -EPERM; in fan_set_disable()
8525 return -ERESTARTSYS; in fan_set_disable()
8532 rc = -EIO; in fan_set_disable()
8541 rc = -EIO; in fan_set_disable()
8547 rc = -ENXIO; in fan_set_disable()
8563 return -EPERM; in fan_set_speed()
8566 return -ERESTARTSYS; in fan_set_speed()
8574 rc = -EIO; in fan_set_speed()
8576 rc = -EINVAL; in fan_set_speed()
8580 rc = -ENXIO; in fan_set_speed()
8638 /* sysfs fan pwm1_enable ----------------------------------------------- */
8668 return -EINVAL; in fan_pwm1_enable_store()
8684 /* reserved for software-controlled auto mode */ in fan_pwm1_enable_store()
8685 return -ENOSYS; in fan_pwm1_enable_store()
8687 return -EINVAL; in fan_pwm1_enable_store()
8691 if (res == -ENXIO) in fan_pwm1_enable_store()
8692 return -EINVAL; in fan_pwm1_enable_store()
8704 /* sysfs fan pwm1 ------------------------------------------------------ */
8735 return -EINVAL; in fan_pwm1_store()
8740 /* scale down from 0-255 to 0-7 */ in fan_pwm1_store()
8744 return -ERESTARTSYS; in fan_pwm1_store()
8750 if (rc == -ENXIO) in fan_pwm1_store()
8751 rc = -EINVAL; in fan_pwm1_store()
8764 /* sysfs fan fan1_input ------------------------------------------------ */
8781 /* sysfs fan fan2_input ------------------------------------------------ */
8798 /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
8810 return -EINVAL; in fan_watchdog_store()
8813 return -EPERM; in fan_watchdog_store()
8824 /* --------------------------------------------------------------------- */
8891 /* all other ThinkPads: note that even old-style in fan_init()
8914 /* 570, 770x-JL */ in fan_init()
8962 fan_attributes[ARRAY_SIZE(fan_attributes)-2] = in fan_init()
8965 rc = sysfs_create_group(&tpacpi_hwmon->kobj, in fan_init()
8973 sysfs_remove_group(&tpacpi_hwmon->kobj, in fan_init()
8988 sysfs_remove_group(&tpacpi_hwmon->kobj, &fan_attr_group); in fan_exit()
9123 seq_printf(m, " (<level> is 0-7)\n"); in fan_read()
9127 seq_printf(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); in fan_read()
9134 "commands:\twatchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))\n"); in fan_read()
9137 seq_printf(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); in fan_read()
9149 (strlencmp(cmd, "level full-speed") == 0)) in fan_write_cmd_level()
9155 if (*rc == -ENXIO) in fan_write_cmd_level()
9171 if (*rc == -ENXIO) in fan_write_cmd_enable()
9186 if (*rc == -ENXIO) in fan_write_cmd_disable()
9206 if (*rc == -ENXIO) in fan_write_cmd_speed()
9224 *rc = -EINVAL; in fan_write_cmd_watchdog()
9250 rc = -EINVAL; in fan_write()
9298 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_on_off()
9299 pr_warn("Thinkpad ACPI has no %s interface.\n", t->name); in mute_led_on_off()
9300 return -EIO; in mute_led_on_off()
9303 if (!acpi_evalf(hkey_handle, &output, t->name, "dd", in mute_led_on_off()
9304 state ? t->on_value : t->off_value)) in mute_led_on_off()
9305 return -EIO; in mute_led_on_off()
9307 t->state = state; in mute_led_on_off()
9316 if (t->state < 0 || t->state == on) in tpacpi_led_set()
9317 return t->state; in tpacpi_led_set()
9338 .default_trigger = "audio-mute",
9344 .default_trigger = "audio-micmute",
9355 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_init()
9356 t->state = -ENODEV; in mute_led_init()
9361 err = led_classdev_register(&tpacpi_pdev->dev, &mute_led_cdev[i]); in mute_led_init()
9363 while (i--) in mute_led_init()
9387 if (t->state >= 0) in mute_led_resume()
9388 mute_led_on_off(t, t->state); in mute_led_resume()
9470 return -ENODEV; in tpacpi_battery_get()
9477 return -ENODEV; in tpacpi_battery_get()
9491 return -EINVAL; in tpacpi_battery_get()
9500 /* The battery ID is in bits 8-9, 2 bits */ in tpacpi_battery_set()
9508 return -ENODEV; in tpacpi_battery_set()
9514 return -ENODEV; in tpacpi_battery_set()
9519 return -EINVAL; in tpacpi_battery_set()
9539 return -ENODEV; in tpacpi_battery_probe()
9548 return -ENODEV; in tpacpi_battery_probe()
9552 return -ENODEV; in tpacpi_battery_probe()
9558 return -ENODEV; in tpacpi_battery_probe()
9564 return -ENODEV; in tpacpi_battery_probe()
9568 return -ENODEV; in tpacpi_battery_probe()
9620 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_store()
9631 return -ENODEV; in tpacpi_battery_store()
9634 return -EINVAL; in tpacpi_battery_store()
9636 return -EINVAL; in tpacpi_battery_store()
9638 return -ENODEV; in tpacpi_battery_store()
9644 return -ENODEV; in tpacpi_battery_store()
9647 return -EINVAL; in tpacpi_battery_store()
9649 return -EINVAL; in tpacpi_battery_store()
9659 return -EINVAL; in tpacpi_battery_store()
9663 return -EINVAL; in tpacpi_battery_store()
9687 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_show()
9691 return -ENODEV; in tpacpi_battery_show()
9752 int batteryid = tpacpi_battery_get_id(battery->desc->name); in tpacpi_battery_add()
9755 return -ENODEV; in tpacpi_battery_add()
9756 if (device_add_groups(&battery->dev, tpacpi_battery_groups)) in tpacpi_battery_add()
9757 return -ENODEV; in tpacpi_battery_add()
9763 device_remove_groups(&battery->dev, tpacpi_battery_groups); in tpacpi_battery_remove()
9823 return -EIO; in lcdshadow_on_off()
9827 return -EIO; in lcdshadow_on_off()
9848 lcdshadow_state = -ENODEV; in tpacpi_lcdshadow_init()
9853 lcdshadow_state = -EIO; in tpacpi_lcdshadow_init()
9854 return -EIO; in tpacpi_lcdshadow_init()
9857 lcdshadow_state = -ENODEV; in tpacpi_lcdshadow_init()
9886 int res, state = -EINVAL; in lcdshadow_write()
9889 return -ENODEV; in lcdshadow_write()
9898 return -EINVAL; in lcdshadow_write()
9914 #define DYTC_CMD_QUERY 0 /* To get DYTC status - enable/revision */
9915 #define DYTC_QUERY_ENABLE_BIT 8 /* Bit 8 - 0 = disabled, 1 = enabled */
9916 #define DYTC_QUERY_SUBREV_BIT 16 /* Bits 16 - 27 - sub revision */
9917 #define DYTC_QUERY_REV_BIT 28 /* Bits 28 - 31 - revision */
9937 return -ENODEV; in dytc_command()
9940 return -EIO; in dytc_command()
9948 /* Check if we've been called before - and just return cached value */ in dytc_get_version()
9958 if (err == -ENODEV) in dytc_get_version()
9992 return -ENODEV; in palmsensor_get()
9994 return -EIO; in palmsensor_get()
10012 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "dytc_lapmode"); in lapsensor_refresh()
10028 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "palmsensor"); in palmsensor_refresh()
10063 if ((palm_err == -ENODEV) && (lap_err == -ENODEV)) in tpacpi_proxsensor_init()
10066 if (palm_err && (palm_err != -ENODEV)) in tpacpi_proxsensor_init()
10068 if (lap_err && (lap_err != -ENODEV)) in tpacpi_proxsensor_init()
10072 err = sysfs_create_file(&tpacpi_pdev->dev.kobj, &dev_attr_palmsensor.attr); in tpacpi_proxsensor_init()
10088 err = sysfs_create_file(&tpacpi_pdev->dev.kobj, &dev_attr_dytc_lapmode.attr); in tpacpi_proxsensor_init()
10098 sysfs_remove_file(&tpacpi_pdev->dev.kobj, &dev_attr_dytc_lapmode.attr); in proxsensor_exit()
10100 sysfs_remove_file(&tpacpi_pdev->dev.kobj, &dev_attr_palmsensor.attr); in proxsensor_exit()
10104 .name = "proximity-sensor",
10116 #define DYTC_GET_FUNCTION_BIT 8 /* Bits 8-11 - function setting */
10117 #define DYTC_GET_MODE_BIT 12 /* Bits 12-15 - mode setting */
10119 #define DYTC_SET_FUNCTION_BIT 12 /* Bits 12-15 - function setting */
10120 #define DYTC_SET_MODE_BIT 16 /* Bits 16-19 - mode setting */
10121 #define DYTC_SET_VALID_BIT 20 /* Bit 20 - 1 = on, 0 = off */
10132 #define DYTC_ERR_MASK 0xF /* Bits 0-3 in cmd result are the error result */
10164 return -EINVAL; in convert_dytc_to_profile()
10182 return -EOPNOTSUPP; in convert_profile_to_dytc()
10199 * Helper function - check if we are in CQL mode and if we are
10200 * - disable CQL,
10201 * - run the command
10202 * - enable CQL
10249 return -ENODEV; in dytc_profile_set()
10258 * Note we still need to disable CQL mode before hand and re-enable in dytc_profile_set()
10277 /* Success - update current profile */ in dytc_profile_set()
10327 if (err == -ENODEV) in tpacpi_dytc_profile_init()
10378 .name = "dytc-profile",
10400 {"fr-ch", 0x100c},
10420 return -ENODEV; in set_keyboard_lang_command()
10424 return -EIO; in set_keyboard_lang_command()
10436 return -ENODEV; in get_keyboard_lang()
10440 return -EIO; in get_keyboard_lang()
10444 * '(' and ')') keys which use layout dependent key-press emulation. in get_keyboard_lang()
10447 return -ENODEV; in get_keyboard_lang()
10504 dev_err(&tpacpi_pdev->dev, "Unknown Keyboard language. Ignoring\n"); in keyboard_lang_store()
10505 return -EINVAL; in keyboard_lang_store()
10508 tpacpi_disclose_usertask(attr->attr.name, in keyboard_lang_store()
10511 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang"); in keyboard_lang_store()
10535 if (err == -ENODEV) in tpacpi_kbdlang_init()
10541 /* Platform supports this feature - create the sysfs file */ in tpacpi_kbdlang_init()
10542 return sysfs_create_group(&tpacpi_pdev->dev.kobj, &kbdlang_attr_group); in tpacpi_kbdlang_init()
10547 sysfs_remove_group(&tpacpi_pdev->dev.kobj, &kbdlang_attr_group); in kbdlang_exit()
10571 return -ENODEV; in dprc_command()
10575 return -EIO; in dprc_command()
10583 return -ENODEV; in dprc_command()
10602 return -ENODEV; in get_wwan_antenna()
10618 return -ENODATA; in wwan_antenna_type_show()
10632 if (wwanantenna_err == -ENODEV) in tpacpi_dprc_init()
10636 if (wwanantenna_err && (wwanantenna_err != -ENODEV)) in tpacpi_dprc_init()
10642 err = sysfs_create_file(&tpacpi_pdev->dev.kobj, &dev_attr_wwan_antenna_type.attr); in tpacpi_dprc_init()
10652 sysfs_remove_file(&tpacpi_pdev->dev.kobj, &dev_attr_wwan_antenna_type.attr); in dprc_exit()
10711 if (!atomic_add_unless(&dytc_ignore_event, -1, 0)) in tpacpi_driver_event()
10721 /* --------------------------------------------------------------------- */
10743 dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name); in ibm_exit()
10745 list_del_init(&ibm->all_drivers); in ibm_exit()
10747 if (ibm->flags.acpi_notify_installed) { in ibm_exit()
10749 "%s: acpi_remove_notify_handler\n", ibm->name); in ibm_exit()
10750 BUG_ON(!ibm->acpi); in ibm_exit()
10751 acpi_remove_notify_handler(*ibm->acpi->handle, in ibm_exit()
10752 ibm->acpi->type, in ibm_exit()
10754 ibm->flags.acpi_notify_installed = 0; in ibm_exit()
10757 if (ibm->flags.proc_created) { in ibm_exit()
10759 "%s: remove_proc_entry\n", ibm->name); in ibm_exit()
10760 remove_proc_entry(ibm->name, proc_dir); in ibm_exit()
10761 ibm->flags.proc_created = 0; in ibm_exit()
10764 if (ibm->flags.acpi_driver_registered) { in ibm_exit()
10766 "%s: acpi_bus_unregister_driver\n", ibm->name); in ibm_exit()
10767 BUG_ON(!ibm->acpi); in ibm_exit()
10768 acpi_bus_unregister_driver(ibm->acpi->driver); in ibm_exit()
10769 kfree(ibm->acpi->driver); in ibm_exit()
10770 ibm->acpi->driver = NULL; in ibm_exit()
10771 ibm->flags.acpi_driver_registered = 0; in ibm_exit()
10774 if (ibm->flags.init_called && ibm->exit) { in ibm_exit()
10775 ibm->exit(); in ibm_exit()
10776 ibm->flags.init_called = 0; in ibm_exit()
10779 dbg_printk(TPACPI_DBG_INIT, "finished removing %s\n", ibm->name); in ibm_exit()
10785 struct ibm_struct *ibm = iibm->data; in ibm_init()
10790 INIT_LIST_HEAD(&ibm->all_drivers); in ibm_init()
10792 if (ibm->flags.experimental && !experimental) in ibm_init()
10796 "probing for %s\n", ibm->name); in ibm_init()
10798 if (iibm->init) { in ibm_init()
10799 ret = iibm->init(iibm); in ibm_init()
10805 ibm->flags.init_called = 1; in ibm_init()
10808 if (ibm->acpi) { in ibm_init()
10809 if (ibm->acpi->hid) { in ibm_init()
10815 if (ibm->acpi->notify) { in ibm_init()
10817 if (ret == -ENODEV) { in ibm_init()
10819 ibm->name); in ibm_init()
10829 "%s installed\n", ibm->name); in ibm_init()
10831 if (ibm->read) { in ibm_init()
10832 umode_t mode = iibm->base_procfs_mode; in ibm_init()
10836 if (ibm->write) in ibm_init()
10838 entry = proc_create_data(ibm->name, mode, proc_dir, in ibm_init()
10841 pr_err("unable to create proc entry %s\n", ibm->name); in ibm_init()
10842 ret = -ENODEV; in ibm_init()
10845 ibm->flags.proc_created = 1; in ibm_init()
10848 list_add_tail(&ibm->all_drivers, &tpacpi_all_drivers); in ibm_init()
10855 ibm->name, ret); in ibm_init()
10878 * Ancient 570/600 and -SL lacks (#.##c) in tpacpi_parse_fw_id()
10904 * ---------------------------------------------------- in find_new_ec_fwstr()
10917 if (dm->type != 140 || dm->length < 0x0F || in find_new_ec_fwstr()
10927 /* returns 0 - probe ok, or < 0 - probe error.
10929 * On error, kfree() cleanup on tp->* is not performed, caller must do it */
10939 return -EINVAL; in get_thinkpad_model_data()
10944 tp->vendor = PCI_VENDOR_ID_IBM; in get_thinkpad_model_data()
10946 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
10951 tp->bios_version_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
10952 if (s && !tp->bios_version_str) in get_thinkpad_model_data()
10953 return -ENOMEM; in get_thinkpad_model_data()
10956 t = tpacpi_parse_fw_id(tp->bios_version_str, in get_thinkpad_model_data()
10957 &tp->bios_model, &tp->bios_release); in get_thinkpad_model_data()
10964 * up-to-date BIOS or they will not be detected. in get_thinkpad_model_data()
10969 if (sscanf(dev->name, in get_thinkpad_model_data()
10970 "IBM ThinkPad Embedded Controller -[%17c", in get_thinkpad_model_data()
10972 ec_fw_string[sizeof(ec_fw_string) - 1] = 0; in get_thinkpad_model_data()
10983 tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); in get_thinkpad_model_data()
10984 if (!tp->ec_version_str) in get_thinkpad_model_data()
10985 return -ENOMEM; in get_thinkpad_model_data()
10988 &tp->ec_model, &tp->ec_release); in get_thinkpad_model_data()
10998 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
10999 if (!tp->model_str) in get_thinkpad_model_data()
11000 return -ENOMEM; in get_thinkpad_model_data()
11004 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11005 if (!tp->model_str) in get_thinkpad_model_data()
11006 return -ENOMEM; in get_thinkpad_model_data()
11011 tp->nummodel_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11012 if (s && !tp->nummodel_str) in get_thinkpad_model_data()
11013 return -ENOMEM; in get_thinkpad_model_data()
11023 return -ENODEV; in probe_for_thinkpad()
11027 return -ENODEV; in probe_for_thinkpad()
11030 * Non-ancient models have better DMI tagging, but very old models in probe_for_thinkpad()
11042 return -ENODEV; in probe_for_thinkpad()
11046 return -ENODEV; in probe_for_thinkpad()
11175 if (!kp || !kp->name || !val) in set_ibm_param()
11176 return -EINVAL; in set_ibm_param()
11182 if (!ibm || !ibm->name) in set_ibm_param()
11185 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { in set_ibm_param()
11186 if (strlen(val) > sizeof(ibms_init[i].param) - 1) in set_ibm_param()
11187 return -ENOSPC; in set_ibm_param()
11193 return -EINVAL; in set_ibm_param()
11198 "Enables experimental features when non-zero");
11201 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
11205 "Attempts to load the driver even on a mis-identified ThinkPad when true");
11248 …MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command at module load, see documentatio…
11347 /* Driver-level probe */ in thinkpad_acpi_module_init()
11372 return -ENOMEM; in thinkpad_acpi_module_init()
11379 return -ENODEV; in thinkpad_acpi_module_init()
11413 tpacpi_pdev = platform_device_register_simple(TPACPI_DRVR_NAME, -1, in thinkpad_acpi_module_init()
11424 -1, NULL, 0); in thinkpad_acpi_module_init()
11434 &tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, NULL); in thinkpad_acpi_module_init()
11447 return -ENOMEM; in thinkpad_acpi_module_init()
11450 tpacpi_inputdev->name = "ThinkPad Extra Buttons"; in thinkpad_acpi_module_init()
11451 tpacpi_inputdev->phys = TPACPI_DRVR_NAME "/input0"; in thinkpad_acpi_module_init()
11452 tpacpi_inputdev->id.bustype = BUS_HOST; in thinkpad_acpi_module_init()
11453 tpacpi_inputdev->id.vendor = thinkpad_id.vendor; in thinkpad_acpi_module_init()
11454 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT; in thinkpad_acpi_module_init()
11455 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION; in thinkpad_acpi_module_init()
11456 tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev; in thinkpad_acpi_module_init()
11466 ret = ibms_init[i].data->write(ibms_init[i].param); in thinkpad_acpi_module_init()