Skip to contentSkip to conversation

Add sysfs interface for touchpad state

PATCH In review Ritesh Raj Sarraf 2 participants 11 messages Jan 30, 2017 – Feb 14, 2017 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add sysfs interface for touchpad state

Lenovo Yoga (many variants: Yoga, Yoga2 Pro, Yoga2 13, Yoga3 Pro, Yoga 3 14 etc) has multiple modles that are a hybrid laptop, working in laptop mode as well as tablet mode.

There is no interface available to query the physical state of these devices. Also, from the driver, it doesn't look to be having an EC command to get that information from the acpi driver.

When in tablet mode, the hardware keyboard and touchpad get disabled. This could be one sub-optimal way to assume that under such condition (touchpad disabled) the machine is in Tablet-Mode. Other than this, I've not come across another way to determine the physical state of the hardware.

Currently, some of the hardware status is provided through debugfs, which is useless for unprivileged processes. (This already has many broken reports: radio and wifi, which are active/on as I write this)

root@learner:/sys/kernel/debug# cat ideapad/status
Backlight max:	16
Backlight now:	3
BL power value:	On
=====================
Radio status:	Off(0)
Wifi status:	Off(0)
BT status:	Off(0)
3G status:	Off(0)
=====================
Touchpad status:On(1)
SW_TABLET_MODE:	Off(0)
Camera status:	On(1)

This patch adds a sysfs interface for unprivileged process access under:
/sys/bus/platform/devices/VPC2004\:00/touchpad_state

rrs@learner:/sys/bus/platform/devices/VPC2004:00$ cat touchpad_state
1
2017-01-30 / 16:12:00 ♒♒♒  ☺
rrs@learner:/sys/bus/platform/devices/VPC2004:00$ cat touchpad_state
0
2017-01-30 / 16:12:06 ♒♒♒  ☺
---
 drivers/platform/x86/ideapad-laptop.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/platform/x86/ideapad-laptop.c +24 -0
index a7614fc542b5..3a1622ef2f45 100644
@@ -423,9 +423,33 @@ static ssize_t store_ideapad_fan(struct device *dev,
 
 static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
 
+
+static ssize_t show_touchpad_state(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	unsigned long result;
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+
+	if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result))
+		return sprintf(buf, "-1\n");
+	return sprintf(buf, "%lu\n", result);
+}
+
+static ssize_t store_touchpad_state(struct device *dev,
+				 struct device_attribute *attr,
+				 const char *buf, size_t count)
+{
+        /* Don't enable writing here */
+        return -1;
+}
+
+static DEVICE_ATTR(touchpad_state, 0644, show_touchpad_state, store_touchpad_state);
+
 static struct attribute *ideapad_attributes[] = {
 	&dev_attr_camera_power.attr,
 	&dev_attr_fan_mode.attr,
+	&dev_attr_touchpad_state.attr,
 	NULL
 };
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 3 lines · Ritesh Raj Sarraf

Lenovo Yoga (many variants: Yoga, Yoga2 Pro, Yoga2 13, Yoga3 Pro, Yoga 3 14 etc) has multiple modles that are a hybrid laptop, working in laptop mode as well as tablet mode.

The main question is who is the initiator of the mode change? Do you need to do anything in UI to prepare OS for such switch?

Quoted 10 lines

There is no interface available to query the physical state of these devices. Also, from the driver, it doesn't look to be having an EC command to get that information from the acpi driver.

When in tablet mode, the hardware keyboard and touchpad get disabled. This could be one sub-optimal way to assume that under such condition (touchpad disabled) the machine is in Tablet-Mode. Other than this, I've not come across another way to determine the physical state of the hardware.

Quoted 3 lines

Currently, some of the hardware status is provided through debugfs, which is useless for unprivileged processes. (This already has many broken reports: radio and wifi, which are active/on as I write this)

This should be fixed.

Quoted 17 lines
root@learner:/sys/kernel/debug# cat ideapad/status
Backlight max:  16
Backlight now:  3
BL power value: On
=====================
Radio status:   Off(0)
Wifi status:    Off(0)
BT status:      Off(0)
3G status:      Off(0)
=====================
Touchpad status:On(1)
SW_TABLET_MODE: Off(0)
Camera status:  On(1)

This patch adds a sysfs interface for unprivileged process access under:
/sys/bus/platform/devices/VPC2004\:00/touchpad_state

Quoted 6 lines
rrs@learner:/sys/bus/platform/devices/VPC2004:00$ cat touchpad_state
1
2017-01-30 / 16:12:00 ♒♒♒  ☺
rrs@learner:/sys/bus/platform/devices/VPC2004:00$ cat touchpad_state
0
2017-01-30 / 16:12:06 ♒♒♒  ☺

You introduce an ABI without documenting it.

Quoted 15 lines
---
 drivers/platform/x86/ideapad-laptop.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/platform/x86/ideapad-laptop.c +1 -0
index a7614fc542b5..3a1622ef2f45 100644
@@ -423,9 +423,33 @@ static ssize_t store_ideapad_fan(struct device *dev,
 
 static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
 
+

drivers/platform/x86/ideapad-laptop.c static ssize_t store_ideapad_fan(struct device *dev, · line 436

Quoted 10 lines
drivers/platform/x86/ideapad-laptop.c +9 -0
+static ssize_t show_touchpad_state(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
+{
+       unsigned long result;
+       struct ideapad_private *priv = dev_get_drvdata(dev);
+
+       if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result))
 
+               return sprintf(buf, "-1\n");

That is bad. Return the error code what read_ec_data() returns. If it is not suitable convert it here.

drivers/platform/x86/ideapad-laptop.c static ssize_t store_ideapad_fan(struct device *dev, · line 444

Quoted 10 lines
drivers/platform/x86/ideapad-laptop.c +9 -0
+       return sprintf(buf, "%lu\n", result);
 
+}
+
+static ssize_t store_touchpad_state(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf, size_t count)
+{
+        /* Don't enable writing here */
+        return -1;

And why you can't just drop this completely?

drivers/platform/x86/ideapad-laptop.c static ssize_t store_ideapad_fan(struct device *dev, · line 452

Quoted 8 lines
drivers/platform/x86/ideapad-laptop.c +5 -0
+}
+
+static DEVICE_ATTR(touchpad_state, 0644, show_touchpad_state, store_touchpad_state);
+
 static struct attribute *ideapad_attributes[] = {
        &dev_attr_camera_power.attr,
        &dev_attr_fan_mode.attr,
+       &dev_attr_touchpad_state.attr,

Is it really state, btw? Reading your commit message I would assume this is also "mode" for touchpad.

Quoted 2 lines
drivers/platform/x86/ideapad-laptop.c +0 -0
        NULL

};

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw

Hello Andy,

Quoted 8 lines · Andy Shevchenko
Quoted 3 lines · Ritesh Raj Sarraf

Lenovo Yoga (many variants: Yoga, Yoga2 Pro, Yoga2 13, Yoga3 Pro, Yoga 3 14 etc) has multiple modles that are a hybrid laptop, working in laptop mode as well as tablet mode.

The main question is who is the initiator of the mode change? Do you need to do anything in UI to prepare OS for such switch?

The human user is the only initiator. The hardware has 360 degree rotation. There is nothing special needed in the UI, or the OS, to get into tablet mode. Just flip the hardware 360 degree into tablet mode.

More details on the hardware series can be found at:
http://shop.lenovo.com/us/en/laptops/lenovo/yoga-laptop-series/yoga-laptop-2-13/

Quoted 10 lines
Quoted 10 lines

There is no interface available to query the physical state of these devices. Also, from the driver, it doesn't look to be having an EC command to get that information from the acpi driver.

When in tablet mode, the hardware keyboard and touchpad get disabled. This could be one sub-optimal way to assume that under such condition (touchpad disabled) the machine is in Tablet-Mode. Other than this, I've not come across another way to determine the physical state of the hardware.

Quoted 6 lines
Quoted 3 lines

Currently, some of the hardware status is provided through debugfs, which is useless for unprivileged processes. (This already has many broken reports: radio and wifi, which are active/on as I write this)

This should be fixed.

Thanks.

Quoted 12 lines
Quoted 9 lines

This patch adds a sysfs interface for unprivileged process access under:
/sys/bus/platform/devices/VPC2004\:00/touchpad_state

rrs@learner:/sys/bus/platform/devices/VPC2004:00$ cat touchpad_state
1
2017-01-30 / 16:12:00 ♒♒♒  ☺
rrs@learner:/sys/bus/platform/devices/VPC2004:00$ cat touchpad_state
0
2017-01-30 / 16:12:06 ♒♒♒  ☺

You introduce an ABI without documenting it.

Sorry about that. I am no kernel developer, just wanting to fix my hardware.

I looked into the doc. The documentation mentions the sysfs path:
'/sys/devices/platform/ideapad/fan_mode', which is what we would also want to use.

But the driver only shows the interface through:
'/sys/devices/platform/devices/VPC2004:00/'

Is this an expected behavior ?

Quoted 16 lines

Review

Quoted 12 lines
(quoted diff) +10 -0
+
+static ssize_t show_touchpad_state(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
+{
+       unsigned long result;
+       struct ideapad_private *priv = dev_get_drvdata(dev);
+
+       if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result))
+               return sprintf(buf, "-1\n");

That is bad. Return the error code what read_ec_data() returns. If it is not suitable convert it here.

All that read_ec_data() can return are 0 and -1.

The other 2 consumers, show_ideapad_cam() and show_ideapad_fan() are doing the same.

Quoted 12 lines

Review

Quoted 9 lines

+       return sprintf(buf, "%lu\n", result);

(quoted diff) +8 -0
+}
+
+static ssize_t store_touchpad_state(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf, size_t count)
+{
+        /* Don't enable writing here */
+        return -1;

And why you can't just drop this completely?

I did that. But it was failing to build. But anyways, please see my revised patch along with write support.

Quoted 4 lines
Quoted 4 lines
(quoted diff) +3 -0
+}
+
+static DEVICE_ATTR(touchpad_state, 0644, show_touchpad_state,

store_touchpad_state);

Quoted 9 lines
Quoted 5 lines

+
 static struct attribute *ideapad_attributes[] = { &dev_attr_camera_power.attr, &dev_attr_fan_mode.attr,
+       &dev_attr_touchpad_state.attr,

Is it really state, btw? Reading your commit message I would assume this is also "mode" for touchpad.

Actually, yes. It'd be better to have it as a mode, along with allowing to write. That way it will be consistent with the other 2 (cam and fan) interfaces.

Please find attached revised patch along with write support and ABI Documentation changes.

Thanks,
Ritesh

Signature · 2 lines
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System

From 8a3980bb15e31a5c17e7541bc60cbe4bc56bf604 Mon Sep 17 00:00:00 2001
From: Ritesh Raj Sarraf <[email protected]>
Date: Mon, 30 Jan 2017 15:05:48 +0530
Subject: [PATCH] Add sysfs interface for touchpad state
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Lenovo Yoga (many variants: Yoga, Yoga2 Pro, Yoga2 13, Yoga3 Pro, Yoga 3 14 etc) has multiple modles that are a hybrid laptop, working in laptop mode as well as tablet mode.

This patch adds a sysfs interface for read/write access under:
/sys/bus/platform/devices/VPC2004\:00/touchpad_mode

rrs@learner:~$ cat /sys/bus/platform/devices/VPC2004\:00/touchpad_mode
1
2017-01-31 / 16:58:46 ♒♒♒  ☺
rrs@learner:~$ su
Password:
root@learner:/home/rrs# echo 0 > /sys/bus/platform/devices/VPC2004\:00/touchpad_mode
root@learner:/home/rrs# cat  /sys/bus/platform/devices/VPC2004\:00/touchpad_mode
0
root@learner:/home/rrs# echo 1 > /sys/bus/platform/devices/VPC2004\:00/touchpad_mode
root@learner:/home/rrs# cat  /sys/bus/platform/devices/VPC2004\:00/touchpad_mode
1
root@learner:/home/rrs# exit
2017-01-31 / 16:59:26 ♒♒♒  ☺
rrs@learner:~$

Enable write. Change name to _mode

Update ABI documentation for ideapad-laptop

---
 .../ABI/testing/sysfs-platform-ideapad-laptop      |  9 ++++++
 drivers/platform/x86/ideapad-laptop.c              | 33 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)
Documentation/ABI/testing/sysfs-platform-ideapad-laptop +9 -0
index b31e782bd985..401e37e5acbd 100644
@@ -17,3 +17,12 @@ Description:
 			* 2 -> Dust Cleaning
 			* 4 -> Efficient Thermal Dissipation Mode
 
+What:		/sys/devices/platform/ideapad/touchpad_mode
+Date:		Jan 2017
+KernelVersion:	4.11
+Contact:	"Ritesh Raj Sarraf <[email protected]>"
+Description:
+		Control touchpad mode.
+                        * 1 -> Switched On
+                        * 0 -> Switched Off
+
drivers/platform/x86/ideapad-laptop.c +33 -0
index a7614fc542b5..e612e0764ba6 100644
@@ -423,9 +423,42 @@ static ssize_t store_ideapad_fan(struct device *dev,
 
 static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
 
+
+static ssize_t show_touchpad_mode(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	unsigned long result;
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+
+	if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result))
+		return sprintf(buf, "-1\n");
+	return sprintf(buf, "%lu\n", result);
+}
+
+static ssize_t store_touchpad_mode(struct device *dev,
+				 struct device_attribute *attr,
+				 const char *buf, size_t count)
+{
+	int ret, state;
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+
+	if (!count)
+		return 0;
+	if (sscanf(buf, "%i", &state) != 1)
+		return -EINVAL;
+	ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
+	if (ret < 0)
+		return -EIO;
+	return count;
+}
+
+static DEVICE_ATTR(touchpad_mode, 0644, show_touchpad_mode, store_touchpad_mode);
+
 static struct attribute *ideapad_attributes[] = {
 	&dev_attr_camera_power.attr,
 	&dev_attr_fan_mode.attr,
+	&dev_attr_touchpad_mode.attr,
 	NULL
 };
 
Signature · 1 line
2.11.0
#3 lore raw
Quoted 12 lines · Ritesh Raj Sarraf

Hello Andy,

Quoted 8 lines · Andy Shevchenko
Quoted 3 lines · Ritesh Raj Sarraf

Lenovo Yoga (many variants: Yoga, Yoga2 Pro, Yoga2 13, Yoga3 Pro, Yoga 3 14 etc) has multiple modles that are a hybrid laptop, working in laptop mode as well as tablet mode.

The main question is who is the initiator of the mode change? Do you need to do anything in UI to prepare OS for such switch?

Quoted 6 lines

The human user is the only initiator. The hardware has 360 degree rotation. There is nothing special needed in the UI, or the OS, to get into tablet mode. Just flip the hardware 360 degree into tablet mode.

More details on the hardware series can be found at:
http://shop.lenovo.com/us/en/laptops/lenovo/yoga-laptop-series/yoga-laptop-2-13/

We have Yoga 900 here and I just played with it.
So, can you do the following:
1. Boot system to a text mode (no X).
2. Be sure that ideapad_lenovo module is loaded
3. By looking into output of
% ls -l /sys/class/input
find VPC2004 related *event* number (/.../eventX/...)
4. Run
% od -x /dev/input/eventX
5. Ensure that you get events (hex dump) when you bend the cover.

We can continue after you try the above.

Quoted 10 lines

Sorry about that. I am no kernel developer, just wanting to fix my hardware.

I looked into the doc. The documentation mentions the sysfs path:
'/sys/devices/platform/ideapad/fan_mode', which is what we would also want to use.

But the driver only shows the interface through:
'/sys/devices/platform/devices/VPC2004:00/'

Is this an expected behavior ?

Driver is old, perhaps it's not fixed part, perhaps it's by design.

Quoted 2 lines

Please find attached revised patch along with write support and ABI Documentation changes.

Next time please avoid attachments here.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Quoted 11 lines · Andy Shevchenko

We have Yoga 900 here and I just played with it.
So, can you do the following:
1. Boot system to a text mode (no X).
2. Be sure that ideapad_lenovo module is loaded
3. By looking into output of
% ls -l /sys/class/input
find VPC2004 related *event* number (/.../eventX/...)
4. Run
% od -x /dev/input/eventX
5. Ensure that you get events (hex dump) when you bend the cover.

Quoted 2 lines

We can continue after you try the above.

Fantastic. In that case, I hope you can help enable SW_TABLET_MODE for ideapad driver too.

Here's what you asked for:

root@learner:/sys/class/input# ls * -l
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event0 -> ../../devices/platform/i8042/serio0/input/input0/event0
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event1 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:01/PNP0C0C:00/input/input3/event1
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event10 -> ../../devices/pci0000:00/0000:00:1b.0/sound/card1/input12/event10
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event11 -> ../../devices/pci0000:00/0000:00:03.0/sound/card0/input13/event11
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event12 -> ../../devices/pci0000:00/0000:00:03.0/sound/card0/input14/event12
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event13 -> ../../devices/pci0000:00/0000:00:03.0/sound/card0/input15/event13
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event14 -> ../../devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/input/input16/event14
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event15 -> ../../devices/pci0000:00/0000:00:14.0/usb2/2-5/2-5:1.0/0003:04F3:0303.0001/input/input17/event15
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event2 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:01/PNP0C0D:00/input/input4/event2
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event3 -> ../../devices/LNXSYSTM:00/LNXPWRBN:00/input/input5/event3
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event4 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/LNXVIDEO:00/input/input7/event4
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event5 -> ../../devices/platform/i8042/serio1/input/input6/event5
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event6 -> ../../devices/pci0000:00/0000:00:1f.0/PNP0C09:00/VPC2004:00/input/input8/event6
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event7 -> ../../devices/platform/pcspkr/input/input9/event7
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event8 -> ../../devices/pci0000:00/0000:00:1b.0/sound/card1/input10/event8
lrwxrwxrwx 1 root root 0 Feb  1 19:33 event9 -> ../../devices/pci0000:00/0000:00:1b.0/sound/card1/input11/event9
lrwxrwxrwx 1 root root 0 Feb  1 19:32 input0 -> ../../devices/platform/i8042/serio0/input/input0
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input10 -> ../../devices/pci0000:00/0000:00:1b.0/sound/card1/input10
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input11 -> ../../devices/pci0000:00/0000:00:1b.0/sound/card1/input11
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input12 -> ../../devices/pci0000:00/0000:00:1b.0/sound/card1/input12
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input13 -> ../../devices/pci0000:00/0000:00:03.0/sound/card0/input13
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input14 -> ../../devices/pci0000:00/0000:00:03.0/sound/card0/input14
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input15 -> ../../devices/pci0000:00/0000:00:03.0/sound/card0/input15
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input16 -> ../../devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/input/input16
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input17 -> ../../devices/pci0000:00/0000:00:14.0/usb2/2-5/2-5:1.0/0003:04F3:0303.0001/input/input17
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input3 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:01/PNP0C0C:00/input/input3
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input4 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:01/PNP0C0D:00/input/input4
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input5 -> ../../devices/LNXSYSTM:00/LNXPWRBN:00/input/input5
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input6 -> ../../devices/platform/i8042/serio1/input/input6
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input7 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/LNXVIDEO:00/input/input7
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input8 -> ../../devices/pci0000:00/0000:00:1f.0/PNP0C09:00/VPC2004:00/input/input8
lrwxrwxrwx 1 root root 0 Feb  1 19:33 input9 -> ../../devices/platform/pcspkr/input/input9
lrwxrwxrwx 1 root root 0 Feb  1 19:33 mice -> ../../devices/virtual/input/mice
lrwxrwxrwx 1 root root 0 Feb  1 19:33 mouse0 -> ../../devices/platform/i8042/serio1/input/input6/mouse0
lrwxrwxrwx 1 root root 0 Feb  1 19:33 mouse1 -> ../../devices/pci0000:00/0000:00:14.0/usb2/2-5/2-5:1.0/0003:04F3:0303.0001/input/input17/mouse1
root@learner:/sys/class/input# od -x /dev/input/event6
?0000000 ee33 5891 0000 0000 2bd9 0005 0000 0000
^@0000020 0004 0004 0042 0000 ee33 5891 0000 0000
0000040 2bd9 0005 0000 0000 0001 00c1 0001 0000
0000060 ee33 5891 0000 0000 2bd9 0005 0000 0000
0000100 0000 0000 0000 0000 ee33 5891 0000 0000
0000120 2c09 0005 0000 0000 0001 00c1 0000 0000
0000140 ee33 5891 0000 0000 2c09 0005 0000 0000
0000160 0000 0000 0000 0000 ee37 5891 0000 0000
0000200 3d7e 000f 0000 0000 0004 0004 0043 0000
0000220 ee37 5891 0000 0000 3d7e 000f 0000 0000
0000240 0001 00c0 0001 0000 ee37 5891 0000 0000
0000260 3d7e 000f 0000 0000 0000 0000 0000 0000
0000300 ee37 5891 0000 0000 3dae 000f 0000 0000
0000320 0001 00c0 0000 0000 ee37 5891 0000 0000
0000340 3dae 000f 0000 0000 0000 0000 0000 0000
Quoted 10 lines
Quoted 10 lines

Sorry about that. I am no kernel developer, just wanting to fix my hardware.

I looked into the doc. The documentation mentions the sysfs path:
'/sys/devices/platform/ideapad/fan_mode', which is what we would also want to
use.

But the driver only shows the interface through:
'/sys/devices/platform/devices/VPC2004:00/'

Quoted 8 lines
Quoted 1 line

Is this an expected behavior ?

Driver is old, perhaps it's not fixed part, perhaps it's by design.

Quoted 2 lines

Please find attached revised patch along with write support and ABI Documentation changes.

Next time please avoid attachments here.

Okay. I'll figure out how to do that. By the way, does the patch make sense for inclusion ? To have an interface for touchpad mode ?

- --
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEQCVDstmIVAB/Yn02pjpYo/LhdWkFAliR8DMACgkQpjpYo/Lh dWkhlQ/+LAY58rMdSVlJNFFnK0/CyUuSn5vBu8JQF2xN6tSAQuTyFq3i0HfrR0/d h44rf1RNpTpljwxvvnKtDiwiInF+u7vtCU+CbMxbqMdruf0cAX1k6O27Cup78yLu 9Ht2tuZyID5zTb0mXUFGjSo2sEwRCZXhHPpiiyQlksTlY+CcqJTUWQgENvyF0bkX 2r2pBQAZo69eiZjpuqp0D6DZV6CNVjuh1EWN2f/DC+05KfvIp8es3wfr35/K9BfH pyi2geOZ4yzOiUPPferW/TXNIWKrm2GRiWzpa8GnEHfLWMMWeRT/xYq3KviXzRbq Hr5wDDkDnLZtc0J7pEX+8M1ycpyLKOiJ65ZQl/erRtU/u8Ji7Xjrhtn3hRIQO9fh SiizDRPlJ3nlcnKPlTGe4M2/3yZ+idEup+ttFR6DdELeOA9IYiGJMu9OMaHonmuo r2jZ0sn+2KuwPge/A9jI3pyAhjKypJ0p+0/+u1y6bglrjaGoh4llcOqBW3gMi69N dR5GiPCXwHxXb16rFM3Hwy7MgEBxgXtn72Q3ThOUotuh8Z6ramYOldtMGFO/Deco b147oQtpGmXVmPamqrDdf4z+HqBwRgj9SJ0mtwmi3U7mcpv5LWZcOSImkp8uKx52 bCKGLaakiSYUhP3KZ07d+DyhF4tfCPBSV2Jn3CCwtb1ZKhO0sTk= =IETm
-----END PGP SIGNATURE-----

#5 lore raw
Quoted 22 lines · Ritesh Raj Sarraf
Quoted 11 lines · Andy Shevchenko

We have Yoga 900 here and I just played with it.
So, can you do the following:
1. Boot system to a text mode (no X).
2. Be sure that ideapad_lenovo module is loaded
3. By looking into output of
% ls -l /sys/class/input
find VPC2004 related *event* number (/.../eventX/...)
4. Run
% od -x /dev/input/eventX
5. Ensure that you get events (hex dump) when you bend the cover.

Quoted 2 lines

We can continue after you try the above.

Fantastic. In that case, I hope you can help enable SW_TABLET_MODE for ideapad driver too.

Here's what you asked for:

lrwxrwxrwx 1 root root 0 Feb 1 19:33 event6 -> ../../devices/pci0000:00/0000:00:1f.0/PNP0C09:00/VPC2004:00/input/input8/event6

Quoted 16 lines
root@learner:/sys/class/input# od -x /dev/input/event6
?0000000 ee33 5891 0000 0000 2bd9 0005 0000 0000
^@0000020 0004 0004 0042 0000 ee33 5891 0000 0000
0000040 2bd9 0005 0000 0000 0001 00c1 0001 0000
0000060 ee33 5891 0000 0000 2bd9 0005 0000 0000
0000100 0000 0000 0000 0000 ee33 5891 0000 0000
0000120 2c09 0005 0000 0000 0001 00c1 0000 0000
0000140 ee33 5891 0000 0000 2c09 0005 0000 0000
0000160 0000 0000 0000 0000 ee37 5891 0000 0000
0000200 3d7e 000f 0000 0000 0004 0004 0043 0000
0000220 ee37 5891 0000 0000 3d7e 000f 0000 0000
0000240 0001 00c0 0001 0000 ee37 5891 0000 0000
0000260 3d7e 000f 0000 0000 0000 0000 0000 0000
0000300 ee37 5891 0000 0000 3dae 000f 0000 0000
0000320 0001 00c0 0000 0000 ee37 5891 0000 0000
0000340 3dae 000f 0000 0000 0000 0000 0000 0000

So, the whole idea of this exercise is to show that driver sends an event whenever you bend / unbend the cover.
User space already will know what is the state of the cover.

Quoted 2 lines

By the way, does the patch make sense for inclusion ? To have an interface for touchpad mode ?

The question now is why do you need that on top of existing event?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Quoted 17 lines · Andy Shevchenko
Quoted 8 lines
root@learner:/sys/class/input# od -x /dev/input/event6
?0000000 ee33 5891 0000 0000 2bd9 0005 0000 0000
^@0000020 0004 0004 0042 0000 ee33 5891 0000 0000
0000040 2bd9 0005 0000 0000 0001 00c1 0001 0000
0000060 ee33 5891 0000 0000 2bd9 0005 0000 0000
0000100 0000 0000 0000 0000 ee33 5891 0000 0000
0000120 2c09 0005 0000 0000 0001 00c1 0000 0000
0000140 ee33 5891 0000 0000 2c09 0005 0000 0000
Quoted 8 lines
0000160 0000 0000 0000 0000 ee37 5891 0000 0000
0000200 3d7e 000f 0000 0000 0004 0004 0043 0000
0000220 ee37 5891 0000 0000 3d7e 000f 0000 0000
0000240 0001 00c0 0001 0000 ee37 5891 0000 0000
0000260 3d7e 000f 0000 0000 0000 0000 0000 0000
0000300 ee37 5891 0000 0000 3dae 000f 0000 0000
0000320 0001 00c0 0000 0000 ee37 5891 0000 0000
0000340 3dae 000f 0000 0000 0000 0000 0000 0000
Quoted 4 lines

So, the whole idea of this exercise is to show that driver sends an event whenever you bend / unbend the cover.
User space already will know what is the state of the cover.

Yes. But we've not found the interface in sysfs where we could read that from. Nor did udev report anything meaningful for it.

Quoted 4 lines
Quoted 2 lines

By the way, does the patch make sense for inclusion ? To have an interface for touchpad mode ?

The question now is why do you need that on top of existing event?

If you have time, please see:
https://bugs.launchpad.net/bugs/1366421

It has pretty much all the details on what and why we need something in sysfs.

For HP and ThinkPad, there already are interfaces available.

/sys/devices/platform/hp-wmi/tablet /sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode

It'd be nice to see the same for Yoga IdeaPad; a proper interface for tablet- mode.

- --
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEQCVDstmIVAB/Yn02pjpYo/LhdWkFAliSChYACgkQpjpYo/Lh dWm/LhAAitvcaPzR2fUR6gtlxMLOQDTEPA8rjQdVmIBFLYPV9OTyJPkjz9V0aZlR S4BcGa43foXLNsj5tGFNoy8gucwQ2bpEEpPJazlsmRVk9SB7Ui0GVzU673EUqCHD wR3NI4MzlEmo6RV8DxTyx6rGOjGH2XGjwi6cbfZFLiehw7RjYZV5ggO5uxK+O43n EbudMaiHOZeg+rYtU+c162TdAjPwwWTiTx5LJvZpam7QS3M31U76PdVt75bacbfH m7TarxK15ksP9Mmj3DJnXKavOS5u92mPRkSIZmE/hmWsJ/X6tmTzgX0tHddF4N+7 yaftBwglqV6Da8Xylc9GKkC2Q/b0mXSQqTwr86fK2TyKY6HHj5QJ6CNG9gwP33tG Kg2zIpMzKul7FHpJeQIrHL312Z/4bek1Islki2ydt8CwdheMPTnxUqcFNKpaTItM FudQTJuaffXinmavGtwco/iFBqJbnqX3RkgWpXxyIvG4NTLrcMcMDKY6DRo+f2FB 0ojU2APhPZ+63+fvCwO1Bv06/vbzfphkOvgQv6w2laekmuCJaF2RfQDj8N+DiteH LRmqYpF4UEr4WnJeHuumV3oRQsjHU6exdzg/5oBNyJ1vD8CzRFYvTgyNmdunmFnp ybuVmjVIjFKxGnF1x46ZFF+o7CM0+3XeC6vFYbT3WNDQq1iQKTY= =/CI9
-----END PGP SIGNATURE-----

#7 lore raw
Quoted 29 lines · Ritesh Raj Sarraf
Quoted 17 lines · Andy Shevchenko
Quoted 8 lines
root@learner:/sys/class/input# od -x /dev/input/event6
?0000000 ee33 5891 0000 0000 2bd9 0005 0000 0000
^@0000020 0004 0004 0042 0000 ee33 5891 0000 0000
0000040 2bd9 0005 0000 0000 0001 00c1 0001 0000
0000060 ee33 5891 0000 0000 2bd9 0005 0000 0000
0000100 0000 0000 0000 0000 ee33 5891 0000 0000
0000120 2c09 0005 0000 0000 0001 00c1 0000 0000
0000140 ee33 5891 0000 0000 2c09 0005 0000 0000
Quoted 8 lines
0000160 0000 0000 0000 0000 ee37 5891 0000 0000
0000200 3d7e 000f 0000 0000 0004 0004 0043 0000
0000220 ee37 5891 0000 0000 3d7e 000f 0000 0000
0000240 0001 00c0 0001 0000 ee37 5891 0000 0000
0000260 3d7e 000f 0000 0000 0000 0000 0000 0000
0000300 ee37 5891 0000 0000 3dae 000f 0000 0000
0000320 0001 00c0 0000 0000 ee37 5891 0000 0000
0000340 3dae 000f 0000 0000 0000 0000 0000 0000
Quoted 4 lines

So, the whole idea of this exercise is to show that driver sends an event whenever you bend / unbend the cover.
User space already will know what is the state of the cover.

Yes. But we've not found the interface in sysfs where we could read that from. Nor did udev report anything meaningful for it.

Quoted 3 lines
Quoted 2 lines

By the way, does the patch make sense for inclusion ? To have an interface for touchpad mode ?

Quoted 6 lines
Quoted 1 line

The question now is why do you need that on top of existing event?

If you have time, please see:
https://bugs.launchpad.net/bugs/1366421

It has pretty much all the details on what and why we need something in sysfs.

It's a lo-o-ong discussion from which I, might be wrongly, assumed that there couple of problems: a) you don't know initial state, b) something preventing use of event.

Keyboard and touchpad are disabled by hw, so, only what OS needs is a notification.

Can you point me exactly to the message that explains _why_ it's impossible to use standard eventX mechanism for that?

Quoted 1 line

For HP and ThinkPad, there already are interfaces available.

Perhaps those hybrids didn't lock keyboard and touchpad in hw and don't send any event, that's why OS needs it.

Quoted 5 lines

/sys/devices/platform/hp-wmi/tablet /sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode

It'd be nice to see the same for Yoga IdeaPad; a proper interface for tablet- mode

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hello Andy,

Quoted 10 lines · Andy Shevchenko
Quoted 5 lines

If you have time, please see:
https://bugs.launchpad.net/bugs/1366421

It has pretty much all the details on what and why we need something in sysfs.

It's a lo-o-ong discussion from which I, might be wrongly, assumed that there couple of problems: a) you don't know initial state, b) something preventing use of event.

Yes.

Quoted 3 lines

Keyboard and touchpad are disabled by hw, so, only what OS needs is a notification.

Yes.

Quoted 3 lines

Can you point me exactly to the message that explains _why_ it's impossible to use standard eventX mechanism for that?

Comment #43 has the summary of what we've tried.
https://bugs.launchpad.net/onboard/+bug/1366421/comments/43

Some of the drivers do SW_TABLET_MODE, but ideapad does not. Some of the drivers do sysfs, but ideapad does not.

For ideapad, under Xorg, it generates hotkey events.
And the hotkey event are going to work under Xorg only. What about Wayland/Mir ? We also aren't sure, if the keycodes that it sends, are uniform across all Yoga variants.

- --
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEQCVDstmIVAB/Yn02pjpYo/LhdWkFAliS6ucACgkQpjpYo/Lh dWlydw/9Ejt8FSHXB3yCwBJdJc0OKfTx3zoJnJ3USbarE3XbNGW+M++FEnz9l6CR CI97nJDmXRQIXdfKv8xgnoUIFvZhFP20DhvytUx6ukadcLSH/Dwzf60BTThJok08 q76j7hBpV9bRiWANaBw2dPKLt/4++UVPT5Pd8yb70gC0J8PLJ4iyFeEFgOaoniIp wv01whOHDkSiSW6Due/jC9Cwwv0m4AKeiUYZtJ3oJgFn1yBirlCWjkWvTktjxgwD QyL3QWePqTl11JATIp34zS+cXOKZFdS26F741aE0eLWP0i9N9KlXceNXe9OXWwYg EkxGQLbgqgQJ7J4XgRpl6x2ajgwA61Q0KtRep7+TLNT+9SC+OYUqsttLk6EwKSsc 5CAyOcQC1d2i9vPDMHBbqB+Gluu/GcNON7fv3oTbPXYIWkw9kT4yDDlz4Phi3noK fncCkYw/yp3/lAkTYW5ChEj2/HADcgY3uqG1tpI1XC0YNVxd9LQY++GlboJOVTp5 EoHBcWTmBGKJVXOW1ZmzER5pPDpf6CE/pb0KCBNq3ZLvyyPV/VRJeOPgre1+7Kz5 Ub9mygN3rU/GhalFCj5BQIQpeiTCZa1ax1Ze1iNvJLxfsE5oasWW8yDNdzcl70Wr grPDk83bTKf+LdNa/jpTijZTMzhpMBWLdZf8N6c1pofDdABMoXU= =wiLZ
-----END PGP SIGNATURE-----

#9 lore raw

I'm sorry for top-posting, but something wrong with email quoting. I'm using here gmail, it might not recognize message properly.

So, please fix the subject line to have a prefix, in your case "platform/x86: ideapad-laptop: ...".
Add to the commit message what you explained me and put a link to that comment. And resend new version with all maintainers included (there is a script scripts/get_maintainer.pl to help with the list of maintainers).

Quoted 10 lines · Andy Shevchenko
Quoted 5 lines

If you have time, please see:
https://bugs.launchpad.net/bugs/1366421

It has pretty much all the details on what and why we need something in sysfs.

It's a lo-o-ong discussion from which I, might be wrongly, assumed that there couple of problems: a) you don't know initial state, b) something preventing use of event.

Yes.

Quoted 3 lines

Keyboard and touchpad are disabled by hw, so, only what OS needs is a notification.

Yes.

Quoted 3 lines

Can you point me exactly to the message that explains _why_ it's impossible to use standard eventX mechanism for that?

Comment #43 has the summary of what we've tried.
https://bugs.launchpad.net/onboard/+bug/1366421/comments/43

Some of the drivers do SW_TABLET_MODE, but ideapad does not. Some of the drivers do sysfs, but ideapad does not.

For ideapad, under Xorg, it generates hotkey events.
And the hotkey event are going to work under Xorg only. What about Wayland/Mir ? We also aren't sure, if the keycodes that it sends, are uniform across all Yoga variants.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Quoted 10 lines · Andy Shevchenko

I'm sorry for top-posting, but something wrong with email quoting. I'm using here gmail, it might not recognize message properly.

So, please fix the subject line to have a prefix, in your case "platform/x86: ideapad-laptop: ...".
Add to the commit message what you explained me and put a link to that comment.
And resend new version with all maintainers included (there is a script scripts/get_maintainer.pl to help with the list of maintainers).

Thank you Andy. I've just re-sent (through git send-email) a revised patch, with your comments.

- --
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEQCVDstmIVAB/Yn02pjpYo/LhdWkFAlijEcMACgkQpjpYo/Lh dWkieRAAtfWMgH+rwbCLjXRMTfGLTG8Nf76Iyq1w+8ny09/IyN9g15YMCuE2O5QI RgQQNa5e/DZ7qqGbxlZP7T5om2PWMDlREsnjiEYBwIDBPfOd/+ob/SPRGvXPf/QP Lx47EAmVoT4dv9urcz/54G9QjYxvgE96RlE42qx1z2mompdqAyrmg28AgqccILrU rcMC9xU+2x172/z8kpdx+hZf87Zi3EevIUjrjJq39b1MDyePkv7l9Mz724RRxWfs UheZSKJtJonySz/psg9xqDzYsc23UY0XWLbTjGBCFfc+8ZYLNvobDXJkPJMK5cyx Qy0ZHkkRZC0bHiuu24WMcgmelSTcwS2WTjdYOZxOoS9nshXU/xJ33C5tjq/yrfC4 nwQsru+SdZml8xmFUHDCXfCnyMOjB5zG2n241kMjMhu7fC3UDZ+1ptxeUAk066It ov3LlPxs5sV/qOvFNbWAm8CJEPDX9kNpZ9IFneic2AZhfgR0BCiAItjvlkZVmpNi iGDIHyASM6csX8hcGKW8NAJwbZYkjrUPJRQYiqhwtbmkP7eHxEIWX1ac1uxQZP9A zUlxZCOSyWLKqp3+rVX/H3KsuRAJUkkLIzN7jwepPBdy8EAfXUuwuayfmAxXGges JtErebhnb4/WdYSkOPZcmGLGxQHlsh7mdzeEN8Gbh844Li/C0z0= =QTp1
-----END PGP SIGNATURE-----