public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: Matthew Garrett <mjg@redhat.com>
Cc: Frans Pop <elendil@planet.nl>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Maciej Rutecki <maciej.rutecki@gmail.com>,
	linux acpi <linux-acpi@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: [RFT] hp-wmi: improved rfkill support for wifi
Date: Sat, 18 Jul 2009 17:55:25 +0100	[thread overview]
Message-ID: <4A61FE7D.9080409@tuffmail.co.uk> (raw)

I borrowed a HP G7000 last week.  The hp-wmi driver seemed a bit
confused about hard v.s. soft blocks on the wifi, so I fixed it based on
acpidump output [1].  I hope this will work on other HP model numbers,
but it would benefit from testing.  Any volunteers?

The wireless is toggled by a hardware button.  If your laptop is the
same, you should see a "2" in the output of "cat
/sys/class/rfkill/rfkill*/state" when the wireless is disabled.  "1"
means enabled, and "0" means "disabled by software".  Without this
patch, the driver would wrongly show "0" when the wireless was disabled
by the hardware button.

There are some other side-effects which the patch should fix.  I think
it should improve behaviour when you disable the wireless and reboot
into Windows, or vice versa.  Without the patch, it seemed that hp-wmi
would leave a "soft block" without being asked to.  After disabling the
wireless and rebooting into Windows, pressing the wireless button failed
to re-enable it.  Instead, the HP Wireless Assistant popup toggled
between "wireless disabled" and "wireless off".

[1] HP G7000 acpidump.out
<http://bugzilla.kernel.org/show_bug.cgi?id=13745#c1>

Thanks
Alan

----->
>From 9446bad909bf4c6b3d6d57d2f364ac18616f9baa Mon Sep 17 00:00:00 2001
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Date: Sat, 18 Jul 2009 16:48:37 +0100
Subject: [PATCH] [PATCH] hp-wmi: improve wlan rfkill support

1) The platform appears to support both hardware and software block
   states.  The current code only reads the overall state, and reports
   it as the software state.  Fix it.

2) Since the software state appears to be persistent, mark it as such.

3) Check rfkill in the resume handler resume.  Both the hard and soft
   blocked states could change over hibernation.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
---
 drivers/platform/x86/hp-wmi.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index ca50856..517ac47 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -180,11 +180,21 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {
 	.set_block = hp_wmi_set_block,
 };
 
-static bool hp_wmi_wifi_state(void)
+static bool hp_wmi_wifi_sw_state(void)
 {
 	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
 
-	if (wireless & 0x100)
+	if (wireless & 0x200)
+		return false;
+	else
+		return true;
+}
+
+static bool hp_wmi_wifi_hw_state(void)
+{
+	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+
+	if (wireless & 0x800)
 		return false;
 	else
 		return true;
@@ -359,8 +369,9 @@ static void hp_wmi_notify(u32 value, void *context)
 			input_sync(hp_wmi_input_dev);
 		} else if (eventcode == 0x5) {
 			if (wifi_rfkill)
-				rfkill_set_sw_state(wifi_rfkill,
-						    hp_wmi_wifi_state());
+				rfkill_set_states(wifi_rfkill,
+						  hp_wmi_wifi_sw_state(),
+						  hp_wmi_wifi_hw_state());
 			if (bluetooth_rfkill)
 				rfkill_set_sw_state(bluetooth_rfkill,
 						    hp_wmi_bluetooth_state());
@@ -451,6 +462,10 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 					   RFKILL_TYPE_WLAN,
 					   &hp_wmi_rfkill_ops,
 					   (void *) 0);
+		rfkill_init_sw_state(wifi_rfkill,
+				     hp_wmi_wifi_sw_state());
+		rfkill_set_hw_state(wifi_rfkill,
+				    hp_wmi_wifi_hw_state());
 		err = rfkill_register(wifi_rfkill);
 		if (err)
 			goto register_wifi_error;
@@ -526,6 +541,10 @@ static int hp_wmi_resume_handler(struct platform_device *device)
 			    hp_wmi_tablet_state());
 	input_sync(hp_wmi_input_dev);
 
+	rfkill_set_states(wifi_rfkill,
+			  hp_wmi_wifi_sw_state(),
+			  hp_wmi_wifi_hw_state());
+
 	return 0;
 }
 
-- 
1.6.3.2




             reply	other threads:[~2009-07-18 16:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-18 16:55 Alan Jenkins [this message]
2009-07-18 17:03 ` [RFT] hp-wmi: improved rfkill support for wifi Matthew Garrett
2009-07-18 18:55 ` Maciej Rutecki
2009-07-18 20:46   ` Alan Jenkins
2009-07-18 21:37     ` Corentin Chary
2009-07-19  8:15       ` Maciej Rutecki
2009-07-19  7:28     ` Maciej Rutecki
2009-07-19 17:21       ` Alan Jenkins
2009-07-19 18:10         ` Maciej Rutecki
2009-07-19 18:24           ` Alan Jenkins
2009-07-19 19:08             ` Maciej Rutecki
2009-07-20 17:10               ` Alan Jenkins
2009-07-20 19:54                 ` Maciej Rutecki
2009-07-20 20:08                   ` Alan Jenkins
2009-07-19 18:25           ` Matthew Garrett
2009-07-19 19:08             ` Maciej Rutecki

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=4A61FE7D.9080409@tuffmail.co.uk \
    --to=alan-jenkins@tuffmail.co.uk \
    --cc=Larry.Finger@lwfinger.net \
    --cc=elendil@planet.nl \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.rutecki@gmail.com \
    --cc=mjg@redhat.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