RE: [PATCH] Support tablet mode switch for Dell laptops

From: Mario.Limonciello
Date: Thu Jan 18 2018 - 10:23:36 EST


> -----Original Message-----
> From: platform-driver-x86-owner@xxxxxxxxxxxxxxx [mailto:platform-driver-x86-
> owner@xxxxxxxxxxxxxxx] On Behalf Of Andy Shevchenko
> Sent: Thursday, January 18, 2018 9:13 AM
> To: Marco Martin <notmart@xxxxxxxxx>; Limonciello, Mario
> <Mario_Limonciello@xxxxxxxx>
> Cc: Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>; Matthew Garrett
> <mjg59@xxxxxxxxxxxxx>; Pali RohÃr <pali.rohar@xxxxxxxxx>; Darren Hart
> <dvhart@xxxxxxxxxxxxx>; Andy Shevchenko <andy@xxxxxxxxxxxxx>;
> bhush94@xxxxxxxxx; Platform Driver <platform-driver-x86@xxxxxxxxxxxxxxx>
> Subject: Re: [PATCH] Support tablet mode switch for Dell laptops
>
> On Thu, Jan 18, 2018 at 3:59 PM, Marco Martin <notmart@xxxxxxxxx> 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@xxxxxxxxxxxxxxx
> > CC:Matthew Garrett <mjg59@xxxxxxxxxxxxx>
> > CC:"Pali RohÃr" <pali.rohar@xxxxxxxxx>
> > CC:Darren Hart <dvhart@xxxxxxxxxxxxx>
> > CC:Andy Shevchenko <andy@xxxxxxxxxxxxx>
> >
> > Signed-off-by: Marco Martin <notmart@xxxxxxxxx>
> > ---
> > 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