2011-02-26 17:20:40 +08:00
|
|
|
/*
|
|
|
|
* Asus Notebooks WMI hotkey driver
|
|
|
|
*
|
|
|
|
* Copyright(C) 2010 Corentin Chary <corentin.chary@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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/input/sparse-keymap.h>
|
2012-03-20 16:53:11 +08:00
|
|
|
#include <linux/fb.h>
|
asus-nb-wmi: add wapf quirk for ASUS machines
The BIOS of these machines will try to enable/disable wifi/bt in
their own sqeuence. It won't read the enable/disable parameter
in WMI command, but just iterates the wifi/bt's status described below
1st. enable wifi, enable bt
2nd. disable wifi, enable bt
3rd. enable wifi, disable bt
4th. disable wifi, disable bt
That will totally mess up the rfkill status, since we will try to read
wifi and bt's status and reset it again while booting up.
To avoid this, these machines should set the wapf value to 4,
that will let software totally control the wifi/bt's status and
BIOS will do nothing instead of sending out the 0x88(KEY_RFKILL) event
instead of 0x5e(wifi enable), 0x5f(wifi diable), 0x7d(bt enable), and
0x7e(bt disable) through WMI.
With this patch[1], it will handle the KEY_RFKILL event correctly and
will block/unblock wifi and bt together.
1. https://lkml.org/lkml/2012/5/21/75
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2012-07-04 11:19:08 +08:00
|
|
|
#include <linux/dmi.h>
|
2011-02-26 17:20:40 +08:00
|
|
|
|
|
|
|
#include "asus-wmi.h"
|
|
|
|
|
|
|
|
#define ASUS_NB_WMI_FILE "asus-nb-wmi"
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>");
|
|
|
|
MODULE_DESCRIPTION("Asus Notebooks WMI Hotkey Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
#define ASUS_NB_WMI_EVENT_GUID "0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C"
|
|
|
|
|
|
|
|
MODULE_ALIAS("wmi:"ASUS_NB_WMI_EVENT_GUID);
|
|
|
|
|
2011-07-01 17:34:39 +08:00
|
|
|
/*
|
|
|
|
* WAPF defines the behavior of the Fn+Fx wlan key
|
|
|
|
* The significance of values is yet to be found, but
|
|
|
|
* most of the time:
|
|
|
|
* Bit | Bluetooth | WLAN
|
|
|
|
* 0 | Hardware | Hardware
|
|
|
|
* 1 | Hardware | Software
|
|
|
|
* 4 | Software | Software
|
|
|
|
*/
|
asus-nb-wmi: add wapf quirk for ASUS machines
The BIOS of these machines will try to enable/disable wifi/bt in
their own sqeuence. It won't read the enable/disable parameter
in WMI command, but just iterates the wifi/bt's status described below
1st. enable wifi, enable bt
2nd. disable wifi, enable bt
3rd. enable wifi, disable bt
4th. disable wifi, disable bt
That will totally mess up the rfkill status, since we will try to read
wifi and bt's status and reset it again while booting up.
To avoid this, these machines should set the wapf value to 4,
that will let software totally control the wifi/bt's status and
BIOS will do nothing instead of sending out the 0x88(KEY_RFKILL) event
instead of 0x5e(wifi enable), 0x5f(wifi diable), 0x7d(bt enable), and
0x7e(bt disable) through WMI.
With this patch[1], it will handle the KEY_RFKILL event correctly and
will block/unblock wifi and bt together.
1. https://lkml.org/lkml/2012/5/21/75
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2012-07-04 11:19:08 +08:00
|
|
|
static int wapf = -1;
|
2011-07-01 17:34:39 +08:00
|
|
|
module_param(wapf, uint, 0444);
|
|
|
|
MODULE_PARM_DESC(wapf, "WAPF value");
|
|
|
|
|
asus-nb-wmi: add wapf quirk for ASUS machines
The BIOS of these machines will try to enable/disable wifi/bt in
their own sqeuence. It won't read the enable/disable parameter
in WMI command, but just iterates the wifi/bt's status described below
1st. enable wifi, enable bt
2nd. disable wifi, enable bt
3rd. enable wifi, disable bt
4th. disable wifi, disable bt
That will totally mess up the rfkill status, since we will try to read
wifi and bt's status and reset it again while booting up.
To avoid this, these machines should set the wapf value to 4,
that will let software totally control the wifi/bt's status and
BIOS will do nothing instead of sending out the 0x88(KEY_RFKILL) event
instead of 0x5e(wifi enable), 0x5f(wifi diable), 0x7d(bt enable), and
0x7e(bt disable) through WMI.
With this patch[1], it will handle the KEY_RFKILL event correctly and
will block/unblock wifi and bt together.
1. https://lkml.org/lkml/2012/5/21/75
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2012-07-04 11:19:08 +08:00
|
|
|
static struct quirk_entry *quirks;
|
|
|
|
|
2012-03-20 16:53:10 +08:00
|
|
|
static struct quirk_entry quirk_asus_unknown = {
|
asus-nb-wmi: add wapf quirk for ASUS machines
The BIOS of these machines will try to enable/disable wifi/bt in
their own sqeuence. It won't read the enable/disable parameter
in WMI command, but just iterates the wifi/bt's status described below
1st. enable wifi, enable bt
2nd. disable wifi, enable bt
3rd. enable wifi, disable bt
4th. disable wifi, disable bt
That will totally mess up the rfkill status, since we will try to read
wifi and bt's status and reset it again while booting up.
To avoid this, these machines should set the wapf value to 4,
that will let software totally control the wifi/bt's status and
BIOS will do nothing instead of sending out the 0x88(KEY_RFKILL) event
instead of 0x5e(wifi enable), 0x5f(wifi diable), 0x7d(bt enable), and
0x7e(bt disable) through WMI.
With this patch[1], it will handle the KEY_RFKILL event correctly and
will block/unblock wifi and bt together.
1. https://lkml.org/lkml/2012/5/21/75
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2012-07-04 11:19:08 +08:00
|
|
|
.wapf = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct quirk_entry quirk_asus_x401u = {
|
|
|
|
.wapf = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int dmi_matched(const struct dmi_system_id *dmi)
|
|
|
|
{
|
|
|
|
quirks = dmi->driver_data;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct dmi_system_id asus_quirks[] = {
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "ASUSTeK COMPUTER INC. X401U",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "X401U"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_asus_x401u,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "ASUSTeK COMPUTER INC. X401A1",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "X401A1"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_asus_x401u,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "ASUSTeK COMPUTER INC. X501U",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "X501U"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_asus_x401u,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "ASUSTeK COMPUTER INC. X501A1",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "X501A1"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_asus_x401u,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "ASUSTeK COMPUTER INC. X55A",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "X55A"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_asus_x401u,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "ASUSTeK COMPUTER INC. X55C",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "X55C"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_asus_x401u,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "ASUSTeK COMPUTER INC. X55U",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "X55U"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_asus_x401u,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.callback = dmi_matched,
|
|
|
|
.ident = "ASUSTeK COMPUTER INC. X55VD",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "X55VD"),
|
|
|
|
},
|
|
|
|
.driver_data = &quirk_asus_x401u,
|
|
|
|
},
|
|
|
|
{},
|
2012-03-20 16:53:10 +08:00
|
|
|
};
|
|
|
|
|
2011-07-01 17:34:39 +08:00
|
|
|
static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
|
|
|
|
{
|
asus-nb-wmi: add wapf quirk for ASUS machines
The BIOS of these machines will try to enable/disable wifi/bt in
their own sqeuence. It won't read the enable/disable parameter
in WMI command, but just iterates the wifi/bt's status described below
1st. enable wifi, enable bt
2nd. disable wifi, enable bt
3rd. enable wifi, disable bt
4th. disable wifi, disable bt
That will totally mess up the rfkill status, since we will try to read
wifi and bt's status and reset it again while booting up.
To avoid this, these machines should set the wapf value to 4,
that will let software totally control the wifi/bt's status and
BIOS will do nothing instead of sending out the 0x88(KEY_RFKILL) event
instead of 0x5e(wifi enable), 0x5f(wifi diable), 0x7d(bt enable), and
0x7e(bt disable) through WMI.
With this patch[1], it will handle the KEY_RFKILL event correctly and
will block/unblock wifi and bt together.
1. https://lkml.org/lkml/2012/5/21/75
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2012-07-04 11:19:08 +08:00
|
|
|
quirks = &quirk_asus_unknown;
|
|
|
|
dmi_check_system(asus_quirks);
|
|
|
|
|
|
|
|
driver->quirks = quirks;
|
2012-03-20 16:53:11 +08:00
|
|
|
driver->panel_power = FB_BLANK_UNBLANK;
|
asus-nb-wmi: add wapf quirk for ASUS machines
The BIOS of these machines will try to enable/disable wifi/bt in
their own sqeuence. It won't read the enable/disable parameter
in WMI command, but just iterates the wifi/bt's status described below
1st. enable wifi, enable bt
2nd. disable wifi, enable bt
3rd. enable wifi, disable bt
4th. disable wifi, disable bt
That will totally mess up the rfkill status, since we will try to read
wifi and bt's status and reset it again while booting up.
To avoid this, these machines should set the wapf value to 4,
that will let software totally control the wifi/bt's status and
BIOS will do nothing instead of sending out the 0x88(KEY_RFKILL) event
instead of 0x5e(wifi enable), 0x5f(wifi diable), 0x7d(bt enable), and
0x7e(bt disable) through WMI.
With this patch[1], it will handle the KEY_RFKILL event correctly and
will block/unblock wifi and bt together.
1. https://lkml.org/lkml/2012/5/21/75
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
2012-07-04 11:19:08 +08:00
|
|
|
|
|
|
|
/* overwrite the wapf setting if the wapf paramater is specified */
|
|
|
|
if (wapf != -1)
|
|
|
|
quirks->wapf = wapf;
|
|
|
|
else
|
|
|
|
wapf = quirks->wapf;
|
2011-07-01 17:34:39 +08:00
|
|
|
}
|
|
|
|
|
2011-02-26 17:20:40 +08:00
|
|
|
static const struct key_entry asus_nb_wmi_keymap[] = {
|
|
|
|
{ KE_KEY, 0x30, { KEY_VOLUMEUP } },
|
|
|
|
{ KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
|
|
|
|
{ KE_KEY, 0x32, { KEY_MUTE } },
|
|
|
|
{ KE_KEY, 0x33, { KEY_DISPLAYTOGGLE } }, /* LCD on */
|
|
|
|
{ KE_KEY, 0x34, { KEY_DISPLAY_OFF } }, /* LCD off */
|
|
|
|
{ KE_KEY, 0x40, { KEY_PREVIOUSSONG } },
|
|
|
|
{ KE_KEY, 0x41, { KEY_NEXTSONG } },
|
|
|
|
{ KE_KEY, 0x43, { KEY_STOPCD } },
|
|
|
|
{ KE_KEY, 0x45, { KEY_PLAYPAUSE } },
|
|
|
|
{ KE_KEY, 0x4c, { KEY_MEDIA } },
|
|
|
|
{ KE_KEY, 0x50, { KEY_EMAIL } },
|
|
|
|
{ KE_KEY, 0x51, { KEY_WWW } },
|
|
|
|
{ KE_KEY, 0x55, { KEY_CALC } },
|
2012-03-20 16:53:02 +08:00
|
|
|
{ KE_IGNORE, 0x57, }, /* Battery mode */
|
|
|
|
{ KE_IGNORE, 0x58, }, /* AC mode */
|
2011-02-26 17:20:40 +08:00
|
|
|
{ KE_KEY, 0x5C, { KEY_F15 } }, /* Power Gear key */
|
2011-07-01 17:34:39 +08:00
|
|
|
{ KE_KEY, 0x5D, { KEY_WLAN } }, /* Wireless console Toggle */
|
|
|
|
{ KE_KEY, 0x5E, { KEY_WLAN } }, /* Wireless console Enable */
|
|
|
|
{ KE_KEY, 0x5F, { KEY_WLAN } }, /* Wireless console Disable */
|
2011-02-26 17:20:40 +08:00
|
|
|
{ KE_KEY, 0x60, { KEY_SWITCHVIDEOMODE } },
|
|
|
|
{ KE_KEY, 0x61, { KEY_SWITCHVIDEOMODE } },
|
|
|
|
{ KE_KEY, 0x62, { KEY_SWITCHVIDEOMODE } },
|
|
|
|
{ KE_KEY, 0x63, { KEY_SWITCHVIDEOMODE } },
|
|
|
|
{ KE_KEY, 0x6B, { KEY_TOUCHPAD_TOGGLE } },
|
|
|
|
{ KE_KEY, 0x7D, { KEY_BLUETOOTH } },
|
2011-07-01 17:34:39 +08:00
|
|
|
{ KE_KEY, 0x7E, { KEY_BLUETOOTH } },
|
2011-02-26 17:20:40 +08:00
|
|
|
{ KE_KEY, 0x82, { KEY_CAMERA } },
|
|
|
|
{ KE_KEY, 0x88, { KEY_RFKILL } },
|
|
|
|
{ KE_KEY, 0x8A, { KEY_PROG1 } },
|
|
|
|
{ KE_KEY, 0x95, { KEY_MEDIA } },
|
|
|
|
{ KE_KEY, 0x99, { KEY_PHONE } },
|
|
|
|
{ KE_KEY, 0xb5, { KEY_CALC } },
|
|
|
|
{ KE_KEY, 0xc4, { KEY_KBDILLUMUP } },
|
|
|
|
{ KE_KEY, 0xc5, { KEY_KBDILLUMDOWN } },
|
|
|
|
{ KE_END, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct asus_wmi_driver asus_nb_wmi_driver = {
|
|
|
|
.name = ASUS_NB_WMI_FILE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.event_guid = ASUS_NB_WMI_EVENT_GUID,
|
|
|
|
.keymap = asus_nb_wmi_keymap,
|
|
|
|
.input_name = "Asus WMI hotkeys",
|
|
|
|
.input_phys = ASUS_NB_WMI_FILE "/input0",
|
2012-03-20 16:53:08 +08:00
|
|
|
.detect_quirks = asus_nb_wmi_quirks,
|
2011-02-26 17:20:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int __init asus_nb_wmi_init(void)
|
|
|
|
{
|
|
|
|
return asus_wmi_register_driver(&asus_nb_wmi_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit asus_nb_wmi_exit(void)
|
|
|
|
{
|
|
|
|
asus_wmi_unregister_driver(&asus_nb_wmi_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(asus_nb_wmi_init);
|
|
|
|
module_exit(asus_nb_wmi_exit);
|