* [PATCH 1/5] asus-laptop use acpi_evaluate_integer instead of read_acpi_int
2007-03-11 9:23 [PATCH 0/5] asus-laptop cleanups, bugfix and features Corentin CHARY
@ 2007-03-11 9:25 ` Corentin CHARY
2007-03-11 9:26 ` [PATCH 2/5] asus-laptop clean write_status Corentin CHARY
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Corentin CHARY @ 2007-03-11 9:25 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, acpi4asus-user
From: Corentin Chary <corentincj@iksaif.net>
Use acpi_evaluate_integer() instead of read_acpi_int()
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
asus-laptop.c | 68 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 34 insertions(+), 34 deletions(-)
--- a/drivers/misc/asus-laptop.c 2007-03-10 15:52:25.000000000 +0100
+++ b/drivers/misc/asus-laptop.c 2007-03-10 16:16:18.000000000 +0100
@@ -245,32 +245,19 @@
return (status == AE_OK);
}
-static int read_acpi_int(acpi_handle handle, const char *method, int *val,
- struct acpi_object_list *params)
-{
- struct acpi_buffer output;
- union acpi_object out_obj;
- acpi_status status;
-
- output.length = sizeof(out_obj);
- output.pointer = &out_obj;
-
- status = acpi_evaluate_object(handle, (char *)method, params, &output);
- *val = out_obj.integer.value;
- return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
-}
-
static int read_wireless_status(int mask)
{
- int status;
+ ulong status;
+ acpi_status rv = AE_OK;
if (!wireless_status_handle)
return (hotk->status & mask) ? 1 : 0;
- if (read_acpi_int(wireless_status_handle, NULL, &status, NULL)) {
- return (status & mask) ? 1 : 0;
- } else
+ rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status);
+ if (ACPI_FAILURE(rv))
printk(ASUS_WARNING "Error reading Wireless status\n");
+ else
+ return (status & mask) ? 1 : 0;
return (hotk->status & mask) ? 1 : 0;
}
@@ -354,9 +341,11 @@
static int read_brightness(struct backlight_device *bd)
{
- int value;
+ ulong value;
+ acpi_status rv = AE_OK;
- if (!read_acpi_int(brightness_get_handle, NULL, &value, NULL))
+ rv = acpi_evaluate_integer(brightness_get_handle, NULL, NULL, &value);
+ if (ACPI_FAILURE(rv))
printk(ASUS_WARNING "Error reading brightness\n");
return value;
@@ -403,8 +392,10 @@
struct device_attribute *attr, char *page)
{
int len = 0;
- int temp;
+ ulong temp;
char buf[16]; //enough for all info
+ acpi_status rv = AE_OK;
+
/*
* We use the easy way, we don't care of off and count, so we don't set eof
* to 1
@@ -418,9 +409,10 @@
* bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card.
* The significance of others is yet to be found.
*/
- if (read_acpi_int(hotk->handle, "SFUN", &temp, NULL))
- len +=
- sprintf(page + len, "SFUN value : 0x%04x\n", temp);
+ rv = acpi_evaluate_integer(hotk->handle, "SFUN", NULL, &temp);
+ if (!ACPI_FAILURE(rv))
+ len += sprintf(page + len, "SFUN value : 0x%04x\n",
+ (uint) temp);
/*
* Another value for userspace: the ASYM method returns 0x02 for
* battery low and 0x04 for battery critical, its readings tend to be
@@ -428,9 +420,10 @@
* Note: since not all the laptops provide this method, errors are
* silently ignored.
*/
- if (read_acpi_int(hotk->handle, "ASYM", &temp, NULL))
- len +=
- sprintf(page + len, "ASYM value : 0x%04x\n", temp);
+ rv = acpi_evaluate_integer(hotk->handle, "ASYM", NULL, &temp);
+ if (!ACPI_FAILURE(rv))
+ len += sprintf(page + len, "ASYM value : 0x%04x\n",
+ (uint) temp);
if (asus_info) {
snprintf(buf, 16, "%d", asus_info->length);
len += sprintf(page + len, "DSDT length : %s\n", buf);
@@ -547,12 +540,15 @@
static int read_display(void)
{
- int value = 0;
+ ulong value = 0;
+ acpi_status rv = AE_OK;
/* In most of the case, we know how to set the display, but sometime
we can't read it */
if (display_get_handle) {
- if (!read_acpi_int(display_get_handle, NULL, &value, NULL))
+ rv = acpi_evaluate_integer(display_get_handle, NULL,
+ NULL, &value);
+ if (ACPI_FAILURE(rv))
printk(ASUS_WARNING "Error reading display status\n");
}
@@ -771,7 +767,7 @@
{
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *model = NULL;
- int bsts_result, hwrs_result;
+ ulong bsts_result, hwrs_result;
char *string = NULL;
acpi_status status;
@@ -794,11 +790,13 @@
}
/* This needs to be called for some laptops to init properly */
- if (!read_acpi_int(hotk->handle, "BSTS", &bsts_result, NULL))
+ status =
+ acpi_evaluate_integer(hotk->handle, "BSTS", NULL, &bsts_result);
+ if (ACPI_FAILURE(status))
printk(ASUS_WARNING "Error calling BSTS\n");
else if (bsts_result)
printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n",
- bsts_result);
+ (uint) bsts_result);
/*
* Try to match the object returned by INIT to the specific model.
@@ -840,7 +838,9 @@
* The significance of others is yet to be found.
* If we don't find the method, we assume the device are present.
*/
- if (!read_acpi_int(hotk->handle, "HRWS", &hwrs_result, NULL))
+ status =
+ acpi_evaluate_integer(hotk->handle, "HRWS", NULL, &hwrs_result);
+ if (ACPI_FAILURE(status))
hwrs_result = WL_HWRS | BT_HWRS;
if (hwrs_result & WL_HWRS)
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 2/5] asus-laptop clean write_status
2007-03-11 9:23 [PATCH 0/5] asus-laptop cleanups, bugfix and features Corentin CHARY
2007-03-11 9:25 ` [PATCH 1/5] asus-laptop use acpi_evaluate_integer instead of read_acpi_int Corentin CHARY
@ 2007-03-11 9:26 ` Corentin CHARY
2007-03-11 9:26 ` [PATCH 3/5] asus-laptop add GLED Corentin CHARY
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Corentin CHARY @ 2007-03-11 9:26 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, acpi4asus-user
From: Corentin Chary <corentincj@iksaif.net>
Clean the write_status function, and implement special case with
a switch inside write_status. It also make sure bt and wl status
are right when booting with the hardware switch off.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
asus-laptop.c | 48 +++++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 19 deletions(-)
--- a/drivers/misc/asus-laptop.c 2007-03-10 16:26:02.000000000 +0100
+++ b/drivers/misc/asus-laptop.c 2007-03-10 16:25:08.000000000 +0100
@@ -272,19 +272,25 @@
return (hotk->status & mask) ? 1 : 0;
}
-static void write_status(acpi_handle handle, int out, int mask, int invert)
+static void write_status(acpi_handle handle, int out, int mask)
{
hotk->status = (out) ? (hotk->status | mask) : (hotk->status & ~mask);
- if (invert) /* invert target value */
+ switch (mask) {
+ case MLED_ON:
out = !out & 0x1;
+ break;
+ default:
+ out &= 0x1;
+ break;
+ }
if (handle && !write_acpi_int(handle, NULL, out, NULL))
- printk(ASUS_WARNING " write failed\n");
+ printk(ASUS_WARNING " write failed %x\n", mask);
}
/* /sys/class/led handlers */
-#define ASUS_LED_HANDLER(object, mask, invert) \
+#define ASUS_LED_HANDLER(object, mask) \
static void object##_led_set(struct led_classdev *led_cdev, \
enum led_brightness value) \
{ \
@@ -294,13 +300,13 @@
static void object##_led_update(struct work_struct *ignored) \
{ \
int value = object##_led_wk; \
- write_status(object##_set_handle, value, (mask), (invert)); \
+ write_status(object##_set_handle, value, (mask)); \
}
-ASUS_LED_HANDLER(mled, MLED_ON, 1);
-ASUS_LED_HANDLER(pled, PLED_ON, 0);
-ASUS_LED_HANDLER(rled, RLED_ON, 0);
-ASUS_LED_HANDLER(tled, TLED_ON, 0);
+ASUS_LED_HANDLER(mled, MLED_ON);
+ASUS_LED_HANDLER(pled, PLED_ON);
+ASUS_LED_HANDLER(rled, RLED_ON);
+ASUS_LED_HANDLER(tled, TLED_ON);
static int get_lcd_state(void)
{
@@ -325,7 +331,7 @@
printk(ASUS_WARNING "Error switching LCD\n");
}
- write_status(NULL, lcd, LCD_ON, 0);
+ write_status(NULL, lcd, LCD_ON);
return 0;
}
@@ -458,7 +464,7 @@
}
static ssize_t store_status(const char *buf, size_t count,
- acpi_handle handle, int mask, int invert)
+ acpi_handle handle, int mask)
{
int rv, value;
int out = 0;
@@ -467,7 +473,7 @@
if (rv > 0)
out = value ? 1 : 0;
- write_status(handle, out, mask, invert);
+ write_status(handle, out, mask);
return rv;
}
@@ -508,7 +514,7 @@
static ssize_t store_wlan(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- return store_status(buf, count, wl_switch_handle, WL_ON, 0);
+ return store_status(buf, count, wl_switch_handle, WL_ON);
}
/*
@@ -524,7 +530,7 @@
struct device_attribute *attr, const char *buf,
size_t count)
{
- return store_status(buf, count, bt_switch_handle, BT_ON, 0);
+ return store_status(buf, count, bt_switch_handle, BT_ON);
}
/*
@@ -652,10 +658,10 @@
* switched
*/
if (event == ATKD_LCD_ON) {
- write_status(NULL, 1, LCD_ON, 0);
+ write_status(NULL, 1, LCD_ON);
lcd_blank(FB_BLANK_UNBLANK);
} else if (event == ATKD_LCD_OFF) {
- write_status(NULL, 0, LCD_ON, 0);
+ write_status(NULL, 0, LCD_ON);
lcd_blank(FB_BLANK_POWERDOWN);
}
@@ -928,11 +934,15 @@
asus_hotk_found = 1;
/* WLED and BLED are on by default */
- write_status(bt_switch_handle, 1, BT_ON, 0);
- write_status(wl_switch_handle, 1, WL_ON, 0);
+ write_status(bt_switch_handle, 1, BT_ON);
+ write_status(wl_switch_handle, 1, WL_ON);
+
+ /* If the h/w switch is off, we need to check the real status */
+ write_status(NULL, read_status(BT_ON), BT_ON);
+ write_status(NULL, read_status(WL_ON), WL_ON);
/* LCD Backlight is on by default */
- write_status(NULL, 1, LCD_ON, 0);
+ write_status(NULL, 1, LCD_ON);
/* LED display is off by default */
hotk->ledd_status = 0xFFF;
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 3/5] asus-laptop add GLED
2007-03-11 9:23 [PATCH 0/5] asus-laptop cleanups, bugfix and features Corentin CHARY
2007-03-11 9:25 ` [PATCH 1/5] asus-laptop use acpi_evaluate_integer instead of read_acpi_int Corentin CHARY
2007-03-11 9:26 ` [PATCH 2/5] asus-laptop clean write_status Corentin CHARY
@ 2007-03-11 9:26 ` Corentin CHARY
2007-03-11 9:27 ` [PATCH 4/5] asus-laptop add wapf param Corentin CHARY
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Corentin CHARY @ 2007-03-11 9:26 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, acpi4asus-user
From: Corentin Chary <corentincj@iksaif.net>
Add support for "gaming" led.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
asus-laptop.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
--- a/drivers/misc/asus-laptop.c 2007-03-10 16:27:02.000000000 +0100
+++ b/drivers/misc/asus-laptop.c 2007-03-10 16:29:53.000000000 +0100
@@ -81,7 +81,8 @@
#define TLED_ON 0x08 //touchpad LED
#define RLED_ON 0x10 //Record LED
#define PLED_ON 0x20 //Phone LED
-#define LCD_ON 0x40 //LCD backlight
+#define GLED_ON 0x40 //Gaming LED
+#define LCD_ON 0x80 //LCD backlight
#define ASUS_LOG ASUS_HOTK_FILE ": "
#define ASUS_ERR KERN_ERR ASUS_LOG
@@ -103,6 +104,7 @@
ASUS_HANDLE(tled_set, ASUS_HOTK_PREFIX "TLED");
ASUS_HANDLE(rled_set, ASUS_HOTK_PREFIX "RLED"); /* W1JC */
ASUS_HANDLE(pled_set, ASUS_HOTK_PREFIX "PLED"); /* A7J */
+ASUS_HANDLE(gled_set, ASUS_HOTK_PREFIX "GLED"); /* G1, G2 (probably) */
/* LEDD */
ASUS_HANDLE(ledd_set, ASUS_HOTK_PREFIX "SLCM");
@@ -221,6 +223,7 @@
ASUS_LED(tled, "touchpad");
ASUS_LED(rled, "record");
ASUS_LED(pled, "phone");
+ASUS_LED(gled, "gaming");
/*
* This function evaluates an ACPI method, given an int as parameter, the
@@ -280,6 +283,9 @@
case MLED_ON:
out = !out & 0x1;
break;
+ case GLED_ON:
+ out = (out & 0x1) + 1;
+ break;
default:
out &= 0x1;
break;
@@ -307,6 +313,7 @@
ASUS_LED_HANDLER(pled, PLED_ON);
ASUS_LED_HANDLER(rled, RLED_ON);
ASUS_LED_HANDLER(tled, TLED_ON);
+ASUS_LED_HANDLER(gled, GLED_ON);
static int get_lcd_state(void)
{
@@ -835,6 +842,7 @@
ASUS_HANDLE_INIT(tled_set);
ASUS_HANDLE_INIT(rled_set);
ASUS_HANDLE_INIT(pled_set);
+ ASUS_HANDLE_INIT(gled_set);
ASUS_HANDLE_INIT(ledd_set);
@@ -1001,6 +1009,7 @@
ASUS_LED_UNREGISTER(tled);
ASUS_LED_UNREGISTER(pled);
ASUS_LED_UNREGISTER(rled);
+ ASUS_LED_UNREGISTER(gled);
destroy_workqueue(led_workqueue);
}
@@ -1072,6 +1081,10 @@
if (rv)
return rv;
+ rv = ASUS_LED_REGISTER(gled, dev);
+ if (rv)
+ return rv;
+
led_workqueue = create_singlethread_workqueue("led_workqueue");
if (!led_workqueue)
return -ENOMEM;
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 4/5] asus-laptop add wapf param
2007-03-11 9:23 [PATCH 0/5] asus-laptop cleanups, bugfix and features Corentin CHARY
` (2 preceding siblings ...)
2007-03-11 9:26 ` [PATCH 3/5] asus-laptop add GLED Corentin CHARY
@ 2007-03-11 9:27 ` Corentin CHARY
2007-03-11 9:28 ` [PATCH 5/5] asus-laptop version bump Corentin CHARY
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Corentin CHARY @ 2007-03-11 9:27 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, acpi4asus-user
From: Corentin Chary <corentincj@iksaif.net>
Add the "wapf" param. This param allows to define the behavior
of the Fn F2 key (wlan switch).
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
asus-laptop.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
--- a/drivers/misc/asus-laptop.c 2007-03-10 16:31:07.000000000 +0100
+++ b/drivers/misc/asus-laptop.c 2007-03-10 16:34:24.000000000 +0100
@@ -95,6 +95,19 @@
MODULE_DESCRIPTION(ASUS_HOTK_NAME);
MODULE_LICENSE("GPL");
+/* WAPF defines the behavior of the Fn+Fx wlan key
+ * The significance of values is yet to be found, but
+ * most of the time:
+ * 0x0 will do nothing
+ * 0x1 will allow to control the device with Fn+Fx key.
+ * 0x4 will send an ACPI event (0x88) while pressing the Fn+Fx key
+ * 0x5 like 0x1 or 0x4
+ * So, if something doesn't work as you want, just try other values =)
+ */
+static uint wapf = 1;
+module_param(wapf, uint, 0644);
+MODULE_PARM_DESC(wapf, "WAPF value");
+
#define ASUS_HANDLE(object, paths...) \
static acpi_handle object##_handle = NULL; \
static char *object##_paths[] = { paths }
@@ -811,6 +824,9 @@
printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n",
(uint) bsts_result);
+ /* This too ... */
+ write_acpi_int(hotk->handle, "CWAP", wapf, NULL);
+
/*
* Try to match the object returned by INIT to the specific model.
* Handle every possible object (or the lack of thereof) the DSDT
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 5/5] asus-laptop version bump
2007-03-11 9:23 [PATCH 0/5] asus-laptop cleanups, bugfix and features Corentin CHARY
` (3 preceding siblings ...)
2007-03-11 9:27 ` [PATCH 4/5] asus-laptop add wapf param Corentin CHARY
@ 2007-03-11 9:28 ` Corentin CHARY
2007-03-11 19:41 ` [PATCH 0/5] asus-laptop cleanups, bugfix and features Len Brown
2007-03-11 19:51 ` Len Brown
6 siblings, 0 replies; 8+ messages in thread
From: Corentin CHARY @ 2007-03-11 9:28 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, acpi4asus-user
From: Corentin Chary <corentincj@iksaif.net>
Version and copyright bump.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
asus-laptop.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/misc/asus-laptop.c 2007-03-10 16:35:10.000000000 +0100
+++ b/drivers/misc/asus-laptop.c 2007-03-10 16:35:53.000000000 +0100
@@ -3,7 +3,7 @@
*
*
* Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor
- * Copyright (C) 2006 Corentin Chary
+ * Copyright (C) 2006-2007 Corentin Chary
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@
#include <acpi/acpi_bus.h>
#include <asm/uaccess.h>
-#define ASUS_LAPTOP_VERSION "0.40"
+#define ASUS_LAPTOP_VERSION "0.41"
#define ASUS_HOTK_NAME "Asus Laptop Support"
#define ASUS_HOTK_CLASS "hotkey"
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 0/5] asus-laptop cleanups, bugfix and features
2007-03-11 9:23 [PATCH 0/5] asus-laptop cleanups, bugfix and features Corentin CHARY
` (4 preceding siblings ...)
2007-03-11 9:28 ` [PATCH 5/5] asus-laptop version bump Corentin CHARY
@ 2007-03-11 19:41 ` Len Brown
2007-03-11 19:51 ` Len Brown
6 siblings, 0 replies; 8+ messages in thread
From: Len Brown @ 2007-03-11 19:41 UTC (permalink / raw)
To: corentincj; +Cc: linux-acpi, acpi4asus-user
On Sunday 11 March 2007 05:23, Corentin CHARY wrote:
> Hi,
> There's not much to tell ... It would be nice if these patch could be merged
> before 2.6.21 =).
> These patch are against acpi-test, and can probably be applied on 2.6.21.
Deep into 2.6.21-rc3 the focus really must be on regressions.
Cleanups and new features are surely 2.6.22 material.
Fixes for bugs that have always been there, are
2.6.22 material, unless they're really small and obvious,
or extremely serious.
thanks,
-Len
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 0/5] asus-laptop cleanups, bugfix and features
2007-03-11 9:23 [PATCH 0/5] asus-laptop cleanups, bugfix and features Corentin CHARY
` (5 preceding siblings ...)
2007-03-11 19:41 ` [PATCH 0/5] asus-laptop cleanups, bugfix and features Len Brown
@ 2007-03-11 19:51 ` Len Brown
6 siblings, 0 replies; 8+ messages in thread
From: Len Brown @ 2007-03-11 19:51 UTC (permalink / raw)
To: corentincj; +Cc: linux-acpi, acpi4asus-user
1-5 applied to acpi-test.
thanks,
-Len
^ permalink raw reply [flat|nested] 8+ messages in thread