* [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop)
@ 2009-01-20 15:17 Corentin Chary
2009-01-20 15:17 ` [PATCH 01/10] eeepc-laptop: split eeepc_backlight_exit() Corentin Chary
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Corentin Chary
Hi len,
Here is a group of update for asus related platform drivers.
You can also pull git://git.iksaif.net/acpi4asus.git acpi4asus
Thanks
Corentin Chary (7):
eeepc-laptop: split eeepc_backlight_exit()
asus_acpi: Add R1F support
asus-laptop: use generic netlink interface
asus-laptop: hotkeys via the generic input interface
asus-laptop: update Kconfig for input layer
asus-laptop: fix label indentation
eeepc-laptop: use netlink interface
Matthew Garrett (3):
eeepc-laptop: Add support for extended hotkeys
eeepc-laptop: Check return values from rfkill_register
eeepc-laptop: Implement rfkill hotplugging in eeepc-laptop
drivers/platform/x86/Kconfig | 1 +
drivers/platform/x86/asus-laptop.c | 176 ++++++++++++++++++++++++++++++++--
drivers/platform/x86/asus_acpi.c | 16 +++-
drivers/platform/x86/eeepc-laptop.c | 161 ++++++++++++++++++++++++++++----
4 files changed, 323 insertions(+), 31 deletions(-)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 01/10] eeepc-laptop: split eeepc_backlight_exit()
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 02/10] asus_acpi: Add R1F support Corentin Chary
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Corentin Chary
eeepc_backlight_exit() was doing rfkill and input stuff, which
is a nonsense. This patch add two specific exit functions, one
for input and one for rfkill.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/eeepc-laptop.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 9d93cb9..66d611b 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -737,13 +737,21 @@ static void eeepc_backlight_exit(void)
{
if (eeepc_backlight_device)
backlight_device_unregister(eeepc_backlight_device);
- if (ehotk->inputdev)
- input_unregister_device(ehotk->inputdev);
+ eeepc_backlight_device = NULL;
+}
+
+static void eeepc_rfkill_exit(void)
+{
if (ehotk->eeepc_wlan_rfkill)
rfkill_unregister(ehotk->eeepc_wlan_rfkill);
if (ehotk->eeepc_bluetooth_rfkill)
rfkill_unregister(ehotk->eeepc_bluetooth_rfkill);
- eeepc_backlight_device = NULL;
+}
+
+static void eeepc_input_exit(void)
+{
+ if (ehotk->inputdev)
+ input_unregister_device(ehotk->inputdev);
}
static void eeepc_hwmon_exit(void)
@@ -762,6 +770,8 @@ static void eeepc_hwmon_exit(void)
static void __exit eeepc_laptop_exit(void)
{
eeepc_backlight_exit();
+ eeepc_rfkill_exit();
+ eeepc_input_exit();
eeepc_hwmon_exit();
acpi_bus_unregister_driver(&eeepc_hotk_driver);
sysfs_remove_group(&platform_device->dev.kobj,
@@ -865,6 +875,8 @@ fail_platform_driver:
fail_hwmon:
eeepc_backlight_exit();
fail_backlight:
+ eeepc_input_exit();
+ eeepc_rfkill_exit();
return result;
}
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 02/10] asus_acpi: Add R1F support
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
2009-01-20 15:17 ` [PATCH 01/10] eeepc-laptop: split eeepc_backlight_exit() Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 03/10] asus-laptop: use generic netlink interface Corentin Chary
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Corentin Chary
Add R1F support
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/asus_acpi.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c
index 1e74988..d63f26e 100644
--- a/drivers/platform/x86/asus_acpi.c
+++ b/drivers/platform/x86/asus_acpi.c
@@ -143,6 +143,7 @@ struct asus_hotk {
S1300N, S5200N*/
A4S, /* Z81sp */
F3Sa, /* (Centrino) */
+ R1F,
END_MODEL
} model; /* Models currently supported */
u16 event_count[128]; /* Count for each event TODO make this better */
@@ -420,7 +421,18 @@ static struct model_data model_conf[END_MODEL] = {
.display_get = "\\ADVG",
.display_set = "SDSP",
},
-
+ {
+ .name = "R1F",
+ .mt_bt_switch = "BLED",
+ .mt_mled = "MLED",
+ .mt_wled = "WLED",
+ .mt_lcd_switch = "\\Q10",
+ .lcd_status = "\\GP06",
+ .brightness_set = "SPLV",
+ .brightness_get = "GPLV",
+ .display_set = "SDSP",
+ .display_get = "\\INFB"
+ }
};
/* procdir we use */
@@ -1165,6 +1177,8 @@ static int asus_model_match(char *model)
return W3V;
else if (strncmp(model, "W5A", 3) == 0)
return W5A;
+ else if (strncmp(model, "R1F", 3) == 0)
+ return R1F;
else if (strncmp(model, "A4S", 3) == 0)
return A4S;
else if (strncmp(model, "F3Sa", 4) == 0)
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 03/10] asus-laptop: use generic netlink interface
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
2009-01-20 15:17 ` [PATCH 01/10] eeepc-laptop: split eeepc_backlight_exit() Corentin Chary
2009-01-20 15:17 ` [PATCH 02/10] asus_acpi: Add R1F support Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 04/10] asus-laptop: hotkeys via the generic input interface Corentin Chary
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Corentin Chary
To be prepared for /proc/acpi/event removal we export events
also through generic netlink interface.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/asus-laptop.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 8fb8b35..1b7a28c 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -738,8 +738,9 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
lcd_blank(FB_BLANK_POWERDOWN);
}
- acpi_bus_generate_proc_event(hotk->device, event,
- hotk->event_count[event % 128]++);
+ acpi_bus_generate_netlink_event(hotk->device->pnp.device_class,
+ dev_name(&hotk->device->dev), event,
+ hotk->event_count[event % 128]++);
return;
}
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 04/10] asus-laptop: hotkeys via the generic input interface
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
` (2 preceding siblings ...)
2009-01-20 15:17 ` [PATCH 03/10] asus-laptop: use generic netlink interface Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 05/10] asus-laptop: update Kconfig for input layer Corentin Chary
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Corentin Chary
This patch is based on eeepc-laptop.c and the patchs
from Nicolas Trangez and Daniel Nascimento (mainly for the keymap).
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/asus-laptop.c | 155 +++++++++++++++++++++++++++++++++++-
1 files changed, 154 insertions(+), 1 deletions(-)
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 1b7a28c..53dbfb4 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -46,6 +46,7 @@
#include <acpi/acpi_drivers.h>
#include <acpi/acpi_bus.h>
#include <asm/uaccess.h>
+#include <linux/input.h>
#define ASUS_LAPTOP_VERSION "0.42"
@@ -181,6 +182,8 @@ struct asus_hotk {
u8 light_level; //light sensor level
u8 light_switch; //light sensor switch value
u16 event_count[128]; //count for each event TODO make this better
+ struct input_dev *inputdev;
+ u16 *keycode_map;
};
/*
@@ -250,6 +253,37 @@ ASUS_LED(rled, "record");
ASUS_LED(pled, "phone");
ASUS_LED(gled, "gaming");
+struct key_entry {
+ char type;
+ u8 code;
+ u16 keycode;
+};
+
+enum { KE_KEY, KE_END };
+
+static struct key_entry asus_keymap[] = {
+ {KE_KEY, 0x30, KEY_VOLUMEUP},
+ {KE_KEY, 0x31, KEY_VOLUMEDOWN},
+ {KE_KEY, 0x32, KEY_MUTE},
+ {KE_KEY, 0x33, KEY_SWITCHVIDEOMODE},
+ {KE_KEY, 0x34, KEY_SWITCHVIDEOMODE},
+ {KE_KEY, 0x40, KEY_PREVIOUSSONG},
+ {KE_KEY, 0x41, KEY_NEXTSONG},
+ {KE_KEY, 0x43, KEY_STOP},
+ {KE_KEY, 0x45, KEY_PLAYPAUSE},
+ {KE_KEY, 0x50, KEY_EMAIL},
+ {KE_KEY, 0x51, KEY_WWW},
+ {KE_KEY, 0x5C, BTN_EXTRA}, /* Performance */
+ {KE_KEY, 0x5D, KEY_WLAN},
+ {KE_KEY, 0x61, KEY_SWITCHVIDEOMODE},
+ {KE_KEY, 0x6B, BTN_TOUCH}, /* Lock Mouse */
+ {KE_KEY, 0x82, KEY_CAMERA},
+ {KE_KEY, 0x8A, KEY_TV},
+ {KE_KEY, 0x95, KEY_MEDIA},
+ {KE_KEY, 0x99, KEY_PHONE},
+ {KE_END, 0},
+};
+
/*
* This function evaluates an ACPI method, given an int as parameter, the
* method is searched within the scope of the handle, can be NULL. The output
@@ -720,8 +754,68 @@ static ssize_t store_gps(struct device *dev, struct device_attribute *attr,
return store_status(buf, count, NULL, GPS_ON);
}
+/*
+ * Hotkey functions
+ */
+static struct key_entry *asus_get_entry_by_scancode(int code)
+{
+ struct key_entry *key;
+
+ for (key = asus_keymap; key->type != KE_END; key++)
+ if (code == key->code)
+ return key;
+
+ return NULL;
+}
+
+static struct key_entry *asus_get_entry_by_keycode(int code)
+{
+ struct key_entry *key;
+
+ for (key = asus_keymap; key->type != KE_END; key++)
+ if (code == key->keycode && key->type == KE_KEY)
+ return key;
+
+ return NULL;
+}
+
+static int asus_getkeycode(struct input_dev *dev, int scancode, int *keycode)
+{
+ struct key_entry *key = asus_get_entry_by_scancode(scancode);
+
+ if (key && key->type == KE_KEY) {
+ *keycode = key->keycode;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+static int asus_setkeycode(struct input_dev *dev, int scancode, int keycode)
+{
+ struct key_entry *key;
+ int old_keycode;
+
+ if (keycode < 0 || keycode > KEY_MAX)
+ return -EINVAL;
+
+ key = asus_get_entry_by_scancode(scancode);
+ if (key && key->type == KE_KEY) {
+ old_keycode = key->keycode;
+ key->keycode = keycode;
+ set_bit(keycode, dev->keybit);
+ if (!asus_get_entry_by_keycode(old_keycode))
+ clear_bit(old_keycode, dev->keybit);
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
{
+ static struct key_entry *key;
+
/* TODO Find a better way to handle events count. */
if (!hotk)
return;
@@ -742,7 +836,20 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
dev_name(&hotk->device->dev), event,
hotk->event_count[event % 128]++);
- return;
+ if (hotk->inputdev) {
+ key = asus_get_entry_by_scancode(event);
+ if (!key)
+ return ;
+
+ switch (key->type) {
+ case KE_KEY:
+ input_report_key(hotk->inputdev, key->keycode, 1);
+ input_sync(hotk->inputdev);
+ input_report_key(hotk->inputdev, key->keycode, 0);
+ input_sync(hotk->inputdev);
+ break;
+ }
+ }
}
#define ASUS_CREATE_DEVICE_ATTR(_name) \
@@ -960,6 +1067,38 @@ static int asus_hotk_get_info(void)
return AE_OK;
}
+static int asus_input_init(void)
+{
+ const struct key_entry *key;
+ int result;
+
+ hotk->inputdev = input_allocate_device();
+ if (!hotk->inputdev) {
+ printk(ASUS_INFO "Unable to allocate input device\n");
+ return 0;
+ }
+ hotk->inputdev->name = "Asus Laptop extra buttons";
+ hotk->inputdev->phys = ASUS_HOTK_FILE "/input0";
+ hotk->inputdev->id.bustype = BUS_HOST;
+ hotk->inputdev->getkeycode = asus_getkeycode;
+ hotk->inputdev->setkeycode = asus_setkeycode;
+
+ for (key = asus_keymap; key->type != KE_END; key++) {
+ switch (key->type) {
+ case KE_KEY:
+ set_bit(EV_KEY, hotk->inputdev->evbit);
+ set_bit(key->keycode, hotk->inputdev->keybit);
+ break;
+ }
+ }
+ result = input_register_device(hotk->inputdev);
+ if (result) {
+ printk(ASUS_INFO "Unable to register input device\n");
+ input_free_device(hotk->inputdev);
+ }
+ return result;
+}
+
static int asus_hotk_check(void)
{
int result = 0;
@@ -1092,10 +1231,17 @@ static void asus_led_exit(void)
ASUS_LED_UNREGISTER(gled);
}
+static void asus_input_exit(void)
+{
+ if (hotk->inputdev)
+ input_unregister_device(hotk->inputdev);
+}
+
static void __exit asus_laptop_exit(void)
{
asus_backlight_exit();
asus_led_exit();
+ asus_input_exit();
acpi_bus_unregister_driver(&asus_hotk_driver);
sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group);
@@ -1217,6 +1363,10 @@ static int __init asus_laptop_init(void)
printk(ASUS_INFO "Brightness ignored, must be controlled by "
"ACPI video driver\n");
+ result = asus_input_init();
+ if (result)
+ goto fail_input;
+
result = asus_led_init(dev);
if (result)
goto fail_led;
@@ -1256,6 +1406,9 @@ static int __init asus_laptop_init(void)
asus_led_exit();
fail_led:
+ asus_input_exit();
+
+ fail_input:
asus_backlight_exit();
fail_backlight:
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 05/10] asus-laptop: update Kconfig for input layer
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
` (3 preceding siblings ...)
2009-01-20 15:17 ` [PATCH 04/10] asus-laptop: hotkeys via the generic input interface Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 06/10] asus-laptop: fix label indentation Corentin Chary
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Corentin Chary
Update Kconfig, now asus-laptop use the input layer.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/Kconfig | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 1a266d4..9436311 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -42,6 +42,7 @@ config ASUS_LAPTOP
depends on LEDS_CLASS
depends on NEW_LEDS
depends on BACKLIGHT_CLASS_DEVICE
+ depends on INPUT
---help---
This is the new Linux driver for Asus laptops. It may also support some
MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 06/10] asus-laptop: fix label indentation
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
` (4 preceding siblings ...)
2009-01-20 15:17 ` [PATCH 05/10] asus-laptop: update Kconfig for input layer Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 07/10] eeepc-laptop: Add support for extended hotkeys Corentin Chary
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Corentin Chary
Fix the label indentation
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/asus-laptop.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 53dbfb4..56af6cf 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1184,7 +1184,7 @@ static int asus_hotk_add(struct acpi_device *device)
/* GPS is on by default */
write_status(NULL, 1, GPS_ON);
- end:
+end:
if (result) {
kfree(hotk->name);
kfree(hotk);
@@ -1393,25 +1393,25 @@ static int __init asus_laptop_init(void)
return 0;
- fail_sysfs:
+fail_sysfs:
platform_device_del(asuspf_device);
- fail_platform_device2:
+fail_platform_device2:
platform_device_put(asuspf_device);
- fail_platform_device1:
+fail_platform_device1:
platform_driver_unregister(&asuspf_driver);
- fail_platform_driver:
+fail_platform_driver:
asus_led_exit();
- fail_led:
+fail_led:
asus_input_exit();
- fail_input:
+fail_input:
asus_backlight_exit();
- fail_backlight:
+fail_backlight:
return result;
}
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 07/10] eeepc-laptop: Add support for extended hotkeys
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
` (5 preceding siblings ...)
2009-01-20 15:17 ` [PATCH 06/10] asus-laptop: fix label indentation Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 08/10] eeepc-laptop: Check return values from rfkill_register Corentin Chary
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Matthew Garrett, Matthew Garrett, Corentin Chary
From: Matthew Garrett <mjg59@srcf.ucam.org>
Newer Eees have extra hotkeys above the function keys. This patch adds support
for sending them through the input layer.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/eeepc-laptop.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 66d611b..d153871 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -161,6 +161,10 @@ static struct key_entry eeepc_keymap[] = {
{KE_KEY, 0x13, KEY_MUTE },
{KE_KEY, 0x14, KEY_VOLUMEDOWN },
{KE_KEY, 0x15, KEY_VOLUMEUP },
+ {KE_KEY, 0x1a, KEY_COFFEE },
+ {KE_KEY, 0x1b, KEY_ZOOM },
+ {KE_KEY, 0x1c, KEY_PROG2 },
+ {KE_KEY, 0x1d, KEY_PROG3 },
{KE_KEY, 0x30, KEY_SWITCHVIDEOMODE },
{KE_KEY, 0x31, KEY_SWITCHVIDEOMODE },
{KE_KEY, 0x32, KEY_SWITCHVIDEOMODE },
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 08/10] eeepc-laptop: Check return values from rfkill_register
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
` (6 preceding siblings ...)
2009-01-20 15:17 ` [PATCH 07/10] eeepc-laptop: Add support for extended hotkeys Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 09/10] eeepc-laptop: Implement rfkill hotplugging in eeepc-laptop Corentin Chary
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Matthew Garrett, Matthew Garrett, Corentin Chary
From: Matthew Garrett <mjg59@srcf.ucam.org>
Error out if rfkill registration fails, and also set the default system state
appropriately on boot
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/eeepc-laptop.c | 51 +++++++++++++++++++++++++---------
1 files changed, 37 insertions(+), 14 deletions(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index d153871..21e5206 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -562,7 +562,7 @@ static int eeepc_hotk_add(struct acpi_device *device)
ehotk->device = device;
result = eeepc_hotk_check();
if (result)
- goto end;
+ goto ehotk_fail;
status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY,
eeepc_hotk_notify, ehotk);
if (ACPI_FAILURE(status))
@@ -573,18 +573,25 @@ static int eeepc_hotk_add(struct acpi_device *device)
RFKILL_TYPE_WLAN);
if (!ehotk->eeepc_wlan_rfkill)
- goto end;
+ goto wlan_fail;
ehotk->eeepc_wlan_rfkill->name = "eeepc-wlan";
ehotk->eeepc_wlan_rfkill->toggle_radio = eeepc_wlan_rfkill_set;
ehotk->eeepc_wlan_rfkill->get_state = eeepc_wlan_rfkill_state;
- if (get_acpi(CM_ASL_WLAN) == 1)
+ if (get_acpi(CM_ASL_WLAN) == 1) {
ehotk->eeepc_wlan_rfkill->state =
RFKILL_STATE_UNBLOCKED;
- else
+ rfkill_set_default(RFKILL_TYPE_WLAN,
+ RFKILL_STATE_UNBLOCKED);
+ } else {
ehotk->eeepc_wlan_rfkill->state =
RFKILL_STATE_SOFT_BLOCKED;
- rfkill_register(ehotk->eeepc_wlan_rfkill);
+ rfkill_set_default(RFKILL_TYPE_WLAN,
+ RFKILL_STATE_SOFT_BLOCKED);
+ }
+ result = rfkill_register(ehotk->eeepc_wlan_rfkill);
+ if (result)
+ goto wlan_fail;
}
if (get_acpi(CM_ASL_BLUETOOTH) != -1) {
@@ -592,27 +599,43 @@ static int eeepc_hotk_add(struct acpi_device *device)
rfkill_allocate(&device->dev, RFKILL_TYPE_BLUETOOTH);
if (!ehotk->eeepc_bluetooth_rfkill)
- goto end;
+ goto bluetooth_fail;
ehotk->eeepc_bluetooth_rfkill->name = "eeepc-bluetooth";
ehotk->eeepc_bluetooth_rfkill->toggle_radio =
eeepc_bluetooth_rfkill_set;
ehotk->eeepc_bluetooth_rfkill->get_state =
eeepc_bluetooth_rfkill_state;
- if (get_acpi(CM_ASL_BLUETOOTH) == 1)
+ if (get_acpi(CM_ASL_BLUETOOTH) == 1) {
ehotk->eeepc_bluetooth_rfkill->state =
RFKILL_STATE_UNBLOCKED;
- else
+ rfkill_set_default(RFKILL_TYPE_BLUETOOTH,
+ RFKILL_STATE_UNBLOCKED);
+ } else {
ehotk->eeepc_bluetooth_rfkill->state =
RFKILL_STATE_SOFT_BLOCKED;
- rfkill_register(ehotk->eeepc_bluetooth_rfkill);
- }
+ rfkill_set_default(RFKILL_TYPE_BLUETOOTH,
+ RFKILL_STATE_SOFT_BLOCKED);
+ }
- end:
- if (result) {
- kfree(ehotk);
- ehotk = NULL;
+ result = rfkill_register(ehotk->eeepc_bluetooth_rfkill);
+ if (result)
+ goto bluetooth_fail;
}
+ return 0;
+
+ bluetooth_fail:
+ if (ehotk->eeepc_bluetooth_rfkill)
+ rfkill_free(ehotk->eeepc_bluetooth_rfkill);
+ rfkill_unregister(ehotk->eeepc_wlan_rfkill);
+ ehotk->eeepc_wlan_rfkill = NULL;
+ wlan_fail:
+ if (ehotk->eeepc_wlan_rfkill)
+ rfkill_free(ehotk->eeepc_wlan_rfkill);
+ ehotk_fail:
+ kfree(ehotk);
+ ehotk = NULL;
+
return result;
}
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 09/10] eeepc-laptop: Implement rfkill hotplugging in eeepc-laptop
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
` (7 preceding siblings ...)
2009-01-20 15:17 ` [PATCH 08/10] eeepc-laptop: Check return values from rfkill_register Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 15:17 ` [PATCH 10/10] eeepc-laptop: use netlink interface Corentin Chary
2009-01-20 19:41 ` [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Len Brown
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Matthew Garrett, Corentin Chary
From: Matthew Garrett <mjg@redhat.com>
The Eee implements rfkill by logically unplugging the wireless card from the
PCI bus. Despite sending ACPI notifications, this does not appear to be
implemented using standard ACPI hotplug - nor does the firmware provide the
_OSC method required to support native PCIe hotplug. The only sensible choice
appears to be to handle the hotplugging directly in the eeepc-laptop driver.
Tested successfully on a 700, 900 and 901.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/eeepc-laptop.c | 83 +++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 21e5206..66655d2 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -30,6 +30,7 @@
#include <linux/uaccess.h>
#include <linux/input.h>
#include <linux/rfkill.h>
+#include <linux/pci.h>
#define EEEPC_LAPTOP_VERSION "0.1"
@@ -517,6 +518,41 @@ static void notify_brn(void)
bd->props.brightness = read_brightness(bd);
}
+static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
+{
+ struct pci_dev *dev;
+ struct pci_bus *bus = pci_find_bus(0, 1);
+
+ if (event != ACPI_NOTIFY_BUS_CHECK)
+ return;
+
+ if (!bus) {
+ printk(EEEPC_WARNING "Unable to find PCI bus 1?\n");
+ return;
+ }
+
+ if (get_acpi(CM_ASL_WLAN) == 1) {
+ dev = pci_get_slot(bus, 0);
+ if (dev) {
+ /* Device already present */
+ pci_dev_put(dev);
+ return;
+ }
+ dev = pci_scan_single_device(bus, 0);
+ if (dev) {
+ pci_bus_assign_resources(bus);
+ if (pci_bus_add_device(dev))
+ printk(EEEPC_ERR "Unable to hotplug wifi\n");
+ }
+ } else {
+ dev = pci_get_slot(bus, 0);
+ if (dev) {
+ pci_remove_bus_device(dev);
+ pci_dev_put(dev);
+ }
+ }
+}
+
static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
{
static struct key_entry *key;
@@ -543,6 +579,45 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
}
}
+static int eeepc_register_rfkill_notifier(char *node)
+{
+ acpi_status status = AE_OK;
+ acpi_handle handle;
+
+ status = acpi_get_handle(NULL, node, &handle);
+
+ if (ACPI_SUCCESS(status)) {
+ status = acpi_install_notify_handler(handle,
+ ACPI_SYSTEM_NOTIFY,
+ eeepc_rfkill_notify,
+ NULL);
+ if (ACPI_FAILURE(status))
+ printk(EEEPC_WARNING
+ "Failed to register notify on %s\n", node);
+ } else
+ return -ENODEV;
+
+ return 0;
+}
+
+static void eeepc_unregister_rfkill_notifier(char *node)
+{
+ acpi_status status = AE_OK;
+ acpi_handle handle;
+
+ status = acpi_get_handle(NULL, node, &handle);
+
+ if (ACPI_SUCCESS(status)) {
+ status = acpi_remove_notify_handler(handle,
+ ACPI_SYSTEM_NOTIFY,
+ eeepc_rfkill_notify);
+ if (ACPI_FAILURE(status))
+ printk(EEEPC_ERR
+ "Error removing rfkill notify handler %s\n",
+ node);
+ }
+}
+
static int eeepc_hotk_add(struct acpi_device *device)
{
acpi_status status = AE_OK;
@@ -622,6 +697,10 @@ static int eeepc_hotk_add(struct acpi_device *device)
if (result)
goto bluetooth_fail;
}
+
+ eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6");
+ eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7");
+
return 0;
bluetooth_fail:
@@ -649,6 +728,10 @@ static int eeepc_hotk_remove(struct acpi_device *device, int type)
eeepc_hotk_notify);
if (ACPI_FAILURE(status))
printk(EEEPC_ERR "Error removing notify handler\n");
+
+ eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
+ eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
+
kfree(ehotk);
return 0;
}
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 10/10] eeepc-laptop: use netlink interface
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
` (8 preceding siblings ...)
2009-01-20 15:17 ` [PATCH 09/10] eeepc-laptop: Implement rfkill hotplugging in eeepc-laptop Corentin Chary
@ 2009-01-20 15:17 ` Corentin Chary
2009-01-20 19:41 ` [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Len Brown
10 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2009-01-20 15:17 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, Corentin Chary
To be prepared for /proc/acpi/event removal we export events
also through generic netlink interface.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
drivers/platform/x86/eeepc-laptop.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 66655d2..4348d99 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -560,8 +560,9 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
return;
if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
notify_brn();
- acpi_bus_generate_proc_event(ehotk->device, event,
- ehotk->event_count[event % 128]++);
+ acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class,
+ dev_name(&ehotk->device->dev), event,
+ ehotk->event_count[event % 128]++);
if (ehotk->inputdev) {
key = eepc_get_entry_by_scancode(event);
if (key) {
--
1.6.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop)
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
` (9 preceding siblings ...)
2009-01-20 15:17 ` [PATCH 10/10] eeepc-laptop: use netlink interface Corentin Chary
@ 2009-01-20 19:41 ` Len Brown
10 siblings, 0 replies; 12+ messages in thread
From: Len Brown @ 2009-01-20 19:41 UTC (permalink / raw)
To: Corentin Chary; +Cc: linux-acpi
Thanks for the refresh Corentin. I've checked these into the ACPI tree.
Given that they are driver specific, I think I'll ask forgivness
for missing the merge window and submit them for upstream with
the next batch.
--
Len Brown, Intel Open Source Technology Center
On Tue, 20 Jan 2009, Corentin Chary wrote:
> Hi len,
> Here is a group of update for asus related platform drivers.
> You can also pull git://git.iksaif.net/acpi4asus.git acpi4asus
> Thanks
>
> Corentin Chary (7):
> eeepc-laptop: split eeepc_backlight_exit()
> asus_acpi: Add R1F support
> asus-laptop: use generic netlink interface
> asus-laptop: hotkeys via the generic input interface
> asus-laptop: update Kconfig for input layer
> asus-laptop: fix label indentation
> eeepc-laptop: use netlink interface
>
> Matthew Garrett (3):
> eeepc-laptop: Add support for extended hotkeys
> eeepc-laptop: Check return values from rfkill_register
> eeepc-laptop: Implement rfkill hotplugging in eeepc-laptop
>
> drivers/platform/x86/Kconfig | 1 +
> drivers/platform/x86/asus-laptop.c | 176 ++++++++++++++++++++++++++++++++--
> drivers/platform/x86/asus_acpi.c | 16 +++-
> drivers/platform/x86/eeepc-laptop.c | 161 ++++++++++++++++++++++++++++----
> 4 files changed, 323 insertions(+), 31 deletions(-)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-01-20 19:41 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-20 15:17 [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Corentin Chary
2009-01-20 15:17 ` [PATCH 01/10] eeepc-laptop: split eeepc_backlight_exit() Corentin Chary
2009-01-20 15:17 ` [PATCH 02/10] asus_acpi: Add R1F support Corentin Chary
2009-01-20 15:17 ` [PATCH 03/10] asus-laptop: use generic netlink interface Corentin Chary
2009-01-20 15:17 ` [PATCH 04/10] asus-laptop: hotkeys via the generic input interface Corentin Chary
2009-01-20 15:17 ` [PATCH 05/10] asus-laptop: update Kconfig for input layer Corentin Chary
2009-01-20 15:17 ` [PATCH 06/10] asus-laptop: fix label indentation Corentin Chary
2009-01-20 15:17 ` [PATCH 07/10] eeepc-laptop: Add support for extended hotkeys Corentin Chary
2009-01-20 15:17 ` [PATCH 08/10] eeepc-laptop: Check return values from rfkill_register Corentin Chary
2009-01-20 15:17 ` [PATCH 09/10] eeepc-laptop: Implement rfkill hotplugging in eeepc-laptop Corentin Chary
2009-01-20 15:17 ` [PATCH 10/10] eeepc-laptop: use netlink interface Corentin Chary
2009-01-20 19:41 ` [PATCH 00/10] acpi4asus updates (eeepc-laptop, asus_acpi and asus-laptop) Len Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox