Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 437cb0db authored by Matthew Garrett's avatar Matthew Garrett
Browse files

Merge branch 'x86-platform-next' into x86-platform

parents 139f37f5 987dfbaa
Loading
Loading
Loading
Loading
+0 −184
Original line number Diff line number Diff line
Acer Laptop WMI Extras Driver
http://code.google.com/p/aceracpi
Version 0.3
4th April 2009

Copyright 2007-2009 Carlos Corbacho <carlos@strangeworlds.co.uk>

acer-wmi is a driver to allow you to control various parts of your Acer laptop
hardware under Linux which are exposed via ACPI-WMI.

This driver completely replaces the old out-of-tree acer_acpi, which I am
currently maintaining for bug fixes only on pre-2.6.25 kernels. All development
work is now focused solely on acer-wmi.

Disclaimer
**********

Acer and Wistron have provided nothing towards the development acer_acpi or
acer-wmi. All information we have has been through the efforts of the developers
and the users to discover as much as possible about the hardware.

As such, I do warn that this could break your hardware - this is extremely
unlikely of course, but please bear this in mind.

Background
**********

acer-wmi is derived from acer_acpi, originally developed by Mark
Smith in 2005, then taken over by Carlos Corbacho in 2007, in order to activate
the wireless LAN card under a 64-bit version of Linux, as acerhk[1] (the
previous solution to the problem) relied on making 32 bit BIOS calls which are
not possible in kernel space from a 64 bit OS.

[1] acerhk: http://www.cakey.de/acerhk/

Supported Hardware
******************

NOTE: The Acer Aspire One is not supported hardware. It cannot work with
acer-wmi until Acer fix their ACPI-WMI implementation on them, so has been
blacklisted until that happens.

Please see the website for the current list of known working hardware:

http://code.google.com/p/aceracpi/wiki/SupportedHardware

If your laptop is not listed, or listed as unknown, and works with acer-wmi,
please contact me with a copy of the DSDT.

If your Acer laptop doesn't work with acer-wmi, I would also like to see the
DSDT.

To send me the DSDT, as root/sudo:

cat /sys/firmware/acpi/tables/DSDT > dsdt

And send me the resulting 'dsdt' file.

Usage
*****

On Acer laptops, acer-wmi should already be autoloaded based on DMI matching.
For non-Acer laptops, until WMI based autoloading support is added, you will
need to manually load acer-wmi.

acer-wmi creates /sys/devices/platform/acer-wmi, and fills it with various
files whose usage is detailed below, which enables you to control some of the
following (varies between models):

* the wireless LAN card radio
* inbuilt Bluetooth adapter
* inbuilt 3G card
* mail LED of your laptop
* brightness of the LCD panel

Wireless
********

With regards to wireless, all acer-wmi does is enable the radio on the card. It
is not responsible for the wireless LED - once the radio is enabled, this is
down to the wireless driver for your card. So the behaviour of the wireless LED,
once you enable the radio, will depend on your hardware and driver combination.

e.g. With the BCM4318 on the Acer Aspire 5020 series:

ndiswrapper: Light blinks on when transmitting
b43: Solid light, blinks off when transmitting

Wireless radio control is unconditionally enabled - all Acer laptops that support
acer-wmi come with built-in wireless. However, should you feel so inclined to
ever wish to remove the card, or swap it out at some point, please get in touch
with me, as we may well be able to gain some data on wireless card detection.

The wireless radio is exposed through rfkill.

Bluetooth
*********

For bluetooth, this is an internal USB dongle, so once enabled, you will get
a USB device connection event, and a new USB device appears. When you disable
bluetooth, you get the reverse - a USB device disconnect event, followed by the
device disappearing again.

Bluetooth is autodetected by acer-wmi, so if you do not have a bluetooth module
installed in your laptop, this file won't exist (please be aware that it is
quite common for Acer not to fit bluetooth to their laptops - so just because
you have a bluetooth button on the laptop, doesn't mean that bluetooth is
installed).

For the adventurously minded - if you want to buy an internal bluetooth
module off the internet that is compatible with your laptop and fit it, then
it will work just fine with acer-wmi.

Bluetooth is exposed through rfkill.

3G
**

3G is currently not autodetected, so the 'threeg' file is always created under
sysfs. So far, no-one in possession of an Acer laptop with 3G built-in appears to
have tried Linux, or reported back, so we don't have any information on this.

If you have an Acer laptop that does have a 3G card in, please contact me so we
can properly detect these, and find out a bit more about them.

To read the status of the 3G card (0=off, 1=on):
cat /sys/devices/platform/acer-wmi/threeg

To enable the 3G card:
echo 1 > /sys/devices/platform/acer-wmi/threeg

To disable the 3G card:
echo 0 > /sys/devices/platform/acer-wmi/threeg

To set the state of the 3G card when loading acer-wmi, pass:
threeg=X (where X is 0 or 1)

Mail LED
********

This can be found in most older Acer laptops supported by acer-wmi, and many
newer ones - it is built into the 'mail' button, and blinks when active.

On newer (WMID) laptops though, we have no way of detecting the mail LED. If
your laptop identifies itself in dmesg as a WMID model, then please try loading
acer_acpi with:

force_series=2490

This will use a known alternative method of reading/ writing the mail LED. If
it works, please report back to me with the DMI data from your laptop so this
can be added to acer-wmi.

The LED is exposed through the LED subsystem, and can be found in:

/sys/devices/platform/acer-wmi/leds/acer-wmi::mail/

The mail LED is autodetected, so if you don't have one, the LED device won't
be registered.

Backlight
*********

The backlight brightness control is available on all acer-wmi supported
hardware. The maximum brightness level is usually 15, but on some newer laptops
it's 10 (this is again autodetected).

The backlight is exposed through the backlight subsystem, and can be found in:

/sys/devices/platform/acer-wmi/backlight/acer-wmi/

Credits
*******

Olaf Tauber, who did the real hard work when he developed acerhk
http://www.cakey.de/acerhk/
All the authors of laptop ACPI modules in the kernel, whose work
was an inspiration in the early days of acer_acpi
Mathieu Segaud, who solved the problem with having to modprobe the driver
twice in acer_acpi 0.2.
Jim Ramsay, who added support for the WMID interface
Mark Smith, who started the original acer_acpi

And the many people who have used both acer_acpi and acer-wmi.
+3 −8
Original line number Diff line number Diff line
@@ -223,10 +223,8 @@ S: Maintained
F:	drivers/platform/x86/acerhdf.c

ACER WMI LAPTOP EXTRAS
M:	Carlos Corbacho <carlos@strangeworlds.co.uk>
L:	aceracpi@googlegroups.com (subscribers-only)
M:	Joey Lee <jlee@novell.com>
L:	platform-driver-x86@vger.kernel.org
W:	http://code.google.com/p/aceracpi
S:	Maintained
F:	drivers/platform/x86/acer-wmi.c

@@ -271,10 +269,8 @@ S: Supported
F:	drivers/acpi/video.c

ACPI WMI DRIVER
M:	Carlos Corbacho <carlos@strangeworlds.co.uk>
L:	platform-driver-x86@vger.kernel.org
W:	http://www.lesswatts.org/projects/acpi/
S:	Maintained
S:	Orphan
F:	drivers/platform/x86/wmi.c

AD1889 ALSA SOUND DRIVER
@@ -3033,9 +3029,8 @@ S: Maintained
F:	drivers/net/wireless/hostap/

HP COMPAQ TC1100 TABLET WMI EXTRAS DRIVER
M:	Carlos Corbacho <carlos@strangeworlds.co.uk>
L:	platform-driver-x86@vger.kernel.org
S:	Odd Fixes
S:	Orphan
F:	drivers/platform/x86/tc1100-wmi.c

HP100:	Driver for HP 10/100 Mbit/s Voice Grade Network Adapter Series
+10 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ config ACER_WMI

config ACERHDF
	tristate "Acer Aspire One temperature and fan driver"
	depends on THERMAL && THERMAL_HWMON && ACPI
	depends on THERMAL && ACPI
	---help---
	  This is a driver for Acer Aspire One netbooks. It allows to access
	  the temperature sensor and to control the fan.
@@ -760,4 +760,13 @@ config MXM_WMI
          MXM is a standard for laptop graphics cards, the WMI interface
	  is required for switchable nvidia graphics machines

config INTEL_OAKTRAIL
	tristate "Intel Oaktrail Platform Extras"
	depends on ACPI
	depends on RFKILL && BACKLIGHT_CLASS_DEVICE && ACPI
	---help---
	  Intel Oaktrail platform need this driver to provide interfaces to
	  enable/disable the Camera, WiFi, BT etc. devices. If in doubt, say Y
	  here; it will only load on supported platforms.

endif # X86_PLATFORM_DEVICES
+2 −1
Original line number Diff line number Diff line
@@ -41,5 +41,6 @@ obj-$(CONFIG_XO1_RFKILL) += xo1-rfkill.o
obj-$(CONFIG_XO15_EBOOK)	+= xo15-ebook.o
obj-$(CONFIG_IBM_RTL)		+= ibm_rtl.o
obj-$(CONFIG_SAMSUNG_LAPTOP)	+= samsung-laptop.o
obj-$(CONFIG_INTEL_MFLD_THERMAL)	+= intel_mid_thermal.o
obj-$(CONFIG_MXM_WMI)		+= mxm-wmi.o
obj-$(CONFIG_INTEL_MID_POWER_BUTTON)	+= intel_mid_powerbtn.o
obj-$(CONFIG_INTEL_OAKTRAIL)	+= intel_oaktrail.o
+159 −25
Original line number Diff line number Diff line
@@ -98,13 +98,26 @@ enum acer_wmi_event_ids {

static const struct key_entry acer_wmi_keymap[] = {
	{KE_KEY, 0x01, {KEY_WLAN} },     /* WiFi */
	{KE_KEY, 0x03, {KEY_WLAN} },     /* WiFi */
	{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 */
	{KE_IGNORE, 0x41, {KEY_MUTE} },
	{KE_IGNORE, 0x42, {KEY_PREVIOUSSONG} },
	{KE_IGNORE, 0x43, {KEY_NEXTSONG} },
	{KE_IGNORE, 0x44, {KEY_PLAYPAUSE} },
	{KE_IGNORE, 0x45, {KEY_STOP} },
	{KE_IGNORE, 0x48, {KEY_VOLUMEUP} },
	{KE_IGNORE, 0x49, {KEY_VOLUMEDOWN} },
	{KE_IGNORE, 0x61, {KEY_SWITCHVIDEOMODE} },
	{KE_IGNORE, 0x62, {KEY_BRIGHTNESSUP} },
	{KE_IGNORE, 0x63, {KEY_BRIGHTNESSDOWN} },
	{KE_KEY, 0x64, {KEY_SWITCHVIDEOMODE} },	/* Display Switch */
	{KE_IGNORE, 0x81, {KEY_SLEEP} },
	{KE_KEY, 0x82, {KEY_TOUCHPAD_TOGGLE} },	/* Touch Pad On/Off */
	{KE_IGNORE, 0x83, {KEY_TOUCHPAD_TOGGLE} },
	{KE_END, 0}
};

@@ -122,6 +135,7 @@ struct event_return_value {
 */
#define ACER_WMID3_GDS_WIRELESS		(1<<0)	/* WiFi */
#define ACER_WMID3_GDS_THREEG		(1<<6)	/* 3G */
#define ACER_WMID3_GDS_WIMAX		(1<<7)	/* WiMAX */
#define ACER_WMID3_GDS_BLUETOOTH	(1<<11)	/* BT */

struct lm_input_params {
@@ -737,8 +751,11 @@ WMI_execute_u32(u32 method_id, u32 in, u32 *out)

	obj = (union acpi_object *) result.pointer;
	if (obj && obj->type == ACPI_TYPE_BUFFER &&
		obj->buffer.length == sizeof(u32)) {
		(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;
	} else {
		tmp = 0;
	}
@@ -866,8 +883,11 @@ static acpi_status WMID_set_capabilities(void)

	obj = (union acpi_object *) out.pointer;
	if (obj && obj->type == ACPI_TYPE_BUFFER &&
		obj->buffer.length == sizeof(u32)) {
		(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;
	} else {
		kfree(out.pointer);
		return AE_ERROR;
@@ -876,6 +896,7 @@ static acpi_status WMID_set_capabilities(void)
	dmi_walk(type_aa_dmi_decode, NULL);
	if (!has_type_aa) {
		interface->capability |= ACER_CAP_WIRELESS;
		if (devices & 0x40)
			interface->capability |= ACER_CAP_THREEG;
		if (devices & 0x10)
			interface->capability |= ACER_CAP_BLUETOOTH;
@@ -961,9 +982,11 @@ 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
	 */
	if (mailled >= 0)
		set_u32(mailled, ACER_CAP_MAILLED);
	if (!has_type_aa)
	if (!has_type_aa && threeg >= 0)
		set_u32(threeg, ACER_CAP_THREEG);
	if (brightness >= 0)
		set_u32(brightness, ACER_CAP_BRIGHTNESS);
}

@@ -1081,7 +1104,7 @@ static acpi_status wmid3_get_device_status(u32 *value, u16 device)
		return AE_ERROR;
	}
	if (obj->buffer.length != 8) {
		pr_warning("Unknown buffer length %d\n", obj->buffer.length);
		pr_warn("Unknown buffer length %d\n", obj->buffer.length);
		kfree(obj);
		return AE_ERROR;
	}
@@ -1090,8 +1113,8 @@ static acpi_status wmid3_get_device_status(u32 *value, u16 device)
	kfree(obj);

	if (return_value.error_code || return_value.ec_return_value)
		pr_warning("Get Device Status failed: "
			"0x%x - 0x%x\n", return_value.error_code,
		pr_warn("Get Device Status failed: 0x%x - 0x%x\n",
			return_value.error_code,
			return_value.ec_return_value);
	else
		*value = !!(return_value.devices & device);
@@ -1124,6 +1147,114 @@ static acpi_status get_device_status(u32 *value, u32 cap)
	}
}

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;
	struct wmid3_gds_input_param params = {
		.function_num = 0x1,
		.hotkey_number = 0x01,
		.devices = ACER_WMID3_GDS_WIRELESS &
				ACER_WMID3_GDS_THREEG &
				ACER_WMID3_GDS_WIMAX &
				ACER_WMID3_GDS_BLUETOOTH,
	};
	struct acpi_buffer input = {
		sizeof(struct wmid3_gds_input_param),
		&params
	};
	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
	struct acpi_buffer output2 = { 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_warning("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_warning("Get Current Device Status failed: "
			"0x%x - 0x%x\n", return_value.error_code,
			return_value.ec_return_value);
		return status;
	}

	devices = return_value.devices;
	params.function_num = 0x2;
	params.hotkey_number = 0x01;
	params.devices = (value) ? (devices | device) : (devices & ~device);

	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output2);
	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) {
		pr_warning("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_warning("Set Device Status failed: "
			"0x%x - 0x%x\n", return_value.error_code,
			return_value.ec_return_value);

	return status;
}

static acpi_status set_device_status(u32 value, u32 cap)
{
	if (wmi_has_guid(WMID_GUID3)) {
		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);

	} else {
		return set_u32(value, cap);
	}
}

/*
 * Rfkill devices
 */
@@ -1160,7 +1291,7 @@ static int acer_rfkill_set(void *data, bool blocked)
	u32 cap = (unsigned long)data;

	if (rfkill_inited) {
		status = set_u32(!blocked, cap);
		status = set_device_status(!blocked, cap);
		if (ACPI_FAILURE(status))
			return -ENODEV;
	}
@@ -1317,7 +1448,7 @@ static void acer_wmi_notify(u32 value, void *context)

	status = wmi_get_event_data(value, &response);
	if (status != AE_OK) {
		pr_warning("bad event status 0x%x\n", status);
		pr_warn("bad event status 0x%x\n", status);
		return;
	}

@@ -1326,12 +1457,12 @@ static void acer_wmi_notify(u32 value, void *context)
	if (!obj)
		return;
	if (obj->type != ACPI_TYPE_BUFFER) {
		pr_warning("Unknown response received %d\n", obj->type);
		pr_warn("Unknown response received %d\n", obj->type);
		kfree(obj);
		return;
	}
	if (obj->buffer.length != 8) {
		pr_warning("Unknown buffer length %d\n", obj->buffer.length);
		pr_warn("Unknown buffer length %d\n", obj->buffer.length);
		kfree(obj);
		return;
	}
@@ -1343,7 +1474,7 @@ static void acer_wmi_notify(u32 value, void *context)
	case WMID_HOTKEY_EVENT:
		if (return_value.device_state) {
			u16 device_state = return_value.device_state;
			pr_debug("deivces states: 0x%x\n", device_state);
			pr_debug("device state: 0x%x\n", device_state);
			if (has_cap(ACER_CAP_WIRELESS))
				rfkill_set_sw_state(wireless_rfkill,
				!(device_state & ACER_WMID3_GDS_WIRELESS));
@@ -1356,11 +1487,11 @@ static void acer_wmi_notify(u32 value, void *context)
		}
		if (!sparse_keymap_report_event(acer_wmi_input_dev,
				return_value.key_num, 1, true))
			pr_warning("Unknown key number - 0x%x\n",
			pr_warn("Unknown key number - 0x%x\n",
				return_value.key_num);
		break;
	default:
		pr_warning("Unknown function number - %d - %d\n",
		pr_warn("Unknown function number - %d - %d\n",
			return_value.function, return_value.key_num);
		break;
	}
@@ -1389,7 +1520,7 @@ wmid3_set_lm_mode(struct lm_input_params *params,
		return AE_ERROR;
	}
	if (obj->buffer.length != 4) {
		pr_warning("Unknown buffer length %d\n", obj->buffer.length);
		pr_warn("Unknown buffer length %d\n", obj->buffer.length);
		kfree(obj);
		return AE_ERROR;
	}
@@ -1414,11 +1545,11 @@ static int acer_wmi_enable_ec_raw(void)
	status = wmid3_set_lm_mode(&params, &return_value);

	if (return_value.error_code || return_value.ec_return_value)
		pr_warning("Enabling EC raw mode failed: "
		       "0x%x - 0x%x\n", return_value.error_code,
		pr_warn("Enabling EC raw mode failed: 0x%x - 0x%x\n",
			return_value.error_code,
			return_value.ec_return_value);
	else
		pr_info("Enabled EC raw mode");
		pr_info("Enabled EC raw mode\n");

	return status;
}
@@ -1437,8 +1568,8 @@ static int acer_wmi_enable_lm(void)
	status = wmid3_set_lm_mode(&params, &return_value);

	if (return_value.error_code || return_value.ec_return_value)
		pr_warning("Enabling Launch Manager failed: "
		       "0x%x - 0x%x\n", return_value.error_code,
		pr_warn("Enabling Launch Manager failed: 0x%x - 0x%x\n",
			return_value.error_code,
			return_value.ec_return_value);

	return status;
@@ -1506,8 +1637,11 @@ static u32 get_wmid_devices(void)

	obj = (union acpi_object *) out.pointer;
	if (obj && obj->type == ACPI_TYPE_BUFFER &&
		obj->buffer.length == sizeof(u32)) {
		(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;
	}

	kfree(out.pointer);
Loading