Unverified Commit 2d53dfac authored by Armin Wolf's avatar Armin Wolf Committed by Ilpo Järvinen
Browse files

platform/x86: uniwill-laptop: Rename FN lock and super key lock attrs



It turns out that both sysfs attributes actually directly control
the FN lock status/super key enable status, rather than the
triggering of the associated events. This behavior was first observed
on a Tuxedo notebook and was belived to be a hardware quirk.
However, it seems that i simply misunderstood the manual of the
OEM software for Intel NUC devices. The correct behavior is:

- fn_lock_toggle_enable enables/disables FN lock mode
- super_key_toggle_enable enables/disables the super key

Rename both sysfs attributes to avoid confusing users.

Fixes: d0504796 ("platform/x86: Add Uniwill laptop driver")
Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20260218005101.73680-2-W_Armin@gmx.de


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent e3aa6fea
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
What:		/sys/bus/platform/devices/INOU0000:XX/fn_lock_toggle_enable
What:		/sys/bus/platform/devices/INOU0000:XX/fn_lock
Date:		November 2025
KernelVersion:	6.19
Contact:	Armin Wolf <W_Armin@gmx.de>
@@ -8,15 +8,15 @@ Description:

		Reading this file returns the current enable status of the FN lock functionality.

What:		/sys/bus/platform/devices/INOU0000:XX/super_key_toggle_enable
What:		/sys/bus/platform/devices/INOU0000:XX/super_key_enable
Date:		November 2025
KernelVersion:	6.19
Contact:	Armin Wolf <W_Armin@gmx.de>
Description:
                Allows userspace applications to enable/disable the super key functionality
                of the integrated keyboard by writing "1"/"0" into this file.
		Allows userspace applications to enable/disable the super key of the integrated
		keyboard by writing "1"/"0" into this file.

		Reading this file returns the current enable status of the super key functionality.
		Reading this file returns the current enable status of the super key.

What:		/sys/bus/platform/devices/INOU0000:XX/touchpad_toggle_enable
Date:		November 2025
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ Keyboard settings

The ``uniwill-laptop`` driver allows the user to enable/disable:

 - the FN and super key lock functionality of the integrated keyboard
 - the FN lock and super key of the integrated keyboard
 - the touchpad toggle functionality of the integrated touchpad

See Documentation/ABI/testing/sysfs-driver-uniwill-laptop for details.
+30 −28
Original line number Diff line number Diff line
@@ -314,8 +314,8 @@
#define LED_CHANNELS		3
#define LED_MAX_BRIGHTNESS	200

#define UNIWILL_FEATURE_FN_LOCK_TOGGLE		BIT(0)
#define UNIWILL_FEATURE_SUPER_KEY_TOGGLE	BIT(1)
#define UNIWILL_FEATURE_FN_LOCK			BIT(0)
#define UNIWILL_FEATURE_SUPER_KEY		BIT(1)
#define UNIWILL_FEATURE_TOUCHPAD_TOGGLE		BIT(2)
#define UNIWILL_FEATURE_LIGHTBAR		BIT(3)
#define UNIWILL_FEATURE_BATTERY			BIT(4)
@@ -377,11 +377,15 @@ static const struct key_entry uniwill_keymap[] = {
	{ KE_IGNORE,    UNIWILL_OSD_CAPSLOCK,                   { KEY_CAPSLOCK }},
	{ KE_IGNORE,    UNIWILL_OSD_NUMLOCK,                    { KEY_NUMLOCK }},

	/* Reported when the user locks/unlocks the super key */
	{ KE_IGNORE,    UNIWILL_OSD_SUPER_KEY_LOCK_ENABLE,      { KEY_UNKNOWN }},
	{ KE_IGNORE,    UNIWILL_OSD_SUPER_KEY_LOCK_DISABLE,     { KEY_UNKNOWN }},
	/*
	 * Reported when the user enables/disables the super key.
	 * Those events might even be reported when the change was done
	 * using the sysfs attribute!
	 */
	{ KE_IGNORE,    UNIWILL_OSD_SUPER_KEY_DISABLE,		{ KEY_UNKNOWN }},
	{ KE_IGNORE,    UNIWILL_OSD_SUPER_KEY_ENABLE,		{ KEY_UNKNOWN }},
	/* Optional, might not be reported by all devices */
	{ KE_IGNORE,	UNIWILL_OSD_SUPER_KEY_LOCK_CHANGED,	{ KEY_UNKNOWN }},
	{ KE_IGNORE,	UNIWILL_OSD_SUPER_KEY_STATE_CHANGED,	{ KEY_UNKNOWN }},

	/* Reported in manual mode when toggling the airplane mode status */
	{ KE_KEY,       UNIWILL_OSD_RFKILL,                     { KEY_RFKILL }},
@@ -600,8 +604,8 @@ static const struct regmap_config uniwill_ec_config = {
	.use_single_write = true,
};

static ssize_t fn_lock_toggle_enable_store(struct device *dev, struct device_attribute *attr,
					   const char *buf, size_t count)
static ssize_t fn_lock_store(struct device *dev, struct device_attribute *attr, const char *buf,
			     size_t count)
{
	struct uniwill_data *data = dev_get_drvdata(dev);
	unsigned int value;
@@ -624,8 +628,7 @@ static ssize_t fn_lock_toggle_enable_store(struct device *dev, struct device_att
	return count;
}

static ssize_t fn_lock_toggle_enable_show(struct device *dev, struct device_attribute *attr,
					  char *buf)
static ssize_t fn_lock_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct uniwill_data *data = dev_get_drvdata(dev);
	unsigned int value;
@@ -638,9 +641,9 @@ static ssize_t fn_lock_toggle_enable_show(struct device *dev, struct device_attr
	return sysfs_emit(buf, "%d\n", !!(value & FN_LOCK_STATUS));
}

static DEVICE_ATTR_RW(fn_lock_toggle_enable);
static DEVICE_ATTR_RW(fn_lock);

static ssize_t super_key_toggle_enable_store(struct device *dev, struct device_attribute *attr,
static ssize_t super_key_enable_store(struct device *dev, struct device_attribute *attr,
				      const char *buf, size_t count)
{
	struct uniwill_data *data = dev_get_drvdata(dev);
@@ -673,8 +676,7 @@ static ssize_t super_key_toggle_enable_store(struct device *dev, struct device_a
	return count;
}

static ssize_t super_key_toggle_enable_show(struct device *dev, struct device_attribute *attr,
					    char *buf)
static ssize_t super_key_enable_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct uniwill_data *data = dev_get_drvdata(dev);
	unsigned int value;
@@ -687,7 +689,7 @@ static ssize_t super_key_toggle_enable_show(struct device *dev, struct device_at
	return sysfs_emit(buf, "%d\n", !(value & SUPER_KEY_LOCK_STATUS));
}

static DEVICE_ATTR_RW(super_key_toggle_enable);
static DEVICE_ATTR_RW(super_key_enable);

static ssize_t touchpad_toggle_enable_store(struct device *dev, struct device_attribute *attr,
					    const char *buf, size_t count)
@@ -881,8 +883,8 @@ static int uniwill_nvidia_ctgp_init(struct uniwill_data *data)

static struct attribute *uniwill_attrs[] = {
	/* Keyboard-related */
	&dev_attr_fn_lock_toggle_enable.attr,
	&dev_attr_super_key_toggle_enable.attr,
	&dev_attr_fn_lock.attr,
	&dev_attr_super_key_enable.attr,
	&dev_attr_touchpad_toggle_enable.attr,
	/* Lightbar-related */
	&dev_attr_rainbow_animation.attr,
@@ -897,13 +899,13 @@ static umode_t uniwill_attr_is_visible(struct kobject *kobj, struct attribute *a
	struct device *dev = kobj_to_dev(kobj);
	struct uniwill_data *data = dev_get_drvdata(dev);

	if (attr == &dev_attr_fn_lock_toggle_enable.attr) {
		if (uniwill_device_supports(data, UNIWILL_FEATURE_FN_LOCK_TOGGLE))
	if (attr == &dev_attr_fn_lock.attr) {
		if (uniwill_device_supports(data, UNIWILL_FEATURE_FN_LOCK))
			return attr->mode;
	}

	if (attr == &dev_attr_super_key_toggle_enable.attr) {
		if (uniwill_device_supports(data, UNIWILL_FEATURE_SUPER_KEY_TOGGLE))
	if (attr == &dev_attr_super_key_enable.attr) {
		if (uniwill_device_supports(data, UNIWILL_FEATURE_SUPER_KEY))
			return attr->mode;
	}

@@ -1505,7 +1507,7 @@ static void uniwill_shutdown(struct platform_device *pdev)

static int uniwill_suspend_keyboard(struct uniwill_data *data)
{
	if (!uniwill_device_supports(data, UNIWILL_FEATURE_SUPER_KEY_TOGGLE))
	if (!uniwill_device_supports(data, UNIWILL_FEATURE_SUPER_KEY))
		return 0;

	/*
@@ -1565,7 +1567,7 @@ static int uniwill_resume_keyboard(struct uniwill_data *data)
	unsigned int value;
	int ret;

	if (!uniwill_device_supports(data, UNIWILL_FEATURE_SUPER_KEY_TOGGLE))
	if (!uniwill_device_supports(data, UNIWILL_FEATURE_SUPER_KEY))
		return 0;

	ret = regmap_read(data->regmap, EC_ADDR_SWITCH_STATUS, &value);
@@ -1643,16 +1645,16 @@ static struct platform_driver uniwill_driver = {
};

static struct uniwill_device_descriptor lapac71h_descriptor __initdata = {
	.features = UNIWILL_FEATURE_FN_LOCK_TOGGLE |
		    UNIWILL_FEATURE_SUPER_KEY_TOGGLE |
	.features = UNIWILL_FEATURE_FN_LOCK |
		    UNIWILL_FEATURE_SUPER_KEY |
		    UNIWILL_FEATURE_TOUCHPAD_TOGGLE |
		    UNIWILL_FEATURE_BATTERY |
		    UNIWILL_FEATURE_HWMON,
};

static struct uniwill_device_descriptor lapkc71f_descriptor __initdata = {
	.features = UNIWILL_FEATURE_FN_LOCK_TOGGLE |
		    UNIWILL_FEATURE_SUPER_KEY_TOGGLE |
	.features = UNIWILL_FEATURE_FN_LOCK |
		    UNIWILL_FEATURE_SUPER_KEY |
		    UNIWILL_FEATURE_TOUCHPAD_TOGGLE |
		    UNIWILL_FEATURE_LIGHTBAR |
		    UNIWILL_FEATURE_BATTERY |
+3 −3
Original line number Diff line number Diff line
@@ -64,8 +64,8 @@
#define UNIWILL_OSD_KB_LED_LEVEL3		0x3E
#define UNIWILL_OSD_KB_LED_LEVEL4		0x3F

#define UNIWILL_OSD_SUPER_KEY_LOCK_ENABLE	0x40
#define UNIWILL_OSD_SUPER_KEY_LOCK_DISABLE	0x41
#define UNIWILL_OSD_SUPER_KEY_DISABLE		0x40
#define UNIWILL_OSD_SUPER_KEY_ENABLE		0x41

#define UNIWILL_OSD_MENU_JP			0x42

@@ -74,7 +74,7 @@

#define UNIWILL_OSD_RFKILL			0xA4

#define UNIWILL_OSD_SUPER_KEY_LOCK_CHANGED	0xA5
#define UNIWILL_OSD_SUPER_KEY_STATE_CHANGED	0xA5

#define UNIWILL_OSD_LIGHTBAR_STATE_CHANGED	0xA6