Lines Matching +full:cap +full:- +full:get
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2007-2009 Carlos Corbacho <carlos@strangeworlds.co.uk>
8 * Copyright (C) 2005-2007 E.M. Smith
9 * Copyright (C) 2007-2008 Carlos Corbacho <cathectic@gmail.com>
30 #include <linux/input/sparse-keymap.h>
44 * Meaning is unknown - this number is required for writing to ACPI for AMW0
87 #define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB"
88 #define AMW0_GUID2 "431F16ED-0C2B-444C-B267-27DEB140CF9C"
89 #define WMID_GUID1 "6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3"
90 #define WMID_GUID2 "95764E09-FB56-4E83-B31A-37761F60994A"
91 #define WMID_GUID3 "61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
92 #define WMID_GUID4 "7A4DDFE7-5B5D-40B4-8595-4408E0CC7F56"
97 #define ACERWMID_EVENT_GUID "676AA15E-6A47-4D9F-A2CC-1E6D18D14026"
99 MODULE_ALIAS("wmi:67C3371D-95A3-4C37-BB61-DD47B491DAAB");
100 MODULE_ALIAS("wmi:6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3");
101 MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
194 * GUID3 Get Device Status device flags
240 struct wmid3_gds_get_input_param { /* Get Device Status input parameter */
243 u16 devices; /* Get Device */
246 struct wmid3_gds_return_value { /* Get Device Status return value*/
293 static int mailled = -1;
294 static int brightness = -1;
295 static int threeg = -1;
297 static int force_caps = -1;
341 /* Each low-level interface must define at least some of the following */
380 if (quirks->mailled)
381 interface->capability |= ACER_CAP_MAILLED;
383 if (quirks->brightness)
384 interface->capability |= ACER_CAP_BRIGHTNESS;
386 if (quirks->turbo)
387 interface->capability |= ACER_CAP_TURBO_OC | ACER_CAP_TURBO_LED
390 if (quirks->predator_v4)
391 interface->capability |= ACER_CAP_PLATFORM_PROFILE |
397 quirks = dmi->driver_data;
403 if (force_caps == -1) {
404 force_caps = (uintptr_t)dmi->driver_data;
405 pr_info("Found %s, set force_caps to 0x%x\n", dmi->ident, force_caps);
414 .brightness = -1,
458 /* The Aspire One has a dummy ACPI-WMI interface - disable it */
501 * that those machines are supported by acer-wmi driver.
614 .ident = "Acer Nitro AN515-58",
617 DMI_MATCH(DMI_PRODUCT_NAME, "Nitro AN515-58"),
623 .ident = "Acer Predator PH315-53",
626 DMI_MATCH(DMI_PRODUCT_NAME, "Predator PH315-53"),
632 .ident = "Acer Predator PHN16-71",
635 DMI_MATCH(DMI_PRODUCT_NAME, "Predator PHN16-71"),
641 .ident = "Acer Predator PH16-71",
644 DMI_MATCH(DMI_PRODUCT_NAME, "Predator PH16-71"),
650 .ident = "Acer Predator PH16-72",
653 DMI_MATCH(DMI_PRODUCT_NAME, "Predator PH16-72"),
659 .ident = "Acer Predator PH18-71",
662 DMI_MATCH(DMI_PRODUCT_NAME, "Predator PH18-71"),
668 .ident = "Acer Predator PT14-51",
671 DMI_MATCH(DMI_PRODUCT_NAME, "Predator PT14-51"),
677 .ident = "Acer Aspire Switch 10E SW3-016",
680 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW3-016"),
686 .ident = "Acer Aspire Switch 10 SW5-012",
689 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
695 .ident = "Acer Aspire Switch V 10 SW5-017",
698 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SW5-017"),
715 * This quirk list is for those non-acer machines that have AMW0_GUID1
716 * but supported by acer-wmi in past days. Keeping this quirk list here
718 * here anymore. Those non-acer machines should be supported by
769 .ident = "Lenovo Ideapad S205-10382JG",
778 .ident = "Lenovo Ideapad S205-1038DPG",
828 static bool has_cap(u32 cap)
830 return interface->capability & cap;
864 static acpi_status AMW0_get_u32(u32 *value, u32 cap)
869 switch (cap) {
871 switch (quirks->mailled) {
881 switch (quirks->wireless) {
909 switch (quirks->bluetooth) {
919 switch (quirks->brightness) {
934 static acpi_status AMW0_set_u32(u32 value, u32 cap)
942 switch (cap) {
961 switch (quirks->brightness) {
989 if (obj && obj->type == ACPI_TYPE_BUFFER &&
990 obj->buffer.length == sizeof(struct wmab_ret)) {
991 ret = *((struct wmab_ret *) obj->buffer.pointer);
998 interface->capability |= ACER_CAP_MAILLED;
1009 { "SNY5001", 0}, /* sony-laptop in charge */
1018 for (id = norfkill_ids; id->id[0]; id++)
1019 if (acpi_dev_found(id->id))
1040 interface->capability |= ACER_CAP_WIRELESS;
1055 if (obj && obj->type == ACPI_TYPE_BUFFER &&
1056 obj->buffer.length == sizeof(struct wmab_ret)) {
1057 ret = *((struct wmab_ret *) obj->buffer.pointer);
1064 interface->capability |= ACER_CAP_WIRELESS;
1078 if (obj && obj->type == ACPI_TYPE_BUFFER
1079 && obj->buffer.length == sizeof(struct wmab_ret)) {
1080 ret = *((struct wmab_ret *) obj->buffer.pointer);
1087 interface->capability |= ACER_CAP_BLUETOOTH;
1094 if (quirks->brightness >= 0)
1095 interface->capability |= ACER_CAP_BRIGHTNESS;
1130 if (obj->type == ACPI_TYPE_BUFFER &&
1131 (obj->buffer.length == sizeof(u32) ||
1132 obj->buffer.length == sizeof(u64))) {
1133 tmp = *((u32 *) obj->buffer.pointer);
1134 } else if (obj->type == ACPI_TYPE_INTEGER) {
1135 tmp = (u32) obj->integer.value;
1147 static acpi_status WMID_get_u32(u32 *value, u32 cap)
1153 switch (cap) {
1167 if (quirks->mailled == 1) {
1184 static acpi_status WMID_set_u32(u32 value, u32 cap)
1189 switch (cap) {
1213 if (quirks->mailled == 1) {
1251 else if (obj->type != ACPI_TYPE_BUFFER) {
1255 if (obj->buffer.length != 8) {
1256 pr_warn("Unknown buffer length %d\n", obj->buffer.length);
1261 return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer);
1265 pr_warn("Get 0x%x Device Status failed: 0x%x - 0x%x\n",
1275 static acpi_status wmid_v2_get_u32(u32 *value, u32 cap)
1279 switch (cap) {
1330 else if (obj->type != ACPI_TYPE_BUFFER) {
1334 if (obj->buffer.length != 8) {
1335 pr_warn("Unknown buffer length %d\n", obj->buffer.length);
1340 return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer);
1344 pr_warn("Get Current Device Status failed: 0x%x - 0x%x\n",
1361 else if (obj->type != ACPI_TYPE_BUFFER) {
1365 if (obj->buffer.length != 4) {
1366 pr_warn("Unknown buffer length %d\n", obj->buffer.length);
1371 return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer);
1375 pr_warn("Set Device Status failed: 0x%x - 0x%x\n",
1382 static acpi_status wmid_v2_set_u32(u32 value, u32 cap)
1386 switch (cap) {
1406 /* We are looking for OEM-specific Type AAh */
1407 if (header->type != 0xAA)
1414 type_aa->commun_func_bitmap);
1415 commun_func_bitmap = type_aa->commun_func_bitmap;
1417 if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_WIRELESS)
1418 interface->capability |= ACER_CAP_WIRELESS;
1419 if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_THREEG)
1420 interface->capability |= ACER_CAP_THREEG;
1421 if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_BLUETOOTH)
1422 interface->capability |= ACER_CAP_BLUETOOTH;
1423 if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_RFBTN)
1426 commun_fn_key_number = type_aa->commun_fn_key_number;
1442 if (obj->type == ACPI_TYPE_BUFFER &&
1443 (obj->buffer.length == sizeof(u32) ||
1444 obj->buffer.length == sizeof(u64))) {
1445 devices = *((u32 *) obj->buffer.pointer);
1446 } else if (obj->type == ACPI_TYPE_INTEGER) {
1447 devices = (u32) obj->integer.value;
1459 interface->capability |= ACER_CAP_WIRELESS;
1461 interface->capability |= ACER_CAP_THREEG;
1463 interface->capability |= ACER_CAP_BLUETOOTH;
1500 if (obj->type == ACPI_TYPE_BUFFER) {
1501 if (obj->buffer.length == sizeof(u32))
1502 tmp = *((u32 *) obj->buffer.pointer);
1503 else if (obj->buffer.length == sizeof(u64))
1504 tmp = *((u64 *) obj->buffer.pointer);
1505 } else if (obj->type == ACPI_TYPE_INTEGER) {
1506 tmp = (u64) obj->integer.value;
1531 return -EIO;
1535 switch (obj->type) {
1537 *out = obj->integer.value;
1540 if (obj->buffer.length < sizeof(*out))
1541 ret = -ENOMSG;
1543 *out = get_unaligned_le64(obj->buffer.pointer);
1547 ret = -ENOMSG;
1557 static acpi_status WMID_gaming_set_u64(u64 value, u32 cap)
1561 if (!(interface->capability & cap))
1564 switch (cap) {
1578 static acpi_status WMID_gaming_get_u64(u64 *value, u32 cap)
1585 if (!(interface->capability & cap))
1588 switch (cap) {
1610 return -EIO;
1614 return -EIO;
1627 if (quirks->cpu_fans > 0)
1629 for (i = 0; i < (quirks->cpu_fans + quirks->gpu_fans); ++i)
1631 for (i = 0; i < quirks->gpu_fans; ++i)
1633 if (quirks->cpu_fans > 0)
1635 for (i = 0; i < (quirks->cpu_fans + quirks->gpu_fans); ++i)
1637 for (i = 0; i < quirks->gpu_fans; ++i)
1653 return -EIO;
1657 return -EIO;
1677 return -EIO;
1685 * Generic Device (interface-independent)
1688 static acpi_status get_u32(u32 *value, u32 cap)
1692 switch (interface->type) {
1694 status = AMW0_get_u32(value, cap);
1697 if (cap == ACER_CAP_MAILLED) {
1698 status = AMW0_get_u32(value, cap);
1703 status = WMID_get_u32(value, cap);
1706 if (cap & (ACER_CAP_WIRELESS |
1709 status = wmid_v2_get_u32(value, cap);
1711 status = WMID_get_u32(value, cap);
1718 static acpi_status set_u32(u32 value, u32 cap)
1722 if (interface->capability & cap) {
1723 switch (interface->type) {
1725 return AMW0_set_u32(value, cap);
1727 if (cap == ACER_CAP_MAILLED)
1728 return AMW0_set_u32(value, cap);
1736 if (cap == ACER_CAP_WIRELESS ||
1737 cap == ACER_CAP_BLUETOOTH) {
1738 status = WMID_set_u32(value, cap);
1742 return AMW0_set_u32(value, cap);
1746 return WMID_set_u32(value, cap);
1748 if (cap & (ACER_CAP_WIRELESS |
1751 return wmid_v2_set_u32(value, cap);
1753 return WMID_set_u32(value, cap);
1786 .name = "acer-wmi::mail",
1835 bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops,
1845 bd->props.power = BACKLIGHT_POWER_ON;
1846 bd->props.brightness = read_brightness(bd);
1871 return -1;
1888 return -1;
1895 return -1;
1897 if (out_obj->package.count != 4)
1898 return -1;
1901 (s16)out_obj->package.elements[0].integer.value);
1903 (s16)out_obj->package.elements[1].integer.value);
1905 (s16)out_obj->package.elements[2].integer.value);
1917 /* Get current state from turbo button */
1919 return -1;
1981 return -EOPNOTSUPP;
2010 return -EOPNOTSUPP;
2070 * no-op.
2087 if (quirks->predator_v4) {
2089 &device->dev, "acer-wmi", NULL, &acer_predator_v4_platform_profile_ops);
2104 if (quirks->predator_v4) {
2149 case 0x04: /* Stand-alone tablet */
2170 pr_err("Error getting keyboard-dock initial status: %s\n",
2176 if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
2177 pr_err("Unexpected output format getting keyboard-dock initial status\n");
2181 output = obj->buffer.pointer;
2183 pr_err("Unexpected output [0]=0x%02x [3]=0x%02x getting keyboard-dock initial status\n",
2202 sw_tablet_mode = acer_kbd_dock_state_to_sw_tablet_mode(event->kbd_dock_state);
2220 if (quirks->wireless == 3)
2245 u32 cap = (unsigned long)data;
2248 status = set_u32(!blocked, cap);
2250 return -ENODEV;
2262 char *name, u32 cap)
2271 (void *)(unsigned long)cap);
2273 return ERR_PTR(-ENOMEM);
2275 status = get_u32(&state, cap);
2295 "acer-wireless", ACER_CAP_WIRELESS);
2304 RFKILL_TYPE_BLUETOOTH, "acer-bluetooth",
2314 RFKILL_TYPE_WWAN, "acer-threeg",
2376 if (obj->type != ACPI_TYPE_BUFFER) {
2377 pr_warn("Unknown response received %d\n", obj->type);
2380 if (obj->buffer.length != 8) {
2381 pr_warn("Unknown buffer length %d\n", obj->buffer.length);
2385 return_value = *((struct event_return_value *)obj->buffer.pointer);
2395 pr_warn("Unknown key number - 0x%x\n",
2399 switch (key->keycode) {
2433 pr_warn("Unknown function number - %d - %d\n",
2457 else if (obj->type != ACPI_TYPE_BUFFER) {
2461 if (obj->buffer.length != 4) {
2462 pr_warn("Unknown buffer length %d\n", obj->buffer.length);
2467 *return_value = *((struct func_return_value *)obj->buffer.pointer);
2488 pr_warn("Enabling EC raw mode failed: 0x%x - 0x%x\n",
2512 pr_warn("Enabling Launch Manager failed: 0x%x - 0x%x\n",
2534 pr_warn("Enabling RF Button failed: 0x%x - 0x%x\n",
2546 adev = acpi_dev_get_first_match_dev("BST0001", NULL, -1);
2548 return -ENODEV;
2555 return -ENOMEM;
2557 acer_wmi_accel_dev->open = acer_gsensor_open;
2559 acer_wmi_accel_dev->name = "Acer BMA150 accelerometer";
2560 acer_wmi_accel_dev->phys = "wmi/input1";
2561 acer_wmi_accel_dev->id.bustype = BUS_HOST;
2562 acer_wmi_accel_dev->evbit[0] = BIT_MASK(EV_ABS);
2563 input_set_abs_params(acer_wmi_accel_dev, ABS_X, -16384, 16384, 0, 0);
2564 input_set_abs_params(acer_wmi_accel_dev, ABS_Y, -16384, 16384, 0, 0);
2565 input_set_abs_params(acer_wmi_accel_dev, ABS_Z, -16384, 16384, 0, 0);
2585 return -ENOMEM;
2587 acer_wmi_input_dev->name = "Acer WMI hotkeys";
2588 acer_wmi_input_dev->phys = "wmi/input0";
2589 acer_wmi_input_dev->id.bustype = BUS_HOST;
2601 err = -EIO;
2643 if (obj->type == ACPI_TYPE_BUFFER &&
2644 (obj->buffer.length == sizeof(u32) ||
2645 obj->buffer.length == sizeof(u64))) {
2646 devices = *((u32 *) obj->buffer.pointer);
2647 } else if (obj->type == ACPI_TYPE_INTEGER) {
2648 devices = (u32) obj->integer.value;
2666 err = acer_led_init(&device->dev);
2672 err = acer_backlight_init(&device->dev);
2677 err = acer_rfkill_init(&device->dev);
2722 struct acer_data *data = &interface->data;
2725 return -ENOMEM;
2730 data->mailled = value;
2735 data->brightness = value;
2743 struct acer_data *data = &interface->data;
2746 return -ENOMEM;
2749 set_u32(data->mailled, ACER_CAP_MAILLED);
2752 set_u32(data->brightness, ACER_CAP_BRIGHTNESS);
2768 struct acer_data *data = &interface->data;
2779 .name = "acer-wmi",
2791 debugfs_remove_recursive(interface->debug.root);
2796 interface->debug.root = debugfs_create_dir("acer-wmi", NULL);
2798 debugfs_create_u32("devices", S_IRUGO, interface->debug.root,
2799 &interface->debug.wmid_devices);
2831 if (*supported_sensors & BIT(sensor_id - 1))
2867 return -EOPNOTSUPP;
2896 struct device *dev = &acer_platform_device->dev;
2927 pr_info("Acer Laptop ACPI-WMI Extras\n");
2930 pr_info("Blacklisted hardware detected - not loading\n");
2931 return -ENODEV;
2939 * acer-wmi driver handled those non-Acer machines by quirks list.
2940 * But actually acer-wmi driver was loaded on any machines that have
2942 * be supported by appropriate wmi drivers. e.g. fujitsu-laptop,
2943 * ideapad-laptop. So, here checks the machine that has AMW0_GUID1
2951 return -ENODEV;
2955 * Detect which ACPI-WMI interface we're using.
2972 return -ENODEV;
2975 interface->capability |= ACER_CAP_BRIGHTNESS;
2976 } else if (!wmi_has_guid(WMID_GUID2) && interface && !has_type_aa && force_caps == -1) {
2978 return -ENODEV;
2986 return -ENODEV;
2995 return -ENODEV;
3001 interface->capability &= ~ACER_CAP_BRIGHTNESS;
3004 interface->capability |= ACER_CAP_SET_FUNCTION_MODE;
3006 if (force_caps != -1)
3007 interface->capability = force_caps;
3010 (interface->capability & ACER_CAP_SET_FUNCTION_MODE)) {
3017 return -ENODEV;
3021 return -ENODEV;
3032 if (err && err != -ENODEV)
3042 acer_platform_device = platform_device_alloc("acer-wmi", PLATFORM_DEVID_NONE);
3044 err = -ENOMEM;
3053 interface->debug.wmid_devices = get_wmid_devices();