diff options
Diffstat (limited to 'drivers/misc/hp-wmi.c')
| -rw-r--r-- | drivers/misc/hp-wmi.c | 91 |
1 files changed, 54 insertions, 37 deletions
diff --git a/drivers/misc/hp-wmi.c b/drivers/misc/hp-wmi.c index 1dbcbcb323a2..6d407c2a4f91 100644 --- a/drivers/misc/hp-wmi.c +++ b/drivers/misc/hp-wmi.c | |||
| @@ -49,6 +49,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); | |||
| 49 | #define HPWMI_ALS_QUERY 0x3 | 49 | #define HPWMI_ALS_QUERY 0x3 |
| 50 | #define HPWMI_DOCK_QUERY 0x4 | 50 | #define HPWMI_DOCK_QUERY 0x4 |
| 51 | #define HPWMI_WIRELESS_QUERY 0x5 | 51 | #define HPWMI_WIRELESS_QUERY 0x5 |
| 52 | #define HPWMI_HOTKEY_QUERY 0xc | ||
| 52 | 53 | ||
| 53 | static int __init hp_wmi_bios_setup(struct platform_device *device); | 54 | static int __init hp_wmi_bios_setup(struct platform_device *device); |
| 54 | static int __exit hp_wmi_bios_remove(struct platform_device *device); | 55 | static int __exit hp_wmi_bios_remove(struct platform_device *device); |
| @@ -69,7 +70,7 @@ struct bios_return { | |||
| 69 | 70 | ||
| 70 | struct key_entry { | 71 | struct key_entry { |
| 71 | char type; /* See KE_* below */ | 72 | char type; /* See KE_* below */ |
| 72 | u8 code; | 73 | u16 code; |
| 73 | u16 keycode; | 74 | u16 keycode; |
| 74 | }; | 75 | }; |
| 75 | 76 | ||
| @@ -79,7 +80,9 @@ static struct key_entry hp_wmi_keymap[] = { | |||
| 79 | {KE_SW, 0x01, SW_DOCK}, | 80 | {KE_SW, 0x01, SW_DOCK}, |
| 80 | {KE_KEY, 0x02, KEY_BRIGHTNESSUP}, | 81 | {KE_KEY, 0x02, KEY_BRIGHTNESSUP}, |
| 81 | {KE_KEY, 0x03, KEY_BRIGHTNESSDOWN}, | 82 | {KE_KEY, 0x03, KEY_BRIGHTNESSDOWN}, |
| 82 | {KE_KEY, 0x04, KEY_HELP}, | 83 | {KE_KEY, 0x20e6, KEY_PROG1}, |
| 84 | {KE_KEY, 0x2142, KEY_MEDIA}, | ||
| 85 | {KE_KEY, 0x231b, KEY_HELP}, | ||
| 83 | {KE_END, 0} | 86 | {KE_END, 0} |
| 84 | }; | 87 | }; |
| 85 | 88 | ||
| @@ -177,9 +180,9 @@ static int hp_wmi_wifi_state(void) | |||
| 177 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | 180 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); |
| 178 | 181 | ||
| 179 | if (wireless & 0x100) | 182 | if (wireless & 0x100) |
| 180 | return 1; | 183 | return RFKILL_STATE_UNBLOCKED; |
| 181 | else | 184 | else |
| 182 | return 0; | 185 | return RFKILL_STATE_SOFT_BLOCKED; |
| 183 | } | 186 | } |
| 184 | 187 | ||
| 185 | static int hp_wmi_bluetooth_state(void) | 188 | static int hp_wmi_bluetooth_state(void) |
| @@ -187,9 +190,9 @@ static int hp_wmi_bluetooth_state(void) | |||
| 187 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | 190 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); |
| 188 | 191 | ||
| 189 | if (wireless & 0x10000) | 192 | if (wireless & 0x10000) |
| 190 | return 1; | 193 | return RFKILL_STATE_UNBLOCKED; |
| 191 | else | 194 | else |
| 192 | return 0; | 195 | return RFKILL_STATE_SOFT_BLOCKED; |
| 193 | } | 196 | } |
| 194 | 197 | ||
| 195 | static int hp_wmi_wwan_state(void) | 198 | static int hp_wmi_wwan_state(void) |
| @@ -197,9 +200,9 @@ static int hp_wmi_wwan_state(void) | |||
| 197 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | 200 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); |
| 198 | 201 | ||
| 199 | if (wireless & 0x1000000) | 202 | if (wireless & 0x1000000) |
| 200 | return 1; | 203 | return RFKILL_STATE_UNBLOCKED; |
| 201 | else | 204 | else |
| 202 | return 0; | 205 | return RFKILL_STATE_SOFT_BLOCKED; |
| 203 | } | 206 | } |
| 204 | 207 | ||
| 205 | static ssize_t show_display(struct device *dev, struct device_attribute *attr, | 208 | static ssize_t show_display(struct device *dev, struct device_attribute *attr, |
| @@ -318,6 +321,9 @@ void hp_wmi_notify(u32 value, void *context) | |||
| 318 | 321 | ||
| 319 | if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) { | 322 | if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) { |
| 320 | int eventcode = *((u8 *) obj->buffer.pointer); | 323 | int eventcode = *((u8 *) obj->buffer.pointer); |
| 324 | if (eventcode == 0x4) | ||
| 325 | eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0, | ||
| 326 | 0); | ||
| 321 | key = hp_wmi_get_entry_by_scancode(eventcode); | 327 | key = hp_wmi_get_entry_by_scancode(eventcode); |
| 322 | if (key) { | 328 | if (key) { |
| 323 | switch (key->type) { | 329 | switch (key->type) { |
| @@ -338,12 +344,14 @@ void hp_wmi_notify(u32 value, void *context) | |||
| 338 | } | 344 | } |
| 339 | } else if (eventcode == 0x5) { | 345 | } else if (eventcode == 0x5) { |
| 340 | if (wifi_rfkill) | 346 | if (wifi_rfkill) |
| 341 | wifi_rfkill->state = hp_wmi_wifi_state(); | 347 | rfkill_force_state(wifi_rfkill, |
| 348 | hp_wmi_wifi_state()); | ||
| 342 | if (bluetooth_rfkill) | 349 | if (bluetooth_rfkill) |
| 343 | bluetooth_rfkill->state = | 350 | rfkill_force_state(bluetooth_rfkill, |
| 344 | hp_wmi_bluetooth_state(); | 351 | hp_wmi_bluetooth_state()); |
| 345 | if (wwan_rfkill) | 352 | if (wwan_rfkill) |
| 346 | wwan_rfkill->state = hp_wmi_wwan_state(); | 353 | rfkill_force_state(wwan_rfkill, |
| 354 | hp_wmi_wwan_state()); | ||
| 347 | } else | 355 | } else |
| 348 | printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", | 356 | printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", |
| 349 | eventcode); | 357 | eventcode); |
| @@ -398,6 +406,7 @@ static void cleanup_sysfs(struct platform_device *device) | |||
| 398 | static int __init hp_wmi_bios_setup(struct platform_device *device) | 406 | static int __init hp_wmi_bios_setup(struct platform_device *device) |
| 399 | { | 407 | { |
| 400 | int err; | 408 | int err; |
| 409 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | ||
| 401 | 410 | ||
| 402 | err = device_create_file(&device->dev, &dev_attr_display); | 411 | err = device_create_file(&device->dev, &dev_attr_display); |
| 403 | if (err) | 412 | if (err) |
| @@ -412,28 +421,33 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) | |||
| 412 | if (err) | 421 | if (err) |
| 413 | goto add_sysfs_error; | 422 | goto add_sysfs_error; |
| 414 | 423 | ||
| 415 | wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN); | 424 | if (wireless & 0x1) { |
| 416 | wifi_rfkill->name = "hp-wifi"; | 425 | wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN); |
| 417 | wifi_rfkill->state = hp_wmi_wifi_state(); | 426 | wifi_rfkill->name = "hp-wifi"; |
| 418 | wifi_rfkill->toggle_radio = hp_wmi_wifi_set; | 427 | wifi_rfkill->state = hp_wmi_wifi_state(); |
| 419 | wifi_rfkill->user_claim_unsupported = 1; | 428 | wifi_rfkill->toggle_radio = hp_wmi_wifi_set; |
| 420 | 429 | wifi_rfkill->user_claim_unsupported = 1; | |
| 421 | bluetooth_rfkill = rfkill_allocate(&device->dev, | 430 | rfkill_register(wifi_rfkill); |
| 422 | RFKILL_TYPE_BLUETOOTH); | 431 | } |
| 423 | bluetooth_rfkill->name = "hp-bluetooth"; | 432 | |
| 424 | bluetooth_rfkill->state = hp_wmi_bluetooth_state(); | 433 | if (wireless & 0x2) { |
| 425 | bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; | 434 | bluetooth_rfkill = rfkill_allocate(&device->dev, |
| 426 | bluetooth_rfkill->user_claim_unsupported = 1; | 435 | RFKILL_TYPE_BLUETOOTH); |
| 427 | 436 | bluetooth_rfkill->name = "hp-bluetooth"; | |
| 428 | wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WIMAX); | 437 | bluetooth_rfkill->state = hp_wmi_bluetooth_state(); |
| 429 | wwan_rfkill->name = "hp-wwan"; | 438 | bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; |
| 430 | wwan_rfkill->state = hp_wmi_wwan_state(); | 439 | bluetooth_rfkill->user_claim_unsupported = 1; |
| 431 | wwan_rfkill->toggle_radio = hp_wmi_wwan_set; | 440 | rfkill_register(bluetooth_rfkill); |
| 432 | wwan_rfkill->user_claim_unsupported = 1; | 441 | } |
| 433 | 442 | ||
| 434 | rfkill_register(wifi_rfkill); | 443 | if (wireless & 0x4) { |
| 435 | rfkill_register(bluetooth_rfkill); | 444 | wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WWAN); |
| 436 | rfkill_register(wwan_rfkill); | 445 | wwan_rfkill->name = "hp-wwan"; |
| 446 | wwan_rfkill->state = hp_wmi_wwan_state(); | ||
| 447 | wwan_rfkill->toggle_radio = hp_wmi_wwan_set; | ||
| 448 | wwan_rfkill->user_claim_unsupported = 1; | ||
| 449 | rfkill_register(wwan_rfkill); | ||
| 450 | } | ||
| 437 | 451 | ||
| 438 | return 0; | 452 | return 0; |
| 439 | add_sysfs_error: | 453 | add_sysfs_error: |
| @@ -445,9 +459,12 @@ static int __exit hp_wmi_bios_remove(struct platform_device *device) | |||
| 445 | { | 459 | { |
| 446 | cleanup_sysfs(device); | 460 | cleanup_sysfs(device); |
| 447 | 461 | ||
| 448 | rfkill_unregister(wifi_rfkill); | 462 | if (wifi_rfkill) |
| 449 | rfkill_unregister(bluetooth_rfkill); | 463 | rfkill_unregister(wifi_rfkill); |
| 450 | rfkill_unregister(wwan_rfkill); | 464 | if (bluetooth_rfkill) |
| 465 | rfkill_unregister(bluetooth_rfkill); | ||
| 466 | if (wwan_rfkill) | ||
| 467 | rfkill_unregister(wwan_rfkill); | ||
| 451 | 468 | ||
| 452 | return 0; | 469 | return 0; |
| 453 | } | 470 | } |
