linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] HID: i2c-hid: Enable wakeup capability from Suspend-to-Idle
@ 2020-07-09  7:57 Kai-Heng Feng
  2020-07-09 10:05 ` Hans de Goede
  2020-07-14 13:15 ` Jiri Kosina
  0 siblings, 2 replies; 3+ messages in thread
From: Kai-Heng Feng @ 2020-07-09  7:57 UTC (permalink / raw)
  To: jikos, benjamin.tissoires
  Cc: hdegoede, anthony.wong, Kai-Heng Feng, You-Sheng Yang,
	Pavel Balan, Aaron Ma, HungNien Chen, Daniel Playfair Cal,
	open list:HID CORE LAYER, open list

Many laptops can be woken up from Suspend-to-Idle by touchpad. This is
also the default behavior on other OSes.

However, if touchpad and touchscreen contact to each other when lid is
closed, wakeup events can be triggered inadventertly.

So let's disable the wakeup by default, but enable the wakeup capability
so users can enable it at their own discretion.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v4:
 - Enable the capability, but disable the wakeup default.

v3:
 - Use device_init_wakeup().
 - Wording change.

v2:
 - Fix compile error when ACPI is not enabled.

 drivers/hid/i2c-hid/i2c-hid-core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 294c84e136d7..c18ca6a6cb3d 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -931,6 +931,14 @@ static void i2c_hid_acpi_fix_up_power(struct device *dev)
 		acpi_device_fix_up_power(adev);
 }
 
+static void i2c_hid_acpi_enable_wakeup(struct device *dev)
+{
+	if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) {
+		device_set_wakeup_capable(dev, true);
+		device_set_wakeup_enable(dev, false);
+	}
+}
+
 static const struct acpi_device_id i2c_hid_acpi_match[] = {
 	{"ACPI0C50", 0 },
 	{"PNP0C50", 0 },
@@ -945,6 +953,8 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client,
 }
 
 static inline void i2c_hid_acpi_fix_up_power(struct device *dev) {}
+
+static inline void i2c_hid_acpi_enable_wakeup(struct device *dev) {}
 #endif
 
 #ifdef CONFIG_OF
@@ -1072,6 +1082,8 @@ static int i2c_hid_probe(struct i2c_client *client,
 
 	i2c_hid_acpi_fix_up_power(&client->dev);
 
+	i2c_hid_acpi_enable_wakeup(&client->dev);
+
 	device_enable_async_suspend(&client->dev);
 
 	/* Make sure there is something at this address */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] HID: i2c-hid: Enable wakeup capability from Suspend-to-Idle
  2020-07-09  7:57 [PATCH v4] HID: i2c-hid: Enable wakeup capability from Suspend-to-Idle Kai-Heng Feng
@ 2020-07-09 10:05 ` Hans de Goede
  2020-07-14 13:15 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2020-07-09 10:05 UTC (permalink / raw)
  To: Kai-Heng Feng, jikos, benjamin.tissoires
  Cc: anthony.wong, You-Sheng Yang, Pavel Balan, Aaron Ma,
	HungNien Chen, Daniel Playfair Cal, open list:HID CORE LAYER,
	open list

Hi,

On 7/9/20 9:57 AM, Kai-Heng Feng wrote:
> Many laptops can be woken up from Suspend-to-Idle by touchpad. This is
> also the default behavior on other OSes.
> 
> However, if touchpad and touchscreen contact to each other when lid is
> closed, wakeup events can be triggered inadventertly.
> 
> So let's disable the wakeup by default, but enable the wakeup capability
> so users can enable it at their own discretion.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Thank you, this version looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
> v4:
>   - Enable the capability, but disable the wakeup default.
> 
> v3:
>   - Use device_init_wakeup().
>   - Wording change.
> 
> v2:
>   - Fix compile error when ACPI is not enabled.
> 
>   drivers/hid/i2c-hid/i2c-hid-core.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
> index 294c84e136d7..c18ca6a6cb3d 100644
> --- a/drivers/hid/i2c-hid/i2c-hid-core.c
> +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
> @@ -931,6 +931,14 @@ static void i2c_hid_acpi_fix_up_power(struct device *dev)
>   		acpi_device_fix_up_power(adev);
>   }
>   
> +static void i2c_hid_acpi_enable_wakeup(struct device *dev)
> +{
> +	if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) {
> +		device_set_wakeup_capable(dev, true);
> +		device_set_wakeup_enable(dev, false);
> +	}
> +}
> +
>   static const struct acpi_device_id i2c_hid_acpi_match[] = {
>   	{"ACPI0C50", 0 },
>   	{"PNP0C50", 0 },
> @@ -945,6 +953,8 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client,
>   }
>   
>   static inline void i2c_hid_acpi_fix_up_power(struct device *dev) {}
> +
> +static inline void i2c_hid_acpi_enable_wakeup(struct device *dev) {}
>   #endif
>   
>   #ifdef CONFIG_OF
> @@ -1072,6 +1082,8 @@ static int i2c_hid_probe(struct i2c_client *client,
>   
>   	i2c_hid_acpi_fix_up_power(&client->dev);
>   
> +	i2c_hid_acpi_enable_wakeup(&client->dev);
> +
>   	device_enable_async_suspend(&client->dev);
>   
>   	/* Make sure there is something at this address */
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] HID: i2c-hid: Enable wakeup capability from Suspend-to-Idle
  2020-07-09  7:57 [PATCH v4] HID: i2c-hid: Enable wakeup capability from Suspend-to-Idle Kai-Heng Feng
  2020-07-09 10:05 ` Hans de Goede
@ 2020-07-14 13:15 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2020-07-14 13:15 UTC (permalink / raw)
  To: Kai-Heng Feng
  Cc: benjamin.tissoires, hdegoede, anthony.wong, You-Sheng Yang,
	Pavel Balan, Aaron Ma, HungNien Chen, Daniel Playfair Cal,
	open list:HID CORE LAYER, open list

On Thu, 9 Jul 2020, Kai-Heng Feng wrote:

> Many laptops can be woken up from Suspend-to-Idle by touchpad. This is
> also the default behavior on other OSes.
> 
> However, if touchpad and touchscreen contact to each other when lid is
> closed, wakeup events can be triggered inadventertly.
> 
> So let's disable the wakeup by default, but enable the wakeup capability
> so users can enable it at their own discretion.

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-14 13:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09  7:57 [PATCH v4] HID: i2c-hid: Enable wakeup capability from Suspend-to-Idle Kai-Heng Feng
2020-07-09 10:05 ` Hans de Goede
2020-07-14 13:15 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).