Skip to content

Commit e5b1032

Browse files
jwrdegoedejic23
authored andcommitted
iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode
Some 360 degree hinges (yoga) style 2-in-1 devices use 2 KXCJ91008-s 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 by a special HingeAngleService process; and this process calls a DSM (Device Specific Method) on the ACPI KIOX010A device node for the sensor in the display, to let the embedded-controller (EC) know about the mode so that it can disable the kbd and touchpad to avoid spurious input while folded into tablet-mode. This notifying of the EC is problematic because sometimes the EC comes up thinking that device is in tablet-mode and the kbd and touchpad do not work. This happens for example on Irbis NB111 devices after a suspend / resume cycle (after a complete battery drain / hard reset without having booted Windows at least once). Other 2-in-1s which are likely affected too are e.g. the Teclast F5 and F6 series. The kxcjk-1013 driver may seem like a strange place to deal with this, but since it is *the* driver for the ACPI KIOX010A device, it is also the driver which has access to the ACPI handle needed by the DSM. Add support for calling the DSM and on probe unconditionally tell the EC that the device is laptop mode, fixing the kbd and touchpad sometimes not working. Fixes: 7f6232e ("iio: accel: kxcjk1013: Add KIOX010A ACPI Hardware-ID") Reported-and-tested-by: russianneuromancer <russianneuromancer@ya.ru> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/20201110133835.129080-3-hdegoede@redhat.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 11e94f2 commit e5b1032

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

drivers/iio/accel/kxcjk-1013.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ enum kx_chipset {
129129
enum kx_acpi_type {
130130
ACPI_GENERIC,
131131
ACPI_SMO8500,
132+
ACPI_KIOX010A,
132133
};
133134

134135
struct kxcjk1013_data {
@@ -275,6 +276,32 @@ static const struct {
275276
{19163, 1, 0},
276277
{38326, 0, 1} };
277278

279+
#ifdef CONFIG_ACPI
280+
enum kiox010a_fn_index {
281+
KIOX010A_SET_LAPTOP_MODE = 1,
282+
KIOX010A_SET_TABLET_MODE = 2,
283+
};
284+
285+
static int kiox010a_dsm(struct device *dev, int fn_index)
286+
{
287+
acpi_handle handle = ACPI_HANDLE(dev);
288+
guid_t kiox010a_dsm_guid;
289+
union acpi_object *obj;
290+
291+
if (!handle)
292+
return -ENODEV;
293+
294+
guid_parse("1f339696-d475-4e26-8cad-2e9f8e6d7a91", &kiox010a_dsm_guid);
295+
296+
obj = acpi_evaluate_dsm(handle, &kiox010a_dsm_guid, 1, fn_index, NULL);
297+
if (!obj)
298+
return -EIO;
299+
300+
ACPI_FREE(obj);
301+
return 0;
302+
}
303+
#endif
304+
278305
static int kxcjk1013_set_mode(struct kxcjk1013_data *data,
279306
enum kxcjk1013_mode mode)
280307
{
@@ -352,6 +379,13 @@ static int kxcjk1013_chip_init(struct kxcjk1013_data *data)
352379
{
353380
int ret;
354381

382+
#ifdef CONFIG_ACPI
383+
if (data->acpi_type == ACPI_KIOX010A) {
384+
/* Make sure the kbd and touchpad on 2-in-1s using 2 KXCJ91008-s work */
385+
kiox010a_dsm(&data->client->dev, KIOX010A_SET_LAPTOP_MODE);
386+
}
387+
#endif
388+
355389
ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_WHO_AM_I);
356390
if (ret < 0) {
357391
dev_err(&data->client->dev, "Error reading who_am_i\n");
@@ -1262,6 +1296,8 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev,
12621296

12631297
if (strcmp(id->id, "SMO8500") == 0)
12641298
*acpi_type = ACPI_SMO8500;
1299+
else if (strcmp(id->id, "KIOX010A") == 0)
1300+
*acpi_type = ACPI_KIOX010A;
12651301

12661302
*chipset = (enum kx_chipset)id->driver_data;
12671303

0 commit comments

Comments
 (0)