linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: mjg@redhat.com, mzxreary@0pointer.de, rpurdie@linux.intel.com,
	jlee@novell.com, linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, greg@kroah.com
Subject: [PATCH 4/4] msi-laptop: Add i8042 filter to sync sw state with BIOS when function key pressed
Date: Wed, 12 May 2010 11:56:47 -0700	[thread overview]
Message-ID: <20100512185647.GC28990@suse.de> (raw)
In-Reply-To: <20100512173359.GA16431@core.coreip.homeip.net>

From: Lee, Chun-Yi <jlee@novell.com>

There have some MSI netbook change devices state by EC when user press
wlan/bluetooth/wwan function keys. So, add a i8042 filter to sync sw
state with BIOS when function keys pressed.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 v2 - fixed some things Dmitry pointed out - gregkh

 drivers/platform/x86/msi-laptop.c |   59 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
index 34bec2e..0b17590 100644
--- a/drivers/platform/x86/msi-laptop.c
+++ b/drivers/platform/x86/msi-laptop.c
@@ -59,6 +59,7 @@
 #include <linux/backlight.h>
 #include <linux/platform_device.h>
 #include <linux/rfkill.h>
+#include <linux/i8042.h>
 
 #define MSI_DRIVER_VERSION "0.5"
 
@@ -581,6 +582,46 @@ static void rfkill_cleanup(void)
 	}
 }
 
+static void msi_update_rfkill(struct work_struct *ignored)
+{
+	get_wireless_state_ec_standard();
+
+	if (rfk_wlan)
+		rfkill_set_sw_state(rfk_wlan, !wlan_s);
+	if (rfk_bluetooth)
+		rfkill_set_sw_state(rfk_bluetooth, !bluetooth_s);
+	if (rfk_threeg)
+		rfkill_set_sw_state(rfk_threeg, !threeg_s);
+}
+static DECLARE_DELAYED_WORK(msi_rfkill_work, msi_update_rfkill);
+
+static bool msi_laptop_i8042_filter(unsigned char data, unsigned char str,
+				    struct serio *port)
+{
+	static bool extended;
+
+	if (str & 0x20)
+		return false;
+
+	/* 0x54 wwan, 0x62 bluetooth, 0x76 wlan*/
+	if (unlikely(data == 0xe0)) {
+		extended = true;
+		return false;
+	} else if (unlikely(extended)) {
+		switch (data) {
+		case 0x54:
+		case 0x62:
+		case 0x76:
+			schedule_delayed_work(&msi_rfkill_work,
+				round_jiffies_relative(0.5 * HZ));
+			break;
+		}
+		extended = false;
+	}
+
+	return false;
+}
+
 static void msi_init_rfkill(struct work_struct *ignored)
 {
 	if (rfk_wlan) {
@@ -706,9 +747,24 @@ static int load_scm_model_init(struct platform_device *sdev)
 	/* initial rfkill */
 	result = rfkill_init(sdev);
 	if (result < 0)
-		return result;
+		goto fail_rfkill;
+
+	result = i8042_install_filter(msi_laptop_i8042_filter);
+	if (result) {
+		printk(KERN_ERR
+			"msi-laptop: Unable to install key filter\n");
+		goto fail_filter;
+	}
 
 	return 0;
+
+fail_filter:
+	rfkill_cleanup();
+
+fail_rfkill:
+
+	return result;
+
 }
 
 static int __init msi_init(void)
@@ -819,6 +875,7 @@ static void __exit msi_cleanup(void)
 	platform_driver_unregister(&msipf_driver);
 	backlight_device_unregister(msibl_device);
 
+	i8042_remove_filter(msi_laptop_i8042_filter);
 	rfkill_cleanup();
 
 	/* Enable automatic brightness control again */

  parent reply	other threads:[~2010-05-12 19:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100512141149.GB20564@kroah.com>
2010-05-12 16:58 ` [PATCH 1/4] msi-laptop: Add N014 N051 dmi information to scm models table Greg Kroah-Hartman
2010-05-12 16:58 ` [PATCH 2/4] msi-laptop: Add MSI CR620 notebook " Greg Kroah-Hartman
2010-05-12 16:58 ` [PATCH 3/4] msi-laptop: Set rfkill init state when msi-laptop intiial Greg Kroah-Hartman
2010-05-12 16:58 ` [PATCH 4/4] msi-laptop: Add i8042 filter to sync sw state with BIOS when function key pressed Greg Kroah-Hartman
2010-05-12 17:33   ` Dmitry Torokhov
2010-05-12 18:55     ` Greg KH
2010-05-12 18:56     ` Greg KH [this message]
2010-05-13  7:52       ` Dmitry Torokhov
2010-05-13 11:53 Joey Lee
2010-05-13 22:54 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2010-05-14  0:37 Joey Lee
2010-05-14 22:49 Joey Lee
2010-05-20 13:32 ` Matthew Garrett
2010-05-20 13:39 Joey Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100512185647.GC28990@suse.de \
    --to=gregkh@suse.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=greg@kroah.com \
    --cc=jlee@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=mzxreary@0pointer.de \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rpurdie@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).