From a9dbcb37a45f45813fc64d672a1f7ae6135650b1 Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Sun, 6 May 2007 14:46:41 +0200 Subject: [PATCH 1/4] asus-laptop: notify ALL events We need to handle all events, because some dsdt use events >= 0x80 Signed-off-by: Corentin Chary Signed-off-by: Len Brown --- drivers/misc/asus-laptop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index 65c32a95e12..dfec565ffa8 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c @@ -950,7 +950,7 @@ static int asus_hotk_add(struct acpi_device *device) * We install the handler, it will receive the hotk in parameter, so, we * could add other data to the hotk struct */ - status = acpi_install_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY, + status = acpi_install_notify_handler(hotk->handle, ACPI_ALL_NOTIFY, asus_hotk_notify, hotk); if (ACPI_FAILURE(status)) printk(ASUS_ERR "Error installing notify handler\n"); @@ -997,7 +997,7 @@ static int asus_hotk_remove(struct acpi_device *device, int type) if (!device || !acpi_driver_data(device)) return -EINVAL; - status = acpi_remove_notify_handler(hotk->handle, ACPI_SYSTEM_NOTIFY, + status = acpi_remove_notify_handler(hotk->handle, ACPI_ALL_NOTIFY, asus_hotk_notify); if (ACPI_FAILURE(status)) printk(ASUS_ERR "Error removing notify handler\n"); From e539c2f69ca17f71dd41ba89cde67612a1326c57 Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Sun, 6 May 2007 14:47:06 +0200 Subject: [PATCH 2/4] asus-laptop: add GPS support Just adds GPS support found in R2H thanks to Sam Lin. It will make a "gps" file in /sys/devices/platform/asus-laptop/. Signed-off-by: Corentin Chary Signed-off-by: Len Brown --- drivers/misc/asus-laptop.c | 55 +++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index dfec565ffa8..f1bab721ff5 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c @@ -30,7 +30,7 @@ * Eric Burghard - LED display support for W1N * Josh Green - Light Sens support * Thomas Tuttle - His first patch for led support was very helpfull - * + * Sam Lin - GPS support */ #include @@ -83,6 +83,7 @@ #define PLED_ON 0x20 //Phone LED #define GLED_ON 0x40 //Gaming LED #define LCD_ON 0x80 //LCD backlight +#define GPS_ON 0x100 //GPS #define ASUS_LOG ASUS_HOTK_FILE ": " #define ASUS_ERR KERN_ERR ASUS_LOG @@ -162,6 +163,12 @@ ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */ ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */ +/* GPS */ +/* R2H use different handle for GPS on/off */ +ASUS_HANDLE(gps_on, ASUS_HOTK_PREFIX "SDON"); /* R2H */ +ASUS_HANDLE(gps_off, ASUS_HOTK_PREFIX "SDOF"); /* R2H */ +ASUS_HANDLE(gps_status, ASUS_HOTK_PREFIX "GPST"); + /* * This is the main structure, we can use it to store anything interesting * about the hotk device @@ -278,12 +285,27 @@ static int read_wireless_status(int mask) return (hotk->status & mask) ? 1 : 0; } +static int read_gps_status(void) { + ulong status; + acpi_status rv = AE_OK; + + rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status); + if (ACPI_FAILURE(rv)) + printk(ASUS_WARNING "Error reading GPS status\n"); + else + return status ? 1 : 0; + + return (hotk->status & GPS_ON) ? 1 : 0; +} + /* Generic LED functions */ static int read_status(int mask) { /* There is a special method for both wireless devices */ if (mask == BT_ON || mask == WL_ON) return read_wireless_status(mask); + else if(mask == GPS_ON) + return read_gps_status(); return (hotk->status & mask) ? 1 : 0; } @@ -299,6 +321,10 @@ static void write_status(acpi_handle handle, int out, int mask) case GLED_ON: out = (out & 0x1) + 1; break; + case GPS_ON: + handle = (out) ? gps_on_handle : gps_off_handle; + out = 0x02; + break; default: out &= 0x1; break; @@ -667,6 +693,21 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, return rv; } +/* + * GPS + */ +static ssize_t show_gps(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n", read_status(GPS_ON)); +} + +static ssize_t store_gps(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + return store_status(buf, count, NULL, GPS_ON); +} + static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) { /* TODO Find a better way to handle events count. */ @@ -715,6 +756,7 @@ static ASUS_CREATE_DEVICE_ATTR(display); static ASUS_CREATE_DEVICE_ATTR(ledd); static ASUS_CREATE_DEVICE_ATTR(ls_switch); static ASUS_CREATE_DEVICE_ATTR(ls_level); +static ASUS_CREATE_DEVICE_ATTR(gps); static struct attribute *asuspf_attributes[] = { &dev_attr_infos.attr, @@ -724,6 +766,7 @@ static struct attribute *asuspf_attributes[] = { &dev_attr_ledd.attr, &dev_attr_ls_switch.attr, &dev_attr_ls_level.attr, + &dev_attr_gps.attr, NULL }; @@ -763,6 +806,9 @@ static void asus_hotk_add_fs(void) ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl); ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw); } + + if(gps_status_handle && gps_on_handle && gps_off_handle) + ASUS_SET_DEVICE_ATTR(gps, 0644, show_gps, store_gps); } static int asus_handle_init(char *name, acpi_handle * handle, @@ -893,6 +939,10 @@ static int asus_hotk_get_info(void) if (ASUS_HANDLE_INIT(ls_switch)) ASUS_HANDLE_INIT(ls_level); + ASUS_HANDLE_INIT(gps_on); + ASUS_HANDLE_INIT(gps_off); + ASUS_HANDLE_INIT(gps_status); + kfree(model); return AE_OK; @@ -981,6 +1031,9 @@ static int asus_hotk_add(struct acpi_device *device) if (ls_level_handle) set_light_sens_level(hotk->light_level); + /* GPS is on by default */ + write_status(NULL, 1, GPS_ON); + end: if (result) { kfree(hotk->name); From 832d995029466e12aef66187bc9103487bf7be9f Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Sun, 6 May 2007 14:47:29 +0200 Subject: [PATCH 3/4] asus-laptop: fix light sens init Fix a stupid light sens detection bug. Signed-off-by: Corentin Chary Signed-off-by: Len Brown --- drivers/misc/asus-laptop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index f1bab721ff5..b39419cc298 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c @@ -936,7 +936,7 @@ static int asus_hotk_get_info(void) /* There is a lot of models with "ALSL", but a few get a real light sens, so we need to check it. */ - if (ASUS_HANDLE_INIT(ls_switch)) + if (!ASUS_HANDLE_INIT(ls_switch)) ASUS_HANDLE_INIT(ls_level); ASUS_HANDLE_INIT(gps_on); From f398532722b44aa797915d6b784e8694b277c2c7 Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Sun, 6 May 2007 14:48:22 +0200 Subject: [PATCH 4/4] asus-laptop: version bump and lindent Version bump, lindent, etc .. Signed-off-by: Corentin Chary Signed-off-by: Len Brown --- drivers/misc/asus-laptop.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index b39419cc298..4f9060a2a2f 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c @@ -48,7 +48,7 @@ #include #include -#define ASUS_LAPTOP_VERSION "0.41" +#define ASUS_LAPTOP_VERSION "0.42" #define ASUS_HOTK_NAME "Asus Laptop Support" #define ASUS_HOTK_CLASS "hotkey" @@ -83,7 +83,7 @@ #define PLED_ON 0x20 //Phone LED #define GLED_ON 0x40 //Gaming LED #define LCD_ON 0x80 //LCD backlight -#define GPS_ON 0x100 //GPS +#define GPS_ON 0x100 //GPS #define ASUS_LOG ASUS_HOTK_FILE ": " #define ASUS_ERR KERN_ERR ASUS_LOG @@ -149,7 +149,7 @@ ASUS_HANDLE(display_set, ASUS_HOTK_PREFIX "SDSP"); ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */ "\\_SB.PCI0.P0P2.VGA.GETD", /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V - S5A M5A z33A W1Jc W2V */ + S5A M5A z33A W1Jc W2V G1 */ "\\_SB.PCI0.P0P3.VGA.GETD", /* A6V A6Q */ "\\_SB.PCI0.P0PA.VGA.GETD", /* A6T, A6M */ "\\_SB.PCI0.PCI1.VGAC.NMAP", /* L3C */ @@ -165,8 +165,8 @@ ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */ /* GPS */ /* R2H use different handle for GPS on/off */ -ASUS_HANDLE(gps_on, ASUS_HOTK_PREFIX "SDON"); /* R2H */ -ASUS_HANDLE(gps_off, ASUS_HOTK_PREFIX "SDOF"); /* R2H */ +ASUS_HANDLE(gps_on, ASUS_HOTK_PREFIX "SDON"); /* R2H */ +ASUS_HANDLE(gps_off, ASUS_HOTK_PREFIX "SDOF"); /* R2H */ ASUS_HANDLE(gps_status, ASUS_HOTK_PREFIX "GPST"); /* @@ -285,17 +285,18 @@ static int read_wireless_status(int mask) return (hotk->status & mask) ? 1 : 0; } -static int read_gps_status(void) { - ulong status; +static int read_gps_status(void) +{ + ulong status; acpi_status rv = AE_OK; rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status); if (ACPI_FAILURE(rv)) - printk(ASUS_WARNING "Error reading GPS status\n"); + printk(ASUS_WARNING "Error reading GPS status\n"); else - return status ? 1 : 0; + return status ? 1 : 0; - return (hotk->status & GPS_ON) ? 1 : 0; + return (hotk->status & GPS_ON) ? 1 : 0; } /* Generic LED functions */ @@ -304,8 +305,8 @@ static int read_status(int mask) /* There is a special method for both wireless devices */ if (mask == BT_ON || mask == WL_ON) return read_wireless_status(mask); - else if(mask == GPS_ON) - return read_gps_status(); + else if (mask == GPS_ON) + return read_gps_status(); return (hotk->status & mask) ? 1 : 0; } @@ -705,7 +706,7 @@ static ssize_t show_gps(struct device *dev, static ssize_t store_gps(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - return store_status(buf, count, NULL, GPS_ON); + return store_status(buf, count, NULL, GPS_ON); } static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) @@ -807,7 +808,7 @@ static void asus_hotk_add_fs(void) ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw); } - if(gps_status_handle && gps_on_handle && gps_off_handle) + if (gps_status_handle && gps_on_handle && gps_off_handle) ASUS_SET_DEVICE_ATTR(gps, 0644, show_gps, store_gps); }