]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
platform/x86: ideapad-laptop: Add sysfs interface for touchpad state
authorRitesh Raj Sarraf <rrs@debian.org>
Fri, 17 Feb 2017 18:47:56 +0000 (00:17 +0530)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 15 May 2017 09:06:09 +0000 (12:06 +0300)
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

Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Documentation/ABI/testing/sysfs-platform-ideapad-laptop
drivers/platform/x86/ideapad-laptop.c

index b31e782bd9850628f77f683ba0f87a5ab6d169ae..597a2f3d1efceb7383c85dda040f4b1def8adddf 100644 (file)
@@ -17,3 +17,11 @@ Description:
                        * 2 -> Dust Cleaning
                        * 4 -> Efficient Thermal Dissipation Mode
 
+What:          /sys/devices/platform/ideapad/touchpad
+Date:          May 2017
+KernelVersion: 4.13
+Contact:       "Ritesh Raj Sarraf <rrs@debian.org>"
+Description:
+               Control touchpad mode.
+                       * 1 -> Switched On
+                       * 0 -> Switched Off
index 24ca9fbe31cc38f1dc35754128a07fd20dbb45f1..933668e48f878e770262aa7ddff176e6d33b3291 100644 (file)
@@ -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 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);
+       bool state;
+       int ret;
+
+       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
 };