linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bugfix for 5.10 0/2] iio: accel: kxcjk1013: Fix kbd/touchpad not working on some 2-in-1s
@ 2020-11-10 13:38 Hans de Goede
  2020-11-10 13:38 ` [PATCH bugfix for 5.10 1/2] iio: accel: kxcjk1013: Replace is_smo8500_device with an acpi_type enum Hans de Goede
  2020-11-10 13:38 ` [PATCH bugfix for 5.10 2/2] iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode Hans de Goede
  0 siblings, 2 replies; 6+ messages in thread
From: Hans de Goede @ 2020-11-10 13:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hans de Goede, Lars-Peter Clausen, Peter Meerwald-Stadler,
	russianneuromancer @ ya . ru, linux-iio

Hi All,

This series fixes a somewhat special bug where sometimes the
kbd/touchpad do not work on certain 2-in-1s with 360 degree
(yoga) hinges, which use 2 accelerometers to allow figuring out the
angle between the display and the base.

The display accelerometer ACPI device / fwnode has a special ACPI
method which allows suppressing kbd + touchpads events when folded
into tablet-mode and sometimes the event suppression gets enabled
by default, this series calls the ACPI method at probe time to
disable the suppression, fixing the kbd/touchpad not working.

A web-search shows various reports about this issue in forums and such,
so it would be good if we can get these 2 patches added to a 5.10-rc#
as a bugfix, as I indicated in the Subject prefix.

Regards,

Hans


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

* [PATCH bugfix for 5.10 1/2] iio: accel: kxcjk1013: Replace is_smo8500_device with an acpi_type enum
  2020-11-10 13:38 [PATCH bugfix for 5.10 0/2] iio: accel: kxcjk1013: Fix kbd/touchpad not working on some 2-in-1s Hans de Goede
@ 2020-11-10 13:38 ` Hans de Goede
  2020-11-10 13:38 ` [PATCH bugfix for 5.10 2/2] iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode Hans de Goede
  1 sibling, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2020-11-10 13:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hans de Goede, Lars-Peter Clausen, Peter Meerwald-Stadler,
	russianneuromancer @ ya . ru, linux-iio

Replace the boolean is_smo8500_device variable with an acpi_type enum.

For now this can be either ACPI_GENERIC or ACPI_SMO8500, this is a
preparation patch for adding special handling for the KIOX010A ACPI HID,
which will add a ACPI_KIOX010A acpi_type to the introduced enum.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/kxcjk-1013.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index beb38d9d607d..abeb0d254046 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -126,6 +126,11 @@ enum kx_chipset {
 	KX_MAX_CHIPS /* this must be last */
 };
 
+enum kx_acpi_type {
+	ACPI_GENERIC,
+	ACPI_SMO8500,
+};
+
 struct kxcjk1013_data {
 	struct i2c_client *client;
 	struct iio_trigger *dready_trig;
@@ -143,7 +148,7 @@ struct kxcjk1013_data {
 	bool motion_trigger_on;
 	int64_t timestamp;
 	enum kx_chipset chipset;
-	bool is_smo8500_device;
+	enum kx_acpi_type acpi_type;
 };
 
 enum kxcjk1013_axis {
@@ -1247,7 +1252,7 @@ static irqreturn_t kxcjk1013_data_rdy_trig_poll(int irq, void *private)
 
 static const char *kxcjk1013_match_acpi_device(struct device *dev,
 					       enum kx_chipset *chipset,
-					       bool *is_smo8500_device)
+					       enum kx_acpi_type *acpi_type)
 {
 	const struct acpi_device_id *id;
 
@@ -1256,7 +1261,7 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev,
 		return NULL;
 
 	if (strcmp(id->id, "SMO8500") == 0)
-		*is_smo8500_device = true;
+		*acpi_type = ACPI_SMO8500;
 
 	*chipset = (enum kx_chipset)id->driver_data;
 
@@ -1299,7 +1304,7 @@ static int kxcjk1013_probe(struct i2c_client *client,
 	} else if (ACPI_HANDLE(&client->dev)) {
 		name = kxcjk1013_match_acpi_device(&client->dev,
 						   &data->chipset,
-						   &data->is_smo8500_device);
+						   &data->acpi_type);
 	} else
 		return -ENODEV;
 
@@ -1316,7 +1321,7 @@ static int kxcjk1013_probe(struct i2c_client *client,
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->info = &kxcjk1013_info;
 
-	if (client->irq > 0 && !data->is_smo8500_device) {
+	if (client->irq > 0 && data->acpi_type != ACPI_SMO8500) {
 		ret = devm_request_threaded_irq(&client->dev, client->irq,
 						kxcjk1013_data_rdy_trig_poll,
 						kxcjk1013_event_handler,
-- 
2.28.0


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

* [PATCH bugfix for 5.10 2/2] iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode
  2020-11-10 13:38 [PATCH bugfix for 5.10 0/2] iio: accel: kxcjk1013: Fix kbd/touchpad not working on some 2-in-1s Hans de Goede
  2020-11-10 13:38 ` [PATCH bugfix for 5.10 1/2] iio: accel: kxcjk1013: Replace is_smo8500_device with an acpi_type enum Hans de Goede
@ 2020-11-10 13:38 ` Hans de Goede
  2020-11-14 16:01   ` Jonathan Cameron
  1 sibling, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-11-10 13:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hans de Goede, Lars-Peter Clausen, Peter Meerwald-Stadler,
	russianneuromancer @ ya . ru, linux-iio

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.

Reported-and-tested-by: russianneuromancer <russianneuromancer@ya.ru>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/kxcjk-1013.c | 36 ++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index abeb0d254046..560a3373ff20 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -129,6 +129,7 @@ enum kx_chipset {
 enum kx_acpi_type {
 	ACPI_GENERIC,
 	ACPI_SMO8500,
+	ACPI_KIOX010A,
 };
 
 struct kxcjk1013_data {
@@ -275,6 +276,32 @@ static const struct {
 			      {19163, 1, 0},
 			      {38326, 0, 1} };
 
+#ifdef CONFIG_ACPI
+enum kiox010a_fn_index {
+	KIOX010A_SET_LAPTOP_MODE = 1,
+	KIOX010A_SET_TABLET_MODE = 2,
+};
+
+static int kiox010a_dsm(struct device *dev, int fn_index)
+{
+	acpi_handle handle = ACPI_HANDLE(dev);
+	guid_t kiox010a_dsm_guid;
+	union acpi_object *obj;
+
+	if (!handle)
+		return -ENODEV;
+
+	guid_parse("1f339696-d475-4e26-8cad-2e9f8e6d7a91", &kiox010a_dsm_guid);
+
+	obj = acpi_evaluate_dsm(handle, &kiox010a_dsm_guid, 1, fn_index, NULL);
+	if (!obj)
+		return -EIO;
+
+	ACPI_FREE(obj);
+	return 0;
+}
+#endif
+
 static int kxcjk1013_set_mode(struct kxcjk1013_data *data,
 			      enum kxcjk1013_mode mode)
 {
@@ -352,6 +379,13 @@ static int kxcjk1013_chip_init(struct kxcjk1013_data *data)
 {
 	int ret;
 
+#ifdef CONFIG_ACPI
+	if (data->acpi_type == ACPI_KIOX010A) {
+		/* Make sure the kbd and touchpad on 2-in-1s using 2 KXCJ91008-s work */
+		kiox010a_dsm(&data->client->dev, KIOX010A_SET_LAPTOP_MODE);
+	}
+#endif
+
 	ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_WHO_AM_I);
 	if (ret < 0) {
 		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,
 
 	if (strcmp(id->id, "SMO8500") == 0)
 		*acpi_type = ACPI_SMO8500;
+	else if (strcmp(id->id, "KIOX010A") == 0)
+		*acpi_type = ACPI_KIOX010A;
 
 	*chipset = (enum kx_chipset)id->driver_data;
 
-- 
2.28.0


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

* Re: [PATCH bugfix for 5.10 2/2] iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode
  2020-11-10 13:38 ` [PATCH bugfix for 5.10 2/2] iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode Hans de Goede
@ 2020-11-14 16:01   ` Jonathan Cameron
  2020-11-14 17:07     ` Hans de Goede
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2020-11-14 16:01 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler,
	russianneuromancer @ ya . ru, linux-iio

On Tue, 10 Nov 2020 14:38:35 +0100
Hans de Goede <hdegoede@redhat.com> wrote:

> 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.
> 
> Reported-and-tested-by: russianneuromancer <russianneuromancer@ya.ru>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hi Hans,

*Mutters darkly about crazy firmware hacks*

I'm fine taking this but I assume we want to backport and for that I'm
after a fixes tag.

Thanks,

Jonathan
 
> ---
>  drivers/iio/accel/kxcjk-1013.c | 36 ++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> index abeb0d254046..560a3373ff20 100644
> --- a/drivers/iio/accel/kxcjk-1013.c
> +++ b/drivers/iio/accel/kxcjk-1013.c
> @@ -129,6 +129,7 @@ enum kx_chipset {
>  enum kx_acpi_type {
>  	ACPI_GENERIC,
>  	ACPI_SMO8500,
> +	ACPI_KIOX010A,
>  };
>  
>  struct kxcjk1013_data {
> @@ -275,6 +276,32 @@ static const struct {
>  			      {19163, 1, 0},
>  			      {38326, 0, 1} };
>  
> +#ifdef CONFIG_ACPI
> +enum kiox010a_fn_index {
> +	KIOX010A_SET_LAPTOP_MODE = 1,
> +	KIOX010A_SET_TABLET_MODE = 2,
> +};
> +
> +static int kiox010a_dsm(struct device *dev, int fn_index)
> +{
> +	acpi_handle handle = ACPI_HANDLE(dev);
> +	guid_t kiox010a_dsm_guid;
> +	union acpi_object *obj;
> +
> +	if (!handle)
> +		return -ENODEV;
> +
> +	guid_parse("1f339696-d475-4e26-8cad-2e9f8e6d7a91", &kiox010a_dsm_guid);
> +
> +	obj = acpi_evaluate_dsm(handle, &kiox010a_dsm_guid, 1, fn_index, NULL);
> +	if (!obj)
> +		return -EIO;
> +
> +	ACPI_FREE(obj);
> +	return 0;
> +}
> +#endif
> +
>  static int kxcjk1013_set_mode(struct kxcjk1013_data *data,
>  			      enum kxcjk1013_mode mode)
>  {
> @@ -352,6 +379,13 @@ static int kxcjk1013_chip_init(struct kxcjk1013_data *data)
>  {
>  	int ret;
>  
> +#ifdef CONFIG_ACPI
> +	if (data->acpi_type == ACPI_KIOX010A) {
> +		/* Make sure the kbd and touchpad on 2-in-1s using 2 KXCJ91008-s work */
> +		kiox010a_dsm(&data->client->dev, KIOX010A_SET_LAPTOP_MODE);
> +	}
> +#endif
> +
>  	ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_WHO_AM_I);
>  	if (ret < 0) {
>  		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,
>  
>  	if (strcmp(id->id, "SMO8500") == 0)
>  		*acpi_type = ACPI_SMO8500;
> +	else if (strcmp(id->id, "KIOX010A") == 0)
> +		*acpi_type = ACPI_KIOX010A;
>  
>  	*chipset = (enum kx_chipset)id->driver_data;
>  


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

* Re: [PATCH bugfix for 5.10 2/2] iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode
  2020-11-14 16:01   ` Jonathan Cameron
@ 2020-11-14 17:07     ` Hans de Goede
  2020-11-14 17:34       ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-11-14 17:07 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler,
	russianneuromancer @ ya . ru, linux-iio

Hi,

On 11/14/20 5:01 PM, Jonathan Cameron wrote:
> On Tue, 10 Nov 2020 14:38:35 +0100
> Hans de Goede <hdegoede@redhat.com> wrote:
> 
>> 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.
>>
>> Reported-and-tested-by: russianneuromancer <russianneuromancer@ya.ru>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Hi Hans,
> 
> *Mutters darkly about crazy firmware hacks*
> 
> I'm fine taking this but I assume we want to backport and for that I'm
> after a fixes tag.

Good point, I guess taking the commit which originally added the
KIOX010A ACPI Hardware-ID makes the most sense:

Fixes: 7f6232e69539 ("iio: accel: kxcjk1013: Add KIOX010A ACPI Hardware-ID")

Regards,

Hans



>> ---
>>  drivers/iio/accel/kxcjk-1013.c | 36 ++++++++++++++++++++++++++++++++++
>>  1 file changed, 36 insertions(+)
>>
>> diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
>> index abeb0d254046..560a3373ff20 100644
>> --- a/drivers/iio/accel/kxcjk-1013.c
>> +++ b/drivers/iio/accel/kxcjk-1013.c
>> @@ -129,6 +129,7 @@ enum kx_chipset {
>>  enum kx_acpi_type {
>>  	ACPI_GENERIC,
>>  	ACPI_SMO8500,
>> +	ACPI_KIOX010A,
>>  };
>>  
>>  struct kxcjk1013_data {
>> @@ -275,6 +276,32 @@ static const struct {
>>  			      {19163, 1, 0},
>>  			      {38326, 0, 1} };
>>  
>> +#ifdef CONFIG_ACPI
>> +enum kiox010a_fn_index {
>> +	KIOX010A_SET_LAPTOP_MODE = 1,
>> +	KIOX010A_SET_TABLET_MODE = 2,
>> +};
>> +
>> +static int kiox010a_dsm(struct device *dev, int fn_index)
>> +{
>> +	acpi_handle handle = ACPI_HANDLE(dev);
>> +	guid_t kiox010a_dsm_guid;
>> +	union acpi_object *obj;
>> +
>> +	if (!handle)
>> +		return -ENODEV;
>> +
>> +	guid_parse("1f339696-d475-4e26-8cad-2e9f8e6d7a91", &kiox010a_dsm_guid);
>> +
>> +	obj = acpi_evaluate_dsm(handle, &kiox010a_dsm_guid, 1, fn_index, NULL);
>> +	if (!obj)
>> +		return -EIO;
>> +
>> +	ACPI_FREE(obj);
>> +	return 0;
>> +}
>> +#endif
>> +
>>  static int kxcjk1013_set_mode(struct kxcjk1013_data *data,
>>  			      enum kxcjk1013_mode mode)
>>  {
>> @@ -352,6 +379,13 @@ static int kxcjk1013_chip_init(struct kxcjk1013_data *data)
>>  {
>>  	int ret;
>>  
>> +#ifdef CONFIG_ACPI
>> +	if (data->acpi_type == ACPI_KIOX010A) {
>> +		/* Make sure the kbd and touchpad on 2-in-1s using 2 KXCJ91008-s work */
>> +		kiox010a_dsm(&data->client->dev, KIOX010A_SET_LAPTOP_MODE);
>> +	}
>> +#endif
>> +
>>  	ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_WHO_AM_I);
>>  	if (ret < 0) {
>>  		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,
>>  
>>  	if (strcmp(id->id, "SMO8500") == 0)
>>  		*acpi_type = ACPI_SMO8500;
>> +	else if (strcmp(id->id, "KIOX010A") == 0)
>> +		*acpi_type = ACPI_KIOX010A;
>>  
>>  	*chipset = (enum kx_chipset)id->driver_data;
>>  
> 


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

* Re: [PATCH bugfix for 5.10 2/2] iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode
  2020-11-14 17:07     ` Hans de Goede
@ 2020-11-14 17:34       ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2020-11-14 17:34 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler,
	russianneuromancer @ ya . ru, linux-iio

On Sat, 14 Nov 2020 18:07:38 +0100
Hans de Goede <hdegoede@redhat.com> wrote:

> Hi,
> 
> On 11/14/20 5:01 PM, Jonathan Cameron wrote:
> > On Tue, 10 Nov 2020 14:38:35 +0100
> > Hans de Goede <hdegoede@redhat.com> wrote:
> >   
> >> 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.
> >>
> >> Reported-and-tested-by: russianneuromancer <russianneuromancer@ya.ru>
> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>  
> > Hi Hans,
> > 
> > *Mutters darkly about crazy firmware hacks*
> > 
> > I'm fine taking this but I assume we want to backport and for that I'm
> > after a fixes tag.  
> 
> Good point, I guess taking the commit which originally added the
> KIOX010A ACPI Hardware-ID makes the most sense:
> 
> Fixes: 7f6232e69539 ("iio: accel: kxcjk1013: Add KIOX010A ACPI Hardware-ID")

Agreed.

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

> 
> Regards,
> 
> Hans
> 
> 
> 
> >> ---
> >>  drivers/iio/accel/kxcjk-1013.c | 36 ++++++++++++++++++++++++++++++++++
> >>  1 file changed, 36 insertions(+)
> >>
> >> diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> >> index abeb0d254046..560a3373ff20 100644
> >> --- a/drivers/iio/accel/kxcjk-1013.c
> >> +++ b/drivers/iio/accel/kxcjk-1013.c
> >> @@ -129,6 +129,7 @@ enum kx_chipset {
> >>  enum kx_acpi_type {
> >>  	ACPI_GENERIC,
> >>  	ACPI_SMO8500,
> >> +	ACPI_KIOX010A,
> >>  };
> >>  
> >>  struct kxcjk1013_data {
> >> @@ -275,6 +276,32 @@ static const struct {
> >>  			      {19163, 1, 0},
> >>  			      {38326, 0, 1} };
> >>  
> >> +#ifdef CONFIG_ACPI
> >> +enum kiox010a_fn_index {
> >> +	KIOX010A_SET_LAPTOP_MODE = 1,
> >> +	KIOX010A_SET_TABLET_MODE = 2,
> >> +};
> >> +
> >> +static int kiox010a_dsm(struct device *dev, int fn_index)
> >> +{
> >> +	acpi_handle handle = ACPI_HANDLE(dev);
> >> +	guid_t kiox010a_dsm_guid;
> >> +	union acpi_object *obj;
> >> +
> >> +	if (!handle)
> >> +		return -ENODEV;
> >> +
> >> +	guid_parse("1f339696-d475-4e26-8cad-2e9f8e6d7a91", &kiox010a_dsm_guid);
> >> +
> >> +	obj = acpi_evaluate_dsm(handle, &kiox010a_dsm_guid, 1, fn_index, NULL);
> >> +	if (!obj)
> >> +		return -EIO;
> >> +
> >> +	ACPI_FREE(obj);
> >> +	return 0;
> >> +}
> >> +#endif
> >> +
> >>  static int kxcjk1013_set_mode(struct kxcjk1013_data *data,
> >>  			      enum kxcjk1013_mode mode)
> >>  {
> >> @@ -352,6 +379,13 @@ static int kxcjk1013_chip_init(struct kxcjk1013_data *data)
> >>  {
> >>  	int ret;
> >>  
> >> +#ifdef CONFIG_ACPI
> >> +	if (data->acpi_type == ACPI_KIOX010A) {
> >> +		/* Make sure the kbd and touchpad on 2-in-1s using 2 KXCJ91008-s work */
> >> +		kiox010a_dsm(&data->client->dev, KIOX010A_SET_LAPTOP_MODE);
> >> +	}
> >> +#endif
> >> +
> >>  	ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_WHO_AM_I);
> >>  	if (ret < 0) {
> >>  		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,
> >>  
> >>  	if (strcmp(id->id, "SMO8500") == 0)
> >>  		*acpi_type = ACPI_SMO8500;
> >> +	else if (strcmp(id->id, "KIOX010A") == 0)
> >> +		*acpi_type = ACPI_KIOX010A;
> >>  
> >>  	*chipset = (enum kx_chipset)id->driver_data;
> >>    
> >   
> 


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

end of thread, other threads:[~2020-11-14 17:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10 13:38 [PATCH bugfix for 5.10 0/2] iio: accel: kxcjk1013: Fix kbd/touchpad not working on some 2-in-1s Hans de Goede
2020-11-10 13:38 ` [PATCH bugfix for 5.10 1/2] iio: accel: kxcjk1013: Replace is_smo8500_device with an acpi_type enum Hans de Goede
2020-11-10 13:38 ` [PATCH bugfix for 5.10 2/2] iio: accel: kxcjk1013: Add support for KIOX010A ACPI DSM for setting tablet-mode Hans de Goede
2020-11-14 16:01   ` Jonathan Cameron
2020-11-14 17:07     ` Hans de Goede
2020-11-14 17:34       ` Jonathan Cameron

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