From c2de5d49776658dd43b2b6d4c4120e76cbbce7b7 Mon Sep 17 00:00:00 2001 From: Shijie Zhang Date: Fri, 28 Oct 2011 08:54:50 +0800 Subject: [PATCH] [PORT FROM GB] Add support for dynamically adjusting volume during the call in S3 state BZ: 13269 This patch fix the problem that can not adjust the volume during the call in S3 state with screen off because of the proximity sensor. By adding sysfs interface "enabled_wakeup" and "disabled_wakeup" in gpio-keys to dynamically enable or disable the gpiokeys. Change-Id: I80c45daca2999821502302998f76e0e54c806a68 Signed-off-by: Shijie Zhang Reviewed-on: http://android.intel.com:8080/26773 Reviewed-by: Barthes, FabienX Tested-by: Barthes, FabienX Reviewed-by: buildbot Tested-by: buildbot --- drivers/input/keyboard/gpio_keys.c | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 6e6145b..07c3cab 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -292,6 +292,44 @@ static ssize_t gpio_keys_store_##name(struct device *dev, \ ATTR_STORE_FN(disabled_keys, EV_KEY); ATTR_STORE_FN(disabled_switches, EV_SW); +static ssize_t gpio_keys_wakeup_enable(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t size, int enable_wakeup) +{ + int i, ret = -EINVAL; + long code; + struct platform_device *pdev = to_platform_device(dev); + struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; + + ret = strict_strtol(buf, 10, &code); + if (ret != 0) { + dev_err(dev, "Invalid input.\n"); + return ret; + } + + for (i = 0; i < pdata->nbuttons; i++) { + struct gpio_keys_button *button = &pdata->buttons[i]; + if ((int)code == button->code) + button->wakeup = enable_wakeup; + } + + return size; +} + + + +static ssize_t gpio_keys_store_enabled_wakeup(struct device *dev, + struct device_attribute *attr, const char *buf, size_t size) +{ + return gpio_keys_wakeup_enable(dev, attr, buf, size, 1); +} + +static ssize_t gpio_keys_store_disabled_wakeup(struct device *dev, + struct device_attribute *attr, const char *buf, size_t size) +{ + return gpio_keys_wakeup_enable(dev, attr, buf, size, 0); +} + /* * ATTRIBUTES: * @@ -304,12 +342,20 @@ static DEVICE_ATTR(disabled_keys, S_IWUSR | S_IRUGO, static DEVICE_ATTR(disabled_switches, S_IWUSR | S_IRUGO, gpio_keys_show_disabled_switches, gpio_keys_store_disabled_switches); +static DEVICE_ATTR(enabled_wakeup, S_IWUSR | S_IRUGO, + NULL, + gpio_keys_store_enabled_wakeup); +static DEVICE_ATTR(disabled_wakeup, S_IWUSR | S_IRUGO, + NULL, + gpio_keys_store_disabled_wakeup); static struct attribute *gpio_keys_attrs[] = { &dev_attr_keys.attr, &dev_attr_switches.attr, &dev_attr_disabled_keys.attr, &dev_attr_disabled_switches.attr, + &dev_attr_enabled_wakeup.attr, + &dev_attr_disabled_wakeup.attr, NULL, }; -- 2.7.4