* [PATCH v4 00/14] platform/x86: alienware-wmi driver rework
@ 2025-01-17 8:13 Kurt Borja
2025-01-17 8:13 ` [PATCH v4 01/14] platform/x86: alienware-wmi: Add a state container for LED control feature Kurt Borja
` (14 more replies)
0 siblings, 15 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Hello!
I rebased these series on top of review-ilpo-next branch to pick up
platform_profile latest changes.
~ Kurt
---
v3->v4:
- First 6 patches are already applied so they are not included
[01/14]
- Reordered some lines in alienfx_probe() for aesthetic purposes
[10/14]
- Removed pr_fmt from header file
[11/14]
- Copy pr_fmt to each linked file
v3: https://lore.kernel.org/platform-driver-x86/20250105153019.19206-2-kuurtb@gmail.com/
Kurt Borja (14):
platform/x86: alienware-wmi: Add a state container for LED control
feature
platform/x86: alienware-wmi: Add WMI Drivers
platform/x86: alienware-wmi: Add a state container for thermal control
methods
platform/x86: alienware-wmi: Refactor LED control methods
platform/x86: alienware-wmi: Refactor hdmi, amplifier, deepslp methods
platform/x86: alienware-wmi: Refactor thermal control methods
platform/x86: alienware-wmi: Split DMI table
MAINTAINERS: Update ALIENWARE WMI DRIVER entry
platform/x86: Rename alienware-wmi.c
platform/x86: Add alienware-wmi.h
platform/x86: Split the alienware-wmi driver
platform/x86: dell: Modify Makefile alignment
platform/x86: Update alienware-wmi config entries
platform/x86: alienware-wmi: Update header and module information
MAINTAINERS | 4 +-
drivers/platform/x86/dell/Kconfig | 30 +-
drivers/platform/x86/dell/Makefile | 45 +-
.../platform/x86/dell/alienware-wmi-base.c | 488 +++++++
.../platform/x86/dell/alienware-wmi-legacy.c | 100 ++
.../platform/x86/dell/alienware-wmi-wmax.c | 773 +++++++++++
drivers/platform/x86/dell/alienware-wmi.c | 1235 -----------------
drivers/platform/x86/dell/alienware-wmi.h | 102 ++
8 files changed, 1515 insertions(+), 1262 deletions(-)
create mode 100644 drivers/platform/x86/dell/alienware-wmi-base.c
create mode 100644 drivers/platform/x86/dell/alienware-wmi-legacy.c
create mode 100644 drivers/platform/x86/dell/alienware-wmi-wmax.c
delete mode 100644 drivers/platform/x86/dell/alienware-wmi.c
create mode 100644 drivers/platform/x86/dell/alienware-wmi.h
base-commit: 81e8e5017f5de3cf28004ae2b628629ef4d43635
--
2.48.1
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v4 01/14] platform/x86: alienware-wmi: Add a state container for LED control feature
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-18 23:34 ` Armin Wolf
2025-01-17 8:13 ` [PATCH v4 02/14] platform/x86: alienware-wmi: Add WMI Drivers Kurt Borja
` (13 subsequent siblings)
14 siblings, 1 reply; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Add a state container for the "alienware-wmi" platform device and
initialize it on the new alienfx_probe(). Migrate all LED control functions
to use this state container, as well as hdmi, amplifier, deepslp group
visibility methods, to support upcoming file split.
Additionally move the led_classdev registration to the platform driver
probe and make it device managed.
Drop alienware_zone_init() and alienware_zone_exit() because they are no
longer needed.
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/alienware-wmi.c | 117 ++++++++++++----------
1 file changed, 65 insertions(+), 52 deletions(-)
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index 63cf016bc912..5779b025761b 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -404,13 +404,18 @@ struct wmax_u32_args {
u8 arg3;
};
+struct alienfx_priv {
+ struct platform_device *pdev;
+ struct led_classdev global_led;
+ struct color_platform colors[4];
+ u8 global_brightness;
+ u8 lighting_control_state;
+};
+
static struct platform_device *platform_device;
-static struct color_platform colors[4];
static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
static u8 interface;
-static u8 lighting_control_state;
-static u8 global_brightness;
/*
* Helpers used for zone control
@@ -442,7 +447,7 @@ static int parse_rgb(const char *buf, struct color_platform *colors)
/*
* Individual RGB zone control
*/
-static int alienware_update_led(u8 location)
+static int alienware_update_led(struct alienfx_priv *priv, u8 location)
{
int method_id;
acpi_status status;
@@ -452,21 +457,21 @@ static int alienware_update_led(u8 location)
struct wmax_led_args wmax_basic_args;
if (interface == WMAX) {
wmax_basic_args.led_mask = 1 << location;
- wmax_basic_args.colors = colors[location];
- wmax_basic_args.state = lighting_control_state;
+ wmax_basic_args.colors = priv->colors[location];
+ wmax_basic_args.state = priv->lighting_control_state;
guid = WMAX_CONTROL_GUID;
method_id = WMAX_METHOD_ZONE_CONTROL;
input.length = sizeof(wmax_basic_args);
input.pointer = &wmax_basic_args;
} else {
- legacy_args.colors = colors[location];
- legacy_args.brightness = global_brightness;
+ legacy_args.colors = priv->colors[location];
+ legacy_args.brightness = priv->global_brightness;
legacy_args.state = 0;
- if (lighting_control_state == LEGACY_BOOTING ||
- lighting_control_state == LEGACY_SUSPEND) {
+ if (priv->lighting_control_state == LEGACY_BOOTING ||
+ priv->lighting_control_state == LEGACY_SUSPEND) {
guid = LEGACY_POWER_CONTROL_GUID;
- legacy_args.state = lighting_control_state;
+ legacy_args.state = priv->lighting_control_state;
} else
guid = LEGACY_CONTROL_GUID;
method_id = location + 1;
@@ -485,22 +490,26 @@ static int alienware_update_led(u8 location)
static ssize_t zone_show(struct device *dev, struct device_attribute *attr,
char *buf, u8 location)
{
+ struct alienfx_priv *priv = dev_get_drvdata(dev);
+ struct color_platform *colors = &priv->colors[location];
+
return sprintf(buf, "red: %d, green: %d, blue: %d\n",
- colors[location].red, colors[location].green,
- colors[location].blue);
+ colors->red, colors->green, colors->blue);
}
static ssize_t zone_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count, u8 location)
{
+ struct alienfx_priv *priv = dev_get_drvdata(dev);
+ struct color_platform *colors = &priv->colors[location];
int ret;
- ret = parse_rgb(buf, &colors[location]);
+ ret = parse_rgb(buf, colors);
if (ret)
return ret;
- ret = alienware_update_led(location);
+ ret = alienware_update_led(priv, location);
return ret ? ret : count;
}
@@ -568,9 +577,11 @@ static ssize_t lighting_control_state_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- if (lighting_control_state == LEGACY_BOOTING)
+ struct alienfx_priv *priv = dev_get_drvdata(dev);
+
+ if (priv->lighting_control_state == LEGACY_BOOTING)
return sysfs_emit(buf, "[booting] running suspend\n");
- else if (lighting_control_state == LEGACY_SUSPEND)
+ else if (priv->lighting_control_state == LEGACY_SUSPEND)
return sysfs_emit(buf, "booting running [suspend]\n");
return sysfs_emit(buf, "booting [running] suspend\n");
@@ -580,6 +591,7 @@ static ssize_t lighting_control_state_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct alienfx_priv *priv = dev_get_drvdata(dev);
u8 val;
if (strcmp(buf, "booting\n") == 0)
@@ -591,9 +603,9 @@ static ssize_t lighting_control_state_store(struct device *dev,
else
val = WMAX_RUNNING;
- lighting_control_state = val;
+ priv->lighting_control_state = val;
pr_debug("alienware-wmi: updated control state to %d\n",
- lighting_control_state);
+ priv->lighting_control_state);
return count;
}
@@ -653,43 +665,26 @@ static int wmax_brightness(int brightness)
static void global_led_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
+ struct alienfx_priv *priv = container_of(led_cdev, struct alienfx_priv,
+ global_led);
int ret;
- global_brightness = brightness;
+
+ priv->global_brightness = brightness;
+
if (interface == WMAX)
ret = wmax_brightness(brightness);
else
- ret = alienware_update_led(0);
+ ret = alienware_update_led(priv, 0);
if (ret)
pr_err("LED brightness update failed\n");
}
static enum led_brightness global_led_get(struct led_classdev *led_cdev)
{
- return global_brightness;
-}
-
-static struct led_classdev global_led = {
- .brightness_set = global_led_set,
- .brightness_get = global_led_get,
- .name = "alienware::global_brightness",
-};
-
-static int alienware_zone_init(struct platform_device *dev)
-{
- if (interface == WMAX) {
- lighting_control_state = WMAX_RUNNING;
- } else if (interface == LEGACY) {
- lighting_control_state = LEGACY_RUNNING;
- }
- global_led.max_brightness = 0x0F;
- global_brightness = global_led.max_brightness;
+ struct alienfx_priv *priv = container_of(led_cdev, struct alienfx_priv,
+ global_led);
- return led_classdev_register(&dev->dev, &global_led);
-}
-
-static void alienware_zone_exit(struct platform_device *dev)
-{
- led_classdev_unregister(&global_led);
+ return priv->global_brightness;
}
static acpi_status alienware_wmax_command(void *in_args, size_t in_size,
@@ -1145,6 +1140,30 @@ static int create_thermal_profile(struct platform_device *platform_device)
/*
* Platform Driver
*/
+static int alienfx_probe(struct platform_device *pdev)
+{
+ struct alienfx_priv *priv;
+
+ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ if (interface == WMAX)
+ priv->lighting_control_state = WMAX_RUNNING;
+ else
+ priv->lighting_control_state = LEGACY_RUNNING;
+
+ priv->pdev = pdev;
+ priv->global_led.name = "alienware::global_brightness";
+ priv->global_led.brightness_set = global_led_set;
+ priv->global_led.brightness_get = global_led_get;
+ priv->global_led.max_brightness = 0x0F;
+ priv->global_brightness = priv->global_led.max_brightness;
+ platform_set_drvdata(pdev, priv);
+
+ return devm_led_classdev_register(&pdev->dev, &priv->global_led);
+}
+
static const struct attribute_group *alienfx_groups[] = {
&zone_attribute_group,
&hdmi_attribute_group,
@@ -1158,6 +1177,7 @@ static struct platform_driver platform_driver = {
.name = "alienware-wmi",
.dev_groups = alienfx_groups,
},
+ .probe = alienfx_probe,
};
static int __init alienware_wmi_init(void)
@@ -1205,14 +1225,8 @@ static int __init alienware_wmi_init(void)
goto fail_prep_thermal_profile;
}
- ret = alienware_zone_init(platform_device);
- if (ret)
- goto fail_prep_zones;
-
return 0;
-fail_prep_zones:
- alienware_zone_exit(platform_device);
fail_prep_thermal_profile:
platform_device_del(platform_device);
fail_platform_device2:
@@ -1227,7 +1241,6 @@ module_init(alienware_wmi_init);
static void __exit alienware_wmi_exit(void)
{
- alienware_zone_exit(platform_device);
platform_device_unregister(platform_device);
platform_driver_unregister(&platform_driver);
}
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 02/14] platform/x86: alienware-wmi: Add WMI Drivers
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
2025-01-17 8:13 ` [PATCH v4 01/14] platform/x86: alienware-wmi: Add a state container for LED control feature Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-18 23:48 ` Armin Wolf
2025-01-17 8:13 ` [PATCH v4 03/14] platform/x86: alienware-wmi: Add a state container for thermal control methods Kurt Borja
` (12 subsequent siblings)
14 siblings, 1 reply; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Add WMI drivers for LEGACY and WMAX devices.
This involves moving platform driver and device registration to a helper
function, which is now called from the driver's preferred WMI device
driver probe. However this is only done if !quirks->thermal because
newer WMAX interface doesn't support any of the features exposed by this
device.
Only one driver is registered on module initialization to prevent
registering duplicate platform driver and device.
Additionally, create_thermal_profile() now takes wmi_device * instead of
platform_device *.
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/alienware-wmi.c | 200 +++++++++++++++++-----
1 file changed, 160 insertions(+), 40 deletions(-)
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index 5779b025761b..e1a5a867f144 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -15,6 +15,7 @@
#include <linux/platform_profile.h>
#include <linux/dmi.h>
#include <linux/leds.h>
+#include <linux/wmi.h>
#define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492"
#define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492"
@@ -39,8 +40,6 @@
MODULE_AUTHOR("Mario Limonciello <mario.limonciello@outlook.com>");
MODULE_DESCRIPTION("Alienware special feature control");
MODULE_LICENSE("GPL");
-MODULE_ALIAS("wmi:" LEGACY_CONTROL_GUID);
-MODULE_ALIAS("wmi:" WMAX_CONTROL_GUID);
static bool force_platform_profile;
module_param_unsafe(force_platform_profile, bool, 0);
@@ -412,7 +411,10 @@ struct alienfx_priv {
u8 lighting_control_state;
};
-static struct platform_device *platform_device;
+struct alienfx_platdata {
+ struct wmi_device *wdev;
+};
+
static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
static u8 interface;
@@ -1127,11 +1129,11 @@ static const struct platform_profile_ops awcc_platform_profile_ops = {
.profile_set = thermal_profile_set,
};
-static int create_thermal_profile(struct platform_device *platform_device)
+static int create_thermal_profile(struct wmi_device *wdev)
{
struct device *ppdev;
- ppdev = devm_platform_profile_register(&platform_device->dev, "alienware-wmi",
+ ppdev = devm_platform_profile_register(&wdev->dev, "alienware-wmi",
NULL, &awcc_platform_profile_ops);
return PTR_ERR_OR_ZERO(ppdev);
@@ -1166,6 +1168,10 @@ static int alienfx_probe(struct platform_device *pdev)
static const struct attribute_group *alienfx_groups[] = {
&zone_attribute_group,
+ NULL
+};
+
+static const struct attribute_group *wmax_alienfx_groups[] = {
&hdmi_attribute_group,
&lifier_attribute_group,
&deepsleep_attribute_group,
@@ -1180,19 +1186,150 @@ static struct platform_driver platform_driver = {
.probe = alienfx_probe,
};
-static int __init alienware_wmi_init(void)
+static int alienware_alienfx_setup(struct alienfx_platdata *pdata)
{
+ struct platform_device *pdev;
int ret;
- if (wmi_has_guid(LEGACY_CONTROL_GUID))
- interface = LEGACY;
- else if (wmi_has_guid(WMAX_CONTROL_GUID))
- interface = WMAX;
- else {
- pr_warn("alienware-wmi: No known WMI GUID found\n");
- return -ENODEV;
+ ret = platform_driver_register(&platform_driver);
+ if (ret < 0)
+ return ret;
+
+ pdev = platform_device_register_data(NULL, "alienware-wmi",
+ PLATFORM_DEVID_NONE, pdata,
+ sizeof(*pdata));
+
+ if (IS_ERR(pdev)) {
+ platform_driver_unregister(&platform_driver);
+ return PTR_ERR(pdev);
}
+ dev_set_drvdata(&pdata->wdev->dev, pdev);
+
+ return 0;
+}
+
+static void alienware_alienfx_exit(struct wmi_device *wdev)
+{
+ struct platform_device *pdev = dev_get_drvdata(&wdev->dev);
+
+ platform_device_unregister(pdev);
+ platform_driver_unregister(&platform_driver);
+}
+
+/*
+ * Legacy WMI driver
+ */
+static int legacy_wmi_probe(struct wmi_device *wdev, const void *context)
+{
+ struct alienfx_platdata pdata = {
+ .wdev = wdev,
+ };
+
+ return alienware_alienfx_setup(&pdata);
+}
+
+static void legacy_wmi_remove(struct wmi_device *wdev)
+{
+ alienware_alienfx_exit(wdev);
+}
+
+static struct wmi_device_id alienware_legacy_device_id_table[] = {
+ { LEGACY_CONTROL_GUID, NULL },
+ { },
+};
+MODULE_DEVICE_TABLE(wmi, alienware_legacy_device_id_table);
+
+static struct wmi_driver alienware_legacy_wmi_driver = {
+ .driver = {
+ .name = "alienware-wmi-alienfx",
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ },
+ .id_table = alienware_legacy_device_id_table,
+ .probe = legacy_wmi_probe,
+ .remove = legacy_wmi_remove,
+};
+
+static int __init alienware_legacy_wmi_init(void)
+{
+ return wmi_driver_register(&alienware_legacy_wmi_driver);
+}
+
+static void __exit alienware_legacy_wmi_exit(void)
+{
+ wmi_driver_unregister(&alienware_legacy_wmi_driver);
+}
+
+/*
+ * WMAX WMI driver
+ */
+static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
+{
+ struct alienfx_platdata pdata = {
+ .wdev = wdev,
+ };
+ struct platform_device *pdev;
+ int ret;
+
+ if (quirks->thermal) {
+ return create_thermal_profile(wdev);
+ } else {
+ ret = alienware_alienfx_setup(&pdata);
+ if (ret < 0)
+ return ret;
+
+ pdev = dev_get_drvdata(&wdev->dev);
+
+ ret = device_add_groups(&pdev->dev, wmax_alienfx_groups);
+ if (ret < 0)
+ alienware_alienfx_exit(wdev);
+
+ return ret;
+ }
+}
+
+static void wmax_wmi_remove(struct wmi_device *wdev)
+{
+ struct platform_device *pdev;
+
+ if (!quirks->thermal) {
+ pdev = dev_get_drvdata(&wdev->dev);
+
+ device_remove_groups(&pdev->dev, wmax_alienfx_groups);
+ alienware_alienfx_exit(wdev);
+ }
+}
+
+static struct wmi_device_id alienware_wmax_device_id_table[] = {
+ { WMAX_CONTROL_GUID, NULL },
+ { },
+};
+MODULE_DEVICE_TABLE(wmi, alienware_wmax_device_id_table);
+
+static struct wmi_driver alienware_wmax_wmi_driver = {
+ .driver = {
+ .name = "alienware-wmi-wmax",
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ },
+ .id_table = alienware_wmax_device_id_table,
+ .probe = wmax_wmi_probe,
+ .remove = wmax_wmi_remove,
+};
+
+static int __init alienware_wmax_wmi_init(void)
+{
+ return wmi_driver_register(&alienware_wmax_wmi_driver);
+}
+
+static void __exit alienware_wmax_wmi_exit(void)
+{
+ wmi_driver_unregister(&alienware_wmax_wmi_driver);
+}
+
+static int __init alienware_wmi_init(void)
+{
+ int ret;
+
dmi_check_system(alienware_quirks);
if (quirks == NULL)
quirks = &quirk_unknown;
@@ -1207,33 +1344,14 @@ static int __init alienware_wmi_init(void)
pr_warn("force_gmode requires platform profile support\n");
}
- ret = platform_driver_register(&platform_driver);
- if (ret)
- goto fail_platform_driver;
- platform_device = platform_device_alloc("alienware-wmi", PLATFORM_DEVID_NONE);
- if (!platform_device) {
- ret = -ENOMEM;
- goto fail_platform_device1;
- }
- ret = platform_device_add(platform_device);
- if (ret)
- goto fail_platform_device2;
-
- if (quirks->thermal) {
- ret = create_thermal_profile(platform_device);
- if (ret)
- goto fail_prep_thermal_profile;
+ if (wmi_has_guid(WMAX_CONTROL_GUID)) {
+ interface = WMAX;
+ ret = alienware_wmax_wmi_init();
+ } else {
+ interface = LEGACY;
+ ret = alienware_legacy_wmi_init();
}
- return 0;
-
-fail_prep_thermal_profile:
- platform_device_del(platform_device);
-fail_platform_device2:
- platform_device_put(platform_device);
-fail_platform_device1:
- platform_driver_unregister(&platform_driver);
-fail_platform_driver:
return ret;
}
@@ -1241,8 +1359,10 @@ module_init(alienware_wmi_init);
static void __exit alienware_wmi_exit(void)
{
- platform_device_unregister(platform_device);
- platform_driver_unregister(&platform_driver);
+ if (interface == WMAX)
+ alienware_wmax_wmi_exit();
+ else
+ alienware_legacy_wmi_exit();
}
module_exit(alienware_wmi_exit);
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 03/14] platform/x86: alienware-wmi: Add a state container for thermal control methods
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
2025-01-17 8:13 ` [PATCH v4 01/14] platform/x86: alienware-wmi: Add a state container for LED control feature Kurt Borja
2025-01-17 8:13 ` [PATCH v4 02/14] platform/x86: alienware-wmi: Add WMI Drivers Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 04/14] platform/x86: alienware-wmi: Refactor LED " Kurt Borja
` (11 subsequent siblings)
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Refactor all thermal control methods to use the newly defined awcc_priv
state container instead of global variables. While at it, rename
create_thermal_profile to alienware_awcc_setup and use it to set up the
WMI device "awcc" driver data.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/alienware-wmi.c | 36 ++++++++++++++++-------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index e1a5a867f144..7356260f7f09 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -403,6 +403,12 @@ struct wmax_u32_args {
u8 arg3;
};
+struct awcc_priv {
+ struct wmi_device *wdev;
+ struct device *ppdev;
+ enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
+};
+
struct alienfx_priv {
struct platform_device *pdev;
struct led_classdev global_led;
@@ -415,8 +421,6 @@ struct alienfx_platdata {
struct wmi_device *wdev;
};
-static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
-
static u8 interface;
/*
@@ -1051,6 +1055,8 @@ static int thermal_profile_get(struct device *dev,
static int thermal_profile_set(struct device *dev,
enum platform_profile_option profile)
{
+ struct awcc_priv *priv = dev_get_drvdata(dev);
+
if (quirks->gmode) {
u32 gmode_status;
int ret;
@@ -1071,12 +1077,13 @@ static int thermal_profile_set(struct device *dev,
}
}
- return wmax_thermal_control(supported_thermal_profiles[profile]);
+ return wmax_thermal_control(priv->supported_thermal_profiles[profile]);
}
static int thermal_profile_probe(void *drvdata, unsigned long *choices)
{
enum platform_profile_option profile;
+ struct awcc_priv *priv = drvdata;
enum wmax_thermal_mode mode;
u8 sys_desc[4];
u32 first_mode;
@@ -1105,7 +1112,7 @@ static int thermal_profile_probe(void *drvdata, unsigned long *choices)
mode = out_data & WMAX_THERMAL_MODE_MASK;
profile = wmax_mode_to_platform_profile[mode];
- supported_thermal_profiles[profile] = out_data;
+ priv->supported_thermal_profiles[profile] = out_data;
set_bit(profile, choices);
}
@@ -1114,7 +1121,7 @@ static int thermal_profile_probe(void *drvdata, unsigned long *choices)
return -ENODEV;
if (quirks->gmode) {
- supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =
+ priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =
WMAX_THERMAL_MODE_GMODE;
set_bit(PLATFORM_PROFILE_PERFORMANCE, choices);
@@ -1129,14 +1136,21 @@ static const struct platform_profile_ops awcc_platform_profile_ops = {
.profile_set = thermal_profile_set,
};
-static int create_thermal_profile(struct wmi_device *wdev)
+static int alienware_awcc_setup(struct wmi_device *wdev)
{
- struct device *ppdev;
+ struct awcc_priv *priv;
+
+ priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->wdev = wdev;
+ dev_set_drvdata(&wdev->dev, priv);
- ppdev = devm_platform_profile_register(&wdev->dev, "alienware-wmi",
- NULL, &awcc_platform_profile_ops);
+ priv->ppdev = devm_platform_profile_register(&wdev->dev, "alienware-wmi",
+ priv, &awcc_platform_profile_ops);
- return PTR_ERR_OR_ZERO(ppdev);
+ return PTR_ERR_OR_ZERO(priv->ppdev);
}
/*
@@ -1272,7 +1286,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
int ret;
if (quirks->thermal) {
- return create_thermal_profile(wdev);
+ return alienware_awcc_setup(wdev);
} else {
ret = alienware_alienfx_setup(&pdata);
if (ret < 0)
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 04/14] platform/x86: alienware-wmi: Refactor LED control methods
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (2 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 03/14] platform/x86: alienware-wmi: Add a state container for thermal control methods Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-18 23:58 ` Armin Wolf
2025-01-17 8:13 ` [PATCH v4 05/14] platform/x86: alienware-wmi: Refactor hdmi, amplifier, deepslp methods Kurt Borja
` (10 subsequent siblings)
14 siblings, 1 reply; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Both WMI devices handled by this module specify a distinct interface for
LED control. Previously this module handled this by dynamically adapting
arguments passed to wmi_evaluate_method() based on the `interface`
global variable.
To avoid the use of global variables, and enable the migration to
non-deprecated WMI methods, let the WMI drivers define upd_led and
upd_brightness operations, which completely replace
alienware_update_led() and wmax_brightness().
Also define alienware_wmi_command(), which serves as a wrapper for
wmidev_evaluate_method(). This new method is very similar to
alienware_wmax_command() but is WMI device agnostic.
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/alienware-wmi.c | 164 ++++++++++++++--------
1 file changed, 102 insertions(+), 62 deletions(-)
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index 7356260f7f09..c9d9cf36b87b 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -417,12 +417,42 @@ struct alienfx_priv {
u8 lighting_control_state;
};
+struct alienfx_ops {
+ int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev,
+ u8 location);
+ int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev,
+ u8 brightness);
+};
+
struct alienfx_platdata {
struct wmi_device *wdev;
+ struct alienfx_ops ops;
};
static u8 interface;
+static int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
+ void *in_args, size_t in_size, u32 *out_data)
+{
+ struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
+ struct acpi_buffer in = {in_size, in_args};
+ union acpi_object *obj;
+ acpi_status ret;
+
+ ret = wmidev_evaluate_method(wdev, 0, method_id, &in, out_data ? &out : NULL);
+ if (ACPI_FAILURE(ret))
+ return -EIO;
+
+ obj = out.pointer;
+
+ if (out_data && obj && obj->type == ACPI_TYPE_INTEGER)
+ *out_data = (u32)obj->integer.value;
+
+ kfree(obj);
+
+ return 0;
+}
+
/*
* Helpers used for zone control
*/
@@ -453,46 +483,6 @@ static int parse_rgb(const char *buf, struct color_platform *colors)
/*
* Individual RGB zone control
*/
-static int alienware_update_led(struct alienfx_priv *priv, u8 location)
-{
- int method_id;
- acpi_status status;
- char *guid;
- struct acpi_buffer input;
- struct legacy_led_args legacy_args;
- struct wmax_led_args wmax_basic_args;
- if (interface == WMAX) {
- wmax_basic_args.led_mask = 1 << location;
- wmax_basic_args.colors = priv->colors[location];
- wmax_basic_args.state = priv->lighting_control_state;
- guid = WMAX_CONTROL_GUID;
- method_id = WMAX_METHOD_ZONE_CONTROL;
-
- input.length = sizeof(wmax_basic_args);
- input.pointer = &wmax_basic_args;
- } else {
- legacy_args.colors = priv->colors[location];
- legacy_args.brightness = priv->global_brightness;
- legacy_args.state = 0;
- if (priv->lighting_control_state == LEGACY_BOOTING ||
- priv->lighting_control_state == LEGACY_SUSPEND) {
- guid = LEGACY_POWER_CONTROL_GUID;
- legacy_args.state = priv->lighting_control_state;
- } else
- guid = LEGACY_CONTROL_GUID;
- method_id = location + 1;
-
- input.length = sizeof(legacy_args);
- input.pointer = &legacy_args;
- }
- pr_debug("alienware-wmi: guid %s method %d\n", guid, method_id);
-
- status = wmi_evaluate_method(guid, 0, method_id, &input, NULL);
- if (ACPI_FAILURE(status))
- pr_err("alienware-wmi: zone set failure: %u\n", status);
- return ACPI_FAILURE(status);
-}
-
static ssize_t zone_show(struct device *dev, struct device_attribute *attr,
char *buf, u8 location)
{
@@ -509,13 +499,14 @@ static ssize_t zone_store(struct device *dev, struct device_attribute *attr,
{
struct alienfx_priv *priv = dev_get_drvdata(dev);
struct color_platform *colors = &priv->colors[location];
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
int ret;
ret = parse_rgb(buf, colors);
if (ret)
return ret;
- ret = alienware_update_led(priv, location);
+ ret = pdata->ops.upd_led(priv, pdata->wdev, location);
return ret ? ret : count;
}
@@ -651,36 +642,17 @@ static struct attribute_group zone_attribute_group = {
/*
* LED Brightness (Global)
*/
-static int wmax_brightness(int brightness)
-{
- acpi_status status;
- struct acpi_buffer input;
- struct wmax_brightness_args args = {
- .led_mask = 0xFF,
- .percentage = brightness,
- };
- input.length = sizeof(args);
- input.pointer = &args;
- status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0,
- WMAX_METHOD_BRIGHTNESS, &input, NULL);
- if (ACPI_FAILURE(status))
- pr_err("alienware-wmi: brightness set failure: %u\n", status);
- return ACPI_FAILURE(status);
-}
-
static void global_led_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
struct alienfx_priv *priv = container_of(led_cdev, struct alienfx_priv,
global_led);
+ struct alienfx_platdata *pdata = dev_get_platdata(&priv->pdev->dev);
int ret;
priv->global_brightness = brightness;
- if (interface == WMAX)
- ret = wmax_brightness(brightness);
- else
- ret = alienware_update_led(priv, 0);
+ ret = pdata->ops.upd_brightness(priv, pdata->wdev, brightness);
if (ret)
pr_err("LED brightness update failed\n");
}
@@ -1234,10 +1206,49 @@ static void alienware_alienfx_exit(struct wmi_device *wdev)
/*
* Legacy WMI driver
*/
+static int legacy_wmi_update_led(struct alienfx_priv *priv,
+ struct wmi_device *wdev, u8 location)
+{
+ struct legacy_led_args legacy_args = {
+ .colors = priv->colors[location],
+ .brightness = priv->global_brightness,
+ .state = 0,
+ };
+ struct acpi_buffer input;
+ acpi_status status;
+
+ if (legacy_args.state != LEGACY_RUNNING) {
+ legacy_args.state = priv->lighting_control_state;
+
+ input.length = sizeof(legacy_args);
+ input.pointer = &legacy_args;
+
+ status = wmi_evaluate_method(LEGACY_POWER_CONTROL_GUID, 0,
+ location + 1, &input, NULL);
+ if (ACPI_FAILURE(status))
+ return -EIO;
+
+ return 0;
+ }
+
+ return alienware_wmi_command(wdev, location + 1, &legacy_args,
+ sizeof(legacy_args), NULL);
+}
+
+static int legacy_wmi_update_brightness(struct alienfx_priv *priv,
+ struct wmi_device *wdev, u8 brightness)
+{
+ return legacy_wmi_update_led(priv, wdev, 0);
+}
+
static int legacy_wmi_probe(struct wmi_device *wdev, const void *context)
{
struct alienfx_platdata pdata = {
.wdev = wdev,
+ .ops = {
+ .upd_led = legacy_wmi_update_led,
+ .upd_brightness = legacy_wmi_update_brightness,
+ },
};
return alienware_alienfx_setup(&pdata);
@@ -1277,10 +1288,39 @@ static void __exit alienware_legacy_wmi_exit(void)
/*
* WMAX WMI driver
*/
+static int wmax_wmi_update_led(struct alienfx_priv *priv,
+ struct wmi_device *wdev, u8 location)
+{
+ struct wmax_led_args in_args = {
+ .led_mask = 1 << location,
+ .colors = priv->colors[location],
+ .state = priv->lighting_control_state,
+ };
+
+ return alienware_wmi_command(wdev, WMAX_METHOD_ZONE_CONTROL, &in_args,
+ sizeof(in_args), NULL);
+}
+
+static int wmax_wmi_update_brightness(struct alienfx_priv *priv,
+ struct wmi_device *wdev, u8 brightness)
+{
+ struct wmax_brightness_args in_args = {
+ .led_mask = 0xFF,
+ .percentage = brightness,
+ };
+
+ return alienware_wmi_command(wdev, WMAX_METHOD_BRIGHTNESS, &in_args,
+ sizeof(in_args), NULL);
+}
+
static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
{
struct alienfx_platdata pdata = {
.wdev = wdev,
+ .ops = {
+ .upd_led = wmax_wmi_update_led,
+ .upd_brightness = wmax_wmi_update_brightness,
+ },
};
struct platform_device *pdev;
int ret;
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 05/14] platform/x86: alienware-wmi: Refactor hdmi, amplifier, deepslp methods
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (3 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 04/14] platform/x86: alienware-wmi: Refactor LED " Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 06/14] platform/x86: alienware-wmi: Refactor thermal control methods Kurt Borja
` (9 subsequent siblings)
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Refactor show/store methods for hdmi, amplifier, deepslp sysfs groups to
use alienware_wmi_command() instead of alienware_wmax_command() which
uses deprecated WMI methods.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/alienware-wmi.c | 80 +++++++++++++----------
1 file changed, 45 insertions(+), 35 deletions(-)
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index c9d9cf36b87b..7f442428e45e 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -700,53 +700,57 @@ static acpi_status alienware_wmax_command(void *in_args, size_t in_size,
static ssize_t cable_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
struct wmax_basic_args in_args = {
.arg = 0,
};
- acpi_status status;
u32 out_data;
+ int ret;
+
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_CABLE,
+ &in_args, sizeof(in_args), &out_data);
- status =
- alienware_wmax_command(&in_args, sizeof(in_args),
- WMAX_METHOD_HDMI_CABLE, &out_data);
- if (ACPI_SUCCESS(status)) {
+ if (!ret) {
if (out_data == 0)
return sysfs_emit(buf, "[unconnected] connected unknown\n");
else if (out_data == 1)
return sysfs_emit(buf, "unconnected [connected] unknown\n");
}
- pr_err("alienware-wmi: unknown HDMI cable status: %d\n", status);
+
+ pr_err("alienware-wmi: unknown HDMI cable status: %d\n", ret);
return sysfs_emit(buf, "unconnected connected [unknown]\n");
}
static ssize_t source_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
struct wmax_basic_args in_args = {
.arg = 0,
};
- acpi_status status;
u32 out_data;
+ int ret;
- status =
- alienware_wmax_command(&in_args, sizeof(in_args),
- WMAX_METHOD_HDMI_STATUS, &out_data);
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_STATUS,
+ &in_args, sizeof(in_args), &out_data);
- if (ACPI_SUCCESS(status)) {
+ if (!ret) {
if (out_data == 1)
return sysfs_emit(buf, "[input] gpu unknown\n");
else if (out_data == 2)
return sysfs_emit(buf, "input [gpu] unknown\n");
}
- pr_err("alienware-wmi: unknown HDMI source status: %u\n", status);
+
+ pr_err("alienware-wmi: unknown HDMI source status: %u\n", ret);
return sysfs_emit(buf, "input gpu [unknown]\n");
}
static ssize_t source_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
struct wmax_basic_args args;
- acpi_status status;
+ int ret;
if (strcmp(buf, "gpu\n") == 0)
args.arg = 1;
@@ -756,12 +760,12 @@ static ssize_t source_store(struct device *dev, struct device_attribute *attr,
args.arg = 3;
pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf);
- status = alienware_wmax_command(&args, sizeof(args),
- WMAX_METHOD_HDMI_SOURCE, NULL);
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_SOURCE, &args,
+ sizeof(args), NULL);
+
+ if (ret < 0)
+ pr_err("alienware-wmi: HDMI toggle failed: results: %u\n", ret);
- if (ACPI_FAILURE(status))
- pr_err("alienware-wmi: HDMI toggle failed: results: %u\n",
- status);
return count;
}
@@ -794,22 +798,24 @@ static const struct attribute_group hdmi_attribute_group = {
static ssize_t status_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
struct wmax_basic_args in_args = {
.arg = 0,
};
- acpi_status status;
u32 out_data;
+ int ret;
- status =
- alienware_wmax_command(&in_args, sizeof(in_args),
- WMAX_METHOD_AMPLIFIER_CABLE, &out_data);
- if (ACPI_SUCCESS(status)) {
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_AMPLIFIER_CABLE,
+ &in_args, sizeof(in_args), &out_data);
+
+ if (!ret) {
if (out_data == 0)
return sysfs_emit(buf, "[unconnected] connected unknown\n");
else if (out_data == 1)
return sysfs_emit(buf, "unconnected [connected] unknown\n");
}
- pr_err("alienware-wmi: unknown amplifier cable status: %d\n", status);
+
+ pr_err("alienware-wmi: unknown amplifier cable status: %d\n", ret);
return sysfs_emit(buf, "unconnected connected [unknown]\n");
}
@@ -839,15 +845,17 @@ static const struct attribute_group amplifier_attribute_group = {
static ssize_t deepsleep_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
struct wmax_basic_args in_args = {
.arg = 0,
};
- acpi_status status;
u32 out_data;
+ int ret;
- status = alienware_wmax_command(&in_args, sizeof(in_args),
- WMAX_METHOD_DEEP_SLEEP_STATUS, &out_data);
- if (ACPI_SUCCESS(status)) {
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_STATUS,
+ &in_args, sizeof(in_args), &out_data);
+
+ if (!ret) {
if (out_data == 0)
return sysfs_emit(buf, "[disabled] s5 s5_s4\n");
else if (out_data == 1)
@@ -855,15 +863,17 @@ static ssize_t deepsleep_show(struct device *dev, struct device_attribute *attr,
else if (out_data == 2)
return sysfs_emit(buf, "disabled s5 [s5_s4]\n");
}
- pr_err("alienware-wmi: unknown deep sleep status: %d\n", status);
+
+ pr_err("alienware-wmi: unknown deep sleep status: %d\n", ret);
return sysfs_emit(buf, "disabled s5 s5_s4 [unknown]\n");
}
static ssize_t deepsleep_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
struct wmax_basic_args args;
- acpi_status status;
+ int ret;
if (strcmp(buf, "disabled\n") == 0)
args.arg = 0;
@@ -873,12 +883,12 @@ static ssize_t deepsleep_store(struct device *dev, struct device_attribute *attr
args.arg = 2;
pr_debug("alienware-wmi: setting deep sleep to %d : %s", args.arg, buf);
- status = alienware_wmax_command(&args, sizeof(args),
- WMAX_METHOD_DEEP_SLEEP_CONTROL, NULL);
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_CONTROL,
+ &args, sizeof(args), NULL);
+
+ if (!ret)
+ pr_err("alienware-wmi: deep sleep control failed: results: %u\n", ret);
- if (ACPI_FAILURE(status))
- pr_err("alienware-wmi: deep sleep control failed: results: %u\n",
- status);
return count;
}
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 06/14] platform/x86: alienware-wmi: Refactor thermal control methods
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (4 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 05/14] platform/x86: alienware-wmi: Refactor hdmi, amplifier, deepslp methods Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 07/14] platform/x86: alienware-wmi: Split DMI table Kurt Borja
` (8 subsequent siblings)
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Refactor thermal control methods to use alienware_wmi_command() instead
of alienware_wmax_command().
Drop alienware_wmax_command() as there is no more users left.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/alienware-wmi.c | 87 ++++++++---------------
1 file changed, 30 insertions(+), 57 deletions(-)
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index 7f442428e45e..877b3d9d7cab 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -665,34 +665,6 @@ static enum led_brightness global_led_get(struct led_classdev *led_cdev)
return priv->global_brightness;
}
-static acpi_status alienware_wmax_command(void *in_args, size_t in_size,
- u32 command, u32 *out_data)
-{
- acpi_status status;
- union acpi_object *obj;
- struct acpi_buffer input;
- struct acpi_buffer output;
-
- input.length = in_size;
- input.pointer = in_args;
- if (out_data) {
- output.length = ACPI_ALLOCATE_BUFFER;
- output.pointer = NULL;
- status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0,
- command, &input, &output);
- if (ACPI_SUCCESS(status)) {
- obj = (union acpi_object *)output.pointer;
- if (obj && obj->type == ACPI_TYPE_INTEGER)
- *out_data = (u32)obj->integer.value;
- }
- kfree(output.pointer);
- } else {
- status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0,
- command, &input, NULL);
- }
- return status;
-}
-
/*
* The HDMI mux sysfs node indicates the status of the HDMI input mux.
* It can toggle between standard system GPU output and HDMI input.
@@ -938,7 +910,8 @@ static bool is_wmax_thermal_code(u32 code)
return false;
}
-static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data)
+static int wmax_thermal_information(struct wmi_device *wdev, u8 operation,
+ u8 arg, u32 *out_data)
{
struct wmax_u32_args in_args = {
.operation = operation,
@@ -946,14 +919,12 @@ static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data)
.arg2 = 0,
.arg3 = 0,
};
- acpi_status status;
-
- status = alienware_wmax_command(&in_args, sizeof(in_args),
- WMAX_METHOD_THERMAL_INFORMATION,
- out_data);
+ int ret;
- if (ACPI_FAILURE(status))
- return -EIO;
+ ret = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_INFORMATION,
+ &in_args, sizeof(in_args), out_data);
+ if (ret < 0)
+ return ret;
if (*out_data == WMAX_FAILURE_CODE)
return -EBADRQC;
@@ -961,7 +932,7 @@ static int wmax_thermal_information(u8 operation, u8 arg, u32 *out_data)
return 0;
}
-static int wmax_thermal_control(u8 profile)
+static int wmax_thermal_control(struct wmi_device *wdev, u8 profile)
{
struct wmax_u32_args in_args = {
.operation = WMAX_OPERATION_ACTIVATE_PROFILE,
@@ -969,15 +940,13 @@ static int wmax_thermal_control(u8 profile)
.arg2 = 0,
.arg3 = 0,
};
- acpi_status status;
u32 out_data;
+ int ret;
- status = alienware_wmax_command(&in_args, sizeof(in_args),
- WMAX_METHOD_THERMAL_CONTROL,
- &out_data);
-
- if (ACPI_FAILURE(status))
- return -EIO;
+ ret = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_CONTROL,
+ &in_args, sizeof(in_args), &out_data);
+ if (ret)
+ return ret;
if (out_data == WMAX_FAILURE_CODE)
return -EBADRQC;
@@ -985,7 +954,8 @@ static int wmax_thermal_control(u8 profile)
return 0;
}
-static int wmax_game_shift_status(u8 operation, u32 *out_data)
+static int wmax_game_shift_status(struct wmi_device *wdev, u8 operation,
+ u32 *out_data)
{
struct wmax_u32_args in_args = {
.operation = operation,
@@ -993,14 +963,13 @@ static int wmax_game_shift_status(u8 operation, u32 *out_data)
.arg2 = 0,
.arg3 = 0,
};
- acpi_status status;
+ int ret;
- status = alienware_wmax_command(&in_args, sizeof(in_args),
- WMAX_METHOD_GAME_SHIFT_STATUS,
- out_data);
+ ret = alienware_wmi_command(wdev, WMAX_METHOD_GAME_SHIFT_STATUS,
+ &in_args, sizeof(in_args), out_data);
- if (ACPI_FAILURE(status))
- return -EIO;
+ if (ret < 0)
+ return ret;
if (*out_data == WMAX_FAILURE_CODE)
return -EOPNOTSUPP;
@@ -1011,10 +980,11 @@ static int wmax_game_shift_status(u8 operation, u32 *out_data)
static int thermal_profile_get(struct device *dev,
enum platform_profile_option *profile)
{
+ struct awcc_priv *priv = dev_get_drvdata(dev);
u32 out_data;
int ret;
- ret = wmax_thermal_information(WMAX_OPERATION_CURRENT_PROFILE,
+ ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_CURRENT_PROFILE,
0, &out_data);
if (ret < 0)
@@ -1043,7 +1013,8 @@ static int thermal_profile_set(struct device *dev,
u32 gmode_status;
int ret;
- ret = wmax_game_shift_status(WMAX_OPERATION_GET_GAME_SHIFT_STATUS,
+ ret = wmax_game_shift_status(priv->wdev,
+ WMAX_OPERATION_GET_GAME_SHIFT_STATUS,
&gmode_status);
if (ret < 0)
@@ -1051,7 +1022,8 @@ static int thermal_profile_set(struct device *dev,
if ((profile == PLATFORM_PROFILE_PERFORMANCE && !gmode_status) ||
(profile != PLATFORM_PROFILE_PERFORMANCE && gmode_status)) {
- ret = wmax_game_shift_status(WMAX_OPERATION_TOGGLE_GAME_SHIFT,
+ ret = wmax_game_shift_status(priv->wdev,
+ WMAX_OPERATION_TOGGLE_GAME_SHIFT,
&gmode_status);
if (ret < 0)
@@ -1059,7 +1031,8 @@ static int thermal_profile_set(struct device *dev,
}
}
- return wmax_thermal_control(priv->supported_thermal_profiles[profile]);
+ return wmax_thermal_control(priv->wdev,
+ priv->supported_thermal_profiles[profile]);
}
static int thermal_profile_probe(void *drvdata, unsigned long *choices)
@@ -1072,7 +1045,7 @@ static int thermal_profile_probe(void *drvdata, unsigned long *choices)
u32 out_data;
int ret;
- ret = wmax_thermal_information(WMAX_OPERATION_SYS_DESCRIPTION,
+ ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_SYS_DESCRIPTION,
0, (u32 *) &sys_desc);
if (ret < 0)
return ret;
@@ -1080,7 +1053,7 @@ static int thermal_profile_probe(void *drvdata, unsigned long *choices)
first_mode = sys_desc[0] + sys_desc[1];
for (u32 i = 0; i < sys_desc[3]; i++) {
- ret = wmax_thermal_information(WMAX_OPERATION_LIST_IDS,
+ ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_LIST_IDS,
i + first_mode, &out_data);
if (ret == -EIO)
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 07/14] platform/x86: alienware-wmi: Split DMI table
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (5 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 06/14] platform/x86: alienware-wmi: Refactor thermal control methods Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 17:15 ` Kurt Borja
2025-01-19 0:03 ` Armin Wolf
2025-01-17 8:13 ` [PATCH v4 08/14] MAINTAINERS: Update ALIENWARE WMI DRIVER entry Kurt Borja
` (7 subsequent siblings)
14 siblings, 2 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Split thermal features into a new DMI table to support upcoming file
split. While at it:
Rename quirk_entry -> alienfx_features,
Rename quirks -> alienfx
and change hdmi_mux, amplifier and deepslp types to bool, because they are
already being implicitly used as bools.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/alienware-wmi.c | 337 ++++++++++------------
1 file changed, 158 insertions(+), 179 deletions(-)
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index 877b3d9d7cab..5d9816521072 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -113,102 +113,68 @@ static const enum platform_profile_option wmax_mode_to_platform_profile[THERMAL_
[THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE,
};
-struct quirk_entry {
+struct alienfx_quirks {
u8 num_zones;
- u8 hdmi_mux;
- u8 amplifier;
- u8 deepslp;
- bool thermal;
- bool gmode;
+ bool hdmi_mux;
+ bool amplifier;
+ bool deepslp;
};
-static struct quirk_entry *quirks;
+static struct alienfx_quirks *alienfx;
-static struct quirk_entry quirk_inspiron5675 = {
+static struct alienfx_quirks quirk_inspiron5675 = {
.num_zones = 2,
- .hdmi_mux = 0,
- .amplifier = 0,
- .deepslp = 0,
- .thermal = false,
- .gmode = false,
+ .hdmi_mux = false,
+ .amplifier = false,
+ .deepslp = false,
};
-static struct quirk_entry quirk_unknown = {
+static struct alienfx_quirks quirk_unknown = {
.num_zones = 2,
- .hdmi_mux = 0,
- .amplifier = 0,
- .deepslp = 0,
- .thermal = false,
- .gmode = false,
+ .hdmi_mux = false,
+ .amplifier = false,
+ .deepslp = false,
};
-static struct quirk_entry quirk_x51_r1_r2 = {
+static struct alienfx_quirks quirk_x51_r1_r2 = {
.num_zones = 3,
- .hdmi_mux = 0,
- .amplifier = 0,
- .deepslp = 0,
- .thermal = false,
- .gmode = false,
+ .hdmi_mux = false,
+ .amplifier = false,
+ .deepslp = false,
};
-static struct quirk_entry quirk_x51_r3 = {
+static struct alienfx_quirks quirk_x51_r3 = {
.num_zones = 4,
- .hdmi_mux = 0,
- .amplifier = 1,
- .deepslp = 0,
- .thermal = false,
- .gmode = false,
+ .hdmi_mux = false,
+ .amplifier = true,
+ .deepslp = false,
};
-static struct quirk_entry quirk_asm100 = {
+static struct alienfx_quirks quirk_asm100 = {
.num_zones = 2,
- .hdmi_mux = 1,
- .amplifier = 0,
- .deepslp = 0,
- .thermal = false,
- .gmode = false,
+ .hdmi_mux = true,
+ .amplifier = false,
+ .deepslp = false,
};
-static struct quirk_entry quirk_asm200 = {
+static struct alienfx_quirks quirk_asm200 = {
.num_zones = 2,
- .hdmi_mux = 1,
- .amplifier = 0,
- .deepslp = 1,
- .thermal = false,
- .gmode = false,
+ .hdmi_mux = true,
+ .amplifier = false,
+ .deepslp = true,
};
-static struct quirk_entry quirk_asm201 = {
+static struct alienfx_quirks quirk_asm201 = {
.num_zones = 2,
- .hdmi_mux = 1,
- .amplifier = 1,
- .deepslp = 1,
- .thermal = false,
- .gmode = false,
-};
-
-static struct quirk_entry quirk_g_series = {
- .num_zones = 2,
- .hdmi_mux = 0,
- .amplifier = 0,
- .deepslp = 0,
- .thermal = true,
- .gmode = true,
-};
-
-static struct quirk_entry quirk_x_series = {
- .num_zones = 2,
- .hdmi_mux = 0,
- .amplifier = 0,
- .deepslp = 0,
- .thermal = true,
- .gmode = false,
+ .hdmi_mux = true,
+ .amplifier = true,
+ .deepslp = true,
};
static int __init dmi_matched(const struct dmi_system_id *dmi)
{
- quirks = dmi->driver_data;
+ alienfx = dmi->driver_data;
return 1;
}
@@ -240,42 +206,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = {
},
.driver_data = &quirk_asm201,
},
- {
- .callback = dmi_matched,
- .ident = "Alienware m17 R5",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
- },
- .driver_data = &quirk_x_series,
- },
- {
- .callback = dmi_matched,
- .ident = "Alienware m18 R2",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"),
- },
- .driver_data = &quirk_x_series,
- },
- {
- .callback = dmi_matched,
- .ident = "Alienware x15 R1",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"),
- },
- .driver_data = &quirk_x_series,
- },
- {
- .callback = dmi_matched,
- .ident = "Alienware x17 R2",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"),
- },
- .driver_data = &quirk_x_series,
- },
{
.callback = dmi_matched,
.ident = "Alienware X51 R1",
@@ -303,60 +233,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = {
},
.driver_data = &quirk_x51_r3,
},
- {
- .callback = dmi_matched,
- .ident = "Dell Inc. G15 5510",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
- },
- .driver_data = &quirk_g_series,
- },
- {
- .callback = dmi_matched,
- .ident = "Dell Inc. G15 5511",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"),
- },
- .driver_data = &quirk_g_series,
- },
- {
- .callback = dmi_matched,
- .ident = "Dell Inc. G15 5515",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
- },
- .driver_data = &quirk_g_series,
- },
- {
- .callback = dmi_matched,
- .ident = "Dell Inc. G3 3500",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"),
- },
- .driver_data = &quirk_g_series,
- },
- {
- .callback = dmi_matched,
- .ident = "Dell Inc. G3 3590",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"),
- },
- .driver_data = &quirk_g_series,
- },
- {
- .callback = dmi_matched,
- .ident = "Dell Inc. G5 5500",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"),
- },
- .driver_data = &quirk_g_series,
- },
{
.callback = dmi_matched,
.ident = "Dell Inc. Inspiron 5675",
@@ -431,6 +307,103 @@ struct alienfx_platdata {
static u8 interface;
+struct awcc_quirks {
+ bool gmode;
+};
+
+static struct awcc_quirks g_series_quirks = {
+ .gmode = true,
+};
+
+static struct awcc_quirks generic_quirks = {
+ .gmode = false,
+};
+
+static const struct dmi_system_id awcc_dmi_table[] __initconst = {
+ {
+ .ident = "Alienware m17 R5",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
+ },
+ .driver_data = &generic_quirks,
+ },
+ {
+ .ident = "Alienware m18 R2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"),
+ },
+ .driver_data = &generic_quirks,
+ },
+ {
+ .ident = "Alienware x15 R1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"),
+ },
+ .driver_data = &generic_quirks,
+ },
+ {
+ .ident = "Alienware x17 R2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"),
+ },
+ .driver_data = &generic_quirks,
+ },
+ {
+ .ident = "Dell Inc. G15 5510",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G15 5511",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G15 5515",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G3 3500",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G3 3590",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G5 5500",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+};
+
+struct awcc_quirks *awcc;
+
static int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
void *in_args, size_t in_size, u32 *out_data)
{
@@ -612,7 +585,7 @@ static DEVICE_ATTR_RW(lighting_control_state);
static umode_t zone_attr_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
- if (n < quirks->num_zones + 1)
+ if (n < alienfx->num_zones + 1)
return attr->mode;
return 0;
@@ -620,7 +593,7 @@ static umode_t zone_attr_visible(struct kobject *kobj,
static bool zone_group_visible(struct kobject *kobj)
{
- return quirks->num_zones > 0;
+ return alienfx->num_zones > 0;
}
DEFINE_SYSFS_GROUP_VISIBLE(zone);
@@ -746,7 +719,7 @@ static DEVICE_ATTR_RW(source);
static bool hdmi_group_visible(struct kobject *kobj)
{
- return quirks->hdmi_mux;
+ return alienfx->hdmi_mux;
}
DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi);
@@ -795,7 +768,7 @@ static DEVICE_ATTR_RO(status);
static bool amplifier_group_visible(struct kobject *kobj)
{
- return quirks->amplifier;
+ return alienfx->amplifier;
}
DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier);
@@ -868,7 +841,7 @@ static DEVICE_ATTR_RW(deepsleep);
static bool deepsleep_group_visible(struct kobject *kobj)
{
- return quirks->deepslp;
+ return alienfx->deepslp;
}
DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep);
@@ -1009,7 +982,7 @@ static int thermal_profile_set(struct device *dev,
{
struct awcc_priv *priv = dev_get_drvdata(dev);
- if (quirks->gmode) {
+ if (awcc->gmode) {
u32 gmode_status;
int ret;
@@ -1075,7 +1048,7 @@ static int thermal_profile_probe(void *drvdata, unsigned long *choices)
if (bitmap_empty(choices, PLATFORM_PROFILE_LAST))
return -ENODEV;
- if (quirks->gmode) {
+ if (awcc->gmode) {
priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =
WMAX_THERMAL_MODE_GMODE;
@@ -1308,7 +1281,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
struct platform_device *pdev;
int ret;
- if (quirks->thermal) {
+ if (awcc) {
return alienware_awcc_setup(wdev);
} else {
ret = alienware_alienfx_setup(&pdata);
@@ -1329,7 +1302,7 @@ static void wmax_wmi_remove(struct wmi_device *wdev)
{
struct platform_device *pdev;
- if (!quirks->thermal) {
+ if (!awcc) {
pdev = dev_get_drvdata(&wdev->dev);
device_remove_groups(&pdev->dev, wmax_alienfx_groups);
@@ -1355,6 +1328,22 @@ static struct wmi_driver alienware_wmax_wmi_driver = {
static int __init alienware_wmax_wmi_init(void)
{
+ const struct dmi_system_id *id;
+
+ id = dmi_first_match(awcc_dmi_table);
+ if (id)
+ awcc = id->driver_data;
+
+ if (force_platform_profile)
+ awcc = &generic_quirks;
+
+ if (force_gmode) {
+ if (awcc)
+ awcc->gmode = true;
+ else
+ pr_warn("force_gmode requires platform profile support\n");
+ }
+
return wmi_driver_register(&alienware_wmax_wmi_driver);
}
@@ -1368,18 +1357,8 @@ static int __init alienware_wmi_init(void)
int ret;
dmi_check_system(alienware_quirks);
- if (quirks == NULL)
- quirks = &quirk_unknown;
-
- if (force_platform_profile)
- quirks->thermal = true;
-
- if (force_gmode) {
- if (quirks->thermal)
- quirks->gmode = true;
- else
- pr_warn("force_gmode requires platform profile support\n");
- }
+ if (!alienfx)
+ alienfx = &quirk_unknown;
if (wmi_has_guid(WMAX_CONTROL_GUID)) {
interface = WMAX;
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 08/14] MAINTAINERS: Update ALIENWARE WMI DRIVER entry
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (6 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 07/14] platform/x86: alienware-wmi: Split DMI table Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 09/14] platform/x86: Rename alienware-wmi.c Kurt Borja
` (6 subsequent siblings)
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Dell has been inactive in its maintainership role of this driver since
around 2021. Due to this, add myself as a maintainer and update path
to support upcoming changes.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
MAINTAINERS | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 3809931b9240..596c6a46478c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -784,10 +784,12 @@ F: Documentation/admin-guide/perf/alibaba_pmu.rst
F: drivers/perf/alibaba_uncore_drw_pmu.c
ALIENWARE WMI DRIVER
+M: Kurt Borja <kuurtb@gmail.com>
+L: platform-driver-x86@vger.kernel.org
L: Dell.Client.Kernel@dell.com
S: Maintained
F: Documentation/wmi/devices/alienware-wmi.rst
-F: drivers/platform/x86/dell/alienware-wmi.c
+F: drivers/platform/x86/dell/alienware-wmi*
ALLEGRO DVT VIDEO IP CORE DRIVER
M: Michael Tretter <m.tretter@pengutronix.de>
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 09/14] platform/x86: Rename alienware-wmi.c
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (7 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 08/14] MAINTAINERS: Update ALIENWARE WMI DRIVER entry Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 10/14] platform/x86: Add alienware-wmi.h Kurt Borja
` (5 subsequent siblings)
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Rename alienware-wmi to support upcoming split.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/Makefile | 1 +
.../platform/x86/dell/{alienware-wmi.c => alienware-wmi-base.c} | 0
2 files changed, 1 insertion(+)
rename drivers/platform/x86/dell/{alienware-wmi.c => alienware-wmi-base.c} (100%)
diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile
index bb3cbd470a46..f8aec8502c2f 100644
--- a/drivers/platform/x86/dell/Makefile
+++ b/drivers/platform/x86/dell/Makefile
@@ -5,6 +5,7 @@
#
obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o
+alienware-wmi-objs := alienware-wmi-base.o
obj-$(CONFIG_DCDBAS) += dcdbas.o
obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi-base.c
similarity index 100%
rename from drivers/platform/x86/dell/alienware-wmi.c
rename to drivers/platform/x86/dell/alienware-wmi-base.c
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 10/14] platform/x86: Add alienware-wmi.h
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (8 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 09/14] platform/x86: Rename alienware-wmi.c Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 11/14] platform/x86: Split the alienware-wmi driver Kurt Borja
` (4 subsequent siblings)
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Add a header file for alienware-wmi with shared resources to support the
upcoming file split.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
.../platform/x86/dell/alienware-wmi-base.c | 69 +++-------------
drivers/platform/x86/dell/alienware-wmi.h | 80 +++++++++++++++++++
2 files changed, 90 insertions(+), 59 deletions(-)
create mode 100644 drivers/platform/x86/dell/alienware-wmi.h
diff --git a/drivers/platform/x86/dell/alienware-wmi-base.c b/drivers/platform/x86/dell/alienware-wmi-base.c
index 5d9816521072..702bf21988f2 100644
--- a/drivers/platform/x86/dell/alienware-wmi-base.c
+++ b/drivers/platform/x86/dell/alienware-wmi-base.c
@@ -16,10 +16,7 @@
#include <linux/dmi.h>
#include <linux/leds.h>
#include <linux/wmi.h>
-
-#define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492"
-#define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492"
-#define WMAX_CONTROL_GUID "A70591CE-A997-11DA-B012-B622A1EF5492"
+#include "alienware-wmi.h"
#define WMAX_METHOD_HDMI_SOURCE 0x1
#define WMAX_METHOD_HDMI_STATUS 0x2
@@ -54,18 +51,6 @@ enum INTERFACE_FLAGS {
WMAX,
};
-enum LEGACY_CONTROL_STATES {
- LEGACY_RUNNING = 1,
- LEGACY_BOOTING = 0,
- LEGACY_SUSPEND = 3,
-};
-
-enum WMAX_CONTROL_STATES {
- WMAX_RUNNING = 0xFF,
- WMAX_BOOTING = 0,
- WMAX_SUSPEND = 3,
-};
-
enum WMAX_THERMAL_INFORMATION_OPERATIONS {
WMAX_OPERATION_SYS_DESCRIPTION = 0x02,
WMAX_OPERATION_LIST_IDS = 0x03,
@@ -113,15 +98,7 @@ static const enum platform_profile_option wmax_mode_to_platform_profile[THERMAL_
[THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE,
};
-struct alienfx_quirks {
- u8 num_zones;
- bool hdmi_mux;
- bool amplifier;
- bool deepslp;
-};
-
-static struct alienfx_quirks *alienfx;
-
+struct alienfx_quirks *alienfx;
static struct alienfx_quirks quirk_inspiron5675 = {
.num_zones = 2,
@@ -245,12 +222,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = {
{}
};
-struct color_platform {
- u8 blue;
- u8 green;
- u8 red;
-} __packed;
-
struct wmax_brightness_args {
u32 led_mask;
u32 percentage;
@@ -285,26 +256,6 @@ struct awcc_priv {
enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
};
-struct alienfx_priv {
- struct platform_device *pdev;
- struct led_classdev global_led;
- struct color_platform colors[4];
- u8 global_brightness;
- u8 lighting_control_state;
-};
-
-struct alienfx_ops {
- int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev,
- u8 location);
- int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev,
- u8 brightness);
-};
-
-struct alienfx_platdata {
- struct wmi_device *wdev;
- struct alienfx_ops ops;
-};
-
static u8 interface;
struct awcc_quirks {
@@ -404,8 +355,8 @@ static const struct dmi_system_id awcc_dmi_table[] __initconst = {
struct awcc_quirks *awcc;
-static int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
- void *in_args, size_t in_size, u32 *out_data)
+int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
+ void *in_args, size_t in_size, u32 *out_data)
{
struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_buffer in = {in_size, in_args};
@@ -1128,7 +1079,7 @@ static struct platform_driver platform_driver = {
.probe = alienfx_probe,
};
-static int alienware_alienfx_setup(struct alienfx_platdata *pdata)
+int alienware_alienfx_setup(struct alienfx_platdata *pdata)
{
struct platform_device *pdev;
int ret;
@@ -1151,7 +1102,7 @@ static int alienware_alienfx_setup(struct alienfx_platdata *pdata)
return 0;
}
-static void alienware_alienfx_exit(struct wmi_device *wdev)
+void alienware_alienfx_exit(struct wmi_device *wdev)
{
struct platform_device *pdev = dev_get_drvdata(&wdev->dev);
@@ -1231,12 +1182,12 @@ static struct wmi_driver alienware_legacy_wmi_driver = {
.remove = legacy_wmi_remove,
};
-static int __init alienware_legacy_wmi_init(void)
+int __init alienware_legacy_wmi_init(void)
{
return wmi_driver_register(&alienware_legacy_wmi_driver);
}
-static void __exit alienware_legacy_wmi_exit(void)
+void __exit alienware_legacy_wmi_exit(void)
{
wmi_driver_unregister(&alienware_legacy_wmi_driver);
}
@@ -1326,7 +1277,7 @@ static struct wmi_driver alienware_wmax_wmi_driver = {
.remove = wmax_wmi_remove,
};
-static int __init alienware_wmax_wmi_init(void)
+int __init alienware_wmax_wmi_init(void)
{
const struct dmi_system_id *id;
@@ -1347,7 +1298,7 @@ static int __init alienware_wmax_wmi_init(void)
return wmi_driver_register(&alienware_wmax_wmi_driver);
}
-static void __exit alienware_wmax_wmi_exit(void)
+void __exit alienware_wmax_wmi_exit(void)
{
wmi_driver_unregister(&alienware_wmax_wmi_driver);
}
diff --git a/drivers/platform/x86/dell/alienware-wmi.h b/drivers/platform/x86/dell/alienware-wmi.h
new file mode 100644
index 000000000000..00b7505e1073
--- /dev/null
+++ b/drivers/platform/x86/dell/alienware-wmi.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Alienware WMI special features driver
+ *
+ * Copyright (C) 2014 Dell Inc <Dell.Client.Kernel@dell.com>
+ * Copyright (C) 2024 Kurt Borja <kuurtb@gmail.com>
+ */
+
+#ifndef _ALIENWARE_WMI_H_
+#define _ALIENWARE_WMI_H_
+
+#include <linux/leds.h>
+#include <linux/platform_device.h>
+#include <linux/wmi.h>
+
+#define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492"
+#define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492"
+#define WMAX_CONTROL_GUID "A70591CE-A997-11DA-B012-B622A1EF5492"
+
+extern struct alienfx_quirks *alienfx;
+
+enum LEGACY_CONTROL_STATES {
+ LEGACY_RUNNING = 1,
+ LEGACY_BOOTING = 0,
+ LEGACY_SUSPEND = 3,
+};
+
+enum WMAX_CONTROL_STATES {
+ WMAX_RUNNING = 0xFF,
+ WMAX_BOOTING = 0,
+ WMAX_SUSPEND = 3,
+};
+
+struct alienfx_quirks {
+ u8 num_zones;
+ bool hdmi_mux;
+ bool amplifier;
+ bool deepslp;
+};
+
+struct color_platform {
+ u8 blue;
+ u8 green;
+ u8 red;
+} __packed;
+
+struct alienfx_priv {
+ struct platform_device *pdev;
+ struct alienfx_quirks *quirks;
+ struct led_classdev global_led;
+ struct color_platform colors[4];
+ u8 global_brightness;
+ u8 lighting_control_state;
+};
+
+struct alienfx_ops {
+ int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev,
+ u8 location);
+ int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev,
+ u8 brightness);
+};
+
+struct alienfx_platdata {
+ struct wmi_device *wdev;
+ struct alienfx_ops ops;
+};
+
+int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
+ void *in_args, size_t in_size, u32 *out_data);
+
+int alienware_alienfx_setup(struct alienfx_platdata *pdata);
+void alienware_alienfx_exit(struct wmi_device *wdev);
+
+int __init alienware_legacy_wmi_init(void);
+void __exit alienware_legacy_wmi_exit(void);
+
+int __init alienware_wmax_wmi_init(void);
+void __exit alienware_wmax_wmi_exit(void);
+
+#endif
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 11/14] platform/x86: Split the alienware-wmi driver
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (9 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 10/14] platform/x86: Add alienware-wmi.h Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 12/14] platform/x86: dell: Modify Makefile alignment Kurt Borja
` (3 subsequent siblings)
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Split alienware-wmi WMI drivers into different files. This is done
seamlessly by copying and pasting, however some blocks are reordered.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/Makefile | 2 +
.../platform/x86/dell/alienware-wmi-base.c | 849 ------------------
.../platform/x86/dell/alienware-wmi-legacy.c | 100 +++
.../platform/x86/dell/alienware-wmi-wmax.c | 773 ++++++++++++++++
drivers/platform/x86/dell/alienware-wmi.h | 1 -
5 files changed, 875 insertions(+), 850 deletions(-)
create mode 100644 drivers/platform/x86/dell/alienware-wmi-legacy.c
create mode 100644 drivers/platform/x86/dell/alienware-wmi-wmax.c
diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile
index f8aec8502c2f..03ba459f3d31 100644
--- a/drivers/platform/x86/dell/Makefile
+++ b/drivers/platform/x86/dell/Makefile
@@ -6,6 +6,8 @@
obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o
alienware-wmi-objs := alienware-wmi-base.o
+alienware-wmi-y += alienware-wmi-legacy.o
+alienware-wmi-y += alienware-wmi-wmax.o
obj-$(CONFIG_DCDBAS) += dcdbas.o
obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o
diff --git a/drivers/platform/x86/dell/alienware-wmi-base.c b/drivers/platform/x86/dell/alienware-wmi-base.c
index 702bf21988f2..e55c962c84d7 100644
--- a/drivers/platform/x86/dell/alienware-wmi-base.c
+++ b/drivers/platform/x86/dell/alienware-wmi-base.c
@@ -8,96 +8,21 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/acpi.h>
-#include <linux/bitfield.h>
-#include <linux/bits.h>
#include <linux/module.h>
#include <linux/platform_device.h>
-#include <linux/platform_profile.h>
#include <linux/dmi.h>
#include <linux/leds.h>
-#include <linux/wmi.h>
#include "alienware-wmi.h"
-#define WMAX_METHOD_HDMI_SOURCE 0x1
-#define WMAX_METHOD_HDMI_STATUS 0x2
-#define WMAX_METHOD_BRIGHTNESS 0x3
-#define WMAX_METHOD_ZONE_CONTROL 0x4
-#define WMAX_METHOD_HDMI_CABLE 0x5
-#define WMAX_METHOD_AMPLIFIER_CABLE 0x6
-#define WMAX_METHOD_DEEP_SLEEP_CONTROL 0x0B
-#define WMAX_METHOD_DEEP_SLEEP_STATUS 0x0C
-#define WMAX_METHOD_THERMAL_INFORMATION 0x14
-#define WMAX_METHOD_THERMAL_CONTROL 0x15
-#define WMAX_METHOD_GAME_SHIFT_STATUS 0x25
-
-#define WMAX_THERMAL_MODE_GMODE 0xAB
-
-#define WMAX_FAILURE_CODE 0xFFFFFFFF
-
MODULE_AUTHOR("Mario Limonciello <mario.limonciello@outlook.com>");
MODULE_DESCRIPTION("Alienware special feature control");
MODULE_LICENSE("GPL");
-static bool force_platform_profile;
-module_param_unsafe(force_platform_profile, bool, 0);
-MODULE_PARM_DESC(force_platform_profile, "Forces auto-detecting thermal profiles without checking if WMI thermal backend is available");
-
-static bool force_gmode;
-module_param_unsafe(force_gmode, bool, 0);
-MODULE_PARM_DESC(force_gmode, "Forces G-Mode when performance profile is selected");
-
enum INTERFACE_FLAGS {
LEGACY,
WMAX,
};
-enum WMAX_THERMAL_INFORMATION_OPERATIONS {
- WMAX_OPERATION_SYS_DESCRIPTION = 0x02,
- WMAX_OPERATION_LIST_IDS = 0x03,
- WMAX_OPERATION_CURRENT_PROFILE = 0x0B,
-};
-
-enum WMAX_THERMAL_CONTROL_OPERATIONS {
- WMAX_OPERATION_ACTIVATE_PROFILE = 0x01,
-};
-
-enum WMAX_GAME_SHIFT_STATUS_OPERATIONS {
- WMAX_OPERATION_TOGGLE_GAME_SHIFT = 0x01,
- WMAX_OPERATION_GET_GAME_SHIFT_STATUS = 0x02,
-};
-
-enum WMAX_THERMAL_TABLES {
- WMAX_THERMAL_TABLE_BASIC = 0x90,
- WMAX_THERMAL_TABLE_USTT = 0xA0,
-};
-
-enum wmax_thermal_mode {
- THERMAL_MODE_USTT_BALANCED,
- THERMAL_MODE_USTT_BALANCED_PERFORMANCE,
- THERMAL_MODE_USTT_COOL,
- THERMAL_MODE_USTT_QUIET,
- THERMAL_MODE_USTT_PERFORMANCE,
- THERMAL_MODE_USTT_LOW_POWER,
- THERMAL_MODE_BASIC_QUIET,
- THERMAL_MODE_BASIC_BALANCED,
- THERMAL_MODE_BASIC_BALANCED_PERFORMANCE,
- THERMAL_MODE_BASIC_PERFORMANCE,
- THERMAL_MODE_LAST,
-};
-
-static const enum platform_profile_option wmax_mode_to_platform_profile[THERMAL_MODE_LAST] = {
- [THERMAL_MODE_USTT_BALANCED] = PLATFORM_PROFILE_BALANCED,
- [THERMAL_MODE_USTT_BALANCED_PERFORMANCE] = PLATFORM_PROFILE_BALANCED_PERFORMANCE,
- [THERMAL_MODE_USTT_COOL] = PLATFORM_PROFILE_COOL,
- [THERMAL_MODE_USTT_QUIET] = PLATFORM_PROFILE_QUIET,
- [THERMAL_MODE_USTT_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE,
- [THERMAL_MODE_USTT_LOW_POWER] = PLATFORM_PROFILE_LOW_POWER,
- [THERMAL_MODE_BASIC_QUIET] = PLATFORM_PROFILE_QUIET,
- [THERMAL_MODE_BASIC_BALANCED] = PLATFORM_PROFILE_BALANCED,
- [THERMAL_MODE_BASIC_BALANCED_PERFORMANCE] = PLATFORM_PROFILE_BALANCED_PERFORMANCE,
- [THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE,
-};
-
struct alienfx_quirks *alienfx;
static struct alienfx_quirks quirk_inspiron5675 = {
@@ -222,139 +147,8 @@ static const struct dmi_system_id alienware_quirks[] __initconst = {
{}
};
-struct wmax_brightness_args {
- u32 led_mask;
- u32 percentage;
-};
-
-struct wmax_basic_args {
- u8 arg;
-};
-
-struct legacy_led_args {
- struct color_platform colors;
- u8 brightness;
- u8 state;
-} __packed;
-
-struct wmax_led_args {
- u32 led_mask;
- struct color_platform colors;
- u8 state;
-} __packed;
-
-struct wmax_u32_args {
- u8 operation;
- u8 arg1;
- u8 arg2;
- u8 arg3;
-};
-
-struct awcc_priv {
- struct wmi_device *wdev;
- struct device *ppdev;
- enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
-};
-
static u8 interface;
-struct awcc_quirks {
- bool gmode;
-};
-
-static struct awcc_quirks g_series_quirks = {
- .gmode = true,
-};
-
-static struct awcc_quirks generic_quirks = {
- .gmode = false,
-};
-
-static const struct dmi_system_id awcc_dmi_table[] __initconst = {
- {
- .ident = "Alienware m17 R5",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
- },
- .driver_data = &generic_quirks,
- },
- {
- .ident = "Alienware m18 R2",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"),
- },
- .driver_data = &generic_quirks,
- },
- {
- .ident = "Alienware x15 R1",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"),
- },
- .driver_data = &generic_quirks,
- },
- {
- .ident = "Alienware x17 R2",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
- DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"),
- },
- .driver_data = &generic_quirks,
- },
- {
- .ident = "Dell Inc. G15 5510",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
- },
- .driver_data = &g_series_quirks,
- },
- {
- .ident = "Dell Inc. G15 5511",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"),
- },
- .driver_data = &g_series_quirks,
- },
- {
- .ident = "Dell Inc. G15 5515",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
- },
- .driver_data = &g_series_quirks,
- },
- {
- .ident = "Dell Inc. G3 3500",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"),
- },
- .driver_data = &g_series_quirks,
- },
- {
- .ident = "Dell Inc. G3 3590",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"),
- },
- .driver_data = &g_series_quirks,
- },
- {
- .ident = "Dell Inc. G5 5500",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
- DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"),
- },
- .driver_data = &g_series_quirks,
- },
-};
-
-struct awcc_quirks *awcc;
-
int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
void *in_args, size_t in_size, u32 *out_data)
{
@@ -589,449 +383,6 @@ static enum led_brightness global_led_get(struct led_classdev *led_cdev)
return priv->global_brightness;
}
-/*
- * The HDMI mux sysfs node indicates the status of the HDMI input mux.
- * It can toggle between standard system GPU output and HDMI input.
- */
-static ssize_t cable_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct alienfx_platdata *pdata = dev_get_platdata(dev);
- struct wmax_basic_args in_args = {
- .arg = 0,
- };
- u32 out_data;
- int ret;
-
- ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_CABLE,
- &in_args, sizeof(in_args), &out_data);
-
- if (!ret) {
- if (out_data == 0)
- return sysfs_emit(buf, "[unconnected] connected unknown\n");
- else if (out_data == 1)
- return sysfs_emit(buf, "unconnected [connected] unknown\n");
- }
-
- pr_err("alienware-wmi: unknown HDMI cable status: %d\n", ret);
- return sysfs_emit(buf, "unconnected connected [unknown]\n");
-}
-
-static ssize_t source_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct alienfx_platdata *pdata = dev_get_platdata(dev);
- struct wmax_basic_args in_args = {
- .arg = 0,
- };
- u32 out_data;
- int ret;
-
- ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_STATUS,
- &in_args, sizeof(in_args), &out_data);
-
- if (!ret) {
- if (out_data == 1)
- return sysfs_emit(buf, "[input] gpu unknown\n");
- else if (out_data == 2)
- return sysfs_emit(buf, "input [gpu] unknown\n");
- }
-
- pr_err("alienware-wmi: unknown HDMI source status: %u\n", ret);
- return sysfs_emit(buf, "input gpu [unknown]\n");
-}
-
-static ssize_t source_store(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct alienfx_platdata *pdata = dev_get_platdata(dev);
- struct wmax_basic_args args;
- int ret;
-
- if (strcmp(buf, "gpu\n") == 0)
- args.arg = 1;
- else if (strcmp(buf, "input\n") == 0)
- args.arg = 2;
- else
- args.arg = 3;
- pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf);
-
- ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_SOURCE, &args,
- sizeof(args), NULL);
-
- if (ret < 0)
- pr_err("alienware-wmi: HDMI toggle failed: results: %u\n", ret);
-
- return count;
-}
-
-static DEVICE_ATTR_RO(cable);
-static DEVICE_ATTR_RW(source);
-
-static bool hdmi_group_visible(struct kobject *kobj)
-{
- return alienfx->hdmi_mux;
-}
-DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi);
-
-static struct attribute *hdmi_attrs[] = {
- &dev_attr_cable.attr,
- &dev_attr_source.attr,
- NULL,
-};
-
-static const struct attribute_group hdmi_attribute_group = {
- .name = "hdmi",
- .is_visible = SYSFS_GROUP_VISIBLE(hdmi),
- .attrs = hdmi_attrs,
-};
-
-/*
- * Alienware GFX amplifier support
- * - Currently supports reading cable status
- * - Leaving expansion room to possibly support dock/undock events later
- */
-static ssize_t status_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct alienfx_platdata *pdata = dev_get_platdata(dev);
- struct wmax_basic_args in_args = {
- .arg = 0,
- };
- u32 out_data;
- int ret;
-
- ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_AMPLIFIER_CABLE,
- &in_args, sizeof(in_args), &out_data);
-
- if (!ret) {
- if (out_data == 0)
- return sysfs_emit(buf, "[unconnected] connected unknown\n");
- else if (out_data == 1)
- return sysfs_emit(buf, "unconnected [connected] unknown\n");
- }
-
- pr_err("alienware-wmi: unknown amplifier cable status: %d\n", ret);
- return sysfs_emit(buf, "unconnected connected [unknown]\n");
-}
-
-static DEVICE_ATTR_RO(status);
-
-static bool amplifier_group_visible(struct kobject *kobj)
-{
- return alienfx->amplifier;
-}
-DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier);
-
-static struct attribute *amplifier_attrs[] = {
- &dev_attr_status.attr,
- NULL,
-};
-
-static const struct attribute_group amplifier_attribute_group = {
- .name = "amplifier",
- .is_visible = SYSFS_GROUP_VISIBLE(amplifier),
- .attrs = amplifier_attrs,
-};
-
-/*
- * Deep Sleep Control support
- * - Modifies BIOS setting for deep sleep control allowing extra wakeup events
- */
-static ssize_t deepsleep_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct alienfx_platdata *pdata = dev_get_platdata(dev);
- struct wmax_basic_args in_args = {
- .arg = 0,
- };
- u32 out_data;
- int ret;
-
- ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_STATUS,
- &in_args, sizeof(in_args), &out_data);
-
- if (!ret) {
- if (out_data == 0)
- return sysfs_emit(buf, "[disabled] s5 s5_s4\n");
- else if (out_data == 1)
- return sysfs_emit(buf, "disabled [s5] s5_s4\n");
- else if (out_data == 2)
- return sysfs_emit(buf, "disabled s5 [s5_s4]\n");
- }
-
- pr_err("alienware-wmi: unknown deep sleep status: %d\n", ret);
- return sysfs_emit(buf, "disabled s5 s5_s4 [unknown]\n");
-}
-
-static ssize_t deepsleep_store(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct alienfx_platdata *pdata = dev_get_platdata(dev);
- struct wmax_basic_args args;
- int ret;
-
- if (strcmp(buf, "disabled\n") == 0)
- args.arg = 0;
- else if (strcmp(buf, "s5\n") == 0)
- args.arg = 1;
- else
- args.arg = 2;
- pr_debug("alienware-wmi: setting deep sleep to %d : %s", args.arg, buf);
-
- ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_CONTROL,
- &args, sizeof(args), NULL);
-
- if (!ret)
- pr_err("alienware-wmi: deep sleep control failed: results: %u\n", ret);
-
- return count;
-}
-
-static DEVICE_ATTR_RW(deepsleep);
-
-static bool deepsleep_group_visible(struct kobject *kobj)
-{
- return alienfx->deepslp;
-}
-DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep);
-
-static struct attribute *deepsleep_attrs[] = {
- &dev_attr_deepsleep.attr,
- NULL,
-};
-
-static const struct attribute_group deepsleep_attribute_group = {
- .name = "deepsleep",
- .is_visible = SYSFS_GROUP_VISIBLE(deepsleep),
- .attrs = deepsleep_attrs,
-};
-
-/*
- * Thermal Profile control
- * - Provides thermal profile control through the Platform Profile API
- */
-#define WMAX_THERMAL_TABLE_MASK GENMASK(7, 4)
-#define WMAX_THERMAL_MODE_MASK GENMASK(3, 0)
-#define WMAX_SENSOR_ID_MASK BIT(8)
-
-static bool is_wmax_thermal_code(u32 code)
-{
- if (code & WMAX_SENSOR_ID_MASK)
- return false;
-
- if ((code & WMAX_THERMAL_MODE_MASK) >= THERMAL_MODE_LAST)
- return false;
-
- if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_BASIC &&
- (code & WMAX_THERMAL_MODE_MASK) >= THERMAL_MODE_BASIC_QUIET)
- return true;
-
- if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_USTT &&
- (code & WMAX_THERMAL_MODE_MASK) <= THERMAL_MODE_USTT_LOW_POWER)
- return true;
-
- return false;
-}
-
-static int wmax_thermal_information(struct wmi_device *wdev, u8 operation,
- u8 arg, u32 *out_data)
-{
- struct wmax_u32_args in_args = {
- .operation = operation,
- .arg1 = arg,
- .arg2 = 0,
- .arg3 = 0,
- };
- int ret;
-
- ret = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_INFORMATION,
- &in_args, sizeof(in_args), out_data);
- if (ret < 0)
- return ret;
-
- if (*out_data == WMAX_FAILURE_CODE)
- return -EBADRQC;
-
- return 0;
-}
-
-static int wmax_thermal_control(struct wmi_device *wdev, u8 profile)
-{
- struct wmax_u32_args in_args = {
- .operation = WMAX_OPERATION_ACTIVATE_PROFILE,
- .arg1 = profile,
- .arg2 = 0,
- .arg3 = 0,
- };
- u32 out_data;
- int ret;
-
- ret = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_CONTROL,
- &in_args, sizeof(in_args), &out_data);
- if (ret)
- return ret;
-
- if (out_data == WMAX_FAILURE_CODE)
- return -EBADRQC;
-
- return 0;
-}
-
-static int wmax_game_shift_status(struct wmi_device *wdev, u8 operation,
- u32 *out_data)
-{
- struct wmax_u32_args in_args = {
- .operation = operation,
- .arg1 = 0,
- .arg2 = 0,
- .arg3 = 0,
- };
- int ret;
-
- ret = alienware_wmi_command(wdev, WMAX_METHOD_GAME_SHIFT_STATUS,
- &in_args, sizeof(in_args), out_data);
-
- if (ret < 0)
- return ret;
-
- if (*out_data == WMAX_FAILURE_CODE)
- return -EOPNOTSUPP;
-
- return 0;
-}
-
-static int thermal_profile_get(struct device *dev,
- enum platform_profile_option *profile)
-{
- struct awcc_priv *priv = dev_get_drvdata(dev);
- u32 out_data;
- int ret;
-
- ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_CURRENT_PROFILE,
- 0, &out_data);
-
- if (ret < 0)
- return ret;
-
- if (out_data == WMAX_THERMAL_MODE_GMODE) {
- *profile = PLATFORM_PROFILE_PERFORMANCE;
- return 0;
- }
-
- if (!is_wmax_thermal_code(out_data))
- return -ENODATA;
-
- out_data &= WMAX_THERMAL_MODE_MASK;
- *profile = wmax_mode_to_platform_profile[out_data];
-
- return 0;
-}
-
-static int thermal_profile_set(struct device *dev,
- enum platform_profile_option profile)
-{
- struct awcc_priv *priv = dev_get_drvdata(dev);
-
- if (awcc->gmode) {
- u32 gmode_status;
- int ret;
-
- ret = wmax_game_shift_status(priv->wdev,
- WMAX_OPERATION_GET_GAME_SHIFT_STATUS,
- &gmode_status);
-
- if (ret < 0)
- return ret;
-
- if ((profile == PLATFORM_PROFILE_PERFORMANCE && !gmode_status) ||
- (profile != PLATFORM_PROFILE_PERFORMANCE && gmode_status)) {
- ret = wmax_game_shift_status(priv->wdev,
- WMAX_OPERATION_TOGGLE_GAME_SHIFT,
- &gmode_status);
-
- if (ret < 0)
- return ret;
- }
- }
-
- return wmax_thermal_control(priv->wdev,
- priv->supported_thermal_profiles[profile]);
-}
-
-static int thermal_profile_probe(void *drvdata, unsigned long *choices)
-{
- enum platform_profile_option profile;
- struct awcc_priv *priv = drvdata;
- enum wmax_thermal_mode mode;
- u8 sys_desc[4];
- u32 first_mode;
- u32 out_data;
- int ret;
-
- ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_SYS_DESCRIPTION,
- 0, (u32 *) &sys_desc);
- if (ret < 0)
- return ret;
-
- first_mode = sys_desc[0] + sys_desc[1];
-
- for (u32 i = 0; i < sys_desc[3]; i++) {
- ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_LIST_IDS,
- i + first_mode, &out_data);
-
- if (ret == -EIO)
- return ret;
-
- if (ret == -EBADRQC)
- break;
-
- if (!is_wmax_thermal_code(out_data))
- continue;
-
- mode = out_data & WMAX_THERMAL_MODE_MASK;
- profile = wmax_mode_to_platform_profile[mode];
- priv->supported_thermal_profiles[profile] = out_data;
-
- set_bit(profile, choices);
- }
-
- if (bitmap_empty(choices, PLATFORM_PROFILE_LAST))
- return -ENODEV;
-
- if (awcc->gmode) {
- priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =
- WMAX_THERMAL_MODE_GMODE;
-
- set_bit(PLATFORM_PROFILE_PERFORMANCE, choices);
- }
-
- return 0;
-}
-
-static const struct platform_profile_ops awcc_platform_profile_ops = {
- .probe = thermal_profile_probe,
- .profile_get = thermal_profile_get,
- .profile_set = thermal_profile_set,
-};
-
-static int alienware_awcc_setup(struct wmi_device *wdev)
-{
- struct awcc_priv *priv;
-
- priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
-
- priv->wdev = wdev;
- dev_set_drvdata(&wdev->dev, priv);
-
- priv->ppdev = devm_platform_profile_register(&wdev->dev, "alienware-wmi",
- priv, &awcc_platform_profile_ops);
-
- return PTR_ERR_OR_ZERO(priv->ppdev);
-}
-
/*
* Platform Driver
*/
@@ -1064,13 +415,6 @@ static const struct attribute_group *alienfx_groups[] = {
NULL
};
-static const struct attribute_group *wmax_alienfx_groups[] = {
- &hdmi_attribute_group,
- &lifier_attribute_group,
- &deepsleep_attribute_group,
- NULL
-};
-
static struct platform_driver platform_driver = {
.driver = {
.name = "alienware-wmi",
@@ -1110,199 +454,6 @@ void alienware_alienfx_exit(struct wmi_device *wdev)
platform_driver_unregister(&platform_driver);
}
-/*
- * Legacy WMI driver
- */
-static int legacy_wmi_update_led(struct alienfx_priv *priv,
- struct wmi_device *wdev, u8 location)
-{
- struct legacy_led_args legacy_args = {
- .colors = priv->colors[location],
- .brightness = priv->global_brightness,
- .state = 0,
- };
- struct acpi_buffer input;
- acpi_status status;
-
- if (legacy_args.state != LEGACY_RUNNING) {
- legacy_args.state = priv->lighting_control_state;
-
- input.length = sizeof(legacy_args);
- input.pointer = &legacy_args;
-
- status = wmi_evaluate_method(LEGACY_POWER_CONTROL_GUID, 0,
- location + 1, &input, NULL);
- if (ACPI_FAILURE(status))
- return -EIO;
-
- return 0;
- }
-
- return alienware_wmi_command(wdev, location + 1, &legacy_args,
- sizeof(legacy_args), NULL);
-}
-
-static int legacy_wmi_update_brightness(struct alienfx_priv *priv,
- struct wmi_device *wdev, u8 brightness)
-{
- return legacy_wmi_update_led(priv, wdev, 0);
-}
-
-static int legacy_wmi_probe(struct wmi_device *wdev, const void *context)
-{
- struct alienfx_platdata pdata = {
- .wdev = wdev,
- .ops = {
- .upd_led = legacy_wmi_update_led,
- .upd_brightness = legacy_wmi_update_brightness,
- },
- };
-
- return alienware_alienfx_setup(&pdata);
-}
-
-static void legacy_wmi_remove(struct wmi_device *wdev)
-{
- alienware_alienfx_exit(wdev);
-}
-
-static struct wmi_device_id alienware_legacy_device_id_table[] = {
- { LEGACY_CONTROL_GUID, NULL },
- { },
-};
-MODULE_DEVICE_TABLE(wmi, alienware_legacy_device_id_table);
-
-static struct wmi_driver alienware_legacy_wmi_driver = {
- .driver = {
- .name = "alienware-wmi-alienfx",
- .probe_type = PROBE_PREFER_ASYNCHRONOUS,
- },
- .id_table = alienware_legacy_device_id_table,
- .probe = legacy_wmi_probe,
- .remove = legacy_wmi_remove,
-};
-
-int __init alienware_legacy_wmi_init(void)
-{
- return wmi_driver_register(&alienware_legacy_wmi_driver);
-}
-
-void __exit alienware_legacy_wmi_exit(void)
-{
- wmi_driver_unregister(&alienware_legacy_wmi_driver);
-}
-
-/*
- * WMAX WMI driver
- */
-static int wmax_wmi_update_led(struct alienfx_priv *priv,
- struct wmi_device *wdev, u8 location)
-{
- struct wmax_led_args in_args = {
- .led_mask = 1 << location,
- .colors = priv->colors[location],
- .state = priv->lighting_control_state,
- };
-
- return alienware_wmi_command(wdev, WMAX_METHOD_ZONE_CONTROL, &in_args,
- sizeof(in_args), NULL);
-}
-
-static int wmax_wmi_update_brightness(struct alienfx_priv *priv,
- struct wmi_device *wdev, u8 brightness)
-{
- struct wmax_brightness_args in_args = {
- .led_mask = 0xFF,
- .percentage = brightness,
- };
-
- return alienware_wmi_command(wdev, WMAX_METHOD_BRIGHTNESS, &in_args,
- sizeof(in_args), NULL);
-}
-
-static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
-{
- struct alienfx_platdata pdata = {
- .wdev = wdev,
- .ops = {
- .upd_led = wmax_wmi_update_led,
- .upd_brightness = wmax_wmi_update_brightness,
- },
- };
- struct platform_device *pdev;
- int ret;
-
- if (awcc) {
- return alienware_awcc_setup(wdev);
- } else {
- ret = alienware_alienfx_setup(&pdata);
- if (ret < 0)
- return ret;
-
- pdev = dev_get_drvdata(&wdev->dev);
-
- ret = device_add_groups(&pdev->dev, wmax_alienfx_groups);
- if (ret < 0)
- alienware_alienfx_exit(wdev);
-
- return ret;
- }
-}
-
-static void wmax_wmi_remove(struct wmi_device *wdev)
-{
- struct platform_device *pdev;
-
- if (!awcc) {
- pdev = dev_get_drvdata(&wdev->dev);
-
- device_remove_groups(&pdev->dev, wmax_alienfx_groups);
- alienware_alienfx_exit(wdev);
- }
-}
-
-static struct wmi_device_id alienware_wmax_device_id_table[] = {
- { WMAX_CONTROL_GUID, NULL },
- { },
-};
-MODULE_DEVICE_TABLE(wmi, alienware_wmax_device_id_table);
-
-static struct wmi_driver alienware_wmax_wmi_driver = {
- .driver = {
- .name = "alienware-wmi-wmax",
- .probe_type = PROBE_PREFER_ASYNCHRONOUS,
- },
- .id_table = alienware_wmax_device_id_table,
- .probe = wmax_wmi_probe,
- .remove = wmax_wmi_remove,
-};
-
-int __init alienware_wmax_wmi_init(void)
-{
- const struct dmi_system_id *id;
-
- id = dmi_first_match(awcc_dmi_table);
- if (id)
- awcc = id->driver_data;
-
- if (force_platform_profile)
- awcc = &generic_quirks;
-
- if (force_gmode) {
- if (awcc)
- awcc->gmode = true;
- else
- pr_warn("force_gmode requires platform profile support\n");
- }
-
- return wmi_driver_register(&alienware_wmax_wmi_driver);
-}
-
-void __exit alienware_wmax_wmi_exit(void)
-{
- wmi_driver_unregister(&alienware_wmax_wmi_driver);
-}
-
static int __init alienware_wmi_init(void)
{
int ret;
diff --git a/drivers/platform/x86/dell/alienware-wmi-legacy.c b/drivers/platform/x86/dell/alienware-wmi-legacy.c
new file mode 100644
index 000000000000..04c1be2efdc4
--- /dev/null
+++ b/drivers/platform/x86/dell/alienware-wmi-legacy.c
@@ -0,0 +1,100 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Alienware LEGACY WMI device driver
+ *
+ * Copyright (C) 2025 Kurt Borja <kuurtb@gmail.com>
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/wmi.h>
+#include "alienware-wmi.h"
+
+struct legacy_led_args {
+ struct color_platform colors;
+ u8 brightness;
+ u8 state;
+} __packed;
+
+
+/*
+ * Legacy WMI driver
+ */
+static int legacy_wmi_update_led(struct alienfx_priv *priv,
+ struct wmi_device *wdev, u8 location)
+{
+ struct legacy_led_args legacy_args = {
+ .colors = priv->colors[location],
+ .brightness = priv->global_brightness,
+ .state = 0,
+ };
+ struct acpi_buffer input;
+ acpi_status status;
+
+ if (legacy_args.state != LEGACY_RUNNING) {
+ legacy_args.state = priv->lighting_control_state;
+
+ input.length = sizeof(legacy_args);
+ input.pointer = &legacy_args;
+
+ status = wmi_evaluate_method(LEGACY_POWER_CONTROL_GUID, 0,
+ location + 1, &input, NULL);
+ if (ACPI_FAILURE(status))
+ return -EIO;
+
+ return 0;
+ }
+
+ return alienware_wmi_command(wdev, location + 1, &legacy_args,
+ sizeof(legacy_args), NULL);
+}
+
+static int legacy_wmi_update_brightness(struct alienfx_priv *priv,
+ struct wmi_device *wdev, u8 brightness)
+{
+ return legacy_wmi_update_led(priv, wdev, 0);
+}
+
+static int legacy_wmi_probe(struct wmi_device *wdev, const void *context)
+{
+ struct alienfx_platdata pdata = {
+ .wdev = wdev,
+ .ops = {
+ .upd_led = legacy_wmi_update_led,
+ .upd_brightness = legacy_wmi_update_brightness,
+ },
+ };
+
+ return alienware_alienfx_setup(&pdata);
+}
+
+static void legacy_wmi_remove(struct wmi_device *wdev)
+{
+ alienware_alienfx_exit(wdev);
+}
+
+static struct wmi_device_id alienware_legacy_device_id_table[] = {
+ { LEGACY_CONTROL_GUID, NULL },
+ { },
+};
+MODULE_DEVICE_TABLE(wmi, alienware_legacy_device_id_table);
+
+static struct wmi_driver alienware_legacy_wmi_driver = {
+ .driver = {
+ .name = "alienware-wmi-alienfx",
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ },
+ .id_table = alienware_legacy_device_id_table,
+ .probe = legacy_wmi_probe,
+ .remove = legacy_wmi_remove,
+};
+
+int __init alienware_legacy_wmi_init(void)
+{
+ return wmi_driver_register(&alienware_legacy_wmi_driver);
+}
+
+void __exit alienware_legacy_wmi_exit(void)
+{
+ wmi_driver_unregister(&alienware_legacy_wmi_driver);
+}
diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platform/x86/dell/alienware-wmi-wmax.c
new file mode 100644
index 000000000000..05284f14997d
--- /dev/null
+++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c
@@ -0,0 +1,773 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Alienware WMAX WMI device driver
+ *
+ * Copyright (C) 2014 Dell Inc <Dell.Client.Kernel@dell.com>
+ * Copyright (C) 2025 Kurt Borja <kuurtb@gmail.com>
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/dmi.h>
+#include <linux/moduleparam.h>
+#include <linux/platform_profile.h>
+#include <linux/wmi.h>
+#include "alienware-wmi.h"
+
+#define WMAX_METHOD_HDMI_SOURCE 0x1
+#define WMAX_METHOD_HDMI_STATUS 0x2
+#define WMAX_METHOD_HDMI_CABLE 0x5
+#define WMAX_METHOD_AMPLIFIER_CABLE 0x6
+#define WMAX_METHOD_DEEP_SLEEP_CONTROL 0x0B
+#define WMAX_METHOD_DEEP_SLEEP_STATUS 0x0C
+#define WMAX_METHOD_BRIGHTNESS 0x3
+#define WMAX_METHOD_ZONE_CONTROL 0x4
+#define WMAX_METHOD_THERMAL_INFORMATION 0x14
+#define WMAX_METHOD_THERMAL_CONTROL 0x15
+#define WMAX_METHOD_GAME_SHIFT_STATUS 0x25
+
+#define WMAX_THERMAL_MODE_GMODE 0xAB
+
+#define WMAX_FAILURE_CODE 0xFFFFFFFF
+#define WMAX_THERMAL_TABLE_MASK GENMASK(7, 4)
+#define WMAX_THERMAL_MODE_MASK GENMASK(3, 0)
+#define WMAX_SENSOR_ID_MASK BIT(8)
+
+static bool force_platform_profile;
+module_param_unsafe(force_platform_profile, bool, 0);
+MODULE_PARM_DESC(force_platform_profile, "Forces auto-detecting thermal profiles without checking if WMI thermal backend is available");
+
+static bool force_gmode;
+module_param_unsafe(force_gmode, bool, 0);
+MODULE_PARM_DESC(force_gmode, "Forces G-Mode when performance profile is selected");
+
+struct awcc_quirks {
+ bool gmode;
+};
+
+static struct awcc_quirks g_series_quirks = {
+ .gmode = true,
+};
+
+static struct awcc_quirks generic_quirks = {
+ .gmode = false,
+};
+
+static const struct dmi_system_id awcc_dmi_table[] __initconst = {
+ {
+ .ident = "Alienware m17 R5",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
+ },
+ .driver_data = &generic_quirks,
+ },
+ {
+ .ident = "Alienware m18 R2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"),
+ },
+ .driver_data = &generic_quirks,
+ },
+ {
+ .ident = "Alienware x15 R1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"),
+ },
+ .driver_data = &generic_quirks,
+ },
+ {
+ .ident = "Alienware x17 R2",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"),
+ },
+ .driver_data = &generic_quirks,
+ },
+ {
+ .ident = "Dell Inc. G15 5510",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G15 5511",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G15 5515",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G3 3500",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G3 3590",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+ {
+ .ident = "Dell Inc. G5 5500",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"),
+ },
+ .driver_data = &g_series_quirks,
+ },
+};
+
+enum WMAX_THERMAL_INFORMATION_OPERATIONS {
+ WMAX_OPERATION_SYS_DESCRIPTION = 0x02,
+ WMAX_OPERATION_LIST_IDS = 0x03,
+ WMAX_OPERATION_CURRENT_PROFILE = 0x0B,
+};
+
+enum WMAX_THERMAL_CONTROL_OPERATIONS {
+ WMAX_OPERATION_ACTIVATE_PROFILE = 0x01,
+};
+
+enum WMAX_GAME_SHIFT_STATUS_OPERATIONS {
+ WMAX_OPERATION_TOGGLE_GAME_SHIFT = 0x01,
+ WMAX_OPERATION_GET_GAME_SHIFT_STATUS = 0x02,
+};
+
+enum WMAX_THERMAL_TABLES {
+ WMAX_THERMAL_TABLE_BASIC = 0x90,
+ WMAX_THERMAL_TABLE_USTT = 0xA0,
+};
+
+enum wmax_thermal_mode {
+ THERMAL_MODE_USTT_BALANCED,
+ THERMAL_MODE_USTT_BALANCED_PERFORMANCE,
+ THERMAL_MODE_USTT_COOL,
+ THERMAL_MODE_USTT_QUIET,
+ THERMAL_MODE_USTT_PERFORMANCE,
+ THERMAL_MODE_USTT_LOW_POWER,
+ THERMAL_MODE_BASIC_QUIET,
+ THERMAL_MODE_BASIC_BALANCED,
+ THERMAL_MODE_BASIC_BALANCED_PERFORMANCE,
+ THERMAL_MODE_BASIC_PERFORMANCE,
+ THERMAL_MODE_LAST,
+};
+
+struct wmax_led_args {
+ u32 led_mask;
+ struct color_platform colors;
+ u8 state;
+} __packed;
+
+struct wmax_brightness_args {
+ u32 led_mask;
+ u32 percentage;
+};
+
+struct wmax_basic_args {
+ u8 arg;
+};
+
+struct wmax_u32_args {
+ u8 operation;
+ u8 arg1;
+ u8 arg2;
+ u8 arg3;
+};
+
+struct awcc_priv {
+ struct wmi_device *wdev;
+ struct device *ppdev;
+ enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
+};
+
+static const enum platform_profile_option wmax_mode_to_platform_profile[THERMAL_MODE_LAST] = {
+ [THERMAL_MODE_USTT_BALANCED] = PLATFORM_PROFILE_BALANCED,
+ [THERMAL_MODE_USTT_BALANCED_PERFORMANCE] = PLATFORM_PROFILE_BALANCED_PERFORMANCE,
+ [THERMAL_MODE_USTT_COOL] = PLATFORM_PROFILE_COOL,
+ [THERMAL_MODE_USTT_QUIET] = PLATFORM_PROFILE_QUIET,
+ [THERMAL_MODE_USTT_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE,
+ [THERMAL_MODE_USTT_LOW_POWER] = PLATFORM_PROFILE_LOW_POWER,
+ [THERMAL_MODE_BASIC_QUIET] = PLATFORM_PROFILE_QUIET,
+ [THERMAL_MODE_BASIC_BALANCED] = PLATFORM_PROFILE_BALANCED,
+ [THERMAL_MODE_BASIC_BALANCED_PERFORMANCE] = PLATFORM_PROFILE_BALANCED_PERFORMANCE,
+ [THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE,
+};
+
+struct awcc_quirks *awcc;
+
+/*
+ * The HDMI mux sysfs node indicates the status of the HDMI input mux.
+ * It can toggle between standard system GPU output and HDMI input.
+ */
+static ssize_t cable_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
+ struct wmax_basic_args in_args = {
+ .arg = 0,
+ };
+ u32 out_data;
+ int ret;
+
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_CABLE,
+ &in_args, sizeof(in_args), &out_data);
+
+ if (!ret) {
+ if (out_data == 0)
+ return sysfs_emit(buf, "[unconnected] connected unknown\n");
+ else if (out_data == 1)
+ return sysfs_emit(buf, "unconnected [connected] unknown\n");
+ }
+
+ pr_err("alienware-wmi: unknown HDMI cable status: %d\n", ret);
+ return sysfs_emit(buf, "unconnected connected [unknown]\n");
+}
+
+static ssize_t source_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
+ struct wmax_basic_args in_args = {
+ .arg = 0,
+ };
+ u32 out_data;
+ int ret;
+
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_STATUS,
+ &in_args, sizeof(in_args), &out_data);
+
+ if (!ret) {
+ if (out_data == 1)
+ return sysfs_emit(buf, "[input] gpu unknown\n");
+ else if (out_data == 2)
+ return sysfs_emit(buf, "input [gpu] unknown\n");
+ }
+
+ pr_err("alienware-wmi: unknown HDMI source status: %u\n", ret);
+ return sysfs_emit(buf, "input gpu [unknown]\n");
+}
+
+static ssize_t source_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
+ struct wmax_basic_args args;
+ int ret;
+
+ if (strcmp(buf, "gpu\n") == 0)
+ args.arg = 1;
+ else if (strcmp(buf, "input\n") == 0)
+ args.arg = 2;
+ else
+ args.arg = 3;
+ pr_debug("alienware-wmi: setting hdmi to %d : %s", args.arg, buf);
+
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_HDMI_SOURCE, &args,
+ sizeof(args), NULL);
+
+ if (ret < 0)
+ pr_err("alienware-wmi: HDMI toggle failed: results: %u\n", ret);
+
+ return count;
+}
+
+static DEVICE_ATTR_RO(cable);
+static DEVICE_ATTR_RW(source);
+
+static bool hdmi_group_visible(struct kobject *kobj)
+{
+ return alienfx->hdmi_mux;
+}
+DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi);
+
+static struct attribute *hdmi_attrs[] = {
+ &dev_attr_cable.attr,
+ &dev_attr_source.attr,
+ NULL,
+};
+
+static const struct attribute_group hdmi_attribute_group = {
+ .name = "hdmi",
+ .is_visible = SYSFS_GROUP_VISIBLE(hdmi),
+ .attrs = hdmi_attrs,
+};
+
+/*
+ * Alienware GFX amplifier support
+ * - Currently supports reading cable status
+ * - Leaving expansion room to possibly support dock/undock events later
+ */
+static ssize_t status_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
+ struct wmax_basic_args in_args = {
+ .arg = 0,
+ };
+ u32 out_data;
+ int ret;
+
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_AMPLIFIER_CABLE,
+ &in_args, sizeof(in_args), &out_data);
+
+ if (!ret) {
+ if (out_data == 0)
+ return sysfs_emit(buf, "[unconnected] connected unknown\n");
+ else if (out_data == 1)
+ return sysfs_emit(buf, "unconnected [connected] unknown\n");
+ }
+
+ pr_err("alienware-wmi: unknown amplifier cable status: %d\n", ret);
+ return sysfs_emit(buf, "unconnected connected [unknown]\n");
+}
+
+static DEVICE_ATTR_RO(status);
+
+static bool amplifier_group_visible(struct kobject *kobj)
+{
+ return alienfx->amplifier;
+}
+DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier);
+
+static struct attribute *amplifier_attrs[] = {
+ &dev_attr_status.attr,
+ NULL,
+};
+
+static const struct attribute_group amplifier_attribute_group = {
+ .name = "amplifier",
+ .is_visible = SYSFS_GROUP_VISIBLE(amplifier),
+ .attrs = amplifier_attrs,
+};
+
+/*
+ * Deep Sleep Control support
+ * - Modifies BIOS setting for deep sleep control allowing extra wakeup events
+ */
+static ssize_t deepsleep_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
+ struct wmax_basic_args in_args = {
+ .arg = 0,
+ };
+ u32 out_data;
+ int ret;
+
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_STATUS,
+ &in_args, sizeof(in_args), &out_data);
+
+ if (!ret) {
+ if (out_data == 0)
+ return sysfs_emit(buf, "[disabled] s5 s5_s4\n");
+ else if (out_data == 1)
+ return sysfs_emit(buf, "disabled [s5] s5_s4\n");
+ else if (out_data == 2)
+ return sysfs_emit(buf, "disabled s5 [s5_s4]\n");
+ }
+
+ pr_err("alienware-wmi: unknown deep sleep status: %d\n", ret);
+ return sysfs_emit(buf, "disabled s5 s5_s4 [unknown]\n");
+}
+
+static ssize_t deepsleep_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct alienfx_platdata *pdata = dev_get_platdata(dev);
+ struct wmax_basic_args args;
+ int ret;
+
+ if (strcmp(buf, "disabled\n") == 0)
+ args.arg = 0;
+ else if (strcmp(buf, "s5\n") == 0)
+ args.arg = 1;
+ else
+ args.arg = 2;
+ pr_debug("alienware-wmi: setting deep sleep to %d : %s", args.arg, buf);
+
+ ret = alienware_wmi_command(pdata->wdev, WMAX_METHOD_DEEP_SLEEP_CONTROL,
+ &args, sizeof(args), NULL);
+
+ if (!ret)
+ pr_err("alienware-wmi: deep sleep control failed: results: %u\n", ret);
+
+ return count;
+}
+
+static DEVICE_ATTR_RW(deepsleep);
+
+static bool deepsleep_group_visible(struct kobject *kobj)
+{
+ return alienfx->deepslp;
+}
+DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep);
+
+static struct attribute *deepsleep_attrs[] = {
+ &dev_attr_deepsleep.attr,
+ NULL,
+};
+
+static const struct attribute_group deepsleep_attribute_group = {
+ .name = "deepsleep",
+ .is_visible = SYSFS_GROUP_VISIBLE(deepsleep),
+ .attrs = deepsleep_attrs,
+};
+
+static const struct attribute_group *wmax_alienfx_groups[] = {
+ &hdmi_attribute_group,
+ &lifier_attribute_group,
+ &deepsleep_attribute_group,
+ NULL
+};
+
+/*
+ * Thermal Profile control
+ * - Provides thermal profile control through the Platform Profile API
+ */
+static bool is_wmax_thermal_code(u32 code)
+{
+ if (code & WMAX_SENSOR_ID_MASK)
+ return false;
+
+ if ((code & WMAX_THERMAL_MODE_MASK) >= THERMAL_MODE_LAST)
+ return false;
+
+ if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_BASIC &&
+ (code & WMAX_THERMAL_MODE_MASK) >= THERMAL_MODE_BASIC_QUIET)
+ return true;
+
+ if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_USTT &&
+ (code & WMAX_THERMAL_MODE_MASK) <= THERMAL_MODE_USTT_LOW_POWER)
+ return true;
+
+ return false;
+}
+
+static int wmax_thermal_information(struct wmi_device *wdev, u8 operation,
+ u8 arg, u32 *out_data)
+{
+ struct wmax_u32_args in_args = {
+ .operation = operation,
+ .arg1 = arg,
+ .arg2 = 0,
+ .arg3 = 0,
+ };
+ int ret;
+
+ ret = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_INFORMATION,
+ &in_args, sizeof(in_args), out_data);
+ if (ret < 0)
+ return ret;
+
+ if (*out_data == WMAX_FAILURE_CODE)
+ return -EBADRQC;
+
+ return 0;
+}
+
+static int wmax_thermal_control(struct wmi_device *wdev, u8 profile)
+{
+ struct wmax_u32_args in_args = {
+ .operation = WMAX_OPERATION_ACTIVATE_PROFILE,
+ .arg1 = profile,
+ .arg2 = 0,
+ .arg3 = 0,
+ };
+ u32 out_data;
+ int ret;
+
+ ret = alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_CONTROL,
+ &in_args, sizeof(in_args), &out_data);
+ if (ret)
+ return ret;
+
+ if (out_data == WMAX_FAILURE_CODE)
+ return -EBADRQC;
+
+ return 0;
+}
+
+static int wmax_game_shift_status(struct wmi_device *wdev, u8 operation,
+ u32 *out_data)
+{
+ struct wmax_u32_args in_args = {
+ .operation = operation,
+ .arg1 = 0,
+ .arg2 = 0,
+ .arg3 = 0,
+ };
+ int ret;
+
+ ret = alienware_wmi_command(wdev, WMAX_METHOD_GAME_SHIFT_STATUS,
+ &in_args, sizeof(in_args), out_data);
+
+ if (ret < 0)
+ return ret;
+
+ if (*out_data == WMAX_FAILURE_CODE)
+ return -EOPNOTSUPP;
+
+ return 0;
+}
+
+static int thermal_profile_get(struct device *dev,
+ enum platform_profile_option *profile)
+{
+ struct awcc_priv *priv = dev_get_drvdata(dev);
+ u32 out_data;
+ int ret;
+
+ ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_CURRENT_PROFILE,
+ 0, &out_data);
+
+ if (ret < 0)
+ return ret;
+
+ if (out_data == WMAX_THERMAL_MODE_GMODE) {
+ *profile = PLATFORM_PROFILE_PERFORMANCE;
+ return 0;
+ }
+
+ if (!is_wmax_thermal_code(out_data))
+ return -ENODATA;
+
+ out_data &= WMAX_THERMAL_MODE_MASK;
+ *profile = wmax_mode_to_platform_profile[out_data];
+
+ return 0;
+}
+
+static int thermal_profile_set(struct device *dev,
+ enum platform_profile_option profile)
+{
+ struct awcc_priv *priv = dev_get_drvdata(dev);
+
+ if (awcc->gmode) {
+ u32 gmode_status;
+ int ret;
+
+ ret = wmax_game_shift_status(priv->wdev,
+ WMAX_OPERATION_GET_GAME_SHIFT_STATUS,
+ &gmode_status);
+
+ if (ret < 0)
+ return ret;
+
+ if ((profile == PLATFORM_PROFILE_PERFORMANCE && !gmode_status) ||
+ (profile != PLATFORM_PROFILE_PERFORMANCE && gmode_status)) {
+ ret = wmax_game_shift_status(priv->wdev,
+ WMAX_OPERATION_TOGGLE_GAME_SHIFT,
+ &gmode_status);
+
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return wmax_thermal_control(priv->wdev,
+ priv->supported_thermal_profiles[profile]);
+}
+
+static int thermal_profile_probe(void *drvdata, unsigned long *choices)
+{
+ enum platform_profile_option profile;
+ struct awcc_priv *priv = drvdata;
+ enum wmax_thermal_mode mode;
+ u8 sys_desc[4];
+ u32 first_mode;
+ u32 out_data;
+ int ret;
+
+ ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_SYS_DESCRIPTION,
+ 0, (u32 *) &sys_desc);
+ if (ret < 0)
+ return ret;
+
+ first_mode = sys_desc[0] + sys_desc[1];
+
+ for (u32 i = 0; i < sys_desc[3]; i++) {
+ ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_LIST_IDS,
+ i + first_mode, &out_data);
+
+ if (ret == -EIO)
+ return ret;
+
+ if (ret == -EBADRQC)
+ break;
+
+ if (!is_wmax_thermal_code(out_data))
+ continue;
+
+ mode = out_data & WMAX_THERMAL_MODE_MASK;
+ profile = wmax_mode_to_platform_profile[mode];
+ priv->supported_thermal_profiles[profile] = out_data;
+
+ set_bit(profile, choices);
+ }
+
+ if (bitmap_empty(choices, PLATFORM_PROFILE_LAST))
+ return -ENODEV;
+
+ if (awcc->gmode) {
+ priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =
+ WMAX_THERMAL_MODE_GMODE;
+
+ set_bit(PLATFORM_PROFILE_PERFORMANCE, choices);
+ }
+
+ return 0;
+}
+
+static const struct platform_profile_ops awcc_platform_profile_ops = {
+ .probe = thermal_profile_probe,
+ .profile_get = thermal_profile_get,
+ .profile_set = thermal_profile_set,
+};
+
+static int alienware_awcc_setup(struct wmi_device *wdev)
+{
+ struct awcc_priv *priv;
+
+ priv = devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->wdev = wdev;
+ dev_set_drvdata(&wdev->dev, priv);
+
+ priv->ppdev = devm_platform_profile_register(&wdev->dev, "alienware-wmi",
+ priv, &awcc_platform_profile_ops);
+
+ return PTR_ERR_OR_ZERO(priv->ppdev);
+}
+
+/*
+ * WMAX WMI driver
+ */
+static int wmax_wmi_update_led(struct alienfx_priv *priv,
+ struct wmi_device *wdev, u8 location)
+{
+ struct wmax_led_args in_args = {
+ .led_mask = 1 << location,
+ .colors = priv->colors[location],
+ .state = priv->lighting_control_state,
+ };
+
+ return alienware_wmi_command(wdev, WMAX_METHOD_ZONE_CONTROL, &in_args,
+ sizeof(in_args), NULL);
+}
+
+static int wmax_wmi_update_brightness(struct alienfx_priv *priv,
+ struct wmi_device *wdev, u8 brightness)
+{
+ struct wmax_brightness_args in_args = {
+ .led_mask = 0xFF,
+ .percentage = brightness,
+ };
+
+ return alienware_wmi_command(wdev, WMAX_METHOD_BRIGHTNESS, &in_args,
+ sizeof(in_args), NULL);
+}
+
+static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
+{
+ struct alienfx_platdata pdata = {
+ .wdev = wdev,
+ .ops = {
+ .upd_led = wmax_wmi_update_led,
+ .upd_brightness = wmax_wmi_update_brightness,
+ },
+ };
+ struct platform_device *pdev;
+ int ret = 0;
+
+ if (awcc) {
+ return alienware_awcc_setup(wdev);
+ } else {
+ ret = alienware_alienfx_setup(&pdata);
+ if (ret < 0)
+ return ret;
+
+ pdev = dev_get_drvdata(&wdev->dev);
+
+ ret = device_add_groups(&pdev->dev, wmax_alienfx_groups);
+ if (ret < 0)
+ alienware_alienfx_exit(wdev);
+
+ return ret;
+ }
+}
+
+static void wmax_wmi_remove(struct wmi_device *wdev)
+{
+ struct platform_device *pdev;
+
+ if (!awcc) {
+ pdev = dev_get_drvdata(&wdev->dev);
+
+ device_remove_groups(&pdev->dev, wmax_alienfx_groups);
+ alienware_alienfx_exit(wdev);
+ }
+}
+
+static struct wmi_device_id alienware_wmax_device_id_table[] = {
+ { WMAX_CONTROL_GUID, NULL },
+ { },
+};
+MODULE_DEVICE_TABLE(wmi, alienware_wmax_device_id_table);
+
+static struct wmi_driver alienware_wmax_wmi_driver = {
+ .driver = {
+ .name = "alienware-wmi-wmax",
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ },
+ .id_table = alienware_wmax_device_id_table,
+ .probe = wmax_wmi_probe,
+ .remove = wmax_wmi_remove,
+};
+
+int __init alienware_wmax_wmi_init(void)
+{
+ const struct dmi_system_id *id;
+
+ id = dmi_first_match(awcc_dmi_table);
+ if (id)
+ awcc = id->driver_data;
+
+ if (force_platform_profile)
+ awcc = &generic_quirks;
+
+ if (force_gmode) {
+ if (awcc)
+ awcc->gmode = true;
+ else
+ pr_warn("force_gmode requires platform profile support\n");
+ }
+
+ return wmi_driver_register(&alienware_wmax_wmi_driver);
+}
+
+void __exit alienware_wmax_wmi_exit(void)
+{
+ wmi_driver_unregister(&alienware_wmax_wmi_driver);
+}
diff --git a/drivers/platform/x86/dell/alienware-wmi.h b/drivers/platform/x86/dell/alienware-wmi.h
index 00b7505e1073..188440ef096e 100644
--- a/drivers/platform/x86/dell/alienware-wmi.h
+++ b/drivers/platform/x86/dell/alienware-wmi.h
@@ -46,7 +46,6 @@ struct color_platform {
struct alienfx_priv {
struct platform_device *pdev;
- struct alienfx_quirks *quirks;
struct led_classdev global_led;
struct color_platform colors[4];
u8 global_brightness;
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 12/14] platform/x86: dell: Modify Makefile alignment
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (10 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 11/14] platform/x86: Split the alienware-wmi driver Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 13/14] platform/x86: Update alienware-wmi config entries Kurt Borja
` (2 subsequent siblings)
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Add one more TAB to each line to support upcoming changes.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/Makefile | 48 +++++++++++++++---------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile
index 03ba459f3d31..d5718ef34c48 100644
--- a/drivers/platform/x86/dell/Makefile
+++ b/drivers/platform/x86/dell/Makefile
@@ -4,27 +4,27 @@
# Dell x86 Platform-Specific Drivers
#
-obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o
-alienware-wmi-objs := alienware-wmi-base.o
-alienware-wmi-y += alienware-wmi-legacy.o
-alienware-wmi-y += alienware-wmi-wmax.o
-obj-$(CONFIG_DCDBAS) += dcdbas.o
-obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
-obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o
-obj-$(CONFIG_DELL_RBU) += dell_rbu.o
-obj-$(CONFIG_DELL_PC) += dell-pc.o
-obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o
-dell-smbios-objs := dell-smbios-base.o
-dell-smbios-$(CONFIG_DELL_SMBIOS_WMI) += dell-smbios-wmi.o
-dell-smbios-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o
-obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o
-obj-$(CONFIG_DELL_SMO8800) += dell-lis3lv02d.o
-obj-$(CONFIG_DELL_UART_BACKLIGHT) += dell-uart-backlight.o
-obj-$(CONFIG_DELL_WMI) += dell-wmi.o
-dell-wmi-objs := dell-wmi-base.o
-dell-wmi-$(CONFIG_DELL_WMI_PRIVACY) += dell-wmi-privacy.o
-obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o
-obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o
-obj-$(CONFIG_DELL_WMI_DDV) += dell-wmi-ddv.o
-obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o
-obj-$(CONFIG_DELL_WMI_SYSMAN) += dell-wmi-sysman/
+obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o
+alienware-wmi-objs := alienware-wmi-base.o
+alienware-wmi-y += alienware-wmi-legacy.o
+alienware-wmi-y += alienware-wmi-wmax.o
+obj-$(CONFIG_DCDBAS) += dcdbas.o
+obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
+obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o
+obj-$(CONFIG_DELL_RBU) += dell_rbu.o
+obj-$(CONFIG_DELL_PC) += dell-pc.o
+obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o
+dell-smbios-objs := dell-smbios-base.o
+dell-smbios-$(CONFIG_DELL_SMBIOS_WMI) += dell-smbios-wmi.o
+dell-smbios-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o
+obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o
+obj-$(CONFIG_DELL_SMO8800) += dell-lis3lv02d.o
+obj-$(CONFIG_DELL_UART_BACKLIGHT) += dell-uart-backlight.o
+obj-$(CONFIG_DELL_WMI) += dell-wmi.o
+dell-wmi-objs := dell-wmi-base.o
+dell-wmi-$(CONFIG_DELL_WMI_PRIVACY) += dell-wmi-privacy.o
+obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o
+obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o
+obj-$(CONFIG_DELL_WMI_DDV) += dell-wmi-ddv.o
+obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o
+obj-$(CONFIG_DELL_WMI_SYSMAN) += dell-wmi-sysman/
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 13/14] platform/x86: Update alienware-wmi config entries
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (11 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 12/14] platform/x86: dell: Modify Makefile alignment Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 14/14] platform/x86: alienware-wmi: Update header and module information Kurt Borja
2025-01-19 0:09 ` [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Armin Wolf
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Add config entries for each WMI driver managed by the alienware-wmi
module to be able to conditionally compile them.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/Kconfig | 30 +++++++++++++++++++----
drivers/platform/x86/dell/Makefile | 4 +--
drivers/platform/x86/dell/alienware-wmi.h | 23 +++++++++++++++++
3 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig
index d09060aedd3f..f8a0dffcaab7 100644
--- a/drivers/platform/x86/dell/Kconfig
+++ b/drivers/platform/x86/dell/Kconfig
@@ -18,15 +18,35 @@ config ALIENWARE_WMI
tristate "Alienware Special feature control"
default m
depends on ACPI
+ depends on ACPI_WMI
+ depends on DMI
depends on LEDS_CLASS
depends on NEW_LEDS
- depends on ACPI_WMI
+ help
+ This is a driver for controlling Alienware WMI driven features.
+
+ On legacy devices, it exposes an interface for controlling the AlienFX
+ zones on Alienware machines that don't contain a dedicated
+ AlienFX USB MCU such as the X51 and X51-R2.
+
+ On newer devices, it exposes the AWCC thermal control interface through
+ known Kernel APIs.
+
+config ALIENWARE_WMI_LEGACY
+ bool "Alienware Legacy WMI device driver"
+ default y
+ depends on ALIENWARE_WMI
+ help
+ Legacy Alienware WMI driver with AlienFX LED control capabilities.
+
+config ALIENWARE_WMI_WMAX
+ bool "Alienware WMAX WMI device driver"
+ default y
+ depends on ALIENWARE_WMI
select ACPI_PLATFORM_PROFILE
help
- This is a driver for controlling Alienware BIOS driven
- features. It exposes an interface for controlling the AlienFX
- zones on Alienware machines that don't contain a dedicated AlienFX
- USB MCU such as the X51 and X51-R2.
+ Alienware WMI driver with AlienFX LED, HDMI, amplifier, deep sleep and
+ AWCC thermal control capabilities.
config DCDBAS
tristate "Dell Systems Management Base Driver"
diff --git a/drivers/platform/x86/dell/Makefile b/drivers/platform/x86/dell/Makefile
index d5718ef34c48..8ac9a933c770 100644
--- a/drivers/platform/x86/dell/Makefile
+++ b/drivers/platform/x86/dell/Makefile
@@ -6,8 +6,8 @@
obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o
alienware-wmi-objs := alienware-wmi-base.o
-alienware-wmi-y += alienware-wmi-legacy.o
-alienware-wmi-y += alienware-wmi-wmax.o
+alienware-wmi-$(CONFIG_ALIENWARE_WMI_LEGACY) += alienware-wmi-legacy.o
+alienware-wmi-$(CONFIG_ALIENWARE_WMI_WMAX) += alienware-wmi-wmax.o
obj-$(CONFIG_DCDBAS) += dcdbas.o
obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
obj-$(CONFIG_DELL_RBTN) += dell-rbtn.o
diff --git a/drivers/platform/x86/dell/alienware-wmi.h b/drivers/platform/x86/dell/alienware-wmi.h
index 188440ef096e..f66ae2a6e5c5 100644
--- a/drivers/platform/x86/dell/alienware-wmi.h
+++ b/drivers/platform/x86/dell/alienware-wmi.h
@@ -70,10 +70,33 @@ int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
int alienware_alienfx_setup(struct alienfx_platdata *pdata);
void alienware_alienfx_exit(struct wmi_device *wdev);
+#if IS_ENABLED(CONFIG_ALIENWARE_WMI_LEGACY)
int __init alienware_legacy_wmi_init(void);
void __exit alienware_legacy_wmi_exit(void);
+#else
+static inline int alienware_legacy_wmi_init(void)
+{
+ return -ENODEV;
+}
+
+static inline void alienware_legacy_wmi_exit(void)
+{
+}
+#endif
+#if IS_ENABLED(CONFIG_ALIENWARE_WMI_WMAX)
int __init alienware_wmax_wmi_init(void);
void __exit alienware_wmax_wmi_exit(void);
+#else
+static inline int alienware_wmax_wmi_init(void)
+{
+ return -ENODEV;
+}
+
+
+static inline void alienware_wmax_wmi_exit(void)
+{
+}
+#endif
#endif
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 14/14] platform/x86: alienware-wmi: Update header and module information
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (12 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 13/14] platform/x86: Update alienware-wmi config entries Kurt Borja
@ 2025-01-17 8:13 ` Kurt Borja
2025-01-19 0:09 ` [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Armin Wolf
14 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 8:13 UTC (permalink / raw)
To: platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel, Kurt Borja
Update module header and description. Additionally add myself as a module
author.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/platform/x86/dell/alienware-wmi-base.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/dell/alienware-wmi-base.c b/drivers/platform/x86/dell/alienware-wmi-base.c
index e55c962c84d7..01fe08d1a224 100644
--- a/drivers/platform/x86/dell/alienware-wmi-base.c
+++ b/drivers/platform/x86/dell/alienware-wmi-base.c
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
- * Alienware AlienFX control
+ * Alienware special feature control
*
* Copyright (C) 2014 Dell Inc <Dell.Client.Kernel@dell.com>
+ * Copyright (C) 2025 Kurt Borja <kuurtb@gmail.com>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -15,6 +16,7 @@
#include "alienware-wmi.h"
MODULE_AUTHOR("Mario Limonciello <mario.limonciello@outlook.com>");
+MODULE_AUTHOR("Kurt Borja <kuurtb@gmail.com>");
MODULE_DESCRIPTION("Alienware special feature control");
MODULE_LICENSE("GPL");
--
2.48.1
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v4 07/14] platform/x86: alienware-wmi: Split DMI table
2025-01-17 8:13 ` [PATCH v4 07/14] platform/x86: alienware-wmi: Split DMI table Kurt Borja
@ 2025-01-17 17:15 ` Kurt Borja
2025-01-19 0:03 ` Armin Wolf
1 sibling, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-17 17:15 UTC (permalink / raw)
To: Kurt Borja, platform-driver-x86
Cc: Ilpo Järvinen, Armin Wolf, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
On Fri Jan 17, 2025 at 3:13 AM -05, Kurt Borja wrote:
> Split thermal features into a new DMI table to support upcoming file
> split. While at it:
>
> Rename quirk_entry -> alienfx_features,
> Rename quirks -> alienfx
>
> and change hdmi_mux, amplifier and deepslp types to bool, because they are
> already being implicitly used as bools.
>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
> drivers/platform/x86/dell/alienware-wmi.c | 337 ++++++++++------------
> 1 file changed, 158 insertions(+), 179 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index 877b3d9d7cab..5d9816521072 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -113,102 +113,68 @@ static const enum platform_profile_option wmax_mode_to_platform_profile[THERMAL_
> [THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE,
> };
>
> -struct quirk_entry {
> +struct alienfx_quirks {
> u8 num_zones;
> - u8 hdmi_mux;
> - u8 amplifier;
> - u8 deepslp;
> - bool thermal;
> - bool gmode;
> + bool hdmi_mux;
> + bool amplifier;
> + bool deepslp;
> };
>
> -static struct quirk_entry *quirks;
> +static struct alienfx_quirks *alienfx;
>
>
> -static struct quirk_entry quirk_inspiron5675 = {
> +static struct alienfx_quirks quirk_inspiron5675 = {
> .num_zones = 2,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = false,
> + .amplifier = false,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_unknown = {
> +static struct alienfx_quirks quirk_unknown = {
> .num_zones = 2,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = false,
> + .amplifier = false,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_x51_r1_r2 = {
> +static struct alienfx_quirks quirk_x51_r1_r2 = {
> .num_zones = 3,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = false,
> + .amplifier = false,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_x51_r3 = {
> +static struct alienfx_quirks quirk_x51_r3 = {
> .num_zones = 4,
> - .hdmi_mux = 0,
> - .amplifier = 1,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = false,
> + .amplifier = true,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_asm100 = {
> +static struct alienfx_quirks quirk_asm100 = {
> .num_zones = 2,
> - .hdmi_mux = 1,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = true,
> + .amplifier = false,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_asm200 = {
> +static struct alienfx_quirks quirk_asm200 = {
> .num_zones = 2,
> - .hdmi_mux = 1,
> - .amplifier = 0,
> - .deepslp = 1,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = true,
> + .amplifier = false,
> + .deepslp = true,
> };
>
> -static struct quirk_entry quirk_asm201 = {
> +static struct alienfx_quirks quirk_asm201 = {
> .num_zones = 2,
> - .hdmi_mux = 1,
> - .amplifier = 1,
> - .deepslp = 1,
> - .thermal = false,
> - .gmode = false,
> -};
> -
> -static struct quirk_entry quirk_g_series = {
> - .num_zones = 2,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = true,
> - .gmode = true,
> -};
> -
> -static struct quirk_entry quirk_x_series = {
> - .num_zones = 2,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = true,
> - .gmode = false,
> + .hdmi_mux = true,
> + .amplifier = true,
> + .deepslp = true,
> };
>
> static int __init dmi_matched(const struct dmi_system_id *dmi)
> {
> - quirks = dmi->driver_data;
> + alienfx = dmi->driver_data;
> return 1;
> }
>
> @@ -240,42 +206,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = {
> },
> .driver_data = &quirk_asm201,
> },
> - {
> - .callback = dmi_matched,
> - .ident = "Alienware m17 R5",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
> - },
> - .driver_data = &quirk_x_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Alienware m18 R2",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"),
> - },
> - .driver_data = &quirk_x_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Alienware x15 R1",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"),
> - },
> - .driver_data = &quirk_x_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Alienware x17 R2",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"),
> - },
> - .driver_data = &quirk_x_series,
> - },
> {
> .callback = dmi_matched,
> .ident = "Alienware X51 R1",
> @@ -303,60 +233,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = {
> },
> .driver_data = &quirk_x51_r3,
> },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G15 5510",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G15 5511",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G15 5515",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G3 3500",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G3 3590",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G5 5500",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> {
> .callback = dmi_matched,
> .ident = "Dell Inc. Inspiron 5675",
> @@ -431,6 +307,103 @@ struct alienfx_platdata {
>
> static u8 interface;
>
> +struct awcc_quirks {
> + bool gmode;
> +};
> +
> +static struct awcc_quirks g_series_quirks = {
> + .gmode = true,
> +};
> +
> +static struct awcc_quirks generic_quirks = {
> + .gmode = false,
> +};
> +
> +static const struct dmi_system_id awcc_dmi_table[] __initconst = {
> + {
> + .ident = "Alienware m17 R5",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
> + },
> + .driver_data = &generic_quirks,
> + },
> + {
> + .ident = "Alienware m18 R2",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"),
> + },
> + .driver_data = &generic_quirks,
> + },
> + {
> + .ident = "Alienware x15 R1",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"),
> + },
> + .driver_data = &generic_quirks,
> + },
> + {
> + .ident = "Alienware x17 R2",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"),
> + },
> + .driver_data = &generic_quirks,
> + },
> + {
> + .ident = "Dell Inc. G15 5510",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G15 5511",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G15 5515",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G3 3500",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G3 3590",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G5 5500",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> +};
> +
> +struct awcc_quirks *awcc;
I just noticed this should be static. I'll fix for v5 after Armin's
feedback.
~ Kurt
> <snip>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 01/14] platform/x86: alienware-wmi: Add a state container for LED control feature
2025-01-17 8:13 ` [PATCH v4 01/14] platform/x86: alienware-wmi: Add a state container for LED control feature Kurt Borja
@ 2025-01-18 23:34 ` Armin Wolf
0 siblings, 0 replies; 24+ messages in thread
From: Armin Wolf @ 2025-01-18 23:34 UTC (permalink / raw)
To: Kurt Borja, platform-driver-x86
Cc: Ilpo Järvinen, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
Am 17.01.25 um 09:13 schrieb Kurt Borja:
> Add a state container for the "alienware-wmi" platform device and
> initialize it on the new alienfx_probe(). Migrate all LED control functions
> to use this state container, as well as hdmi, amplifier, deepslp group
> visibility methods, to support upcoming file split.
Where does this patch touch the visibility methods of the attribute groups?
>
> Additionally move the led_classdev registration to the platform driver
> probe and make it device managed.
>
> Drop alienware_zone_init() and alienware_zone_exit() because they are no
> longer needed.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
> drivers/platform/x86/dell/alienware-wmi.c | 117 ++++++++++++----------
> 1 file changed, 65 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index 63cf016bc912..5779b025761b 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -404,13 +404,18 @@ struct wmax_u32_args {
> u8 arg3;
> };
>
> +struct alienfx_priv {
> + struct platform_device *pdev;
> + struct led_classdev global_led;
> + struct color_platform colors[4];
> + u8 global_brightness;
> + u8 lighting_control_state;
> +};
> +
> static struct platform_device *platform_device;
> -static struct color_platform colors[4];
> static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
>
> static u8 interface;
> -static u8 lighting_control_state;
> -static u8 global_brightness;
>
> /*
> * Helpers used for zone control
> @@ -442,7 +447,7 @@ static int parse_rgb(const char *buf, struct color_platform *colors)
> /*
> * Individual RGB zone control
> */
> -static int alienware_update_led(u8 location)
> +static int alienware_update_led(struct alienfx_priv *priv, u8 location)
> {
> int method_id;
> acpi_status status;
> @@ -452,21 +457,21 @@ static int alienware_update_led(u8 location)
> struct wmax_led_args wmax_basic_args;
> if (interface == WMAX) {
> wmax_basic_args.led_mask = 1 << location;
> - wmax_basic_args.colors = colors[location];
> - wmax_basic_args.state = lighting_control_state;
> + wmax_basic_args.colors = priv->colors[location];
> + wmax_basic_args.state = priv->lighting_control_state;
> guid = WMAX_CONTROL_GUID;
> method_id = WMAX_METHOD_ZONE_CONTROL;
>
> input.length = sizeof(wmax_basic_args);
> input.pointer = &wmax_basic_args;
> } else {
> - legacy_args.colors = colors[location];
> - legacy_args.brightness = global_brightness;
> + legacy_args.colors = priv->colors[location];
> + legacy_args.brightness = priv->global_brightness;
> legacy_args.state = 0;
> - if (lighting_control_state == LEGACY_BOOTING ||
> - lighting_control_state == LEGACY_SUSPEND) {
> + if (priv->lighting_control_state == LEGACY_BOOTING ||
> + priv->lighting_control_state == LEGACY_SUSPEND) {
> guid = LEGACY_POWER_CONTROL_GUID;
> - legacy_args.state = lighting_control_state;
> + legacy_args.state = priv->lighting_control_state;
> } else
> guid = LEGACY_CONTROL_GUID;
> method_id = location + 1;
> @@ -485,22 +490,26 @@ static int alienware_update_led(u8 location)
> static ssize_t zone_show(struct device *dev, struct device_attribute *attr,
> char *buf, u8 location)
> {
> + struct alienfx_priv *priv = dev_get_drvdata(dev);
> + struct color_platform *colors = &priv->colors[location];
> +
> return sprintf(buf, "red: %d, green: %d, blue: %d\n",
> - colors[location].red, colors[location].green,
> - colors[location].blue);
> + colors->red, colors->green, colors->blue);
>
> }
>
> static ssize_t zone_store(struct device *dev, struct device_attribute *attr,
> const char *buf, size_t count, u8 location)
> {
> + struct alienfx_priv *priv = dev_get_drvdata(dev);
> + struct color_platform *colors = &priv->colors[location];
> int ret;
>
> - ret = parse_rgb(buf, &colors[location]);
> + ret = parse_rgb(buf, colors);
> if (ret)
> return ret;
>
> - ret = alienware_update_led(location);
> + ret = alienware_update_led(priv, location);
>
> return ret ? ret : count;
> }
> @@ -568,9 +577,11 @@ static ssize_t lighting_control_state_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> {
> - if (lighting_control_state == LEGACY_BOOTING)
> + struct alienfx_priv *priv = dev_get_drvdata(dev);
> +
> + if (priv->lighting_control_state == LEGACY_BOOTING)
> return sysfs_emit(buf, "[booting] running suspend\n");
> - else if (lighting_control_state == LEGACY_SUSPEND)
> + else if (priv->lighting_control_state == LEGACY_SUSPEND)
> return sysfs_emit(buf, "booting running [suspend]\n");
>
> return sysfs_emit(buf, "booting [running] suspend\n");
> @@ -580,6 +591,7 @@ static ssize_t lighting_control_state_store(struct device *dev,
> struct device_attribute *attr,
> const char *buf, size_t count)
> {
> + struct alienfx_priv *priv = dev_get_drvdata(dev);
> u8 val;
>
> if (strcmp(buf, "booting\n") == 0)
> @@ -591,9 +603,9 @@ static ssize_t lighting_control_state_store(struct device *dev,
> else
> val = WMAX_RUNNING;
>
> - lighting_control_state = val;
> + priv->lighting_control_state = val;
> pr_debug("alienware-wmi: updated control state to %d\n",
> - lighting_control_state);
> + priv->lighting_control_state);
>
> return count;
> }
> @@ -653,43 +665,26 @@ static int wmax_brightness(int brightness)
> static void global_led_set(struct led_classdev *led_cdev,
> enum led_brightness brightness)
> {
> + struct alienfx_priv *priv = container_of(led_cdev, struct alienfx_priv,
> + global_led);
> int ret;
> - global_brightness = brightness;
> +
> + priv->global_brightness = brightness;
> +
> if (interface == WMAX)
> ret = wmax_brightness(brightness);
> else
> - ret = alienware_update_led(0);
> + ret = alienware_update_led(priv, 0);
> if (ret)
> pr_err("LED brightness update failed\n");
> }
>
> static enum led_brightness global_led_get(struct led_classdev *led_cdev)
> {
> - return global_brightness;
> -}
> -
> -static struct led_classdev global_led = {
> - .brightness_set = global_led_set,
> - .brightness_get = global_led_get,
> - .name = "alienware::global_brightness",
> -};
> -
> -static int alienware_zone_init(struct platform_device *dev)
> -{
> - if (interface == WMAX) {
> - lighting_control_state = WMAX_RUNNING;
> - } else if (interface == LEGACY) {
> - lighting_control_state = LEGACY_RUNNING;
> - }
> - global_led.max_brightness = 0x0F;
> - global_brightness = global_led.max_brightness;
> + struct alienfx_priv *priv = container_of(led_cdev, struct alienfx_priv,
> + global_led);
>
> - return led_classdev_register(&dev->dev, &global_led);
> -}
> -
> -static void alienware_zone_exit(struct platform_device *dev)
> -{
> - led_classdev_unregister(&global_led);
> + return priv->global_brightness;
> }
>
> static acpi_status alienware_wmax_command(void *in_args, size_t in_size,
> @@ -1145,6 +1140,30 @@ static int create_thermal_profile(struct platform_device *platform_device)
> /*
> * Platform Driver
> */
> +static int alienfx_probe(struct platform_device *pdev)
> +{
> + struct alienfx_priv *priv;
> +
> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + if (interface == WMAX)
> + priv->lighting_control_state = WMAX_RUNNING;
> + else
> + priv->lighting_control_state = LEGACY_RUNNING;
> +
> + priv->pdev = pdev;
> + priv->global_led.name = "alienware::global_brightness";
> + priv->global_led.brightness_set = global_led_set;
> + priv->global_led.brightness_get = global_led_get;
> + priv->global_led.max_brightness = 0x0F;
> + priv->global_brightness = priv->global_led.max_brightness;
> + platform_set_drvdata(pdev, priv);
> +
> + return devm_led_classdev_register(&pdev->dev, &priv->global_led);
> +}
> +
> static const struct attribute_group *alienfx_groups[] = {
> &zone_attribute_group,
> &hdmi_attribute_group,
> @@ -1158,6 +1177,7 @@ static struct platform_driver platform_driver = {
> .name = "alienware-wmi",
> .dev_groups = alienfx_groups,
> },
> + .probe = alienfx_probe,
> };
>
> static int __init alienware_wmi_init(void)
> @@ -1205,14 +1225,8 @@ static int __init alienware_wmi_init(void)
> goto fail_prep_thermal_profile;
> }
>
> - ret = alienware_zone_init(platform_device);
> - if (ret)
> - goto fail_prep_zones;
> -
> return 0;
>
> -fail_prep_zones:
> - alienware_zone_exit(platform_device);
> fail_prep_thermal_profile:
> platform_device_del(platform_device);
> fail_platform_device2:
> @@ -1227,7 +1241,6 @@ module_init(alienware_wmi_init);
>
> static void __exit alienware_wmi_exit(void)
> {
> - alienware_zone_exit(platform_device);
> platform_device_unregister(platform_device);
> platform_driver_unregister(&platform_driver);
> }
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 02/14] platform/x86: alienware-wmi: Add WMI Drivers
2025-01-17 8:13 ` [PATCH v4 02/14] platform/x86: alienware-wmi: Add WMI Drivers Kurt Borja
@ 2025-01-18 23:48 ` Armin Wolf
2025-01-19 16:47 ` Kurt Borja
0 siblings, 1 reply; 24+ messages in thread
From: Armin Wolf @ 2025-01-18 23:48 UTC (permalink / raw)
To: Kurt Borja, platform-driver-x86
Cc: Ilpo Järvinen, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
Am 17.01.25 um 09:13 schrieb Kurt Borja:
> Add WMI drivers for LEGACY and WMAX devices.
>
> This involves moving platform driver and device registration to a helper
> function, which is now called from the driver's preferred WMI device
> driver probe. However this is only done if !quirks->thermal because
> newer WMAX interface doesn't support any of the features exposed by this
> device.
>
> Only one driver is registered on module initialization to prevent
> registering duplicate platform driver and device.
>
> Additionally, create_thermal_profile() now takes wmi_device * instead of
> platform_device *.
>
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
> drivers/platform/x86/dell/alienware-wmi.c | 200 +++++++++++++++++-----
> 1 file changed, 160 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index 5779b025761b..e1a5a867f144 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -15,6 +15,7 @@
> #include <linux/platform_profile.h>
> #include <linux/dmi.h>
> #include <linux/leds.h>
> +#include <linux/wmi.h>
>
> #define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492"
> #define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492"
> @@ -39,8 +40,6 @@
> MODULE_AUTHOR("Mario Limonciello <mario.limonciello@outlook.com>");
> MODULE_DESCRIPTION("Alienware special feature control");
> MODULE_LICENSE("GPL");
> -MODULE_ALIAS("wmi:" LEGACY_CONTROL_GUID);
> -MODULE_ALIAS("wmi:" WMAX_CONTROL_GUID);
>
> static bool force_platform_profile;
> module_param_unsafe(force_platform_profile, bool, 0);
> @@ -412,7 +411,10 @@ struct alienfx_priv {
> u8 lighting_control_state;
> };
>
> -static struct platform_device *platform_device;
> +struct alienfx_platdata {
> + struct wmi_device *wdev;
> +};
> +
> static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
>
> static u8 interface;
> @@ -1127,11 +1129,11 @@ static const struct platform_profile_ops awcc_platform_profile_ops = {
> .profile_set = thermal_profile_set,
> };
>
> -static int create_thermal_profile(struct platform_device *platform_device)
> +static int create_thermal_profile(struct wmi_device *wdev)
> {
> struct device *ppdev;
>
> - ppdev = devm_platform_profile_register(&platform_device->dev, "alienware-wmi",
> + ppdev = devm_platform_profile_register(&wdev->dev, "alienware-wmi",
> NULL, &awcc_platform_profile_ops);
>
> return PTR_ERR_OR_ZERO(ppdev);
> @@ -1166,6 +1168,10 @@ static int alienfx_probe(struct platform_device *pdev)
>
> static const struct attribute_group *alienfx_groups[] = {
> &zone_attribute_group,
> + NULL
> +};
> +
> +static const struct attribute_group *wmax_alienfx_groups[] = {
> &hdmi_attribute_group,
> &lifier_attribute_group,
> &deepsleep_attribute_group,
> @@ -1180,19 +1186,150 @@ static struct platform_driver platform_driver = {
> .probe = alienfx_probe,
> };
>
> -static int __init alienware_wmi_init(void)
> +static int alienware_alienfx_setup(struct alienfx_platdata *pdata)
> {
> + struct platform_device *pdev;
> int ret;
>
> - if (wmi_has_guid(LEGACY_CONTROL_GUID))
> - interface = LEGACY;
> - else if (wmi_has_guid(WMAX_CONTROL_GUID))
> - interface = WMAX;
> - else {
> - pr_warn("alienware-wmi: No known WMI GUID found\n");
> - return -ENODEV;
> + ret = platform_driver_register(&platform_driver);
> + if (ret < 0)
> + return ret;
Can you register this platform driver during module initialization? Otherwise we might encounter
a kernel crash should a WMI driver probe multiple devices and thus calling this method more than once.
Please note however that platform_device_register_data() can be called multiple times (it simply returns
an error should the "alienware-wmi" device already exist).
> +
> + pdev = platform_device_register_data(NULL, "alienware-wmi",
> + PLATFORM_DEVID_NONE, pdata,
> + sizeof(*pdata));
> +
> + if (IS_ERR(pdev)) {
> + platform_driver_unregister(&platform_driver);
> + return PTR_ERR(pdev);
> }
>
> + dev_set_drvdata(&pdata->wdev->dev, pdev);
> +
> + return 0;
> +}
> +
> +static void alienware_alienfx_exit(struct wmi_device *wdev)
> +{
> + struct platform_device *pdev = dev_get_drvdata(&wdev->dev);
> +
> + platform_device_unregister(pdev);
> + platform_driver_unregister(&platform_driver);
> +}
> +
> +/*
> + * Legacy WMI driver
> + */
> +static int legacy_wmi_probe(struct wmi_device *wdev, const void *context)
> +{
> + struct alienfx_platdata pdata = {
> + .wdev = wdev,
> + };
> +
> + return alienware_alienfx_setup(&pdata);
> +}
> +
> +static void legacy_wmi_remove(struct wmi_device *wdev)
> +{
> + alienware_alienfx_exit(wdev);
> +}
> +
> +static struct wmi_device_id alienware_legacy_device_id_table[] = {
Please make this device id table const.
> + { LEGACY_CONTROL_GUID, NULL },
> + { },
> +};
> +MODULE_DEVICE_TABLE(wmi, alienware_legacy_device_id_table);
> +
> +static struct wmi_driver alienware_legacy_wmi_driver = {
> + .driver = {
> + .name = "alienware-wmi-alienfx",
> + .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> + },
> + .id_table = alienware_legacy_device_id_table,
> + .probe = legacy_wmi_probe,
> + .remove = legacy_wmi_remove,
> +};
> +
> +static int __init alienware_legacy_wmi_init(void)
> +{
> + return wmi_driver_register(&alienware_legacy_wmi_driver);
> +}
> +
> +static void __exit alienware_legacy_wmi_exit(void)
> +{
> + wmi_driver_unregister(&alienware_legacy_wmi_driver);
> +}
> +
> +/*
> + * WMAX WMI driver
> + */
> +static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
> +{
> + struct alienfx_platdata pdata = {
> + .wdev = wdev,
> + };
> + struct platform_device *pdev;
> + int ret;
> +
> + if (quirks->thermal) {
> + return create_thermal_profile(wdev);
> + } else {
> + ret = alienware_alienfx_setup(&pdata);
> + if (ret < 0)
> + return ret;
> +
> + pdev = dev_get_drvdata(&wdev->dev);
> +
> + ret = device_add_groups(&pdev->dev, wmax_alienfx_groups);
> + if (ret < 0)
> + alienware_alienfx_exit(wdev);
> +
> + return ret;
> + }
> +}
> +
> +static void wmax_wmi_remove(struct wmi_device *wdev)
> +{
> + struct platform_device *pdev;
> +
> + if (!quirks->thermal) {
> + pdev = dev_get_drvdata(&wdev->dev);
> +
> + device_remove_groups(&pdev->dev, wmax_alienfx_groups);
> + alienware_alienfx_exit(wdev);
> + }
> +}
> +
> +static struct wmi_device_id alienware_wmax_device_id_table[] = {
Please make this device id table const.
Other than that the code looks promising.
Thanks,
Armin Wolf
> + { WMAX_CONTROL_GUID, NULL },
> + { },
> +};
> +MODULE_DEVICE_TABLE(wmi, alienware_wmax_device_id_table);
> +
> +static struct wmi_driver alienware_wmax_wmi_driver = {
> + .driver = {
> + .name = "alienware-wmi-wmax",
> + .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> + },
> + .id_table = alienware_wmax_device_id_table,
> + .probe = wmax_wmi_probe,
> + .remove = wmax_wmi_remove,
> +};
> +
> +static int __init alienware_wmax_wmi_init(void)
> +{
> + return wmi_driver_register(&alienware_wmax_wmi_driver);
> +}
> +
> +static void __exit alienware_wmax_wmi_exit(void)
> +{
> + wmi_driver_unregister(&alienware_wmax_wmi_driver);
> +}
> +
> +static int __init alienware_wmi_init(void)
> +{
> + int ret;
> +
> dmi_check_system(alienware_quirks);
> if (quirks == NULL)
> quirks = &quirk_unknown;
> @@ -1207,33 +1344,14 @@ static int __init alienware_wmi_init(void)
> pr_warn("force_gmode requires platform profile support\n");
> }
>
> - ret = platform_driver_register(&platform_driver);
> - if (ret)
> - goto fail_platform_driver;
> - platform_device = platform_device_alloc("alienware-wmi", PLATFORM_DEVID_NONE);
> - if (!platform_device) {
> - ret = -ENOMEM;
> - goto fail_platform_device1;
> - }
> - ret = platform_device_add(platform_device);
> - if (ret)
> - goto fail_platform_device2;
> -
> - if (quirks->thermal) {
> - ret = create_thermal_profile(platform_device);
> - if (ret)
> - goto fail_prep_thermal_profile;
> + if (wmi_has_guid(WMAX_CONTROL_GUID)) {
> + interface = WMAX;
> + ret = alienware_wmax_wmi_init();
> + } else {
> + interface = LEGACY;
> + ret = alienware_legacy_wmi_init();
> }
>
> - return 0;
> -
> -fail_prep_thermal_profile:
> - platform_device_del(platform_device);
> -fail_platform_device2:
> - platform_device_put(platform_device);
> -fail_platform_device1:
> - platform_driver_unregister(&platform_driver);
> -fail_platform_driver:
> return ret;
> }
>
> @@ -1241,8 +1359,10 @@ module_init(alienware_wmi_init);
>
> static void __exit alienware_wmi_exit(void)
> {
> - platform_device_unregister(platform_device);
> - platform_driver_unregister(&platform_driver);
> + if (interface == WMAX)
> + alienware_wmax_wmi_exit();
> + else
> + alienware_legacy_wmi_exit();
> }
>
> module_exit(alienware_wmi_exit);
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 04/14] platform/x86: alienware-wmi: Refactor LED control methods
2025-01-17 8:13 ` [PATCH v4 04/14] platform/x86: alienware-wmi: Refactor LED " Kurt Borja
@ 2025-01-18 23:58 ` Armin Wolf
2025-01-19 16:50 ` Kurt Borja
0 siblings, 1 reply; 24+ messages in thread
From: Armin Wolf @ 2025-01-18 23:58 UTC (permalink / raw)
To: Kurt Borja, platform-driver-x86
Cc: Ilpo Järvinen, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
Am 17.01.25 um 09:13 schrieb Kurt Borja:
> Both WMI devices handled by this module specify a distinct interface for
> LED control. Previously this module handled this by dynamically adapting
> arguments passed to wmi_evaluate_method() based on the `interface`
> global variable.
>
> To avoid the use of global variables, and enable the migration to
> non-deprecated WMI methods, let the WMI drivers define upd_led and
> upd_brightness operations, which completely replace
> alienware_update_led() and wmax_brightness().
>
> Also define alienware_wmi_command(), which serves as a wrapper for
> wmidev_evaluate_method(). This new method is very similar to
> alienware_wmax_command() but is WMI device agnostic.
>
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
> drivers/platform/x86/dell/alienware-wmi.c | 164 ++++++++++++++--------
> 1 file changed, 102 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index 7356260f7f09..c9d9cf36b87b 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -417,12 +417,42 @@ struct alienfx_priv {
> u8 lighting_control_state;
> };
>
> +struct alienfx_ops {
> + int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev,
> + u8 location);
> + int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev,
> + u8 brightness);
> +};
> +
> struct alienfx_platdata {
> struct wmi_device *wdev;
> + struct alienfx_ops ops;
> };
>
> static u8 interface;
>
> +static int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
> + void *in_args, size_t in_size, u32 *out_data)
> +{
> + struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
> + struct acpi_buffer in = {in_size, in_args};
> + union acpi_object *obj;
> + acpi_status ret;
> +
> + ret = wmidev_evaluate_method(wdev, 0, method_id, &in, out_data ? &out : NULL);
> + if (ACPI_FAILURE(ret))
> + return -EIO;
> +
> + obj = out.pointer;
> +
> + if (out_data && obj && obj->type == ACPI_TYPE_INTEGER)
> + *out_data = (u32)obj->integer.value;
Please return an error here if out_data is true but obj is NULL or not of ACPI_TYPE_INTEGER.
With this being fixed:
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> +
> + kfree(obj);
> +
> + return 0;
> +}
> +
> /*
> * Helpers used for zone control
> */
> @@ -453,46 +483,6 @@ static int parse_rgb(const char *buf, struct color_platform *colors)
> /*
> * Individual RGB zone control
> */
> -static int alienware_update_led(struct alienfx_priv *priv, u8 location)
> -{
> - int method_id;
> - acpi_status status;
> - char *guid;
> - struct acpi_buffer input;
> - struct legacy_led_args legacy_args;
> - struct wmax_led_args wmax_basic_args;
> - if (interface == WMAX) {
> - wmax_basic_args.led_mask = 1 << location;
> - wmax_basic_args.colors = priv->colors[location];
> - wmax_basic_args.state = priv->lighting_control_state;
> - guid = WMAX_CONTROL_GUID;
> - method_id = WMAX_METHOD_ZONE_CONTROL;
> -
> - input.length = sizeof(wmax_basic_args);
> - input.pointer = &wmax_basic_args;
> - } else {
> - legacy_args.colors = priv->colors[location];
> - legacy_args.brightness = priv->global_brightness;
> - legacy_args.state = 0;
> - if (priv->lighting_control_state == LEGACY_BOOTING ||
> - priv->lighting_control_state == LEGACY_SUSPEND) {
> - guid = LEGACY_POWER_CONTROL_GUID;
> - legacy_args.state = priv->lighting_control_state;
> - } else
> - guid = LEGACY_CONTROL_GUID;
> - method_id = location + 1;
> -
> - input.length = sizeof(legacy_args);
> - input.pointer = &legacy_args;
> - }
> - pr_debug("alienware-wmi: guid %s method %d\n", guid, method_id);
> -
> - status = wmi_evaluate_method(guid, 0, method_id, &input, NULL);
> - if (ACPI_FAILURE(status))
> - pr_err("alienware-wmi: zone set failure: %u\n", status);
> - return ACPI_FAILURE(status);
> -}
> -
> static ssize_t zone_show(struct device *dev, struct device_attribute *attr,
> char *buf, u8 location)
> {
> @@ -509,13 +499,14 @@ static ssize_t zone_store(struct device *dev, struct device_attribute *attr,
> {
> struct alienfx_priv *priv = dev_get_drvdata(dev);
> struct color_platform *colors = &priv->colors[location];
> + struct alienfx_platdata *pdata = dev_get_platdata(dev);
> int ret;
>
> ret = parse_rgb(buf, colors);
> if (ret)
> return ret;
>
> - ret = alienware_update_led(priv, location);
> + ret = pdata->ops.upd_led(priv, pdata->wdev, location);
>
> return ret ? ret : count;
> }
> @@ -651,36 +642,17 @@ static struct attribute_group zone_attribute_group = {
> /*
> * LED Brightness (Global)
> */
> -static int wmax_brightness(int brightness)
> -{
> - acpi_status status;
> - struct acpi_buffer input;
> - struct wmax_brightness_args args = {
> - .led_mask = 0xFF,
> - .percentage = brightness,
> - };
> - input.length = sizeof(args);
> - input.pointer = &args;
> - status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0,
> - WMAX_METHOD_BRIGHTNESS, &input, NULL);
> - if (ACPI_FAILURE(status))
> - pr_err("alienware-wmi: brightness set failure: %u\n", status);
> - return ACPI_FAILURE(status);
> -}
> -
> static void global_led_set(struct led_classdev *led_cdev,
> enum led_brightness brightness)
> {
> struct alienfx_priv *priv = container_of(led_cdev, struct alienfx_priv,
> global_led);
> + struct alienfx_platdata *pdata = dev_get_platdata(&priv->pdev->dev);
> int ret;
>
> priv->global_brightness = brightness;
>
> - if (interface == WMAX)
> - ret = wmax_brightness(brightness);
> - else
> - ret = alienware_update_led(priv, 0);
> + ret = pdata->ops.upd_brightness(priv, pdata->wdev, brightness);
> if (ret)
> pr_err("LED brightness update failed\n");
> }
> @@ -1234,10 +1206,49 @@ static void alienware_alienfx_exit(struct wmi_device *wdev)
> /*
> * Legacy WMI driver
> */
> +static int legacy_wmi_update_led(struct alienfx_priv *priv,
> + struct wmi_device *wdev, u8 location)
> +{
> + struct legacy_led_args legacy_args = {
> + .colors = priv->colors[location],
> + .brightness = priv->global_brightness,
> + .state = 0,
> + };
> + struct acpi_buffer input;
> + acpi_status status;
> +
> + if (legacy_args.state != LEGACY_RUNNING) {
> + legacy_args.state = priv->lighting_control_state;
> +
> + input.length = sizeof(legacy_args);
> + input.pointer = &legacy_args;
> +
> + status = wmi_evaluate_method(LEGACY_POWER_CONTROL_GUID, 0,
> + location + 1, &input, NULL);
> + if (ACPI_FAILURE(status))
> + return -EIO;
> +
> + return 0;
> + }
> +
> + return alienware_wmi_command(wdev, location + 1, &legacy_args,
> + sizeof(legacy_args), NULL);
> +}
> +
> +static int legacy_wmi_update_brightness(struct alienfx_priv *priv,
> + struct wmi_device *wdev, u8 brightness)
> +{
> + return legacy_wmi_update_led(priv, wdev, 0);
> +}
> +
> static int legacy_wmi_probe(struct wmi_device *wdev, const void *context)
> {
> struct alienfx_platdata pdata = {
> .wdev = wdev,
> + .ops = {
> + .upd_led = legacy_wmi_update_led,
> + .upd_brightness = legacy_wmi_update_brightness,
> + },
> };
>
> return alienware_alienfx_setup(&pdata);
> @@ -1277,10 +1288,39 @@ static void __exit alienware_legacy_wmi_exit(void)
> /*
> * WMAX WMI driver
> */
> +static int wmax_wmi_update_led(struct alienfx_priv *priv,
> + struct wmi_device *wdev, u8 location)
> +{
> + struct wmax_led_args in_args = {
> + .led_mask = 1 << location,
> + .colors = priv->colors[location],
> + .state = priv->lighting_control_state,
> + };
> +
> + return alienware_wmi_command(wdev, WMAX_METHOD_ZONE_CONTROL, &in_args,
> + sizeof(in_args), NULL);
> +}
> +
> +static int wmax_wmi_update_brightness(struct alienfx_priv *priv,
> + struct wmi_device *wdev, u8 brightness)
> +{
> + struct wmax_brightness_args in_args = {
> + .led_mask = 0xFF,
> + .percentage = brightness,
> + };
> +
> + return alienware_wmi_command(wdev, WMAX_METHOD_BRIGHTNESS, &in_args,
> + sizeof(in_args), NULL);
> +}
> +
> static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
> {
> struct alienfx_platdata pdata = {
> .wdev = wdev,
> + .ops = {
> + .upd_led = wmax_wmi_update_led,
> + .upd_brightness = wmax_wmi_update_brightness,
> + },
> };
> struct platform_device *pdev;
> int ret;
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 07/14] platform/x86: alienware-wmi: Split DMI table
2025-01-17 8:13 ` [PATCH v4 07/14] platform/x86: alienware-wmi: Split DMI table Kurt Borja
2025-01-17 17:15 ` Kurt Borja
@ 2025-01-19 0:03 ` Armin Wolf
1 sibling, 0 replies; 24+ messages in thread
From: Armin Wolf @ 2025-01-19 0:03 UTC (permalink / raw)
To: Kurt Borja, platform-driver-x86
Cc: Ilpo Järvinen, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
Am 17.01.25 um 09:13 schrieb Kurt Borja:
> Split thermal features into a new DMI table to support upcoming file
> split. While at it:
>
> Rename quirk_entry -> alienfx_features,
> Rename quirks -> alienfx
>
> and change hdmi_mux, amplifier and deepslp types to bool, because they are
> already being implicitly used as bools.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
> drivers/platform/x86/dell/alienware-wmi.c | 337 ++++++++++------------
> 1 file changed, 158 insertions(+), 179 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index 877b3d9d7cab..5d9816521072 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -113,102 +113,68 @@ static const enum platform_profile_option wmax_mode_to_platform_profile[THERMAL_
> [THERMAL_MODE_BASIC_PERFORMANCE] = PLATFORM_PROFILE_PERFORMANCE,
> };
>
> -struct quirk_entry {
> +struct alienfx_quirks {
> u8 num_zones;
> - u8 hdmi_mux;
> - u8 amplifier;
> - u8 deepslp;
> - bool thermal;
> - bool gmode;
> + bool hdmi_mux;
> + bool amplifier;
> + bool deepslp;
> };
>
> -static struct quirk_entry *quirks;
> +static struct alienfx_quirks *alienfx;
>
>
> -static struct quirk_entry quirk_inspiron5675 = {
> +static struct alienfx_quirks quirk_inspiron5675 = {
> .num_zones = 2,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = false,
> + .amplifier = false,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_unknown = {
> +static struct alienfx_quirks quirk_unknown = {
> .num_zones = 2,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = false,
> + .amplifier = false,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_x51_r1_r2 = {
> +static struct alienfx_quirks quirk_x51_r1_r2 = {
> .num_zones = 3,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = false,
> + .amplifier = false,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_x51_r3 = {
> +static struct alienfx_quirks quirk_x51_r3 = {
> .num_zones = 4,
> - .hdmi_mux = 0,
> - .amplifier = 1,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = false,
> + .amplifier = true,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_asm100 = {
> +static struct alienfx_quirks quirk_asm100 = {
> .num_zones = 2,
> - .hdmi_mux = 1,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = true,
> + .amplifier = false,
> + .deepslp = false,
> };
>
> -static struct quirk_entry quirk_asm200 = {
> +static struct alienfx_quirks quirk_asm200 = {
> .num_zones = 2,
> - .hdmi_mux = 1,
> - .amplifier = 0,
> - .deepslp = 1,
> - .thermal = false,
> - .gmode = false,
> + .hdmi_mux = true,
> + .amplifier = false,
> + .deepslp = true,
> };
>
> -static struct quirk_entry quirk_asm201 = {
> +static struct alienfx_quirks quirk_asm201 = {
> .num_zones = 2,
> - .hdmi_mux = 1,
> - .amplifier = 1,
> - .deepslp = 1,
> - .thermal = false,
> - .gmode = false,
> -};
> -
> -static struct quirk_entry quirk_g_series = {
> - .num_zones = 2,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = true,
> - .gmode = true,
> -};
> -
> -static struct quirk_entry quirk_x_series = {
> - .num_zones = 2,
> - .hdmi_mux = 0,
> - .amplifier = 0,
> - .deepslp = 0,
> - .thermal = true,
> - .gmode = false,
> + .hdmi_mux = true,
> + .amplifier = true,
> + .deepslp = true,
> };
>
> static int __init dmi_matched(const struct dmi_system_id *dmi)
> {
> - quirks = dmi->driver_data;
> + alienfx = dmi->driver_data;
> return 1;
> }
>
> @@ -240,42 +206,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = {
> },
> .driver_data = &quirk_asm201,
> },
> - {
> - .callback = dmi_matched,
> - .ident = "Alienware m17 R5",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
> - },
> - .driver_data = &quirk_x_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Alienware m18 R2",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"),
> - },
> - .driver_data = &quirk_x_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Alienware x15 R1",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"),
> - },
> - .driver_data = &quirk_x_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Alienware x17 R2",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"),
> - },
> - .driver_data = &quirk_x_series,
> - },
> {
> .callback = dmi_matched,
> .ident = "Alienware X51 R1",
> @@ -303,60 +233,6 @@ static const struct dmi_system_id alienware_quirks[] __initconst = {
> },
> .driver_data = &quirk_x51_r3,
> },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G15 5510",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G15 5511",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G15 5515",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G3 3500",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G3 3590",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> - {
> - .callback = dmi_matched,
> - .ident = "Dell Inc. G5 5500",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"),
> - },
> - .driver_data = &quirk_g_series,
> - },
> {
> .callback = dmi_matched,
> .ident = "Dell Inc. Inspiron 5675",
> @@ -431,6 +307,103 @@ struct alienfx_platdata {
>
> static u8 interface;
>
> +struct awcc_quirks {
> + bool gmode;
> +};
> +
> +static struct awcc_quirks g_series_quirks = {
> + .gmode = true,
> +};
> +
> +static struct awcc_quirks generic_quirks = {
> + .gmode = false,
> +};
> +
> +static const struct dmi_system_id awcc_dmi_table[] __initconst = {
> + {
> + .ident = "Alienware m17 R5",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"),
> + },
> + .driver_data = &generic_quirks,
> + },
> + {
> + .ident = "Alienware m18 R2",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R2"),
> + },
> + .driver_data = &generic_quirks,
> + },
> + {
> + .ident = "Alienware x15 R1",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x15 R1"),
> + },
> + .driver_data = &generic_quirks,
> + },
> + {
> + .ident = "Alienware x17 R2",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Alienware"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware x17 R2"),
> + },
> + .driver_data = &generic_quirks,
> + },
> + {
> + .ident = "Dell Inc. G15 5510",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5510"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G15 5511",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5511"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G15 5515",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5515"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G3 3500",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "G3 3500"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G3 3590",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "G3 3590"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> + {
> + .ident = "Dell Inc. G5 5500",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "G5 5500"),
> + },
> + .driver_data = &g_series_quirks,
> + },
> +};
> +
> +struct awcc_quirks *awcc;
> +
> static int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
> void *in_args, size_t in_size, u32 *out_data)
> {
> @@ -612,7 +585,7 @@ static DEVICE_ATTR_RW(lighting_control_state);
> static umode_t zone_attr_visible(struct kobject *kobj,
> struct attribute *attr, int n)
> {
> - if (n < quirks->num_zones + 1)
> + if (n < alienfx->num_zones + 1)
> return attr->mode;
>
> return 0;
> @@ -620,7 +593,7 @@ static umode_t zone_attr_visible(struct kobject *kobj,
>
> static bool zone_group_visible(struct kobject *kobj)
> {
> - return quirks->num_zones > 0;
> + return alienfx->num_zones > 0;
> }
> DEFINE_SYSFS_GROUP_VISIBLE(zone);
>
> @@ -746,7 +719,7 @@ static DEVICE_ATTR_RW(source);
>
> static bool hdmi_group_visible(struct kobject *kobj)
> {
> - return quirks->hdmi_mux;
> + return alienfx->hdmi_mux;
> }
> DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(hdmi);
>
> @@ -795,7 +768,7 @@ static DEVICE_ATTR_RO(status);
>
> static bool amplifier_group_visible(struct kobject *kobj)
> {
> - return quirks->amplifier;
> + return alienfx->amplifier;
> }
> DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(amplifier);
>
> @@ -868,7 +841,7 @@ static DEVICE_ATTR_RW(deepsleep);
>
> static bool deepsleep_group_visible(struct kobject *kobj)
> {
> - return quirks->deepslp;
> + return alienfx->deepslp;
> }
> DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(deepsleep);
>
> @@ -1009,7 +982,7 @@ static int thermal_profile_set(struct device *dev,
> {
> struct awcc_priv *priv = dev_get_drvdata(dev);
>
> - if (quirks->gmode) {
> + if (awcc->gmode) {
> u32 gmode_status;
> int ret;
>
> @@ -1075,7 +1048,7 @@ static int thermal_profile_probe(void *drvdata, unsigned long *choices)
> if (bitmap_empty(choices, PLATFORM_PROFILE_LAST))
> return -ENODEV;
>
> - if (quirks->gmode) {
> + if (awcc->gmode) {
> priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =
> WMAX_THERMAL_MODE_GMODE;
>
> @@ -1308,7 +1281,7 @@ static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
> struct platform_device *pdev;
> int ret;
>
> - if (quirks->thermal) {
> + if (awcc) {
> return alienware_awcc_setup(wdev);
> } else {
> ret = alienware_alienfx_setup(&pdata);
> @@ -1329,7 +1302,7 @@ static void wmax_wmi_remove(struct wmi_device *wdev)
> {
> struct platform_device *pdev;
>
> - if (!quirks->thermal) {
> + if (!awcc) {
> pdev = dev_get_drvdata(&wdev->dev);
>
> device_remove_groups(&pdev->dev, wmax_alienfx_groups);
> @@ -1355,6 +1328,22 @@ static struct wmi_driver alienware_wmax_wmi_driver = {
>
> static int __init alienware_wmax_wmi_init(void)
> {
> + const struct dmi_system_id *id;
> +
> + id = dmi_first_match(awcc_dmi_table);
> + if (id)
> + awcc = id->driver_data;
> +
> + if (force_platform_profile)
> + awcc = &generic_quirks;
> +
> + if (force_gmode) {
> + if (awcc)
> + awcc->gmode = true;
> + else
> + pr_warn("force_gmode requires platform profile support\n");
> + }
> +
> return wmi_driver_register(&alienware_wmax_wmi_driver);
> }
>
> @@ -1368,18 +1357,8 @@ static int __init alienware_wmi_init(void)
> int ret;
>
> dmi_check_system(alienware_quirks);
> - if (quirks == NULL)
> - quirks = &quirk_unknown;
> -
> - if (force_platform_profile)
> - quirks->thermal = true;
> -
> - if (force_gmode) {
> - if (quirks->thermal)
> - quirks->gmode = true;
> - else
> - pr_warn("force_gmode requires platform profile support\n");
> - }
> + if (!alienfx)
> + alienfx = &quirk_unknown;
>
> if (wmi_has_guid(WMAX_CONTROL_GUID)) {
> interface = WMAX;
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 00/14] platform/x86: alienware-wmi driver rework
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
` (13 preceding siblings ...)
2025-01-17 8:13 ` [PATCH v4 14/14] platform/x86: alienware-wmi: Update header and module information Kurt Borja
@ 2025-01-19 0:09 ` Armin Wolf
2025-01-19 16:53 ` Kurt Borja
14 siblings, 1 reply; 24+ messages in thread
From: Armin Wolf @ 2025-01-19 0:09 UTC (permalink / raw)
To: Kurt Borja, platform-driver-x86
Cc: Ilpo Järvinen, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
Am 17.01.25 um 09:13 schrieb Kurt Borja:
> Hello!
>
> I rebased these series on top of review-ilpo-next branch to pick up
> platform_profile latest changes.
So far i am quite pleased with the current state of the patch series. The issues
i found a relatively minor. I am already looking forward to reviewing the (hopefully
final) v5 patch series :).
Besides that: Did you test this changes on a real Alienware machine?
Thanks,
Armin Wolf
> ~ Kurt
> ---
> v3->v4:
> - First 6 patches are already applied so they are not included
>
> [01/14]
> - Reordered some lines in alienfx_probe() for aesthetic purposes
>
> [10/14]
> - Removed pr_fmt from header file
>
> [11/14]
> - Copy pr_fmt to each linked file
>
> v3: https://lore.kernel.org/platform-driver-x86/20250105153019.19206-2-kuurtb@gmail.com/
>
> Kurt Borja (14):
> platform/x86: alienware-wmi: Add a state container for LED control
> feature
> platform/x86: alienware-wmi: Add WMI Drivers
> platform/x86: alienware-wmi: Add a state container for thermal control
> methods
> platform/x86: alienware-wmi: Refactor LED control methods
> platform/x86: alienware-wmi: Refactor hdmi, amplifier, deepslp methods
> platform/x86: alienware-wmi: Refactor thermal control methods
> platform/x86: alienware-wmi: Split DMI table
> MAINTAINERS: Update ALIENWARE WMI DRIVER entry
> platform/x86: Rename alienware-wmi.c
> platform/x86: Add alienware-wmi.h
> platform/x86: Split the alienware-wmi driver
> platform/x86: dell: Modify Makefile alignment
> platform/x86: Update alienware-wmi config entries
> platform/x86: alienware-wmi: Update header and module information
>
> MAINTAINERS | 4 +-
> drivers/platform/x86/dell/Kconfig | 30 +-
> drivers/platform/x86/dell/Makefile | 45 +-
> .../platform/x86/dell/alienware-wmi-base.c | 488 +++++++
> .../platform/x86/dell/alienware-wmi-legacy.c | 100 ++
> .../platform/x86/dell/alienware-wmi-wmax.c | 773 +++++++++++
> drivers/platform/x86/dell/alienware-wmi.c | 1235 -----------------
> drivers/platform/x86/dell/alienware-wmi.h | 102 ++
> 8 files changed, 1515 insertions(+), 1262 deletions(-)
> create mode 100644 drivers/platform/x86/dell/alienware-wmi-base.c
> create mode 100644 drivers/platform/x86/dell/alienware-wmi-legacy.c
> create mode 100644 drivers/platform/x86/dell/alienware-wmi-wmax.c
> delete mode 100644 drivers/platform/x86/dell/alienware-wmi.c
> create mode 100644 drivers/platform/x86/dell/alienware-wmi.h
>
>
> base-commit: 81e8e5017f5de3cf28004ae2b628629ef4d43635
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 02/14] platform/x86: alienware-wmi: Add WMI Drivers
2025-01-18 23:48 ` Armin Wolf
@ 2025-01-19 16:47 ` Kurt Borja
0 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-19 16:47 UTC (permalink / raw)
To: Armin Wolf, platform-driver-x86
Cc: Ilpo Järvinen, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
On Sat Jan 18, 2025 at 6:48 PM -05, Armin Wolf wrote:
> Am 17.01.25 um 09:13 schrieb Kurt Borja:
>
> > Add WMI drivers for LEGACY and WMAX devices.
> >
> > This involves moving platform driver and device registration to a helper
> > function, which is now called from the driver's preferred WMI device
> > driver probe. However this is only done if !quirks->thermal because
> > newer WMAX interface doesn't support any of the features exposed by this
> > device.
> >
> > Only one driver is registered on module initialization to prevent
> > registering duplicate platform driver and device.
> >
> > Additionally, create_thermal_profile() now takes wmi_device * instead of
> > platform_device *.
> >
> > Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> > ---
> > drivers/platform/x86/dell/alienware-wmi.c | 200 +++++++++++++++++-----
> > 1 file changed, 160 insertions(+), 40 deletions(-)
> >
> > diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> > index 5779b025761b..e1a5a867f144 100644
> > --- a/drivers/platform/x86/dell/alienware-wmi.c
> > +++ b/drivers/platform/x86/dell/alienware-wmi.c
> > @@ -15,6 +15,7 @@
> > #include <linux/platform_profile.h>
> > #include <linux/dmi.h>
> > #include <linux/leds.h>
> > +#include <linux/wmi.h>
> >
> > #define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492"
> > #define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492"
> > @@ -39,8 +40,6 @@
> > MODULE_AUTHOR("Mario Limonciello <mario.limonciello@outlook.com>");
> > MODULE_DESCRIPTION("Alienware special feature control");
> > MODULE_LICENSE("GPL");
> > -MODULE_ALIAS("wmi:" LEGACY_CONTROL_GUID);
> > -MODULE_ALIAS("wmi:" WMAX_CONTROL_GUID);
> >
> > static bool force_platform_profile;
> > module_param_unsafe(force_platform_profile, bool, 0);
> > @@ -412,7 +411,10 @@ struct alienfx_priv {
> > u8 lighting_control_state;
> > };
> >
> > -static struct platform_device *platform_device;
> > +struct alienfx_platdata {
> > + struct wmi_device *wdev;
> > +};
> > +
> > static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
> >
> > static u8 interface;
> > @@ -1127,11 +1129,11 @@ static const struct platform_profile_ops awcc_platform_profile_ops = {
> > .profile_set = thermal_profile_set,
> > };
> >
> > -static int create_thermal_profile(struct platform_device *platform_device)
> > +static int create_thermal_profile(struct wmi_device *wdev)
> > {
> > struct device *ppdev;
> >
> > - ppdev = devm_platform_profile_register(&platform_device->dev, "alienware-wmi",
> > + ppdev = devm_platform_profile_register(&wdev->dev, "alienware-wmi",
> > NULL, &awcc_platform_profile_ops);
> >
> > return PTR_ERR_OR_ZERO(ppdev);
> > @@ -1166,6 +1168,10 @@ static int alienfx_probe(struct platform_device *pdev)
> >
> > static const struct attribute_group *alienfx_groups[] = {
> > &zone_attribute_group,
> > + NULL
> > +};
> > +
> > +static const struct attribute_group *wmax_alienfx_groups[] = {
> > &hdmi_attribute_group,
> > &lifier_attribute_group,
> > &deepsleep_attribute_group,
> > @@ -1180,19 +1186,150 @@ static struct platform_driver platform_driver = {
> > .probe = alienfx_probe,
> > };
> >
> > -static int __init alienware_wmi_init(void)
> > +static int alienware_alienfx_setup(struct alienfx_platdata *pdata)
> > {
> > + struct platform_device *pdev;
> > int ret;
> >
> > - if (wmi_has_guid(LEGACY_CONTROL_GUID))
> > - interface = LEGACY;
> > - else if (wmi_has_guid(WMAX_CONTROL_GUID))
> > - interface = WMAX;
> > - else {
> > - pr_warn("alienware-wmi: No known WMI GUID found\n");
> > - return -ENODEV;
> > + ret = platform_driver_register(&platform_driver);
> > + if (ret < 0)
> > + return ret;
>
> Can you register this platform driver during module initialization? Otherwise we might encounter
> a kernel crash should a WMI driver probe multiple devices and thus calling this method more than once.
Makes sense, I will register it on module init.
>
> Please note however that platform_device_register_data() can be called multiple times (it simply returns
> an error should the "alienware-wmi" device already exist).
That's good to know. Then it should be ok to set .no_singleton = true
after the above change.
~ Kurt
>
> > +
> > + pdev = platform_device_register_data(NULL, "alienware-wmi",
> > + PLATFORM_DEVID_NONE, pdata,
> > + sizeof(*pdata));
> > +
> > + if (IS_ERR(pdev)) {
> > + platform_driver_unregister(&platform_driver);
> > + return PTR_ERR(pdev);
> > }
> >
> > + dev_set_drvdata(&pdata->wdev->dev, pdev);
> > +
> > + return 0;
> > +}
> > +
> > +static void alienware_alienfx_exit(struct wmi_device *wdev)
> > +{
> > + struct platform_device *pdev = dev_get_drvdata(&wdev->dev);
> > +
> > + platform_device_unregister(pdev);
> > + platform_driver_unregister(&platform_driver);
> > +}
> > +
> > +/*
> > + * Legacy WMI driver
> > + */
> > +static int legacy_wmi_probe(struct wmi_device *wdev, const void *context)
> > +{
> > + struct alienfx_platdata pdata = {
> > + .wdev = wdev,
> > + };
> > +
> > + return alienware_alienfx_setup(&pdata);
> > +}
> > +
> > +static void legacy_wmi_remove(struct wmi_device *wdev)
> > +{
> > + alienware_alienfx_exit(wdev);
> > +}
> > +
> > +static struct wmi_device_id alienware_legacy_device_id_table[] = {
>
> Please make this device id table const.
>
> > + { LEGACY_CONTROL_GUID, NULL },
> > + { },
> > +};
> > +MODULE_DEVICE_TABLE(wmi, alienware_legacy_device_id_table);
> > +
> > +static struct wmi_driver alienware_legacy_wmi_driver = {
> > + .driver = {
> > + .name = "alienware-wmi-alienfx",
> > + .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> > + },
> > + .id_table = alienware_legacy_device_id_table,
> > + .probe = legacy_wmi_probe,
> > + .remove = legacy_wmi_remove,
> > +};
> > +
> > +static int __init alienware_legacy_wmi_init(void)
> > +{
> > + return wmi_driver_register(&alienware_legacy_wmi_driver);
> > +}
> > +
> > +static void __exit alienware_legacy_wmi_exit(void)
> > +{
> > + wmi_driver_unregister(&alienware_legacy_wmi_driver);
> > +}
> > +
> > +/*
> > + * WMAX WMI driver
> > + */
> > +static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
> > +{
> > + struct alienfx_platdata pdata = {
> > + .wdev = wdev,
> > + };
> > + struct platform_device *pdev;
> > + int ret;
> > +
> > + if (quirks->thermal) {
> > + return create_thermal_profile(wdev);
> > + } else {
> > + ret = alienware_alienfx_setup(&pdata);
> > + if (ret < 0)
> > + return ret;
> > +
> > + pdev = dev_get_drvdata(&wdev->dev);
> > +
> > + ret = device_add_groups(&pdev->dev, wmax_alienfx_groups);
> > + if (ret < 0)
> > + alienware_alienfx_exit(wdev);
> > +
> > + return ret;
> > + }
> > +}
> > +
> > +static void wmax_wmi_remove(struct wmi_device *wdev)
> > +{
> > + struct platform_device *pdev;
> > +
> > + if (!quirks->thermal) {
> > + pdev = dev_get_drvdata(&wdev->dev);
> > +
> > + device_remove_groups(&pdev->dev, wmax_alienfx_groups);
> > + alienware_alienfx_exit(wdev);
> > + }
> > +}
> > +
> > +static struct wmi_device_id alienware_wmax_device_id_table[] = {
>
> Please make this device id table const.
Thanks! I missed these two.
~ Kurt
>
> Other than that the code looks promising.
>
> Thanks,
> Armin Wolf
>
> > + { WMAX_CONTROL_GUID, NULL },
> > + { },
> > +};
> > +MODULE_DEVICE_TABLE(wmi, alienware_wmax_device_id_table);
> > +
> > +static struct wmi_driver alienware_wmax_wmi_driver = {
> > + .driver = {
> > + .name = "alienware-wmi-wmax",
> > + .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> > + },
> > + .id_table = alienware_wmax_device_id_table,
> > + .probe = wmax_wmi_probe,
> > + .remove = wmax_wmi_remove,
> > +};
> > +
> > +static int __init alienware_wmax_wmi_init(void)
> > +{
> > + return wmi_driver_register(&alienware_wmax_wmi_driver);
> > +}
> > +
> > +static void __exit alienware_wmax_wmi_exit(void)
> > +{
> > + wmi_driver_unregister(&alienware_wmax_wmi_driver);
> > +}
> > +
> > +static int __init alienware_wmi_init(void)
> > +{
> > + int ret;
> > +
> > dmi_check_system(alienware_quirks);
> > if (quirks == NULL)
> > quirks = &quirk_unknown;
> > @@ -1207,33 +1344,14 @@ static int __init alienware_wmi_init(void)
> > pr_warn("force_gmode requires platform profile support\n");
> > }
> >
> > - ret = platform_driver_register(&platform_driver);
> > - if (ret)
> > - goto fail_platform_driver;
> > - platform_device = platform_device_alloc("alienware-wmi", PLATFORM_DEVID_NONE);
> > - if (!platform_device) {
> > - ret = -ENOMEM;
> > - goto fail_platform_device1;
> > - }
> > - ret = platform_device_add(platform_device);
> > - if (ret)
> > - goto fail_platform_device2;
> > -
> > - if (quirks->thermal) {
> > - ret = create_thermal_profile(platform_device);
> > - if (ret)
> > - goto fail_prep_thermal_profile;
> > + if (wmi_has_guid(WMAX_CONTROL_GUID)) {
> > + interface = WMAX;
> > + ret = alienware_wmax_wmi_init();
> > + } else {
> > + interface = LEGACY;
> > + ret = alienware_legacy_wmi_init();
> > }
> >
> > - return 0;
> > -
> > -fail_prep_thermal_profile:
> > - platform_device_del(platform_device);
> > -fail_platform_device2:
> > - platform_device_put(platform_device);
> > -fail_platform_device1:
> > - platform_driver_unregister(&platform_driver);
> > -fail_platform_driver:
> > return ret;
> > }
> >
> > @@ -1241,8 +1359,10 @@ module_init(alienware_wmi_init);
> >
> > static void __exit alienware_wmi_exit(void)
> > {
> > - platform_device_unregister(platform_device);
> > - platform_driver_unregister(&platform_driver);
> > + if (interface == WMAX)
> > + alienware_wmax_wmi_exit();
> > + else
> > + alienware_legacy_wmi_exit();
> > }
> >
> > module_exit(alienware_wmi_exit);
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 04/14] platform/x86: alienware-wmi: Refactor LED control methods
2025-01-18 23:58 ` Armin Wolf
@ 2025-01-19 16:50 ` Kurt Borja
0 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-19 16:50 UTC (permalink / raw)
To: Armin Wolf, platform-driver-x86
Cc: Ilpo Järvinen, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
On Sat Jan 18, 2025 at 6:58 PM -05, Armin Wolf wrote:
> Am 17.01.25 um 09:13 schrieb Kurt Borja:
>
> > Both WMI devices handled by this module specify a distinct interface for
> > LED control. Previously this module handled this by dynamically adapting
> > arguments passed to wmi_evaluate_method() based on the `interface`
> > global variable.
> >
> > To avoid the use of global variables, and enable the migration to
> > non-deprecated WMI methods, let the WMI drivers define upd_led and
> > upd_brightness operations, which completely replace
> > alienware_update_led() and wmax_brightness().
> >
> > Also define alienware_wmi_command(), which serves as a wrapper for
> > wmidev_evaluate_method(). This new method is very similar to
> > alienware_wmax_command() but is WMI device agnostic.
> >
> > Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> > ---
> > drivers/platform/x86/dell/alienware-wmi.c | 164 ++++++++++++++--------
> > 1 file changed, 102 insertions(+), 62 deletions(-)
> >
> > diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> > index 7356260f7f09..c9d9cf36b87b 100644
> > --- a/drivers/platform/x86/dell/alienware-wmi.c
> > +++ b/drivers/platform/x86/dell/alienware-wmi.c
> > @@ -417,12 +417,42 @@ struct alienfx_priv {
> > u8 lighting_control_state;
> > };
> >
> > +struct alienfx_ops {
> > + int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev,
> > + u8 location);
> > + int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev,
> > + u8 brightness);
> > +};
> > +
> > struct alienfx_platdata {
> > struct wmi_device *wdev;
> > + struct alienfx_ops ops;
> > };
> >
> > static u8 interface;
> >
> > +static int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
> > + void *in_args, size_t in_size, u32 *out_data)
> > +{
> > + struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
> > + struct acpi_buffer in = {in_size, in_args};
> > + union acpi_object *obj;
> > + acpi_status ret;
> > +
> > + ret = wmidev_evaluate_method(wdev, 0, method_id, &in, out_data ? &out : NULL);
> > + if (ACPI_FAILURE(ret))
> > + return -EIO;
> > +
> > + obj = out.pointer;
> > +
> > + if (out_data && obj && obj->type == ACPI_TYPE_INTEGER)
> > + *out_data = (u32)obj->integer.value;
>
> Please return an error here if out_data is true but obj is NULL or not of ACPI_TYPE_INTEGER.
Sure.
>
> With this being fixed:
>
> Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Thanks!
>
> > +
> > + kfree(obj);
> > +
> > + return 0;
> > +}
> > +
> > /*
> > * Helpers used for zone control
> > */
> > @@ -453,46 +483,6 @@ static int parse_rgb(const char *buf, struct color_platform *colors)
> > /*
> > * Individual RGB zone control
> > */
> > -static int alienware_update_led(struct alienfx_priv *priv, u8 location)
> > -{
> > - int method_id;
> > - acpi_status status;
> > - char *guid;
> > - struct acpi_buffer input;
> > - struct legacy_led_args legacy_args;
> > - struct wmax_led_args wmax_basic_args;
> > - if (interface == WMAX) {
> > - wmax_basic_args.led_mask = 1 << location;
> > - wmax_basic_args.colors = priv->colors[location];
> > - wmax_basic_args.state = priv->lighting_control_state;
> > - guid = WMAX_CONTROL_GUID;
> > - method_id = WMAX_METHOD_ZONE_CONTROL;
> > -
> > - input.length = sizeof(wmax_basic_args);
> > - input.pointer = &wmax_basic_args;
> > - } else {
> > - legacy_args.colors = priv->colors[location];
> > - legacy_args.brightness = priv->global_brightness;
> > - legacy_args.state = 0;
> > - if (priv->lighting_control_state == LEGACY_BOOTING ||
> > - priv->lighting_control_state == LEGACY_SUSPEND) {
> > - guid = LEGACY_POWER_CONTROL_GUID;
> > - legacy_args.state = priv->lighting_control_state;
> > - } else
> > - guid = LEGACY_CONTROL_GUID;
> > - method_id = location + 1;
> > -
> > - input.length = sizeof(legacy_args);
> > - input.pointer = &legacy_args;
> > - }
> > - pr_debug("alienware-wmi: guid %s method %d\n", guid, method_id);
> > -
> > - status = wmi_evaluate_method(guid, 0, method_id, &input, NULL);
> > - if (ACPI_FAILURE(status))
> > - pr_err("alienware-wmi: zone set failure: %u\n", status);
> > - return ACPI_FAILURE(status);
> > -}
> > -
> > static ssize_t zone_show(struct device *dev, struct device_attribute *attr,
> > char *buf, u8 location)
> > {
> > @@ -509,13 +499,14 @@ static ssize_t zone_store(struct device *dev, struct device_attribute *attr,
> > {
> > struct alienfx_priv *priv = dev_get_drvdata(dev);
> > struct color_platform *colors = &priv->colors[location];
> > + struct alienfx_platdata *pdata = dev_get_platdata(dev);
> > int ret;
> >
> > ret = parse_rgb(buf, colors);
> > if (ret)
> > return ret;
> >
> > - ret = alienware_update_led(priv, location);
> > + ret = pdata->ops.upd_led(priv, pdata->wdev, location);
> >
> > return ret ? ret : count;
> > }
> > @@ -651,36 +642,17 @@ static struct attribute_group zone_attribute_group = {
> > /*
> > * LED Brightness (Global)
> > */
> > -static int wmax_brightness(int brightness)
> > -{
> > - acpi_status status;
> > - struct acpi_buffer input;
> > - struct wmax_brightness_args args = {
> > - .led_mask = 0xFF,
> > - .percentage = brightness,
> > - };
> > - input.length = sizeof(args);
> > - input.pointer = &args;
> > - status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0,
> > - WMAX_METHOD_BRIGHTNESS, &input, NULL);
> > - if (ACPI_FAILURE(status))
> > - pr_err("alienware-wmi: brightness set failure: %u\n", status);
> > - return ACPI_FAILURE(status);
> > -}
> > -
> > static void global_led_set(struct led_classdev *led_cdev,
> > enum led_brightness brightness)
> > {
> > struct alienfx_priv *priv = container_of(led_cdev, struct alienfx_priv,
> > global_led);
> > + struct alienfx_platdata *pdata = dev_get_platdata(&priv->pdev->dev);
> > int ret;
> >
> > priv->global_brightness = brightness;
> >
> > - if (interface == WMAX)
> > - ret = wmax_brightness(brightness);
> > - else
> > - ret = alienware_update_led(priv, 0);
> > + ret = pdata->ops.upd_brightness(priv, pdata->wdev, brightness);
> > if (ret)
> > pr_err("LED brightness update failed\n");
> > }
> > @@ -1234,10 +1206,49 @@ static void alienware_alienfx_exit(struct wmi_device *wdev)
> > /*
> > * Legacy WMI driver
> > */
> > +static int legacy_wmi_update_led(struct alienfx_priv *priv,
> > + struct wmi_device *wdev, u8 location)
> > +{
> > + struct legacy_led_args legacy_args = {
> > + .colors = priv->colors[location],
> > + .brightness = priv->global_brightness,
> > + .state = 0,
> > + };
> > + struct acpi_buffer input;
> > + acpi_status status;
> > +
> > + if (legacy_args.state != LEGACY_RUNNING) {
> > + legacy_args.state = priv->lighting_control_state;
> > +
> > + input.length = sizeof(legacy_args);
> > + input.pointer = &legacy_args;
> > +
> > + status = wmi_evaluate_method(LEGACY_POWER_CONTROL_GUID, 0,
> > + location + 1, &input, NULL);
> > + if (ACPI_FAILURE(status))
> > + return -EIO;
> > +
> > + return 0;
> > + }
> > +
> > + return alienware_wmi_command(wdev, location + 1, &legacy_args,
> > + sizeof(legacy_args), NULL);
> > +}
> > +
> > +static int legacy_wmi_update_brightness(struct alienfx_priv *priv,
> > + struct wmi_device *wdev, u8 brightness)
> > +{
> > + return legacy_wmi_update_led(priv, wdev, 0);
> > +}
> > +
> > static int legacy_wmi_probe(struct wmi_device *wdev, const void *context)
> > {
> > struct alienfx_platdata pdata = {
> > .wdev = wdev,
> > + .ops = {
> > + .upd_led = legacy_wmi_update_led,
> > + .upd_brightness = legacy_wmi_update_brightness,
> > + },
> > };
> >
> > return alienware_alienfx_setup(&pdata);
> > @@ -1277,10 +1288,39 @@ static void __exit alienware_legacy_wmi_exit(void)
> > /*
> > * WMAX WMI driver
> > */
> > +static int wmax_wmi_update_led(struct alienfx_priv *priv,
> > + struct wmi_device *wdev, u8 location)
> > +{
> > + struct wmax_led_args in_args = {
> > + .led_mask = 1 << location,
> > + .colors = priv->colors[location],
> > + .state = priv->lighting_control_state,
> > + };
> > +
> > + return alienware_wmi_command(wdev, WMAX_METHOD_ZONE_CONTROL, &in_args,
> > + sizeof(in_args), NULL);
> > +}
> > +
> > +static int wmax_wmi_update_brightness(struct alienfx_priv *priv,
> > + struct wmi_device *wdev, u8 brightness)
> > +{
> > + struct wmax_brightness_args in_args = {
> > + .led_mask = 0xFF,
> > + .percentage = brightness,
> > + };
> > +
> > + return alienware_wmi_command(wdev, WMAX_METHOD_BRIGHTNESS, &in_args,
> > + sizeof(in_args), NULL);
> > +}
> > +
> > static int wmax_wmi_probe(struct wmi_device *wdev, const void *context)
> > {
> > struct alienfx_platdata pdata = {
> > .wdev = wdev,
> > + .ops = {
> > + .upd_led = wmax_wmi_update_led,
> > + .upd_brightness = wmax_wmi_update_brightness,
> > + },
> > };
> > struct platform_device *pdev;
> > int ret;
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 00/14] platform/x86: alienware-wmi driver rework
2025-01-19 0:09 ` [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Armin Wolf
@ 2025-01-19 16:53 ` Kurt Borja
0 siblings, 0 replies; 24+ messages in thread
From: Kurt Borja @ 2025-01-19 16:53 UTC (permalink / raw)
To: Armin Wolf, platform-driver-x86
Cc: Ilpo Järvinen, Mario Limonciello, Hans de Goede,
Dell.Client.Kernel, linux-kernel
On Sat Jan 18, 2025 at 7:09 PM -05, Armin Wolf wrote:
> Am 17.01.25 um 09:13 schrieb Kurt Borja:
>
> > Hello!
> >
> > I rebased these series on top of review-ilpo-next branch to pick up
> > platform_profile latest changes.
>
> So far i am quite pleased with the current state of the patch series. The issues
> i found a relatively minor. I am already looking forward to reviewing the (hopefully
> final) v5 patch series :).
Hi Armin,
Hopefully.
Thank you so much for your work on this :)
>
> Besides that: Did you test this changes on a real Alienware machine?
Yes, this was tested on an Alienware x15 R1. I tested all quirks
including those that are not supported by my machine, of course WMAX
would return err on those.
~ Kurt
>
> Thanks,
> Armin Wolf
>
> > ~ Kurt
> > ---
> > v3->v4:
> > - First 6 patches are already applied so they are not included
> >
> > [01/14]
> > - Reordered some lines in alienfx_probe() for aesthetic purposes
> >
> > [10/14]
> > - Removed pr_fmt from header file
> >
> > [11/14]
> > - Copy pr_fmt to each linked file
> >
> > v3: https://lore.kernel.org/platform-driver-x86/20250105153019.19206-2-kuurtb@gmail.com/
> >
> > Kurt Borja (14):
> > platform/x86: alienware-wmi: Add a state container for LED control
> > feature
> > platform/x86: alienware-wmi: Add WMI Drivers
> > platform/x86: alienware-wmi: Add a state container for thermal control
> > methods
> > platform/x86: alienware-wmi: Refactor LED control methods
> > platform/x86: alienware-wmi: Refactor hdmi, amplifier, deepslp methods
> > platform/x86: alienware-wmi: Refactor thermal control methods
> > platform/x86: alienware-wmi: Split DMI table
> > MAINTAINERS: Update ALIENWARE WMI DRIVER entry
> > platform/x86: Rename alienware-wmi.c
> > platform/x86: Add alienware-wmi.h
> > platform/x86: Split the alienware-wmi driver
> > platform/x86: dell: Modify Makefile alignment
> > platform/x86: Update alienware-wmi config entries
> > platform/x86: alienware-wmi: Update header and module information
> >
> > MAINTAINERS | 4 +-
> > drivers/platform/x86/dell/Kconfig | 30 +-
> > drivers/platform/x86/dell/Makefile | 45 +-
> > .../platform/x86/dell/alienware-wmi-base.c | 488 +++++++
> > .../platform/x86/dell/alienware-wmi-legacy.c | 100 ++
> > .../platform/x86/dell/alienware-wmi-wmax.c | 773 +++++++++++
> > drivers/platform/x86/dell/alienware-wmi.c | 1235 -----------------
> > drivers/platform/x86/dell/alienware-wmi.h | 102 ++
> > 8 files changed, 1515 insertions(+), 1262 deletions(-)
> > create mode 100644 drivers/platform/x86/dell/alienware-wmi-base.c
> > create mode 100644 drivers/platform/x86/dell/alienware-wmi-legacy.c
> > create mode 100644 drivers/platform/x86/dell/alienware-wmi-wmax.c
> > delete mode 100644 drivers/platform/x86/dell/alienware-wmi.c
> > create mode 100644 drivers/platform/x86/dell/alienware-wmi.h
> >
> >
> > base-commit: 81e8e5017f5de3cf28004ae2b628629ef4d43635
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2025-01-19 16:53 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17 8:13 [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Kurt Borja
2025-01-17 8:13 ` [PATCH v4 01/14] platform/x86: alienware-wmi: Add a state container for LED control feature Kurt Borja
2025-01-18 23:34 ` Armin Wolf
2025-01-17 8:13 ` [PATCH v4 02/14] platform/x86: alienware-wmi: Add WMI Drivers Kurt Borja
2025-01-18 23:48 ` Armin Wolf
2025-01-19 16:47 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 03/14] platform/x86: alienware-wmi: Add a state container for thermal control methods Kurt Borja
2025-01-17 8:13 ` [PATCH v4 04/14] platform/x86: alienware-wmi: Refactor LED " Kurt Borja
2025-01-18 23:58 ` Armin Wolf
2025-01-19 16:50 ` Kurt Borja
2025-01-17 8:13 ` [PATCH v4 05/14] platform/x86: alienware-wmi: Refactor hdmi, amplifier, deepslp methods Kurt Borja
2025-01-17 8:13 ` [PATCH v4 06/14] platform/x86: alienware-wmi: Refactor thermal control methods Kurt Borja
2025-01-17 8:13 ` [PATCH v4 07/14] platform/x86: alienware-wmi: Split DMI table Kurt Borja
2025-01-17 17:15 ` Kurt Borja
2025-01-19 0:03 ` Armin Wolf
2025-01-17 8:13 ` [PATCH v4 08/14] MAINTAINERS: Update ALIENWARE WMI DRIVER entry Kurt Borja
2025-01-17 8:13 ` [PATCH v4 09/14] platform/x86: Rename alienware-wmi.c Kurt Borja
2025-01-17 8:13 ` [PATCH v4 10/14] platform/x86: Add alienware-wmi.h Kurt Borja
2025-01-17 8:13 ` [PATCH v4 11/14] platform/x86: Split the alienware-wmi driver Kurt Borja
2025-01-17 8:13 ` [PATCH v4 12/14] platform/x86: dell: Modify Makefile alignment Kurt Borja
2025-01-17 8:13 ` [PATCH v4 13/14] platform/x86: Update alienware-wmi config entries Kurt Borja
2025-01-17 8:13 ` [PATCH v4 14/14] platform/x86: alienware-wmi: Update header and module information Kurt Borja
2025-01-19 0:09 ` [PATCH v4 00/14] platform/x86: alienware-wmi driver rework Armin Wolf
2025-01-19 16:53 ` Kurt Borja
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).