Skip to contentSkip to conversation

platform/x86: ideapad-laptop: Add sysfs interface for touchpad state

PATCH In review Ritesh Raj Sarraf 3 participants 13 messages Feb 17, 2017 – May 7, 2017 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 platform/x86: ideapad-laptop: 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.

Currently, there is no easy interface to determine the touchpad status, which in case of the Yoga family of machines, can also be useful to assume tablet mode status.
Note: The ideapad-laptop driver does not provide a SW_TABLET_MODE either

For a detailed discussion on why we want either of the interfaces, please see:
https://bugs.launchpad.net/onboard/+bug/1366421/comments/43

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

v4:
Use kstrtobool because supported values are boolean

v3:
Include Darren Hart's comments
Changed sysfs inteface from "touchpad_mode" to "touchpad"

v2:
Include Andy Shevchenko's comments

---
 .../ABI/testing/sysfs-platform-ideapad-laptop      |  8 +++++
 drivers/platform/x86/ideapad-laptop.c              | 34 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)
Documentation/ABI/testing/sysfs-platform-ideapad-laptop +8 -0
index b31e782bd985..5d24f1e8e6ef 100644
@@ -17,3 +17,11 @@ Description:
 			* 2 -> Dust Cleaning
 			* 4 -> Efficient Thermal Dissipation Mode
 
+What:		/sys/devices/platform/ideapad/touchpad
+Date:		Feb 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 +34 -0
index f46ece2ce3c4..b35954707e11 100644
@@ -423,9 +423,43 @@ static ssize_t store_ideapad_fan(struct device *dev,
 
 static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
 
+
+static ssize_t touchpad_show(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+	unsigned long result;
+
+	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 touchpad_store(struct device *dev,
+				 struct device_attribute *attr,
+				 const char *buf, size_t count)
+{
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+	int ret;
+	bool state;
+
+	ret = kstrtobool(buf, &state);
+	if (ret)
+		return ret;
+
+	ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
+	if (ret < 0)
+		return -EIO;
+	return count;
+}
+
+static DEVICE_ATTR_RW(touchpad);
+
 static struct attribute *ideapad_attributes[] = {
 	&dev_attr_camera_power.attr,
 	&dev_attr_fan_mode.attr,
+	&dev_attr_touchpad.attr,
 	NULL
 };
 
Signature · 1 line
2.11.0
#1 lore raw

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

Hello Darren / Andy,

Any further comment on this patch ? Will this be accepted ? Please give a N/ACK.

Thanks,
Ritesh

Quoted 96 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.

Currently, there is no easy interface to determine the touchpad status, which in case of the Yoga family of machines, can also be useful to assume tablet mode status.
Note: The ideapad-laptop driver does not provide a SW_TABLET_MODE either

For a detailed discussion  on why we want either of the interfaces, please see:
https://bugs.launchpad.net/onboard/+bug/1366421/comments/43

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

v4:
Use kstrtobool because supported values are boolean

v3:
Include Darren Hart's comments
Changed sysfs inteface from "touchpad_mode" to "touchpad"

v2:
Include Andy Shevchenko's comments

---
 .../ABI/testing/sysfs-platform-ideapad-laptop      |  8 +++++ drivers/platform/x86/ideapad-laptop.c              | 34
++++++++++++++++++++++

 2 files changed, 42 insertions(+)
Documentation/ABI/testing/sysfs-platform-ideapad-laptop +0 -0
index b31e782bd985..5d24f1e8e6ef 100644
@@ -17,3 +17,11 @@ Description:
  			* 2 -> Dust Cleaning
  			* 4 -> Efficient Thermal Dissipation Mode

Documentation/ABI/testing/sysfs-platform-ideapad-laptop +8 -0
+What:		/sys/devices/platform/ideapad/touchpad
+Date:		Feb 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 +0 -0
index f46ece2ce3c4..b35954707e11 100644
@@ -423,9 +423,43 @@ 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 +33 -0
+
+static ssize_t touchpad_show(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+	unsigned long result;
+
+	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 touchpad_store(struct device *dev,
+				 struct device_attribute *attr,
+				 const char *buf, size_t count)
+{
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+	int ret;
+	bool state;
+
+	ret = kstrtobool(buf, &state);
+	if (ret)
+		return ret;
+
+	ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
+	if (ret < 0)
+		return -EIO;
+	return count;
+}
+
+static DEVICE_ATTR_RW(touchpad);
+

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

drivers/platform/x86/ideapad-laptop.c +1 -0
+	&dev_attr_touchpad.attr,
Quoted 3 lines

  NULL
 };

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

iQIzBAEBCgAdFiEEQCVDstmIVAB/Yn02pjpYo/LhdWkFAlitZtIACgkQpjpYo/Lh dWnCsw/9Eo0+id6jjJZaVRBhtQTcI510T2IY/wDFfrMOH8Ei2+Iw1d/rCCA5iCWa HDP9R+AZpFxM71nJsm/JZVuYOZDbKh17TkeM9eIG1dpQH48I576hz0IdwvRNeT+t kba0NGyQTw0PdMdP8mcOhrFbDkFiLJ0rg0fu1ESxilTnshTUPch+1aUexqeBTCYG ICvidlD0gr+Q8x9pbqCEdFNwRzqekl7a9ezR4bvyqXpJSx2DWVq2WFHbnrX9BADF gextZaRWQ7sUR27seXO3JL0DgfYspDkP2UQno7lr4Vx3UxyeUUDVYmF2OmpupHJu F8BifivXBPy0ZDLn8UbKgEMBqLIx5E3BWWdVyJyobkB9PHoDbe0vvpNXyAQW2xzY X+CtozZ04su9rk5L+ivsozbAyNFXirHrXOOGZzTa/svKHSsR7xiFA9JHK5mwtnsl KhJNR0FkXH+QIBm8dbUDteJ9/fTodnUjXN+C7dya9+Sb0Bi1AgSpVe1poZ+74XWR jz5NtJ+yKxo7SOQ6SxRSPN7zLfhwpORoi5pid2Qn0dKpW8GoB8b6bi0xHGWuraIJ LIVTJE6TgMgFkjPTJR4vlR+eoxyDM2HTsyx59fWwECEJUANXit7pnbixnZ4McYLh he6dsgStv8kuHNNCJoeDPLiNYvruUKqHdnf/Vvbk0A+sCgY8JAI= =BuNe
-----END PGP SIGNATURE-----

#2 lore raw
Quoted 2 lines · Ritesh Raj Sarraf

Any further comment on this patch ? Will this be accepted ? Please give a N/ACK.

First of all, please do not top post.

Quoted 10 lines · Ritesh Raj Sarraf
Quoted 9 lines

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.

Currently, there is no easy interface to determine the touchpad status, which in case of the Yoga family of machines, can also be useful to assume tablet mode status.
Note: The ideapad-laptop driver does not provide a SW_TABLET_MODE either

Quoted 6 lines
Quoted 6 lines

For a detailed discussion on why we want either of the interfaces, please see:
https://bugs.launchpad.net/onboard/+bug/1366421/comments/43

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

While patch is okay to me per se, I would like to have a formal acknowledgement from maintainer.

Ike, can you give one?

Quoted 19 lines
Quoted 19 lines
Documentation/ABI/testing/sysfs-platform-ideapad-laptop +8 -0
@@ -17,3 +17,11 @@ Description:
                      * 2 -> Dust Cleaning
                      * 4 -> Efficient Thermal Dissipation Mode
 
+What:                /sys/devices/platform/ideapad/touchpad
+Date:                Feb 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 +0 -0
index f46ece2ce3c4..b35954707e11 100644
@@ -423,9 +423,43 @@ static ssize_t store_ideapad_fan(struct device *dev,
 
Quoted 4 lines

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

Quoted 4 lines
drivers/platform/x86/ideapad-laptop.c +1 -0
 static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
 
 
+

Extra empty line.

Quoted 18 lines
Quoted 17 lines
drivers/platform/x86/ideapad-laptop.c +17 -0
+static ssize_t touchpad_show(struct device *dev,
+                             struct device_attribute *attr,
+                             char *buf)
+{
+     struct ideapad_private *priv = dev_get_drvdata(dev);
+     unsigned long result;
+
+     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 touchpad_store(struct device *dev,
+                              struct device_attribute *attr,
+                              const char *buf, size_t count)
+{
+     struct ideapad_private *priv = dev_get_drvdata(dev);
Quoted 2 lines

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

Quoted 2 lines
drivers/platform/x86/ideapad-laptop.c +2 -0
+     int ret;
+     bool state;

Reverse tree order.

Quoted 19 lines
Quoted 19 lines
drivers/platform/x86/ideapad-laptop.c +14 -0
+
+     ret = kstrtobool(buf, &state);
+     if (ret)
+             return ret;
+
+     ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
+     if (ret < 0)
+             return -EIO;
+     return count;
+}
+
+static DEVICE_ATTR_RW(touchpad);
+
 static struct attribute *ideapad_attributes[] = {
      &dev_attr_camera_power.attr,
      &dev_attr_fan_mode.attr,
+     &dev_attr_touchpad.attr,
      NULL
 };
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
In reply to Ritesh Raj Sarraf
Quoted 2 lines · Ritesh Raj Sarraf

Any further comment on this patch ? Will this be accepted ? Please give a N/ACK.

Sorry for a long delay, but I can't go with this without clear understanding that there is indeed no other ways available. From what I read in the above link the main issue that driver doesn't send SW_TABLET_MODE event through input device.
I think this is the best approach how it should go.

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

Hello,

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

Any further comment on this patch ? Will this be accepted ? Please give a N/ACK.

Sorry for a long delay, but I can't go with this without clear understanding that there is indeed no other ways available. From what I read in the above link

i am assuming you are referring to the launchpad bug report here.

Quoted 2 lines

the main issue that driver doesn't
send SW_TABLET_MODE event through input device.

Well. Yes. That is one part. If SW_TABLET_MODE is done in the driver, much better. My patch was simply in line with some of the other drivers (hp-wmi and thinkpad_acpi) to get it working for Lenovo Yoga series.

Quoted 1 line

I think this is the best approach how it should go.

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

Hello,

Quoted 2 lines · Andy Shevchenko

On Wed, Feb 22, 2017 at 12:24 PM, Ritesh Raj Sarraf <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Any further comment on this patch ? Will this be accepted ? Please give a N/ACK.

Sorry for a long delay, but I can't go with this without clear understanding that there is indeed no other ways available. From what I read in the above link

i am assuming you are referring to the launchpad bug report here.

Correct.

Quoted 6 lines
Quoted 2 lines

the main issue that driver doesn't
send SW_TABLET_MODE event through input device.

Well. Yes. That is one part. If SW_TABLET_MODE is done in the driver, much better. My patch was simply in line with some of the other drivers (hp-wmi and thinkpad_acpi) to get it working for Lenovo Yoga series.

sysfs ABI for drivers that provide input interface is quite strong for my opinion. It means I'm not totally objecting, but I would accept it if and only if there is nothing else could be done.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Ritesh Raj Sarraf

Hello,

Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Ritesh Raj Sarraf

Any further comment on this patch ? Will this be accepted ? Please give a N/ACK.

Sorry for a long delay,

Eeek, likewise. This one fell off my stack. We've improved our patch management process since this was originally submitted, so hopefully this is more and more rare.

Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

but I can't go with this without clear understanding that there is indeed no other ways available. From what I read in the above link

i am assuming you are referring to the launchpad bug report here.

Correct.

Quoted 3 lines
Quoted 2 lines

the main issue that driver doesn't
send SW_TABLET_MODE event through input device.

Quoted 7 lines
Quoted 3 lines

Well. Yes. That is one part. If SW_TABLET_MODE is done in the driver, much better. My patch was simply in line with some of the other drivers (hp-wmi and thinkpad_acpi) to get it working for Lenovo Yoga series.

sysfs ABI for drivers that provide input interface is quite strong for my opinion. It means I'm not totally objecting, but I would accept it if and only if there is nothing else could be done.

Agreed, we've recently wanted to remove certain sysfs attributes from another driver as they were obsolete and better implemented in other ways, but once they are there, are hands are tied.

That said, we will support getting these systems functional. From what I see in the patch you are implementing a polling sysfs interface. Have you verified that there is no event we can capture and send the SW_TABLET_MODE along to the input system?

Finally, I just want to point out that while it may seem capricious for us to resist accepting a new sysfs attribute that exists in other drivers, please note that the thinkpad driver (for example) is ancient and implements multiple mechanisms for several things and should not be considered as a reference for new code. hp_wmi is another story.

Andy, we may also need to consult on a set of common laptop attributes that we will accept in general. This would ease review and also lead to some more uniformity in the sysfs attributes of the most common features (like tablet mode, touchpad, etc.). That said, the value are likely to be platform specific and it could prove difficult to map all that variety to a common set of values.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#7 lore raw
Quoted 9 lines · Darren Hart
Quoted 3 lines

sysfs ABI for drivers that provide input interface is quite strong for my opinion. It means I'm not totally objecting, but I would accept it if and only if there is nothing else could be done.

Agreed, we've recently wanted to remove certain sysfs attributes from another driver as they were obsolete and better implemented in other ways, but once they
are there, are hands are tied.

Quoted 7 lines

That said, we will support getting these systems functional. From what I see in
the patch you are implementing a polling sysfs interface. Have you verified that
there is no event we can capture and send the SW_TABLET_MODE along to the input
system?

I believe it does generate an event (at least on my Yoga 2 13 variant). IIRC, when I talked to Andy initially about the driver's limitation, we did do an exercise [1] to determine if an event was generated.

Cooking this patch (sysfs interface) was much quicker and easy. I looked at the other example drivers, that do SW_TABLET_MODE, but left it there. I don't think I have all the necessary information to get that done for the ideapad driver.

[1] https://patchwork.kernel.org/patch/9546987/

Signature · 2 lines
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System
#8 lore raw
Quoted 22 lines · Ritesh Raj Sarraf
Quoted 9 lines · Darren Hart
Quoted 3 lines

sysfs ABI for drivers that provide input interface is quite strong for my opinion. It means I'm not totally objecting, but I would accept it if and only if there is nothing else could be done.

Agreed, we've recently wanted to remove certain sysfs attributes from another driver as they were obsolete and better implemented in other ways, but once they
are there, are hands are tied.

Quoted 7 lines

That said, we will support getting these systems functional. From what I see in
the patch you are implementing a polling sysfs interface. Have you verified that
there is no event we can capture and send the SW_TABLET_MODE along to the input
system?

I believe it does generate an event (at least on my Yoga 2 13 variant). IIRC, when I talked to Andy initially about the driver's limitation, we did do an exercise [1] to determine if an event was generated.

Quoted 6 lines

Cooking this patch (sysfs interface) was much quicker and easy. I looked at the other example drivers, that do SW_TABLET_MODE, but left it there. I don't think I have all the necessary information to get that done for the ideapad driver.

[1] https://patchwork.kernel.org/patch/9546987/

Thanks. We really want to avoid user-space having to write platform specific sysfs attribute access to determine system state for common things like "should I show the on screen keyboard?". That doesn't scale and will result in a very sparse support matrix in general.

Something I am not particularly well versed in is the issue with hotkeys, xinput, and only working in Xorg rather than wayland. Where in the stack is this limitation created? I assume it is above the kernel - no reason Wayland can't read SW_TABLET_MODE from the input subsystem correct?

I believe I have a couple systems which will replicate this issue so I'll try to spend some time with them to see what else might be done.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#9 lore raw
In reply to Andy Shevchenko

Resending again, as Google servers are behaving weird lately.

Quoted 11 lines · Andy Shevchenko
Quoted 7 lines
Quoted 2 lines

the main issue that driver doesn't
send SW_TABLET_MODE event through input device.

Well. Yes. That is one part. If SW_TABLET_MODE is done in the driver, much better. My patch was simply in line with some of the other drivers (hp-wmi and
thinkpad_acpi) to get it working for Lenovo Yoga series.

sysfs ABI for drivers that provide input interface is quite strong for my opinion. It means I'm not totally objecting, but I would accept it if and only if there is nothing else could be done.

The need we have in the user application is for read-only access.

I have attached the same old patch with just the minor file attribute change, which would make the sysfs interface to read-only. If in future, there are good reasons to expose that interface as read/write, updating that attribute can be revisited.

Can this now be included in your tree ? This minor patch may be helpful to many Ideapad users with a Hybrid machine.

PS: Given how minimal the change is, I just hand updated the patch. If you want it in the proper git send-email flow, please let me know.

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

From f18911c1ee0714943a023db8ae43bf84a3873d98 Mon Sep 17 00:00:00 2001
From: Ritesh Raj Sarraf <[email protected]>
Date: Mon, 30 Jan 2017 15:05:48 +0530
Subject: [PATCH v4] platform/x86: ideapad-laptop: 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.

Currently, there is no easy interface to determine the touchpad status, which in case of the Yoga family of machines, can also be useful to assume tablet mode status.
Note: The ideapad-laptop driver does not provide a SW_TABLET_MODE either

For a detailed discussion on why we want either of the interfaces, please see:
https://bugs.launchpad.net/onboard/+bug/1366421/comments/43

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

v5:
Set file attribute to read-only

v4:
Use kstrtobool because supported values are boolean

v3:
Include Darren Hart's comments
Changed sysfs inteface from "touchpad_mode" to "touchpad"

v2:
Include Andy Shevchenko's comments

---
 .../ABI/testing/sysfs-platform-ideapad-laptop      |  8 +++++
 drivers/platform/x86/ideapad-laptop.c              | 34 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)
Documentation/ABI/testing/sysfs-platform-ideapad-laptop +8 -0
index b31e782bd985..5d24f1e8e6ef 100644
@@ -17,3 +17,11 @@ Description:
 			* 2 -> Dust Cleaning
 			* 4 -> Efficient Thermal Dissipation Mode
 
+What:		/sys/devices/platform/ideapad/touchpad
+Date:		Feb 2017
+KernelVersion:	4.12
+Contact:	"Ritesh Raj Sarraf <[email protected]>"
+Description:
+		Read touchpad status.
+			* 1 -> Switched On
+			* 0 -> Switched Off
drivers/platform/x86/ideapad-laptop.c +34 -0
index f46ece2ce3c4..b35954707e11 100644
@@ -423,9 +423,43 @@ static ssize_t store_ideapad_fan(struct device *dev,
 
 static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
 
+
+static ssize_t touchpad_show(struct device *dev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+	unsigned long result;
+
+	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 touchpad_store(struct device *dev,
+				 struct device_attribute *attr,
+				 const char *buf, size_t count)
+{
+	struct ideapad_private *priv = dev_get_drvdata(dev);
+	int ret;
+	bool state;
+
+	ret = kstrtobool(buf, &state);
+	if (ret)
+		return ret;
+
+	ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
+	if (ret < 0)
+		return -EIO;
+	return count;
+}
+
+static DEVICE_ATTR_RO(touchpad);
+
 static struct attribute *ideapad_attributes[] = {
 	&dev_attr_camera_power.attr,
 	&dev_attr_fan_mode.attr,
+	&dev_attr_touchpad.attr,
 	NULL
 };
 
Signature · 1 line
2.11.0
#10 lore raw
Quoted 11 lines · Ritesh Raj Sarraf

Resending again, as Google servers are behaving weird lately.

Quoted 8 lines · Andy Shevchenko
Quoted 7 lines
Quoted 2 lines

the main issue that driver doesn't
send SW_TABLET_MODE event through input device.

Well. Yes. That is one part. If SW_TABLET_MODE is done in the driver, much better. My patch was simply in line with some of the other drivers (hp-wmi and
thinkpad_acpi) to get it working for Lenovo Yoga series.

Quoted 5 lines
Quoted 3 lines

sysfs ABI for drivers that provide input interface is quite strong for my opinion. It means I'm not totally objecting, but I would accept it if and only if there is nothing else could be done.

The need we have in the user application is for read-only access.

I does not matter at all! You are proposing a part of ABI which will be closer to what is "carved in stone". Here is the problem.

So, I'm really trying hard to get avoid such "small things" which would make our lives quite hard in long term prospective while fixing short-term issues in a good will.

Please, consider to do it better. For now I didn't hear any proof that there is no other way to achieve your goal.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw
Quoted 21 lines · Andy Shevchenko
Quoted 11 lines · Ritesh Raj Sarraf

Resending again, as Google servers are behaving weird lately.

Quoted 8 lines · Andy Shevchenko
Quoted 7 lines
Quoted 2 lines

the main issue that driver doesn't
send SW_TABLET_MODE event through input device.

Well. Yes. That is one part. If SW_TABLET_MODE is done in the driver, much better. My patch was simply in line with some of the other drivers (hp-wmi and
thinkpad_acpi) to get it working for Lenovo Yoga series.

Quoted 5 lines
Quoted 3 lines

sysfs ABI for drivers that provide input interface is quite strong for my opinion. It means I'm not totally objecting, but I would accept it if and only if there is nothing else could be done.

The need we have in the user application is for read-only access.

I does not matter at all! You are proposing a part of ABI which will be closer to what is "carved in stone". Here is the problem.

Quoted 6 lines

So, I'm really trying hard to get avoid such "small things" which would make our lives quite hard in long term prospective while fixing short-term issues in a good will.

Please, consider to do it better. For now I didn't hear any proof that there is no other way to achieve your goal.

I spent a day with the Lenovo Yoga 2 11 I have available, and have not yet found a reliable means of detecting the tablet mode (reverse engineering these things isn't something I'm expert at though). I've reached out to the original author for some context, but that didn't lead to any revelations as of yet.

Ultimately, this sysfs attribute is no better or worse than others that exist in our tree. So until we can provide a better solution, we do need to be careful to not inadvertently favor one laptop driver over another while seeking to avoid sysfs stable API issues.

I do think we need to start distinguishing between core kernel userspace interfaces and leaf node driver sysfs attributes.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#12 lore raw
Quoted 26 lines · Darren Hart
Quoted 25 lines · Andy Shevchenko
Quoted 11 lines · Ritesh Raj Sarraf

Resending again, as Google servers are behaving weird lately.

Quoted 8 lines · Andy Shevchenko
Quoted 7 lines
Quoted 2 lines

the main issue that driver doesn't
send SW_TABLET_MODE event through input device.

Well. Yes. That is one part. If SW_TABLET_MODE is done in the driver, much better. My patch was simply in line with some of the other drivers (hp-wmi and
thinkpad_acpi) to get it working for Lenovo Yoga series.

Quoted 5 lines
Quoted 3 lines

sysfs ABI for drivers that provide input interface is quite strong for my opinion. It means I'm not totally objecting, but I would accept it if and only if there is nothing else could be done.

The need we have in the user application is for read-only access.

I does not matter at all! You are proposing a part of ABI which will be closer to what is "carved in stone". Here is the problem.

So, I'm really trying hard to get avoid such "small things" which would make our lives quite hard in long term prospective while fixing short-term issues in a good will.

Quoted 7 lines
Quoted 2 lines

Please, consider to do it better. For now I didn't hear any proof that there is no other way to achieve your goal.

I spent a day with the Lenovo Yoga 2 11 I have available, and have not yet found a reliable means of detecting the tablet mode (reverse engineering these things isn't something I'm expert at though). I've reached out to the original author for some context, but that didn't lead to any revelations as of yet.

Okay, I have pushed to testing current version and put on top the separate patch for switching attribute to be RO.
(I just realized it might produce a warning since we have defined and not used function.)

Quoted 7 lines

Ultimately, this sysfs attribute is no better or worse than others that exist in our tree. So until we can provide a better solution, we do need to be careful to not inadvertently favor one laptop driver over another while seeking to avoid sysfs stable API issues.

I do think we need to start distinguishing between core kernel userspace interfaces and leaf node driver sysfs attributes.

More flexibility -- more ways to abuse it OTOH :-)

Signature · 2 lines
With Best Regards,
Andy Shevchenko