2 * Acer WMI Laptop Extras
4 * Copyright (C) 2007-2009 Carlos Corbacho <carlos@strangeworlds.co.uk>
7 * Copyright (C) 2005-2007 E.M. Smith
8 * Copyright (C) 2007-2008 Carlos Corbacho <cathectic@gmail.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/types.h>
31 #include <linux/dmi.h>
33 #include <linux/backlight.h>
34 #include <linux/leds.h>
35 #include <linux/platform_device.h>
36 #include <linux/acpi.h>
37 #include <linux/i8042.h>
38 #include <linux/rfkill.h>
39 #include <linux/workqueue.h>
40 #include <linux/debugfs.h>
41 #include <linux/slab.h>
42 #include <linux/input.h>
43 #include <linux/input/sparse-keymap.h>
45 #include <acpi/acpi_drivers.h>
47 MODULE_AUTHOR("Carlos Corbacho");
48 MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver");
49 MODULE_LICENSE("GPL");
53 * Meaning is unknown - this number is required for writing to ACPI for AMW0
54 * (it's also used in acerhk when directly accessing the BIOS)
56 #define ACER_AMW0_WRITE 0x9610
59 * Bit masks for the AMW0 interface
61 #define ACER_AMW0_WIRELESS_MASK 0x35
62 #define ACER_AMW0_BLUETOOTH_MASK 0x34
63 #define ACER_AMW0_MAILLED_MASK 0x31
66 * Method IDs for WMID interface
68 #define ACER_WMID_GET_WIRELESS_METHODID 1
69 #define ACER_WMID_GET_BLUETOOTH_METHODID 2
70 #define ACER_WMID_GET_BRIGHTNESS_METHODID 3
71 #define ACER_WMID_SET_WIRELESS_METHODID 4
72 #define ACER_WMID_SET_BLUETOOTH_METHODID 5
73 #define ACER_WMID_SET_BRIGHTNESS_METHODID 6
74 #define ACER_WMID_GET_THREEG_METHODID 10
75 #define ACER_WMID_SET_THREEG_METHODID 11
78 * Acer ACPI method GUIDs
80 #define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB"
81 #define AMW0_GUID2 "431F16ED-0C2B-444C-B267-27DEB140CF9C"
82 #define WMID_GUID1 "6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3"
83 #define WMID_GUID2 "95764E09-FB56-4E83-B31A-37761F60994A"
84 #define WMID_GUID3 "61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
87 * Acer ACPI event GUIDs
89 #define ACERWMID_EVENT_GUID "676AA15E-6A47-4D9F-A2CC-1E6D18D14026"
91 MODULE_ALIAS("wmi:67C3371D-95A3-4C37-BB61-DD47B491DAAB");
92 MODULE_ALIAS("wmi:6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3");
93 MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
95 enum acer_wmi_event_ids
{
96 WMID_HOTKEY_EVENT
= 0x1,
99 static const struct key_entry acer_wmi_keymap
[] = {
100 {KE_KEY
, 0x01, {KEY_WLAN
} }, /* WiFi */
101 {KE_KEY
, 0x03, {KEY_WLAN
} }, /* WiFi */
102 {KE_KEY
, 0x12, {KEY_BLUETOOTH
} }, /* BT */
103 {KE_KEY
, 0x21, {KEY_PROG1
} }, /* Backup */
104 {KE_KEY
, 0x22, {KEY_PROG2
} }, /* Arcade */
105 {KE_KEY
, 0x23, {KEY_PROG3
} }, /* P_Key */
106 {KE_KEY
, 0x24, {KEY_PROG4
} }, /* Social networking_Key */
107 {KE_IGNORE
, 0x41, {KEY_MUTE
} },
108 {KE_IGNORE
, 0x42, {KEY_PREVIOUSSONG
} },
109 {KE_IGNORE
, 0x43, {KEY_NEXTSONG
} },
110 {KE_IGNORE
, 0x44, {KEY_PLAYPAUSE
} },
111 {KE_IGNORE
, 0x45, {KEY_STOP
} },
112 {KE_IGNORE
, 0x48, {KEY_VOLUMEUP
} },
113 {KE_IGNORE
, 0x49, {KEY_VOLUMEDOWN
} },
114 {KE_IGNORE
, 0x61, {KEY_SWITCHVIDEOMODE
} },
115 {KE_IGNORE
, 0x62, {KEY_BRIGHTNESSUP
} },
116 {KE_IGNORE
, 0x63, {KEY_BRIGHTNESSDOWN
} },
117 {KE_KEY
, 0x64, {KEY_SWITCHVIDEOMODE
} }, /* Display Switch */
118 {KE_IGNORE
, 0x81, {KEY_SLEEP
} },
119 {KE_KEY
, 0x82, {KEY_TOUCHPAD_TOGGLE
} }, /* Touch Pad On/Off */
120 {KE_IGNORE
, 0x83, {KEY_TOUCHPAD_TOGGLE
} },
124 static struct input_dev
*acer_wmi_input_dev
;
126 struct event_return_value
{
131 } __attribute__((packed
));
134 * GUID3 Get Device Status device flags
136 #define ACER_WMID3_GDS_WIRELESS (1<<0) /* WiFi */
137 #define ACER_WMID3_GDS_THREEG (1<<6) /* 3G */
138 #define ACER_WMID3_GDS_BLUETOOTH (1<<11) /* BT */
140 struct lm_input_params
{
141 u8 function_num
; /* Function Number */
142 u16 commun_devices
; /* Communication type devices default status */
143 u16 devices
; /* Other type devices default status */
144 u8 lm_status
; /* Launch Manager Status */
146 } __attribute__((packed
));
148 struct lm_return_value
{
149 u8 error_code
; /* Error Code */
150 u8 ec_return_value
; /* EC Return Value */
152 } __attribute__((packed
));
154 struct wmid3_gds_input_param
{ /* Get Device Status input parameter */
155 u8 function_num
; /* Function Number */
156 u8 hotkey_number
; /* Hotkey Number */
157 u16 devices
; /* Get Device */
158 } __attribute__((packed
));
160 struct wmid3_gds_return_value
{ /* Get Device Status return value*/
161 u8 error_code
; /* Error Code */
162 u8 ec_return_value
; /* EC Return Value */
163 u16 devices
; /* Current Device Status */
165 } __attribute__((packed
));
167 struct hotkey_function_type_aa
{
171 u16 commun_func_bitmap
;
172 } __attribute__((packed
));
175 * Interface capability flags
177 #define ACER_CAP_MAILLED (1<<0)
178 #define ACER_CAP_WIRELESS (1<<1)
179 #define ACER_CAP_BLUETOOTH (1<<2)
180 #define ACER_CAP_BRIGHTNESS (1<<3)
181 #define ACER_CAP_THREEG (1<<4)
182 #define ACER_CAP_ANY (0xFFFFFFFF)
185 * Interface type flags
187 enum interface_flags
{
193 #define ACER_DEFAULT_WIRELESS 0
194 #define ACER_DEFAULT_BLUETOOTH 0
195 #define ACER_DEFAULT_MAILLED 0
196 #define ACER_DEFAULT_THREEG 0
198 static int max_brightness
= 0xF;
200 static int mailled
= -1;
201 static int brightness
= -1;
202 static int threeg
= -1;
203 static int force_series
;
204 static bool ec_raw_mode
;
205 static bool has_type_aa
;
207 module_param(mailled
, int, 0444);
208 module_param(brightness
, int, 0444);
209 module_param(threeg
, int, 0444);
210 module_param(force_series
, int, 0444);
211 module_param(ec_raw_mode
, bool, 0444);
212 MODULE_PARM_DESC(mailled
, "Set initial state of Mail LED");
213 MODULE_PARM_DESC(brightness
, "Set initial LCD backlight brightness");
214 MODULE_PARM_DESC(threeg
, "Set initial state of 3G hardware");
215 MODULE_PARM_DESC(force_series
, "Force a different laptop series");
216 MODULE_PARM_DESC(ec_raw_mode
, "Enable EC raw mode");
226 struct dentry
*devices
;
230 static struct rfkill
*wireless_rfkill
;
231 static struct rfkill
*bluetooth_rfkill
;
232 static struct rfkill
*threeg_rfkill
;
233 static bool rfkill_inited
;
235 /* Each low-level interface must define at least some of the following */
236 struct wmi_interface
{
237 /* The WMI device type */
240 /* The capabilities this interface provides */
243 /* Private data for the current interface */
244 struct acer_data data
;
246 /* debugfs entries associated with this interface */
247 struct acer_debug debug
;
250 /* The static interface pointer, points to the currently detected interface */
251 static struct wmi_interface
*interface
;
254 * Embedded Controller quirks
255 * Some laptops require us to directly access the EC to either enable or query
256 * features that are not available through WMI.
266 static struct quirk_entry
*quirks
;
268 static void set_quirks(void)
274 interface
->capability
|= ACER_CAP_MAILLED
;
276 if (quirks
->brightness
)
277 interface
->capability
|= ACER_CAP_BRIGHTNESS
;
280 static int dmi_matched(const struct dmi_system_id
*dmi
)
282 quirks
= dmi
->driver_data
;
286 static struct quirk_entry quirk_unknown
= {
289 static struct quirk_entry quirk_acer_aspire_1520
= {
293 static struct quirk_entry quirk_acer_travelmate_2490
= {
297 /* This AMW0 laptop has no bluetooth */
298 static struct quirk_entry quirk_medion_md_98300
= {
302 static struct quirk_entry quirk_fujitsu_amilo_li_1718
= {
306 /* The Aspire One has a dummy ACPI-WMI interface - disable it */
307 static struct dmi_system_id __devinitdata acer_blacklist
[] = {
309 .ident
= "Acer Aspire One (SSD)",
311 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
312 DMI_MATCH(DMI_PRODUCT_NAME
, "AOA110"),
316 .ident
= "Acer Aspire One (HDD)",
318 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
319 DMI_MATCH(DMI_PRODUCT_NAME
, "AOA150"),
325 static struct dmi_system_id acer_quirks
[] = {
327 .callback
= dmi_matched
,
328 .ident
= "Acer Aspire 1360",
330 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
331 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 1360"),
333 .driver_data
= &quirk_acer_aspire_1520
,
336 .callback
= dmi_matched
,
337 .ident
= "Acer Aspire 1520",
339 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
340 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 1520"),
342 .driver_data
= &quirk_acer_aspire_1520
,
345 .callback
= dmi_matched
,
346 .ident
= "Acer Aspire 3100",
348 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
349 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 3100"),
351 .driver_data
= &quirk_acer_travelmate_2490
,
354 .callback
= dmi_matched
,
355 .ident
= "Acer Aspire 3610",
357 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
358 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 3610"),
360 .driver_data
= &quirk_acer_travelmate_2490
,
363 .callback
= dmi_matched
,
364 .ident
= "Acer Aspire 5100",
366 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
367 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5100"),
369 .driver_data
= &quirk_acer_travelmate_2490
,
372 .callback
= dmi_matched
,
373 .ident
= "Acer Aspire 5610",
375 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
376 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5610"),
378 .driver_data
= &quirk_acer_travelmate_2490
,
381 .callback
= dmi_matched
,
382 .ident
= "Acer Aspire 5630",
384 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
385 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5630"),
387 .driver_data
= &quirk_acer_travelmate_2490
,
390 .callback
= dmi_matched
,
391 .ident
= "Acer Aspire 5650",
393 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
394 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5650"),
396 .driver_data
= &quirk_acer_travelmate_2490
,
399 .callback
= dmi_matched
,
400 .ident
= "Acer Aspire 5680",
402 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
403 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5680"),
405 .driver_data
= &quirk_acer_travelmate_2490
,
408 .callback
= dmi_matched
,
409 .ident
= "Acer Aspire 9110",
411 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
412 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 9110"),
414 .driver_data
= &quirk_acer_travelmate_2490
,
417 .callback
= dmi_matched
,
418 .ident
= "Acer TravelMate 2490",
420 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
421 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 2490"),
423 .driver_data
= &quirk_acer_travelmate_2490
,
426 .callback
= dmi_matched
,
427 .ident
= "Acer TravelMate 4200",
429 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
430 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 4200"),
432 .driver_data
= &quirk_acer_travelmate_2490
,
435 .callback
= dmi_matched
,
436 .ident
= "Fujitsu Siemens Amilo Li 1718",
438 DMI_MATCH(DMI_SYS_VENDOR
, "FUJITSU SIEMENS"),
439 DMI_MATCH(DMI_PRODUCT_NAME
, "AMILO Li 1718"),
441 .driver_data
= &quirk_fujitsu_amilo_li_1718
,
444 .callback
= dmi_matched
,
445 .ident
= "Medion MD 98300",
447 DMI_MATCH(DMI_SYS_VENDOR
, "MEDION"),
448 DMI_MATCH(DMI_PRODUCT_NAME
, "WAM2030"),
450 .driver_data
= &quirk_medion_md_98300
,
455 /* Find which quirks are needed for a particular vendor/ model pair */
456 static void find_quirks(void)
459 dmi_check_system(acer_quirks
);
460 } else if (force_series
== 2490) {
461 quirks
= &quirk_acer_travelmate_2490
;
465 quirks
= &quirk_unknown
;
471 * General interface convenience methods
474 static bool has_cap(u32 cap
)
476 if ((interface
->capability
& cap
) != 0)
483 * AMW0 (V1) interface
500 static acpi_status
wmab_execute(struct wmab_args
*regbuf
,
501 struct acpi_buffer
*result
)
503 struct acpi_buffer input
;
505 input
.length
= sizeof(struct wmab_args
);
506 input
.pointer
= (u8
*)regbuf
;
508 status
= wmi_evaluate_method(AMW0_GUID1
, 1, 1, &input
, result
);
513 static acpi_status
AMW0_get_u32(u32
*value
, u32 cap
,
514 struct wmi_interface
*iface
)
520 case ACER_CAP_MAILLED
:
521 switch (quirks
->mailled
) {
523 err
= ec_read(0xA, &result
);
526 *value
= (result
>> 7) & 0x1;
530 case ACER_CAP_WIRELESS
:
531 switch (quirks
->wireless
) {
533 err
= ec_read(0x7B, &result
);
536 *value
= result
& 0x1;
539 err
= ec_read(0x71, &result
);
542 *value
= result
& 0x1;
545 err
= ec_read(0xA, &result
);
548 *value
= (result
>> 2) & 0x1;
552 case ACER_CAP_BLUETOOTH
:
553 switch (quirks
->bluetooth
) {
555 err
= ec_read(0xA, &result
);
558 *value
= (result
>> 4) & 0x1;
562 case ACER_CAP_BRIGHTNESS
:
563 switch (quirks
->brightness
) {
565 err
= ec_read(0x83, &result
);
578 static acpi_status
AMW0_set_u32(u32 value
, u32 cap
, struct wmi_interface
*iface
)
580 struct wmab_args args
;
582 args
.eax
= ACER_AMW0_WRITE
;
583 args
.ebx
= value
? (1<<8) : 0;
584 args
.ecx
= args
.edx
= 0;
587 case ACER_CAP_MAILLED
:
589 return AE_BAD_PARAMETER
;
590 args
.ebx
|= ACER_AMW0_MAILLED_MASK
;
592 case ACER_CAP_WIRELESS
:
594 return AE_BAD_PARAMETER
;
595 args
.ebx
|= ACER_AMW0_WIRELESS_MASK
;
597 case ACER_CAP_BLUETOOTH
:
599 return AE_BAD_PARAMETER
;
600 args
.ebx
|= ACER_AMW0_BLUETOOTH_MASK
;
602 case ACER_CAP_BRIGHTNESS
:
603 if (value
> max_brightness
)
604 return AE_BAD_PARAMETER
;
605 switch (quirks
->brightness
) {
607 return ec_write(0x83, value
);
614 /* Actually do the set */
615 return wmab_execute(&args
, NULL
);
618 static acpi_status
AMW0_find_mailled(void)
620 struct wmab_args args
;
622 acpi_status status
= AE_OK
;
623 struct acpi_buffer out
= { ACPI_ALLOCATE_BUFFER
, NULL
};
624 union acpi_object
*obj
;
627 args
.ebx
= args
.ecx
= args
.edx
= 0;
629 status
= wmab_execute(&args
, &out
);
630 if (ACPI_FAILURE(status
))
633 obj
= (union acpi_object
*) out
.pointer
;
634 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
635 obj
->buffer
.length
== sizeof(struct wmab_ret
)) {
636 ret
= *((struct wmab_ret
*) obj
->buffer
.pointer
);
643 interface
->capability
|= ACER_CAP_MAILLED
;
650 static acpi_status
AMW0_set_capabilities(void)
652 struct wmab_args args
;
655 struct acpi_buffer out
= { ACPI_ALLOCATE_BUFFER
, NULL
};
656 union acpi_object
*obj
;
659 * On laptops with this strange GUID (non Acer), normal probing doesn't
662 if (wmi_has_guid(AMW0_GUID2
)) {
663 interface
->capability
|= ACER_CAP_WIRELESS
;
667 args
.eax
= ACER_AMW0_WRITE
;
668 args
.ecx
= args
.edx
= 0;
670 args
.ebx
= 0xa2 << 8;
671 args
.ebx
|= ACER_AMW0_WIRELESS_MASK
;
673 status
= wmab_execute(&args
, &out
);
674 if (ACPI_FAILURE(status
))
678 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
679 obj
->buffer
.length
== sizeof(struct wmab_ret
)) {
680 ret
= *((struct wmab_ret
*) obj
->buffer
.pointer
);
687 interface
->capability
|= ACER_CAP_WIRELESS
;
690 args
.ebx
|= ACER_AMW0_BLUETOOTH_MASK
;
693 * It's ok to use existing buffer for next wmab_execute call.
694 * But we need to kfree(out.pointer) if next wmab_execute fail.
696 status
= wmab_execute(&args
, &out
);
697 if (ACPI_FAILURE(status
))
700 obj
= (union acpi_object
*) out
.pointer
;
701 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
702 && obj
->buffer
.length
== sizeof(struct wmab_ret
)) {
703 ret
= *((struct wmab_ret
*) obj
->buffer
.pointer
);
710 interface
->capability
|= ACER_CAP_BLUETOOTH
;
713 * This appears to be safe to enable, since all Wistron based laptops
714 * appear to use the same EC register for brightness, even if they
715 * differ for wireless, etc
717 if (quirks
->brightness
>= 0)
718 interface
->capability
|= ACER_CAP_BRIGHTNESS
;
726 static struct wmi_interface AMW0_interface
= {
730 static struct wmi_interface AMW0_V2_interface
= {
731 .type
= ACER_AMW0_V2
,
735 * New interface (The WMID interface)
738 WMI_execute_u32(u32 method_id
, u32 in
, u32
*out
)
740 struct acpi_buffer input
= { (acpi_size
) sizeof(u32
), (void *)(&in
) };
741 struct acpi_buffer result
= { ACPI_ALLOCATE_BUFFER
, NULL
};
742 union acpi_object
*obj
;
746 status
= wmi_evaluate_method(WMID_GUID1
, 1, method_id
, &input
, &result
);
748 if (ACPI_FAILURE(status
))
751 obj
= (union acpi_object
*) result
.pointer
;
752 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
753 (obj
->buffer
.length
== sizeof(u32
) ||
754 obj
->buffer
.length
== sizeof(u64
))) {
755 tmp
= *((u32
*) obj
->buffer
.pointer
);
763 kfree(result
.pointer
);
768 static acpi_status
WMID_get_u32(u32
*value
, u32 cap
,
769 struct wmi_interface
*iface
)
773 u32 result
, method_id
= 0;
776 case ACER_CAP_WIRELESS
:
777 method_id
= ACER_WMID_GET_WIRELESS_METHODID
;
779 case ACER_CAP_BLUETOOTH
:
780 method_id
= ACER_WMID_GET_BLUETOOTH_METHODID
;
782 case ACER_CAP_BRIGHTNESS
:
783 method_id
= ACER_WMID_GET_BRIGHTNESS_METHODID
;
785 case ACER_CAP_THREEG
:
786 method_id
= ACER_WMID_GET_THREEG_METHODID
;
788 case ACER_CAP_MAILLED
:
789 if (quirks
->mailled
== 1) {
797 status
= WMI_execute_u32(method_id
, 0, &result
);
799 if (ACPI_SUCCESS(status
))
805 static acpi_status
WMID_set_u32(u32 value
, u32 cap
, struct wmi_interface
*iface
)
811 case ACER_CAP_BRIGHTNESS
:
812 if (value
> max_brightness
)
813 return AE_BAD_PARAMETER
;
814 method_id
= ACER_WMID_SET_BRIGHTNESS_METHODID
;
816 case ACER_CAP_WIRELESS
:
818 return AE_BAD_PARAMETER
;
819 method_id
= ACER_WMID_SET_WIRELESS_METHODID
;
821 case ACER_CAP_BLUETOOTH
:
823 return AE_BAD_PARAMETER
;
824 method_id
= ACER_WMID_SET_BLUETOOTH_METHODID
;
826 case ACER_CAP_THREEG
:
828 return AE_BAD_PARAMETER
;
829 method_id
= ACER_WMID_SET_THREEG_METHODID
;
831 case ACER_CAP_MAILLED
:
833 return AE_BAD_PARAMETER
;
834 if (quirks
->mailled
== 1) {
835 param
= value
? 0x92 : 0x93;
837 i8042_command(¶m
, 0x1059);
845 return WMI_execute_u32(method_id
, (u32
)value
, NULL
);
848 static void type_aa_dmi_decode(const struct dmi_header
*header
, void *dummy
)
850 struct hotkey_function_type_aa
*type_aa
;
852 /* We are looking for OEM-specific Type AAh */
853 if (header
->type
!= 0xAA)
857 type_aa
= (struct hotkey_function_type_aa
*) header
;
859 pr_info("Function bitmap for Communication Button: 0x%x\n",
860 type_aa
->commun_func_bitmap
);
862 if (type_aa
->commun_func_bitmap
& ACER_WMID3_GDS_WIRELESS
)
863 interface
->capability
|= ACER_CAP_WIRELESS
;
864 if (type_aa
->commun_func_bitmap
& ACER_WMID3_GDS_THREEG
)
865 interface
->capability
|= ACER_CAP_THREEG
;
866 if (type_aa
->commun_func_bitmap
& ACER_WMID3_GDS_BLUETOOTH
)
867 interface
->capability
|= ACER_CAP_BLUETOOTH
;
870 static acpi_status
WMID_set_capabilities(void)
872 struct acpi_buffer out
= {ACPI_ALLOCATE_BUFFER
, NULL
};
873 union acpi_object
*obj
;
877 status
= wmi_query_block(WMID_GUID2
, 1, &out
);
878 if (ACPI_FAILURE(status
))
881 obj
= (union acpi_object
*) out
.pointer
;
882 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
883 (obj
->buffer
.length
== sizeof(u32
) ||
884 obj
->buffer
.length
== sizeof(u64
))) {
885 devices
= *((u32
*) obj
->buffer
.pointer
);
891 dmi_walk(type_aa_dmi_decode
, NULL
);
893 interface
->capability
|= ACER_CAP_WIRELESS
;
895 interface
->capability
|= ACER_CAP_THREEG
;
897 interface
->capability
|= ACER_CAP_BLUETOOTH
;
900 /* WMID always provides brightness methods */
901 interface
->capability
|= ACER_CAP_BRIGHTNESS
;
903 if (!(devices
& 0x20))
904 max_brightness
= 0x9;
910 static struct wmi_interface wmid_interface
= {
915 * Generic Device (interface-independent)
918 static acpi_status
get_u32(u32
*value
, u32 cap
)
920 acpi_status status
= AE_ERROR
;
922 switch (interface
->type
) {
924 status
= AMW0_get_u32(value
, cap
, interface
);
927 if (cap
== ACER_CAP_MAILLED
) {
928 status
= AMW0_get_u32(value
, cap
, interface
);
932 status
= WMID_get_u32(value
, cap
, interface
);
939 static acpi_status
set_u32(u32 value
, u32 cap
)
943 if (interface
->capability
& cap
) {
944 switch (interface
->type
) {
946 return AMW0_set_u32(value
, cap
, interface
);
948 if (cap
== ACER_CAP_MAILLED
)
949 return AMW0_set_u32(value
, cap
, interface
);
952 * On some models, some WMID methods don't toggle
953 * properly. For those cases, we want to run the AMW0
954 * method afterwards to be certain we've really toggled
957 if (cap
== ACER_CAP_WIRELESS
||
958 cap
== ACER_CAP_BLUETOOTH
) {
959 status
= WMID_set_u32(value
, cap
, interface
);
960 if (ACPI_FAILURE(status
))
963 return AMW0_set_u32(value
, cap
, interface
);
966 return WMID_set_u32(value
, cap
, interface
);
968 return AE_BAD_PARAMETER
;
971 return AE_BAD_PARAMETER
;
974 static void __init
acer_commandline_init(void)
977 * These will all fail silently if the value given is invalid, or the
978 * capability isn't available on the given interface
981 set_u32(mailled
, ACER_CAP_MAILLED
);
982 if (!has_type_aa
&& threeg
>= 0)
983 set_u32(threeg
, ACER_CAP_THREEG
);
985 set_u32(brightness
, ACER_CAP_BRIGHTNESS
);
989 * LED device (Mail LED only, no other LEDs known yet)
991 static void mail_led_set(struct led_classdev
*led_cdev
,
992 enum led_brightness value
)
994 set_u32(value
, ACER_CAP_MAILLED
);
997 static struct led_classdev mail_led
= {
998 .name
= "acer-wmi::mail",
999 .brightness_set
= mail_led_set
,
1002 static int __devinit
acer_led_init(struct device
*dev
)
1004 return led_classdev_register(dev
, &mail_led
);
1007 static void acer_led_exit(void)
1009 set_u32(LED_OFF
, ACER_CAP_MAILLED
);
1010 led_classdev_unregister(&mail_led
);
1016 static struct backlight_device
*acer_backlight_device
;
1018 static int read_brightness(struct backlight_device
*bd
)
1021 get_u32(&value
, ACER_CAP_BRIGHTNESS
);
1025 static int update_bl_status(struct backlight_device
*bd
)
1027 int intensity
= bd
->props
.brightness
;
1029 if (bd
->props
.power
!= FB_BLANK_UNBLANK
)
1031 if (bd
->props
.fb_blank
!= FB_BLANK_UNBLANK
)
1034 set_u32(intensity
, ACER_CAP_BRIGHTNESS
);
1039 static const struct backlight_ops acer_bl_ops
= {
1040 .get_brightness
= read_brightness
,
1041 .update_status
= update_bl_status
,
1044 static int __devinit
acer_backlight_init(struct device
*dev
)
1046 struct backlight_properties props
;
1047 struct backlight_device
*bd
;
1049 memset(&props
, 0, sizeof(struct backlight_properties
));
1050 props
.type
= BACKLIGHT_PLATFORM
;
1051 props
.max_brightness
= max_brightness
;
1052 bd
= backlight_device_register("acer-wmi", dev
, NULL
, &acer_bl_ops
,
1055 pr_err("Could not register Acer backlight device\n");
1056 acer_backlight_device
= NULL
;
1060 acer_backlight_device
= bd
;
1062 bd
->props
.power
= FB_BLANK_UNBLANK
;
1063 bd
->props
.brightness
= read_brightness(bd
);
1064 backlight_update_status(bd
);
1068 static void acer_backlight_exit(void)
1070 backlight_device_unregister(acer_backlight_device
);
1073 static acpi_status
wmid3_get_device_status(u32
*value
, u16 device
)
1075 struct wmid3_gds_return_value return_value
;
1077 union acpi_object
*obj
;
1078 struct wmid3_gds_input_param params
= {
1079 .function_num
= 0x1,
1080 .hotkey_number
= 0x01,
1083 struct acpi_buffer input
= {
1084 sizeof(struct wmid3_gds_input_param
),
1087 struct acpi_buffer output
= { ACPI_ALLOCATE_BUFFER
, NULL
};
1089 status
= wmi_evaluate_method(WMID_GUID3
, 0, 0x2, &input
, &output
);
1090 if (ACPI_FAILURE(status
))
1093 obj
= output
.pointer
;
1097 else if (obj
->type
!= ACPI_TYPE_BUFFER
) {
1101 if (obj
->buffer
.length
!= 8) {
1102 pr_warn("Unknown buffer length %d\n", obj
->buffer
.length
);
1107 return_value
= *((struct wmid3_gds_return_value
*)obj
->buffer
.pointer
);
1110 if (return_value
.error_code
|| return_value
.ec_return_value
)
1111 pr_warn("Get Device Status failed: 0x%x - 0x%x\n",
1112 return_value
.error_code
,
1113 return_value
.ec_return_value
);
1115 *value
= !!(return_value
.devices
& device
);
1120 static acpi_status
get_device_status(u32
*value
, u32 cap
)
1122 if (wmi_has_guid(WMID_GUID3
)) {
1126 case ACER_CAP_WIRELESS
:
1127 device
= ACER_WMID3_GDS_WIRELESS
;
1129 case ACER_CAP_BLUETOOTH
:
1130 device
= ACER_WMID3_GDS_BLUETOOTH
;
1132 case ACER_CAP_THREEG
:
1133 device
= ACER_WMID3_GDS_THREEG
;
1138 return wmid3_get_device_status(value
, device
);
1141 return get_u32(value
, cap
);
1148 static void acer_rfkill_update(struct work_struct
*ignored
);
1149 static DECLARE_DELAYED_WORK(acer_rfkill_work
, acer_rfkill_update
);
1150 static void acer_rfkill_update(struct work_struct
*ignored
)
1155 status
= get_u32(&state
, ACER_CAP_WIRELESS
);
1156 if (ACPI_SUCCESS(status
))
1157 rfkill_set_sw_state(wireless_rfkill
, !state
);
1159 if (has_cap(ACER_CAP_BLUETOOTH
)) {
1160 status
= get_u32(&state
, ACER_CAP_BLUETOOTH
);
1161 if (ACPI_SUCCESS(status
))
1162 rfkill_set_sw_state(bluetooth_rfkill
, !state
);
1165 if (has_cap(ACER_CAP_THREEG
) && wmi_has_guid(WMID_GUID3
)) {
1166 status
= wmid3_get_device_status(&state
,
1167 ACER_WMID3_GDS_THREEG
);
1168 if (ACPI_SUCCESS(status
))
1169 rfkill_set_sw_state(threeg_rfkill
, !state
);
1172 schedule_delayed_work(&acer_rfkill_work
, round_jiffies_relative(HZ
));
1175 static int acer_rfkill_set(void *data
, bool blocked
)
1178 u32 cap
= (unsigned long)data
;
1180 if (rfkill_inited
) {
1181 status
= set_u32(!blocked
, cap
);
1182 if (ACPI_FAILURE(status
))
1189 static const struct rfkill_ops acer_rfkill_ops
= {
1190 .set_block
= acer_rfkill_set
,
1193 static struct rfkill
*acer_rfkill_register(struct device
*dev
,
1194 enum rfkill_type type
,
1195 char *name
, u32 cap
)
1198 struct rfkill
*rfkill_dev
;
1202 rfkill_dev
= rfkill_alloc(name
, dev
, type
,
1204 (void *)(unsigned long)cap
);
1206 return ERR_PTR(-ENOMEM
);
1208 status
= get_device_status(&state
, cap
);
1210 err
= rfkill_register(rfkill_dev
);
1212 rfkill_destroy(rfkill_dev
);
1213 return ERR_PTR(err
);
1216 if (ACPI_SUCCESS(status
))
1217 rfkill_set_sw_state(rfkill_dev
, !state
);
1222 static int acer_rfkill_init(struct device
*dev
)
1224 wireless_rfkill
= acer_rfkill_register(dev
, RFKILL_TYPE_WLAN
,
1225 "acer-wireless", ACER_CAP_WIRELESS
);
1226 if (IS_ERR(wireless_rfkill
))
1227 return PTR_ERR(wireless_rfkill
);
1229 if (has_cap(ACER_CAP_BLUETOOTH
)) {
1230 bluetooth_rfkill
= acer_rfkill_register(dev
,
1231 RFKILL_TYPE_BLUETOOTH
, "acer-bluetooth",
1232 ACER_CAP_BLUETOOTH
);
1233 if (IS_ERR(bluetooth_rfkill
)) {
1234 rfkill_unregister(wireless_rfkill
);
1235 rfkill_destroy(wireless_rfkill
);
1236 return PTR_ERR(bluetooth_rfkill
);
1240 if (has_cap(ACER_CAP_THREEG
)) {
1241 threeg_rfkill
= acer_rfkill_register(dev
,
1242 RFKILL_TYPE_WWAN
, "acer-threeg",
1244 if (IS_ERR(threeg_rfkill
)) {
1245 rfkill_unregister(wireless_rfkill
);
1246 rfkill_destroy(wireless_rfkill
);
1247 rfkill_unregister(bluetooth_rfkill
);
1248 rfkill_destroy(bluetooth_rfkill
);
1249 return PTR_ERR(threeg_rfkill
);
1253 rfkill_inited
= true;
1255 if (ec_raw_mode
|| !wmi_has_guid(ACERWMID_EVENT_GUID
))
1256 schedule_delayed_work(&acer_rfkill_work
,
1257 round_jiffies_relative(HZ
));
1262 static void acer_rfkill_exit(void)
1264 if (ec_raw_mode
|| !wmi_has_guid(ACERWMID_EVENT_GUID
))
1265 cancel_delayed_work_sync(&acer_rfkill_work
);
1267 rfkill_unregister(wireless_rfkill
);
1268 rfkill_destroy(wireless_rfkill
);
1270 if (has_cap(ACER_CAP_BLUETOOTH
)) {
1271 rfkill_unregister(bluetooth_rfkill
);
1272 rfkill_destroy(bluetooth_rfkill
);
1275 if (has_cap(ACER_CAP_THREEG
)) {
1276 rfkill_unregister(threeg_rfkill
);
1277 rfkill_destroy(threeg_rfkill
);
1285 static ssize_t
show_bool_threeg(struct device
*dev
,
1286 struct device_attribute
*attr
, char *buf
)
1290 if (wmi_has_guid(WMID_GUID3
))
1291 status
= wmid3_get_device_status(&result
,
1292 ACER_WMID3_GDS_THREEG
);
1294 status
= get_u32(&result
, ACER_CAP_THREEG
);
1295 if (ACPI_SUCCESS(status
))
1296 return sprintf(buf
, "%u\n", result
);
1297 return sprintf(buf
, "Read error\n");
1300 static ssize_t
set_bool_threeg(struct device
*dev
,
1301 struct device_attribute
*attr
, const char *buf
, size_t count
)
1303 u32 tmp
= simple_strtoul(buf
, NULL
, 10);
1304 acpi_status status
= set_u32(tmp
, ACER_CAP_THREEG
);
1305 if (ACPI_FAILURE(status
))
1309 static DEVICE_ATTR(threeg
, S_IRUGO
| S_IWUSR
, show_bool_threeg
,
1312 static ssize_t
show_interface(struct device
*dev
, struct device_attribute
*attr
,
1315 switch (interface
->type
) {
1317 return sprintf(buf
, "AMW0\n");
1319 return sprintf(buf
, "AMW0 v2\n");
1321 return sprintf(buf
, "WMID\n");
1323 return sprintf(buf
, "Error!\n");
1327 static DEVICE_ATTR(interface
, S_IRUGO
, show_interface
, NULL
);
1329 static void acer_wmi_notify(u32 value
, void *context
)
1331 struct acpi_buffer response
= { ACPI_ALLOCATE_BUFFER
, NULL
};
1332 union acpi_object
*obj
;
1333 struct event_return_value return_value
;
1336 status
= wmi_get_event_data(value
, &response
);
1337 if (status
!= AE_OK
) {
1338 pr_warn("bad event status 0x%x\n", status
);
1342 obj
= (union acpi_object
*)response
.pointer
;
1346 if (obj
->type
!= ACPI_TYPE_BUFFER
) {
1347 pr_warn("Unknown response received %d\n", obj
->type
);
1351 if (obj
->buffer
.length
!= 8) {
1352 pr_warn("Unknown buffer length %d\n", obj
->buffer
.length
);
1357 return_value
= *((struct event_return_value
*)obj
->buffer
.pointer
);
1360 switch (return_value
.function
) {
1361 case WMID_HOTKEY_EVENT
:
1362 if (return_value
.device_state
) {
1363 u16 device_state
= return_value
.device_state
;
1364 pr_debug("device state: 0x%x\n", device_state
);
1365 if (has_cap(ACER_CAP_WIRELESS
))
1366 rfkill_set_sw_state(wireless_rfkill
,
1367 !(device_state
& ACER_WMID3_GDS_WIRELESS
));
1368 if (has_cap(ACER_CAP_BLUETOOTH
))
1369 rfkill_set_sw_state(bluetooth_rfkill
,
1370 !(device_state
& ACER_WMID3_GDS_BLUETOOTH
));
1371 if (has_cap(ACER_CAP_THREEG
))
1372 rfkill_set_sw_state(threeg_rfkill
,
1373 !(device_state
& ACER_WMID3_GDS_THREEG
));
1375 if (!sparse_keymap_report_event(acer_wmi_input_dev
,
1376 return_value
.key_num
, 1, true))
1377 pr_warn("Unknown key number - 0x%x\n",
1378 return_value
.key_num
);
1381 pr_warn("Unknown function number - %d - %d\n",
1382 return_value
.function
, return_value
.key_num
);
1388 wmid3_set_lm_mode(struct lm_input_params
*params
,
1389 struct lm_return_value
*return_value
)
1392 union acpi_object
*obj
;
1394 struct acpi_buffer input
= { sizeof(struct lm_input_params
), params
};
1395 struct acpi_buffer output
= { ACPI_ALLOCATE_BUFFER
, NULL
};
1397 status
= wmi_evaluate_method(WMID_GUID3
, 0, 0x1, &input
, &output
);
1398 if (ACPI_FAILURE(status
))
1401 obj
= output
.pointer
;
1405 else if (obj
->type
!= ACPI_TYPE_BUFFER
) {
1409 if (obj
->buffer
.length
!= 4) {
1410 pr_warn("Unknown buffer length %d\n", obj
->buffer
.length
);
1415 *return_value
= *((struct lm_return_value
*)obj
->buffer
.pointer
);
1421 static int acer_wmi_enable_ec_raw(void)
1423 struct lm_return_value return_value
;
1425 struct lm_input_params params
= {
1426 .function_num
= 0x1,
1427 .commun_devices
= 0xFFFF,
1429 .lm_status
= 0x00, /* Launch Manager Deactive */
1432 status
= wmid3_set_lm_mode(¶ms
, &return_value
);
1434 if (return_value
.error_code
|| return_value
.ec_return_value
)
1435 pr_warn("Enabling EC raw mode failed: 0x%x - 0x%x\n",
1436 return_value
.error_code
,
1437 return_value
.ec_return_value
);
1439 pr_info("Enabled EC raw mode\n");
1444 static int acer_wmi_enable_lm(void)
1446 struct lm_return_value return_value
;
1448 struct lm_input_params params
= {
1449 .function_num
= 0x1,
1450 .commun_devices
= 0xFFFF,
1452 .lm_status
= 0x01, /* Launch Manager Active */
1455 status
= wmid3_set_lm_mode(¶ms
, &return_value
);
1457 if (return_value
.error_code
|| return_value
.ec_return_value
)
1458 pr_warn("Enabling Launch Manager failed: 0x%x - 0x%x\n",
1459 return_value
.error_code
,
1460 return_value
.ec_return_value
);
1465 static int __init
acer_wmi_input_setup(void)
1470 acer_wmi_input_dev
= input_allocate_device();
1471 if (!acer_wmi_input_dev
)
1474 acer_wmi_input_dev
->name
= "Acer WMI hotkeys";
1475 acer_wmi_input_dev
->phys
= "wmi/input0";
1476 acer_wmi_input_dev
->id
.bustype
= BUS_HOST
;
1478 err
= sparse_keymap_setup(acer_wmi_input_dev
, acer_wmi_keymap
, NULL
);
1482 status
= wmi_install_notify_handler(ACERWMID_EVENT_GUID
,
1483 acer_wmi_notify
, NULL
);
1484 if (ACPI_FAILURE(status
)) {
1486 goto err_free_keymap
;
1489 err
= input_register_device(acer_wmi_input_dev
);
1491 goto err_uninstall_notifier
;
1495 err_uninstall_notifier
:
1496 wmi_remove_notify_handler(ACERWMID_EVENT_GUID
);
1498 sparse_keymap_free(acer_wmi_input_dev
);
1500 input_free_device(acer_wmi_input_dev
);
1504 static void acer_wmi_input_destroy(void)
1506 wmi_remove_notify_handler(ACERWMID_EVENT_GUID
);
1507 sparse_keymap_free(acer_wmi_input_dev
);
1508 input_unregister_device(acer_wmi_input_dev
);
1514 static u32
get_wmid_devices(void)
1516 struct acpi_buffer out
= {ACPI_ALLOCATE_BUFFER
, NULL
};
1517 union acpi_object
*obj
;
1521 status
= wmi_query_block(WMID_GUID2
, 1, &out
);
1522 if (ACPI_FAILURE(status
))
1525 obj
= (union acpi_object
*) out
.pointer
;
1526 if (obj
&& obj
->type
== ACPI_TYPE_BUFFER
&&
1527 (obj
->buffer
.length
== sizeof(u32
) ||
1528 obj
->buffer
.length
== sizeof(u64
))) {
1529 devices
= *((u32
*) obj
->buffer
.pointer
);
1539 static int __devinit
acer_platform_probe(struct platform_device
*device
)
1543 if (has_cap(ACER_CAP_MAILLED
)) {
1544 err
= acer_led_init(&device
->dev
);
1549 if (has_cap(ACER_CAP_BRIGHTNESS
)) {
1550 err
= acer_backlight_init(&device
->dev
);
1552 goto error_brightness
;
1555 err
= acer_rfkill_init(&device
->dev
);
1562 if (has_cap(ACER_CAP_BRIGHTNESS
))
1563 acer_backlight_exit();
1565 if (has_cap(ACER_CAP_MAILLED
))
1571 static int acer_platform_remove(struct platform_device
*device
)
1573 if (has_cap(ACER_CAP_MAILLED
))
1575 if (has_cap(ACER_CAP_BRIGHTNESS
))
1576 acer_backlight_exit();
1582 static int acer_platform_suspend(struct platform_device
*dev
,
1586 struct acer_data
*data
= &interface
->data
;
1591 if (has_cap(ACER_CAP_MAILLED
)) {
1592 get_u32(&value
, ACER_CAP_MAILLED
);
1593 set_u32(LED_OFF
, ACER_CAP_MAILLED
);
1594 data
->mailled
= value
;
1597 if (has_cap(ACER_CAP_BRIGHTNESS
)) {
1598 get_u32(&value
, ACER_CAP_BRIGHTNESS
);
1599 data
->brightness
= value
;
1605 static int acer_platform_resume(struct platform_device
*device
)
1607 struct acer_data
*data
= &interface
->data
;
1612 if (has_cap(ACER_CAP_MAILLED
))
1613 set_u32(data
->mailled
, ACER_CAP_MAILLED
);
1615 if (has_cap(ACER_CAP_BRIGHTNESS
))
1616 set_u32(data
->brightness
, ACER_CAP_BRIGHTNESS
);
1621 static void acer_platform_shutdown(struct platform_device
*device
)
1623 struct acer_data
*data
= &interface
->data
;
1628 if (has_cap(ACER_CAP_MAILLED
))
1629 set_u32(LED_OFF
, ACER_CAP_MAILLED
);
1632 static struct platform_driver acer_platform_driver
= {
1635 .owner
= THIS_MODULE
,
1637 .probe
= acer_platform_probe
,
1638 .remove
= acer_platform_remove
,
1639 .suspend
= acer_platform_suspend
,
1640 .resume
= acer_platform_resume
,
1641 .shutdown
= acer_platform_shutdown
,
1644 static struct platform_device
*acer_platform_device
;
1646 static int remove_sysfs(struct platform_device
*device
)
1648 if (has_cap(ACER_CAP_THREEG
))
1649 device_remove_file(&device
->dev
, &dev_attr_threeg
);
1651 device_remove_file(&device
->dev
, &dev_attr_interface
);
1656 static int create_sysfs(void)
1658 int retval
= -ENOMEM
;
1660 if (has_cap(ACER_CAP_THREEG
)) {
1661 retval
= device_create_file(&acer_platform_device
->dev
,
1667 retval
= device_create_file(&acer_platform_device
->dev
,
1668 &dev_attr_interface
);
1675 remove_sysfs(acer_platform_device
);
1679 static void remove_debugfs(void)
1681 debugfs_remove(interface
->debug
.devices
);
1682 debugfs_remove(interface
->debug
.root
);
1685 static int create_debugfs(void)
1687 interface
->debug
.root
= debugfs_create_dir("acer-wmi", NULL
);
1688 if (!interface
->debug
.root
) {
1689 pr_err("Failed to create debugfs directory");
1693 interface
->debug
.devices
= debugfs_create_u32("devices", S_IRUGO
,
1694 interface
->debug
.root
,
1695 &interface
->debug
.wmid_devices
);
1696 if (!interface
->debug
.devices
)
1706 static int __init
acer_wmi_init(void)
1710 pr_info("Acer Laptop ACPI-WMI Extras\n");
1712 if (dmi_check_system(acer_blacklist
)) {
1713 pr_info("Blacklisted hardware detected - not loading\n");
1720 * Detect which ACPI-WMI interface we're using.
1722 if (wmi_has_guid(AMW0_GUID1
) && wmi_has_guid(WMID_GUID1
))
1723 interface
= &AMW0_V2_interface
;
1725 if (!wmi_has_guid(AMW0_GUID1
) && wmi_has_guid(WMID_GUID1
))
1726 interface
= &wmid_interface
;
1728 if (wmi_has_guid(WMID_GUID2
) && interface
) {
1729 if (ACPI_FAILURE(WMID_set_capabilities())) {
1730 pr_err("Unable to detect available WMID devices\n");
1733 } else if (!wmi_has_guid(WMID_GUID2
) && interface
) {
1734 pr_err("No WMID device detection method found\n");
1738 if (wmi_has_guid(AMW0_GUID1
) && !wmi_has_guid(WMID_GUID1
)) {
1739 interface
= &AMW0_interface
;
1741 if (ACPI_FAILURE(AMW0_set_capabilities())) {
1742 pr_err("Unable to detect available AMW0 devices\n");
1747 if (wmi_has_guid(AMW0_GUID1
))
1748 AMW0_find_mailled();
1751 pr_err("No or unsupported WMI interface, unable to load\n");
1757 if (acpi_video_backlight_support() && has_cap(ACER_CAP_BRIGHTNESS
)) {
1758 interface
->capability
&= ~ACER_CAP_BRIGHTNESS
;
1759 pr_info("Brightness must be controlled by "
1760 "generic video driver\n");
1763 if (wmi_has_guid(WMID_GUID3
)) {
1765 if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
1766 pr_err("Cannot enable EC raw mode\n");
1769 } else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
1770 pr_err("Cannot enable Launch Manager mode\n");
1773 } else if (ec_raw_mode
) {
1774 pr_info("No WMID EC raw mode enable method\n");
1777 if (wmi_has_guid(ACERWMID_EVENT_GUID
)) {
1778 err
= acer_wmi_input_setup();
1783 err
= platform_driver_register(&acer_platform_driver
);
1785 pr_err("Unable to register platform driver.\n");
1786 goto error_platform_register
;
1789 acer_platform_device
= platform_device_alloc("acer-wmi", -1);
1790 if (!acer_platform_device
) {
1792 goto error_device_alloc
;
1795 err
= platform_device_add(acer_platform_device
);
1797 goto error_device_add
;
1799 err
= create_sysfs();
1801 goto error_create_sys
;
1803 if (wmi_has_guid(WMID_GUID2
)) {
1804 interface
->debug
.wmid_devices
= get_wmid_devices();
1805 err
= create_debugfs();
1807 goto error_create_debugfs
;
1810 /* Override any initial settings with values from the commandline */
1811 acer_commandline_init();
1815 error_create_debugfs
:
1816 remove_sysfs(acer_platform_device
);
1818 platform_device_del(acer_platform_device
);
1820 platform_device_put(acer_platform_device
);
1822 platform_driver_unregister(&acer_platform_driver
);
1823 error_platform_register
:
1824 if (wmi_has_guid(ACERWMID_EVENT_GUID
))
1825 acer_wmi_input_destroy();
1830 static void __exit
acer_wmi_exit(void)
1832 if (wmi_has_guid(ACERWMID_EVENT_GUID
))
1833 acer_wmi_input_destroy();
1835 remove_sysfs(acer_platform_device
);
1837 platform_device_unregister(acer_platform_device
);
1838 platform_driver_unregister(&acer_platform_driver
);
1840 pr_info("Acer Laptop WMI Extras unloaded\n");
1844 module_init(acer_wmi_init
);
1845 module_exit(acer_wmi_exit
);