iio: accel: bmc150: Add support for DUAL250E ACPI DSM for setting the hinge angle
authorHans de Goede <hdegoede@redhat.com>
Sun, 23 May 2021 17:01:01 +0000 (19:01 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 9 Jun 2021 19:53:15 +0000 (20:53 +0100)
commitaddab6febc42ed94e4eee1abbe486150e4f8b9e9
tree48c2dacf1baa4e9dbc7a67586aed91e603924682
parent35157f443b6f4537b03ea1752bd96fbb28ec7a4f
iio: accel: bmc150: Add support for DUAL250E ACPI DSM for setting the hinge angle

Some 360 degree hinges (yoga) style 2-in-1 devices use 2 bmc150 accels
to allow the OS to determine the angle between the display and the base
of the device, so that the OS can determine if the 2-in-1 is in laptop
or in tablet-mode.

On Windows both accelerometers are read (polled) by a special service
and this service calls the DSM (Device Specific Method), which in turn
translates the angles to one of laptop/tablet/tent/stand mode and then
notifies the EC about the new mode and the EC then enables or disables
the builtin keyboard and touchpad based in the mode.

When the 2-in-1 is powered-on or resumed folded in tablet mode the
EC senses this independent of the DSM by using a HALL effect sensor
which senses that the keyboard has been folded away behind the display.

At power-on or resume the EC disables the keyboard based on this and
the only way to get the keyboard to work after this is to call the
DSM to re-enable it.

Call the DSM on probe() and resume() to fix the keyboard not working
when powered-on / resumed in tablet-mode.

This patch was developed and tested on a Lenovo Yoga 300-IBR.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210523170103.176958-8-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/bmc150-accel-core.c
drivers/iio/accel/bmc150-accel-i2c.c
drivers/iio/accel/bmc150-accel.h