LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] platform/x86: intel-vbtn: Report switch events when event wakes device
@ 2019-05-20 22:41 Mathew King
  2019-05-21 13:37 ` Jett Rink
  0 siblings, 1 reply; 4+ messages in thread
From: Mathew King @ 2019-05-20 22:41 UTC (permalink / raw)
  To: linux-kernel
  Cc: Mathew King, AceLan Kao, Andy Shevchenko, Darren Hart,
	platform-driver-x86, Jett Rink, Mario.Limonciello

When a switch event, such as tablet mode/laptop mode or docked/undocked,
wakes a device make sure that the value of the swich is reported.
Without when a device is put in tablet mode from laptop mode when it is
suspended or vice versa the device will wake up but mode will be
incorrect.

Tested by suspending a device in laptop mode and putting it in tablet
mode, the device resumes and is in tablet mode. When suspending the
device in tablet mode and putting it in laptop mode the device resumes
and is in laptop mode.

Signed-off-by: Mathew King <mathewk@chromium.org>

---
Changes in v2:
  - Added comment explaining why switch events are reported
  - Format so that checkpatch is happy
---
 drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index 06cd7e818ed5..a0d0cecff55f 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 	struct platform_device *device = context;
 	struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
 	unsigned int val = !(event & 1); /* Even=press, Odd=release */
-	const struct key_entry *ke_rel;
+	const struct key_entry *ke, *ke_rel;
 	bool autorelease;
 
 	if (priv->wakeup_mode) {
-		if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
+		ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
+		if (ke) {
 			pm_wakeup_hard_event(&device->dev);
+
+			/*
+			 * Switch events like tablet mode will wake the device
+			 * and report the new switch position to the input
+			 * subsystem.
+			 */
+			if (ke->type == KE_SW)
+				sparse_keymap_report_event(priv->input_dev,
+							   event,
+							   val,
+							   0);
 			return;
 		}
 		goto out_unknown;
-- 
2.21.0.1020.gf2820cf01a-goog


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

* Re: [PATCH v2] platform/x86: intel-vbtn: Report switch events when event wakes device
  2019-05-20 22:41 [PATCH v2] platform/x86: intel-vbtn: Report switch events when event wakes device Mathew King
@ 2019-05-21 13:37 ` Jett Rink
  2019-05-21 13:42   ` Mario.Limonciello
  0 siblings, 1 reply; 4+ messages in thread
From: Jett Rink @ 2019-05-21 13:37 UTC (permalink / raw)
  To: Mathew King
  Cc: linux-kernel, AceLan Kao, Andy Shevchenko, Darren Hart,
	platform-driver-x86, Mario.Limonciello

On Mon, May 20, 2019 at 4:41 PM Mathew King <mathewk@chromium.org> wrote:
>
> When a switch event, such as tablet mode/laptop mode or docked/undocked,
> wakes a device make sure that the value of the swich is reported.
> Without when a device is put in tablet mode from laptop mode when it is
> suspended or vice versa the device will wake up but mode will be
> incorrect.
>
> Tested by suspending a device in laptop mode and putting it in tablet
> mode, the device resumes and is in tablet mode. When suspending the
> device in tablet mode and putting it in laptop mode the device resumes
> and is in laptop mode.
>
> Signed-off-by: Mathew King <mathewk@chromium.org>
>
> ---
> Changes in v2:
>   - Added comment explaining why switch events are reported
>   - Format so that checkpatch is happy
> ---
>  drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> index 06cd7e818ed5..a0d0cecff55f 100644
> --- a/drivers/platform/x86/intel-vbtn.c
> +++ b/drivers/platform/x86/intel-vbtn.c
> @@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
>         struct platform_device *device = context;
>         struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
>         unsigned int val = !(event & 1); /* Even=press, Odd=release */
> -       const struct key_entry *ke_rel;
> +       const struct key_entry *ke, *ke_rel;
>         bool autorelease;
>
>         if (priv->wakeup_mode) {
> -               if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
> +               ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
> +               if (ke) {
>                         pm_wakeup_hard_event(&device->dev);
> +
> +                       /*
> +                        * Switch events like tablet mode will wake the device
> +                        * and report the new switch position to the input
> +                        * subsystem.
> +                        */
Thanks for adding the comment; This looks good to me.

> +                       if (ke->type == KE_SW)
> +                               sparse_keymap_report_event(priv->input_dev,
> +                                                          event,
> +                                                          val,
> +                                                          0);
>                         return;
>                 }
>                 goto out_unknown;
> --
> 2.21.0.1020.gf2820cf01a-goog
>

Reviewed-by: Jett Rink <jettrink@chromium.org>

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

* RE: [PATCH v2] platform/x86: intel-vbtn: Report switch events when event wakes device
  2019-05-21 13:37 ` Jett Rink
@ 2019-05-21 13:42   ` Mario.Limonciello
  2019-05-24 16:31     ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Mario.Limonciello @ 2019-05-21 13:42 UTC (permalink / raw)
  To: jettrink, mathewk
  Cc: linux-kernel, acelan.kao, andy, dvhart, platform-driver-x86

> -----Original Message-----
> From: Jett Rink <jettrink@chromium.org>
> Sent: Tuesday, May 21, 2019 8:37 AM
> To: Mathew King
> Cc: linux-kernel; AceLan Kao; Andy Shevchenko; Darren Hart; platform-driver-
> x86@vger.kernel.org; Limonciello, Mario
> Subject: Re: [PATCH v2] platform/x86: intel-vbtn: Report switch events when event
> wakes device
> 
> 
> [EXTERNAL EMAIL]
> 
> On Mon, May 20, 2019 at 4:41 PM Mathew King <mathewk@chromium.org>
> wrote:
> >
> > When a switch event, such as tablet mode/laptop mode or docked/undocked,
> > wakes a device make sure that the value of the swich is reported.
> > Without when a device is put in tablet mode from laptop mode when it is
> > suspended or vice versa the device will wake up but mode will be
> > incorrect.
> >
> > Tested by suspending a device in laptop mode and putting it in tablet
> > mode, the device resumes and is in tablet mode. When suspending the
> > device in tablet mode and putting it in laptop mode the device resumes
> > and is in laptop mode.
> >
> > Signed-off-by: Mathew King <mathewk@chromium.org>
> >
> > ---
> > Changes in v2:
> >   - Added comment explaining why switch events are reported
> >   - Format so that checkpatch is happy
> > ---
> >  drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> > index 06cd7e818ed5..a0d0cecff55f 100644
> > --- a/drivers/platform/x86/intel-vbtn.c
> > +++ b/drivers/platform/x86/intel-vbtn.c
> > @@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32
> event, void *context)
> >         struct platform_device *device = context;
> >         struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
> >         unsigned int val = !(event & 1); /* Even=press, Odd=release */
> > -       const struct key_entry *ke_rel;
> > +       const struct key_entry *ke, *ke_rel;
> >         bool autorelease;
> >
> >         if (priv->wakeup_mode) {
> > -               if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
> > +               ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
> > +               if (ke) {
> >                         pm_wakeup_hard_event(&device->dev);
> > +
> > +                       /*
> > +                        * Switch events like tablet mode will wake the device
> > +                        * and report the new switch position to the input
> > +                        * subsystem.
> > +                        */
> Thanks for adding the comment; This looks good to me.
> 
> > +                       if (ke->type == KE_SW)
> > +                               sparse_keymap_report_event(priv->input_dev,
> > +                                                          event,
> > +                                                          val,
> > +                                                          0);
> >                         return;
> >                 }
> >                 goto out_unknown;
> > --
> > 2.21.0.1020.gf2820cf01a-goog
> >
> 
> Reviewed-by: Jett Rink <jettrink@chromium.org>

Reviewed-by: Mario Limonciello <mario.limonciello@dell.com>

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

* Re: [PATCH v2] platform/x86: intel-vbtn: Report switch events when event wakes device
  2019-05-21 13:42   ` Mario.Limonciello
@ 2019-05-24 16:31     ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2019-05-24 16:31 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: jettrink, mathewk, Linux Kernel Mailing List, AceLan Kao,
	Andy Shevchenko, Darren Hart, Platform Driver

On Tue, May 21, 2019 at 4:43 PM <Mario.Limonciello@dell.com> wrote:
>
> > -----Original Message-----
> > From: Jett Rink <jettrink@chromium.org>
> > Sent: Tuesday, May 21, 2019 8:37 AM
> > To: Mathew King
> > Cc: linux-kernel; AceLan Kao; Andy Shevchenko; Darren Hart; platform-driver-
> > x86@vger.kernel.org; Limonciello, Mario
> > Subject: Re: [PATCH v2] platform/x86: intel-vbtn: Report switch events when event
> > wakes device
> >
> >

Pushed to my review and testing queue, thanks!

> > [EXTERNAL EMAIL]
> >
> > On Mon, May 20, 2019 at 4:41 PM Mathew King <mathewk@chromium.org>
> > wrote:
> > >
> > > When a switch event, such as tablet mode/laptop mode or docked/undocked,
> > > wakes a device make sure that the value of the swich is reported.
> > > Without when a device is put in tablet mode from laptop mode when it is
> > > suspended or vice versa the device will wake up but mode will be
> > > incorrect.
> > >
> > > Tested by suspending a device in laptop mode and putting it in tablet
> > > mode, the device resumes and is in tablet mode. When suspending the
> > > device in tablet mode and putting it in laptop mode the device resumes
> > > and is in laptop mode.
> > >
> > > Signed-off-by: Mathew King <mathewk@chromium.org>
> > >
> > > ---
> > > Changes in v2:
> > >   - Added comment explaining why switch events are reported
> > >   - Format so that checkpatch is happy
> > > ---
> > >  drivers/platform/x86/intel-vbtn.c | 16 ++++++++++++++--
> > >  1 file changed, 14 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> > > index 06cd7e818ed5..a0d0cecff55f 100644
> > > --- a/drivers/platform/x86/intel-vbtn.c
> > > +++ b/drivers/platform/x86/intel-vbtn.c
> > > @@ -76,12 +76,24 @@ static void notify_handler(acpi_handle handle, u32
> > event, void *context)
> > >         struct platform_device *device = context;
> > >         struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
> > >         unsigned int val = !(event & 1); /* Even=press, Odd=release */
> > > -       const struct key_entry *ke_rel;
> > > +       const struct key_entry *ke, *ke_rel;
> > >         bool autorelease;
> > >
> > >         if (priv->wakeup_mode) {
> > > -               if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
> > > +               ke = sparse_keymap_entry_from_scancode(priv->input_dev, event);
> > > +               if (ke) {
> > >                         pm_wakeup_hard_event(&device->dev);
> > > +
> > > +                       /*
> > > +                        * Switch events like tablet mode will wake the device
> > > +                        * and report the new switch position to the input
> > > +                        * subsystem.
> > > +                        */
> > Thanks for adding the comment; This looks good to me.
> >
> > > +                       if (ke->type == KE_SW)
> > > +                               sparse_keymap_report_event(priv->input_dev,
> > > +                                                          event,
> > > +                                                          val,
> > > +                                                          0);
> > >                         return;
> > >                 }
> > >                 goto out_unknown;
> > > --
> > > 2.21.0.1020.gf2820cf01a-goog
> > >
> >
> > Reviewed-by: Jett Rink <jettrink@chromium.org>
>
> Reviewed-by: Mario Limonciello <mario.limonciello@dell.com>



-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2019-05-24 16:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-20 22:41 [PATCH v2] platform/x86: intel-vbtn: Report switch events when event wakes device Mathew King
2019-05-21 13:37 ` Jett Rink
2019-05-21 13:42   ` Mario.Limonciello
2019-05-24 16:31     ` Andy Shevchenko

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).