Skip to contentSkip to conversation

hp-wmi: improved rfkill support for wifi

RFT Alan Jenkins 4 participants 16 messages Jul 18, 2009 – Jul 20, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore 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

----->

Quoted 1 line

From 9446bad909bf4c6b3d6d57d2f364ac18616f9baa Mon Sep 17 00:00:00 2001

From: Alan Jenkins <[email protected]>
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.

---
 drivers/platform/x86/hp-wmi.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)
drivers/platform/x86/hp-wmi.c +23 -4
index ca50856..517ac47 100644
@@ -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;
 }
 
Signature · 1 line
1.6.3.2
#1 lore raw
Quoted 4 lines · Alan Jenkins

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?

This looks good. Would you mind doing the same for bluetooth and wwan? What documentation I have suggests they should have the same behaviour.

Signature · 1 line
Matthew Garrett | [email protected]
#2 lore raw
In reply to Alan Jenkins

2009/7/18 Alan Jenkins <[email protected]>:

Quoted 4 lines

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?

HP/Compaq nx6310
2.6.31-rc3+patch

When is enabled by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hci0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1

When disabled by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
2
1
0

I enable again by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill2  rfkill3  rfkill4
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
hci0
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1

I disable "by software" in Windows XP (bluetooth and wireless):

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
hci0
root@gumis:/sys/class/rfkill# cat rfkill*/state
2
0
1
1

Bluetooth works fine when I back to Linux, it seems be enabled during boot. Wireless is disabled. I cannot connect to network. So I re-enable it in Windows:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hci0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1

Regards

Signature · 6 lines
Maciej Rutecki
http://www.maciek.unixy.pl
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 81 lines · Maciej Rutecki

2009/7/18 Alan Jenkins <[email protected]>:

Quoted 5 lines

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?

HP/Compaq nx6310
2.6.31-rc3+patch

When is enabled by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hci0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1

When disabled by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
2
1
0

I enable again by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill2  rfkill3  rfkill4
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
hci0
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1

I disable "by software" in Windows XP (bluetooth and wireless):

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
hci0
root@gumis:/sys/class/rfkill# cat rfkill*/state
2
0
1
1

Bluetooth works fine when I back to Linux, it seems be enabled during boot. Wireless is disabled. I cannot connect to network. So I re-enable it in Windows:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hci0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1
Quoted 2 lines

Regards

Great detail! That all fits with what I was expecting.

Linux can also do enabling "by software". At the moment, you need to download and compile a utility to poke /dev/rfkill. I wouldn't bother testing it, because I didn't change that bit :-).

I'll try extending this to bluetooth and wwan as Matthew suggested. If you have time to run "acpidump" and send me the output, that would help me check the details.

Thanks for volunteering :-)
Alan

#4 lore raw
Quoted 82 lines · Alan Jenkins
Quoted 81 lines · Maciej Rutecki

2009/7/18 Alan Jenkins <[email protected]>:

Quoted 5 lines

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?

HP/Compaq nx6310
2.6.31-rc3+patch

When is enabled by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hci0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1

When disabled by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
2
1
0

I enable again by button:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill2  rfkill3  rfkill4
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
hci0
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1

I disable "by software" in Windows XP (bluetooth and wireless):

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hp-wifi
hp-bluetooth
hci0
root@gumis:/sys/class/rfkill# cat rfkill*/state
2
0
1
1

Bluetooth works fine when I back to Linux, it seems be enabled during boot. Wireless is disabled. I cannot connect to network. So I re-enable it in Windows:

root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1  rfkill2  rfkill3
root@gumis:/sys/class/rfkill# cat rfkill*/name
phy0
hci0
hp-wifi
hp-bluetooth
root@gumis:/sys/class/rfkill# cat rfkill*/state
1
1
1
1
Quoted 8 lines
Quoted 2 lines

Regards

Great detail!  That all fits with what I was expecting.

Linux can also do enabling "by software".  At the moment, you need to download and compile a utility to poke /dev/rfkill.  I wouldn't bother testing it, because I didn't change that bit :-).

Utility is here
http://git.sipsolutions.net/?p=rfkill.git
And a patch to restore write access to /sys/class/rfkill/*/state file is here
http://lkml.org/lkml/2009/7/10/339

Quoted 3 lines

I'll try extending this to bluetooth and wwan as Matthew suggested.  If you have time to run "acpidump" and send me the output, that would help me check the details.

I have an HP 8710p, so if you want acpidump and test on another hardware, just ask :).

Signature · 6 lines
Corentin Chary
http://xf.iksaif.net - http://uffs.org
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

2009/7/18 Corentin Chary <[email protected]>:

Quoted 8 lines
Quoted 3 lines

Linux can also do enabling "by software".  At the moment, you need to download and compile a utility to poke /dev/rfkill.  I wouldn't bother testing it, because I didn't change that bit :-).

Utility is here
http://git.sipsolutions.net/?p=rfkill.git
And a patch to restore write access to /sys/class/rfkill/*/state file is here
http://lkml.org/lkml/2009/7/10/339

Great tool.

Block bluetooth:

root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill block 3
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
3: hp-bluetooth: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 3
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
3: hp-bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: no
5: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no

Block wireless:

root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill block 0
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
2: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
3: hp-bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: no
5: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 0
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
3: hp-bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: no
5: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no

Works very nice on my laptop

Thanks!

Signature · 6 lines
Maciej Rutecki
http://www.maciek.unixy.pl
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw
In reply to Alan Jenkins

2009/7/18 Alan Jenkins <[email protected]>:
[...]

Quoted 3 lines

I'll try extending this to bluetooth and wwan as Matthew suggested.  If you have time to run "acpidump" and send me the output, that would help

acpidump in attachment.

Regards

Signature · 2 lines
Maciej Rutecki
http://www.maciek.unixy.pl
#7 lore raw
Quoted 9 lines · Maciej Rutecki

2009/7/18 Alan Jenkins <[email protected]>:
[...]

Quoted 3 lines

I'll try extending this to bluetooth and wwan as Matthew suggested. If you have time to run "acpidump" and send me the output, that would help

acpidump in attachment.

Heh, I got lucky borrowing the G7000. Your acpidump is much less human readable, and Matthews lot is the same. I gave up looking for the right bits.

So I had to guess :-). The interface seems nicely structured, so I generalized my changes and applied them to the other rfkill devices. Patch follows - apply on top of the first one.

Now if you disable bluetooth in the Windows driver and reboot to linux, you should find it stays disabled.

Alan

--------------------------------------------------------------------------

drivers/platform/x86/hp-wmi.c +84 -72
index 517ac47..43eb30e 100644
@@ -51,6 +51,12 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
 #define HPWMI_WIRELESS_QUERY 0x5
 #define HPWMI_HOTKEY_QUERY 0xc
 
+enum hp_wmi_radio {
+	HPWMI_WIFI = 0,
+	HPWMI_BLUETOOTH = 1,
+	HPWMI_WWAN = 2,
+};
+
 static int __init hp_wmi_bios_setup(struct platform_device *device);
 static int __exit hp_wmi_bios_remove(struct platform_device *device);
 static int hp_wmi_resume_handler(struct platform_device *device);
@@ -170,8 +176,8 @@ static int hp_wmi_tablet_state(void)
 
 static int hp_wmi_set_block(void *data, bool blocked)
 {
-	unsigned long b = (unsigned long) data;
-	int query = BIT(b + 8) | ((!blocked) << b);
+	enum hp_wmi_radio r = (enum hp_wmi_radio) data;
+	int query = BIT(r + 8) | ((!blocked) << r);
 
 	return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);
 }
@@ -180,41 +186,23 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {
 	.set_block = hp_wmi_set_block,
 };
 
-static bool hp_wmi_wifi_sw_state(void)
-{
-	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-	if (wireless & 0x200)
-		return false;
-	else
-		return true;
-}
-
-static bool hp_wmi_wifi_hw_state(void)
+static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
 {
 	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+	int mask = 0x200 << (r * 8);
 
-	if (wireless & 0x800)
+	if (wireless & mask)
 		return false;
 	else
 		return true;
 }
 
-static bool hp_wmi_bluetooth_state(void)
+static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)
 {
 	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+	int mask = 0x800 << (r * 8);
 
-	if (wireless & 0x10000)
-		return false;
-	else
-		return true;
-}
-
-static bool hp_wmi_wwan_state(void)
-{
-	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-	if (wireless & 0x1000000)
+	if (wireless & mask)
 		return false;
 	else
 		return true;
@@ -339,50 +327,55 @@ static void hp_wmi_notify(u32 value, void *context)
 	struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
 	static struct key_entry *key;
 	union acpi_object *obj;
+	int eventcode;
 
 	wmi_get_event_data(value, &response);
 
 	obj = (union acpi_object *)response.pointer;
 
-	if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) {
-		int eventcode = *((u8 *) obj->buffer.pointer);
-		if (eventcode == 0x4)
-			eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
-							 0);
-		key = hp_wmi_get_entry_by_scancode(eventcode);
-		if (key) {
-			switch (key->type) {
-			case KE_KEY:
-				input_report_key(hp_wmi_input_dev,
-						 key->keycode, 1);
-				input_sync(hp_wmi_input_dev);
-				input_report_key(hp_wmi_input_dev,
-						 key->keycode, 0);
-				input_sync(hp_wmi_input_dev);
-				break;
-			}
-		} else if (eventcode == 0x1) {
-			input_report_switch(hp_wmi_input_dev, SW_DOCK,
-					    hp_wmi_dock_state());
-			input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-					    hp_wmi_tablet_state());
+	if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
+		printk(KERN_INFO "HP WMI: Unknown response received\n");
+		return;
+	}
+
+	eventcode = *((u8 *) obj->buffer.pointer);
+	if (eventcode == 0x4)
+		eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
+						0);
+	key = hp_wmi_get_entry_by_scancode(eventcode);
+	if (key) {
+		switch (key->type) {
+		case KE_KEY:
+			input_report_key(hp_wmi_input_dev,
+					 key->keycode, 1);
+			input_sync(hp_wmi_input_dev);
+			input_report_key(hp_wmi_input_dev,
+					 key->keycode, 0);
 			input_sync(hp_wmi_input_dev);
-		} else if (eventcode == 0x5) {
-			if (wifi_rfkill)
-				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());
-			if (wwan_rfkill)
-				rfkill_set_sw_state(wwan_rfkill,
-						    hp_wmi_wwan_state());
-		} else
-			printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
-			       eventcode);
+			break;
+		}
+	} else if (eventcode == 0x1) {
+		input_report_switch(hp_wmi_input_dev, SW_DOCK,
+				    hp_wmi_dock_state());
+		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+				    hp_wmi_tablet_state());
+		input_sync(hp_wmi_input_dev);
+	} else if (eventcode == 0x5) {
+		if (wifi_rfkill)
+			rfkill_set_states(wifi_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_WIFI),
+					  hp_wmi_get_hw_state(HPWMI_WIFI));
+		if (bluetooth_rfkill)
+			rfkill_set_states(bluetooth_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+					  hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+		if (wwan_rfkill)
+			rfkill_set_states(wwan_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_WWAN),
+					  hp_wmi_get_hw_state(HPWMI_WWAN));
 	} else
-		printk(KERN_INFO "HP WMI: Unknown response received\n");
+		printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
+			eventcode);
 }
 
 static int __init hp_wmi_input_setup(void)
@@ -461,11 +454,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev,
 					   RFKILL_TYPE_WLAN,
 					   &hp_wmi_rfkill_ops,
-					   (void *) 0);
+					   (void *) HPWMI_WIFI);
 		rfkill_init_sw_state(wifi_rfkill,
-				     hp_wmi_wifi_sw_state());
+				     hp_wmi_get_sw_state(HPWMI_WIFI));
 		rfkill_set_hw_state(wifi_rfkill,
-				    hp_wmi_wifi_hw_state());
+				    hp_wmi_get_hw_state(HPWMI_WIFI));
 		err = rfkill_register(wifi_rfkill);
 		if (err)
 			goto register_wifi_error;
@@ -475,8 +468,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		bluetooth_rfkill = rfkill_alloc("hp-bluetooth", &device->dev,
 						RFKILL_TYPE_BLUETOOTH,
 						&hp_wmi_rfkill_ops,
-						(void *) 1);
-		err = rfkill_register(bluetooth_rfkill);
+						(void *) HPWMI_BLUETOOTH);
+		rfkill_init_sw_state(wifi_rfkill,
+				     hp_wmi_get_sw_state(HPWMI_BLUETOOTH));
+		rfkill_set_hw_state(wifi_rfkill,
+				    hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
 		if (err)
 			goto register_bluetooth_error;
 	}
@@ -485,7 +481,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		wwan_rfkill = rfkill_alloc("hp-wwan", &device->dev,
 					   RFKILL_TYPE_WWAN,
 					   &hp_wmi_rfkill_ops,
-					   (void *) 2);
+					   (void *) HPWMI_WWAN);
+		rfkill_init_sw_state(wifi_rfkill,
+				     hp_wmi_get_sw_state(HPWMI_WWAN));
+		rfkill_set_hw_state(wifi_rfkill,
+				    hp_wmi_get_hw_state(HPWMI_WWAN));
 		err = rfkill_register(wwan_rfkill);
 		if (err)
 			goto register_wwan_err;
@@ -541,9 +541,21 @@ 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());
+	if (wifi_rfkill) {
+		rfkill_set_states(wifi_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_WIFI),
+				  hp_wmi_get_hw_state(HPWMI_WIFI));
+	}
+	if (bluetooth_rfkill) {
+		rfkill_set_states(bluetooth_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+				  hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+	}
+	if (wwan_rfkill) {
+		rfkill_set_states(wwan_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_WWAN),
+				  hp_wmi_get_hw_state(HPWMI_WWAN));
+	}
 
 	return 0;
 }
#8 lore raw

2009/7/19 Alan Jenkins <[email protected]>:

Quoted 15 lines
Quoted 9 lines · Maciej Rutecki

2009/7/18 Alan Jenkins <[email protected]>:
[...]

Quoted 3 lines

I'll try extending this to bluetooth and wwan as Matthew suggested.  If you have time to run "acpidump" and send me the output, that would help

acpidump in attachment.

Heh, I got lucky borrowing the G7000.  Your acpidump is much less human readable, and Matthews lot is the same.  I gave up looking for the right bits.

Quoted 7 lines

So I had to guess :-).  The interface seems nicely structured, so I generalized my changes and applied them to the other rfkill devices. Patch follows - apply on top of the first one.

Now if you disable bluetooth in the Windows driver and reboot to linux, you should find it stays disabled.

2.6.31-rc3+ patches:
http://lkml.org/lkml/2009/7/18/131
http://lkml.org/lkml/2009/7/10/339
http://lkml.org/lkml/2009/7/19/57

Disable bluetooth and wireless in Windows XP
When modprobe hp-wmi during boot:

[    9.648259] input: HP WMI hotkeys as /class/input/input8
[    9.664468] Platform driver 'hp-wmi' needs updating - please use dev_pm_ops
[    9.707352] ------------[ cut here ]------------
[    9.708007] Kernel BUG at f80763b7 [verbose debug info unavailable]
[    9.708007] invalid opcode: 0000 [#1] SMP
[    9.708007] last sysfs file: /sys/class/input/input8/modalias
[    9.708007] Modules linked in: hp_wmi(+) fuse sbp2 loop arc4 ecb

iwl3945 iwlcore snd_hda_codec_si3054 firmware_class pcmcia snd_hda_codec_analog mac80211 snd_hda_intel snd_hda_codec led_class snd_pcm_oss snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer snd_seq_device uhci_hcd cfg80211 ehci_hcd yenta_socket snd ohci1394 b44 rsrc_nonstatic rfkill usbcore intel_agp psmouse ieee1394 ssb rtc_cmos pcmcia_core video agpgart mii soundcore serio_raw backlight rtc_core output rtc_lib snd_page_alloc ac evdev fan button battery sg

[    9.708007]
[    9.708007] Pid: 1544, comm: modprobe Not tainted (2.6.31-rc3 #1)
HP Compaq nx6310 (EY501ES#AKD)
[    9.708007] EIP: 0060:[<f80763b7>] EFLAGS: 00010202 CPU: 0
[    9.708007] EIP is at rfkill_init_sw_state+0x57/0x70 [rfkill]
[    9.708007] EAX: f65ad800 EBX: f65ad800 ECX: 00000008 EDX: 00000001
[    9.708007] ESI: 00000001 EDI: 0c0c0c2b EBP: f65b3de0 ESP: f65b3dd4
[    9.708007]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[    9.708007] Process modprobe (pid: 1544, ti=f65b2000 task=f7155d00
task.ti=f65b2000)
[    9.708007] Stack:
[    9.708007]  00000000 f6b94308 0c0c0c2b f65b3e00 f8efa18f f8ef68d8
00000001 f6b94300
[    9.708007] <0> ffffffed f6b94308 f8ef74dc f65b3e08 c02f38f1
f65b3e30 c02f28ad 00000000
[    9.708007] <0> 00000000 f6b94300 f6b94308 f65b3e30 f8ef74dc
f6b94308 f6b94308 f65b3e40
[    9.708007] Call Trace:
[    9.708007]  [<f8efa18f>] ? hp_wmi_bios_setup+0x18f/0x211 [hp_wmi]
[    9.708007]  [<c02f38f1>] ? platform_drv_probe+0x11/0x20
[    9.708007]  [<c02f28ad>] ? driver_probe_device+0x6d/0x180
[    9.708007]  [<c02f2aa9>] ? __device_attach+0x49/0x60
[    9.708007]  [<c02f1eb3>] ? bus_for_each_drv+0x53/0x80
[    9.708007]  [<c02f2b6b>] ? device_attach+0x6b/0x70
[    9.708007]  [<c02f2a60>] ? __device_attach+0x0/0x60
[    9.708007]  [<c02f1cb7>] ? bus_attach_device+0x47/0x70
[    9.708007]  [<c02f04ce>] ? device_add+0x4fe/0x640
[    9.708007]  [<c026bad2>] ? kobject_set_name_vargs+0x62/0x70
[    9.708007]  [<c02f4265>] ? platform_device_add+0x145/0x190
[    9.708007]  [<c02f43f4>] ? platform_device_alloc+0x54/0x70
[    9.708007]  [<f8efa211>] ? hp_wmi_init+0x0/0x1aa [hp_wmi]
[    9.708007]  [<f8efa3a7>] ? hp_wmi_init+0x196/0x1aa [hp_wmi]
[    9.708007]  [<c010112f>] ? do_one_initcall+0x2f/0x150
[    9.708007]  [<c017d6d7>] ? tracepoint_module_notify+0x37/0x40
[    9.708007]  [<c0151b0d>] ? notifier_call_chain+0x2d/0x60
[    9.708007]  [<c0151f12>] ? __blocking_notifier_call_chain+0x52/0x60
[    9.708007]  [<c016421f>] ? sys_init_module+0xaf/0x1f0
[    9.708007]  [<c0102ec4>] ? sysenter_do_call+0x12/0x22
[    9.708007] Code: 02 83 c1 02 84 d2 75 1c f7 d1 21 c1 89 4b 0c c6
43 15 01 89 fa 89 d8 e8 98 2f 35 c8 5b 5e 5f c9 c3 8d 76 00 09 c1 89
4b 0c eb e4 <0f> 0b eb fe 90 8d 74 26 00 0f 0b eb fe 8d b6 00 00 00 00
8d bf
[    9.708007] EIP: [<f80763b7>] rfkill_init_sw_state+0x57/0x70
[rfkill] SS:ESP 0068:f65b3dd4
[   10.413477] ---[ end trace 15451c5b7e8810a1 ]---

Try enable bluetooth and wireless:

root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill  list
0: phy0: Wireless LAN
        Soft blocked: yes
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill  unblock 0
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill  list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill  unblock 1
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill  list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
root@gumis:/sys/class/rfkill# ls
rfkill0  rfkill1
root@gumis:/sys/class/rfkill# cat rfkill0/state
1
root@gumis:/sys/class/rfkill# cat rfkill1/state
1

Bluetooth still doesn't work. I can enable wifi.

LED from wifi/bluetooth button sometimes flashing(!)

Regards

Signature · 6 lines
Maciej Rutecki
http://www.maciek.unixy.pl
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw
Quoted 35 lines · Maciej Rutecki

2009/7/19 Alan Jenkins <[email protected]>:

Quoted 17 lines
Quoted 11 lines · Maciej Rutecki

2009/7/18 Alan Jenkins <[email protected]>:
[...]

Quoted 4 lines

I'll try extending this to bluetooth and wwan as Matthew suggested. If you have time to run "acpidump" and send me the output, that would help

acpidump in attachment.

Heh, I got lucky borrowing the G7000. Your acpidump is much less human readable, and Matthews lot is the same. I gave up looking for the right bits.

Quoted 8 lines

So I had to guess :-). The interface seems nicely structured, so I generalized my changes and applied them to the other rfkill devices. Patch follows - apply on top of the first one.

Now if you disable bluetooth in the Windows driver and reboot to linux, you should find it stays disabled.

2.6.31-rc3+ patches:
http://lkml.org/lkml/2009/7/18/131
http://lkml.org/lkml/2009/7/10/339
http://lkml.org/lkml/2009/7/19/57

Disable bluetooth and wireless in Windows XP
When modprobe hp-wmi during boot:

Quoted 8 lines
[    9.648259] input: HP WMI hotkeys as /class/input/input8
[    9.664468] Platform driver 'hp-wmi' needs updating - please use dev_pm_ops
[    9.707352] ------------[ cut here ]------------
[    9.708007] Kernel BUG at f80763b7 [verbose debug info unavailable
[    9.708007] EIP is at rfkill_init_sw_state+0x57/0x70 [rfkill
[    9.708007]  [<f8efa18f>] ? hp_wmi_bios_setup+0x18f/0x211 [hp_wmi

Sorry, that was a dumb copy+paste error. Here's a fixed version.

Quoted 1 line

LED from wifi/bluetooth button sometimes flashing(!)

Hmm. That might be a sign that I guessed wrong.

--------------------------------------------------------------------------

drivers/platform/x86/hp-wmi.c +84 -72
index 517ac47..35ef858 100644
@@ -51,6 +51,12 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
 #define HPWMI_WIRELESS_QUERY 0x5
 #define HPWMI_HOTKEY_QUERY 0xc
 
+enum hp_wmi_radio {
+	HPWMI_WIFI = 0,
+	HPWMI_BLUETOOTH = 1,
+	HPWMI_WWAN = 2,
+};
+
 static int __init hp_wmi_bios_setup(struct platform_device *device);
 static int __exit hp_wmi_bios_remove(struct platform_device *device);
 static int hp_wmi_resume_handler(struct platform_device *device);
@@ -170,8 +176,8 @@ static int hp_wmi_tablet_state(void)
 
 static int hp_wmi_set_block(void *data, bool blocked)
 {
-	unsigned long b = (unsigned long) data;
-	int query = BIT(b + 8) | ((!blocked) << b);
+	enum hp_wmi_radio r = (enum hp_wmi_radio) data;
+	int query = BIT(r + 8) | ((!blocked) << r);
 
 	return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);
 }
@@ -180,41 +186,23 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {
 	.set_block = hp_wmi_set_block,
 };
 
-static bool hp_wmi_wifi_sw_state(void)
+static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
 {
 	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+	int mask = 0x200 << (r * 8);
 
-	if (wireless & 0x200)
+	if (wireless & mask)
 		return false;
 	else
 		return true;
 }
 
-static bool hp_wmi_wifi_hw_state(void)
+static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)
 {
 	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+	int mask = 0x800 << (r * 8);
 
-	if (wireless & 0x800)
-		return false;
-	else
-		return true;
-}
-
-static bool hp_wmi_bluetooth_state(void)
-{
-	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-	if (wireless & 0x10000)
-		return false;
-	else
-		return true;
-}
-
-static bool hp_wmi_wwan_state(void)
-{
-	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-	if (wireless & 0x1000000)
+	if (wireless & mask)
 		return false;
 	else
 		return true;
@@ -339,50 +327,55 @@ static void hp_wmi_notify(u32 value, void *context)
 	struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
 	static struct key_entry *key;
 	union acpi_object *obj;
+	int eventcode;
 
 	wmi_get_event_data(value, &response);
 
 	obj = (union acpi_object *)response.pointer;
 
-	if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) {
-		int eventcode = *((u8 *) obj->buffer.pointer);
-		if (eventcode == 0x4)
-			eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
-							 0);
-		key = hp_wmi_get_entry_by_scancode(eventcode);
-		if (key) {
-			switch (key->type) {
-			case KE_KEY:
-				input_report_key(hp_wmi_input_dev,
-						 key->keycode, 1);
-				input_sync(hp_wmi_input_dev);
-				input_report_key(hp_wmi_input_dev,
-						 key->keycode, 0);
-				input_sync(hp_wmi_input_dev);
-				break;
-			}
-		} else if (eventcode == 0x1) {
-			input_report_switch(hp_wmi_input_dev, SW_DOCK,
-					    hp_wmi_dock_state());
-			input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-					    hp_wmi_tablet_state());
+	if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
+		printk(KERN_INFO "HP WMI: Unknown response received\n");
+		return;
+	}
+
+	eventcode = *((u8 *) obj->buffer.pointer);
+	if (eventcode == 0x4)
+		eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
+						0);
+	key = hp_wmi_get_entry_by_scancode(eventcode);
+	if (key) {
+		switch (key->type) {
+		case KE_KEY:
+			input_report_key(hp_wmi_input_dev,
+					 key->keycode, 1);
 			input_sync(hp_wmi_input_dev);
-		} else if (eventcode == 0x5) {
-			if (wifi_rfkill)
-				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());
-			if (wwan_rfkill)
-				rfkill_set_sw_state(wwan_rfkill,
-						    hp_wmi_wwan_state());
-		} else
-			printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
-			       eventcode);
+			input_report_key(hp_wmi_input_dev,
+					 key->keycode, 0);
+			input_sync(hp_wmi_input_dev);
+			break;
+		}
+	} else if (eventcode == 0x1) {
+		input_report_switch(hp_wmi_input_dev, SW_DOCK,
+				    hp_wmi_dock_state());
+		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+				    hp_wmi_tablet_state());
+		input_sync(hp_wmi_input_dev);
+	} else if (eventcode == 0x5) {
+		if (wifi_rfkill)
+			rfkill_set_states(wifi_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_WIFI),
+					  hp_wmi_get_hw_state(HPWMI_WIFI));
+		if (bluetooth_rfkill)
+			rfkill_set_states(bluetooth_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+					  hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+		if (wwan_rfkill)
+			rfkill_set_states(wwan_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_WWAN),
+					  hp_wmi_get_hw_state(HPWMI_WWAN));
 	} else
-		printk(KERN_INFO "HP WMI: Unknown response received\n");
+		printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
+			eventcode);
 }
 
 static int __init hp_wmi_input_setup(void)
@@ -461,11 +454,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev,
 					   RFKILL_TYPE_WLAN,
 					   &hp_wmi_rfkill_ops,
-					   (void *) 0);
+					   (void *) HPWMI_WIFI);
 		rfkill_init_sw_state(wifi_rfkill,
-				     hp_wmi_wifi_sw_state());
+				     hp_wmi_get_sw_state(HPWMI_WIFI));
 		rfkill_set_hw_state(wifi_rfkill,
-				    hp_wmi_wifi_hw_state());
+				    hp_wmi_get_hw_state(HPWMI_WIFI));
 		err = rfkill_register(wifi_rfkill);
 		if (err)
 			goto register_wifi_error;
@@ -475,8 +468,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		bluetooth_rfkill = rfkill_alloc("hp-bluetooth", &device->dev,
 						RFKILL_TYPE_BLUETOOTH,
 						&hp_wmi_rfkill_ops,
-						(void *) 1);
-		err = rfkill_register(bluetooth_rfkill);
+						(void *) HPWMI_BLUETOOTH);
+		rfkill_init_sw_state(bluetooth_rfkill,
+				     hp_wmi_get_sw_state(HPWMI_BLUETOOTH));
+		rfkill_set_hw_state(bluetooth_rfkill,
+				    hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
 		if (err)
 			goto register_bluetooth_error;
 	}
@@ -485,7 +481,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		wwan_rfkill = rfkill_alloc("hp-wwan", &device->dev,
 					   RFKILL_TYPE_WWAN,
 					   &hp_wmi_rfkill_ops,
-					   (void *) 2);
+					   (void *) HPWMI_WWAN);
+		rfkill_init_sw_state(wwan_rfkill,
+				     hp_wmi_get_sw_state(HPWMI_WWAN));
+		rfkill_set_hw_state(wwan_rfkill,
+				    hp_wmi_get_hw_state(HPWMI_WWAN));
 		err = rfkill_register(wwan_rfkill);
 		if (err)
 			goto register_wwan_err;
@@ -541,9 +541,21 @@ 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());
+	if (wifi_rfkill) {
+		rfkill_set_states(wifi_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_WIFI),
+				  hp_wmi_get_hw_state(HPWMI_WIFI));
+	}
+	if (bluetooth_rfkill) {
+		rfkill_set_states(bluetooth_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+				  hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+	}
+	if (wwan_rfkill) {
+		rfkill_set_states(wwan_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_WWAN),
+				  hp_wmi_get_hw_state(HPWMI_WWAN));
+	}
 
 	return 0;
 }
#10 lore raw

2009/7/19 Alan Jenkins <[email protected]>:

Quoted 3 lines

Sorry, that was a dumb copy+paste error.  Here's a fixed version.

No errors during boot, but still bluetooth is disabled:

root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: yes
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 0
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 1
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no

In /sys/class/rfkill I see only 2 "rfkill?" directory (compare to my first e-mail):

root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ls /sys/class/rfkill/
rfkill0  rfkill1
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# cat
/sys/class/rfkill/rfkill0/state
1
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# cat
/sys/class/rfkill/rfkill1/state
1
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# /etc/init.d/bluetooth
force-reload
Restarting bluetooth: hcid.
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# hciconfig -a hci0
Can't get device info: No such device

Wireless works OK.

Regards

Signature · 6 lines
Maciej Rutecki
http://www.maciek.unixy.pl
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw
Quoted 8 lines · Maciej Rutecki

2009/7/19 Alan Jenkins <[email protected]>:

Quoted 3 lines

Sorry, that was a dumb copy+paste error. Here's a fixed version.

No errors during boot, but still bluetooth is disabled:

Quoted 9 lines
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: yes
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 0

...and here's the version that remembers to register the bluetooth. I reviewed the patch again; hopefully that's the last dumb error.

Alan

drivers/platform/x86/hp-wmi.c +81 -71
index 517ac47..adb26d3 100644
@@ -51,6 +51,12 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
 #define HPWMI_WIRELESS_QUERY 0x5
 #define HPWMI_HOTKEY_QUERY 0xc
 
+enum hp_wmi_radio {
+	HPWMI_WIFI = 0,
+	HPWMI_BLUETOOTH = 1,
+	HPWMI_WWAN = 2,
+};
+
 static int __init hp_wmi_bios_setup(struct platform_device *device);
 static int __exit hp_wmi_bios_remove(struct platform_device *device);
 static int hp_wmi_resume_handler(struct platform_device *device);
@@ -170,8 +176,8 @@ static int hp_wmi_tablet_state(void)
 
 static int hp_wmi_set_block(void *data, bool blocked)
 {
-	unsigned long b = (unsigned long) data;
-	int query = BIT(b + 8) | ((!blocked) << b);
+	enum hp_wmi_radio r = (enum hp_wmi_radio) data;
+	int query = BIT(r + 8) | ((!blocked) << r);
 
 	return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);
 }
@@ -180,41 +186,23 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {
 	.set_block = hp_wmi_set_block,
 };
 
-static bool hp_wmi_wifi_sw_state(void)
+static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
 {
 	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+	int mask = 0x200 << (r * 8);
 
-	if (wireless & 0x200)
+	if (wireless & mask)
 		return false;
 	else
 		return true;
 }
 
-static bool hp_wmi_wifi_hw_state(void)
+static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)
 {
 	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+	int mask = 0x800 << (r * 8);
 
-	if (wireless & 0x800)
-		return false;
-	else
-		return true;
-}
-
-static bool hp_wmi_bluetooth_state(void)
-{
-	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-	if (wireless & 0x10000)
-		return false;
-	else
-		return true;
-}
-
-static bool hp_wmi_wwan_state(void)
-{
-	int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-	if (wireless & 0x1000000)
+	if (wireless & mask)
 		return false;
 	else
 		return true;
@@ -339,50 +327,55 @@ static void hp_wmi_notify(u32 value, void *context)
 	struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
 	static struct key_entry *key;
 	union acpi_object *obj;
+	int eventcode;
 
 	wmi_get_event_data(value, &response);
 
 	obj = (union acpi_object *)response.pointer;
 
-	if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) {
-		int eventcode = *((u8 *) obj->buffer.pointer);
-		if (eventcode == 0x4)
-			eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
-							 0);
-		key = hp_wmi_get_entry_by_scancode(eventcode);
-		if (key) {
-			switch (key->type) {
-			case KE_KEY:
-				input_report_key(hp_wmi_input_dev,
-						 key->keycode, 1);
-				input_sync(hp_wmi_input_dev);
-				input_report_key(hp_wmi_input_dev,
-						 key->keycode, 0);
-				input_sync(hp_wmi_input_dev);
-				break;
-			}
-		} else if (eventcode == 0x1) {
-			input_report_switch(hp_wmi_input_dev, SW_DOCK,
-					    hp_wmi_dock_state());
-			input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-					    hp_wmi_tablet_state());
+	if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
+		printk(KERN_INFO "HP WMI: Unknown response received\n");
+		return;
+	}
+
+	eventcode = *((u8 *) obj->buffer.pointer);
+	if (eventcode == 0x4)
+		eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
+						0);
+	key = hp_wmi_get_entry_by_scancode(eventcode);
+	if (key) {
+		switch (key->type) {
+		case KE_KEY:
+			input_report_key(hp_wmi_input_dev,
+					 key->keycode, 1);
+			input_sync(hp_wmi_input_dev);
+			input_report_key(hp_wmi_input_dev,
+					 key->keycode, 0);
 			input_sync(hp_wmi_input_dev);
-		} else if (eventcode == 0x5) {
-			if (wifi_rfkill)
-				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());
-			if (wwan_rfkill)
-				rfkill_set_sw_state(wwan_rfkill,
-						    hp_wmi_wwan_state());
-		} else
-			printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
-			       eventcode);
+			break;
+		}
+	} else if (eventcode == 0x1) {
+		input_report_switch(hp_wmi_input_dev, SW_DOCK,
+				    hp_wmi_dock_state());
+		input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+				    hp_wmi_tablet_state());
+		input_sync(hp_wmi_input_dev);
+	} else if (eventcode == 0x5) {
+		if (wifi_rfkill)
+			rfkill_set_states(wifi_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_WIFI),
+					  hp_wmi_get_hw_state(HPWMI_WIFI));
+		if (bluetooth_rfkill)
+			rfkill_set_states(bluetooth_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+					  hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+		if (wwan_rfkill)
+			rfkill_set_states(wwan_rfkill,
+					  hp_wmi_get_sw_state(HPWMI_WWAN),
+					  hp_wmi_get_hw_state(HPWMI_WWAN));
 	} else
-		printk(KERN_INFO "HP WMI: Unknown response received\n");
+		printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
+			eventcode);
 }
 
 static int __init hp_wmi_input_setup(void)
@@ -461,11 +454,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev,
 					   RFKILL_TYPE_WLAN,
 					   &hp_wmi_rfkill_ops,
-					   (void *) 0);
+					   (void *) HPWMI_WIFI);
 		rfkill_init_sw_state(wifi_rfkill,
-				     hp_wmi_wifi_sw_state());
+				     hp_wmi_get_sw_state(HPWMI_WIFI));
 		rfkill_set_hw_state(wifi_rfkill,
-				    hp_wmi_wifi_hw_state());
+				    hp_wmi_get_hw_state(HPWMI_WIFI));
 		err = rfkill_register(wifi_rfkill);
 		if (err)
 			goto register_wifi_error;
@@ -475,7 +468,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		bluetooth_rfkill = rfkill_alloc("hp-bluetooth", &device->dev,
 						RFKILL_TYPE_BLUETOOTH,
 						&hp_wmi_rfkill_ops,
-						(void *) 1);
+						(void *) HPWMI_BLUETOOTH);
+		rfkill_init_sw_state(bluetooth_rfkill,
+				     hp_wmi_get_sw_state(HPWMI_BLUETOOTH));
+		rfkill_set_hw_state(bluetooth_rfkill,
+				    hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
 		err = rfkill_register(bluetooth_rfkill);
 		if (err)
 			goto register_bluetooth_error;
@@ -485,7 +482,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 		wwan_rfkill = rfkill_alloc("hp-wwan", &device->dev,
 					   RFKILL_TYPE_WWAN,
 					   &hp_wmi_rfkill_ops,
-					   (void *) 2);
+					   (void *) HPWMI_WWAN);
+		rfkill_init_sw_state(wwan_rfkill,
+				     hp_wmi_get_sw_state(HPWMI_WWAN));
+		rfkill_set_hw_state(wwan_rfkill,
+				    hp_wmi_get_hw_state(HPWMI_WWAN));
 		err = rfkill_register(wwan_rfkill);
 		if (err)
 			goto register_wwan_err;
@@ -541,9 +542,18 @@ 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());
+	if (wifi_rfkill)
+		rfkill_set_states(wifi_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_WIFI),
+				  hp_wmi_get_hw_state(HPWMI_WIFI));
+	if (bluetooth_rfkill)
+		rfkill_set_states(bluetooth_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+				  hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+	if (wwan_rfkill)
+		rfkill_set_states(wwan_rfkill,
+				  hp_wmi_get_sw_state(HPWMI_WWAN),
+				  hp_wmi_get_hw_state(HPWMI_WWAN));
 
 	return 0;
 }
#12 lore raw

2009/7/20 Alan Jenkins <[email protected]>:

Quoted 3 lines

...and here's the version that remembers to register the bluetooth.  I reviewed the patch again; hopefully that's the last dumb error.

[...]

2.6.31-rc3+ patches:
http://lkml.org/lkml/2009/7/18/131
http://lkml.org/lkml/2009/7/10/339
+ patch below:

Quoted 225 lines
drivers/platform/x86/hp-wmi.c +11 -4
index 517ac47..adb26d3 100644
@@ -51,6 +51,12 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
  #define HPWMI_WIRELESS_QUERY 0x5
  #define HPWMI_HOTKEY_QUERY 0xc
 
+enum hp_wmi_radio {
+       HPWMI_WIFI = 0,
+       HPWMI_BLUETOOTH = 1,
+       HPWMI_WWAN = 2,
+};
+
  static int __init hp_wmi_bios_setup(struct platform_device *device);
  static int __exit hp_wmi_bios_remove(struct platform_device *device);
  static int hp_wmi_resume_handler(struct platform_device *device);
@@ -170,8 +176,8 @@ static int hp_wmi_tablet_state(void)
 
  static int hp_wmi_set_block(void *data, bool blocked)
  {
-       unsigned long b = (unsigned long) data;
-       int query = BIT(b + 8) | ((!blocked) << b);
+       enum hp_wmi_radio r = (enum hp_wmi_radio) data;
+       int query = BIT(r + 8) | ((!blocked) << r);
 
        return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);
  }
@@ -180,41 +186,23 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {
        .set_block = hp_wmi_set_block,
  };
 
-static bool hp_wmi_wifi_sw_state(void)
+static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
  {
        int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+       int mask = 0x200 << (r * 8);
 
-       if (wireless & 0x200)
+       if (wireless & mask)
                return false;

       else
               return true;
 }

drivers/platform/x86/hp-wmi.c +1 -1
-static bool hp_wmi_wifi_hw_state(void)
+static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)

 {
       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+       int mask = 0x800 << (r * 8);

-       if (wireless & 0x800)
-               return false;
-       else
-               return true;

drivers/platform/x86/hp-wmi.c +1 -17
-}
-
-static bool hp_wmi_bluetooth_state(void)
-{
-       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-       if (wireless & 0x10000)
-               return false;
-       else
-               return true;
-}
-
-static bool hp_wmi_wwan_state(void)
-{
-       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-       if (wireless & 0x1000000)
+       if (wireless & mask)

               return false;
       else
               return true;

drivers/platform/x86/hp-wmi.c +60 -45
@@ -339,50 +327,55 @@ static void hp_wmi_notify(u32 value, void *context)
        struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
        static struct key_entry *key;
        union acpi_object *obj;
+       int eventcode;
 
        wmi_get_event_data(value, &response);
 
        obj = (union acpi_object *)response.pointer;
 
-       if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) {
-               int eventcode = *((u8 *) obj->buffer.pointer);
-               if (eventcode == 0x4)
-                       eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
-                                                        0);
-               key = hp_wmi_get_entry_by_scancode(eventcode);
-               if (key) {
-                       switch (key->type) {
-                       case KE_KEY:
-                               input_report_key(hp_wmi_input_dev,
-                                                key->keycode, 1);
-                               input_sync(hp_wmi_input_dev);
-                               input_report_key(hp_wmi_input_dev,
-                                                key->keycode, 0);
-                               input_sync(hp_wmi_input_dev);
-                               break;
-                       }
-               } else if (eventcode == 0x1) {
-                       input_report_switch(hp_wmi_input_dev, SW_DOCK,
-                                           hp_wmi_dock_state());
-                       input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-                                           hp_wmi_tablet_state());
+       if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
+               printk(KERN_INFO "HP WMI: Unknown response received\n");
+               return;
+       }
+
+       eventcode = *((u8 *) obj->buffer.pointer);
+       if (eventcode == 0x4)
+               eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
+                                               0);
+       key = hp_wmi_get_entry_by_scancode(eventcode);
+       if (key) {
+               switch (key->type) {
+               case KE_KEY:
+                       input_report_key(hp_wmi_input_dev,
+                                        key->keycode, 1);
+                       input_sync(hp_wmi_input_dev);
+                       input_report_key(hp_wmi_input_dev,
+                                        key->keycode, 0);
                        input_sync(hp_wmi_input_dev);
-               } else if (eventcode == 0x5) {
-                       if (wifi_rfkill)
-                               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());
-                       if (wwan_rfkill)
-                               rfkill_set_sw_state(wwan_rfkill,
-                                                   hp_wmi_wwan_state());
-               } else
-                       printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
-                              eventcode);
+                       break;
+               }
+       } else if (eventcode == 0x1) {
+               input_report_switch(hp_wmi_input_dev, SW_DOCK,
+                                   hp_wmi_dock_state());
+               input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+                                   hp_wmi_tablet_state());
+               input_sync(hp_wmi_input_dev);
+       } else if (eventcode == 0x5) {
+               if (wifi_rfkill)
+                       rfkill_set_states(wifi_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_WIFI),
+                                         hp_wmi_get_hw_state(HPWMI_WIFI));
+               if (bluetooth_rfkill)
+                       rfkill_set_states(bluetooth_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+                                         hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+               if (wwan_rfkill)
+                       rfkill_set_states(wwan_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_WWAN),
+                                         hp_wmi_get_hw_state(HPWMI_WWAN));
        } else
-               printk(KERN_INFO "HP WMI: Unknown response received\n");
+               printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
+                       eventcode);
  }
 
  static int __init hp_wmi_input_setup(void)
@@ -461,11 +454,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev,
                                           RFKILL_TYPE_WLAN,
                                           &hp_wmi_rfkill_ops,
-                                          (void *) 0);
+                                          (void *) HPWMI_WIFI);
                rfkill_init_sw_state(wifi_rfkill,
-                                    hp_wmi_wifi_sw_state());
+                                    hp_wmi_get_sw_state(HPWMI_WIFI));
                rfkill_set_hw_state(wifi_rfkill,
-                                   hp_wmi_wifi_hw_state());
+                                   hp_wmi_get_hw_state(HPWMI_WIFI));
                err = rfkill_register(wifi_rfkill);
                if (err)
                        goto register_wifi_error;
@@ -475,7 +468,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                bluetooth_rfkill = rfkill_alloc("hp-bluetooth", &device->dev,
                                                RFKILL_TYPE_BLUETOOTH,
                                                &hp_wmi_rfkill_ops,
-                                               (void *) 1);
+                                               (void *) HPWMI_BLUETOOTH);
+               rfkill_init_sw_state(bluetooth_rfkill,
+                                    hp_wmi_get_sw_state(HPWMI_BLUETOOTH));
+               rfkill_set_hw_state(bluetooth_rfkill,
+                                   hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
                err = rfkill_register(bluetooth_rfkill);
                if (err)
                        goto register_bluetooth_error;
@@ -485,7 +482,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                wwan_rfkill = rfkill_alloc("hp-wwan", &device->dev,
                                           RFKILL_TYPE_WWAN,
                                           &hp_wmi_rfkill_ops,
-                                          (void *) 2);
+                                          (void *) HPWMI_WWAN);
+               rfkill_init_sw_state(wwan_rfkill,
+                                    hp_wmi_get_sw_state(HPWMI_WWAN));
+               rfkill_set_hw_state(wwan_rfkill,
+                                   hp_wmi_get_hw_state(HPWMI_WWAN));
                err = rfkill_register(wwan_rfkill);
                if (err)
                        goto register_wwan_err;
@@ -541,9 +542,18 @@ 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());
+       if (wifi_rfkill)
+               rfkill_set_states(wifi_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_WIFI),
+                                 hp_wmi_get_hw_state(HPWMI_WIFI));
+       if (bluetooth_rfkill)

drivers/platform/x86/hp-wmi.c static int hp_wmi_resume_handler(struct platform_device *device) · line 559

Quoted 10 lines
drivers/platform/x86/hp-wmi.c +7 -0
+               rfkill_set_states(bluetooth_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+                                 hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+       if (wwan_rfkill)
+               rfkill_set_states(wwan_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_WWAN),
+                                 hp_wmi_get_hw_state(HPWMI_WWAN));
 
        return 0;
  }
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: yes
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 0
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 1
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 2
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: no
3: hci0: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 3
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: no
3: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# hciconfig
hci0:   Type: USB
        BD Address: 00:16:41:88:A0:1B ACL MTU: 1017:8 SCO MTU: 64:8
        DOWN
        RX bytes:318 acl:0 sco:0 events:6 errors:0
        TX bytes:27 acl:0 sco:0 commands:9 errors:0

Works OK. Thanks :-)

During compile I have got:
CC [M] drivers/platform/x86/hp-wmi.o drivers/platform/x86/hp-wmi.c: In function ‘hp_wmi_bios_setup’:
drivers/platform/x86/hp-wmi.c:460: warning: ignoring return value of ‘rfkill_set_hw_state’, declared with attribute warn_unused_result drivers/platform/x86/hp-wmi.c:474: warning: ignoring return value of ‘rfkill_set_hw_state’, declared with attribute warn_unused_result drivers/platform/x86/hp-wmi.c:488: warning: ignoring return value of ‘rfkill_set_hw_state’, declared with attribute warn_unused_result

root@gumis:/home/maciek# gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian
4.3.3-13' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --enable-multiarch --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-mpfr --enable-targets=all --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Debian 4.3.3-13)

Regards

Signature · 2 lines
Maciej Rutecki
http://www.maciek.unixy.pl
#13 lore raw
Quoted 319 lines · Maciej Rutecki

2009/7/20 Alan Jenkins <[email protected]>:

Quoted 3 lines

...and here's the version that remembers to register the bluetooth. I reviewed the patch again; hopefully that's the last dumb error.

[...]

2.6.31-rc3+ patches:
http://lkml.org/lkml/2009/7/18/131
http://lkml.org/lkml/2009/7/10/339
+ patch below:

Quoted 226 lines
drivers/platform/x86/hp-wmi.c +74 -71
index 517ac47..adb26d3 100644
@@ -51,6 +51,12 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
 #define HPWMI_WIRELESS_QUERY 0x5
 #define HPWMI_HOTKEY_QUERY 0xc
 
+enum hp_wmi_radio {
+       HPWMI_WIFI = 0,
+       HPWMI_BLUETOOTH = 1,
+       HPWMI_WWAN = 2,
+};
+
 static int __init hp_wmi_bios_setup(struct platform_device *device);
 static int __exit hp_wmi_bios_remove(struct platform_device *device);
 static int hp_wmi_resume_handler(struct platform_device *device);
@@ -170,8 +176,8 @@ static int hp_wmi_tablet_state(void)
 
 static int hp_wmi_set_block(void *data, bool blocked)
 {
-       unsigned long b = (unsigned long) data;
-       int query = BIT(b + 8) | ((!blocked) << b);
+       enum hp_wmi_radio r = (enum hp_wmi_radio) data;
+       int query = BIT(r + 8) | ((!blocked) << r);
 
       return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);
 }
@@ -180,41 +186,23 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {
       .set_block = hp_wmi_set_block,
 };
 
-static bool hp_wmi_wifi_sw_state(void)
+static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
 {
       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+       int mask = 0x200 << (r * 8);
 
-       if (wireless & 0x200)
+       if (wireless & mask)
               return false;
       else
               return true;
 }
 
-static bool hp_wmi_wifi_hw_state(void)
+static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)
 {
       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+       int mask = 0x800 << (r * 8);
 
-       if (wireless & 0x800)
-               return false;
-       else
-               return true;
-}
-
-static bool hp_wmi_bluetooth_state(void)
-{
-       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-       if (wireless & 0x10000)
-               return false;
-       else
-               return true;
-}
-
-static bool hp_wmi_wwan_state(void)
-{
-       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-       if (wireless & 0x1000000)
+       if (wireless & mask)
               return false;
       else
               return true;
@@ -339,50 +327,55 @@ static void hp_wmi_notify(u32 value, void *context)
       struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
       static struct key_entry *key;
       union acpi_object *obj;
+       int eventcode;
 
       wmi_get_event_data(value, &response);
 
       obj = (union acpi_object *)response.pointer;
 
-       if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) {
-               int eventcode = *((u8 *) obj->buffer.pointer);
-               if (eventcode == 0x4)
-                       eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
-                                                        0);
-               key = hp_wmi_get_entry_by_scancode(eventcode);
-               if (key) {
-                       switch (key->type) {
-                       case KE_KEY:
-                               input_report_key(hp_wmi_input_dev,
-                                                key->keycode, 1);
-                               input_sync(hp_wmi_input_dev);
-                               input_report_key(hp_wmi_input_dev,
-                                                key->keycode, 0);
-                               input_sync(hp_wmi_input_dev);
-                               break;
-                       }
-               } else if (eventcode == 0x1) {
-                       input_report_switch(hp_wmi_input_dev, SW_DOCK,
-                                           hp_wmi_dock_state());
-                       input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-                                           hp_wmi_tablet_state());
+       if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
+               printk(KERN_INFO "HP WMI: Unknown response received\n");
+               return;
+       }
+
+       eventcode = *((u8 *) obj->buffer.pointer);
+       if (eventcode == 0x4)
+               eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
+                                               0);
+       key = hp_wmi_get_entry_by_scancode(eventcode);
+       if (key) {
+               switch (key->type) {
+               case KE_KEY:
+                       input_report_key(hp_wmi_input_dev,
+                                        key->keycode, 1);
+                       input_sync(hp_wmi_input_dev);
+                       input_report_key(hp_wmi_input_dev,
+                                        key->keycode, 0);
                       input_sync(hp_wmi_input_dev);
-               } else if (eventcode == 0x5) {
-                       if (wifi_rfkill)
-                               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());
-                       if (wwan_rfkill)
-                               rfkill_set_sw_state(wwan_rfkill,
-                                                   hp_wmi_wwan_state());
-               } else
-                       printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
-                              eventcode);
+                       break;
+               }
+       } else if (eventcode == 0x1) {
+               input_report_switch(hp_wmi_input_dev, SW_DOCK,
+                                   hp_wmi_dock_state());
+               input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+                                   hp_wmi_tablet_state());
+               input_sync(hp_wmi_input_dev);
+       } else if (eventcode == 0x5) {
+               if (wifi_rfkill)
+                       rfkill_set_states(wifi_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_WIFI),
+                                         hp_wmi_get_hw_state(HPWMI_WIFI));
+               if (bluetooth_rfkill)
+                       rfkill_set_states(bluetooth_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+                                         hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+               if (wwan_rfkill)
+                       rfkill_set_states(wwan_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_WWAN),
+                                         hp_wmi_get_hw_state(HPWMI_WWAN));
       } else
-               printk(KERN_INFO "HP WMI: Unknown response received\n");
+               printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
+                       eventcode);
 }
 
 static int __init hp_wmi_input_setup(void)
@@ -461,11 +454,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
               wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev,
                                          RFKILL_TYPE_WLAN,
                                          &hp_wmi_rfkill_ops,
-                                          (void *) 0);
+                                          (void *) HPWMI_WIFI);
               rfkill_init_sw_state(wifi_rfkill,
-                                    hp_wmi_wifi_sw_state());
+                                    hp_wmi_get_sw_state(HPWMI_WIFI));
               rfkill_set_hw_state(wifi_rfkill,
-                                   hp_wmi_wifi_hw_state());
+                                   hp_wmi_get_hw_state(HPWMI_WIFI));
               err = rfkill_register(wifi_rfkill);
               if (err)
                       goto register_wifi_error;
@@ -475,7 +468,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
               bluetooth_rfkill = rfkill_alloc("hp-bluetooth", &device->dev,
                                               RFKILL_TYPE_BLUETOOTH,
                                               &hp_wmi_rfkill_ops,
-                                               (void *) 1);
+                                               (void *) HPWMI_BLUETOOTH);
+               rfkill_init_sw_state(bluetooth_rfkill,
+                                    hp_wmi_get_sw_state(HPWMI_BLUETOOTH));
+               rfkill_set_hw_state(bluetooth_rfkill,
+                                   hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
               err = rfkill_register(bluetooth_rfkill);
               if (err)
                       goto register_bluetooth_error;
@@ -485,7 +482,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
               wwan_rfkill = rfkill_alloc("hp-wwan", &device->dev,
                                          RFKILL_TYPE_WWAN,
                                          &hp_wmi_rfkill_ops,
-                                          (void *) 2);
+                                          (void *) HPWMI_WWAN);
+               rfkill_init_sw_state(wwan_rfkill,
+                                    hp_wmi_get_sw_state(HPWMI_WWAN));
+               rfkill_set_hw_state(wwan_rfkill,
+                                   hp_wmi_get_hw_state(HPWMI_WWAN));
               err = rfkill_register(wwan_rfkill);
               if (err)
                       goto register_wwan_err;
@@ -541,9 +542,18 @@ 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());
+       if (wifi_rfkill)
+               rfkill_set_states(wifi_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_WIFI),
+                                 hp_wmi_get_hw_state(HPWMI_WIFI));
+       if (bluetooth_rfkill)

drivers/platform/x86/hp-wmi.c static int hp_wmi_resume_handler(struct platform_device *device) · line 559

Quoted 10 lines
drivers/platform/x86/hp-wmi.c +7 -0
+               rfkill_set_states(bluetooth_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+                                 hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+       if (wwan_rfkill)
+               rfkill_set_states(wwan_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_WWAN),
+                                 hp_wmi_get_hw_state(HPWMI_WWAN));
 
       return 0;
 }
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: yes
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 0
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: yes
1: hp-wifi: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 1
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 2
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: no
3: hci0: Bluetooth
        Soft blocked: yes
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill unblock 3
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# ./rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
1: hp-wifi: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: hp-bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: no
3: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
root@gumis:/home/maciek/zrodelka/rfkill/rfkill# hciconfig
hci0:   Type: USB
        BD Address: 00:16:41:88:A0:1B ACL MTU: 1017:8 SCO MTU: 64:8
        DOWN
        RX bytes:318 acl:0 sco:0 events:6 errors:0
        TX bytes:27 acl:0 sco:0 commands:9 errors:0

Works OK. Thanks :-)

Quoted 10 lines

During compile I have got:
CC [M] drivers/platform/x86/hp-wmi.o drivers/platform/x86/hp-wmi.c: In function ‘hp_wmi_bios_setup’:
drivers/platform/x86/hp-wmi.c:460: warning: ignoring return value of ‘rfkill_set_hw_state’, declared with attribute warn_unused_result drivers/platform/x86/hp-wmi.c:474: warning: ignoring return value of ‘rfkill_set_hw_state’, declared with attribute warn_unused_result drivers/platform/x86/hp-wmi.c:488: warning: ignoring return value of ‘rfkill_set_hw_state’, declared with attribute warn_unused_result

The attribute is wrong, I've already submitted a patch to remove it.

I'll combine this patch with the previous one and submit it tomorrow.

Thanks again
Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

2009/7/19 Matthew Garrett <[email protected]>:

Quoted 6 lines · Maciej Rutecki
Quoted 2 lines

LED from wifi/bluetooth button sometimes flashing(!)

The LED will flash if wifi is enabled and bluetooth isn't.

Thanks. I didn't know about it.

Regards

Signature · 2 lines
Maciej Rutecki
http://www.maciek.unixy.pl