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"
43 * The list must end with -1
56 quirks = dmi->driver_data; in dmi_matched()
57 return 1; in dmi_matched()
66 .kbd_timeouts = { 0, 5, 15, 60, 5 * 60, 15 * 60, -1 },
83 .name = "dell-laptop",
343 buffer->input[0] = arg0; in dell_fill_request()
344 buffer->input[1] = arg1; in dell_fill_request()
345 buffer->input[2] = arg2; in dell_fill_request()
346 buffer->input[3] = arg3; in dell_fill_request()
354 buffer->cmd_class = class; in dell_send_request()
355 buffer->cmd_select = select; in dell_send_request()
359 return dell_smbios_error(buffer->output[0]); in dell_send_request()
363 * Derived from information in smbios-wireless-ctl:
370 * cbRes1 Standard return codes (0, -1, -2)
373 * 0 Hardware switch supported (1)
374 * 1 WiFi locator supported (1)
375 * 2 WLAN supported (1)
376 * 3 Bluetooth (BT) supported (1)
377 * 4 WWAN supported (1)
378 * 5 Wireless KBD supported (1)
379 * 6 Uw b supported (1)
380 * 7 WiGig supported (1)
381 * 8 WLAN installed (1)
382 * 9 BT installed (1)
383 * 10 WWAN installed (1)
384 * 11 Uw b installed (1)
385 * 12 WiGig installed (1)
386 * 13-15 Reserved (0)
387 * 16 Hardware (HW) switch is On (1)
388 * 17 WLAN disabled (1)
389 * 18 BT disabled (1)
390 * 19 WWAN disabled (1)
391 * 20 Uw b disabled (1)
392 * 21 WiGig disabled (1)
393 * 20-31 Reserved (0)
404 * 1 WLAN ID
410 * 0 QuickSet disables radio (1)
411 * 1-7 Reserved (0)
413 * cbRes1 Standard return codes (0, -1, -2)
416 * 1 QS disables BT
420 * 5-31 Reserved (0)
428 * 1 Set config
431 * Switch settings (if byte 1==1):
432 * 0 WLAN sw itch control (1)
433 * 1 BT sw itch control (1)
434 * 2 WWAN sw itch control (1)
435 * 3 UWB sw itch control (1)
436 * 4 WiGig sw itch control (1)
437 * 5-7 Reserved (0)
438 * cbArg1, byte2 Enable bits (if byte 1==2):
439 * 0 Enable WiFi locator (1)
441 * cbRes1 Standard return codes (0, -1, -2)
443 * 0 WLAN controlled by sw itch (1)
444 * 1 BT controlled by sw itch (1)
445 * 2 WWAN controlled by sw itch (1)
446 * 3 UWB controlled by sw itch (1)
447 * 4 WiGig controlled by sw itch (1)
448 * 5-6 Reserved (0)
449 * 7 Wireless sw itch config locked (1)
450 * 8 WiFi locator enabled (1)
451 * 9-14 Reserved (0)
452 * 15 WiFi locator setting locked (1)
453 * 16-31 Reserved (0)
459 * cbRes1 Standard return codes (0, -1, -2)
471 * cbRes1 Standard return codes (0, -1, -2)
475 * cbRes1 Standard return codes (0, -1, -2)
479 * cbRes1 Standard return codes (0, -1, -2)
484 int disable = blocked ? 1 : 0; in dell_rfkill_set()
486 int hwswitch_bit = (unsigned long)data - 1; in dell_rfkill_set()
496 status = buffer.output[1]; in dell_rfkill_set()
502 hwswitch = buffer.output[1]; in dell_rfkill_set()
508 disable = 1; in dell_rfkill_set()
510 dell_fill_request(&buffer, 1 | (radio<<8) | (disable << 16), 0, 0, 0); in dell_rfkill_set()
519 /* Has hw-switch, sync sw_state to BIOS */ in dell_rfkill_update_sw_state()
523 1 | (radio << 8) | (block << 16), 0, 0, 0); in dell_rfkill_update_sw_state()
526 /* No hw-switch, sync BIOS state to sw_state */ in dell_rfkill_update_sw_state()
534 if (hwswitch & (BIT(radio - 1))) in dell_rfkill_update_hw_state()
548 status = buffer.output[1]; in dell_rfkill_query()
556 hwswitch = buffer.output[1]; in dell_rfkill_query()
583 status = buffer.output[1]; in dell_debugfs_show()
589 hwswitch_state = buffer.output[1]; in dell_debugfs_show()
595 seq_printf(s, "Bit 1 : Wifi locator supported: %lu\n", in dell_debugfs_show()
596 (status & BIT(1)) >> 1); in dell_debugfs_show()
637 seq_printf(s, "Bit 1 : Bluetooth controlled by switch: %lu\n", in dell_debugfs_show()
638 (hwswitch_state & BIT(1)) >> 1); in dell_debugfs_show()
665 status = buffer.output[1]; in dell_update_rfkill()
674 hwswitch = buffer.output[1]; in dell_update_rfkill()
677 dell_rfkill_update_hw_state(wifi_rfkill, 1, status, hwswitch); in dell_update_rfkill()
678 dell_rfkill_update_sw_state(wifi_rfkill, 1, status); in dell_update_rfkill()
744 whitelisted = 1; in dell_setup_rfkill()
750 status = buffer.output[1]; in dell_setup_rfkill()
760 if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { in dell_setup_rfkill()
761 wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, in dell_setup_rfkill()
763 &dell_rfkill_ops, (void *) 1); in dell_setup_rfkill()
765 ret = -ENOMEM; in dell_setup_rfkill()
773 if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) { in dell_setup_rfkill()
774 bluetooth_rfkill = rfkill_alloc("dell-bluetooth", in dell_setup_rfkill()
775 &platform_device->dev, in dell_setup_rfkill()
779 ret = -ENOMEM; in dell_setup_rfkill()
787 if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) { in dell_setup_rfkill()
788 wwan_rfkill = rfkill_alloc("dell-wwan", in dell_setup_rfkill()
789 &platform_device->dev, in dell_setup_rfkill()
793 ret = -ENOMEM; in dell_setup_rfkill()
802 * Dell Airplane Mode Switch driver (dell-rbtn) supports ACPI devices in dell_setup_rfkill()
816 * dell-rbtn driver will automatically remove its own rfkill devices in dell_setup_rfkill()
841 pr_info("Symbols from dell-rbtn acpi driver are not available\n"); in dell_setup_rfkill()
842 ret = -ENODEV; in dell_setup_rfkill()
846 pr_info("Using dell-rbtn acpi driver for receiving events\n"); in dell_setup_rfkill()
847 } else if (ret != -ENODEV) { in dell_setup_rfkill()
909 return -ENODEV; in dell_send_intensity()
912 token->location, bd->props.brightness, 0, 0); in dell_send_intensity()
931 return -ENODEV; in dell_get_intensity()
933 dell_fill_request(&buffer, token->location, 0, 0, 0); in dell_get_intensity()
942 ret = buffer.output[1]; in dell_get_intensity()
955 char data = 1; in touchpad_led_on()
956 i8042_command(&data, command | 1 << 12); in touchpad_led_on()
963 i8042_command(&data, command | 1 << 12); in touchpad_led_off()
976 .name = "dell-laptop::touchpad",
992 * Derived from information in smbios-keyboard-ctl:
1000 * cbRES1 Standard return codes (0, -1, -2)
1001 * cbRES2, word0 Bitmap of user-selectable modes
1003 * bit 1 Always on (Travis ATG, Siberia)
1004 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1005 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1006 * bit 4 Auto: Input-activity-based On; input-activity based Off
1007 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1008 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1009 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1010 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1011 * bits 9-15 Reserved for future use
1015 * 1 Tasklight
1017 * 3-255 Reserved for future use
1020 * bit 1 Touchpad activity
1023 * bits 4-7 Reserved for future use
1026 * bit 1 Minutes
1029 * bits 4-7 Reserved for future use
1037 * cbRES1 Standard return codes (0, -1, -2)
1040 * bit 1 Always on (Travis ATG, Siberia)
1041 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1042 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1043 * bit 4 Auto: Input-activity-based On; input-activity based Off
1044 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1045 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1046 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1047 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1048 * bits 9-15 Reserved for future use
1052 * bit 1 Touchpad activity
1055 * bits 4-7 Reserved for future use
1062 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1074 * Bits 5:0 Timeout value (0-63) in sec/min/hr/day
1079 * cbRES1 Standard return codes (0, -1, -2)
1082 * bit 1 Always on (Travis ATG, Siberia)
1083 * bit 2 Auto: ALS-based On; ALS-based Off (Travis ATG)
1084 * bit 3 Auto: ALS- and input-activity-based On; input-activity based Off
1085 * bit 4 Auto: Input-activity-based On; input-activity based Off
1086 * bit 5 Auto: Input-activity-based On (illumination level 25%); input-activity based Off
1087 * bit 6 Auto: Input-activity-based On (illumination level 50%); input-activity based Off
1088 * bit 7 Auto: Input-activity-based On (illumination level 75%); input-activity based Off
1089 * bit 8 Auto: Input-activity-based On (illumination level 100%); input-activity based Off
1090 * bits 9-15 Reserved for future use
1095 * bit 1 Touchpad activity
1098 * bits 4-7 Reserved for future use
1105 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1114 * bits 5:0 Timeout value (0-63) in sec/min/hr/day
1218 info->modes = buffer.output[1] & 0xFFFF; in kbd_get_info()
1219 info->type = (buffer.output[1] >> 24) & 0xFF; in kbd_get_info()
1220 info->triggers = buffer.output[2] & 0xFF; in kbd_get_info()
1222 info->levels = (buffer.output[2] >> 16) & 0xFF; in kbd_get_info()
1224 if (quirks && quirks->kbd_led_levels_off_1 && info->levels) in kbd_get_info()
1225 info->levels--; in kbd_get_info()
1228 info->seconds = (buffer.output[3] >> 0) & 0xFF; in kbd_get_info()
1229 if (units & BIT(1)) in kbd_get_info()
1230 info->minutes = (buffer.output[3] >> 8) & 0xFF; in kbd_get_info()
1232 info->hours = (buffer.output[3] >> 16) & 0xFF; in kbd_get_info()
1234 info->days = (buffer.output[3] >> 24) & 0xFF; in kbd_get_info()
1244 return kbd_mode_levels_count - 1; in kbd_get_max_level()
1253 return state->level; in kbd_get_level()
1257 if (kbd_mode_levels[i] == state->mode_bit) in kbd_get_level()
1262 return -EINVAL; in kbd_get_level()
1270 if (state->level == level) in kbd_set_level()
1272 state->level = level; in kbd_set_level()
1273 if (level != 0 && state->mode_bit == KBD_MODE_BIT_OFF) in kbd_set_level()
1274 state->mode_bit = kbd_previous_mode_bit; in kbd_set_level()
1275 else if (level == 0 && state->mode_bit != KBD_MODE_BIT_OFF) { in kbd_set_level()
1276 kbd_previous_mode_bit = state->mode_bit; in kbd_set_level()
1277 state->mode_bit = KBD_MODE_BIT_OFF; in kbd_set_level()
1285 state->mode_bit = kbd_mode_levels[level]; in kbd_set_level()
1289 return -EINVAL; in kbd_set_level()
1303 state->mode_bit = ffs(buffer.output[1] & 0xFFFF); in kbd_get_state()
1304 if (state->mode_bit != 0) in kbd_get_state()
1305 state->mode_bit--; in kbd_get_state()
1307 state->triggers = (buffer.output[1] >> 16) & 0xFF; in kbd_get_state()
1308 state->timeout_value = (buffer.output[1] >> 24) & 0x3F; in kbd_get_state()
1309 state->timeout_unit = (buffer.output[1] >> 30) & 0x3; in kbd_get_state()
1310 state->als_setting = buffer.output[2] & 0xFF; in kbd_get_state()
1311 state->als_value = (buffer.output[2] >> 8) & 0xFF; in kbd_get_state()
1312 state->level = (buffer.output[2] >> 16) & 0xFF; in kbd_get_state()
1313 state->timeout_value_ac = (buffer.output[2] >> 24) & 0x3F; in kbd_get_state()
1314 state->timeout_unit_ac = (buffer.output[2] >> 30) & 0x3; in kbd_get_state()
1326 input1 = BIT(state->mode_bit) & 0xFFFF; in kbd_set_state()
1327 input1 |= (state->triggers & 0xFF) << 16; in kbd_set_state()
1328 input1 |= (state->timeout_value & 0x3F) << 24; in kbd_set_state()
1329 input1 |= (state->timeout_unit & 0x3) << 30; in kbd_set_state()
1330 input2 = state->als_setting & 0xFF; in kbd_set_state()
1331 input2 |= (state->level & 0xFF) << 16; in kbd_set_state()
1332 input2 |= (state->timeout_value_ac & 0x3F) << 24; in kbd_set_state()
1333 input2 |= (state->timeout_unit_ac & 0x3) << 30; in kbd_set_state()
1368 return -EINVAL; in kbd_set_token_bit()
1372 return -EINVAL; in kbd_set_token_bit()
1374 dell_fill_request(&buffer, token->location, token->value, 0, 0); in kbd_set_token_bit()
1388 return -EINVAL; in kbd_get_token_bit()
1392 return -EINVAL; in kbd_get_token_bit()
1394 dell_fill_request(&buffer, token->location, 0, 0, 0); in kbd_get_token_bit()
1396 val = buffer.output[1]; in kbd_get_token_bit()
1401 return (val == token->value); in kbd_get_token_bit()
1411 if (ret == 1) in kbd_get_first_active_token_bit()
1437 if ((quirks && quirks->kbd_missing_ac_tag) || in kbd_init_info()
1462 kbd_previous_level = 1; in kbd_init_info()
1468 kbd_previous_mode_bit--; in kbd_init_info()
1485 kbd_mode_levels[1 + kbd_mode_levels_count++] = i; in kbd_init_info()
1519 if (quirks && quirks->kbd_led_not_present) in kbd_init()
1547 if (ret < 1) in kbd_led_timeout_store()
1548 return -EINVAL; in kbd_led_timeout_store()
1549 else if (ret == 1) in kbd_led_timeout_store()
1553 return -EINVAL; in kbd_led_timeout_store()
1579 return -EINVAL; in kbd_led_timeout_store()
1582 if (quirks && quirks->needs_kbd_timeouts) in kbd_led_timeout_store()
1599 if (quirks && quirks->needs_kbd_timeouts) { in kbd_led_timeout_store()
1600 for (i = 0; quirks->kbd_timeouts[i] != -1; i++) { in kbd_led_timeout_store()
1601 if (value <= quirks->kbd_timeouts[i]) { in kbd_led_timeout_store()
1602 value = quirks->kbd_timeouts[i]; in kbd_led_timeout_store()
1620 return -EINVAL; in kbd_led_timeout_store()
1683 return -EINVAL; in kbd_led_timeout_show()
1706 int trigger_bit = -1; in kbd_led_triggers_store()
1711 if (ret != 1) in kbd_led_triggers_store()
1712 return -EINVAL; in kbd_led_triggers_store()
1714 if (trigger[0] != '+' && trigger[0] != '-') in kbd_led_triggers_store()
1715 return -EINVAL; in kbd_led_triggers_store()
1732 if (strcmp(trigger+1, kbd_led_triggers[i]) != 0) in kbd_led_triggers_store()
1739 if (trigger[0] == '-' && in kbd_led_triggers_store()
1749 if (trigger_bit == -1) { in kbd_led_triggers_store()
1750 ret = -EINVAL; in kbd_led_triggers_store()
1761 * disabling touchpad bit (1), otherwise touchpad in kbd_led_triggers_store()
1762 * bit (1) will not be disabled in kbd_led_triggers_store()
1764 if (trigger_bit == 1) in kbd_led_triggers_store()
1769 ret = -EINVAL; in kbd_led_triggers_store()
1779 ret = -EINVAL; in kbd_led_triggers_store()
1819 buf[len++] = '-'; in kbd_led_triggers_show()
1825 buf[len - 1] = '\n'; in kbd_led_triggers_show()
1877 ret = -EINVAL; in kbd_led_als_enabled_store()
1905 return sprintf(buf, "%d\n", enabled ? 1 : 0); in kbd_led_als_enabled_show()
2006 for (num = kbd_token_bits; num != 0 && ret > 0; --ret) in kbd_led_level_get()
2007 num &= num - 1; /* clear the first bit set */ in kbd_led_level_get()
2010 return ffs(num) - 1; in kbd_led_level_get()
2038 for (num = kbd_token_bits; num != 0 && value > 0; --value) in kbd_led_level_set()
2039 num &= num - 1; /* clear the first bit set */ in kbd_led_level_set()
2043 ret = kbd_set_token_bit(ffs(num) - 1); in kbd_led_level_set()
2046 ret = -ENXIO; in kbd_led_level_set()
2071 return -ENODEV; in kbd_led_init()
2073 kbd_led_groups[1] = NULL; in kbd_led_init()
2078 kbd_led.max_brightness--; in kbd_led_init()
2149 return -ENODEV; in micmute_led_set()
2151 dell_fill_request(&buffer, token->location, token->value, 0, 0); in micmute_led_set()
2159 .max_brightness = 1,
2161 .default_trigger = "audio-micmute",
2171 return -ENODEV; in dell_init()
2180 platform_device = platform_device_alloc("dell-laptop", -1); in dell_init()
2182 ret = -ENOMEM; in dell_init()
2196 if (quirks && quirks->touchpad_led) in dell_init()
2197 touchpad_led_init(&platform_device->dev); in dell_init()
2199 kbd_led_init(&platform_device->dev); in dell_init()
2210 ret = led_classdev_register(&platform_device->dev, &micmute_led_cdev); in dell_init()
2222 dell_fill_request(&buffer, token->location, 0, 0, 0); in dell_init()
2235 &platform_device->dev, in dell_init()
2246 dell_backlight_device->props.brightness = in dell_init()
2248 if (dell_backlight_device->props.brightness < 0) { in dell_init()
2249 ret = dell_backlight_device->props.brightness; in dell_init()
2277 if (quirks && quirks->touchpad_led) in dell_exit()
2289 /* dell-rbtn.c driver export functions which will not work correctly (and could
2290 * cause kernel crash) if they are called before dell-rbtn.c init code. This is
2291 * not problem when dell-rbtn.c is compiled as external module. When both files
2292 * (dell-rbtn.c and dell-laptop.c) are compiled statically into kernel, then we
2293 * need to ensure that dell_init() will be called after initializing dell-rbtn.