mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
platform/x86: asus-armoury: move existing tunings to asus-armoury module
The fw_attributes_class provides a much cleaner interface to all of the attributes introduced to asus-wmi. This patch moves all of these extra attributes over to fw_attributes_class, and shifts the bulk of these definitions to a new kernel module to reduce the clutter of asus-wmi with the intention of deprecating the asus-wmi attributes in future. The work applies only to WMI methods which don't have a clearly defined place within the sysfs and as a result ended up lumped together in /sys/devices/platform/asus-nb-wmi/ with no standard API. Where possible the fw attrs now implement defaults, min, max, scalar, choices, etc. As en example dgpu_disable becomes: /sys/class/firmware-attributes/asus-armoury/attributes/dgpu_disable/ ├── current_value ├── display_name ├── possible_values └── type as do other attributes. Co-developed-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Denis Benato <denis.benato@linux.dev> Signed-off-by: Luke D. Jones <luke@ljones.dev> Link: https://patch.msgid.link/20251102215319.3126879-3-denis.benato@linux.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <linux/hid.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_data/x86/asus-wmi.h>
|
||||
#include <linux/platform_data/x86/asus-wmi-leds-ids.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/usb.h> /* For to_usb_interface for T100 touchpad intf check */
|
||||
#include <linux/power_supply.h>
|
||||
|
||||
@@ -264,6 +264,18 @@ config ASUS_WIRELESS
|
||||
If you choose to compile this driver as a module the module will be
|
||||
called asus-wireless.
|
||||
|
||||
config ASUS_ARMOURY
|
||||
tristate "ASUS Armoury driver"
|
||||
depends on ASUS_WMI
|
||||
select FW_ATTR_CLASS
|
||||
help
|
||||
Say Y here if you have a WMI aware Asus machine and would like to use the
|
||||
firmware_attributes API to control various settings typically exposed in
|
||||
the ASUS Armoury Crate application available on Windows.
|
||||
|
||||
To compile this driver as a module, choose M here: the module will
|
||||
be called asus-armoury.
|
||||
|
||||
config ASUS_WMI
|
||||
tristate "ASUS WMI Driver"
|
||||
depends on ACPI_WMI
|
||||
|
||||
@@ -33,6 +33,7 @@ obj-$(CONFIG_APPLE_GMUX) += apple-gmux.o
|
||||
# ASUS
|
||||
obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
|
||||
obj-$(CONFIG_ASUS_WIRELESS) += asus-wireless.o
|
||||
obj-$(CONFIG_ASUS_ARMOURY) += asus-armoury.o
|
||||
obj-$(CONFIG_ASUS_WMI) += asus-wmi.o
|
||||
obj-$(CONFIG_ASUS_NB_WMI) += asus-nb-wmi.o
|
||||
obj-$(CONFIG_ASUS_TF103C_DOCK) += asus-tf103c-dock.o
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,200 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0
|
||||
*
|
||||
* Definitions for kernel modules using asus-armoury driver
|
||||
*
|
||||
* Copyright (c) 2024 Luke Jones <luke@ljones.dev>
|
||||
*/
|
||||
|
||||
#ifndef _ASUS_ARMOURY_H_
|
||||
#define _ASUS_ARMOURY_H_
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#define DRIVER_NAME "asus-armoury"
|
||||
|
||||
/**
|
||||
* armoury_attr_uint_store() - Send an uint to WMI method if within min/max.
|
||||
* @kobj: Pointer to the driver object.
|
||||
* @attr: Pointer to the attribute calling this function.
|
||||
* @buf: The buffer to read from, this is parsed to `uint` type.
|
||||
* @count: Required by sysfs attribute macros, pass in from the callee attr.
|
||||
* @min: Minimum accepted value. Below this returns -EINVAL.
|
||||
* @max: Maximum accepted value. Above this returns -EINVAL.
|
||||
* @store_value: Pointer to where the parsed value should be stored.
|
||||
* @wmi_dev: The WMI function ID to use.
|
||||
*
|
||||
* This function is intended to be generic so it can be called from any "_store"
|
||||
* attribute which works only with integers.
|
||||
*
|
||||
* Integers to be sent to the WMI method is inclusive range checked and
|
||||
* an error returned if out of range.
|
||||
*
|
||||
* If the value is valid and WMI is success then the sysfs attribute is notified
|
||||
* and if asus_bios_requires_reboot() is true then reboot attribute
|
||||
* is also notified.
|
||||
*
|
||||
* Returns: Either count, or an error.
|
||||
*/
|
||||
ssize_t armoury_attr_uint_store(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
const char *buf, size_t count, u32 min, u32 max,
|
||||
u32 *store_value, u32 wmi_dev);
|
||||
|
||||
/**
|
||||
* armoury_attr_uint_show() - Receive an uint from a WMI method.
|
||||
* @kobj: Pointer to the driver object.
|
||||
* @attr: Pointer to the attribute calling this function.
|
||||
* @buf: The buffer to write to, as an `uint` type.
|
||||
* @wmi_dev: The WMI function ID to use.
|
||||
*
|
||||
* This function is intended to be generic so it can be called from any "_show"
|
||||
* attribute which works only with integers.
|
||||
*
|
||||
* Returns: Either count, or an error.
|
||||
*/
|
||||
ssize_t armoury_attr_uint_show(struct kobject *kobj, struct kobj_attribute *attr,
|
||||
char *buf, u32 wmi_dev);
|
||||
|
||||
#define __ASUS_ATTR_RO(_func, _name) \
|
||||
{ \
|
||||
.attr = { .name = __stringify(_name), .mode = 0444 }, \
|
||||
.show = _func##_##_name##_show, \
|
||||
}
|
||||
|
||||
#define __ASUS_ATTR_RO_AS(_name, _show) \
|
||||
{ \
|
||||
.attr = { .name = __stringify(_name), .mode = 0444 }, \
|
||||
.show = _show, \
|
||||
}
|
||||
|
||||
#define __ASUS_ATTR_RW(_func, _name) \
|
||||
__ATTR(_name, 0644, _func##_##_name##_show, _func##_##_name##_store)
|
||||
|
||||
#define __WMI_STORE_INT(_attr, _min, _max, _wmi) \
|
||||
static ssize_t _attr##_store(struct kobject *kobj, \
|
||||
struct kobj_attribute *attr, \
|
||||
const char *buf, size_t count) \
|
||||
{ \
|
||||
return armoury_attr_uint_store(kobj, attr, buf, count, _min, \
|
||||
_max, NULL, _wmi); \
|
||||
}
|
||||
|
||||
#define ASUS_WMI_SHOW_INT(_attr, _wmi) \
|
||||
static ssize_t _attr##_show(struct kobject *kobj, \
|
||||
struct kobj_attribute *attr, char *buf) \
|
||||
{ \
|
||||
return armoury_attr_uint_show(kobj, attr, buf, _wmi); \
|
||||
}
|
||||
|
||||
/* Create functions and attributes for use in other macros or on their own */
|
||||
|
||||
/* Shows a formatted static variable */
|
||||
#define __ATTR_SHOW_FMT(_prop, _attrname, _fmt, _val) \
|
||||
static ssize_t _attrname##_##_prop##_show( \
|
||||
struct kobject *kobj, struct kobj_attribute *attr, char *buf) \
|
||||
{ \
|
||||
return sysfs_emit(buf, _fmt, _val); \
|
||||
} \
|
||||
static struct kobj_attribute attr_##_attrname##_##_prop = \
|
||||
__ASUS_ATTR_RO(_attrname, _prop)
|
||||
|
||||
#define __ATTR_RO_INT_GROUP_ENUM(_attrname, _wmi, _fsname, _possible, _dispname)\
|
||||
ASUS_WMI_SHOW_INT(_attrname##_current_value, _wmi); \
|
||||
static struct kobj_attribute attr_##_attrname##_current_value = \
|
||||
__ASUS_ATTR_RO(_attrname, current_value); \
|
||||
__ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \
|
||||
__ATTR_SHOW_FMT(possible_values, _attrname, "%s\n", _possible); \
|
||||
static struct kobj_attribute attr_##_attrname##_type = \
|
||||
__ASUS_ATTR_RO_AS(type, enum_type_show); \
|
||||
static struct attribute *_attrname##_attrs[] = { \
|
||||
&attr_##_attrname##_current_value.attr, \
|
||||
&attr_##_attrname##_display_name.attr, \
|
||||
&attr_##_attrname##_possible_values.attr, \
|
||||
&attr_##_attrname##_type.attr, \
|
||||
NULL \
|
||||
}; \
|
||||
static const struct attribute_group _attrname##_attr_group = { \
|
||||
.name = _fsname, .attrs = _attrname##_attrs \
|
||||
}
|
||||
|
||||
#define __ATTR_RW_INT_GROUP_ENUM(_attrname, _minv, _maxv, _wmi, _fsname,\
|
||||
_possible, _dispname) \
|
||||
__WMI_STORE_INT(_attrname##_current_value, _minv, _maxv, _wmi); \
|
||||
ASUS_WMI_SHOW_INT(_attrname##_current_value, _wmi); \
|
||||
static struct kobj_attribute attr_##_attrname##_current_value = \
|
||||
__ASUS_ATTR_RW(_attrname, current_value); \
|
||||
__ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \
|
||||
__ATTR_SHOW_FMT(possible_values, _attrname, "%s\n", _possible); \
|
||||
static struct kobj_attribute attr_##_attrname##_type = \
|
||||
__ASUS_ATTR_RO_AS(type, enum_type_show); \
|
||||
static struct attribute *_attrname##_attrs[] = { \
|
||||
&attr_##_attrname##_current_value.attr, \
|
||||
&attr_##_attrname##_display_name.attr, \
|
||||
&attr_##_attrname##_possible_values.attr, \
|
||||
&attr_##_attrname##_type.attr, \
|
||||
NULL \
|
||||
}; \
|
||||
static const struct attribute_group _attrname##_attr_group = { \
|
||||
.name = _fsname, .attrs = _attrname##_attrs \
|
||||
}
|
||||
|
||||
/* Boolean style enumeration, base macro. Requires adding show/store */
|
||||
#define __ATTR_GROUP_ENUM(_attrname, _fsname, _possible, _dispname) \
|
||||
__ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \
|
||||
__ATTR_SHOW_FMT(possible_values, _attrname, "%s\n", _possible); \
|
||||
static struct kobj_attribute attr_##_attrname##_type = \
|
||||
__ASUS_ATTR_RO_AS(type, enum_type_show); \
|
||||
static struct attribute *_attrname##_attrs[] = { \
|
||||
&attr_##_attrname##_current_value.attr, \
|
||||
&attr_##_attrname##_display_name.attr, \
|
||||
&attr_##_attrname##_possible_values.attr, \
|
||||
&attr_##_attrname##_type.attr, \
|
||||
NULL \
|
||||
}; \
|
||||
static const struct attribute_group _attrname##_attr_group = { \
|
||||
.name = _fsname, .attrs = _attrname##_attrs \
|
||||
}
|
||||
|
||||
#define ASUS_ATTR_GROUP_BOOL_RO(_attrname, _fsname, _wmi, _dispname) \
|
||||
__ATTR_RO_INT_GROUP_ENUM(_attrname, _wmi, _fsname, "0;1", _dispname)
|
||||
|
||||
|
||||
#define ASUS_ATTR_GROUP_BOOL_RW(_attrname, _fsname, _wmi, _dispname) \
|
||||
__ATTR_RW_INT_GROUP_ENUM(_attrname, 0, 1, _wmi, _fsname, "0;1", _dispname)
|
||||
|
||||
#define ASUS_ATTR_GROUP_ENUM_INT_RO(_attrname, _fsname, _wmi, _possible, _dispname) \
|
||||
__ATTR_RO_INT_GROUP_ENUM(_attrname, _wmi, _fsname, _possible, _dispname)
|
||||
|
||||
/*
|
||||
* Requires <name>_current_value_show(), <name>_current_value_show()
|
||||
*/
|
||||
#define ASUS_ATTR_GROUP_BOOL(_attrname, _fsname, _dispname) \
|
||||
static struct kobj_attribute attr_##_attrname##_current_value = \
|
||||
__ASUS_ATTR_RW(_attrname, current_value); \
|
||||
__ATTR_GROUP_ENUM(_attrname, _fsname, "0;1", _dispname)
|
||||
|
||||
/*
|
||||
* Requires <name>_current_value_show(), <name>_current_value_show()
|
||||
* and <name>_possible_values_show()
|
||||
*/
|
||||
#define ASUS_ATTR_GROUP_ENUM(_attrname, _fsname, _dispname) \
|
||||
__ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \
|
||||
static struct kobj_attribute attr_##_attrname##_current_value = \
|
||||
__ASUS_ATTR_RW(_attrname, current_value); \
|
||||
static struct kobj_attribute attr_##_attrname##_possible_values = \
|
||||
__ASUS_ATTR_RO(_attrname, possible_values); \
|
||||
static struct kobj_attribute attr_##_attrname##_type = \
|
||||
__ASUS_ATTR_RO_AS(type, enum_type_show); \
|
||||
static struct attribute *_attrname##_attrs[] = { \
|
||||
&attr_##_attrname##_current_value.attr, \
|
||||
&attr_##_attrname##_display_name.attr, \
|
||||
&attr_##_attrname##_possible_values.attr, \
|
||||
&attr_##_attrname##_type.attr, \
|
||||
NULL \
|
||||
}; \
|
||||
static const struct attribute_group _attrname##_attr_group = { \
|
||||
.name = _fsname, .attrs = _attrname##_attrs \
|
||||
}
|
||||
|
||||
#endif /* _ASUS_ARMOURY_H_ */
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/bits.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dmi.h>
|
||||
@@ -30,6 +31,7 @@
|
||||
#include <linux/pci.h>
|
||||
#include <linux/pci_hotplug.h>
|
||||
#include <linux/platform_data/x86/asus-wmi.h>
|
||||
#include <linux/platform_data/x86/asus-wmi-leds-ids.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/platform_profile.h>
|
||||
#include <linux/power_supply.h>
|
||||
@@ -55,8 +57,6 @@ module_param(fnlock_default, bool, 0444);
|
||||
#define to_asus_wmi_driver(pdrv) \
|
||||
(container_of((pdrv), struct asus_wmi_driver, platform_driver))
|
||||
|
||||
#define ASUS_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66"
|
||||
|
||||
#define NOTIFY_BRNUP_MIN 0x11
|
||||
#define NOTIFY_BRNUP_MAX 0x1f
|
||||
#define NOTIFY_BRNDOWN_MIN 0x20
|
||||
@@ -105,8 +105,6 @@ module_param(fnlock_default, bool, 0444);
|
||||
#define USB_INTEL_XUSB2PR 0xD0
|
||||
#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
|
||||
|
||||
#define ASUS_ACPI_UID_ASUSWMI "ASUSWMI"
|
||||
|
||||
#define WMI_EVENT_MASK 0xFFFF
|
||||
|
||||
#define FAN_CURVE_POINTS 8
|
||||
@@ -561,8 +559,8 @@ static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval)
|
||||
*
|
||||
* Returns:
|
||||
* * %-ENODEV - method ID is unsupported.
|
||||
* * %0 - successful and retval is filled.
|
||||
* * %other - error from WMI call.
|
||||
* * %0 - successful and retval is filled.
|
||||
* * %other - error from WMI call.
|
||||
*/
|
||||
int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef __PLATFORM_DATA_X86_ASUS_WMI_LEDS_IDS_H
|
||||
#define __PLATFORM_DATA_X86_ASUS_WMI_LEDS_IDS_H
|
||||
|
||||
#include <linux/dmi.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
/* To be used by both hid-asus and asus-wmi to determine which controls kbd_brightness */
|
||||
#if IS_REACHABLE(CONFIG_ASUS_WMI) || IS_REACHABLE(CONFIG_HID_ASUS)
|
||||
static const struct dmi_system_id asus_use_hid_led_dmi_ids[] = {
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Zephyrus"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Strix"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Flow"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_FAMILY, "ProArt P16"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_BOARD_NAME, "GA403U"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_BOARD_NAME, "GU605M"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_BOARD_NAME, "RC71L"),
|
||||
},
|
||||
},
|
||||
{ },
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* __PLATFORM_DATA_X86_ASUS_WMI_LEDS_IDS_H */
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
#include <linux/errno.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/dmi.h>
|
||||
|
||||
#define ASUS_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66"
|
||||
#define ASUS_ACPI_UID_ASUSWMI "ASUSWMI"
|
||||
|
||||
/* WMI Methods */
|
||||
#define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */
|
||||
@@ -191,44 +193,4 @@ static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1,
|
||||
}
|
||||
#endif
|
||||
|
||||
/* To be used by both hid-asus and asus-wmi to determine which controls kbd_brightness */
|
||||
static const struct dmi_system_id asus_use_hid_led_dmi_ids[] = {
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Zephyrus"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Strix"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_FAMILY, "ROG Flow"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_FAMILY, "ProArt P16"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_BOARD_NAME, "GA403U"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_BOARD_NAME, "GU605M"),
|
||||
},
|
||||
},
|
||||
{
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_BOARD_NAME, "RC71L"),
|
||||
},
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
#endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */
|
||||
|
||||
Reference in New Issue
Block a user