All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Support tablet mode switch for Dell laptops
@ 2018-01-18 13:59 Marco Martin
  2018-01-18 15:13 ` Andy Shevchenko
  2018-01-18 15:44 ` Pali Rohár
  0 siblings, 2 replies; 14+ messages in thread
From: Marco Martin @ 2018-01-18 13:59 UTC (permalink / raw)
  To: linux-kernel
  Cc: mjg59, pali.rohar, dvhart, andy, bhush94, platform-driver-x86,
	Marco Martin

Dell laptops send events to intel-vbtn.c
0xCC when the laptop enters in tablet mode and
0xCD when the laptop goes out of it

This has been confirmed working on a Dell Inspiron 13-7352
and an Inspiron 13-7000

I'm not sure intel-vbtn is the right place for it, as it
should be dell-specific, but this is the only device driver
where those events arrive at all
also, it would need a way to query the initial state of the switch

CC:platform-driver-x86@vger.kernel.org
CC:Matthew Garrett <mjg59@srcf.ucam.org>
CC:"Pali Rohár" <pali.rohar@gmail.com>
CC:Darren Hart <dvhart@infradead.org>
CC:Andy Shevchenko <andy@infradead.org>

Signed-off-by: Marco Martin <notmart@gmail.com>
---
 drivers/platform/x86/intel-vbtn.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index 146d02f..1fa63e8 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -61,6 +61,10 @@ static int intel_vbtn_input_setup(struct platform_device *device)
 	priv->input_dev->name = "Intel Virtual Button driver";
 	priv->input_dev->id.bustype = BUS_HOST;
 
+	input_set_capability(priv->input_dev, EV_SW, SW_TABLET_MODE);
+	/*TODO: query initial state (and if the switch is present*/
+	input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
+
 	ret = input_register_device(priv->input_dev);
 	if (ret)
 		goto err_free_device;
@@ -84,7 +88,13 @@ 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);
 
-	if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
+	if (event == 0xCC) {
+		input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
+		input_sync(priv->input_dev);
+	} else if (event == 0xCD) {
+		input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
+		input_sync(priv->input_dev);
+	} else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
 		dev_info(&device->dev, "unknown event index 0x%x\n",
 			 event);
 }
-- 
2.7.4

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-18 13:59 [PATCH] Support tablet mode switch for Dell laptops Marco Martin
@ 2018-01-18 15:13 ` Andy Shevchenko
  2018-01-18 15:23     ` Mario.Limonciello
  2018-01-18 15:44 ` Pali Rohár
  1 sibling, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2018-01-18 15:13 UTC (permalink / raw)
  To: Marco Martin, Mario Limonciello
  Cc: Linux Kernel Mailing List, Matthew Garrett, Pali Rohár,
	Darren Hart, Andy Shevchenko, bhush94, Platform Driver

On Thu, Jan 18, 2018 at 3:59 PM, Marco Martin <notmart@gmail.com> wrote:
> Dell laptops send events to intel-vbtn.c
> 0xCC when the laptop enters in tablet mode and
> 0xCD when the laptop goes out of it
>
> This has been confirmed working on a Dell Inspiron 13-7352
> and an Inspiron 13-7000
>
> I'm not sure intel-vbtn is the right place for it, as it
> should be dell-specific, but this is the only device driver
> where those events arrive at all
> also, it would need a way to query the initial state of the switch

Yeah, to me sounds like a hack for now.
So, I would like to hear from everyone: Pali, Mario, Darren?

> CC:platform-driver-x86@vger.kernel.org
> CC:Matthew Garrett <mjg59@srcf.ucam.org>
> CC:"Pali Rohár" <pali.rohar@gmail.com>
> CC:Darren Hart <dvhart@infradead.org>
> CC:Andy Shevchenko <andy@infradead.org>
>
> Signed-off-by: Marco Martin <notmart@gmail.com>
> ---
>  drivers/platform/x86/intel-vbtn.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> index 146d02f..1fa63e8 100644
> --- a/drivers/platform/x86/intel-vbtn.c
> +++ b/drivers/platform/x86/intel-vbtn.c
> @@ -61,6 +61,10 @@ static int intel_vbtn_input_setup(struct platform_device *device)
>         priv->input_dev->name = "Intel Virtual Button driver";
>         priv->input_dev->id.bustype = BUS_HOST;
>
> +       input_set_capability(priv->input_dev, EV_SW, SW_TABLET_MODE);
> +       /*TODO: query initial state (and if the switch is present*/
> +       input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> +
>         ret = input_register_device(priv->input_dev);
>         if (ret)
>                 goto err_free_device;
> @@ -84,7 +88,13 @@ 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);
>
> -       if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> +       if (event == 0xCC) {
> +               input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
> +               input_sync(priv->input_dev);
> +       } else if (event == 0xCD) {
> +               input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> +               input_sync(priv->input_dev);
> +       } else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
>                 dev_info(&device->dev, "unknown event index 0x%x\n",
>                          event);
>  }
> --
> 2.7.4
>



-- 
With Best Regards,
Andy Shevchenko

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

* RE: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-18 15:13 ` Andy Shevchenko
@ 2018-01-18 15:23     ` Mario.Limonciello
  0 siblings, 0 replies; 14+ messages in thread
From: Mario.Limonciello @ 2018-01-18 15:23 UTC (permalink / raw)
  To: andy.shevchenko, notmart
  Cc: linux-kernel, mjg59, pali.rohar, dvhart, andy, bhush94,
	platform-driver-x86

> -----Original Message-----
> From: platform-driver-x86-owner@vger.kernel.org [mailto:platform-driver-x86-
> owner@vger.kernel.org] On Behalf Of Andy Shevchenko
> Sent: Thursday, January 18, 2018 9:13 AM
> To: Marco Martin <notmart@gmail.com>; Limonciello, Mario
> <Mario_Limonciello@Dell.com>
> Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; Matthew Garrett
> <mjg59@srcf.ucam.org>; Pali Rohár <pali.rohar@gmail.com>; Darren Hart
> <dvhart@infradead.org>; Andy Shevchenko <andy@infradead.org>;
> bhush94@gmail.com; Platform Driver <platform-driver-x86@vger.kernel.org>
> Subject: Re: [PATCH] Support tablet mode switch for Dell laptops
> 
> On Thu, Jan 18, 2018 at 3:59 PM, Marco Martin <notmart@gmail.com> wrote:
> > Dell laptops send events to intel-vbtn.c
> > 0xCC when the laptop enters in tablet mode and
> > 0xCD when the laptop goes out of it
> >
> > This has been confirmed working on a Dell Inspiron 13-7352
> > and an Inspiron 13-7000
> >
> > I'm not sure intel-vbtn is the right place for it, as it
> > should be dell-specific, but this is the only device driver
> > where those events arrive at all
> > also, it would need a way to query the initial state of the switch
> 
> Yeah, to me sounds like a hack for now.
> So, I would like to hear from everyone: Pali, Mario, Darren?

AFAIK we don't have a public specification for the ACPI interface
that intel-vbtn uses, it's all reverse engineered.

I think the appropriate thing to do would be open a kernel Bugzilla for your
issue and attach:
1) kernel log without your patch (do you get unknown event index?)
2) your DSDT there to review.

You can subscribe us to it.

Also you should subscribe Alex Hung, who has done lots of work on intel-vbtn
and intel-hid.

> 
> > CC:platform-driver-x86@vger.kernel.org
> > CC:Matthew Garrett <mjg59@srcf.ucam.org>
> > CC:"Pali Rohár" <pali.rohar@gmail.com>
> > CC:Darren Hart <dvhart@infradead.org>
> > CC:Andy Shevchenko <andy@infradead.org>
> >
> > Signed-off-by: Marco Martin <notmart@gmail.com>
> > ---
> >  drivers/platform/x86/intel-vbtn.c | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> > index 146d02f..1fa63e8 100644
> > --- a/drivers/platform/x86/intel-vbtn.c
> > +++ b/drivers/platform/x86/intel-vbtn.c
> > @@ -61,6 +61,10 @@ static int intel_vbtn_input_setup(struct platform_device
> *device)
> >         priv->input_dev->name = "Intel Virtual Button driver";
> >         priv->input_dev->id.bustype = BUS_HOST;
> >
> > +       input_set_capability(priv->input_dev, EV_SW, SW_TABLET_MODE);
> > +       /*TODO: query initial state (and if the switch is present*/
> > +       input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> > +
> >         ret = input_register_device(priv->input_dev);
> >         if (ret)
> >                 goto err_free_device;
> > @@ -84,7 +88,13 @@ 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);
> >
> > -       if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> > +       if (event == 0xCC) {
> > +               input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
> > +               input_sync(priv->input_dev);
> > +       } else if (event == 0xCD) {
> > +               input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> > +               input_sync(priv->input_dev);
> > +       } else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> >                 dev_info(&device->dev, "unknown event index 0x%x\n",
> >                          event);
> >  }
> > --
> > 2.7.4
> >
> 
> 
> 
> --
> With Best Regards,
> Andy Shevchenko

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

* RE: [PATCH] Support tablet mode switch for Dell laptops
@ 2018-01-18 15:23     ` Mario.Limonciello
  0 siblings, 0 replies; 14+ messages in thread
From: Mario.Limonciello @ 2018-01-18 15:23 UTC (permalink / raw)
  To: andy.shevchenko, notmart
  Cc: linux-kernel, mjg59, pali.rohar, dvhart, andy, bhush94,
	platform-driver-x86

> -----Original Message-----
> From: platform-driver-x86-owner@vger.kernel.org [mailto:platform-driver-x86-
> owner@vger.kernel.org] On Behalf Of Andy Shevchenko
> Sent: Thursday, January 18, 2018 9:13 AM
> To: Marco Martin <notmart@gmail.com>; Limonciello, Mario
> <Mario_Limonciello@Dell.com>
> Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; Matthew Garrett
> <mjg59@srcf.ucam.org>; Pali Rohár <pali.rohar@gmail.com>; Darren Hart
> <dvhart@infradead.org>; Andy Shevchenko <andy@infradead.org>;
> bhush94@gmail.com; Platform Driver <platform-driver-x86@vger.kernel.org>
> Subject: Re: [PATCH] Support tablet mode switch for Dell laptops
> 
> On Thu, Jan 18, 2018 at 3:59 PM, Marco Martin <notmart@gmail.com> wrote:
> > Dell laptops send events to intel-vbtn.c
> > 0xCC when the laptop enters in tablet mode and
> > 0xCD when the laptop goes out of it
> >
> > This has been confirmed working on a Dell Inspiron 13-7352
> > and an Inspiron 13-7000
> >
> > I'm not sure intel-vbtn is the right place for it, as it
> > should be dell-specific, but this is the only device driver
> > where those events arrive at all
> > also, it would need a way to query the initial state of the switch
> 
> Yeah, to me sounds like a hack for now.
> So, I would like to hear from everyone: Pali, Mario, Darren?

AFAIK we don't have a public specification for the ACPI interface
that intel-vbtn uses, it's all reverse engineered.

I think the appropriate thing to do would be open a kernel Bugzilla for your
issue and attach:
1) kernel log without your patch (do you get unknown event index?)
2) your DSDT there to review.

You can subscribe us to it.

Also you should subscribe Alex Hung, who has done lots of work on intel-vbtn
and intel-hid.

> 
> > CC:platform-driver-x86@vger.kernel.org
> > CC:Matthew Garrett <mjg59@srcf.ucam.org>
> > CC:"Pali Rohár" <pali.rohar@gmail.com>
> > CC:Darren Hart <dvhart@infradead.org>
> > CC:Andy Shevchenko <andy@infradead.org>
> >
> > Signed-off-by: Marco Martin <notmart@gmail.com>
> > ---
> >  drivers/platform/x86/intel-vbtn.c | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
> > index 146d02f..1fa63e8 100644
> > --- a/drivers/platform/x86/intel-vbtn.c
> > +++ b/drivers/platform/x86/intel-vbtn.c
> > @@ -61,6 +61,10 @@ static int intel_vbtn_input_setup(struct platform_device
> *device)
> >         priv->input_dev->name = "Intel Virtual Button driver";
> >         priv->input_dev->id.bustype = BUS_HOST;
> >
> > +       input_set_capability(priv->input_dev, EV_SW, SW_TABLET_MODE);
> > +       /*TODO: query initial state (and if the switch is present*/
> > +       input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> > +
> >         ret = input_register_device(priv->input_dev);
> >         if (ret)
> >                 goto err_free_device;
> > @@ -84,7 +88,13 @@ 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);
> >
> > -       if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> > +       if (event == 0xCC) {
> > +               input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
> > +               input_sync(priv->input_dev);
> > +       } else if (event == 0xCD) {
> > +               input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> > +               input_sync(priv->input_dev);
> > +       } else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> >                 dev_info(&device->dev, "unknown event index 0x%x\n",
> >                          event);
> >  }
> > --
> > 2.7.4
> >
> 
> 
> 
> --
> With Best Regards,
> Andy Shevchenko

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-18 13:59 [PATCH] Support tablet mode switch for Dell laptops Marco Martin
  2018-01-18 15:13 ` Andy Shevchenko
@ 2018-01-18 15:44 ` Pali Rohár
  2018-01-19 16:01   ` Pali Rohár
  1 sibling, 1 reply; 14+ messages in thread
From: Pali Rohár @ 2018-01-18 15:44 UTC (permalink / raw)
  To: Marco Martin
  Cc: linux-kernel, mjg59, dvhart, andy, bhush94, platform-driver-x86

On Thursday 18 January 2018 14:59:50 Marco Martin wrote:
> -	if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> +	if (event == 0xCC) {
> +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
> +		input_sync(priv->input_dev);
> +	} else if (event == 0xCD) {
> +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> +		input_sync(priv->input_dev);
> +	} else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))

Is not it possible to put 0xCC and 0xCD into sparse keymap table?
Because IIRC sparse keymap was created just to avoid that big
if-elseif-elseif-else blocks.

>  		dev_info(&device->dev, "unknown event index 0x%x\n",
>  			 event);
>  }

-- 
Pali Rohár
pali.rohar@gmail.com

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-18 15:23     ` Mario.Limonciello
  (?)
@ 2018-01-18 15:59     ` Marco Martin
  -1 siblings, 0 replies; 14+ messages in thread
From: Marco Martin @ 2018-01-18 15:59 UTC (permalink / raw)
  To: Mario.Limonciello
  Cc: andy.shevchenko, linux-kernel, Matthew Garrett, pali.rohar,
	dvhart, andy, Bhushan Shah, platform-driver-x86

On Thu, Jan 18, 2018 at 4:23 PM,  <Mario.Limonciello@dell.com> wrote:
> AFAIK we don't have a public specification for the ACPI interface
> that intel-vbtn uses, it's all reverse engineered.
>
> I think the appropriate thing to do would be open a kernel Bugzilla for your
> issue and attach:
> 1) kernel log without your patch (do you get unknown event index?)
> 2) your DSDT there to review.
>
> You can subscribe us to it.

done at
https://bugzilla.kernel.org/show_bug.cgi?id=198507

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-18 15:44 ` Pali Rohár
@ 2018-01-19 16:01   ` Pali Rohár
  2018-01-19 16:09       ` Mario.Limonciello
  0 siblings, 1 reply; 14+ messages in thread
From: Pali Rohár @ 2018-01-19 16:01 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-kernel, mjg59, dvhart, andy, bhush94, platform-driver-x86,
	Marco Martin

On Thursday 18 January 2018 16:44:08 Pali Rohár wrote:
> On Thursday 18 January 2018 14:59:50 Marco Martin wrote:
> > -	if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> > +	if (event == 0xCC) {
> > +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
> > +		input_sync(priv->input_dev);
> > +	} else if (event == 0xCD) {
> > +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> > +		input_sync(priv->input_dev);
> > +	} else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> 
> Is not it possible to put 0xCC and 0xCD into sparse keymap table?
> Because IIRC sparse keymap was created just to avoid that big
> if-elseif-elseif-else blocks.

Dmitry, can you comment above part? I think that there should be better
way how to handle above switches and sparse keymap via one input device.

> >  		dev_info(&device->dev, "unknown event index 0x%x\n",
> >  			 event);
> >  }
> 

-- 
Pali Rohár
pali.rohar@gmail.com

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

* RE: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-19 16:01   ` Pali Rohár
@ 2018-01-19 16:09       ` Mario.Limonciello
  0 siblings, 0 replies; 14+ messages in thread
From: Mario.Limonciello @ 2018-01-19 16:09 UTC (permalink / raw)
  To: pali.rohar, dmitry.torokhov
  Cc: linux-kernel, mjg59, dvhart, andy, bhush94, platform-driver-x86, notmart

> -----Original Message-----
> From: platform-driver-x86-owner@vger.kernel.org [mailto:platform-driver-x86-
> owner@vger.kernel.org] On Behalf Of Pali Rohár
> Sent: Friday, January 19, 2018 10:01 AM
> To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-kernel@vger.kernel.org; mjg59@srcf.ucam.org; dvhart@infradead.org;
> andy@infradead.org; bhush94@gmail.com; platform-driver-x86@vger.kernel.org;
> Marco Martin <notmart@gmail.com>
> Subject: Re: [PATCH] Support tablet mode switch for Dell laptops
> 
> On Thursday 18 January 2018 16:44:08 Pali Rohár wrote:
> > On Thursday 18 January 2018 14:59:50 Marco Martin wrote:
> > > -	if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> > > +	if (event == 0xCC) {
> > > +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
> > > +		input_sync(priv->input_dev);
> > > +	} else if (event == 0xCD) {
> > > +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> > > +		input_sync(priv->input_dev);
> > > +	} else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> >
> > Is not it possible to put 0xCC and 0xCD into sparse keymap table?
> > Because IIRC sparse keymap was created just to avoid that big
> > if-elseif-elseif-else blocks.
> 
> Dmitry, can you comment above part? I think that there should be better
> way how to handle above switches and sparse keymap via one input device.
> 
> > >  		dev_info(&device->dev, "unknown event index 0x%x\n",
> > >  			 event);
> > >  }
> >
> 
> --
> Pali Rohár
> pali.rohar@gmail.com

We discussed a little more on the bug he filed with attached DSDT.  I think that in 
sparse keymap he can use KE_VSW for the entries and sparse keymap can handle.

Assuming that works I'm expecting him to resubmit soon with that and some other
changes I recommended on the bug.

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

* RE: [PATCH] Support tablet mode switch for Dell laptops
@ 2018-01-19 16:09       ` Mario.Limonciello
  0 siblings, 0 replies; 14+ messages in thread
From: Mario.Limonciello @ 2018-01-19 16:09 UTC (permalink / raw)
  To: pali.rohar, dmitry.torokhov
  Cc: linux-kernel, mjg59, dvhart, andy, bhush94, platform-driver-x86, notmart

> -----Original Message-----
> From: platform-driver-x86-owner@vger.kernel.org [mailto:platform-driver-x86-
> owner@vger.kernel.org] On Behalf Of Pali Rohár
> Sent: Friday, January 19, 2018 10:01 AM
> To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-kernel@vger.kernel.org; mjg59@srcf.ucam.org; dvhart@infradead.org;
> andy@infradead.org; bhush94@gmail.com; platform-driver-x86@vger.kernel.org;
> Marco Martin <notmart@gmail.com>
> Subject: Re: [PATCH] Support tablet mode switch for Dell laptops
> 
> On Thursday 18 January 2018 16:44:08 Pali Rohár wrote:
> > On Thursday 18 January 2018 14:59:50 Marco Martin wrote:
> > > -	if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> > > +	if (event == 0xCC) {
> > > +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
> > > +		input_sync(priv->input_dev);
> > > +	} else if (event == 0xCD) {
> > > +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> > > +		input_sync(priv->input_dev);
> > > +	} else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> >
> > Is not it possible to put 0xCC and 0xCD into sparse keymap table?
> > Because IIRC sparse keymap was created just to avoid that big
> > if-elseif-elseif-else blocks.
> 
> Dmitry, can you comment above part? I think that there should be better
> way how to handle above switches and sparse keymap via one input device.
> 
> > >  		dev_info(&device->dev, "unknown event index 0x%x\n",
> > >  			 event);
> > >  }
> >
> 
> --
> Pali Rohár
> pali.rohar@gmail.com

We discussed a little more on the bug he filed with attached DSDT.  I think that in 
sparse keymap he can use KE_VSW for the entries and sparse keymap can handle.

Assuming that works I'm expecting him to resubmit soon with that and some other
changes I recommended on the bug.

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-19 16:09       ` Mario.Limonciello
  (?)
@ 2018-01-19 17:29       ` Dmitry Torokhov
  2018-01-22 11:59           ` Marco Martin
  -1 siblings, 1 reply; 14+ messages in thread
From: Dmitry Torokhov @ 2018-01-19 17:29 UTC (permalink / raw)
  To: Mario.Limonciello
  Cc: pali.rohar, linux-kernel, mjg59, dvhart, andy, bhush94,
	platform-driver-x86, notmart

On Fri, Jan 19, 2018 at 04:09:09PM +0000, Mario.Limonciello@dell.com wrote:
> > -----Original Message-----
> > From: platform-driver-x86-owner@vger.kernel.org [mailto:platform-driver-x86-
> > owner@vger.kernel.org] On Behalf Of Pali Rohár
> > Sent: Friday, January 19, 2018 10:01 AM
> > To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: linux-kernel@vger.kernel.org; mjg59@srcf.ucam.org; dvhart@infradead.org;
> > andy@infradead.org; bhush94@gmail.com; platform-driver-x86@vger.kernel.org;
> > Marco Martin <notmart@gmail.com>
> > Subject: Re: [PATCH] Support tablet mode switch for Dell laptops
> > 
> > On Thursday 18 January 2018 16:44:08 Pali Rohár wrote:
> > > On Thursday 18 January 2018 14:59:50 Marco Martin wrote:
> > > > -	if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> > > > +	if (event == 0xCC) {
> > > > +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 1);
> > > > +		input_sync(priv->input_dev);
> > > > +	} else if (event == 0xCD) {
> > > > +		input_report_switch(priv->input_dev, SW_TABLET_MODE, 0);
> > > > +		input_sync(priv->input_dev);
> > > > +	} else if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
> > >
> > > Is not it possible to put 0xCC and 0xCD into sparse keymap table?
> > > Because IIRC sparse keymap was created just to avoid that big
> > > if-elseif-elseif-else blocks.
> > 
> > Dmitry, can you comment above part? I think that there should be better
> > way how to handle above switches and sparse keymap via one input device.
> > 
> > > >  		dev_info(&device->dev, "unknown event index 0x%x\n",
> > > >  			 event);
> > > >  }
> > >
> > 
> > --
> > Pali Rohár
> > pali.rohar@gmail.com
> 
> We discussed a little more on the bug he filed with attached DSDT.  I think that in 
> sparse keymap he can use KE_VSW for the entries and sparse keymap can handle.

No it should be KE_SW I believe, as the "keycode" encodes the state.
See example in intel-hid.c.

So you probably want:

	...
	{ KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Press */
	{ KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Release */

Thanks.

-- 
Dmitry

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-19 17:29       ` Dmitry Torokhov
@ 2018-01-22 11:59           ` Marco Martin
  0 siblings, 0 replies; 14+ messages in thread
From: Marco Martin @ 2018-01-22 11:59 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mario.Limonciello, pali.rohar, linux-kernel, Matthew Garrett,
	dvhart, andy, Bhushan Shah, platform-driver-x86

On Fri, Jan 19, 2018 at 6:29 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>> We discussed a little more on the bug he filed with attached DSDT.  I think that in
>> sparse keymap he can use KE_VSW for the entries and sparse keymap can handle.
>
> No it should be KE_SW I believe, as the "keycode" encodes the state.
> See example in intel-hid.c.
>
> So you probably want:
>
>         ...
>         { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Press */
>         { KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Release */
>
> Thanks.

If I add those lines to intel_vbtn_keymap and remove the two special
cases for 0xCC and 0xCD, it does work, but only if I explicitly call
input_sync(priv->input_dev) after sparse_keymap_report_event()
otherwise i don't get the event (cheching for instance with evtest)
until a sync gets called (i tried to put the sync only for 0xcd and in
that case i get both 0xcc and 0xcd when i go out of tablet mode)
--
Marco Martin

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
@ 2018-01-22 11:59           ` Marco Martin
  0 siblings, 0 replies; 14+ messages in thread
From: Marco Martin @ 2018-01-22 11:59 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mario.Limonciello, pali.rohar, linux-kernel, Matthew Garrett,
	dvhart, andy, Bhushan Shah, platform-driver-x86

On Fri, Jan 19, 2018 at 6:29 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>> We discussed a little more on the bug he filed with attached DSDT.  I think that in
>> sparse keymap he can use KE_VSW for the entries and sparse keymap can handle.
>
> No it should be KE_SW I believe, as the "keycode" encodes the state.
> See example in intel-hid.c.
>
> So you probably want:
>
>         ...
>         { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Press */
>         { KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Release */
>
> Thanks.

If I add those lines to intel_vbtn_keymap and remove the two special
cases for 0xCC and 0xCD, it does work, but only if I explicitly call
input_sync(priv->input_dev) after sparse_keymap_report_event()
otherwise i don't get the event (cheching for instance with evtest)
until a sync gets called (i tried to put the sync only for 0xcd and in
that case i get both 0xcc and 0xcd when i go out of tablet mode)

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
  2018-01-22 11:59           ` Marco Martin
@ 2018-01-22 12:50             ` Marco Martin
  -1 siblings, 0 replies; 14+ messages in thread
From: Marco Martin @ 2018-01-22 12:50 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mario.Limonciello, pali.rohar, linux-kernel, Matthew Garrett,
	dvhart, andy, Bhushan Shah, platform-driver-x86

On Mon, Jan 22, 2018 at 12:59 PM, Marco Martin <notmart@gmail.com> wrote:
> On Fri, Jan 19, 2018 at 6:29 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>>> We discussed a little more on the bug he filed with attached DSDT.  I think that in
>>> sparse keymap he can use KE_VSW for the entries and sparse keymap can handle.
>>
>> No it should be KE_SW I believe, as the "keycode" encodes the state.
>> See example in intel-hid.c.
>>
>> So you probably want:
>>
>>         ...
>>         { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Press */
>>         { KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Release */
>>
>> Thanks.
>
> If I add those lines to intel_vbtn_keymap and remove the two special
> cases for 0xCC and 0xCD, it does work, but only if I explicitly call
> input_sync(priv->input_dev) after sparse_keymap_report_event()
> otherwise i don't get the event (cheching for instance with evtest)
> until a sync gets called (i tried to put the sync only for 0xcd and in
> that case i get both 0xcc and 0xcd when i go out of tablet mode)

with the caveat of an input_sync every event, new patch as a new
thread with Mario's
 and Dmitry's suggestions integrated in, and formatted to conform
checkpatch controls

--
Marco Martin

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

* Re: [PATCH] Support tablet mode switch for Dell laptops
@ 2018-01-22 12:50             ` Marco Martin
  0 siblings, 0 replies; 14+ messages in thread
From: Marco Martin @ 2018-01-22 12:50 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mario.Limonciello, pali.rohar, linux-kernel, Matthew Garrett,
	dvhart, andy, Bhushan Shah, platform-driver-x86

On Mon, Jan 22, 2018 at 12:59 PM, Marco Martin <notmart@gmail.com> wrote:
> On Fri, Jan 19, 2018 at 6:29 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>>> We discussed a little more on the bug he filed with attached DSDT.  I think that in
>>> sparse keymap he can use KE_VSW for the entries and sparse keymap can handle.
>>
>> No it should be KE_SW I believe, as the "keycode" encodes the state.
>> See example in intel-hid.c.
>>
>> So you probably want:
>>
>>         ...
>>         { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Press */
>>         { KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Release */
>>
>> Thanks.
>
> If I add those lines to intel_vbtn_keymap and remove the two special
> cases for 0xCC and 0xCD, it does work, but only if I explicitly call
> input_sync(priv->input_dev) after sparse_keymap_report_event()
> otherwise i don't get the event (cheching for instance with evtest)
> until a sync gets called (i tried to put the sync only for 0xcd and in
> that case i get both 0xcc and 0xcd when i go out of tablet mode)

with the caveat of an input_sync every event, new patch as a new
thread with Mario's
 and Dmitry's suggestions integrated in, and formatted to conform
checkpatch controls

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

end of thread, other threads:[~2018-01-22 12:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 13:59 [PATCH] Support tablet mode switch for Dell laptops Marco Martin
2018-01-18 15:13 ` Andy Shevchenko
2018-01-18 15:23   ` Mario.Limonciello
2018-01-18 15:23     ` Mario.Limonciello
2018-01-18 15:59     ` Marco Martin
2018-01-18 15:44 ` Pali Rohár
2018-01-19 16:01   ` Pali Rohár
2018-01-19 16:09     ` Mario.Limonciello
2018-01-19 16:09       ` Mario.Limonciello
2018-01-19 17:29       ` Dmitry Torokhov
2018-01-22 11:59         ` Marco Martin
2018-01-22 11:59           ` Marco Martin
2018-01-22 12:50           ` Marco Martin
2018-01-22 12:50             ` Marco Martin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.