blob: faa87d3e3983088d41f32223af3076624e667c52 [file] [log] [blame]
Corentin Chary85091b72007-01-26 14:04:30 +01001/*
2 * asus-laptop.c - Asus Laptop Support
3 *
4 *
5 * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor
Corentin Chary8ec555c2007-03-11 10:28:03 +01006 * Copyright (C) 2006-2007 Corentin Chary
Corentin Chary85091b72007-01-26 14:04:30 +01007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 *
23 * The development page for this driver is located at
24 * http://sourceforge.net/projects/acpi4asus/
25 *
26 * Credits:
27 * Pontus Fuchs - Helper functions, cleanup
28 * Johann Wiesner - Small compile fixes
29 * John Belmonte - ACPI code for Toshiba laptop was a good starting point.
30 * Eric Burghard - LED display support for W1N
31 * Josh Green - Light Sens support
32 * Thomas Tuttle - His first patch for led support was very helpfull
Corentin Charye539c2f2007-05-06 14:47:06 +020033 * Sam Lin - GPS support
Corentin Chary85091b72007-01-26 14:04:30 +010034 */
35
Corentin Chary85091b72007-01-26 14:04:30 +010036#include <linux/kernel.h>
37#include <linux/module.h>
38#include <linux/init.h>
39#include <linux/types.h>
40#include <linux/err.h>
41#include <linux/proc_fs.h>
Corentin Chary6b7091e2007-01-26 14:04:45 +010042#include <linux/backlight.h>
43#include <linux/fb.h>
Corentin Charybe18cda2007-01-26 14:04:35 +010044#include <linux/leds.h>
Corentin Chary85091b72007-01-26 14:04:30 +010045#include <linux/platform_device.h>
46#include <acpi/acpi_drivers.h>
47#include <acpi/acpi_bus.h>
48#include <asm/uaccess.h>
Corentin Chary034ce902009-01-20 16:17:43 +010049#include <linux/input.h>
Corentin Chary85091b72007-01-26 14:04:30 +010050
Corentin Charyf3985322007-05-06 14:48:22 +020051#define ASUS_LAPTOP_VERSION "0.42"
Corentin Chary85091b72007-01-26 14:04:30 +010052
53#define ASUS_HOTK_NAME "Asus Laptop Support"
54#define ASUS_HOTK_CLASS "hotkey"
55#define ASUS_HOTK_DEVICE_NAME "Hotkey"
Corentin Chary85091b72007-01-26 14:04:30 +010056#define ASUS_HOTK_FILE "asus-laptop"
57#define ASUS_HOTK_PREFIX "\\_SB.ATKD."
58
Corentin Charybe18cda2007-01-26 14:04:35 +010059/*
Corentin Chary6b7091e2007-01-26 14:04:45 +010060 * Some events we use, same for all Asus
61 */
62#define ATKD_BR_UP 0x10
63#define ATKD_BR_DOWN 0x20
64#define ATKD_LCD_ON 0x33
65#define ATKD_LCD_OFF 0x34
66
67/*
Corentin Chary4564de12007-01-26 14:04:40 +010068 * Known bits returned by \_SB.ATKD.HWRS
Corentin Charybe18cda2007-01-26 14:04:35 +010069 */
Corentin Chary4564de12007-01-26 14:04:40 +010070#define WL_HWRS 0x80
71#define BT_HWRS 0x100
72
73/*
74 * Flags for hotk status
75 * WL_ON and BT_ON are also used for wireless_status()
76 */
77#define WL_ON 0x01 //internal Wifi
78#define BT_ON 0x02 //internal Bluetooth
Corentin Charybe18cda2007-01-26 14:04:35 +010079#define MLED_ON 0x04 //mail LED
80#define TLED_ON 0x08 //touchpad LED
Len Brown8def05f2007-01-30 01:46:43 -050081#define RLED_ON 0x10 //Record LED
82#define PLED_ON 0x20 //Phone LED
Corentin Charyfdd8d082007-03-11 10:26:48 +010083#define GLED_ON 0x40 //Gaming LED
84#define LCD_ON 0x80 //LCD backlight
Corentin Charyf3985322007-05-06 14:48:22 +020085#define GPS_ON 0x100 //GPS
Corentin Charybe18cda2007-01-26 14:04:35 +010086
Corentin Chary85091b72007-01-26 14:04:30 +010087#define ASUS_LOG ASUS_HOTK_FILE ": "
88#define ASUS_ERR KERN_ERR ASUS_LOG
89#define ASUS_WARNING KERN_WARNING ASUS_LOG
90#define ASUS_NOTICE KERN_NOTICE ASUS_LOG
91#define ASUS_INFO KERN_INFO ASUS_LOG
92#define ASUS_DEBUG KERN_DEBUG ASUS_LOG
93
94MODULE_AUTHOR("Julien Lerouge, Karol Kozimor, Corentin Chary");
95MODULE_DESCRIPTION(ASUS_HOTK_NAME);
96MODULE_LICENSE("GPL");
97
Corentin Chary185e5af2007-03-11 10:27:33 +010098/* WAPF defines the behavior of the Fn+Fx wlan key
99 * The significance of values is yet to be found, but
100 * most of the time:
101 * 0x0 will do nothing
102 * 0x1 will allow to control the device with Fn+Fx key.
103 * 0x4 will send an ACPI event (0x88) while pressing the Fn+Fx key
104 * 0x5 like 0x1 or 0x4
105 * So, if something doesn't work as you want, just try other values =)
106 */
107static uint wapf = 1;
108module_param(wapf, uint, 0644);
109MODULE_PARM_DESC(wapf, "WAPF value");
110
Corentin Chary85091b72007-01-26 14:04:30 +0100111#define ASUS_HANDLE(object, paths...) \
112 static acpi_handle object##_handle = NULL; \
113 static char *object##_paths[] = { paths }
114
Corentin Charybe18cda2007-01-26 14:04:35 +0100115/* LED */
116ASUS_HANDLE(mled_set, ASUS_HOTK_PREFIX "MLED");
117ASUS_HANDLE(tled_set, ASUS_HOTK_PREFIX "TLED");
Len Brown8def05f2007-01-30 01:46:43 -0500118ASUS_HANDLE(rled_set, ASUS_HOTK_PREFIX "RLED"); /* W1JC */
119ASUS_HANDLE(pled_set, ASUS_HOTK_PREFIX "PLED"); /* A7J */
Corentin Charyfdd8d082007-03-11 10:26:48 +0100120ASUS_HANDLE(gled_set, ASUS_HOTK_PREFIX "GLED"); /* G1, G2 (probably) */
Corentin Charybe18cda2007-01-26 14:04:35 +0100121
Corentin Chary722ad972007-01-26 14:04:55 +0100122/* LEDD */
123ASUS_HANDLE(ledd_set, ASUS_HOTK_PREFIX "SLCM");
124
Corentin Chary4564de12007-01-26 14:04:40 +0100125/* Bluetooth and WLAN
126 * WLED and BLED are not handled like other XLED, because in some dsdt
127 * they also control the WLAN/Bluetooth device.
128 */
129ASUS_HANDLE(wl_switch, ASUS_HOTK_PREFIX "WLED");
130ASUS_HANDLE(bt_switch, ASUS_HOTK_PREFIX "BLED");
Len Brown8def05f2007-01-30 01:46:43 -0500131ASUS_HANDLE(wireless_status, ASUS_HOTK_PREFIX "RSTS"); /* All new models */
Corentin Chary4564de12007-01-26 14:04:40 +0100132
Corentin Chary6b7091e2007-01-26 14:04:45 +0100133/* Brightness */
134ASUS_HANDLE(brightness_set, ASUS_HOTK_PREFIX "SPLV");
135ASUS_HANDLE(brightness_get, ASUS_HOTK_PREFIX "GPLV");
136
137/* Backlight */
Len Brown8def05f2007-01-30 01:46:43 -0500138ASUS_HANDLE(lcd_switch, "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */
139 "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */
140 "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */
141 "\\_SB.PCI0.PX40.EC0.Q10", /* M1A */
142 "\\_SB.PCI0.LPCB.EC0._Q10", /* P30 */
Torsten Krah4d0b856e2008-10-17 09:47:57 +0200143 "\\_SB.PCI0.LPCB.EC0._Q0E", /* P30/P35 */
Len Brown8def05f2007-01-30 01:46:43 -0500144 "\\_SB.PCI0.PX40.Q10", /* S1x */
145 "\\Q10"); /* A2x, L2D, L3D, M2E */
Corentin Chary6b7091e2007-01-26 14:04:45 +0100146
Corentin Chary78127b42007-01-26 14:04:49 +0100147/* Display */
148ASUS_HANDLE(display_set, ASUS_HOTK_PREFIX "SDSP");
Len Brown8def05f2007-01-30 01:46:43 -0500149ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L4R M6R A3G
150 M6A M6V VX-1 V6J V6V W3Z */
151 "\\_SB.PCI0.P0P2.VGA.GETD", /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V
Corentin Charyf3985322007-05-06 14:48:22 +0200152 S5A M5A z33A W1Jc W2V G1 */
Len Brown8def05f2007-01-30 01:46:43 -0500153 "\\_SB.PCI0.P0P3.VGA.GETD", /* A6V A6Q */
154 "\\_SB.PCI0.P0PA.VGA.GETD", /* A6T, A6M */
155 "\\_SB.PCI0.PCI1.VGAC.NMAP", /* L3C */
156 "\\_SB.PCI0.VGA.GETD", /* Z96F */
157 "\\ACTD", /* A2D */
158 "\\ADVG", /* A4G Z71A W1N W5A W5F M2N M3N M5N M6N S1N S5N */
159 "\\DNXT", /* P30 */
160 "\\INFB", /* A2H D1 L2D L3D L3H L2E L5D L5C M1A M2E L4L W3V */
161 "\\SSTE"); /* A3F A6F A3N A3L M6N W3N W6A */
Corentin Chary78127b42007-01-26 14:04:49 +0100162
Len Brown8def05f2007-01-30 01:46:43 -0500163ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */
164ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */
Corentin Chary8b857352007-01-26 14:04:58 +0100165
Corentin Charye539c2f2007-05-06 14:47:06 +0200166/* GPS */
167/* R2H use different handle for GPS on/off */
Corentin Charyf3985322007-05-06 14:48:22 +0200168ASUS_HANDLE(gps_on, ASUS_HOTK_PREFIX "SDON"); /* R2H */
169ASUS_HANDLE(gps_off, ASUS_HOTK_PREFIX "SDOF"); /* R2H */
Corentin Charye539c2f2007-05-06 14:47:06 +0200170ASUS_HANDLE(gps_status, ASUS_HOTK_PREFIX "GPST");
171
Corentin Chary85091b72007-01-26 14:04:30 +0100172/*
173 * This is the main structure, we can use it to store anything interesting
174 * about the hotk device
175 */
176struct asus_hotk {
Len Brown8def05f2007-01-30 01:46:43 -0500177 char *name; //laptop name
Corentin Chary85091b72007-01-26 14:04:30 +0100178 struct acpi_device *device; //the device we are in
179 acpi_handle handle; //the handle of the hotk device
180 char status; //status of the hotk, for LEDs, ...
Corentin Chary722ad972007-01-26 14:04:55 +0100181 u32 ledd_status; //status of the LED display
Len Brown8def05f2007-01-30 01:46:43 -0500182 u8 light_level; //light sensor level
183 u8 light_switch; //light sensor switch value
Corentin Chary85091b72007-01-26 14:04:30 +0100184 u16 event_count[128]; //count for each event TODO make this better
Corentin Chary034ce902009-01-20 16:17:43 +0100185 struct input_dev *inputdev;
186 u16 *keycode_map;
Corentin Chary85091b72007-01-26 14:04:30 +0100187};
188
189/*
190 * This header is made available to allow proper configuration given model,
191 * revision number , ... this info cannot go in struct asus_hotk because it is
192 * available before the hotk
193 */
194static struct acpi_table_header *asus_info;
195
196/* The actual device the driver binds to */
197static struct asus_hotk *hotk;
198
199/*
200 * The hotkey driver declaration
201 */
Thomas Renninger1ba90e32007-07-23 14:44:41 +0200202static const struct acpi_device_id asus_device_ids[] = {
203 {"ATK0100", 0},
204 {"", 0},
205};
206MODULE_DEVICE_TABLE(acpi, asus_device_ids);
207
Corentin Chary85091b72007-01-26 14:04:30 +0100208static int asus_hotk_add(struct acpi_device *device);
209static int asus_hotk_remove(struct acpi_device *device, int type);
Bjorn Helgaas586ed162009-04-30 09:35:53 -0600210static void asus_hotk_notify(struct acpi_device *device, u32 event);
211
Corentin Chary85091b72007-01-26 14:04:30 +0100212static struct acpi_driver asus_hotk_driver = {
213 .name = ASUS_HOTK_NAME,
214 .class = ASUS_HOTK_CLASS,
Thomas Renninger1ba90e32007-07-23 14:44:41 +0200215 .ids = asus_device_ids,
Bjorn Helgaas586ed162009-04-30 09:35:53 -0600216 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
Corentin Chary85091b72007-01-26 14:04:30 +0100217 .ops = {
218 .add = asus_hotk_add,
219 .remove = asus_hotk_remove,
Bjorn Helgaas586ed162009-04-30 09:35:53 -0600220 .notify = asus_hotk_notify,
Corentin Chary85091b72007-01-26 14:04:30 +0100221 },
222};
223
Corentin Chary6b7091e2007-01-26 14:04:45 +0100224/* The backlight device /sys/class/backlight */
225static struct backlight_device *asus_backlight_device;
226
227/*
228 * The backlight class declaration
229 */
230static int read_brightness(struct backlight_device *bd);
231static int update_bl_status(struct backlight_device *bd);
Richard Purdie599a52d2007-02-10 23:07:48 +0000232static struct backlight_ops asusbl_ops = {
Len Brown8def05f2007-01-30 01:46:43 -0500233 .get_brightness = read_brightness,
234 .update_status = update_bl_status,
Corentin Chary6b7091e2007-01-26 14:04:45 +0100235};
236
Corentin Charybe18cda2007-01-26 14:04:35 +0100237/* These functions actually update the LED's, and are called from a
238 * workqueue. By doing this as separate work rather than when the LED
239 * subsystem asks, we avoid messing with the Asus ACPI stuff during a
240 * potentially bad time, such as a timer interrupt. */
241static struct workqueue_struct *led_workqueue;
242
243#define ASUS_LED(object, ledname) \
244 static void object##_led_set(struct led_classdev *led_cdev, \
245 enum led_brightness value); \
246 static void object##_led_update(struct work_struct *ignored); \
247 static int object##_led_wk; \
Adrian Bunkf110ef52007-02-20 01:07:25 +0100248 static DECLARE_WORK(object##_led_work, object##_led_update); \
Corentin Charybe18cda2007-01-26 14:04:35 +0100249 static struct led_classdev object##_led = { \
Richard Purdie6c152be2007-10-31 15:00:07 +0100250 .name = "asus::" ledname, \
Corentin Charybe18cda2007-01-26 14:04:35 +0100251 .brightness_set = object##_led_set, \
252 }
253
254ASUS_LED(mled, "mail");
255ASUS_LED(tled, "touchpad");
256ASUS_LED(rled, "record");
257ASUS_LED(pled, "phone");
Corentin Charyfdd8d082007-03-11 10:26:48 +0100258ASUS_LED(gled, "gaming");
Corentin Charybe18cda2007-01-26 14:04:35 +0100259
Corentin Chary034ce902009-01-20 16:17:43 +0100260struct key_entry {
261 char type;
262 u8 code;
263 u16 keycode;
264};
265
266enum { KE_KEY, KE_END };
267
268static struct key_entry asus_keymap[] = {
269 {KE_KEY, 0x30, KEY_VOLUMEUP},
270 {KE_KEY, 0x31, KEY_VOLUMEDOWN},
271 {KE_KEY, 0x32, KEY_MUTE},
272 {KE_KEY, 0x33, KEY_SWITCHVIDEOMODE},
273 {KE_KEY, 0x34, KEY_SWITCHVIDEOMODE},
274 {KE_KEY, 0x40, KEY_PREVIOUSSONG},
275 {KE_KEY, 0x41, KEY_NEXTSONG},
Corentin Chary309f5fb2009-04-27 09:23:42 +0200276 {KE_KEY, 0x43, KEY_STOPCD},
Corentin Chary034ce902009-01-20 16:17:43 +0100277 {KE_KEY, 0x45, KEY_PLAYPAUSE},
278 {KE_KEY, 0x50, KEY_EMAIL},
279 {KE_KEY, 0x51, KEY_WWW},
Corentin Chary309f5fb2009-04-27 09:23:42 +0200280 {KE_KEY, 0x5C, KEY_SCREENLOCK}, /* Screenlock */
Corentin Chary034ce902009-01-20 16:17:43 +0100281 {KE_KEY, 0x5D, KEY_WLAN},
282 {KE_KEY, 0x61, KEY_SWITCHVIDEOMODE},
283 {KE_KEY, 0x6B, BTN_TOUCH}, /* Lock Mouse */
284 {KE_KEY, 0x82, KEY_CAMERA},
Corentin Chary309f5fb2009-04-27 09:23:42 +0200285 {KE_KEY, 0x8A, KEY_PROG1},
Corentin Chary034ce902009-01-20 16:17:43 +0100286 {KE_KEY, 0x95, KEY_MEDIA},
287 {KE_KEY, 0x99, KEY_PHONE},
288 {KE_END, 0},
289};
290
Corentin Chary85091b72007-01-26 14:04:30 +0100291/*
292 * This function evaluates an ACPI method, given an int as parameter, the
293 * method is searched within the scope of the handle, can be NULL. The output
294 * of the method is written is output, which can also be NULL
295 *
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100296 * returns 0 if write is successful, -1 else.
Corentin Chary85091b72007-01-26 14:04:30 +0100297 */
298static int write_acpi_int(acpi_handle handle, const char *method, int val,
299 struct acpi_buffer *output)
300{
301 struct acpi_object_list params; //list of input parameters (an int here)
302 union acpi_object in_obj; //the only param we use
303 acpi_status status;
304
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100305 if (!handle)
306 return 0;
307
Corentin Chary85091b72007-01-26 14:04:30 +0100308 params.count = 1;
309 params.pointer = &in_obj;
310 in_obj.type = ACPI_TYPE_INTEGER;
311 in_obj.integer.value = val;
312
313 status = acpi_evaluate_object(handle, (char *)method, &params, output);
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100314 if (status == AE_OK)
315 return 0;
316 else
317 return -1;
Corentin Chary85091b72007-01-26 14:04:30 +0100318}
319
Len Brown8def05f2007-01-30 01:46:43 -0500320static int read_wireless_status(int mask)
321{
Matthew Wilcox27663c52008-10-10 02:22:59 -0400322 unsigned long long status;
Corentin Chary9a816852007-03-11 10:25:38 +0100323 acpi_status rv = AE_OK;
Corentin Chary4564de12007-01-26 14:04:40 +0100324
325 if (!wireless_status_handle)
326 return (hotk->status & mask) ? 1 : 0;
327
Corentin Chary9a816852007-03-11 10:25:38 +0100328 rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status);
329 if (ACPI_FAILURE(rv))
Corentin Chary4564de12007-01-26 14:04:40 +0100330 printk(ASUS_WARNING "Error reading Wireless status\n");
Corentin Chary9a816852007-03-11 10:25:38 +0100331 else
332 return (status & mask) ? 1 : 0;
Corentin Chary4564de12007-01-26 14:04:40 +0100333
334 return (hotk->status & mask) ? 1 : 0;
335}
336
Corentin Charyf3985322007-05-06 14:48:22 +0200337static int read_gps_status(void)
338{
Matthew Wilcox27663c52008-10-10 02:22:59 -0400339 unsigned long long status;
Corentin Charye539c2f2007-05-06 14:47:06 +0200340 acpi_status rv = AE_OK;
341
342 rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status);
343 if (ACPI_FAILURE(rv))
Corentin Charyf3985322007-05-06 14:48:22 +0200344 printk(ASUS_WARNING "Error reading GPS status\n");
Corentin Charye539c2f2007-05-06 14:47:06 +0200345 else
Corentin Charyf3985322007-05-06 14:48:22 +0200346 return status ? 1 : 0;
Corentin Charye539c2f2007-05-06 14:47:06 +0200347
Corentin Charyf3985322007-05-06 14:48:22 +0200348 return (hotk->status & GPS_ON) ? 1 : 0;
Corentin Charye539c2f2007-05-06 14:47:06 +0200349}
350
Corentin Charybe18cda2007-01-26 14:04:35 +0100351/* Generic LED functions */
352static int read_status(int mask)
353{
Corentin Chary4564de12007-01-26 14:04:40 +0100354 /* There is a special method for both wireless devices */
355 if (mask == BT_ON || mask == WL_ON)
356 return read_wireless_status(mask);
Corentin Charyf3985322007-05-06 14:48:22 +0200357 else if (mask == GPS_ON)
358 return read_gps_status();
Corentin Chary4564de12007-01-26 14:04:40 +0100359
Corentin Charybe18cda2007-01-26 14:04:35 +0100360 return (hotk->status & mask) ? 1 : 0;
361}
362
Corentin Chary935ffee2007-03-11 10:26:12 +0100363static void write_status(acpi_handle handle, int out, int mask)
Corentin Charybe18cda2007-01-26 14:04:35 +0100364{
365 hotk->status = (out) ? (hotk->status | mask) : (hotk->status & ~mask);
366
Corentin Chary935ffee2007-03-11 10:26:12 +0100367 switch (mask) {
368 case MLED_ON:
Roel Kluine1af14e2008-02-02 21:07:38 +0100369 out = !(out & 0x1);
Corentin Chary935ffee2007-03-11 10:26:12 +0100370 break;
Corentin Charyfdd8d082007-03-11 10:26:48 +0100371 case GLED_ON:
372 out = (out & 0x1) + 1;
373 break;
Corentin Charye539c2f2007-05-06 14:47:06 +0200374 case GPS_ON:
375 handle = (out) ? gps_on_handle : gps_off_handle;
376 out = 0x02;
377 break;
Corentin Chary935ffee2007-03-11 10:26:12 +0100378 default:
379 out &= 0x1;
380 break;
381 }
Corentin Charybe18cda2007-01-26 14:04:35 +0100382
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100383 if (write_acpi_int(handle, NULL, out, NULL))
Corentin Chary935ffee2007-03-11 10:26:12 +0100384 printk(ASUS_WARNING " write failed %x\n", mask);
Corentin Charybe18cda2007-01-26 14:04:35 +0100385}
386
387/* /sys/class/led handlers */
Corentin Chary935ffee2007-03-11 10:26:12 +0100388#define ASUS_LED_HANDLER(object, mask) \
Corentin Charybe18cda2007-01-26 14:04:35 +0100389 static void object##_led_set(struct led_classdev *led_cdev, \
390 enum led_brightness value) \
391 { \
Corentin Charye3deda92008-09-24 10:35:55 +0200392 object##_led_wk = (value > 0) ? 1 : 0; \
Corentin Charybe18cda2007-01-26 14:04:35 +0100393 queue_work(led_workqueue, &object##_led_work); \
394 } \
395 static void object##_led_update(struct work_struct *ignored) \
396 { \
397 int value = object##_led_wk; \
Corentin Chary935ffee2007-03-11 10:26:12 +0100398 write_status(object##_set_handle, value, (mask)); \
Corentin Charybe18cda2007-01-26 14:04:35 +0100399 }
400
Corentin Chary935ffee2007-03-11 10:26:12 +0100401ASUS_LED_HANDLER(mled, MLED_ON);
402ASUS_LED_HANDLER(pled, PLED_ON);
403ASUS_LED_HANDLER(rled, RLED_ON);
404ASUS_LED_HANDLER(tled, TLED_ON);
Corentin Charyfdd8d082007-03-11 10:26:48 +0100405ASUS_LED_HANDLER(gled, GLED_ON);
Corentin Charybe18cda2007-01-26 14:04:35 +0100406
Corentin Chary6b7091e2007-01-26 14:04:45 +0100407static int get_lcd_state(void)
408{
409 return read_status(LCD_ON);
410}
411
412static int set_lcd_state(int value)
413{
414 int lcd = 0;
415 acpi_status status = 0;
416
417 lcd = value ? 1 : 0;
418
419 if (lcd == get_lcd_state())
420 return 0;
421
Len Brown8def05f2007-01-30 01:46:43 -0500422 if (lcd_switch_handle) {
Corentin Chary6b7091e2007-01-26 14:04:45 +0100423 status = acpi_evaluate_object(lcd_switch_handle,
424 NULL, NULL, NULL);
425
426 if (ACPI_FAILURE(status))
427 printk(ASUS_WARNING "Error switching LCD\n");
428 }
429
Corentin Chary935ffee2007-03-11 10:26:12 +0100430 write_status(NULL, lcd, LCD_ON);
Corentin Chary6b7091e2007-01-26 14:04:45 +0100431 return 0;
432}
433
434static void lcd_blank(int blank)
435{
436 struct backlight_device *bd = asus_backlight_device;
437
Len Brown8def05f2007-01-30 01:46:43 -0500438 if (bd) {
Richard Purdie599a52d2007-02-10 23:07:48 +0000439 bd->props.power = blank;
Richard Purdie28ee0862007-02-08 22:25:09 +0000440 backlight_update_status(bd);
Corentin Chary6b7091e2007-01-26 14:04:45 +0100441 }
442}
443
444static int read_brightness(struct backlight_device *bd)
445{
Matthew Wilcox27663c52008-10-10 02:22:59 -0400446 unsigned long long value;
Corentin Chary9a816852007-03-11 10:25:38 +0100447 acpi_status rv = AE_OK;
Corentin Chary6b7091e2007-01-26 14:04:45 +0100448
Corentin Chary9a816852007-03-11 10:25:38 +0100449 rv = acpi_evaluate_integer(brightness_get_handle, NULL, NULL, &value);
450 if (ACPI_FAILURE(rv))
Corentin Chary6b7091e2007-01-26 14:04:45 +0100451 printk(ASUS_WARNING "Error reading brightness\n");
452
453 return value;
454}
455
456static int set_brightness(struct backlight_device *bd, int value)
457{
458 int ret = 0;
459
460 value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
461 /* 0 <= value <= 15 */
462
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100463 if (write_acpi_int(brightness_set_handle, NULL, value, NULL)) {
Corentin Chary6b7091e2007-01-26 14:04:45 +0100464 printk(ASUS_WARNING "Error changing brightness\n");
465 ret = -EIO;
466 }
467
468 return ret;
469}
470
471static int update_bl_status(struct backlight_device *bd)
472{
473 int rv;
Richard Purdie599a52d2007-02-10 23:07:48 +0000474 int value = bd->props.brightness;
Corentin Chary6b7091e2007-01-26 14:04:45 +0100475
476 rv = set_brightness(bd, value);
Len Brown8def05f2007-01-30 01:46:43 -0500477 if (rv)
Corentin Chary6b7091e2007-01-26 14:04:45 +0100478 return rv;
479
Richard Purdie599a52d2007-02-10 23:07:48 +0000480 value = (bd->props.power == FB_BLANK_UNBLANK) ? 1 : 0;
Corentin Chary6b7091e2007-01-26 14:04:45 +0100481 return set_lcd_state(value);
482}
483
Corentin Chary85091b72007-01-26 14:04:30 +0100484/*
485 * Platform device handlers
486 */
487
488/*
489 * We write our info in page, we begin at offset off and cannot write more
490 * than count bytes. We set eof to 1 if we handle those 2 values. We return the
491 * number of bytes written in page
492 */
493static ssize_t show_infos(struct device *dev,
Len Brown8def05f2007-01-30 01:46:43 -0500494 struct device_attribute *attr, char *page)
Corentin Chary85091b72007-01-26 14:04:30 +0100495{
496 int len = 0;
Matthew Wilcox27663c52008-10-10 02:22:59 -0400497 unsigned long long temp;
Corentin Chary85091b72007-01-26 14:04:30 +0100498 char buf[16]; //enough for all info
Corentin Chary9a816852007-03-11 10:25:38 +0100499 acpi_status rv = AE_OK;
500
Corentin Chary85091b72007-01-26 14:04:30 +0100501 /*
502 * We use the easy way, we don't care of off and count, so we don't set eof
503 * to 1
504 */
505
506 len += sprintf(page, ASUS_HOTK_NAME " " ASUS_LAPTOP_VERSION "\n");
507 len += sprintf(page + len, "Model reference : %s\n", hotk->name);
508 /*
509 * The SFUN method probably allows the original driver to get the list
510 * of features supported by a given model. For now, 0x0100 or 0x0800
511 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card.
512 * The significance of others is yet to be found.
513 */
Corentin Chary9a816852007-03-11 10:25:38 +0100514 rv = acpi_evaluate_integer(hotk->handle, "SFUN", NULL, &temp);
515 if (!ACPI_FAILURE(rv))
516 len += sprintf(page + len, "SFUN value : 0x%04x\n",
517 (uint) temp);
Corentin Chary85091b72007-01-26 14:04:30 +0100518 /*
519 * Another value for userspace: the ASYM method returns 0x02 for
520 * battery low and 0x04 for battery critical, its readings tend to be
521 * more accurate than those provided by _BST.
522 * Note: since not all the laptops provide this method, errors are
523 * silently ignored.
524 */
Corentin Chary9a816852007-03-11 10:25:38 +0100525 rv = acpi_evaluate_integer(hotk->handle, "ASYM", NULL, &temp);
526 if (!ACPI_FAILURE(rv))
527 len += sprintf(page + len, "ASYM value : 0x%04x\n",
528 (uint) temp);
Corentin Chary85091b72007-01-26 14:04:30 +0100529 if (asus_info) {
530 snprintf(buf, 16, "%d", asus_info->length);
531 len += sprintf(page + len, "DSDT length : %s\n", buf);
532 snprintf(buf, 16, "%d", asus_info->checksum);
533 len += sprintf(page + len, "DSDT checksum : %s\n", buf);
534 snprintf(buf, 16, "%d", asus_info->revision);
535 len += sprintf(page + len, "DSDT revision : %s\n", buf);
536 snprintf(buf, 7, "%s", asus_info->oem_id);
537 len += sprintf(page + len, "OEM id : %s\n", buf);
538 snprintf(buf, 9, "%s", asus_info->oem_table_id);
539 len += sprintf(page + len, "OEM table id : %s\n", buf);
540 snprintf(buf, 16, "%x", asus_info->oem_revision);
541 len += sprintf(page + len, "OEM revision : 0x%s\n", buf);
542 snprintf(buf, 5, "%s", asus_info->asl_compiler_id);
543 len += sprintf(page + len, "ASL comp vendor id : %s\n", buf);
544 snprintf(buf, 16, "%x", asus_info->asl_compiler_revision);
545 len += sprintf(page + len, "ASL comp revision : 0x%s\n", buf);
546 }
547
548 return len;
549}
550
551static int parse_arg(const char *buf, unsigned long count, int *val)
552{
553 if (!count)
554 return 0;
555 if (count > 31)
556 return -EINVAL;
557 if (sscanf(buf, "%i", val) != 1)
558 return -EINVAL;
559 return count;
560}
561
Corentin Chary4564de12007-01-26 14:04:40 +0100562static ssize_t store_status(const char *buf, size_t count,
Corentin Chary935ffee2007-03-11 10:26:12 +0100563 acpi_handle handle, int mask)
Corentin Chary4564de12007-01-26 14:04:40 +0100564{
565 int rv, value;
566 int out = 0;
567
568 rv = parse_arg(buf, count, &value);
569 if (rv > 0)
570 out = value ? 1 : 0;
571
Corentin Chary935ffee2007-03-11 10:26:12 +0100572 write_status(handle, out, mask);
Corentin Chary4564de12007-01-26 14:04:40 +0100573
574 return rv;
575}
576
577/*
Corentin Chary722ad972007-01-26 14:04:55 +0100578 * LEDD display
579 */
580static ssize_t show_ledd(struct device *dev,
581 struct device_attribute *attr, char *buf)
582{
583 return sprintf(buf, "0x%08x\n", hotk->ledd_status);
584}
585
586static ssize_t store_ledd(struct device *dev, struct device_attribute *attr,
587 const char *buf, size_t count)
588{
589 int rv, value;
590
591 rv = parse_arg(buf, count, &value);
592 if (rv > 0) {
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100593 if (write_acpi_int(ledd_set_handle, NULL, value, NULL))
Corentin Chary722ad972007-01-26 14:04:55 +0100594 printk(ASUS_WARNING "LED display write failed\n");
595 else
596 hotk->ledd_status = (u32) value;
597 }
598 return rv;
599}
600
601/*
Corentin Chary4564de12007-01-26 14:04:40 +0100602 * WLAN
603 */
604static ssize_t show_wlan(struct device *dev,
605 struct device_attribute *attr, char *buf)
606{
607 return sprintf(buf, "%d\n", read_status(WL_ON));
608}
609
610static ssize_t store_wlan(struct device *dev, struct device_attribute *attr,
611 const char *buf, size_t count)
612{
Corentin Chary935ffee2007-03-11 10:26:12 +0100613 return store_status(buf, count, wl_switch_handle, WL_ON);
Corentin Chary4564de12007-01-26 14:04:40 +0100614}
615
616/*
617 * Bluetooth
618 */
619static ssize_t show_bluetooth(struct device *dev,
620 struct device_attribute *attr, char *buf)
621{
622 return sprintf(buf, "%d\n", read_status(BT_ON));
623}
624
Len Brown8def05f2007-01-30 01:46:43 -0500625static ssize_t store_bluetooth(struct device *dev,
626 struct device_attribute *attr, const char *buf,
627 size_t count)
Corentin Chary4564de12007-01-26 14:04:40 +0100628{
Corentin Chary935ffee2007-03-11 10:26:12 +0100629 return store_status(buf, count, bt_switch_handle, BT_ON);
Corentin Chary4564de12007-01-26 14:04:40 +0100630}
631
Corentin Chary78127b42007-01-26 14:04:49 +0100632/*
633 * Display
634 */
635static void set_display(int value)
636{
637 /* no sanity check needed for now */
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100638 if (write_acpi_int(display_set_handle, NULL, value, NULL))
Corentin Chary78127b42007-01-26 14:04:49 +0100639 printk(ASUS_WARNING "Error setting display\n");
640 return;
641}
642
643static int read_display(void)
644{
Matthew Wilcox27663c52008-10-10 02:22:59 -0400645 unsigned long long value = 0;
Corentin Chary9a816852007-03-11 10:25:38 +0100646 acpi_status rv = AE_OK;
Corentin Chary78127b42007-01-26 14:04:49 +0100647
648 /* In most of the case, we know how to set the display, but sometime
649 we can't read it */
Len Brown8def05f2007-01-30 01:46:43 -0500650 if (display_get_handle) {
Corentin Chary9a816852007-03-11 10:25:38 +0100651 rv = acpi_evaluate_integer(display_get_handle, NULL,
652 NULL, &value);
653 if (ACPI_FAILURE(rv))
Corentin Chary78127b42007-01-26 14:04:49 +0100654 printk(ASUS_WARNING "Error reading display status\n");
655 }
656
657 value &= 0x0F; /* needed for some models, shouldn't hurt others */
658
659 return value;
660}
Len Brown8def05f2007-01-30 01:46:43 -0500661
Corentin Chary78127b42007-01-26 14:04:49 +0100662/*
663 * Now, *this* one could be more user-friendly, but so far, no-one has
664 * complained. The significance of bits is the same as in store_disp()
665 */
666static ssize_t show_disp(struct device *dev,
667 struct device_attribute *attr, char *buf)
668{
669 return sprintf(buf, "%d\n", read_display());
670}
671
672/*
673 * Experimental support for display switching. As of now: 1 should activate
674 * the LCD output, 2 should do for CRT, 4 for TV-Out and 8 for DVI.
675 * Any combination (bitwise) of these will suffice. I never actually tested 4
676 * displays hooked up simultaneously, so be warned. See the acpi4asus README
677 * for more info.
678 */
679static ssize_t store_disp(struct device *dev, struct device_attribute *attr,
680 const char *buf, size_t count)
681{
682 int rv, value;
683
684 rv = parse_arg(buf, count, &value);
685 if (rv > 0)
686 set_display(value);
687 return rv;
688}
689
Corentin Chary8b857352007-01-26 14:04:58 +0100690/*
691 * Light Sens
692 */
693static void set_light_sens_switch(int value)
694{
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100695 if (write_acpi_int(ls_switch_handle, NULL, value, NULL))
Corentin Chary8b857352007-01-26 14:04:58 +0100696 printk(ASUS_WARNING "Error setting light sensor switch\n");
697 hotk->light_switch = value;
698}
699
700static ssize_t show_lssw(struct device *dev,
701 struct device_attribute *attr, char *buf)
702{
703 return sprintf(buf, "%d\n", hotk->light_switch);
704}
705
706static ssize_t store_lssw(struct device *dev, struct device_attribute *attr,
707 const char *buf, size_t count)
708{
709 int rv, value;
710
711 rv = parse_arg(buf, count, &value);
712 if (rv > 0)
713 set_light_sens_switch(value ? 1 : 0);
714
715 return rv;
716}
717
718static void set_light_sens_level(int value)
719{
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100720 if (write_acpi_int(ls_level_handle, NULL, value, NULL))
Corentin Chary8b857352007-01-26 14:04:58 +0100721 printk(ASUS_WARNING "Error setting light sensor level\n");
722 hotk->light_level = value;
723}
724
725static ssize_t show_lslvl(struct device *dev,
726 struct device_attribute *attr, char *buf)
727{
728 return sprintf(buf, "%d\n", hotk->light_level);
729}
730
731static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr,
732 const char *buf, size_t count)
733{
734 int rv, value;
735
736 rv = parse_arg(buf, count, &value);
737 if (rv > 0) {
738 value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
739 /* 0 <= value <= 15 */
740 set_light_sens_level(value);
741 }
742
743 return rv;
744}
745
Corentin Charye539c2f2007-05-06 14:47:06 +0200746/*
747 * GPS
748 */
749static ssize_t show_gps(struct device *dev,
750 struct device_attribute *attr, char *buf)
751{
752 return sprintf(buf, "%d\n", read_status(GPS_ON));
753}
754
755static ssize_t store_gps(struct device *dev, struct device_attribute *attr,
756 const char *buf, size_t count)
757{
Corentin Charyf3985322007-05-06 14:48:22 +0200758 return store_status(buf, count, NULL, GPS_ON);
Corentin Charye539c2f2007-05-06 14:47:06 +0200759}
760
Corentin Chary034ce902009-01-20 16:17:43 +0100761/*
762 * Hotkey functions
763 */
764static struct key_entry *asus_get_entry_by_scancode(int code)
765{
766 struct key_entry *key;
767
768 for (key = asus_keymap; key->type != KE_END; key++)
769 if (code == key->code)
770 return key;
771
772 return NULL;
773}
774
775static struct key_entry *asus_get_entry_by_keycode(int code)
776{
777 struct key_entry *key;
778
779 for (key = asus_keymap; key->type != KE_END; key++)
780 if (code == key->keycode && key->type == KE_KEY)
781 return key;
782
783 return NULL;
784}
785
786static int asus_getkeycode(struct input_dev *dev, int scancode, int *keycode)
787{
788 struct key_entry *key = asus_get_entry_by_scancode(scancode);
789
790 if (key && key->type == KE_KEY) {
791 *keycode = key->keycode;
792 return 0;
793 }
794
795 return -EINVAL;
796}
797
798static int asus_setkeycode(struct input_dev *dev, int scancode, int keycode)
799{
800 struct key_entry *key;
801 int old_keycode;
802
803 if (keycode < 0 || keycode > KEY_MAX)
804 return -EINVAL;
805
806 key = asus_get_entry_by_scancode(scancode);
807 if (key && key->type == KE_KEY) {
808 old_keycode = key->keycode;
809 key->keycode = keycode;
810 set_bit(keycode, dev->keybit);
811 if (!asus_get_entry_by_keycode(old_keycode))
812 clear_bit(old_keycode, dev->keybit);
813 return 0;
814 }
815
816 return -EINVAL;
817}
818
Bjorn Helgaas586ed162009-04-30 09:35:53 -0600819static void asus_hotk_notify(struct acpi_device *device, u32 event)
Corentin Chary85091b72007-01-26 14:04:30 +0100820{
Corentin Chary034ce902009-01-20 16:17:43 +0100821 static struct key_entry *key;
Corentin Chary6050c8d2009-02-15 19:30:19 +0100822 u16 count;
Corentin Chary034ce902009-01-20 16:17:43 +0100823
Corentin Chary85091b72007-01-26 14:04:30 +0100824 /* TODO Find a better way to handle events count. */
825 if (!hotk)
826 return;
827
Corentin Chary6b7091e2007-01-26 14:04:45 +0100828 /*
829 * We need to tell the backlight device when the backlight power is
830 * switched
831 */
832 if (event == ATKD_LCD_ON) {
Corentin Chary935ffee2007-03-11 10:26:12 +0100833 write_status(NULL, 1, LCD_ON);
Corentin Chary6b7091e2007-01-26 14:04:45 +0100834 lcd_blank(FB_BLANK_UNBLANK);
Len Brown8def05f2007-01-30 01:46:43 -0500835 } else if (event == ATKD_LCD_OFF) {
Corentin Chary935ffee2007-03-11 10:26:12 +0100836 write_status(NULL, 0, LCD_ON);
Corentin Chary6b7091e2007-01-26 14:04:45 +0100837 lcd_blank(FB_BLANK_POWERDOWN);
838 }
839
Corentin Chary6050c8d2009-02-15 19:30:19 +0100840 count = hotk->event_count[event % 128]++;
841 acpi_bus_generate_proc_event(hotk->device, event, count);
Corentin Chary2a7dc0d2009-01-20 16:17:42 +0100842 acpi_bus_generate_netlink_event(hotk->device->pnp.device_class,
843 dev_name(&hotk->device->dev), event,
Corentin Chary6050c8d2009-02-15 19:30:19 +0100844 count);
Corentin Chary85091b72007-01-26 14:04:30 +0100845
Corentin Chary034ce902009-01-20 16:17:43 +0100846 if (hotk->inputdev) {
847 key = asus_get_entry_by_scancode(event);
848 if (!key)
849 return ;
850
851 switch (key->type) {
852 case KE_KEY:
853 input_report_key(hotk->inputdev, key->keycode, 1);
854 input_sync(hotk->inputdev);
855 input_report_key(hotk->inputdev, key->keycode, 0);
856 input_sync(hotk->inputdev);
857 break;
858 }
859 }
Corentin Chary85091b72007-01-26 14:04:30 +0100860}
861
862#define ASUS_CREATE_DEVICE_ATTR(_name) \
863 struct device_attribute dev_attr_##_name = { \
864 .attr = { \
865 .name = __stringify(_name), \
Tejun Heo7b595752007-06-14 03:45:17 +0900866 .mode = 0 }, \
Corentin Chary85091b72007-01-26 14:04:30 +0100867 .show = NULL, \
868 .store = NULL, \
869 }
870
871#define ASUS_SET_DEVICE_ATTR(_name, _mode, _show, _store) \
872 do { \
873 dev_attr_##_name.attr.mode = _mode; \
874 dev_attr_##_name.show = _show; \
875 dev_attr_##_name.store = _store; \
876 } while(0)
877
878static ASUS_CREATE_DEVICE_ATTR(infos);
Corentin Chary4564de12007-01-26 14:04:40 +0100879static ASUS_CREATE_DEVICE_ATTR(wlan);
880static ASUS_CREATE_DEVICE_ATTR(bluetooth);
Corentin Chary78127b42007-01-26 14:04:49 +0100881static ASUS_CREATE_DEVICE_ATTR(display);
Corentin Chary722ad972007-01-26 14:04:55 +0100882static ASUS_CREATE_DEVICE_ATTR(ledd);
Corentin Chary8b857352007-01-26 14:04:58 +0100883static ASUS_CREATE_DEVICE_ATTR(ls_switch);
884static ASUS_CREATE_DEVICE_ATTR(ls_level);
Corentin Charye539c2f2007-05-06 14:47:06 +0200885static ASUS_CREATE_DEVICE_ATTR(gps);
Corentin Chary85091b72007-01-26 14:04:30 +0100886
887static struct attribute *asuspf_attributes[] = {
Len Brown8def05f2007-01-30 01:46:43 -0500888 &dev_attr_infos.attr,
889 &dev_attr_wlan.attr,
890 &dev_attr_bluetooth.attr,
891 &dev_attr_display.attr,
892 &dev_attr_ledd.attr,
893 &dev_attr_ls_switch.attr,
894 &dev_attr_ls_level.attr,
Corentin Charye539c2f2007-05-06 14:47:06 +0200895 &dev_attr_gps.attr,
Len Brown8def05f2007-01-30 01:46:43 -0500896 NULL
Corentin Chary85091b72007-01-26 14:04:30 +0100897};
898
899static struct attribute_group asuspf_attribute_group = {
Len Brown8def05f2007-01-30 01:46:43 -0500900 .attrs = asuspf_attributes
Corentin Chary85091b72007-01-26 14:04:30 +0100901};
902
903static struct platform_driver asuspf_driver = {
Len Brown8def05f2007-01-30 01:46:43 -0500904 .driver = {
905 .name = ASUS_HOTK_FILE,
906 .owner = THIS_MODULE,
907 }
Corentin Chary85091b72007-01-26 14:04:30 +0100908};
909
910static struct platform_device *asuspf_device;
911
Corentin Chary85091b72007-01-26 14:04:30 +0100912static void asus_hotk_add_fs(void)
913{
914 ASUS_SET_DEVICE_ATTR(infos, 0444, show_infos, NULL);
Corentin Chary4564de12007-01-26 14:04:40 +0100915
916 if (wl_switch_handle)
917 ASUS_SET_DEVICE_ATTR(wlan, 0644, show_wlan, store_wlan);
918
919 if (bt_switch_handle)
920 ASUS_SET_DEVICE_ATTR(bluetooth, 0644,
921 show_bluetooth, store_bluetooth);
Corentin Chary78127b42007-01-26 14:04:49 +0100922
923 if (display_set_handle && display_get_handle)
924 ASUS_SET_DEVICE_ATTR(display, 0644, show_disp, store_disp);
Len Brown8def05f2007-01-30 01:46:43 -0500925 else if (display_set_handle)
Corentin Chary78127b42007-01-26 14:04:49 +0100926 ASUS_SET_DEVICE_ATTR(display, 0200, NULL, store_disp);
927
Corentin Chary722ad972007-01-26 14:04:55 +0100928 if (ledd_set_handle)
929 ASUS_SET_DEVICE_ATTR(ledd, 0644, show_ledd, store_ledd);
930
Corentin Chary8b857352007-01-26 14:04:58 +0100931 if (ls_switch_handle && ls_level_handle) {
932 ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl);
933 ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw);
934 }
Corentin Charye539c2f2007-05-06 14:47:06 +0200935
Corentin Charyf3985322007-05-06 14:48:22 +0200936 if (gps_status_handle && gps_on_handle && gps_off_handle)
Corentin Charye539c2f2007-05-06 14:47:06 +0200937 ASUS_SET_DEVICE_ATTR(gps, 0644, show_gps, store_gps);
Corentin Chary85091b72007-01-26 14:04:30 +0100938}
939
Len Brown8def05f2007-01-30 01:46:43 -0500940static int asus_handle_init(char *name, acpi_handle * handle,
Corentin Chary85091b72007-01-26 14:04:30 +0100941 char **paths, int num_paths)
942{
943 int i;
944 acpi_status status;
945
946 for (i = 0; i < num_paths; i++) {
947 status = acpi_get_handle(NULL, paths[i], handle);
948 if (ACPI_SUCCESS(status))
949 return 0;
950 }
951
952 *handle = NULL;
953 return -ENODEV;
954}
955
956#define ASUS_HANDLE_INIT(object) \
957 asus_handle_init(#object, &object##_handle, object##_paths, \
958 ARRAY_SIZE(object##_paths))
959
Corentin Chary85091b72007-01-26 14:04:30 +0100960/*
961 * This function is used to initialize the hotk with right values. In this
962 * method, we can make all the detection we want, and modify the hotk struct
963 */
964static int asus_hotk_get_info(void)
965{
966 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
Corentin Chary85091b72007-01-26 14:04:30 +0100967 union acpi_object *model = NULL;
Matthew Wilcox27663c52008-10-10 02:22:59 -0400968 unsigned long long bsts_result, hwrs_result;
Corentin Chary85091b72007-01-26 14:04:30 +0100969 char *string = NULL;
970 acpi_status status;
971
972 /*
973 * Get DSDT headers early enough to allow for differentiating between
974 * models, but late enough to allow acpi_bus_register_driver() to fail
975 * before doing anything ACPI-specific. Should we encounter a machine,
976 * which needs special handling (i.e. its hotkey device has a different
977 * HID), this bit will be moved. A global variable asus_info contains
978 * the DSDT header.
979 */
Len Brown894d79b2007-02-03 02:13:53 -0500980 status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus_info);
Corentin Chary85091b72007-01-26 14:04:30 +0100981 if (ACPI_FAILURE(status))
982 printk(ASUS_WARNING "Couldn't get the DSDT table header\n");
Corentin Chary85091b72007-01-26 14:04:30 +0100983
984 /* We have to write 0 on init this far for all ASUS models */
Corentin CHARYf8d1c942008-01-16 16:56:42 +0100985 if (write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
Corentin Chary85091b72007-01-26 14:04:30 +0100986 printk(ASUS_ERR "Hotkey initialization failed\n");
987 return -ENODEV;
988 }
989
990 /* This needs to be called for some laptops to init properly */
Corentin Chary9a816852007-03-11 10:25:38 +0100991 status =
992 acpi_evaluate_integer(hotk->handle, "BSTS", NULL, &bsts_result);
993 if (ACPI_FAILURE(status))
Corentin Chary85091b72007-01-26 14:04:30 +0100994 printk(ASUS_WARNING "Error calling BSTS\n");
995 else if (bsts_result)
996 printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n",
Corentin Chary9a816852007-03-11 10:25:38 +0100997 (uint) bsts_result);
Corentin Chary85091b72007-01-26 14:04:30 +0100998
Corentin Chary185e5af2007-03-11 10:27:33 +0100999 /* This too ... */
1000 write_acpi_int(hotk->handle, "CWAP", wapf, NULL);
1001
Corentin Chary85091b72007-01-26 14:04:30 +01001002 /*
1003 * Try to match the object returned by INIT to the specific model.
1004 * Handle every possible object (or the lack of thereof) the DSDT
1005 * writers might throw at us. When in trouble, we pass NULL to
1006 * asus_model_match() and try something completely different.
1007 */
1008 if (buffer.pointer) {
1009 model = buffer.pointer;
1010 switch (model->type) {
1011 case ACPI_TYPE_STRING:
1012 string = model->string.pointer;
1013 break;
1014 case ACPI_TYPE_BUFFER:
1015 string = model->buffer.pointer;
1016 break;
1017 default:
1018 string = "";
1019 break;
1020 }
1021 }
1022 hotk->name = kstrdup(string, GFP_KERNEL);
1023 if (!hotk->name)
1024 return -ENOMEM;
1025
Len Brown8def05f2007-01-30 01:46:43 -05001026 if (*string)
Corentin Chary85091b72007-01-26 14:04:30 +01001027 printk(ASUS_NOTICE " %s model detected\n", string);
1028
Corentin Charybe18cda2007-01-26 14:04:35 +01001029 ASUS_HANDLE_INIT(mled_set);
1030 ASUS_HANDLE_INIT(tled_set);
1031 ASUS_HANDLE_INIT(rled_set);
1032 ASUS_HANDLE_INIT(pled_set);
Corentin Charyfdd8d082007-03-11 10:26:48 +01001033 ASUS_HANDLE_INIT(gled_set);
Corentin Charybe18cda2007-01-26 14:04:35 +01001034
Corentin Chary722ad972007-01-26 14:04:55 +01001035 ASUS_HANDLE_INIT(ledd_set);
1036
Corentin Chary4564de12007-01-26 14:04:40 +01001037 /*
1038 * The HWRS method return informations about the hardware.
1039 * 0x80 bit is for WLAN, 0x100 for Bluetooth.
1040 * The significance of others is yet to be found.
1041 * If we don't find the method, we assume the device are present.
1042 */
Corentin Chary9a816852007-03-11 10:25:38 +01001043 status =
1044 acpi_evaluate_integer(hotk->handle, "HRWS", NULL, &hwrs_result);
1045 if (ACPI_FAILURE(status))
Corentin Chary4564de12007-01-26 14:04:40 +01001046 hwrs_result = WL_HWRS | BT_HWRS;
1047
Len Brown8def05f2007-01-30 01:46:43 -05001048 if (hwrs_result & WL_HWRS)
Corentin Chary4564de12007-01-26 14:04:40 +01001049 ASUS_HANDLE_INIT(wl_switch);
Len Brown8def05f2007-01-30 01:46:43 -05001050 if (hwrs_result & BT_HWRS)
Corentin Chary4564de12007-01-26 14:04:40 +01001051 ASUS_HANDLE_INIT(bt_switch);
1052
1053 ASUS_HANDLE_INIT(wireless_status);
1054
Corentin Chary6b7091e2007-01-26 14:04:45 +01001055 ASUS_HANDLE_INIT(brightness_set);
1056 ASUS_HANDLE_INIT(brightness_get);
1057
1058 ASUS_HANDLE_INIT(lcd_switch);
1059
Corentin Chary78127b42007-01-26 14:04:49 +01001060 ASUS_HANDLE_INIT(display_set);
1061 ASUS_HANDLE_INIT(display_get);
1062
Corentin Chary8b857352007-01-26 14:04:58 +01001063 /* There is a lot of models with "ALSL", but a few get
1064 a real light sens, so we need to check it. */
Corentin Chary832d9952007-05-06 14:47:29 +02001065 if (!ASUS_HANDLE_INIT(ls_switch))
Corentin Chary8b857352007-01-26 14:04:58 +01001066 ASUS_HANDLE_INIT(ls_level);
1067
Corentin Charye539c2f2007-05-06 14:47:06 +02001068 ASUS_HANDLE_INIT(gps_on);
1069 ASUS_HANDLE_INIT(gps_off);
1070 ASUS_HANDLE_INIT(gps_status);
1071
Corentin Chary85091b72007-01-26 14:04:30 +01001072 kfree(model);
1073
1074 return AE_OK;
1075}
1076
Corentin Chary034ce902009-01-20 16:17:43 +01001077static int asus_input_init(void)
1078{
1079 const struct key_entry *key;
1080 int result;
1081
1082 hotk->inputdev = input_allocate_device();
1083 if (!hotk->inputdev) {
1084 printk(ASUS_INFO "Unable to allocate input device\n");
1085 return 0;
1086 }
1087 hotk->inputdev->name = "Asus Laptop extra buttons";
1088 hotk->inputdev->phys = ASUS_HOTK_FILE "/input0";
1089 hotk->inputdev->id.bustype = BUS_HOST;
1090 hotk->inputdev->getkeycode = asus_getkeycode;
1091 hotk->inputdev->setkeycode = asus_setkeycode;
1092
1093 for (key = asus_keymap; key->type != KE_END; key++) {
1094 switch (key->type) {
1095 case KE_KEY:
1096 set_bit(EV_KEY, hotk->inputdev->evbit);
1097 set_bit(key->keycode, hotk->inputdev->keybit);
1098 break;
1099 }
1100 }
1101 result = input_register_device(hotk->inputdev);
1102 if (result) {
1103 printk(ASUS_INFO "Unable to register input device\n");
1104 input_free_device(hotk->inputdev);
1105 }
1106 return result;
1107}
1108
Corentin Chary85091b72007-01-26 14:04:30 +01001109static int asus_hotk_check(void)
1110{
1111 int result = 0;
1112
1113 result = acpi_bus_get_status(hotk->device);
1114 if (result)
1115 return result;
1116
1117 if (hotk->device->status.present) {
1118 result = asus_hotk_get_info();
1119 } else {
1120 printk(ASUS_ERR "Hotkey device not present, aborting\n");
1121 return -EINVAL;
1122 }
1123
1124 return result;
1125}
1126
1127static int asus_hotk_found;
1128
1129static int asus_hotk_add(struct acpi_device *device)
1130{
Corentin Chary85091b72007-01-26 14:04:30 +01001131 int result;
1132
1133 if (!device)
1134 return -EINVAL;
1135
1136 printk(ASUS_NOTICE "Asus Laptop Support version %s\n",
1137 ASUS_LAPTOP_VERSION);
1138
Yoann Padioleaudd00cc42007-07-19 01:49:03 -07001139 hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL);
Corentin Chary85091b72007-01-26 14:04:30 +01001140 if (!hotk)
1141 return -ENOMEM;
Corentin Chary85091b72007-01-26 14:04:30 +01001142
1143 hotk->handle = device->handle;
1144 strcpy(acpi_device_name(device), ASUS_HOTK_DEVICE_NAME);
1145 strcpy(acpi_device_class(device), ASUS_HOTK_CLASS);
Pavel Machekdb89b4f2008-09-22 14:37:34 -07001146 device->driver_data = hotk;
Corentin Chary85091b72007-01-26 14:04:30 +01001147 hotk->device = device;
1148
1149 result = asus_hotk_check();
1150 if (result)
1151 goto end;
1152
1153 asus_hotk_add_fs();
1154
Corentin Chary85091b72007-01-26 14:04:30 +01001155 asus_hotk_found = 1;
1156
Corentin Chary6b7091e2007-01-26 14:04:45 +01001157 /* WLED and BLED are on by default */
Corentin Chary935ffee2007-03-11 10:26:12 +01001158 write_status(bt_switch_handle, 1, BT_ON);
1159 write_status(wl_switch_handle, 1, WL_ON);
1160
1161 /* If the h/w switch is off, we need to check the real status */
1162 write_status(NULL, read_status(BT_ON), BT_ON);
1163 write_status(NULL, read_status(WL_ON), WL_ON);
Corentin Chary4564de12007-01-26 14:04:40 +01001164
Corentin Chary6b7091e2007-01-26 14:04:45 +01001165 /* LCD Backlight is on by default */
Corentin Chary935ffee2007-03-11 10:26:12 +01001166 write_status(NULL, 1, LCD_ON);
Corentin Chary6b7091e2007-01-26 14:04:45 +01001167
Corentin Chary722ad972007-01-26 14:04:55 +01001168 /* LED display is off by default */
1169 hotk->ledd_status = 0xFFF;
1170
Len Brown8def05f2007-01-30 01:46:43 -05001171 /* Set initial values of light sensor and level */
1172 hotk->light_switch = 1; /* Default to light sensor disabled */
1173 hotk->light_level = 0; /* level 5 for sensor sensitivity */
Corentin Chary8b857352007-01-26 14:04:58 +01001174
Len Brown8def05f2007-01-30 01:46:43 -05001175 if (ls_switch_handle)
1176 set_light_sens_switch(hotk->light_switch);
Corentin Chary8b857352007-01-26 14:04:58 +01001177
Len Brown8def05f2007-01-30 01:46:43 -05001178 if (ls_level_handle)
1179 set_light_sens_level(hotk->light_level);
Corentin Chary8b857352007-01-26 14:04:58 +01001180
Corentin Charye539c2f2007-05-06 14:47:06 +02001181 /* GPS is on by default */
1182 write_status(NULL, 1, GPS_ON);
1183
Corentin Charyed6f4422009-01-20 16:17:45 +01001184end:
Corentin Chary85091b72007-01-26 14:04:30 +01001185 if (result) {
1186 kfree(hotk->name);
1187 kfree(hotk);
1188 }
1189
1190 return result;
1191}
1192
1193static int asus_hotk_remove(struct acpi_device *device, int type)
1194{
Corentin Chary85091b72007-01-26 14:04:30 +01001195 if (!device || !acpi_driver_data(device))
1196 return -EINVAL;
1197
Corentin Chary85091b72007-01-26 14:04:30 +01001198 kfree(hotk->name);
1199 kfree(hotk);
1200
1201 return 0;
1202}
1203
Corentin Chary6b7091e2007-01-26 14:04:45 +01001204static void asus_backlight_exit(void)
1205{
Len Brown8def05f2007-01-30 01:46:43 -05001206 if (asus_backlight_device)
Corentin Chary6b7091e2007-01-26 14:04:45 +01001207 backlight_device_unregister(asus_backlight_device);
1208}
1209
Corentin Charybe18cda2007-01-26 14:04:35 +01001210#define ASUS_LED_UNREGISTER(object) \
Guillaume Chazaraine1996a692007-08-16 18:18:53 +02001211 if (object##_led.dev) \
1212 led_classdev_unregister(&object##_led)
Corentin Charybe18cda2007-01-26 14:04:35 +01001213
1214static void asus_led_exit(void)
1215{
Al Viro3b0d7112007-07-23 11:21:34 +01001216 destroy_workqueue(led_workqueue);
Corentin Charybe18cda2007-01-26 14:04:35 +01001217 ASUS_LED_UNREGISTER(mled);
1218 ASUS_LED_UNREGISTER(tled);
1219 ASUS_LED_UNREGISTER(pled);
1220 ASUS_LED_UNREGISTER(rled);
Corentin Charyfdd8d082007-03-11 10:26:48 +01001221 ASUS_LED_UNREGISTER(gled);
Corentin Charybe18cda2007-01-26 14:04:35 +01001222}
1223
Corentin Chary034ce902009-01-20 16:17:43 +01001224static void asus_input_exit(void)
1225{
1226 if (hotk->inputdev)
1227 input_unregister_device(hotk->inputdev);
1228}
1229
Corentin Chary85091b72007-01-26 14:04:30 +01001230static void __exit asus_laptop_exit(void)
1231{
Corentin Chary6b7091e2007-01-26 14:04:45 +01001232 asus_backlight_exit();
Corentin Charybe18cda2007-01-26 14:04:35 +01001233 asus_led_exit();
Corentin Chary034ce902009-01-20 16:17:43 +01001234 asus_input_exit();
Corentin Charybe18cda2007-01-26 14:04:35 +01001235
Corentin Chary85091b72007-01-26 14:04:30 +01001236 acpi_bus_unregister_driver(&asus_hotk_driver);
Len Brown8def05f2007-01-30 01:46:43 -05001237 sysfs_remove_group(&asuspf_device->dev.kobj, &asuspf_attribute_group);
1238 platform_device_unregister(asuspf_device);
1239 platform_driver_unregister(&asuspf_driver);
Corentin Chary85091b72007-01-26 14:04:30 +01001240}
1241
Len Brown8def05f2007-01-30 01:46:43 -05001242static int asus_backlight_init(struct device *dev)
Corentin Chary6b7091e2007-01-26 14:04:45 +01001243{
1244 struct backlight_device *bd;
1245
Len Brown8def05f2007-01-30 01:46:43 -05001246 if (brightness_set_handle && lcd_switch_handle) {
1247 bd = backlight_device_register(ASUS_HOTK_FILE, dev,
Richard Purdie599a52d2007-02-10 23:07:48 +00001248 NULL, &asusbl_ops);
Len Brown8def05f2007-01-30 01:46:43 -05001249 if (IS_ERR(bd)) {
Corentin Chary6b7091e2007-01-26 14:04:45 +01001250 printk(ASUS_ERR
1251 "Could not register asus backlight device\n");
1252 asus_backlight_device = NULL;
1253 return PTR_ERR(bd);
1254 }
1255
1256 asus_backlight_device = bd;
1257
Richard Purdie599a52d2007-02-10 23:07:48 +00001258 bd->props.max_brightness = 15;
1259 bd->props.brightness = read_brightness(NULL);
1260 bd->props.power = FB_BLANK_UNBLANK;
Richard Purdie28ee0862007-02-08 22:25:09 +00001261 backlight_update_status(bd);
Corentin Chary6b7091e2007-01-26 14:04:45 +01001262 }
1263 return 0;
1264}
1265
Corentin Charybe18cda2007-01-26 14:04:35 +01001266static int asus_led_register(acpi_handle handle,
Len Brown8def05f2007-01-30 01:46:43 -05001267 struct led_classdev *ldev, struct device *dev)
Corentin Charybe18cda2007-01-26 14:04:35 +01001268{
Len Brown8def05f2007-01-30 01:46:43 -05001269 if (!handle)
Corentin Charybe18cda2007-01-26 14:04:35 +01001270 return 0;
1271
1272 return led_classdev_register(dev, ldev);
1273}
Len Brown8def05f2007-01-30 01:46:43 -05001274
Corentin Charybe18cda2007-01-26 14:04:35 +01001275#define ASUS_LED_REGISTER(object, device) \
1276 asus_led_register(object##_set_handle, &object##_led, device)
1277
Len Brown8def05f2007-01-30 01:46:43 -05001278static int asus_led_init(struct device *dev)
Corentin Charybe18cda2007-01-26 14:04:35 +01001279{
1280 int rv;
1281
1282 rv = ASUS_LED_REGISTER(mled, dev);
Len Brown8def05f2007-01-30 01:46:43 -05001283 if (rv)
Al Viro3b0d7112007-07-23 11:21:34 +01001284 goto out;
Corentin Charybe18cda2007-01-26 14:04:35 +01001285
1286 rv = ASUS_LED_REGISTER(tled, dev);
Len Brown8def05f2007-01-30 01:46:43 -05001287 if (rv)
Al Viro3b0d7112007-07-23 11:21:34 +01001288 goto out1;
Corentin Charybe18cda2007-01-26 14:04:35 +01001289
1290 rv = ASUS_LED_REGISTER(rled, dev);
Len Brown8def05f2007-01-30 01:46:43 -05001291 if (rv)
Al Viro3b0d7112007-07-23 11:21:34 +01001292 goto out2;
Corentin Charybe18cda2007-01-26 14:04:35 +01001293
1294 rv = ASUS_LED_REGISTER(pled, dev);
Len Brown8def05f2007-01-30 01:46:43 -05001295 if (rv)
Al Viro3b0d7112007-07-23 11:21:34 +01001296 goto out3;
Corentin Charybe18cda2007-01-26 14:04:35 +01001297
Corentin Charyfdd8d082007-03-11 10:26:48 +01001298 rv = ASUS_LED_REGISTER(gled, dev);
1299 if (rv)
Al Viro3b0d7112007-07-23 11:21:34 +01001300 goto out4;
Corentin Charyfdd8d082007-03-11 10:26:48 +01001301
Corentin Charybe18cda2007-01-26 14:04:35 +01001302 led_workqueue = create_singlethread_workqueue("led_workqueue");
Len Brown8def05f2007-01-30 01:46:43 -05001303 if (!led_workqueue)
Al Viro3b0d7112007-07-23 11:21:34 +01001304 goto out5;
Corentin Charybe18cda2007-01-26 14:04:35 +01001305
1306 return 0;
Al Viro3b0d7112007-07-23 11:21:34 +01001307out5:
1308 rv = -ENOMEM;
1309 ASUS_LED_UNREGISTER(gled);
1310out4:
1311 ASUS_LED_UNREGISTER(pled);
1312out3:
1313 ASUS_LED_UNREGISTER(rled);
1314out2:
1315 ASUS_LED_UNREGISTER(tled);
1316out1:
1317 ASUS_LED_UNREGISTER(mled);
1318out:
1319 return rv;
Corentin Charybe18cda2007-01-26 14:04:35 +01001320}
1321
Corentin Chary85091b72007-01-26 14:04:30 +01001322static int __init asus_laptop_init(void)
1323{
1324 int result;
1325
1326 if (acpi_disabled)
1327 return -ENODEV;
1328
Corentin Chary85091b72007-01-26 14:04:30 +01001329 result = acpi_bus_register_driver(&asus_hotk_driver);
1330 if (result < 0)
1331 return result;
1332
1333 /*
1334 * This is a bit of a kludge. We only want this module loaded
1335 * for ASUS systems, but there's currently no way to probe the
1336 * ACPI namespace for ASUS HIDs. So we just return failure if
1337 * we didn't find one, which will cause the module to be
1338 * unloaded.
1339 */
1340 if (!asus_hotk_found) {
1341 acpi_bus_unregister_driver(&asus_hotk_driver);
1342 return -ENODEV;
1343 }
1344
Corentin Chary034ce902009-01-20 16:17:43 +01001345 result = asus_input_init();
1346 if (result)
1347 goto fail_input;
1348
Len Brown8def05f2007-01-30 01:46:43 -05001349 /* Register platform stuff */
Corentin Chary85091b72007-01-26 14:04:30 +01001350 result = platform_driver_register(&asuspf_driver);
Len Brown8def05f2007-01-30 01:46:43 -05001351 if (result)
1352 goto fail_platform_driver;
Corentin Chary85091b72007-01-26 14:04:30 +01001353
Len Brown8def05f2007-01-30 01:46:43 -05001354 asuspf_device = platform_device_alloc(ASUS_HOTK_FILE, -1);
1355 if (!asuspf_device) {
1356 result = -ENOMEM;
1357 goto fail_platform_device1;
1358 }
Corentin Chary85091b72007-01-26 14:04:30 +01001359
Len Brown8def05f2007-01-30 01:46:43 -05001360 result = platform_device_add(asuspf_device);
1361 if (result)
1362 goto fail_platform_device2;
Corentin Chary85091b72007-01-26 14:04:30 +01001363
Len Brown8def05f2007-01-30 01:46:43 -05001364 result = sysfs_create_group(&asuspf_device->dev.kobj,
Corentin Chary85091b72007-01-26 14:04:30 +01001365 &asuspf_attribute_group);
Len Brown8def05f2007-01-30 01:46:43 -05001366 if (result)
1367 goto fail_sysfs;
Corentin Chary85091b72007-01-26 14:04:30 +01001368
Corentin Chary116bf2e2009-06-16 19:28:46 +00001369 result = asus_led_init(&asuspf_device->dev);
1370 if (result)
1371 goto fail_led;
1372
1373 if (!acpi_video_backlight_support()) {
1374 result = asus_backlight_init(&asuspf_device->dev);
1375 if (result)
1376 goto fail_backlight;
1377 } else
1378 printk(ASUS_INFO "Brightness ignored, must be controlled by "
1379 "ACPI video driver\n");
1380
Len Brown8def05f2007-01-30 01:46:43 -05001381 return 0;
Corentin Chary85091b72007-01-26 14:04:30 +01001382
Corentin Chary116bf2e2009-06-16 19:28:46 +00001383fail_backlight:
1384 asus_led_exit();
1385
1386fail_led:
1387 sysfs_remove_group(&asuspf_device->dev.kobj,
1388 &asuspf_attribute_group);
1389
Corentin Charyed6f4422009-01-20 16:17:45 +01001390fail_sysfs:
Len Brown8def05f2007-01-30 01:46:43 -05001391 platform_device_del(asuspf_device);
Corentin Chary85091b72007-01-26 14:04:30 +01001392
Corentin Charyed6f4422009-01-20 16:17:45 +01001393fail_platform_device2:
Corentin Chary85091b72007-01-26 14:04:30 +01001394 platform_device_put(asuspf_device);
1395
Corentin Charyed6f4422009-01-20 16:17:45 +01001396fail_platform_device1:
Len Brown8def05f2007-01-30 01:46:43 -05001397 platform_driver_unregister(&asuspf_driver);
Corentin Chary85091b72007-01-26 14:04:30 +01001398
Corentin Charyed6f4422009-01-20 16:17:45 +01001399fail_platform_driver:
Corentin Chary034ce902009-01-20 16:17:43 +01001400 asus_input_exit();
1401
Corentin Charyed6f4422009-01-20 16:17:45 +01001402fail_input:
Corentin Chary85091b72007-01-26 14:04:30 +01001403
1404 return result;
1405}
1406
1407module_init(asus_laptop_init);
1408module_exit(asus_laptop_exit);