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.
33 #include "dell-rbtn.h"
34 #include "dell-smbios.h"
36 #include "dell-wmi-privacy.h"
47 * The list must end with -1
60 quirks = dmi->driver_data; in dmi_matched()
61 return 1; in dmi_matched()
70 .kbd_timeouts = { 0, 5, 15, 60, 5 * 60, 15 * 60, -1 },
91 .name = "dell-laptop",
372 /* -1 is a sentinel value, telling us to use token->value */
373 #define USE_TVAL ((u32) -1)
382 return -ENODEV; in dell_send_request_for_tokenid()
385 val = token->value; in dell_send_request_for_tokenid()
387 dell_fill_request(buffer, token->location, val, 0, 0); in dell_send_request_for_tokenid()
399 * Derived from information in smbios-wireless-ctl:
406 * cbRes1 Standard return codes (0, -1, -2)
409 * 0 Hardware switch supported (1)
410 * 1 WiFi locator supported (1)
411 * 2 WLAN supported (1)
412 * 3 Bluetooth (BT) supported (1)
413 * 4 WWAN supported (1)
414 * 5 Wireless KBD supported (1)
415 * 6 Uw b supported (1)
416 * 7 WiGig supported (1)
417 * 8 WLAN installed (1)
418 * 9 BT installed (1)
419 * 10 WWAN installed (1)
420 * 11 Uw b installed (1)
421 * 12 WiGig installed (1)
422 * 13-15 Reserved (0)
423 * 16 Hardware (HW) switch is On (1)
424 * 17 WLAN disabled (1)
425 * 18 BT disabled (1)
426 * 19 WWAN disabled (1)
427 * 20 Uw b disabled (1)
428 * 21 WiGig disabled (1)
429 * 20-31 Reserved (0)
440 * 1 WLAN ID
446 * 0 QuickSet disables radio (1)
447 * 1-7 Reserved (0)
449 * cbRes1 Standard return codes (0, -1, -2)
452 * 1 QS disables BT
456 * 5-31 Reserved (0)
464 * 1 Set config
467 * Switch settings (if byte 1==1):
468 * 0 WLAN sw itch control (1)
469 * 1 BT sw itch control (1)
470 * 2 WWAN sw itch control (1)
471 * 3 UWB sw itch control (1)
472 * 4 WiGig sw itch control (1)
473 * 5-7 Reserved (0)
474 * cbArg1, byte2 Enable bits (if byte 1==2):
475 * 0 Enable WiFi locator (1)
477 * cbRes1 Standard return codes (0, -1, -2)
479 * 0 WLAN controlled by sw itch (1)
480 * 1 BT controlled by sw itch (1)
481 * 2 WWAN controlled by sw itch (1)
482 * 3 UWB controlled by sw itch (1)
483 * 4 WiGig controlled by sw itch (1)
484 * 5-6 Reserved (0)
485 * 7 Wireless sw itch config locked (1)
486 * 8 WiFi locator enabled (1)
487 * 9-14 Reserved (0)
488 * 15 WiFi locator setting locked (1)
489 * 16-31 Reserved (0)
495 * cbRes1 Standard return codes (0, -1, -2)
507 * cbRes1 Standard return codes (0, -1, -2)
511 * cbRes1 Standard return codes (0, -1, -2)
515 * cbRes1 Standard return codes (0, -1, -2)
520 int disable = blocked ? 1 : 0; in dell_rfkill_set()
522 int hwswitch_bit = (unsigned long)data - 1; in dell_rfkill_set()
532 status = buffer.output[1]; in dell_rfkill_set()
538 hwswitch = buffer.output[1]; in dell_rfkill_set()
544 disable = 1; in dell_rfkill_set()
546 dell_fill_request(&buffer, 1 | (radio<<8) | (disable << 16), 0, 0, 0); in dell_rfkill_set()
555 /* Has hw-switch, sync sw_state to BIOS */ in dell_rfkill_update_sw_state()
559 1 | (radio << 8) | (block << 16), 0, 0, 0); in dell_rfkill_update_sw_state()
562 /* No hw-switch, sync BIOS state to sw_state */ in dell_rfkill_update_sw_state()
570 if (hwswitch & (BIT(radio - 1))) in dell_rfkill_update_hw_state()
584 status = buffer.output[1]; in dell_rfkill_query()
592 hwswitch = buffer.output[1]; in dell_rfkill_query()
619 status = buffer.output[1]; in dell_debugfs_show()
625 hwswitch_state = buffer.output[1]; in dell_debugfs_show()
631 seq_printf(s, "Bit 1 : Wifi locator supported: %lu\n", in dell_debugfs_show()
632 (status & BIT(1)) >> 1); in dell_debugfs_show()
673 seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n", in dell_debugfs_show()
674 (hwswitch_state & BIT(1)) >> 1); in dell_debugfs_show()
701 status = buffer.output[1]; in dell_update_rfkill()
710 hwswitch = buffer.output[1]; in dell_update_rfkill()
713 dell_rfkill_update_hw_state(wifi_rfkill, 1, status, hwswitch); in dell_update_rfkill()
714 dell_rfkill_update_sw_state(wifi_rfkill, 1, status); in dell_update_rfkill()
780 whitelisted = 1; in dell_setup_rfkill()
786 status = buffer.output[1]; in dell_setup_rfkill()
796 if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { in dell_setup_rfkill()
797 wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, in dell_setup_rfkill()
799 &dell_rfkill_ops, (void *) 1); in dell_setup_rfkill()
801 ret = -ENOMEM; in dell_setup_rfkill()
809 if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) { in dell_setup_rfkill()
810 bluetooth_rfkill = rfkill_alloc("dell-bluetooth", in dell_setup_rfkill()
811 &platform_device->dev, in dell_setup_rfkill()
815 ret = -ENOMEM; in dell_setup_rfkill()
823 if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) { in dell_setup_rfkill()
824 wwan_rfkill = rfkill_alloc("dell-wwan", in dell_setup_rfkill()
825 &platform_device->dev, in dell_setup_rfkill()
829 ret = -ENOMEM; in dell_setup_rfkill()
838 * Dell Airplane Mode Switch driver (dell-rbtn) supports ACPI devices in dell_setup_rfkill()
852 * dell-rbtn driver will automatically remove its own rfkill devices in dell_setup_rfkill()
877 pr_info("Symbols from dell-rbtn acpi driver are not available\n"); in dell_setup_rfkill()
878 ret = -ENODEV; in dell_setup_rfkill()
882 pr_info("Using dell-rbtn acpi driver for receiving events\n"); in dell_setup_rfkill()
883 } else if (ret != -ENODEV) { in dell_setup_rfkill()
945 select, BRIGHTNESS_TOKEN, bd->props.brightness); in dell_send_intensity()
959 ret = buffer.output[1]; in dell_get_intensity()
972 char data = 1; in touchpad_led_on()
973 i8042_command(&data, command | 1 << 12); in touchpad_led_on()
980 i8042_command(&data, command | 1 << 12); in touchpad_led_off()
993 .name = "dell-laptop::touchpad",
1009 * Derived from information in smbios-keyboard-ctl:
1017 * cbRES1 Standard return codes (0, -1, -2)
1018 * cbRES2, word0 Bitmap of user-selectable modes
1020 * bit 1 Always on (Travis ATG, Siberia)
1021 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1022 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1023 * bit 4 Auto: Input-activity-based On; input-activity based Off
1024 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1025 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1026 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1027 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1028 * bits 9-15 Reserved for future use
1032 * 1 Tasklight
1034 * 3-255 Reserved for future use
1037 * bit 1 Touchpad activity
1040 * bits 4-7 Reserved for future use
1043 * bit 1 Minutes
1046 * bits 4-7 Reserved for future use
1054 * cbRES1 Standard return codes (0, -1, -2)
1057 * bit 1 Always on (Travis ATG, Siberia)
1058 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1059 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1060 * bit 4 Auto: Input-activity-based On; input-activity based Off
1061 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1062 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1063 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1064 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1065 * bits 9-15 Reserved for future use
1069 * bit 1 Touchpad activity
1072 * bits 4-7 Reserved for future use
1079 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1091 * Bits 5:0 Timeout value (0-63) in sec/min/hr/day
1096 * cbRES1 Standard return codes (0, -1, -2)
1099 * bit 1 Always on (Travis ATG, Siberia)
1100 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1101 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1102 * bit 4 Auto: Input-activity-based On; input-activity based Off
1103 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1104 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1105 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1106 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1107 * bits 9-15 Reserved for future use
1112 * bit 1 Touchpad activity
1115 * bits 4-7 Reserved for future use
1122 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1131 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1235 info->modes = buffer.output[1] & 0xFFFF; in kbd_get_info()
1236 info->type = (buffer.output[1] >> 24) & 0xFF; in kbd_get_info()
1237 info->triggers = buffer.output[2] & 0xFF; in kbd_get_info()
1239 info->levels = (buffer.output[2] >> 16) & 0xFF; in kbd_get_info()
1241 if (quirks && quirks->kbd_led_levels_off_1 && info->levels) in kbd_get_info()
1242 info->levels--; in kbd_get_info()
1245 info->seconds = (buffer.output[3] >> 0) & 0xFF; in kbd_get_info()
1246 if (units & BIT(1)) in kbd_get_info()
1247 info->minutes = (buffer.output[3] >> 8) & 0xFF; in kbd_get_info()
1249 info->hours = (buffer.output[3] >> 16) & 0xFF; in kbd_get_info()
1251 info->days = (buffer.output[3] >> 24) & 0xFF; in kbd_get_info()
1261 return kbd_mode_levels_count - 1; in kbd_get_max_level()
1270 return state->level; in kbd_get_level()
1274 if (kbd_mode_levels[i] == state->mode_bit) in kbd_get_level()
1279 return -EINVAL; in kbd_get_level()
1287 if (state->level == level) in kbd_set_level()
1289 state->level = level; in kbd_set_level()
1290 if (level != 0 && state->mode_bit == KBD_MODE_BIT_OFF) in kbd_set_level()
1291 state->mode_bit = kbd_previous_mode_bit; in kbd_set_level()
1292 else if (level == 0 && state->mode_bit != KBD_MODE_BIT_OFF) { in kbd_set_level()
1293 kbd_previous_mode_bit = state->mode_bit; in kbd_set_level()
1294 state->mode_bit = KBD_MODE_BIT_OFF; in kbd_set_level()
1302 state->mode_bit = kbd_mode_levels[level]; in kbd_set_level()
1306 return -EINVAL; in kbd_set_level()
1320 state->mode_bit = ffs(buffer.output[1] & 0xFFFF); in kbd_get_state()
1321 if (state->mode_bit != 0) in kbd_get_state()
1322 state->mode_bit--; in kbd_get_state()
1324 state->triggers = (buffer.output[1] >> 16) & 0xFF; in kbd_get_state()
1325 state->timeout_value = (buffer.output[1] >> 24) & 0x3F; in kbd_get_state()
1326 state->timeout_unit = (buffer.output[1] >> 30) & 0x3; in kbd_get_state()
1327 state->als_setting = buffer.output[2] & 0xFF; in kbd_get_state()
1328 state->als_value = (buffer.output[2] >> 8) & 0xFF; in kbd_get_state()
1329 state->level = (buffer.output[2] >> 16) & 0xFF; in kbd_get_state()
1330 state->timeout_value_ac = (buffer.output[2] >> 24) & 0x3F; in kbd_get_state()
1331 state->timeout_unit_ac = (buffer.output[2] >> 30) & 0x3; in kbd_get_state()
1343 input1 = BIT(state->mode_bit) & 0xFFFF; in kbd_set_state()
1344 input1 |= (state->triggers & 0xFF) << 16; in kbd_set_state()
1345 input1 |= (state->timeout_value & 0x3F) << 24; in kbd_set_state()
1346 input1 |= (state->timeout_unit & 0x3) << 30; in kbd_set_state()
1347 input2 = state->als_setting & 0xFF; in kbd_set_state()
1348 input2 |= (state->level & 0xFF) << 16; in kbd_set_state()
1349 input2 |= (state->timeout_value_ac & 0x3F) << 24; in kbd_set_state()
1350 input2 |= (state->timeout_unit_ac & 0x3) << 30; in kbd_set_state()
1383 return -EINVAL; in kbd_set_token_bit()
1396 return -EINVAL; in kbd_get_token_bit()
1400 return -EINVAL; in kbd_get_token_bit()
1402 dell_fill_request(&buffer, token->location, 0, 0, 0); in kbd_get_token_bit()
1407 val = buffer.output[1]; in kbd_get_token_bit()
1408 return (val == token->value); in kbd_get_token_bit()
1418 if (ret == 1) in kbd_get_first_active_token_bit()
1444 if ((quirks && quirks->kbd_missing_ac_tag) || in kbd_init_info()
1469 kbd_previous_level = 1; in kbd_init_info()
1475 kbd_previous_mode_bit--; in kbd_init_info()
1492 kbd_mode_levels[1 + kbd_mode_levels_count++] = i; in kbd_init_info()
1526 if (quirks && quirks->kbd_led_not_present) in kbd_init()
1554 if (ret < 1) in kbd_led_timeout_store()
1555 return -EINVAL; in kbd_led_timeout_store()
1556 else if (ret == 1) in kbd_led_timeout_store()
1560 return -EINVAL; in kbd_led_timeout_store()
1586 return -EINVAL; in kbd_led_timeout_store()
1589 if (quirks && quirks->needs_kbd_timeouts) in kbd_led_timeout_store()
1606 if (quirks && quirks->needs_kbd_timeouts) { in kbd_led_timeout_store()
1607 for (i = 0; quirks->kbd_timeouts[i] != -1; i++) { in kbd_led_timeout_store()
1608 if (value <= quirks->kbd_timeouts[i]) { in kbd_led_timeout_store()
1609 value = quirks->kbd_timeouts[i]; in kbd_led_timeout_store()
1627 return -EINVAL; in kbd_led_timeout_store()
1690 return -EINVAL; in kbd_led_timeout_show()
1713 int trigger_bit = -1; in kbd_led_triggers_store()
1718 if (ret != 1) in kbd_led_triggers_store()
1719 return -EINVAL; in kbd_led_triggers_store()
1721 if (trigger[0] != '+' && trigger[0] != '-') in kbd_led_triggers_store()
1722 return -EINVAL; in kbd_led_triggers_store()
1739 if (strcmp(trigger+1, kbd_led_triggers[i]) != 0) in kbd_led_triggers_store()
1746 if (trigger[0] == '-' && in kbd_led_triggers_store()
1756 if (trigger_bit == -1) { in kbd_led_triggers_store()
1757 ret = -EINVAL; in kbd_led_triggers_store()
1768 * disabling touchpad bit (1), otherwise touchpad in kbd_led_triggers_store()
1769 * bit (1) will not be disabled in kbd_led_triggers_store()
1771 if (trigger_bit == 1) in kbd_led_triggers_store()
1776 ret = -EINVAL; in kbd_led_triggers_store()
1786 ret = -EINVAL; in kbd_led_triggers_store()
1826 buf[len++] = '-'; in kbd_led_triggers_show()
1832 buf[len - 1] = '\n'; in kbd_led_triggers_show()
1884 ret = -EINVAL; in kbd_led_als_enabled_store()
1912 return sprintf(buf, "%d\n", enabled ? 1 : 0); in kbd_led_als_enabled_show()
2013 for (num = kbd_token_bits; num != 0 && ret > 0; --ret) in kbd_led_level_get()
2014 num &= num - 1; /* clear the first bit set */ in kbd_led_level_get()
2017 return ffs(num) - 1; in kbd_led_level_get()
2045 for (num = kbd_token_bits; num != 0 && value > 0; --value) in kbd_led_level_set()
2046 num &= num - 1; /* clear the first bit set */ in kbd_led_level_set()
2050 ret = kbd_set_token_bit(ffs(num) - 1); in kbd_led_level_set()
2053 ret = -ENXIO; in kbd_led_level_set()
2078 return -ENODEV; in kbd_led_init()
2080 kbd_led_groups[1] = NULL; in kbd_led_init()
2085 kbd_led.max_brightness--; in kbd_led_init()
2156 .max_brightness = 1,
2158 .default_trigger = "audio-micmute",
2174 .max_brightness = 1,
2176 .default_trigger = "audio-mute",
2196 if (buffer.output[1] > INT_MAX) in dell_battery_read()
2197 return -EIO; in dell_battery_read()
2199 return buffer.output[1]; in dell_battery_read()
2214 return token->value == (u16) ret; in dell_battery_mode_is_active()
2238 if ((end - start) < CHARGE_MIN_DIFF) in dell_battery_set_custom_charge_start()
2239 start = end - CHARGE_MIN_DIFF; in dell_battery_set_custom_charge_start()
2254 if ((end - start) < CHARGE_MIN_DIFF) in dell_battery_set_custom_charge_end()
2280 count--; in charge_types_show()
2303 return -EINVAL; in charge_types_store()
2323 return -EIO; in charge_control_start_threshold_show()
2338 return -EINVAL; in charge_control_start_threshold_store()
2358 return -EIO; in charge_control_end_threshold_show()
2373 return -EINVAL; in charge_control_end_threshold_store()
2397 return strcmp(battery->desc->name, "BAT0") == 0; in dell_battery_supported()
2407 return device_add_groups(&battery->dev, dell_battery_groups); in dell_battery_add()
2416 device_remove_groups(&battery->dev, dell_battery_groups); in dell_battery_remove()
2460 return -ENODEV; in dell_init()
2469 platform_device = platform_device_alloc("dell-laptop", PLATFORM_DEVID_NONE); in dell_init()
2471 ret = -ENOMEM; in dell_init()
2485 if (quirks && quirks->touchpad_led) in dell_init()
2486 touchpad_led_init(&platform_device->dev); in dell_init()
2488 kbd_led_init(&platform_device->dev); in dell_init()
2489 dell_battery_init(&platform_device->dev); in dell_init()
2500 ret = led_classdev_register(&platform_device->dev, &micmute_led_cdev); in dell_init()
2508 ret = led_classdev_register(&platform_device->dev, &mute_led_cdev); in dell_init()
2528 &platform_device->dev, in dell_init()
2539 dell_backlight_device->props.brightness = in dell_init()
2541 if (dell_backlight_device->props.brightness < 0) { in dell_init()
2542 ret = dell_backlight_device->props.brightness; in dell_init()
2574 if (quirks && quirks->touchpad_led) in dell_exit()
2590 /* dell-rbtn.c driver export functions which will not work correctly (and could
2591 * cause kernel crash) if they are called before dell-rbtn.c init code. This is
2592 * not problem when dell-rbtn.c is compiled as external module. When both files
2593 * (dell-rbtn.c and dell-laptop.c) are compiled statically into kernel, then we
2594 * need to ensure that dell_init() will be called after initializing dell-rbtn.