Skip to contentSkip to conversation

asus-laptop

PATCH In review Corentin CHARY 3 participants 7 messages May 6, 2007 – May 10, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover asus-laptop

Hi Len,
Some asus-laptop patchs for 2.6.22 =).

Signature · 2 lines
CHARY 'Iksaif' Corentin
http://xf.iksaif.net
#1 lore raw

Re: [PATCH 1/4] asus-laptop notify ALL events

From: Corentin Chary <[email protected]>

We need to handle all events, because some dsdt use events >= 0x80

---
 asus-laptop.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/asus-laptop.c +2 -2
@@ -950,7 +950,7 @@
 	 * 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 @@
 	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");
#2 lore raw

Re: [PATCH 2/4] asus-laptop add GPS support

In reply to Corentin CHARY

From: Corentin Chary <[email protected]>

Just adds GPS support found in R2H thanks to Sam Lin. It will make a "gps" file in /sys/devices/platform/asus-laptop/.

---
 asus-laptop.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)
drivers/misc/asus-laptop.c +54 -1
@@ -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 <linux/autoconf.h>
@@ -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(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 @@
 	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 @@
 	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 @@
 	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(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 @@
 	&dev_attr_ledd.attr,
 	&dev_attr_ls_switch.attr,
 	&dev_attr_ls_level.attr,
+	&dev_attr_gps.attr,
 	NULL
 };
 
@@ -763,6 +806,9 @@
 		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 @@
 	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 @@
 	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);
#3 lore raw

Re: [PATCH 3/4] asus-laptop fix light sens init

In reply to Corentin CHARY

From: Corentin Chary <[email protected]>

Fix a stupid light sens detection bug.

---
 asus-laptop.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/asus-laptop.c +1 -1
@@ -936,7 +936,7 @@
 
 	/* 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);
#4 lore raw

PATCH 4/4 asus-laptop version bump and lindent

In reply to Corentin CHARY

From: Corentin Chary <[email protected]>

Version bump, lindent, etc ..

---
 asus-laptop.c |   29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/misc/asus-laptop.c +15 -14
@@ -48,7 +48,7 @@
 #include <acpi/acpi_bus.h>
 #include <asm/uaccess.h>
 
-#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_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 @@
 
 /* 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 @@
 	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 @@
 	/* 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 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 @@
 		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);
 }
 
#5 lore raw
In reply to Corentin CHARY
Quoted 2 lines · Corentin CHARY

Hi Len,
Some asus-laptop patchs for 2.6.22 =).

I recently had a look at an ASUS and wanted to try out the video module.
The laptop had the ACPI specific general brightness and other video AML functions.
But also the ATKxy Asus specific device that asus_acpi makes use of.

In AML code one could see, that the use of those was exclusive, a variable (or method?) was used to either return out immediately from ATKxy or general ACPI funcs (the ones from ACPI spec. Appendix B).

On a quick try asus_acpi worked, video did not.

It looks as if asus begins to move to the spec? Some problems might come up:
- Interference between asus_acpi and video
- Which model works better with what kind of method (there might come a break point, (possibly Vista?), when the ACPI spec functions work better than ATKxy the asus specific device vanishes totally at some point).

While I like the idea that vendors move on to the standard, I fear some more very machine specific problems might hit us in future...

Just some info, if anyone finds out more, I'd be interested in any related info...

Thanks,

Thomas