2008-02-05 10:17:10 +08:00
|
|
|
/*
|
|
|
|
* Acer WMI Laptop Extras
|
|
|
|
*
|
2009-04-04 16:33:39 +08:00
|
|
|
* Copyright (C) 2007-2009 Carlos Corbacho <carlos@strangeworlds.co.uk>
|
2008-02-05 10:17:10 +08:00
|
|
|
*
|
|
|
|
* Based on acer_acpi:
|
|
|
|
* Copyright (C) 2005-2007 E.M. Smith
|
|
|
|
* Copyright (C) 2007-2008 Carlos Corbacho <cathectic@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2011-03-16 18:52:36 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/dmi.h>
|
2008-06-21 16:09:27 +08:00
|
|
|
#include <linux/fb.h>
|
2008-02-05 10:17:10 +08:00
|
|
|
#include <linux/backlight.h>
|
|
|
|
#include <linux/leds.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/i8042.h>
|
2008-10-09 04:40:21 +08:00
|
|
|
#include <linux/rfkill.h>
|
|
|
|
#include <linux/workqueue.h>
|
2008-06-21 16:09:53 +08:00
|
|
|
#include <linux/debugfs.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2010-12-07 10:29:20 +08:00
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/input/sparse-keymap.h>
|
2012-03-27 03:47:58 +08:00
|
|
|
#include <acpi/video.h>
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Carlos Corbacho");
|
|
|
|
MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Magic Number
|
|
|
|
* Meaning is unknown - this number is required for writing to ACPI for AMW0
|
|
|
|
* (it's also used in acerhk when directly accessing the BIOS)
|
|
|
|
*/
|
|
|
|
#define ACER_AMW0_WRITE 0x9610
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bit masks for the AMW0 interface
|
|
|
|
*/
|
|
|
|
#define ACER_AMW0_WIRELESS_MASK 0x35
|
|
|
|
#define ACER_AMW0_BLUETOOTH_MASK 0x34
|
|
|
|
#define ACER_AMW0_MAILLED_MASK 0x31
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Method IDs for WMID interface
|
|
|
|
*/
|
|
|
|
#define ACER_WMID_GET_WIRELESS_METHODID 1
|
|
|
|
#define ACER_WMID_GET_BLUETOOTH_METHODID 2
|
|
|
|
#define ACER_WMID_GET_BRIGHTNESS_METHODID 3
|
|
|
|
#define ACER_WMID_SET_WIRELESS_METHODID 4
|
|
|
|
#define ACER_WMID_SET_BLUETOOTH_METHODID 5
|
|
|
|
#define ACER_WMID_SET_BRIGHTNESS_METHODID 6
|
|
|
|
#define ACER_WMID_GET_THREEG_METHODID 10
|
|
|
|
#define ACER_WMID_SET_THREEG_METHODID 11
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Acer ACPI method GUIDs
|
|
|
|
*/
|
|
|
|
#define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB"
|
2008-06-21 16:09:48 +08:00
|
|
|
#define AMW0_GUID2 "431F16ED-0C2B-444C-B267-27DEB140CF9C"
|
2011-02-10 05:39:40 +08:00
|
|
|
#define WMID_GUID1 "6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3"
|
2011-03-12 01:36:43 +08:00
|
|
|
#define WMID_GUID2 "95764E09-FB56-4E83-B31A-37761F60994A"
|
2010-12-07 10:29:22 +08:00
|
|
|
#define WMID_GUID3 "61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
|
2008-02-05 10:17:10 +08:00
|
|
|
|
2010-12-07 10:29:20 +08:00
|
|
|
/*
|
|
|
|
* Acer ACPI event GUIDs
|
|
|
|
*/
|
|
|
|
#define ACERWMID_EVENT_GUID "676AA15E-6A47-4D9F-A2CC-1E6D18D14026"
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
MODULE_ALIAS("wmi:67C3371D-95A3-4C37-BB61-DD47B491DAAB");
|
2011-04-06 17:40:06 +08:00
|
|
|
MODULE_ALIAS("wmi:6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3");
|
2010-12-07 10:29:20 +08:00
|
|
|
MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
|
|
|
|
|
|
|
|
enum acer_wmi_event_ids {
|
|
|
|
WMID_HOTKEY_EVENT = 0x1,
|
2012-06-02 01:11:22 +08:00
|
|
|
WMID_ACCEL_EVENT = 0x5,
|
2010-12-07 10:29:20 +08:00
|
|
|
};
|
|
|
|
|
2014-07-17 01:43:05 +08:00
|
|
|
static const struct key_entry acer_wmi_keymap[] __initconst = {
|
2010-12-07 10:29:20 +08:00
|
|
|
{KE_KEY, 0x01, {KEY_WLAN} }, /* WiFi */
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_KEY, 0x03, {KEY_WLAN} }, /* WiFi */
|
2011-06-22 01:00:32 +08:00
|
|
|
{KE_KEY, 0x04, {KEY_WLAN} }, /* WiFi */
|
2010-12-07 10:29:20 +08:00
|
|
|
{KE_KEY, 0x12, {KEY_BLUETOOTH} }, /* BT */
|
|
|
|
{KE_KEY, 0x21, {KEY_PROG1} }, /* Backup */
|
|
|
|
{KE_KEY, 0x22, {KEY_PROG2} }, /* Arcade */
|
|
|
|
{KE_KEY, 0x23, {KEY_PROG3} }, /* P_Key */
|
|
|
|
{KE_KEY, 0x24, {KEY_PROG4} }, /* Social networking_Key */
|
2012-01-24 04:35:35 +08:00
|
|
|
{KE_KEY, 0x29, {KEY_PROG3} }, /* P_Key for TM8372 */
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_IGNORE, 0x41, {KEY_MUTE} },
|
|
|
|
{KE_IGNORE, 0x42, {KEY_PREVIOUSSONG} },
|
2012-03-12 18:07:13 +08:00
|
|
|
{KE_IGNORE, 0x4d, {KEY_PREVIOUSSONG} },
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_IGNORE, 0x43, {KEY_NEXTSONG} },
|
2012-03-12 18:07:13 +08:00
|
|
|
{KE_IGNORE, 0x4e, {KEY_NEXTSONG} },
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_IGNORE, 0x44, {KEY_PLAYPAUSE} },
|
2012-03-12 18:07:13 +08:00
|
|
|
{KE_IGNORE, 0x4f, {KEY_PLAYPAUSE} },
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_IGNORE, 0x45, {KEY_STOP} },
|
2012-03-12 18:07:13 +08:00
|
|
|
{KE_IGNORE, 0x50, {KEY_STOP} },
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_IGNORE, 0x48, {KEY_VOLUMEUP} },
|
|
|
|
{KE_IGNORE, 0x49, {KEY_VOLUMEDOWN} },
|
2012-03-12 18:07:13 +08:00
|
|
|
{KE_IGNORE, 0x4a, {KEY_VOLUMEDOWN} },
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_IGNORE, 0x61, {KEY_SWITCHVIDEOMODE} },
|
|
|
|
{KE_IGNORE, 0x62, {KEY_BRIGHTNESSUP} },
|
|
|
|
{KE_IGNORE, 0x63, {KEY_BRIGHTNESSDOWN} },
|
2010-12-07 10:29:20 +08:00
|
|
|
{KE_KEY, 0x64, {KEY_SWITCHVIDEOMODE} }, /* Display Switch */
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_IGNORE, 0x81, {KEY_SLEEP} },
|
2012-12-14 16:14:27 +08:00
|
|
|
{KE_KEY, 0x82, {KEY_TOUCHPAD_TOGGLE} }, /* Touch Pad Toggle */
|
|
|
|
{KE_KEY, KEY_TOUCHPAD_ON, {KEY_TOUCHPAD_ON} },
|
|
|
|
{KE_KEY, KEY_TOUCHPAD_OFF, {KEY_TOUCHPAD_OFF} },
|
2011-05-24 16:35:55 +08:00
|
|
|
{KE_IGNORE, 0x83, {KEY_TOUCHPAD_TOGGLE} },
|
2012-11-27 02:35:02 +08:00
|
|
|
{KE_KEY, 0x85, {KEY_TOUCHPAD_TOGGLE} },
|
2010-12-07 10:29:20 +08:00
|
|
|
{KE_END, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct input_dev *acer_wmi_input_dev;
|
2012-06-02 01:11:22 +08:00
|
|
|
static struct input_dev *acer_wmi_accel_dev;
|
2010-12-07 10:29:20 +08:00
|
|
|
|
|
|
|
struct event_return_value {
|
|
|
|
u8 function;
|
|
|
|
u8 key_num;
|
|
|
|
u16 device_state;
|
|
|
|
u32 reserved;
|
|
|
|
} __attribute__((packed));
|
2008-02-05 10:17:10 +08:00
|
|
|
|
2010-12-07 10:29:22 +08:00
|
|
|
/*
|
|
|
|
* GUID3 Get Device Status device flags
|
|
|
|
*/
|
2010-12-07 10:29:23 +08:00
|
|
|
#define ACER_WMID3_GDS_WIRELESS (1<<0) /* WiFi */
|
2010-12-07 10:29:22 +08:00
|
|
|
#define ACER_WMID3_GDS_THREEG (1<<6) /* 3G */
|
2011-05-22 07:33:54 +08:00
|
|
|
#define ACER_WMID3_GDS_WIMAX (1<<7) /* WiMAX */
|
2010-12-07 10:29:23 +08:00
|
|
|
#define ACER_WMID3_GDS_BLUETOOTH (1<<11) /* BT */
|
2012-12-14 16:14:27 +08:00
|
|
|
#define ACER_WMID3_GDS_TOUCHPAD (1<<1) /* Touchpad */
|
2010-12-07 10:29:22 +08:00
|
|
|
|
2011-01-08 06:25:14 +08:00
|
|
|
struct lm_input_params {
|
|
|
|
u8 function_num; /* Function Number */
|
|
|
|
u16 commun_devices; /* Communication type devices default status */
|
|
|
|
u16 devices; /* Other type devices default status */
|
|
|
|
u8 lm_status; /* Launch Manager Status */
|
|
|
|
u16 reserved;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct lm_return_value {
|
|
|
|
u8 error_code; /* Error Code */
|
|
|
|
u8 ec_return_value; /* EC Return Value */
|
|
|
|
u16 reserved;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2012-03-19 17:37:33 +08:00
|
|
|
struct wmid3_gds_set_input_param { /* Set Device Status input parameter */
|
|
|
|
u8 function_num; /* Function Number */
|
|
|
|
u8 hotkey_number; /* Hotkey Number */
|
|
|
|
u16 devices; /* Set Device */
|
|
|
|
u8 volume_value; /* Volume Value */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct wmid3_gds_get_input_param { /* Get Device Status input parameter */
|
2010-12-07 10:29:22 +08:00
|
|
|
u8 function_num; /* Function Number */
|
|
|
|
u8 hotkey_number; /* Hotkey Number */
|
|
|
|
u16 devices; /* Get Device */
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct wmid3_gds_return_value { /* Get Device Status return value*/
|
|
|
|
u8 error_code; /* Error Code */
|
|
|
|
u8 ec_return_value; /* EC Return Value */
|
|
|
|
u16 devices; /* Current Device Status */
|
|
|
|
u32 reserved;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2010-12-07 10:29:23 +08:00
|
|
|
struct hotkey_function_type_aa {
|
|
|
|
u8 type;
|
|
|
|
u8 length;
|
|
|
|
u16 handle;
|
|
|
|
u16 commun_func_bitmap;
|
2012-03-19 17:37:32 +08:00
|
|
|
u16 application_func_bitmap;
|
|
|
|
u16 media_func_bitmap;
|
|
|
|
u16 display_func_bitmap;
|
|
|
|
u16 others_func_bitmap;
|
|
|
|
u8 commun_fn_key_number;
|
2010-12-07 10:29:23 +08:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
/*
|
|
|
|
* Interface capability flags
|
|
|
|
*/
|
|
|
|
#define ACER_CAP_MAILLED (1<<0)
|
|
|
|
#define ACER_CAP_WIRELESS (1<<1)
|
|
|
|
#define ACER_CAP_BLUETOOTH (1<<2)
|
|
|
|
#define ACER_CAP_BRIGHTNESS (1<<3)
|
|
|
|
#define ACER_CAP_THREEG (1<<4)
|
2012-06-02 01:11:22 +08:00
|
|
|
#define ACER_CAP_ACCEL (1<<5)
|
2008-02-05 10:17:10 +08:00
|
|
|
#define ACER_CAP_ANY (0xFFFFFFFF)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface type flags
|
|
|
|
*/
|
|
|
|
enum interface_flags {
|
|
|
|
ACER_AMW0,
|
|
|
|
ACER_AMW0_V2,
|
|
|
|
ACER_WMID,
|
2011-08-18 18:47:32 +08:00
|
|
|
ACER_WMID_v2,
|
2008-02-05 10:17:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ACER_DEFAULT_WIRELESS 0
|
|
|
|
#define ACER_DEFAULT_BLUETOOTH 0
|
|
|
|
#define ACER_DEFAULT_MAILLED 0
|
|
|
|
#define ACER_DEFAULT_THREEG 0
|
|
|
|
|
|
|
|
static int max_brightness = 0xF;
|
|
|
|
|
|
|
|
static int mailled = -1;
|
|
|
|
static int brightness = -1;
|
|
|
|
static int threeg = -1;
|
|
|
|
static int force_series;
|
2011-01-08 06:25:14 +08:00
|
|
|
static bool ec_raw_mode;
|
2010-12-07 10:29:23 +08:00
|
|
|
static bool has_type_aa;
|
2011-10-06 19:06:13 +08:00
|
|
|
static u16 commun_func_bitmap;
|
2012-03-19 17:37:32 +08:00
|
|
|
static u8 commun_fn_key_number;
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
module_param(mailled, int, 0444);
|
|
|
|
module_param(brightness, int, 0444);
|
|
|
|
module_param(threeg, int, 0444);
|
|
|
|
module_param(force_series, int, 0444);
|
2011-01-08 06:25:14 +08:00
|
|
|
module_param(ec_raw_mode, bool, 0444);
|
2008-02-05 10:17:10 +08:00
|
|
|
MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
|
|
|
|
MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
|
|
|
|
MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
|
|
|
|
MODULE_PARM_DESC(force_series, "Force a different laptop series");
|
2011-01-08 06:25:14 +08:00
|
|
|
MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
struct acer_data {
|
|
|
|
int mailled;
|
|
|
|
int threeg;
|
|
|
|
int brightness;
|
|
|
|
};
|
|
|
|
|
2008-06-21 16:09:53 +08:00
|
|
|
struct acer_debug {
|
|
|
|
struct dentry *root;
|
|
|
|
struct dentry *devices;
|
|
|
|
u32 wmid_devices;
|
|
|
|
};
|
|
|
|
|
2008-10-09 04:40:21 +08:00
|
|
|
static struct rfkill *wireless_rfkill;
|
|
|
|
static struct rfkill *bluetooth_rfkill;
|
2010-12-07 10:29:22 +08:00
|
|
|
static struct rfkill *threeg_rfkill;
|
2011-03-28 16:52:02 +08:00
|
|
|
static bool rfkill_inited;
|
2008-10-09 04:40:21 +08:00
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
/* Each low-level interface must define at least some of the following */
|
|
|
|
struct wmi_interface {
|
|
|
|
/* The WMI device type */
|
|
|
|
u32 type;
|
|
|
|
|
|
|
|
/* The capabilities this interface provides */
|
|
|
|
u32 capability;
|
|
|
|
|
|
|
|
/* Private data for the current interface */
|
|
|
|
struct acer_data data;
|
2008-06-21 16:09:53 +08:00
|
|
|
|
|
|
|
/* debugfs entries associated with this interface */
|
|
|
|
struct acer_debug debug;
|
2008-02-05 10:17:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* The static interface pointer, points to the currently detected interface */
|
|
|
|
static struct wmi_interface *interface;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Embedded Controller quirks
|
|
|
|
* Some laptops require us to directly access the EC to either enable or query
|
|
|
|
* features that are not available through WMI.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct quirk_entry {
|
|
|
|
u8 wireless;
|
|
|
|
u8 mailled;
|
2008-06-21 16:09:22 +08:00
|
|
|
s8 brightness;
|
2008-02-05 10:17:10 +08:00
|
|
|
u8 bluetooth;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct quirk_entry *quirks;
|
|
|
|
|
|
|
|
static void set_quirks(void)
|
|
|
|
{
|
2008-08-24 12:45:21 +08:00
|
|
|
if (!interface)
|
|
|
|
return;
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
if (quirks->mailled)
|
|
|
|
interface->capability |= ACER_CAP_MAILLED;
|
|
|
|
|
|
|
|
if (quirks->brightness)
|
|
|
|
interface->capability |= ACER_CAP_BRIGHTNESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dmi_matched(const struct dmi_system_id *dmi)
|
|
|
|
{
|
|
|
|
quirks = dmi->driver_data;
|
2010-06-30 13:32:16 +08:00
|
|
|
return 1;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct quirk_entry quirk_unknown = {
|
|
|
|
};
|
|
|
|
|
2008-06-21 16:09:22 +08:00
|
|
|
static struct quirk_entry quirk_acer_aspire_1520 = {
|
|
|
|
.brightness = -1,
|
|
|
|
};
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
static struct quirk_entry quirk_acer_travelmate_2490 = {
|
|
|
|
.mailled = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This AMW0 laptop has no bluetooth */
|
|
|
|
static struct quirk_entry quirk_medion_md_98300 = {
|
|
|
|
.wireless = 1,
|
|
|
|
};
|
|
|
|
|
2008-06-21 16:09:38 +08:00
|
|
|
static struct quirk_entry quirk_fujitsu_amilo_li_1718 = {
|
|
|
|
.wireless = 2,
|
|
|
|
};
|
|
|
|
|
2011-07-30 17:00:45 +08:00
|
|
|
static struct quirk_entry quirk_lenovo_ideapad_s205 = {
|
|
|
|
.wireless = 3,
|
|
|
|
};
|
|
|
|
|
2009-04-04 16:33:29 +08:00
|
|
|
/* The Aspire One has a dummy ACPI-WMI interface - disable it */
|
2012-12-22 05:18:33 +08:00
|
|
|
static struct dmi_system_id acer_blacklist[] = {
|
2009-04-04 16:33:29 +08:00
|
|
|
{
|
|
|
|
.ident = "Acer Aspire One (SSD)",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "AOA110"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.ident = "Acer Aspire One (HDD)",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "AOA150"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
static struct dmi_system_id acer_quirks[] = {
|
2008-06-21 16:09:22 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 1360",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_aspire_1520,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 1520",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1520"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_aspire_1520,
|
|
|
|
},
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 3100",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3100"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
2008-03-13 04:13:00 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 3610",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3610"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 5100",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
2008-03-13 04:13:00 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 5610",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 5630",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 5650",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 5680",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer Aspire 9110",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer TravelMate 2490",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
2008-02-16 08:02:56 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Acer TravelMate 4200",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4200"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_acer_travelmate_2490,
|
|
|
|
},
|
2008-06-21 16:09:38 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Fujitsu Siemens Amilo Li 1718",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Li 1718"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_fujitsu_amilo_li_1718,
|
|
|
|
},
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Medion MD 98300",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "WAM2030"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_medion_md_98300,
|
|
|
|
},
|
2011-07-30 17:00:45 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Lenovo Ideapad S205",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "10382LG"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_lenovo_ideapad_s205,
|
|
|
|
},
|
2012-03-20 11:32:49 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Lenovo Ideapad S205 (Brazos)",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Brazos"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_lenovo_ideapad_s205,
|
|
|
|
},
|
2011-10-07 04:01:55 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Lenovo 3000 N200",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "0687A31"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_fujitsu_amilo_li_1718,
|
|
|
|
},
|
2012-12-14 16:14:25 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Lenovo Ideapad S205-10382JG",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "10382JG"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_lenovo_ideapad_s205,
|
|
|
|
},
|
2012-12-14 16:14:28 +08:00
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "Lenovo Ideapad S205-1038DPG",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "1038DPG"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_lenovo_ideapad_s205,
|
|
|
|
},
|
2008-02-05 10:17:10 +08:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2012-03-27 03:47:58 +08:00
|
|
|
static int video_set_backlight_video_vendor(const struct dmi_system_id *d)
|
|
|
|
{
|
|
|
|
interface->capability &= ~ACER_CAP_BRIGHTNESS;
|
|
|
|
pr_info("Brightness must be controlled by generic video driver\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct dmi_system_id video_vendor_dmi_table[] = {
|
|
|
|
{
|
|
|
|
.callback = video_set_backlight_video_vendor,
|
|
|
|
.ident = "Acer TravelMate 4750",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4750"),
|
|
|
|
},
|
|
|
|
},
|
2012-05-21 23:19:51 +08:00
|
|
|
{
|
|
|
|
.callback = video_set_backlight_video_vendor,
|
|
|
|
.ident = "Acer Extensa 5235",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5235"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = video_set_backlight_video_vendor,
|
|
|
|
.ident = "Acer TravelMate 5760",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5760"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = video_set_backlight_video_vendor,
|
|
|
|
.ident = "Acer Aspire 5750",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5750"),
|
|
|
|
},
|
|
|
|
},
|
2014-05-17 16:48:03 +08:00
|
|
|
{
|
|
|
|
.callback = video_set_backlight_video_vendor,
|
|
|
|
.ident = "Acer Aspire 5741",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_BOARD_VENDOR, "Acer"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"),
|
|
|
|
},
|
|
|
|
},
|
2012-03-27 03:47:58 +08:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
/* Find which quirks are needed for a particular vendor/ model pair */
|
|
|
|
static void find_quirks(void)
|
|
|
|
{
|
|
|
|
if (!force_series) {
|
|
|
|
dmi_check_system(acer_quirks);
|
|
|
|
} else if (force_series == 2490) {
|
|
|
|
quirks = &quirk_acer_travelmate_2490;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quirks == NULL)
|
|
|
|
quirks = &quirk_unknown;
|
|
|
|
|
|
|
|
set_quirks();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* General interface convenience methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool has_cap(u32 cap)
|
|
|
|
{
|
|
|
|
if ((interface->capability & cap) != 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AMW0 (V1) interface
|
|
|
|
*/
|
|
|
|
struct wmab_args {
|
|
|
|
u32 eax;
|
|
|
|
u32 ebx;
|
|
|
|
u32 ecx;
|
|
|
|
u32 edx;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wmab_ret {
|
|
|
|
u32 eax;
|
|
|
|
u32 ebx;
|
|
|
|
u32 ecx;
|
|
|
|
u32 edx;
|
|
|
|
u32 eex;
|
|
|
|
};
|
|
|
|
|
|
|
|
static acpi_status wmab_execute(struct wmab_args *regbuf,
|
|
|
|
struct acpi_buffer *result)
|
|
|
|
{
|
|
|
|
struct acpi_buffer input;
|
|
|
|
acpi_status status;
|
|
|
|
input.length = sizeof(struct wmab_args);
|
|
|
|
input.pointer = (u8 *)regbuf;
|
|
|
|
|
|
|
|
status = wmi_evaluate_method(AMW0_GUID1, 1, 1, &input, result);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2012-01-09 14:26:44 +08:00
|
|
|
static acpi_status AMW0_get_u32(u32 *value, u32 cap)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u8 result;
|
|
|
|
|
|
|
|
switch (cap) {
|
|
|
|
case ACER_CAP_MAILLED:
|
|
|
|
switch (quirks->mailled) {
|
|
|
|
default:
|
|
|
|
err = ec_read(0xA, &result);
|
|
|
|
if (err)
|
|
|
|
return AE_ERROR;
|
|
|
|
*value = (result >> 7) & 0x1;
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACER_CAP_WIRELESS:
|
|
|
|
switch (quirks->wireless) {
|
|
|
|
case 1:
|
|
|
|
err = ec_read(0x7B, &result);
|
|
|
|
if (err)
|
|
|
|
return AE_ERROR;
|
|
|
|
*value = result & 0x1;
|
|
|
|
return AE_OK;
|
2008-06-21 16:09:38 +08:00
|
|
|
case 2:
|
|
|
|
err = ec_read(0x71, &result);
|
|
|
|
if (err)
|
|
|
|
return AE_ERROR;
|
|
|
|
*value = result & 0x1;
|
|
|
|
return AE_OK;
|
2011-07-30 17:00:45 +08:00
|
|
|
case 3:
|
|
|
|
err = ec_read(0x78, &result);
|
|
|
|
if (err)
|
|
|
|
return AE_ERROR;
|
|
|
|
*value = result & 0x1;
|
|
|
|
return AE_OK;
|
2008-02-05 10:17:10 +08:00
|
|
|
default:
|
|
|
|
err = ec_read(0xA, &result);
|
|
|
|
if (err)
|
|
|
|
return AE_ERROR;
|
|
|
|
*value = (result >> 2) & 0x1;
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BLUETOOTH:
|
|
|
|
switch (quirks->bluetooth) {
|
|
|
|
default:
|
|
|
|
err = ec_read(0xA, &result);
|
|
|
|
if (err)
|
|
|
|
return AE_ERROR;
|
|
|
|
*value = (result >> 4) & 0x1;
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BRIGHTNESS:
|
|
|
|
switch (quirks->brightness) {
|
|
|
|
default:
|
|
|
|
err = ec_read(0x83, &result);
|
|
|
|
if (err)
|
|
|
|
return AE_ERROR;
|
|
|
|
*value = result;
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2008-08-08 11:57:11 +08:00
|
|
|
return AE_ERROR;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-09 14:26:44 +08:00
|
|
|
static acpi_status AMW0_set_u32(u32 value, u32 cap)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
struct wmab_args args;
|
|
|
|
|
|
|
|
args.eax = ACER_AMW0_WRITE;
|
|
|
|
args.ebx = value ? (1<<8) : 0;
|
|
|
|
args.ecx = args.edx = 0;
|
|
|
|
|
|
|
|
switch (cap) {
|
|
|
|
case ACER_CAP_MAILLED:
|
|
|
|
if (value > 1)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
args.ebx |= ACER_AMW0_MAILLED_MASK;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_WIRELESS:
|
|
|
|
if (value > 1)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
args.ebx |= ACER_AMW0_WIRELESS_MASK;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BLUETOOTH:
|
|
|
|
if (value > 1)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
args.ebx |= ACER_AMW0_BLUETOOTH_MASK;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BRIGHTNESS:
|
|
|
|
if (value > max_brightness)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
switch (quirks->brightness) {
|
|
|
|
default:
|
2008-02-09 07:51:49 +08:00
|
|
|
return ec_write(0x83, value);
|
|
|
|
break;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
default:
|
2008-08-08 11:57:11 +08:00
|
|
|
return AE_ERROR;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Actually do the set */
|
|
|
|
return wmab_execute(&args, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_status AMW0_find_mailled(void)
|
|
|
|
{
|
|
|
|
struct wmab_args args;
|
|
|
|
struct wmab_ret ret;
|
|
|
|
acpi_status status = AE_OK;
|
|
|
|
struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
union acpi_object *obj;
|
|
|
|
|
|
|
|
args.eax = 0x86;
|
|
|
|
args.ebx = args.ecx = args.edx = 0;
|
|
|
|
|
|
|
|
status = wmab_execute(&args, &out);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
obj = (union acpi_object *) out.pointer;
|
|
|
|
if (obj && obj->type == ACPI_TYPE_BUFFER &&
|
|
|
|
obj->buffer.length == sizeof(struct wmab_ret)) {
|
|
|
|
ret = *((struct wmab_ret *) obj->buffer.pointer);
|
|
|
|
} else {
|
2010-07-21 06:19:53 +08:00
|
|
|
kfree(out.pointer);
|
2008-02-05 10:17:10 +08:00
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.eex & 0x1)
|
|
|
|
interface->capability |= ACER_CAP_MAILLED;
|
|
|
|
|
|
|
|
kfree(out.pointer);
|
|
|
|
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
2012-02-03 16:46:39 +08:00
|
|
|
static int AMW0_set_cap_acpi_check_device_found;
|
|
|
|
|
|
|
|
static acpi_status AMW0_set_cap_acpi_check_device_cb(acpi_handle handle,
|
|
|
|
u32 level, void *context, void **retval)
|
|
|
|
{
|
|
|
|
AMW0_set_cap_acpi_check_device_found = 1;
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct acpi_device_id norfkill_ids[] = {
|
|
|
|
{ "VPC2004", 0},
|
|
|
|
{ "IBM0068", 0},
|
|
|
|
{ "LEN0068", 0},
|
2012-03-23 12:36:44 +08:00
|
|
|
{ "SNY5001", 0}, /* sony-laptop in charge */
|
2012-02-03 16:46:39 +08:00
|
|
|
{ "", 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int AMW0_set_cap_acpi_check_device(void)
|
|
|
|
{
|
|
|
|
const struct acpi_device_id *id;
|
|
|
|
|
|
|
|
for (id = norfkill_ids; id->id[0]; id++)
|
|
|
|
acpi_get_devices(id->id, AMW0_set_cap_acpi_check_device_cb,
|
|
|
|
NULL, NULL);
|
|
|
|
return AMW0_set_cap_acpi_check_device_found;
|
|
|
|
}
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
static acpi_status AMW0_set_capabilities(void)
|
|
|
|
{
|
|
|
|
struct wmab_args args;
|
|
|
|
struct wmab_ret ret;
|
2010-07-21 06:19:53 +08:00
|
|
|
acpi_status status;
|
2008-02-05 10:17:10 +08:00
|
|
|
struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
union acpi_object *obj;
|
|
|
|
|
2008-06-21 16:09:48 +08:00
|
|
|
/*
|
|
|
|
* On laptops with this strange GUID (non Acer), normal probing doesn't
|
|
|
|
* work.
|
|
|
|
*/
|
|
|
|
if (wmi_has_guid(AMW0_GUID2)) {
|
2012-02-03 16:46:39 +08:00
|
|
|
if ((quirks != &quirk_unknown) ||
|
|
|
|
!AMW0_set_cap_acpi_check_device())
|
|
|
|
interface->capability |= ACER_CAP_WIRELESS;
|
2008-06-21 16:09:48 +08:00
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
args.eax = ACER_AMW0_WRITE;
|
|
|
|
args.ecx = args.edx = 0;
|
|
|
|
|
|
|
|
args.ebx = 0xa2 << 8;
|
|
|
|
args.ebx |= ACER_AMW0_WIRELESS_MASK;
|
|
|
|
|
|
|
|
status = wmab_execute(&args, &out);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
2010-07-21 06:19:53 +08:00
|
|
|
obj = out.pointer;
|
2008-02-05 10:17:10 +08:00
|
|
|
if (obj && obj->type == ACPI_TYPE_BUFFER &&
|
|
|
|
obj->buffer.length == sizeof(struct wmab_ret)) {
|
|
|
|
ret = *((struct wmab_ret *) obj->buffer.pointer);
|
|
|
|
} else {
|
2010-07-21 06:19:53 +08:00
|
|
|
status = AE_ERROR;
|
|
|
|
goto out;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.eax & 0x1)
|
|
|
|
interface->capability |= ACER_CAP_WIRELESS;
|
|
|
|
|
|
|
|
args.ebx = 2 << 8;
|
|
|
|
args.ebx |= ACER_AMW0_BLUETOOTH_MASK;
|
|
|
|
|
2010-07-21 06:19:53 +08:00
|
|
|
/*
|
|
|
|
* It's ok to use existing buffer for next wmab_execute call.
|
|
|
|
* But we need to kfree(out.pointer) if next wmab_execute fail.
|
|
|
|
*/
|
2008-02-05 10:17:10 +08:00
|
|
|
status = wmab_execute(&args, &out);
|
|
|
|
if (ACPI_FAILURE(status))
|
2010-07-21 06:19:53 +08:00
|
|
|
goto out;
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
obj = (union acpi_object *) out.pointer;
|
|
|
|
if (obj && obj->type == ACPI_TYPE_BUFFER
|
|
|
|
&& obj->buffer.length == sizeof(struct wmab_ret)) {
|
|
|
|
ret = *((struct wmab_ret *) obj->buffer.pointer);
|
|
|
|
} else {
|
2010-07-21 06:19:53 +08:00
|
|
|
status = AE_ERROR;
|
|
|
|
goto out;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret.eax & 0x1)
|
|
|
|
interface->capability |= ACER_CAP_BLUETOOTH;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This appears to be safe to enable, since all Wistron based laptops
|
|
|
|
* appear to use the same EC register for brightness, even if they
|
|
|
|
* differ for wireless, etc
|
|
|
|
*/
|
2008-06-21 16:09:22 +08:00
|
|
|
if (quirks->brightness >= 0)
|
|
|
|
interface->capability |= ACER_CAP_BRIGHTNESS;
|
2008-02-05 10:17:10 +08:00
|
|
|
|
2010-07-21 06:19:53 +08:00
|
|
|
status = AE_OK;
|
|
|
|
out:
|
|
|
|
kfree(out.pointer);
|
|
|
|
return status;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct wmi_interface AMW0_interface = {
|
|
|
|
.type = ACER_AMW0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct wmi_interface AMW0_V2_interface = {
|
|
|
|
.type = ACER_AMW0_V2,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* New interface (The WMID interface)
|
|
|
|
*/
|
|
|
|
static acpi_status
|
|
|
|
WMI_execute_u32(u32 method_id, u32 in, u32 *out)
|
|
|
|
{
|
|
|
|
struct acpi_buffer input = { (acpi_size) sizeof(u32), (void *)(&in) };
|
|
|
|
struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
union acpi_object *obj;
|
2012-12-14 16:14:26 +08:00
|
|
|
u32 tmp = 0;
|
2008-02-05 10:17:10 +08:00
|
|
|
acpi_status status;
|
|
|
|
|
|
|
|
status = wmi_evaluate_method(WMID_GUID1, 1, method_id, &input, &result);
|
|
|
|
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
obj = (union acpi_object *) result.pointer;
|
2012-12-14 16:14:26 +08:00
|
|
|
if (obj) {
|
|
|
|
if (obj->type == ACPI_TYPE_BUFFER &&
|
|
|
|
(obj->buffer.length == sizeof(u32) ||
|
|
|
|
obj->buffer.length == sizeof(u64))) {
|
|
|
|
tmp = *((u32 *) obj->buffer.pointer);
|
|
|
|
} else if (obj->type == ACPI_TYPE_INTEGER) {
|
|
|
|
tmp = (u32) obj->integer.value;
|
|
|
|
}
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (out)
|
|
|
|
*out = tmp;
|
|
|
|
|
|
|
|
kfree(result.pointer);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2012-01-09 14:26:44 +08:00
|
|
|
static acpi_status WMID_get_u32(u32 *value, u32 cap)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
u8 tmp;
|
|
|
|
u32 result, method_id = 0;
|
|
|
|
|
|
|
|
switch (cap) {
|
|
|
|
case ACER_CAP_WIRELESS:
|
|
|
|
method_id = ACER_WMID_GET_WIRELESS_METHODID;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BLUETOOTH:
|
|
|
|
method_id = ACER_WMID_GET_BLUETOOTH_METHODID;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BRIGHTNESS:
|
|
|
|
method_id = ACER_WMID_GET_BRIGHTNESS_METHODID;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_THREEG:
|
|
|
|
method_id = ACER_WMID_GET_THREEG_METHODID;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_MAILLED:
|
|
|
|
if (quirks->mailled == 1) {
|
|
|
|
ec_read(0x9f, &tmp);
|
|
|
|
*value = tmp & 0x1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
default:
|
2008-08-08 11:57:11 +08:00
|
|
|
return AE_ERROR;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
status = WMI_execute_u32(method_id, 0, &result);
|
|
|
|
|
|
|
|
if (ACPI_SUCCESS(status))
|
|
|
|
*value = (u8)result;
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2012-01-09 14:26:44 +08:00
|
|
|
static acpi_status WMID_set_u32(u32 value, u32 cap)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
u32 method_id = 0;
|
|
|
|
char param;
|
|
|
|
|
|
|
|
switch (cap) {
|
|
|
|
case ACER_CAP_BRIGHTNESS:
|
|
|
|
if (value > max_brightness)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
method_id = ACER_WMID_SET_BRIGHTNESS_METHODID;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_WIRELESS:
|
|
|
|
if (value > 1)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
method_id = ACER_WMID_SET_WIRELESS_METHODID;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BLUETOOTH:
|
|
|
|
if (value > 1)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
method_id = ACER_WMID_SET_BLUETOOTH_METHODID;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_THREEG:
|
|
|
|
if (value > 1)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
method_id = ACER_WMID_SET_THREEG_METHODID;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_MAILLED:
|
|
|
|
if (value > 1)
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
if (quirks->mailled == 1) {
|
|
|
|
param = value ? 0x92 : 0x93;
|
2009-09-16 16:06:43 +08:00
|
|
|
i8042_lock_chip();
|
2008-02-05 10:17:10 +08:00
|
|
|
i8042_command(¶m, 0x1059);
|
2009-09-16 16:06:43 +08:00
|
|
|
i8042_unlock_chip();
|
2008-02-05 10:17:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2008-08-08 11:57:11 +08:00
|
|
|
return AE_ERROR;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
return WMI_execute_u32(method_id, (u32)value, NULL);
|
|
|
|
}
|
|
|
|
|
2011-08-18 18:47:32 +08:00
|
|
|
static acpi_status wmid3_get_device_status(u32 *value, u16 device)
|
|
|
|
{
|
|
|
|
struct wmid3_gds_return_value return_value;
|
|
|
|
acpi_status status;
|
|
|
|
union acpi_object *obj;
|
2012-03-19 17:37:33 +08:00
|
|
|
struct wmid3_gds_get_input_param params = {
|
2011-08-18 18:47:32 +08:00
|
|
|
.function_num = 0x1,
|
2012-03-19 17:37:32 +08:00
|
|
|
.hotkey_number = commun_fn_key_number,
|
2011-08-18 18:47:32 +08:00
|
|
|
.devices = device,
|
|
|
|
};
|
|
|
|
struct acpi_buffer input = {
|
2012-03-19 17:37:33 +08:00
|
|
|
sizeof(struct wmid3_gds_get_input_param),
|
2011-08-18 18:47:32 +08:00
|
|
|
¶ms
|
|
|
|
};
|
|
|
|
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
|
|
|
|
status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input, &output);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
obj = output.pointer;
|
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
return AE_ERROR;
|
|
|
|
else if (obj->type != ACPI_TYPE_BUFFER) {
|
|
|
|
kfree(obj);
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
if (obj->buffer.length != 8) {
|
|
|
|
pr_warn("Unknown buffer length %d\n", obj->buffer.length);
|
|
|
|
kfree(obj);
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer);
|
|
|
|
kfree(obj);
|
|
|
|
|
|
|
|
if (return_value.error_code || return_value.ec_return_value)
|
|
|
|
pr_warn("Get 0x%x Device Status failed: 0x%x - 0x%x\n",
|
|
|
|
device,
|
|
|
|
return_value.error_code,
|
|
|
|
return_value.ec_return_value);
|
|
|
|
else
|
|
|
|
*value = !!(return_value.devices & device);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_status wmid_v2_get_u32(u32 *value, u32 cap)
|
|
|
|
{
|
|
|
|
u16 device;
|
|
|
|
|
|
|
|
switch (cap) {
|
|
|
|
case ACER_CAP_WIRELESS:
|
|
|
|
device = ACER_WMID3_GDS_WIRELESS;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BLUETOOTH:
|
|
|
|
device = ACER_WMID3_GDS_BLUETOOTH;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_THREEG:
|
|
|
|
device = ACER_WMID3_GDS_THREEG;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
return wmid3_get_device_status(value, device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_status wmid3_set_device_status(u32 value, u16 device)
|
|
|
|
{
|
|
|
|
struct wmid3_gds_return_value return_value;
|
|
|
|
acpi_status status;
|
|
|
|
union acpi_object *obj;
|
|
|
|
u16 devices;
|
2012-03-19 17:37:33 +08:00
|
|
|
struct wmid3_gds_get_input_param get_params = {
|
2011-08-18 18:47:32 +08:00
|
|
|
.function_num = 0x1,
|
2012-03-19 17:37:32 +08:00
|
|
|
.hotkey_number = commun_fn_key_number,
|
2011-10-06 19:06:13 +08:00
|
|
|
.devices = commun_func_bitmap,
|
2011-08-18 18:47:32 +08:00
|
|
|
};
|
2012-03-19 17:37:33 +08:00
|
|
|
struct acpi_buffer get_input = {
|
|
|
|
sizeof(struct wmid3_gds_get_input_param),
|
|
|
|
&get_params
|
|
|
|
};
|
|
|
|
struct wmid3_gds_set_input_param set_params = {
|
|
|
|
.function_num = 0x2,
|
|
|
|
.hotkey_number = commun_fn_key_number,
|
|
|
|
.devices = commun_func_bitmap,
|
|
|
|
};
|
|
|
|
struct acpi_buffer set_input = {
|
|
|
|
sizeof(struct wmid3_gds_set_input_param),
|
|
|
|
&set_params
|
2011-08-18 18:47:32 +08:00
|
|
|
};
|
|
|
|
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
struct acpi_buffer output2 = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
|
2012-03-19 17:37:33 +08:00
|
|
|
status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &get_input, &output);
|
2011-08-18 18:47:32 +08:00
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
obj = output.pointer;
|
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
return AE_ERROR;
|
|
|
|
else if (obj->type != ACPI_TYPE_BUFFER) {
|
|
|
|
kfree(obj);
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
if (obj->buffer.length != 8) {
|
2011-11-30 03:04:05 +08:00
|
|
|
pr_warn("Unknown buffer length %d\n", obj->buffer.length);
|
2011-08-18 18:47:32 +08:00
|
|
|
kfree(obj);
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer);
|
|
|
|
kfree(obj);
|
|
|
|
|
|
|
|
if (return_value.error_code || return_value.ec_return_value) {
|
2011-11-30 03:04:05 +08:00
|
|
|
pr_warn("Get Current Device Status failed: 0x%x - 0x%x\n",
|
|
|
|
return_value.error_code,
|
2011-08-18 18:47:32 +08:00
|
|
|
return_value.ec_return_value);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
devices = return_value.devices;
|
2012-03-19 17:37:33 +08:00
|
|
|
set_params.devices = (value) ? (devices | device) : (devices & ~device);
|
2011-08-18 18:47:32 +08:00
|
|
|
|
2012-03-19 17:37:33 +08:00
|
|
|
status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &set_input, &output2);
|
2011-08-18 18:47:32 +08:00
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
obj = output2.pointer;
|
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
return AE_ERROR;
|
|
|
|
else if (obj->type != ACPI_TYPE_BUFFER) {
|
|
|
|
kfree(obj);
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
if (obj->buffer.length != 4) {
|
2011-11-30 03:04:05 +08:00
|
|
|
pr_warn("Unknown buffer length %d\n", obj->buffer.length);
|
2011-08-18 18:47:32 +08:00
|
|
|
kfree(obj);
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer);
|
|
|
|
kfree(obj);
|
|
|
|
|
|
|
|
if (return_value.error_code || return_value.ec_return_value)
|
2011-11-30 03:04:05 +08:00
|
|
|
pr_warn("Set Device Status failed: 0x%x - 0x%x\n",
|
|
|
|
return_value.error_code,
|
2011-08-18 18:47:32 +08:00
|
|
|
return_value.ec_return_value);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_status wmid_v2_set_u32(u32 value, u32 cap)
|
|
|
|
{
|
|
|
|
u16 device;
|
|
|
|
|
|
|
|
switch (cap) {
|
|
|
|
case ACER_CAP_WIRELESS:
|
|
|
|
device = ACER_WMID3_GDS_WIRELESS;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_BLUETOOTH:
|
|
|
|
device = ACER_WMID3_GDS_BLUETOOTH;
|
|
|
|
break;
|
|
|
|
case ACER_CAP_THREEG:
|
|
|
|
device = ACER_WMID3_GDS_THREEG;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
return wmid3_set_device_status(value, device);
|
|
|
|
}
|
|
|
|
|
2010-12-07 10:29:23 +08:00
|
|
|
static void type_aa_dmi_decode(const struct dmi_header *header, void *dummy)
|
|
|
|
{
|
|
|
|
struct hotkey_function_type_aa *type_aa;
|
|
|
|
|
|
|
|
/* We are looking for OEM-specific Type AAh */
|
|
|
|
if (header->type != 0xAA)
|
|
|
|
return;
|
|
|
|
|
|
|
|
has_type_aa = true;
|
|
|
|
type_aa = (struct hotkey_function_type_aa *) header;
|
|
|
|
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_info("Function bitmap for Communication Button: 0x%x\n",
|
2010-12-07 10:29:23 +08:00
|
|
|
type_aa->commun_func_bitmap);
|
2011-10-06 19:06:13 +08:00
|
|
|
commun_func_bitmap = type_aa->commun_func_bitmap;
|
2010-12-07 10:29:23 +08:00
|
|
|
|
|
|
|
if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_WIRELESS)
|
|
|
|
interface->capability |= ACER_CAP_WIRELESS;
|
|
|
|
if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_THREEG)
|
|
|
|
interface->capability |= ACER_CAP_THREEG;
|
|
|
|
if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_BLUETOOTH)
|
|
|
|
interface->capability |= ACER_CAP_BLUETOOTH;
|
2012-03-19 17:37:32 +08:00
|
|
|
|
|
|
|
commun_fn_key_number = type_aa->commun_fn_key_number;
|
2010-12-07 10:29:23 +08:00
|
|
|
}
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
static acpi_status WMID_set_capabilities(void)
|
|
|
|
{
|
|
|
|
struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
|
|
|
|
union acpi_object *obj;
|
|
|
|
acpi_status status;
|
|
|
|
u32 devices;
|
|
|
|
|
|
|
|
status = wmi_query_block(WMID_GUID2, 1, &out);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
obj = (union acpi_object *) out.pointer;
|
2012-12-14 16:14:26 +08:00
|
|
|
if (obj) {
|
|
|
|
if (obj->type == ACPI_TYPE_BUFFER &&
|
|
|
|
(obj->buffer.length == sizeof(u32) ||
|
|
|
|
obj->buffer.length == sizeof(u64))) {
|
|
|
|
devices = *((u32 *) obj->buffer.pointer);
|
|
|
|
} else if (obj->type == ACPI_TYPE_INTEGER) {
|
|
|
|
devices = (u32) obj->integer.value;
|
2013-01-03 10:37:45 +08:00
|
|
|
} else {
|
|
|
|
kfree(out.pointer);
|
|
|
|
return AE_ERROR;
|
2012-12-14 16:14:26 +08:00
|
|
|
}
|
2008-02-05 10:17:10 +08:00
|
|
|
} else {
|
2010-07-21 06:19:52 +08:00
|
|
|
kfree(out.pointer);
|
2008-02-05 10:17:10 +08:00
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
|
2011-08-18 18:47:34 +08:00
|
|
|
pr_info("Function bitmap for Communication Device: 0x%x\n", devices);
|
|
|
|
if (devices & 0x07)
|
|
|
|
interface->capability |= ACER_CAP_WIRELESS;
|
2011-08-18 18:47:32 +08:00
|
|
|
if (devices & 0x40)
|
|
|
|
interface->capability |= ACER_CAP_THREEG;
|
|
|
|
if (devices & 0x10)
|
|
|
|
interface->capability |= ACER_CAP_BLUETOOTH;
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
if (!(devices & 0x20))
|
|
|
|
max_brightness = 0x9;
|
|
|
|
|
2010-07-21 06:19:52 +08:00
|
|
|
kfree(out.pointer);
|
2008-02-05 10:17:10 +08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct wmi_interface wmid_interface = {
|
|
|
|
.type = ACER_WMID,
|
|
|
|
};
|
|
|
|
|
2011-08-18 18:47:32 +08:00
|
|
|
static struct wmi_interface wmid_v2_interface = {
|
|
|
|
.type = ACER_WMID_v2,
|
|
|
|
};
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
/*
|
|
|
|
* Generic Device (interface-independent)
|
|
|
|
*/
|
|
|
|
|
|
|
|
static acpi_status get_u32(u32 *value, u32 cap)
|
|
|
|
{
|
2008-08-08 11:57:11 +08:00
|
|
|
acpi_status status = AE_ERROR;
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
switch (interface->type) {
|
|
|
|
case ACER_AMW0:
|
2012-01-09 14:26:44 +08:00
|
|
|
status = AMW0_get_u32(value, cap);
|
2008-02-05 10:17:10 +08:00
|
|
|
break;
|
|
|
|
case ACER_AMW0_V2:
|
|
|
|
if (cap == ACER_CAP_MAILLED) {
|
2012-01-09 14:26:44 +08:00
|
|
|
status = AMW0_get_u32(value, cap);
|
2008-02-05 10:17:10 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ACER_WMID:
|
2012-01-09 14:26:44 +08:00
|
|
|
status = WMID_get_u32(value, cap);
|
2008-02-05 10:17:10 +08:00
|
|
|
break;
|
2011-08-18 18:47:32 +08:00
|
|
|
case ACER_WMID_v2:
|
|
|
|
if (cap & (ACER_CAP_WIRELESS |
|
|
|
|
ACER_CAP_BLUETOOTH |
|
|
|
|
ACER_CAP_THREEG))
|
|
|
|
status = wmid_v2_get_u32(value, cap);
|
|
|
|
else if (wmi_has_guid(WMID_GUID2))
|
2012-01-09 14:26:44 +08:00
|
|
|
status = WMID_get_u32(value, cap);
|
2011-08-18 18:47:32 +08:00
|
|
|
break;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_status set_u32(u32 value, u32 cap)
|
|
|
|
{
|
2008-08-07 02:13:56 +08:00
|
|
|
acpi_status status;
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
if (interface->capability & cap) {
|
|
|
|
switch (interface->type) {
|
|
|
|
case ACER_AMW0:
|
2012-01-09 14:26:44 +08:00
|
|
|
return AMW0_set_u32(value, cap);
|
2008-02-05 10:17:10 +08:00
|
|
|
case ACER_AMW0_V2:
|
2008-08-07 02:13:56 +08:00
|
|
|
if (cap == ACER_CAP_MAILLED)
|
2012-01-09 14:26:44 +08:00
|
|
|
return AMW0_set_u32(value, cap);
|
2008-08-07 02:13:56 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* On some models, some WMID methods don't toggle
|
|
|
|
* properly. For those cases, we want to run the AMW0
|
|
|
|
* method afterwards to be certain we've really toggled
|
|
|
|
* the device state.
|
|
|
|
*/
|
|
|
|
if (cap == ACER_CAP_WIRELESS ||
|
|
|
|
cap == ACER_CAP_BLUETOOTH) {
|
2012-01-09 14:26:44 +08:00
|
|
|
status = WMID_set_u32(value, cap);
|
2008-08-07 02:13:56 +08:00
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
2012-01-09 14:26:44 +08:00
|
|
|
return AMW0_set_u32(value, cap);
|
2008-08-07 02:13:56 +08:00
|
|
|
}
|
2008-02-05 10:17:10 +08:00
|
|
|
case ACER_WMID:
|
2012-01-09 14:26:44 +08:00
|
|
|
return WMID_set_u32(value, cap);
|
2011-08-18 18:47:32 +08:00
|
|
|
case ACER_WMID_v2:
|
|
|
|
if (cap & (ACER_CAP_WIRELESS |
|
|
|
|
ACER_CAP_BLUETOOTH |
|
|
|
|
ACER_CAP_THREEG))
|
|
|
|
return wmid_v2_set_u32(value, cap);
|
|
|
|
else if (wmi_has_guid(WMID_GUID2))
|
2012-01-09 14:26:44 +08:00
|
|
|
return WMID_set_u32(value, cap);
|
2008-02-05 10:17:10 +08:00
|
|
|
default:
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init acer_commandline_init(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* These will all fail silently if the value given is invalid, or the
|
|
|
|
* capability isn't available on the given interface
|
|
|
|
*/
|
2011-04-15 18:42:47 +08:00
|
|
|
if (mailled >= 0)
|
|
|
|
set_u32(mailled, ACER_CAP_MAILLED);
|
|
|
|
if (!has_type_aa && threeg >= 0)
|
2010-12-07 10:29:23 +08:00
|
|
|
set_u32(threeg, ACER_CAP_THREEG);
|
2011-04-15 18:42:47 +08:00
|
|
|
if (brightness >= 0)
|
|
|
|
set_u32(brightness, ACER_CAP_BRIGHTNESS);
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LED device (Mail LED only, no other LEDs known yet)
|
|
|
|
*/
|
|
|
|
static void mail_led_set(struct led_classdev *led_cdev,
|
|
|
|
enum led_brightness value)
|
|
|
|
{
|
|
|
|
set_u32(value, ACER_CAP_MAILLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct led_classdev mail_led = {
|
2008-02-24 21:34:18 +08:00
|
|
|
.name = "acer-wmi::mail",
|
2008-02-05 10:17:10 +08:00
|
|
|
.brightness_set = mail_led_set,
|
|
|
|
};
|
|
|
|
|
2012-12-22 05:18:33 +08:00
|
|
|
static int acer_led_init(struct device *dev)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
return led_classdev_register(dev, &mail_led);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void acer_led_exit(void)
|
|
|
|
{
|
2011-02-27 04:18:58 +08:00
|
|
|
set_u32(LED_OFF, ACER_CAP_MAILLED);
|
2008-02-05 10:17:10 +08:00
|
|
|
led_classdev_unregister(&mail_led);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Backlight device
|
|
|
|
*/
|
|
|
|
static struct backlight_device *acer_backlight_device;
|
|
|
|
|
|
|
|
static int read_brightness(struct backlight_device *bd)
|
|
|
|
{
|
|
|
|
u32 value;
|
|
|
|
get_u32(&value, ACER_CAP_BRIGHTNESS);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int update_bl_status(struct backlight_device *bd)
|
|
|
|
{
|
2008-06-21 16:09:27 +08:00
|
|
|
int intensity = bd->props.brightness;
|
|
|
|
|
|
|
|
if (bd->props.power != FB_BLANK_UNBLANK)
|
|
|
|
intensity = 0;
|
|
|
|
if (bd->props.fb_blank != FB_BLANK_UNBLANK)
|
|
|
|
intensity = 0;
|
|
|
|
|
|
|
|
set_u32(intensity, ACER_CAP_BRIGHTNESS);
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-16 21:14:02 +08:00
|
|
|
static const struct backlight_ops acer_bl_ops = {
|
2008-02-05 10:17:10 +08:00
|
|
|
.get_brightness = read_brightness,
|
|
|
|
.update_status = update_bl_status,
|
|
|
|
};
|
|
|
|
|
2012-12-22 05:18:33 +08:00
|
|
|
static int acer_backlight_init(struct device *dev)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
2010-02-18 05:39:44 +08:00
|
|
|
struct backlight_properties props;
|
2008-02-05 10:17:10 +08:00
|
|
|
struct backlight_device *bd;
|
|
|
|
|
2010-02-18 05:39:44 +08:00
|
|
|
memset(&props, 0, sizeof(struct backlight_properties));
|
2011-03-23 07:30:21 +08:00
|
|
|
props.type = BACKLIGHT_PLATFORM;
|
2010-02-18 05:39:44 +08:00
|
|
|
props.max_brightness = max_brightness;
|
|
|
|
bd = backlight_device_register("acer-wmi", dev, NULL, &acer_bl_ops,
|
|
|
|
&props);
|
2008-02-05 10:17:10 +08:00
|
|
|
if (IS_ERR(bd)) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_err("Could not register Acer backlight device\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
acer_backlight_device = NULL;
|
|
|
|
return PTR_ERR(bd);
|
|
|
|
}
|
|
|
|
|
|
|
|
acer_backlight_device = bd;
|
|
|
|
|
2008-06-21 16:09:27 +08:00
|
|
|
bd->props.power = FB_BLANK_UNBLANK;
|
2009-12-27 03:24:31 +08:00
|
|
|
bd->props.brightness = read_brightness(bd);
|
2008-02-05 10:17:10 +08:00
|
|
|
backlight_update_status(bd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-17 20:22:54 +08:00
|
|
|
static void acer_backlight_exit(void)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
backlight_device_unregister(acer_backlight_device);
|
|
|
|
}
|
|
|
|
|
2012-06-02 01:11:22 +08:00
|
|
|
/*
|
|
|
|
* Accelerometer device
|
|
|
|
*/
|
|
|
|
static acpi_handle gsensor_handle;
|
|
|
|
|
|
|
|
static int acer_gsensor_init(void)
|
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
struct acpi_buffer output;
|
|
|
|
union acpi_object out_obj;
|
|
|
|
|
|
|
|
output.length = sizeof(out_obj);
|
|
|
|
output.pointer = &out_obj;
|
|
|
|
status = acpi_evaluate_object(gsensor_handle, "_INI", NULL, &output);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acer_gsensor_open(struct input_dev *input)
|
|
|
|
{
|
|
|
|
return acer_gsensor_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acer_gsensor_event(void)
|
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
struct acpi_buffer output;
|
|
|
|
union acpi_object out_obj[5];
|
|
|
|
|
|
|
|
if (!has_cap(ACER_CAP_ACCEL))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
output.length = sizeof(out_obj);
|
|
|
|
output.pointer = out_obj;
|
|
|
|
|
|
|
|
status = acpi_evaluate_object(gsensor_handle, "RDVL", NULL, &output);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (out_obj->package.count != 4)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
input_report_abs(acer_wmi_accel_dev, ABS_X,
|
|
|
|
(s16)out_obj->package.elements[0].integer.value);
|
|
|
|
input_report_abs(acer_wmi_accel_dev, ABS_Y,
|
|
|
|
(s16)out_obj->package.elements[1].integer.value);
|
|
|
|
input_report_abs(acer_wmi_accel_dev, ABS_Z,
|
|
|
|
(s16)out_obj->package.elements[2].integer.value);
|
|
|
|
input_sync(acer_wmi_accel_dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-09 04:40:21 +08:00
|
|
|
/*
|
|
|
|
* Rfkill devices
|
|
|
|
*/
|
|
|
|
static void acer_rfkill_update(struct work_struct *ignored);
|
|
|
|
static DECLARE_DELAYED_WORK(acer_rfkill_work, acer_rfkill_update);
|
|
|
|
static void acer_rfkill_update(struct work_struct *ignored)
|
|
|
|
{
|
|
|
|
u32 state;
|
|
|
|
acpi_status status;
|
|
|
|
|
2011-08-18 18:47:33 +08:00
|
|
|
if (has_cap(ACER_CAP_WIRELESS)) {
|
|
|
|
status = get_u32(&state, ACER_CAP_WIRELESS);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
|
|
|
if (quirks->wireless == 3)
|
|
|
|
rfkill_set_hw_state(wireless_rfkill, !state);
|
|
|
|
else
|
|
|
|
rfkill_set_sw_state(wireless_rfkill, !state);
|
2011-07-30 17:00:45 +08:00
|
|
|
}
|
|
|
|
}
|
2008-10-09 04:40:21 +08:00
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_BLUETOOTH)) {
|
|
|
|
status = get_u32(&state, ACER_CAP_BLUETOOTH);
|
|
|
|
if (ACPI_SUCCESS(status))
|
2009-06-17 18:51:56 +08:00
|
|
|
rfkill_set_sw_state(bluetooth_rfkill, !state);
|
2008-10-09 04:40:21 +08:00
|
|
|
}
|
|
|
|
|
2010-12-07 10:29:22 +08:00
|
|
|
if (has_cap(ACER_CAP_THREEG) && wmi_has_guid(WMID_GUID3)) {
|
2011-08-18 18:47:32 +08:00
|
|
|
status = get_u32(&state, ACER_WMID3_GDS_THREEG);
|
2010-12-07 10:29:22 +08:00
|
|
|
if (ACPI_SUCCESS(status))
|
|
|
|
rfkill_set_sw_state(threeg_rfkill, !state);
|
|
|
|
}
|
|
|
|
|
2008-10-11 00:33:35 +08:00
|
|
|
schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ));
|
2008-10-09 04:40:21 +08:00
|
|
|
}
|
|
|
|
|
2009-06-02 19:01:37 +08:00
|
|
|
static int acer_rfkill_set(void *data, bool blocked)
|
2008-10-09 04:40:21 +08:00
|
|
|
{
|
|
|
|
acpi_status status;
|
2009-06-02 19:01:37 +08:00
|
|
|
u32 cap = (unsigned long)data;
|
2011-03-28 16:52:02 +08:00
|
|
|
|
|
|
|
if (rfkill_inited) {
|
2011-08-18 18:47:32 +08:00
|
|
|
status = set_u32(!blocked, cap);
|
2011-03-28 16:52:02 +08:00
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2008-10-09 04:40:21 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-02 19:01:37 +08:00
|
|
|
static const struct rfkill_ops acer_rfkill_ops = {
|
|
|
|
.set_block = acer_rfkill_set,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct rfkill *acer_rfkill_register(struct device *dev,
|
|
|
|
enum rfkill_type type,
|
|
|
|
char *name, u32 cap)
|
2008-10-09 04:40:21 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
struct rfkill *rfkill_dev;
|
2010-12-13 10:02:41 +08:00
|
|
|
u32 state;
|
|
|
|
acpi_status status;
|
2008-10-09 04:40:21 +08:00
|
|
|
|
2009-06-02 19:01:37 +08:00
|
|
|
rfkill_dev = rfkill_alloc(name, dev, type,
|
|
|
|
&acer_rfkill_ops,
|
|
|
|
(void *)(unsigned long)cap);
|
2008-10-09 04:40:21 +08:00
|
|
|
if (!rfkill_dev)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
2011-08-18 18:47:32 +08:00
|
|
|
status = get_u32(&state, cap);
|
2010-12-13 10:02:41 +08:00
|
|
|
|
2008-10-09 04:40:21 +08:00
|
|
|
err = rfkill_register(rfkill_dev);
|
|
|
|
if (err) {
|
2009-06-02 19:01:37 +08:00
|
|
|
rfkill_destroy(rfkill_dev);
|
2008-10-09 04:40:21 +08:00
|
|
|
return ERR_PTR(err);
|
|
|
|
}
|
2011-03-28 16:52:02 +08:00
|
|
|
|
|
|
|
if (ACPI_SUCCESS(status))
|
|
|
|
rfkill_set_sw_state(rfkill_dev, !state);
|
|
|
|
|
2008-10-09 04:40:21 +08:00
|
|
|
return rfkill_dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acer_rfkill_init(struct device *dev)
|
|
|
|
{
|
2011-08-18 18:47:33 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_WIRELESS)) {
|
|
|
|
wireless_rfkill = acer_rfkill_register(dev, RFKILL_TYPE_WLAN,
|
|
|
|
"acer-wireless", ACER_CAP_WIRELESS);
|
|
|
|
if (IS_ERR(wireless_rfkill)) {
|
|
|
|
err = PTR_ERR(wireless_rfkill);
|
|
|
|
goto error_wireless;
|
|
|
|
}
|
|
|
|
}
|
2008-10-09 04:40:21 +08:00
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_BLUETOOTH)) {
|
|
|
|
bluetooth_rfkill = acer_rfkill_register(dev,
|
|
|
|
RFKILL_TYPE_BLUETOOTH, "acer-bluetooth",
|
|
|
|
ACER_CAP_BLUETOOTH);
|
|
|
|
if (IS_ERR(bluetooth_rfkill)) {
|
2011-08-18 18:47:33 +08:00
|
|
|
err = PTR_ERR(bluetooth_rfkill);
|
|
|
|
goto error_bluetooth;
|
2008-10-09 04:40:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-07 10:29:22 +08:00
|
|
|
if (has_cap(ACER_CAP_THREEG)) {
|
|
|
|
threeg_rfkill = acer_rfkill_register(dev,
|
|
|
|
RFKILL_TYPE_WWAN, "acer-threeg",
|
|
|
|
ACER_CAP_THREEG);
|
|
|
|
if (IS_ERR(threeg_rfkill)) {
|
2011-08-18 18:47:33 +08:00
|
|
|
err = PTR_ERR(threeg_rfkill);
|
|
|
|
goto error_threeg;
|
2010-12-07 10:29:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-28 16:52:02 +08:00
|
|
|
rfkill_inited = true;
|
|
|
|
|
2011-08-18 18:47:33 +08:00
|
|
|
if ((ec_raw_mode || !wmi_has_guid(ACERWMID_EVENT_GUID)) &&
|
|
|
|
has_cap(ACER_CAP_WIRELESS | ACER_CAP_BLUETOOTH | ACER_CAP_THREEG))
|
2011-03-28 18:34:13 +08:00
|
|
|
schedule_delayed_work(&acer_rfkill_work,
|
|
|
|
round_jiffies_relative(HZ));
|
2008-10-09 04:40:21 +08:00
|
|
|
|
|
|
|
return 0;
|
2011-08-18 18:47:33 +08:00
|
|
|
|
|
|
|
error_threeg:
|
|
|
|
if (has_cap(ACER_CAP_BLUETOOTH)) {
|
|
|
|
rfkill_unregister(bluetooth_rfkill);
|
|
|
|
rfkill_destroy(bluetooth_rfkill);
|
|
|
|
}
|
|
|
|
error_bluetooth:
|
|
|
|
if (has_cap(ACER_CAP_WIRELESS)) {
|
|
|
|
rfkill_unregister(wireless_rfkill);
|
|
|
|
rfkill_destroy(wireless_rfkill);
|
|
|
|
}
|
|
|
|
error_wireless:
|
|
|
|
return err;
|
2008-10-09 04:40:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void acer_rfkill_exit(void)
|
|
|
|
{
|
2011-08-18 18:47:33 +08:00
|
|
|
if ((ec_raw_mode || !wmi_has_guid(ACERWMID_EVENT_GUID)) &&
|
|
|
|
has_cap(ACER_CAP_WIRELESS | ACER_CAP_BLUETOOTH | ACER_CAP_THREEG))
|
2011-03-28 18:34:13 +08:00
|
|
|
cancel_delayed_work_sync(&acer_rfkill_work);
|
2009-06-02 19:01:37 +08:00
|
|
|
|
2011-08-18 18:47:33 +08:00
|
|
|
if (has_cap(ACER_CAP_WIRELESS)) {
|
|
|
|
rfkill_unregister(wireless_rfkill);
|
|
|
|
rfkill_destroy(wireless_rfkill);
|
|
|
|
}
|
2009-06-02 19:01:37 +08:00
|
|
|
|
2008-10-09 04:40:21 +08:00
|
|
|
if (has_cap(ACER_CAP_BLUETOOTH)) {
|
|
|
|
rfkill_unregister(bluetooth_rfkill);
|
2009-06-02 19:01:37 +08:00
|
|
|
rfkill_destroy(bluetooth_rfkill);
|
2008-10-09 04:40:21 +08:00
|
|
|
}
|
2010-12-07 10:29:22 +08:00
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_THREEG)) {
|
|
|
|
rfkill_unregister(threeg_rfkill);
|
|
|
|
rfkill_destroy(threeg_rfkill);
|
|
|
|
}
|
2008-10-09 04:40:21 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
/*
|
2008-10-09 04:40:26 +08:00
|
|
|
* sysfs interface
|
2008-02-05 10:17:10 +08:00
|
|
|
*/
|
2008-10-09 04:40:26 +08:00
|
|
|
static ssize_t show_bool_threeg(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2008-02-05 10:17:10 +08:00
|
|
|
u32 result; \
|
2010-12-07 10:29:22 +08:00
|
|
|
acpi_status status;
|
2011-05-31 14:52:22 +08:00
|
|
|
|
2011-11-30 03:04:05 +08:00
|
|
|
pr_info("This threeg sysfs will be removed in 2012 - used by: %s\n",
|
|
|
|
current->comm);
|
2011-08-18 18:47:32 +08:00
|
|
|
status = get_u32(&result, ACER_CAP_THREEG);
|
2008-10-09 04:40:26 +08:00
|
|
|
if (ACPI_SUCCESS(status))
|
|
|
|
return sprintf(buf, "%u\n", result);
|
|
|
|
return sprintf(buf, "Read error\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t set_bool_threeg(struct device *dev,
|
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
u32 tmp = simple_strtoul(buf, NULL, 10);
|
|
|
|
acpi_status status = set_u32(tmp, ACER_CAP_THREEG);
|
2011-11-30 03:04:05 +08:00
|
|
|
pr_info("This threeg sysfs will be removed in 2012 - used by: %s\n",
|
|
|
|
current->comm);
|
2011-05-31 14:52:22 +08:00
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return -EINVAL;
|
2008-10-09 04:40:26 +08:00
|
|
|
return count;
|
|
|
|
}
|
2011-02-04 20:23:56 +08:00
|
|
|
static DEVICE_ATTR(threeg, S_IRUGO | S_IWUSR, show_bool_threeg,
|
2008-10-09 04:40:26 +08:00
|
|
|
set_bool_threeg);
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
static ssize_t show_interface(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
2011-11-30 03:04:05 +08:00
|
|
|
pr_info("This interface sysfs will be removed in 2012 - used by: %s\n",
|
|
|
|
current->comm);
|
2008-02-05 10:17:10 +08:00
|
|
|
switch (interface->type) {
|
|
|
|
case ACER_AMW0:
|
|
|
|
return sprintf(buf, "AMW0\n");
|
|
|
|
case ACER_AMW0_V2:
|
|
|
|
return sprintf(buf, "AMW0 v2\n");
|
|
|
|
case ACER_WMID:
|
|
|
|
return sprintf(buf, "WMID\n");
|
2011-08-18 18:47:32 +08:00
|
|
|
case ACER_WMID_v2:
|
|
|
|
return sprintf(buf, "WMID v2\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
default:
|
|
|
|
return sprintf(buf, "Error!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-30 10:20:23 +08:00
|
|
|
static DEVICE_ATTR(interface, S_IRUGO, show_interface, NULL);
|
2008-02-05 10:17:10 +08:00
|
|
|
|
2010-12-07 10:29:20 +08:00
|
|
|
static void acer_wmi_notify(u32 value, void *context)
|
|
|
|
{
|
|
|
|
struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
union acpi_object *obj;
|
|
|
|
struct event_return_value return_value;
|
|
|
|
acpi_status status;
|
2011-06-22 01:00:33 +08:00
|
|
|
u16 device_state;
|
|
|
|
const struct key_entry *key;
|
2012-12-14 16:14:27 +08:00
|
|
|
u32 scancode;
|
2010-12-07 10:29:20 +08:00
|
|
|
|
|
|
|
status = wmi_get_event_data(value, &response);
|
|
|
|
if (status != AE_OK) {
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_warn("bad event status 0x%x\n", status);
|
2010-12-07 10:29:20 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = (union acpi_object *)response.pointer;
|
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
return;
|
|
|
|
if (obj->type != ACPI_TYPE_BUFFER) {
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_warn("Unknown response received %d\n", obj->type);
|
2010-12-07 10:29:20 +08:00
|
|
|
kfree(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (obj->buffer.length != 8) {
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_warn("Unknown buffer length %d\n", obj->buffer.length);
|
2010-12-07 10:29:20 +08:00
|
|
|
kfree(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_value = *((struct event_return_value *)obj->buffer.pointer);
|
|
|
|
kfree(obj);
|
|
|
|
|
|
|
|
switch (return_value.function) {
|
|
|
|
case WMID_HOTKEY_EVENT:
|
2011-06-22 01:00:33 +08:00
|
|
|
device_state = return_value.device_state;
|
|
|
|
pr_debug("device state: 0x%x\n", device_state);
|
|
|
|
|
|
|
|
key = sparse_keymap_entry_from_scancode(acer_wmi_input_dev,
|
|
|
|
return_value.key_num);
|
|
|
|
if (!key) {
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_warn("Unknown key number - 0x%x\n",
|
2010-12-07 10:29:20 +08:00
|
|
|
return_value.key_num);
|
2011-06-22 01:00:33 +08:00
|
|
|
} else {
|
2012-12-14 16:14:27 +08:00
|
|
|
scancode = return_value.key_num;
|
2011-06-22 01:00:33 +08:00
|
|
|
switch (key->keycode) {
|
|
|
|
case KEY_WLAN:
|
|
|
|
case KEY_BLUETOOTH:
|
|
|
|
if (has_cap(ACER_CAP_WIRELESS))
|
|
|
|
rfkill_set_sw_state(wireless_rfkill,
|
|
|
|
!(device_state & ACER_WMID3_GDS_WIRELESS));
|
|
|
|
if (has_cap(ACER_CAP_THREEG))
|
|
|
|
rfkill_set_sw_state(threeg_rfkill,
|
|
|
|
!(device_state & ACER_WMID3_GDS_THREEG));
|
|
|
|
if (has_cap(ACER_CAP_BLUETOOTH))
|
|
|
|
rfkill_set_sw_state(bluetooth_rfkill,
|
|
|
|
!(device_state & ACER_WMID3_GDS_BLUETOOTH));
|
|
|
|
break;
|
2012-12-14 16:14:27 +08:00
|
|
|
case KEY_TOUCHPAD_TOGGLE:
|
|
|
|
scancode = (device_state & ACER_WMID3_GDS_TOUCHPAD) ?
|
|
|
|
KEY_TOUCHPAD_ON : KEY_TOUCHPAD_OFF;
|
2011-06-22 01:00:33 +08:00
|
|
|
}
|
2012-12-14 16:14:27 +08:00
|
|
|
sparse_keymap_report_event(acer_wmi_input_dev, scancode, 1, true);
|
2011-06-22 01:00:33 +08:00
|
|
|
}
|
2010-12-07 10:29:20 +08:00
|
|
|
break;
|
2012-06-02 01:11:22 +08:00
|
|
|
case WMID_ACCEL_EVENT:
|
|
|
|
acer_gsensor_event();
|
|
|
|
break;
|
2010-12-07 10:29:20 +08:00
|
|
|
default:
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_warn("Unknown function number - %d - %d\n",
|
2010-12-07 10:29:20 +08:00
|
|
|
return_value.function, return_value.key_num);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-08 06:25:14 +08:00
|
|
|
static acpi_status
|
|
|
|
wmid3_set_lm_mode(struct lm_input_params *params,
|
|
|
|
struct lm_return_value *return_value)
|
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
union acpi_object *obj;
|
|
|
|
|
|
|
|
struct acpi_buffer input = { sizeof(struct lm_input_params), params };
|
|
|
|
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
|
|
|
|
|
|
|
|
status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return status;
|
|
|
|
|
|
|
|
obj = output.pointer;
|
|
|
|
|
|
|
|
if (!obj)
|
|
|
|
return AE_ERROR;
|
|
|
|
else if (obj->type != ACPI_TYPE_BUFFER) {
|
|
|
|
kfree(obj);
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
if (obj->buffer.length != 4) {
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_warn("Unknown buffer length %d\n", obj->buffer.length);
|
2011-01-08 06:25:14 +08:00
|
|
|
kfree(obj);
|
|
|
|
return AE_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
*return_value = *((struct lm_return_value *)obj->buffer.pointer);
|
|
|
|
kfree(obj);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acer_wmi_enable_ec_raw(void)
|
|
|
|
{
|
|
|
|
struct lm_return_value return_value;
|
|
|
|
acpi_status status;
|
|
|
|
struct lm_input_params params = {
|
|
|
|
.function_num = 0x1,
|
|
|
|
.commun_devices = 0xFFFF,
|
|
|
|
.devices = 0xFFFF,
|
|
|
|
.lm_status = 0x00, /* Launch Manager Deactive */
|
|
|
|
};
|
|
|
|
|
|
|
|
status = wmid3_set_lm_mode(¶ms, &return_value);
|
|
|
|
|
|
|
|
if (return_value.error_code || return_value.ec_return_value)
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_warn("Enabling EC raw mode failed: 0x%x - 0x%x\n",
|
|
|
|
return_value.error_code,
|
|
|
|
return_value.ec_return_value);
|
2011-01-08 06:25:14 +08:00
|
|
|
else
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_info("Enabled EC raw mode\n");
|
2011-01-08 06:25:14 +08:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acer_wmi_enable_lm(void)
|
|
|
|
{
|
|
|
|
struct lm_return_value return_value;
|
|
|
|
acpi_status status;
|
|
|
|
struct lm_input_params params = {
|
|
|
|
.function_num = 0x1,
|
|
|
|
.commun_devices = 0xFFFF,
|
|
|
|
.devices = 0xFFFF,
|
|
|
|
.lm_status = 0x01, /* Launch Manager Active */
|
|
|
|
};
|
|
|
|
|
|
|
|
status = wmid3_set_lm_mode(¶ms, &return_value);
|
|
|
|
|
|
|
|
if (return_value.error_code || return_value.ec_return_value)
|
2011-03-30 06:21:34 +08:00
|
|
|
pr_warn("Enabling Launch Manager failed: 0x%x - 0x%x\n",
|
|
|
|
return_value.error_code,
|
|
|
|
return_value.ec_return_value);
|
2011-01-08 06:25:14 +08:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2012-06-02 01:11:22 +08:00
|
|
|
static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32 level,
|
|
|
|
void *ctx, void **retval)
|
|
|
|
{
|
|
|
|
*(acpi_handle *)retval = ah;
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init acer_wmi_get_handle(const char *name, const char *prop,
|
|
|
|
acpi_handle *ah)
|
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
acpi_handle handle;
|
|
|
|
|
|
|
|
BUG_ON(!name || !ah);
|
|
|
|
|
2012-07-05 07:30:09 +08:00
|
|
|
handle = NULL;
|
2012-06-02 01:11:22 +08:00
|
|
|
status = acpi_get_devices(prop, acer_wmi_get_handle_cb,
|
|
|
|
(void *)name, &handle);
|
|
|
|
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
|
|
|
*ah = handle;
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init acer_wmi_accel_setup(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = acer_wmi_get_handle("SENR", "BST0001", &gsensor_handle);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
interface->capability |= ACER_CAP_ACCEL;
|
|
|
|
|
|
|
|
acer_wmi_accel_dev = input_allocate_device();
|
|
|
|
if (!acer_wmi_accel_dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
acer_wmi_accel_dev->open = acer_gsensor_open;
|
|
|
|
|
|
|
|
acer_wmi_accel_dev->name = "Acer BMA150 accelerometer";
|
|
|
|
acer_wmi_accel_dev->phys = "wmi/input1";
|
|
|
|
acer_wmi_accel_dev->id.bustype = BUS_HOST;
|
|
|
|
acer_wmi_accel_dev->evbit[0] = BIT_MASK(EV_ABS);
|
|
|
|
input_set_abs_params(acer_wmi_accel_dev, ABS_X, -16384, 16384, 0, 0);
|
|
|
|
input_set_abs_params(acer_wmi_accel_dev, ABS_Y, -16384, 16384, 0, 0);
|
|
|
|
input_set_abs_params(acer_wmi_accel_dev, ABS_Z, -16384, 16384, 0, 0);
|
|
|
|
|
|
|
|
err = input_register_device(acer_wmi_accel_dev);
|
|
|
|
if (err)
|
|
|
|
goto err_free_dev;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_free_dev:
|
|
|
|
input_free_device(acer_wmi_accel_dev);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void acer_wmi_accel_destroy(void)
|
|
|
|
{
|
|
|
|
input_unregister_device(acer_wmi_accel_dev);
|
|
|
|
}
|
|
|
|
|
2010-12-07 10:29:20 +08:00
|
|
|
static int __init acer_wmi_input_setup(void)
|
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
acer_wmi_input_dev = input_allocate_device();
|
|
|
|
if (!acer_wmi_input_dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
acer_wmi_input_dev->name = "Acer WMI hotkeys";
|
|
|
|
acer_wmi_input_dev->phys = "wmi/input0";
|
|
|
|
acer_wmi_input_dev->id.bustype = BUS_HOST;
|
|
|
|
|
|
|
|
err = sparse_keymap_setup(acer_wmi_input_dev, acer_wmi_keymap, NULL);
|
|
|
|
if (err)
|
|
|
|
goto err_free_dev;
|
|
|
|
|
|
|
|
status = wmi_install_notify_handler(ACERWMID_EVENT_GUID,
|
|
|
|
acer_wmi_notify, NULL);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
err = -EIO;
|
|
|
|
goto err_free_keymap;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = input_register_device(acer_wmi_input_dev);
|
|
|
|
if (err)
|
|
|
|
goto err_uninstall_notifier;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_uninstall_notifier:
|
|
|
|
wmi_remove_notify_handler(ACERWMID_EVENT_GUID);
|
|
|
|
err_free_keymap:
|
|
|
|
sparse_keymap_free(acer_wmi_input_dev);
|
|
|
|
err_free_dev:
|
|
|
|
input_free_device(acer_wmi_input_dev);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void acer_wmi_input_destroy(void)
|
|
|
|
{
|
|
|
|
wmi_remove_notify_handler(ACERWMID_EVENT_GUID);
|
|
|
|
sparse_keymap_free(acer_wmi_input_dev);
|
|
|
|
input_unregister_device(acer_wmi_input_dev);
|
|
|
|
}
|
|
|
|
|
2008-06-21 16:09:53 +08:00
|
|
|
/*
|
|
|
|
* debugfs functions
|
|
|
|
*/
|
|
|
|
static u32 get_wmid_devices(void)
|
|
|
|
{
|
|
|
|
struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
|
|
|
|
union acpi_object *obj;
|
|
|
|
acpi_status status;
|
2010-07-21 06:19:52 +08:00
|
|
|
u32 devices = 0;
|
2008-06-21 16:09:53 +08:00
|
|
|
|
|
|
|
status = wmi_query_block(WMID_GUID2, 1, &out);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
obj = (union acpi_object *) out.pointer;
|
2012-12-14 16:14:26 +08:00
|
|
|
if (obj) {
|
|
|
|
if (obj->type == ACPI_TYPE_BUFFER &&
|
|
|
|
(obj->buffer.length == sizeof(u32) ||
|
|
|
|
obj->buffer.length == sizeof(u64))) {
|
|
|
|
devices = *((u32 *) obj->buffer.pointer);
|
|
|
|
} else if (obj->type == ACPI_TYPE_INTEGER) {
|
|
|
|
devices = (u32) obj->integer.value;
|
|
|
|
}
|
2008-06-21 16:09:53 +08:00
|
|
|
}
|
2010-07-21 06:19:52 +08:00
|
|
|
|
|
|
|
kfree(out.pointer);
|
|
|
|
return devices;
|
2008-06-21 16:09:53 +08:00
|
|
|
}
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
/*
|
|
|
|
* Platform device
|
|
|
|
*/
|
2012-12-22 05:18:33 +08:00
|
|
|
static int acer_platform_probe(struct platform_device *device)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_MAILLED)) {
|
|
|
|
err = acer_led_init(&device->dev);
|
|
|
|
if (err)
|
|
|
|
goto error_mailled;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_BRIGHTNESS)) {
|
|
|
|
err = acer_backlight_init(&device->dev);
|
|
|
|
if (err)
|
|
|
|
goto error_brightness;
|
|
|
|
}
|
|
|
|
|
2008-10-09 04:40:21 +08:00
|
|
|
err = acer_rfkill_init(&device->dev);
|
2009-04-04 16:33:34 +08:00
|
|
|
if (err)
|
|
|
|
goto error_rfkill;
|
2008-10-09 04:40:21 +08:00
|
|
|
|
|
|
|
return err;
|
2008-02-05 10:17:10 +08:00
|
|
|
|
2009-04-04 16:33:34 +08:00
|
|
|
error_rfkill:
|
|
|
|
if (has_cap(ACER_CAP_BRIGHTNESS))
|
|
|
|
acer_backlight_exit();
|
2008-02-05 10:17:10 +08:00
|
|
|
error_brightness:
|
2009-04-04 16:33:34 +08:00
|
|
|
if (has_cap(ACER_CAP_MAILLED))
|
|
|
|
acer_led_exit();
|
2008-02-05 10:17:10 +08:00
|
|
|
error_mailled:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acer_platform_remove(struct platform_device *device)
|
|
|
|
{
|
|
|
|
if (has_cap(ACER_CAP_MAILLED))
|
|
|
|
acer_led_exit();
|
|
|
|
if (has_cap(ACER_CAP_BRIGHTNESS))
|
|
|
|
acer_backlight_exit();
|
2008-10-09 04:40:21 +08:00
|
|
|
|
|
|
|
acer_rfkill_exit();
|
2008-02-05 10:17:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-28 05:19:35 +08:00
|
|
|
static int acer_suspend(struct device *dev)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
u32 value;
|
|
|
|
struct acer_data *data = &interface->data;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_MAILLED)) {
|
|
|
|
get_u32(&value, ACER_CAP_MAILLED);
|
2011-02-27 04:18:58 +08:00
|
|
|
set_u32(LED_OFF, ACER_CAP_MAILLED);
|
2008-02-05 10:17:10 +08:00
|
|
|
data->mailled = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_BRIGHTNESS)) {
|
|
|
|
get_u32(&value, ACER_CAP_BRIGHTNESS);
|
|
|
|
data->brightness = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-28 05:19:35 +08:00
|
|
|
static int acer_resume(struct device *dev)
|
2008-02-05 10:17:10 +08:00
|
|
|
{
|
|
|
|
struct acer_data *data = &interface->data;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_MAILLED))
|
|
|
|
set_u32(data->mailled, ACER_CAP_MAILLED);
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_BRIGHTNESS))
|
|
|
|
set_u32(data->brightness, ACER_CAP_BRIGHTNESS);
|
|
|
|
|
2012-06-02 01:11:22 +08:00
|
|
|
if (has_cap(ACER_CAP_ACCEL))
|
|
|
|
acer_gsensor_init();
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-28 05:19:35 +08:00
|
|
|
static SIMPLE_DEV_PM_OPS(acer_pm, acer_suspend, acer_resume);
|
|
|
|
|
2011-02-27 04:18:58 +08:00
|
|
|
static void acer_platform_shutdown(struct platform_device *device)
|
|
|
|
{
|
|
|
|
struct acer_data *data = &interface->data;
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_MAILLED))
|
|
|
|
set_u32(LED_OFF, ACER_CAP_MAILLED);
|
|
|
|
}
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
static struct platform_driver acer_platform_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "acer-wmi",
|
|
|
|
.owner = THIS_MODULE,
|
2012-06-28 05:19:35 +08:00
|
|
|
.pm = &acer_pm,
|
2008-02-05 10:17:10 +08:00
|
|
|
},
|
|
|
|
.probe = acer_platform_probe,
|
|
|
|
.remove = acer_platform_remove,
|
2011-02-27 04:18:58 +08:00
|
|
|
.shutdown = acer_platform_shutdown,
|
2008-02-05 10:17:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device *acer_platform_device;
|
|
|
|
|
|
|
|
static int remove_sysfs(struct platform_device *device)
|
|
|
|
{
|
|
|
|
if (has_cap(ACER_CAP_THREEG))
|
|
|
|
device_remove_file(&device->dev, &dev_attr_threeg);
|
|
|
|
|
|
|
|
device_remove_file(&device->dev, &dev_attr_interface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int create_sysfs(void)
|
|
|
|
{
|
|
|
|
int retval = -ENOMEM;
|
|
|
|
|
|
|
|
if (has_cap(ACER_CAP_THREEG)) {
|
|
|
|
retval = device_create_file(&acer_platform_device->dev,
|
|
|
|
&dev_attr_threeg);
|
|
|
|
if (retval)
|
|
|
|
goto error_sysfs;
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = device_create_file(&acer_platform_device->dev,
|
|
|
|
&dev_attr_interface);
|
|
|
|
if (retval)
|
|
|
|
goto error_sysfs;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error_sysfs:
|
|
|
|
remove_sysfs(acer_platform_device);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2008-06-21 16:09:53 +08:00
|
|
|
static void remove_debugfs(void)
|
|
|
|
{
|
|
|
|
debugfs_remove(interface->debug.devices);
|
|
|
|
debugfs_remove(interface->debug.root);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int create_debugfs(void)
|
|
|
|
{
|
|
|
|
interface->debug.root = debugfs_create_dir("acer-wmi", NULL);
|
|
|
|
if (!interface->debug.root) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_err("Failed to create debugfs directory");
|
2008-06-21 16:09:53 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface->debug.devices = debugfs_create_u32("devices", S_IRUGO,
|
|
|
|
interface->debug.root,
|
|
|
|
&interface->debug.wmid_devices);
|
|
|
|
if (!interface->debug.devices)
|
|
|
|
goto error_debugfs;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error_debugfs:
|
2008-09-03 05:35:40 +08:00
|
|
|
remove_debugfs();
|
2008-06-21 16:09:53 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
static int __init acer_wmi_init(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_info("Acer Laptop ACPI-WMI Extras\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
|
2009-04-04 16:33:29 +08:00
|
|
|
if (dmi_check_system(acer_blacklist)) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_info("Blacklisted hardware detected - not loading\n");
|
2009-04-04 16:33:29 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2008-06-21 16:09:22 +08:00
|
|
|
find_quirks();
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
/*
|
|
|
|
* Detect which ACPI-WMI interface we're using.
|
|
|
|
*/
|
|
|
|
if (wmi_has_guid(AMW0_GUID1) && wmi_has_guid(WMID_GUID1))
|
|
|
|
interface = &AMW0_V2_interface;
|
|
|
|
|
|
|
|
if (!wmi_has_guid(AMW0_GUID1) && wmi_has_guid(WMID_GUID1))
|
|
|
|
interface = &wmid_interface;
|
|
|
|
|
2011-08-18 18:47:32 +08:00
|
|
|
if (wmi_has_guid(WMID_GUID3))
|
|
|
|
interface = &wmid_v2_interface;
|
|
|
|
|
|
|
|
if (interface)
|
|
|
|
dmi_walk(type_aa_dmi_decode, NULL);
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
if (wmi_has_guid(WMID_GUID2) && interface) {
|
2011-08-18 18:47:32 +08:00
|
|
|
if (!has_type_aa && ACPI_FAILURE(WMID_set_capabilities())) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_err("Unable to detect available WMID devices\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
2011-08-18 18:47:32 +08:00
|
|
|
/* WMID always provides brightness methods */
|
|
|
|
interface->capability |= ACER_CAP_BRIGHTNESS;
|
|
|
|
} else if (!wmi_has_guid(WMID_GUID2) && interface && !has_type_aa) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_err("No WMID device detection method found\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wmi_has_guid(AMW0_GUID1) && !wmi_has_guid(WMID_GUID1)) {
|
|
|
|
interface = &AMW0_interface;
|
|
|
|
|
|
|
|
if (ACPI_FAILURE(AMW0_set_capabilities())) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_err("Unable to detect available AMW0 devices\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-24 21:34:29 +08:00
|
|
|
if (wmi_has_guid(AMW0_GUID1))
|
|
|
|
AMW0_find_mailled();
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
if (!interface) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_err("No or unsupported WMI interface, unable to load\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2008-08-24 12:45:21 +08:00
|
|
|
set_quirks();
|
|
|
|
|
2012-06-13 15:32:02 +08:00
|
|
|
if (dmi_check_system(video_vendor_dmi_table))
|
|
|
|
acpi_video_dmi_promote_vendor();
|
2011-08-18 18:47:32 +08:00
|
|
|
if (acpi_video_backlight_support()) {
|
2012-06-13 15:32:02 +08:00
|
|
|
interface->capability &= ~ACER_CAP_BRIGHTNESS;
|
|
|
|
pr_info("Brightness must be controlled by acpi video driver\n");
|
|
|
|
} else {
|
|
|
|
pr_info("Disabling ACPI video driver\n");
|
acer-wmi: Switch to acpi_video_unregister_backlight
Switch from acpi_video_unregister(), to acpi_video_unregister_backlight(),
so that the hotkeys handler registered by acpi-video stays in place.
Since there are no mappings for the atkbd raw codes for the brightness
keys used by newer Acer models in /lib/udev/hwdb.d/60-keyboard.hwdb, and
since we map the wmi events with a code of KE_IGNORE, we rely on acpi-video
to do the hotkey handling for us.
For laptops such as the Acer Aspire 5750 which uses intel gfx this works
despite us calling acpi_video_unregister() because the following happens:
1) acpi-video module gets loaded (as it is a dependency of acer-wmi and i915)
2) acpi-video does NOT call acpi_video_register()
3) acer-wmi loads (assume it loads before i915), calls
acpi_video_dmi_promote_vendor(); which sets
ACPI_VIDEO_BACKLIGHT_DMI_VENDOR
4) calls acpi_video_unregister -> not registered, nop
5) i915 loads, calls acpi_video_register
6) acpi_video_register registers the acpi_notifier for the hotkeys,
does NOT register a backlight device because of
ACPI_VIDEO_BACKLIGHT_DMI_VENDOR
But on the Acer Aspire 5750G, which uses nvidia graphics the following happens:
1) acpi-video module gets loaded (as it is a dependency of acer-wmi)
2) acpi-video calls acpi_video_register()
3) acpi_video_register registers the acpi_notifier for the hotkeys,
and a backlight device
4) acer-wmi loads, calls acpi_video_dmi_promote_vendor()
5) calls acpi_video_unregister, this unregisters BOTH the acpi_notifier for
the hotkeys AND the backlight device
And we end up without any handler for the brightness hotkeys. This patch fixes
this by switching over to acpi_video_unregister_backlight() which keeps the
hotkey handler in place.
References: https://bugzilla.kernel.org/show_bug.cgi?id=35622
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2014-05-17 16:48:02 +08:00
|
|
|
acpi_video_unregister_backlight();
|
2008-08-01 23:37:56 +08:00
|
|
|
}
|
|
|
|
|
2011-01-08 06:25:14 +08:00
|
|
|
if (wmi_has_guid(WMID_GUID3)) {
|
|
|
|
if (ec_raw_mode) {
|
|
|
|
if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_err("Cannot enable EC raw mode\n");
|
2011-01-08 06:25:14 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_err("Cannot enable Launch Manager mode\n");
|
2011-01-08 06:25:14 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
} else if (ec_raw_mode) {
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_info("No WMID EC raw mode enable method\n");
|
2011-01-08 06:25:14 +08:00
|
|
|
}
|
|
|
|
|
2010-12-07 10:29:20 +08:00
|
|
|
if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
|
|
|
|
err = acer_wmi_input_setup();
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-06-02 01:11:22 +08:00
|
|
|
acer_wmi_accel_setup();
|
|
|
|
|
2010-06-22 16:17:38 +08:00
|
|
|
err = platform_driver_register(&acer_platform_driver);
|
|
|
|
if (err) {
|
2011-11-30 03:04:05 +08:00
|
|
|
pr_err("Unable to register platform driver\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
goto error_platform_register;
|
|
|
|
}
|
2010-06-22 16:17:38 +08:00
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
acer_platform_device = platform_device_alloc("acer-wmi", -1);
|
2010-06-22 16:17:38 +08:00
|
|
|
if (!acer_platform_device) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto error_device_alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = platform_device_add(acer_platform_device);
|
|
|
|
if (err)
|
|
|
|
goto error_device_add;
|
2008-02-05 10:17:10 +08:00
|
|
|
|
|
|
|
err = create_sysfs();
|
|
|
|
if (err)
|
2010-06-22 16:17:38 +08:00
|
|
|
goto error_create_sys;
|
2008-02-05 10:17:10 +08:00
|
|
|
|
2008-06-21 16:09:53 +08:00
|
|
|
if (wmi_has_guid(WMID_GUID2)) {
|
|
|
|
interface->debug.wmid_devices = get_wmid_devices();
|
|
|
|
err = create_debugfs();
|
|
|
|
if (err)
|
2010-06-22 16:17:38 +08:00
|
|
|
goto error_create_debugfs;
|
2008-06-21 16:09:53 +08:00
|
|
|
}
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
/* Override any initial settings with values from the commandline */
|
|
|
|
acer_commandline_init();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2010-06-22 16:17:38 +08:00
|
|
|
error_create_debugfs:
|
|
|
|
remove_sysfs(acer_platform_device);
|
|
|
|
error_create_sys:
|
|
|
|
platform_device_del(acer_platform_device);
|
|
|
|
error_device_add:
|
|
|
|
platform_device_put(acer_platform_device);
|
|
|
|
error_device_alloc:
|
|
|
|
platform_driver_unregister(&acer_platform_driver);
|
2008-02-05 10:17:10 +08:00
|
|
|
error_platform_register:
|
2010-12-07 10:29:20 +08:00
|
|
|
if (wmi_has_guid(ACERWMID_EVENT_GUID))
|
|
|
|
acer_wmi_input_destroy();
|
2012-06-02 01:11:22 +08:00
|
|
|
if (has_cap(ACER_CAP_ACCEL))
|
|
|
|
acer_wmi_accel_destroy();
|
2010-12-07 10:29:20 +08:00
|
|
|
|
2010-06-22 16:17:38 +08:00
|
|
|
return err;
|
2008-02-05 10:17:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit acer_wmi_exit(void)
|
|
|
|
{
|
2010-12-07 10:29:20 +08:00
|
|
|
if (wmi_has_guid(ACERWMID_EVENT_GUID))
|
|
|
|
acer_wmi_input_destroy();
|
|
|
|
|
2012-06-02 01:11:22 +08:00
|
|
|
if (has_cap(ACER_CAP_ACCEL))
|
|
|
|
acer_wmi_accel_destroy();
|
|
|
|
|
2008-02-05 10:17:10 +08:00
|
|
|
remove_sysfs(acer_platform_device);
|
2008-09-03 05:35:40 +08:00
|
|
|
remove_debugfs();
|
2010-06-03 15:18:03 +08:00
|
|
|
platform_device_unregister(acer_platform_device);
|
2008-02-05 10:17:10 +08:00
|
|
|
platform_driver_unregister(&acer_platform_driver);
|
|
|
|
|
2011-03-16 18:52:36 +08:00
|
|
|
pr_info("Acer Laptop WMI Extras unloaded\n");
|
2008-02-05 10:17:10 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(acer_wmi_init);
|
|
|
|
module_exit(acer_wmi_exit);
|