Lines Matching +full:1 +full:- +full:based

1 // SPDX-License-Identifier: GPL-2.0-only
9 * Based on documentation in the libsmbios package:
10 * Copyright (C) 2005-2014 Dell Inc.
31 #include "dell-rbtn.h"
32 #include "dell-smbios.h"
34 #include "dell-wmi-privacy.h"
45 * The list must end with -1
58 quirks = dmi->driver_data; in dmi_matched()
59 return 1; in dmi_matched()
68 .kbd_timeouts = { 0, 5, 15, 60, 5 * 60, 15 * 60, -1 },
89 .name = "dell-laptop",
359 buffer->input[0] = arg0; in dell_fill_request()
360 buffer->input[1] = arg1; in dell_fill_request()
361 buffer->input[2] = arg2; in dell_fill_request()
362 buffer->input[3] = arg3; in dell_fill_request()
370 buffer->cmd_class = class; in dell_send_request()
371 buffer->cmd_select = select; in dell_send_request()
375 return dell_smbios_error(buffer->output[0]); in dell_send_request()
379 * Derived from information in smbios-wireless-ctl:
386 * cbRes1 Standard return codes (0, -1, -2)
389 * 0 Hardware switch supported (1)
390 * 1 WiFi locator supported (1)
391 * 2 WLAN supported (1)
392 * 3 Bluetooth (BT) supported (1)
393 * 4 WWAN supported (1)
394 * 5 Wireless KBD supported (1)
395 * 6 Uw b supported (1)
396 * 7 WiGig supported (1)
397 * 8 WLAN installed (1)
398 * 9 BT installed (1)
399 * 10 WWAN installed (1)
400 * 11 Uw b installed (1)
401 * 12 WiGig installed (1)
402 * 13-15 Reserved (0)
403 * 16 Hardware (HW) switch is On (1)
404 * 17 WLAN disabled (1)
405 * 18 BT disabled (1)
406 * 19 WWAN disabled (1)
407 * 20 Uw b disabled (1)
408 * 21 WiGig disabled (1)
409 * 20-31 Reserved (0)
420 * 1 WLAN ID
426 * 0 QuickSet disables radio (1)
427 * 1-7 Reserved (0)
429 * cbRes1 Standard return codes (0, -1, -2)
432 * 1 QS disables BT
436 * 5-31 Reserved (0)
444 * 1 Set config
447 * Switch settings (if byte 1==1):
448 * 0 WLAN sw itch control (1)
449 * 1 BT sw itch control (1)
450 * 2 WWAN sw itch control (1)
451 * 3 UWB sw itch control (1)
452 * 4 WiGig sw itch control (1)
453 * 5-7 Reserved (0)
454 * cbArg1, byte2 Enable bits (if byte 1==2):
455 * 0 Enable WiFi locator (1)
457 * cbRes1 Standard return codes (0, -1, -2)
459 * 0 WLAN controlled by sw itch (1)
460 * 1 BT controlled by sw itch (1)
461 * 2 WWAN controlled by sw itch (1)
462 * 3 UWB controlled by sw itch (1)
463 * 4 WiGig controlled by sw itch (1)
464 * 5-6 Reserved (0)
465 * 7 Wireless sw itch config locked (1)
466 * 8 WiFi locator enabled (1)
467 * 9-14 Reserved (0)
468 * 15 WiFi locator setting locked (1)
469 * 16-31 Reserved (0)
475 * cbRes1 Standard return codes (0, -1, -2)
487 * cbRes1 Standard return codes (0, -1, -2)
491 * cbRes1 Standard return codes (0, -1, -2)
495 * cbRes1 Standard return codes (0, -1, -2)
500 int disable = blocked ? 1 : 0; in dell_rfkill_set()
502 int hwswitch_bit = (unsigned long)data - 1; in dell_rfkill_set()
512 status = buffer.output[1]; in dell_rfkill_set()
518 hwswitch = buffer.output[1]; in dell_rfkill_set()
524 disable = 1; in dell_rfkill_set()
526 dell_fill_request(&buffer, 1 | (radio<<8) | (disable << 16), 0, 0, 0); in dell_rfkill_set()
535 /* Has hw-switch, sync sw_state to BIOS */ in dell_rfkill_update_sw_state()
539 1 | (radio << 8) | (block << 16), 0, 0, 0); in dell_rfkill_update_sw_state()
542 /* No hw-switch, sync BIOS state to sw_state */ in dell_rfkill_update_sw_state()
550 if (hwswitch & (BIT(radio - 1))) in dell_rfkill_update_hw_state()
564 status = buffer.output[1]; in dell_rfkill_query()
572 hwswitch = buffer.output[1]; in dell_rfkill_query()
599 status = buffer.output[1]; in dell_debugfs_show()
605 hwswitch_state = buffer.output[1]; in dell_debugfs_show()
611 seq_printf(s, "Bit 1 : Wifi locator supported: %lu\n", in dell_debugfs_show()
612 (status & BIT(1)) >> 1); in dell_debugfs_show()
653 seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n", in dell_debugfs_show()
654 (hwswitch_state & BIT(1)) >> 1); in dell_debugfs_show()
681 status = buffer.output[1]; in dell_update_rfkill()
690 hwswitch = buffer.output[1]; in dell_update_rfkill()
693 dell_rfkill_update_hw_state(wifi_rfkill, 1, status, hwswitch); in dell_update_rfkill()
694 dell_rfkill_update_sw_state(wifi_rfkill, 1, status); in dell_update_rfkill()
760 whitelisted = 1; in dell_setup_rfkill()
766 status = buffer.output[1]; in dell_setup_rfkill()
776 if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { in dell_setup_rfkill()
777 wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, in dell_setup_rfkill()
779 &dell_rfkill_ops, (void *) 1); in dell_setup_rfkill()
781 ret = -ENOMEM; in dell_setup_rfkill()
789 if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) { in dell_setup_rfkill()
790 bluetooth_rfkill = rfkill_alloc("dell-bluetooth", in dell_setup_rfkill()
791 &platform_device->dev, in dell_setup_rfkill()
795 ret = -ENOMEM; in dell_setup_rfkill()
803 if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) { in dell_setup_rfkill()
804 wwan_rfkill = rfkill_alloc("dell-wwan", in dell_setup_rfkill()
805 &platform_device->dev, in dell_setup_rfkill()
809 ret = -ENOMEM; in dell_setup_rfkill()
818 * Dell Airplane Mode Switch driver (dell-rbtn) supports ACPI devices in dell_setup_rfkill()
832 * dell-rbtn driver will automatically remove its own rfkill devices in dell_setup_rfkill()
857 pr_info("Symbols from dell-rbtn acpi driver are not available\n"); in dell_setup_rfkill()
858 ret = -ENODEV; in dell_setup_rfkill()
862 pr_info("Using dell-rbtn acpi driver for receiving events\n"); in dell_setup_rfkill()
863 } else if (ret != -ENODEV) { in dell_setup_rfkill()
925 return -ENODEV; in dell_send_intensity()
928 token->location, bd->props.brightness, 0, 0); in dell_send_intensity()
947 return -ENODEV; in dell_get_intensity()
949 dell_fill_request(&buffer, token->location, 0, 0, 0); in dell_get_intensity()
958 ret = buffer.output[1]; in dell_get_intensity()
971 char data = 1; in touchpad_led_on()
972 i8042_command(&data, command | 1 << 12); in touchpad_led_on()
979 i8042_command(&data, command | 1 << 12); in touchpad_led_off()
992 .name = "dell-laptop::touchpad",
1008 * Derived from information in smbios-keyboard-ctl:
1016 * cbRES1 Standard return codes (0, -1, -2)
1017 * cbRES2, word0 Bitmap of user-selectable modes
1019 * bit 1 Always on (Travis ATG, Siberia)
1020 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1021 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1022 * bit 4 Auto: Input-activity-based On; input-activity based Off
1023 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1024 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1025 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1026 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1027 * bits 9-15 Reserved for future use
1031 * 1 Tasklight
1033 * 3-255 Reserved for future use
1036 * bit 1 Touchpad activity
1039 * bits 4-7 Reserved for future use
1042 * bit 1 Minutes
1045 * bits 4-7 Reserved for future use
1053 * cbRES1 Standard return codes (0, -1, -2)
1056 * bit 1 Always on (Travis ATG, Siberia)
1057 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1058 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1059 * bit 4 Auto: Input-activity-based On; input-activity based Off
1060 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1061 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1062 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1063 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1064 * bits 9-15 Reserved for future use
1068 * bit 1 Touchpad activity
1071 * bits 4-7 Reserved for future use
1078 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1090 * Bits 5:0 Timeout value (0-63) in sec/min/hr/day
1095 * cbRES1 Standard return codes (0, -1, -2)
1098 * bit 1 Always on (Travis ATG, Siberia)
1099 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1100 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1101 * bit 4 Auto: Input-activity-based On; input-activity based Off
1102 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1103 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1104 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1105 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1106 * bits 9-15 Reserved for future use
1111 * bit 1 Touchpad activity
1114 * bits 4-7 Reserved for future use
1121 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1130 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1234 info->modes = buffer.output[1] & 0xFFFF; in kbd_get_info()
1235 info->type = (buffer.output[1] >> 24) & 0xFF; in kbd_get_info()
1236 info->triggers = buffer.output[2] & 0xFF; in kbd_get_info()
1238 info->levels = (buffer.output[2] >> 16) & 0xFF; in kbd_get_info()
1240 if (quirks && quirks->kbd_led_levels_off_1 && info->levels) in kbd_get_info()
1241 info->levels--; in kbd_get_info()
1244 info->seconds = (buffer.output[3] >> 0) & 0xFF; in kbd_get_info()
1245 if (units & BIT(1)) in kbd_get_info()
1246 info->minutes = (buffer.output[3] >> 8) & 0xFF; in kbd_get_info()
1248 info->hours = (buffer.output[3] >> 16) & 0xFF; in kbd_get_info()
1250 info->days = (buffer.output[3] >> 24) & 0xFF; in kbd_get_info()
1260 return kbd_mode_levels_count - 1; in kbd_get_max_level()
1269 return state->level; in kbd_get_level()
1273 if (kbd_mode_levels[i] == state->mode_bit) in kbd_get_level()
1278 return -EINVAL; in kbd_get_level()
1286 if (state->level == level) in kbd_set_level()
1288 state->level = level; in kbd_set_level()
1289 if (level != 0 && state->mode_bit == KBD_MODE_BIT_OFF) in kbd_set_level()
1290 state->mode_bit = kbd_previous_mode_bit; in kbd_set_level()
1291 else if (level == 0 && state->mode_bit != KBD_MODE_BIT_OFF) { in kbd_set_level()
1292 kbd_previous_mode_bit = state->mode_bit; in kbd_set_level()
1293 state->mode_bit = KBD_MODE_BIT_OFF; in kbd_set_level()
1301 state->mode_bit = kbd_mode_levels[level]; in kbd_set_level()
1305 return -EINVAL; in kbd_set_level()
1319 state->mode_bit = ffs(buffer.output[1] & 0xFFFF); in kbd_get_state()
1320 if (state->mode_bit != 0) in kbd_get_state()
1321 state->mode_bit--; in kbd_get_state()
1323 state->triggers = (buffer.output[1] >> 16) & 0xFF; in kbd_get_state()
1324 state->timeout_value = (buffer.output[1] >> 24) & 0x3F; in kbd_get_state()
1325 state->timeout_unit = (buffer.output[1] >> 30) & 0x3; in kbd_get_state()
1326 state->als_setting = buffer.output[2] & 0xFF; in kbd_get_state()
1327 state->als_value = (buffer.output[2] >> 8) & 0xFF; in kbd_get_state()
1328 state->level = (buffer.output[2] >> 16) & 0xFF; in kbd_get_state()
1329 state->timeout_value_ac = (buffer.output[2] >> 24) & 0x3F; in kbd_get_state()
1330 state->timeout_unit_ac = (buffer.output[2] >> 30) & 0x3; in kbd_get_state()
1342 input1 = BIT(state->mode_bit) & 0xFFFF; in kbd_set_state()
1343 input1 |= (state->triggers & 0xFF) << 16; in kbd_set_state()
1344 input1 |= (state->timeout_value & 0x3F) << 24; in kbd_set_state()
1345 input1 |= (state->timeout_unit & 0x3) << 30; in kbd_set_state()
1346 input2 = state->als_setting & 0xFF; in kbd_set_state()
1347 input2 |= (state->level & 0xFF) << 16; in kbd_set_state()
1348 input2 |= (state->timeout_value_ac & 0x3F) << 24; in kbd_set_state()
1349 input2 |= (state->timeout_unit_ac & 0x3) << 30; in kbd_set_state()
1384 return -EINVAL; in kbd_set_token_bit()
1388 return -EINVAL; in kbd_set_token_bit()
1390 dell_fill_request(&buffer, token->location, token->value, 0, 0); in kbd_set_token_bit()
1404 return -EINVAL; in kbd_get_token_bit()
1408 return -EINVAL; in kbd_get_token_bit()
1410 dell_fill_request(&buffer, token->location, 0, 0, 0); in kbd_get_token_bit()
1412 val = buffer.output[1]; in kbd_get_token_bit()
1417 return (val == token->value); in kbd_get_token_bit()
1427 if (ret == 1) in kbd_get_first_active_token_bit()
1453 if ((quirks && quirks->kbd_missing_ac_tag) || in kbd_init_info()
1478 kbd_previous_level = 1; in kbd_init_info()
1484 kbd_previous_mode_bit--; in kbd_init_info()
1501 kbd_mode_levels[1 + kbd_mode_levels_count++] = i; in kbd_init_info()
1535 if (quirks && quirks->kbd_led_not_present) in kbd_init()
1563 if (ret < 1) in kbd_led_timeout_store()
1564 return -EINVAL; in kbd_led_timeout_store()
1565 else if (ret == 1) in kbd_led_timeout_store()
1569 return -EINVAL; in kbd_led_timeout_store()
1595 return -EINVAL; in kbd_led_timeout_store()
1598 if (quirks && quirks->needs_kbd_timeouts) in kbd_led_timeout_store()
1615 if (quirks && quirks->needs_kbd_timeouts) { in kbd_led_timeout_store()
1616 for (i = 0; quirks->kbd_timeouts[i] != -1; i++) { in kbd_led_timeout_store()
1617 if (value <= quirks->kbd_timeouts[i]) { in kbd_led_timeout_store()
1618 value = quirks->kbd_timeouts[i]; in kbd_led_timeout_store()
1636 return -EINVAL; in kbd_led_timeout_store()
1699 return -EINVAL; in kbd_led_timeout_show()
1722 int trigger_bit = -1; in kbd_led_triggers_store()
1727 if (ret != 1) in kbd_led_triggers_store()
1728 return -EINVAL; in kbd_led_triggers_store()
1730 if (trigger[0] != '+' && trigger[0] != '-') in kbd_led_triggers_store()
1731 return -EINVAL; in kbd_led_triggers_store()
1748 if (strcmp(trigger+1, kbd_led_triggers[i]) != 0) in kbd_led_triggers_store()
1755 if (trigger[0] == '-' && in kbd_led_triggers_store()
1765 if (trigger_bit == -1) { in kbd_led_triggers_store()
1766 ret = -EINVAL; in kbd_led_triggers_store()
1777 * disabling touchpad bit (1), otherwise touchpad in kbd_led_triggers_store()
1778 * bit (1) will not be disabled in kbd_led_triggers_store()
1780 if (trigger_bit == 1) in kbd_led_triggers_store()
1785 ret = -EINVAL; in kbd_led_triggers_store()
1795 ret = -EINVAL; in kbd_led_triggers_store()
1835 buf[len++] = '-'; in kbd_led_triggers_show()
1841 buf[len - 1] = '\n'; in kbd_led_triggers_show()
1893 ret = -EINVAL; in kbd_led_als_enabled_store()
1921 return sprintf(buf, "%d\n", enabled ? 1 : 0); in kbd_led_als_enabled_show()
2022 for (num = kbd_token_bits; num != 0 && ret > 0; --ret) in kbd_led_level_get()
2023 num &= num - 1; /* clear the first bit set */ in kbd_led_level_get()
2026 return ffs(num) - 1; in kbd_led_level_get()
2054 for (num = kbd_token_bits; num != 0 && value > 0; --value) in kbd_led_level_set()
2055 num &= num - 1; /* clear the first bit set */ in kbd_led_level_set()
2059 ret = kbd_set_token_bit(ffs(num) - 1); in kbd_led_level_set()
2062 ret = -ENXIO; in kbd_led_level_set()
2087 return -ENODEV; in kbd_led_init()
2089 kbd_led_groups[1] = NULL; in kbd_led_init()
2094 kbd_led.max_brightness--; in kbd_led_init()
2165 return -ENODEV; in micmute_led_set()
2167 dell_fill_request(&buffer, token->location, token->value, 0, 0); in micmute_led_set()
2175 .max_brightness = 1,
2177 .default_trigger = "audio-micmute",
2187 return -ENODEV; in dell_init()
2196 platform_device = platform_device_alloc("dell-laptop", PLATFORM_DEVID_NONE); in dell_init()
2198 ret = -ENOMEM; in dell_init()
2212 if (quirks && quirks->touchpad_led) in dell_init()
2213 touchpad_led_init(&platform_device->dev); in dell_init()
2215 kbd_led_init(&platform_device->dev); in dell_init()
2227 ret = led_classdev_register(&platform_device->dev, &micmute_led_cdev); in dell_init()
2240 dell_fill_request(&buffer, token->location, 0, 0, 0); in dell_init()
2253 &platform_device->dev, in dell_init()
2264 dell_backlight_device->props.brightness = in dell_init()
2266 if (dell_backlight_device->props.brightness < 0) { in dell_init()
2267 ret = dell_backlight_device->props.brightness; in dell_init()
2296 if (quirks && quirks->touchpad_led) in dell_exit()
2309 /* dell-rbtn.c driver export functions which will not work correctly (and could
2310 * cause kernel crash) if they are called before dell-rbtn.c init code. This is
2311 * not problem when dell-rbtn.c is compiled as external module. When both files
2312 * (dell-rbtn.c and dell-laptop.c) are compiled statically into kernel, then we
2313 * need to ensure that dell_init() will be called after initializing dell-rbtn.