Lines Matching +full:sync +full:- +full:token

1 // SPDX-License-Identifier: GPL-2.0-only
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()
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)
402 * 13-15 Reserved (0)
409 * 20-31 Reserved (0)
427 * 1-7 Reserved (0)
429 * cbRes1 Standard return codes (0, -1, -2)
436 * 5-31 Reserved (0)
453 * 5-7 Reserved (0)
457 * cbRes1 Standard return codes (0, -1, -2)
464 * 5-6 Reserved (0)
467 * 9-14 Reserved (0)
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)
502 int hwswitch_bit = (unsigned long)data - 1; in dell_rfkill_set()
535 /* Has hw-switch, sync sw_state to BIOS */ 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()
777 wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, in dell_setup_rfkill()
781 ret = -ENOMEM; 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()
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()
920 struct calling_interface_token *token; in dell_send_intensity() local
923 token = dell_smbios_find_token(BRIGHTNESS_TOKEN); in dell_send_intensity()
924 if (!token) in dell_send_intensity()
925 return -ENODEV; in dell_send_intensity()
928 token->location, bd->props.brightness, 0, 0); in dell_send_intensity()
942 struct calling_interface_token *token; in dell_get_intensity() local
945 token = dell_smbios_find_token(BRIGHTNESS_TOKEN); in dell_get_intensity()
946 if (!token) in dell_get_intensity()
947 return -ENODEV; in dell_get_intensity()
949 dell_fill_request(&buffer, token->location, 0, 0, 0); in dell_get_intensity()
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
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
1033 * 3-255 Reserved for future use
1039 * bits 4-7 Reserved for future use
1045 * bits 4-7 Reserved for future use
1053 * cbRES1 Standard return codes (0, -1, -2)
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
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)
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
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()
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()
1380 struct calling_interface_token *token; in kbd_set_token_bit() local
1384 return -EINVAL; in kbd_set_token_bit()
1386 token = dell_smbios_find_token(kbd_tokens[bit]); in kbd_set_token_bit()
1387 if (!token) 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()
1399 struct calling_interface_token *token; in kbd_get_token_bit() local
1404 return -EINVAL; in kbd_get_token_bit()
1406 token = dell_smbios_find_token(kbd_tokens[bit]); in kbd_get_token_bit()
1407 if (!token) 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()
1417 return (val == token->value); in kbd_get_token_bit()
1449 /* NOTE: Old models without KBD_LED_AC_TOKEN token supports only one in kbd_init_info()
1453 if ((quirks && quirks->kbd_missing_ac_tag) || in kbd_init_info()
1484 kbd_previous_mode_bit--; in kbd_init_info()
1535 if (quirks && quirks->kbd_led_not_present) in kbd_init()
1564 return -EINVAL; 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()
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()
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()
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()
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()
2094 kbd_led.max_brightness--; in kbd_led_init()
2156 struct calling_interface_token *token; in micmute_led_set() local
2160 token = dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE); in micmute_led_set()
2162 token = dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE); in micmute_led_set()
2164 if (!token) in micmute_led_set()
2165 return -ENODEV; in micmute_led_set()
2167 dell_fill_request(&buffer, token->location, token->value, 0, 0); in micmute_led_set()
2177 .default_trigger = "audio-micmute",
2182 struct calling_interface_token *token; in dell_init() local
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()
2236 token = dell_smbios_find_token(BRIGHTNESS_TOKEN); in dell_init()
2237 if (token) { 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.