Skip to content

Commit 36ac0d4

Browse files
rickysarrafandy-shev
authored andcommitted
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 Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
1 parent 2ea659a commit 36ac0d4

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Documentation/ABI/testing/sysfs-platform-ideapad-laptop

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ Description:
1717
* 2 -> Dust Cleaning
1818
* 4 -> Efficient Thermal Dissipation Mode
1919

20+
What: /sys/devices/platform/ideapad/touchpad
21+
Date: May 2017
22+
KernelVersion: 4.13
23+
Contact: "Ritesh Raj Sarraf <rrs@debian.org>"
24+
Description:
25+
Control touchpad mode.
26+
* 1 -> Switched On
27+
* 0 -> Switched Off

drivers/platform/x86/ideapad-laptop.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,42 @@ static ssize_t store_ideapad_fan(struct device *dev,
423423

424424
static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
425425

426+
static ssize_t touchpad_show(struct device *dev,
427+
struct device_attribute *attr,
428+
char *buf)
429+
{
430+
struct ideapad_private *priv = dev_get_drvdata(dev);
431+
unsigned long result;
432+
433+
if (read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result))
434+
return sprintf(buf, "-1\n");
435+
return sprintf(buf, "%lu\n", result);
436+
}
437+
438+
static ssize_t touchpad_store(struct device *dev,
439+
struct device_attribute *attr,
440+
const char *buf, size_t count)
441+
{
442+
struct ideapad_private *priv = dev_get_drvdata(dev);
443+
bool state;
444+
int ret;
445+
446+
ret = kstrtobool(buf, &state);
447+
if (ret)
448+
return ret;
449+
450+
ret = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
451+
if (ret < 0)
452+
return -EIO;
453+
return count;
454+
}
455+
456+
static DEVICE_ATTR_RW(touchpad);
457+
426458
static struct attribute *ideapad_attributes[] = {
427459
&dev_attr_camera_power.attr,
428460
&dev_attr_fan_mode.attr,
461+
&dev_attr_touchpad.attr,
429462
NULL
430463
};
431464

0 commit comments

Comments
 (0)