linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] platform: hp_accel: add a i8042 filter to remove HPQ6000 data from kb bus stream
@ 2014-10-30 16:57 Giedrius Statkevicius
  2014-11-02 22:19 ` Éric Piel
  0 siblings, 1 reply; 3+ messages in thread
From: Giedrius Statkevicius @ 2014-10-30 16:57 UTC (permalink / raw)
  To: eric.piel
  Cc: dvhart, platform-driver-x86, linux-kernel, dmitry.torokhov,
	Giedrius Statkevičius

Add a i8042 filter to hp_accel to remove accelerometer's data with acpi
id HPQ6000 from keyboard bus stream. The codes sent by accelerometer are
e0 25, e0 26, e0 27 and e0 28. The relevant information is already
passed through /dev/freefall so no need to send these undocumented weird
signals through the keyboard bus. Also, unclogs `dmesg` because atkbd
complained about weird scan codes, saves processing power and disk
space.

Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes in v2:
* Remove a unnecessary deletion of a blank line
* Move #includes of i8042.h and serio.h before the relative path
  includes.

First of all, any Tested-Bys are very welcome by people who also have a
accelerometer with acpi id HPQ6000. If it happens with HPQ6007 too we
can easily modify this to install the filter when HPQ6007 is detected.
For the time being the filter is only installed when HPQ6000 is
detected. 

Now moving to what was changed since the RFC. I reworked the filter
function to hopefully make it more clear what it is doing. Since the
codes sent by the accelerometer are extended then we need to filter all
of 0xe0's and then send one 0xe0 back when the actual key isn't in the
range of 0x25-0x28. Also, I've removed the check for errors for
i8042_install_filter() because it's unnecessary to check if it failed.
If multiple HPQ6000's are in the system then no issue occurs even if
multiple i8042_install_filter() are issued because this is handled by
i8042 and it's smart enough not to install the same filter two or more
times.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=84941.

 drivers/platform/x86/hp_accel.c | 44 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
index 13e14ec..6bec745 100644
--- a/drivers/platform/x86/hp_accel.c
+++ b/drivers/platform/x86/hp_accel.c
@@ -37,6 +37,8 @@
 #include <linux/leds.h>
 #include <linux/atomic.h>
 #include <linux/acpi.h>
+#include <linux/i8042.h>
+#include <linux/serio.h>
 #include "../../misc/lis3lv02d/lis3lv02d.h"
 
 #define DRIVER_NAME     "hp_accel"
@@ -73,6 +75,13 @@ static inline void delayed_sysfs_set(struct led_classdev *led_cdev,
 
 /* HP-specific accelerometer driver ------------------------------------ */
 
+/* e0 25, e0 26, e0 27, e0 28 are scan codes that the accelerometer with acpi id
+ * HPQ6000 sends through the keyboard bus */
+#define ACCEL_1 0x25
+#define ACCEL_2 0x26
+#define ACCEL_3 0x27
+#define ACCEL_4 0x28
+
 /* For automatic insertion of the module */
 static const struct acpi_device_id lis3lv02d_device_ids[] = {
 	{"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
@@ -294,6 +303,35 @@ static void lis3lv02d_enum_resources(struct acpi_device *device)
 		printk(KERN_DEBUG DRIVER_NAME ": Error getting resources\n");
 }
 
+static bool hp_accel_i8042_filter(unsigned char data, unsigned char str,
+				  struct serio *port)
+{
+	static bool extended;
+
+	if (str & I8042_STR_AUXDATA)
+		return false;
+
+	if (data == 0xe0) {
+		extended = true;
+		return true;
+	} else if (unlikely(extended)) {
+		extended = false;
+
+		switch (data) {
+		case ACCEL_1:
+		case ACCEL_2:
+		case ACCEL_3:
+		case ACCEL_4:
+			return true;
+		default:
+			serio_interrupt(port, 0xe0, 0);
+			return false;
+		}
+	}
+
+	return false;
+}
+
 static int lis3lv02d_add(struct acpi_device *device)
 {
 	int ret;
@@ -326,6 +364,11 @@ static int lis3lv02d_add(struct acpi_device *device)
 	if (ret)
 		return ret;
 
+	/* filter to remove HPQ6000 accelerometer data
+	 * from keyboard bus stream */
+	if (strstr(dev_name(&device->dev), "HPQ6000"))
+		i8042_install_filter(hp_accel_i8042_filter);
+
 	INIT_WORK(&hpled_led.work, delayed_set_status_worker);
 	ret = led_classdev_register(NULL, &hpled_led.led_classdev);
 	if (ret) {
@@ -343,6 +386,7 @@ static int lis3lv02d_remove(struct acpi_device *device)
 	if (!device)
 		return -EINVAL;
 
+	i8042_remove_filter(hp_accel_i8042_filter);
 	lis3lv02d_joystick_disable(&lis3_dev);
 	lis3lv02d_poweroff(&lis3_dev);
 
-- 
2.1.2


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

* Re: [PATCH v2] platform: hp_accel: add a i8042 filter to remove HPQ6000 data from kb bus stream
  2014-10-30 16:57 [PATCH v2] platform: hp_accel: add a i8042 filter to remove HPQ6000 data from kb bus stream Giedrius Statkevicius
@ 2014-11-02 22:19 ` Éric Piel
  2014-11-04  5:54   ` Darren Hart
  0 siblings, 1 reply; 3+ messages in thread
From: Éric Piel @ 2014-11-02 22:19 UTC (permalink / raw)
  To: Giedrius Statkevicius
  Cc: dvhart, platform-driver-x86, linux-kernel, dmitry.torokhov

On 30-10-14 17:57, Giedrius Statkevicius wrote:
> Add a i8042 filter to hp_accel to remove accelerometer's data with acpi
> id HPQ6000 from keyboard bus stream. The codes sent by accelerometer are
> e0 25, e0 26, e0 27 and e0 28. The relevant information is already
> passed through /dev/freefall so no need to send these undocumented weird
> signals through the keyboard bus. Also, unclogs `dmesg` because atkbd
> complained about weird scan codes, saves processing power and disk
> space.
>
> Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Hi,
Looks fine with respect to the hp accel driver. If Dmitry thinks the 
behaviour is fine then I've got nothing more to say :-)

Reviewed-by: Éric Piel <eric.piel@tremplin-utc.net>

Darren, could you pick up this patch in your tree?

Cheers,
Éric


> ---
> Changes in v2:
> * Remove a unnecessary deletion of a blank line
> * Move #includes of i8042.h and serio.h before the relative path
>    includes.
>
> First of all, any Tested-Bys are very welcome by people who also have a
> accelerometer with acpi id HPQ6000. If it happens with HPQ6007 too we
> can easily modify this to install the filter when HPQ6007 is detected.
> For the time being the filter is only installed when HPQ6000 is
> detected.
>
> Now moving to what was changed since the RFC. I reworked the filter
> function to hopefully make it more clear what it is doing. Since the
> codes sent by the accelerometer are extended then we need to filter all
> of 0xe0's and then send one 0xe0 back when the actual key isn't in the
> range of 0x25-0x28. Also, I've removed the check for errors for
> i8042_install_filter() because it's unnecessary to check if it failed.
> If multiple HPQ6000's are in the system then no issue occurs even if
> multiple i8042_install_filter() are issued because this is handled by
> i8042 and it's smart enough not to install the same filter two or more
> times.
>
> This fixes https://bugzilla.kernel.org/show_bug.cgi?id=84941.
:

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

* Re: [PATCH v2] platform: hp_accel: add a i8042 filter to remove HPQ6000 data from kb bus stream
  2014-11-02 22:19 ` Éric Piel
@ 2014-11-04  5:54   ` Darren Hart
  0 siblings, 0 replies; 3+ messages in thread
From: Darren Hart @ 2014-11-04  5:54 UTC (permalink / raw)
  To: Éric Piel
  Cc: Giedrius Statkevicius, platform-driver-x86, linux-kernel,
	dmitry.torokhov

On Sun, Nov 02, 2014 at 11:19:30PM +0100, Éric Piel wrote:
> On 30-10-14 17:57, Giedrius Statkevicius wrote:
> >Add a i8042 filter to hp_accel to remove accelerometer's data with acpi
> >id HPQ6000 from keyboard bus stream. The codes sent by accelerometer are
> >e0 25, e0 26, e0 27 and e0 28. The relevant information is already
> >passed through /dev/freefall so no need to send these undocumented weird
> >signals through the keyboard bus. Also, unclogs `dmesg` because atkbd
> >complained about weird scan codes, saves processing power and disk
> >space.
> >
> >Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
> >Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Hi,
> Looks fine with respect to the hp accel driver. If Dmitry thinks the
> behaviour is fine then I've got nothing more to say :-)
> 
> Reviewed-by: Éric Piel <eric.piel@tremplin-utc.net>
> 
> Darren, could you pick up this patch in your tree?

Yes, applied. It will make my 3.18-3 series to Linus by the end of the week, I
want it to spend a few days in next first.

> 
> Cheers,
> Éric
> 
> 
> >---
> >Changes in v2:
> >* Remove a unnecessary deletion of a blank line
> >* Move #includes of i8042.h and serio.h before the relative path
> >   includes.
> >
> >First of all, any Tested-Bys are very welcome by people who also have a
> >accelerometer with acpi id HPQ6000. If it happens with HPQ6007 too we
> >can easily modify this to install the filter when HPQ6007 is detected.
> >For the time being the filter is only installed when HPQ6000 is
> >detected.
> >
> >Now moving to what was changed since the RFC. I reworked the filter
> >function to hopefully make it more clear what it is doing. Since the
> >codes sent by the accelerometer are extended then we need to filter all
> >of 0xe0's and then send one 0xe0 back when the actual key isn't in the
> >range of 0x25-0x28. Also, I've removed the check for errors for
> >i8042_install_filter() because it's unnecessary to check if it failed.
> >If multiple HPQ6000's are in the system then no issue occurs even if
> >multiple i8042_install_filter() are issued because this is handled by
> >i8042 and it's smart enough not to install the same filter two or more
> >times.
> >
> >This fixes https://bugzilla.kernel.org/show_bug.cgi?id=84941.
> :
> 

-- 
Darren Hart
Intel Open Source Technology Center

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

end of thread, other threads:[~2014-11-04  5:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-30 16:57 [PATCH v2] platform: hp_accel: add a i8042 filter to remove HPQ6000 data from kb bus stream Giedrius Statkevicius
2014-11-02 22:19 ` Éric Piel
2014-11-04  5:54   ` Darren Hart

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