Merge branch 'linux-next' of git://cavan.codon.org.uk/platform-drivers-x86

Pull x86 platform driver updates from Matthew Garrett:
 "Nothing overly dramatic here - improved support for the Classmate,
  some random small fixes and a rework of backlight management to deal
  with some of the more awkward cases."

* 'linux-next' of git://cavan.codon.org.uk/platform-drivers-x86:
  thinkpad_acpi: Free hotkey_keycode_map after unregistering tpacpi_inputdev
  thinkpad_acpi: Fix a memory leak during module exit
  thinkpad_acpi: Flush the workqueue before freeing tpacpi_leds
  dell-laptop: Add 6 machines to touchpad led quirk
  ACER: Fix Smatch double-free issue
  ACER: Fix up sparse warning
  asus-nb-wmi: add some video toggle keys
  asus-nb-wmi: add wapf quirk for ASUS machines
  classmate-laptop: Fix extra keys hardware id.
  classmate-laptop: Add support for Classmate V4 accelerometer.
  asus-wmi: enable resume on lid open
  asus-wmi: control backlight power through WMI, not ACPI
  samsung-laptop: support R40/R41
  acpi/video_detect: blacklist samsung x360
  samsung-laptop: X360 ACPI backlight device is broken
  drivers-platform-x86: use acpi_video_dmi_promote_vendor()
  acpi: add a way to promote/demote vendor backlight drivers
  ACER: Add support for accelerometer sensor
  asus-wmi: use ASUS_WMI_METHODID_DSTS2 as default DSTS ID.
This commit is contained in:
Linus Torvalds 2012-07-30 11:54:53 -07:00
commit 7d3d09b01a
13 changed files with 864 additions and 34 deletions

View File

@ -29,3 +29,10 @@ KernelVersion: 2.6.39
Contact: "Corentin Chary" <corentincj@iksaif.net>
Description:
Control the card touchpad. 1 means on, 0 means off.
What: /sys/devices/platform/<platform>/lid_resume
Date: May 2012
KernelVersion: 3.5
Contact: "AceLan Kao" <acelan.kao@canonical.com>
Description:
Resume on lid open. 1 means on, 0 means off.

View File

@ -132,6 +132,33 @@ find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
return AE_OK;
}
/* Force to use vendor driver when the ACPI device is known to be
* buggy */
static int video_detect_force_vendor(const struct dmi_system_id *d)
{
acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
return 0;
}
static struct dmi_system_id video_detect_dmi_table[] = {
/* On Samsung X360, the BIOS will set a flag (VDRV) if generic
* ACPI backlight device is used. This flag will definitively break
* the backlight interface (even the vendor interface) untill next
* reboot. It's why we should prevent video.ko from being used here
* and we can't rely on a later call to acpi_video_unregister().
*/
{
.callback = video_detect_force_vendor,
.ident = "X360",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
DMI_MATCH(DMI_BOARD_NAME, "X360"),
},
},
{ },
};
/*
* Returns the video capabilities of a specific ACPI graphics device
*
@ -164,6 +191,8 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle)
* ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
*}
*/
dmi_check_system(video_detect_dmi_table);
} else {
status = acpi_bus_get_device(graphics_handle, &tmp_dev);
if (ACPI_FAILURE(status)) {
@ -182,8 +211,7 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle)
}
EXPORT_SYMBOL(acpi_video_get_capabilities);
/* Returns true if video.ko can do backlight switching */
int acpi_video_backlight_support(void)
static void acpi_video_caps_check(void)
{
/*
* We must check whether the ACPI graphics device is physically plugged
@ -191,6 +219,34 @@ int acpi_video_backlight_support(void)
*/
if (!acpi_video_caps_checked)
acpi_video_get_capabilities(NULL);
}
/* Promote the vendor interface instead of the generic video module.
* This function allow DMI blacklists to be implemented by externals
* platform drivers instead of putting a big blacklist in video_detect.c
* After calling this function you will probably want to call
* acpi_video_unregister() to make sure the video module is not loaded
*/
void acpi_video_dmi_promote_vendor(void)
{
acpi_video_caps_check();
acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
}
EXPORT_SYMBOL(acpi_video_dmi_promote_vendor);
/* To be called when a driver who previously promoted the vendor
* interface */
void acpi_video_dmi_demote_vendor(void)
{
acpi_video_caps_check();
acpi_video_support &= ~ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
}
EXPORT_SYMBOL(acpi_video_dmi_demote_vendor);
/* Returns true if video.ko can do backlight switching */
int acpi_video_backlight_support(void)
{
acpi_video_caps_check();
/* First check for boot param -> highest prio */
if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR)

View File

@ -95,6 +95,7 @@ MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
enum acer_wmi_event_ids {
WMID_HOTKEY_EVENT = 0x1,
WMID_ACCEL_EVENT = 0x5,
};
static const struct key_entry acer_wmi_keymap[] = {
@ -130,6 +131,7 @@ static const struct key_entry acer_wmi_keymap[] = {
};
static struct input_dev *acer_wmi_input_dev;
static struct input_dev *acer_wmi_accel_dev;
struct event_return_value {
u8 function;
@ -200,6 +202,7 @@ struct hotkey_function_type_aa {
#define ACER_CAP_BLUETOOTH (1<<2)
#define ACER_CAP_BRIGHTNESS (1<<3)
#define ACER_CAP_THREEG (1<<4)
#define ACER_CAP_ACCEL (1<<5)
#define ACER_CAP_ANY (0xFFFFFFFF)
/*
@ -1398,6 +1401,60 @@ static void acer_backlight_exit(void)
backlight_device_unregister(acer_backlight_device);
}
/*
* 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;
}
/*
* Rfkill devices
*/
@ -1673,6 +1730,9 @@ static void acer_wmi_notify(u32 value, void *context)
1, true);
}
break;
case WMID_ACCEL_EVENT:
acer_gsensor_event();
break;
default:
pr_warn("Unknown function number - %d - %d\n",
return_value.function, return_value.key_num);
@ -1758,6 +1818,73 @@ static int acer_wmi_enable_lm(void)
return status;
}
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);
handle = NULL;
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);
}
static int __init acer_wmi_input_setup(void)
{
acpi_status status;
@ -1912,6 +2039,9 @@ static int acer_resume(struct device *dev)
if (has_cap(ACER_CAP_BRIGHTNESS))
set_u32(data->brightness, ACER_CAP_BRIGHTNESS);
if (has_cap(ACER_CAP_ACCEL))
acer_gsensor_init();
return 0;
}
@ -2060,14 +2190,16 @@ static int __init acer_wmi_init(void)
set_quirks();
if (dmi_check_system(video_vendor_dmi_table))
acpi_video_dmi_promote_vendor();
if (acpi_video_backlight_support()) {
if (dmi_check_system(video_vendor_dmi_table)) {
acpi_video_unregister();
} else {
interface->capability &= ~ACER_CAP_BRIGHTNESS;
pr_info("Brightness must be controlled by "
"acpi video driver\n");
}
interface->capability &= ~ACER_CAP_BRIGHTNESS;
pr_info("Brightness must be controlled by acpi video driver\n");
} else {
#ifdef CONFIG_ACPI_VIDEO
pr_info("Disabling ACPI video driver\n");
acpi_video_unregister();
#endif
}
if (wmi_has_guid(WMID_GUID3)) {
@ -2090,6 +2222,8 @@ static int __init acer_wmi_init(void)
return err;
}
acer_wmi_accel_setup();
err = platform_driver_register(&acer_platform_driver);
if (err) {
pr_err("Unable to register platform driver\n");
@ -2133,6 +2267,8 @@ error_device_alloc:
error_platform_register:
if (wmi_has_guid(ACERWMID_EVENT_GUID))
acer_wmi_input_destroy();
if (has_cap(ACER_CAP_ACCEL))
acer_wmi_accel_destroy();
return err;
}
@ -2142,6 +2278,9 @@ static void __exit acer_wmi_exit(void)
if (wmi_has_guid(ACERWMID_EVENT_GUID))
acer_wmi_input_destroy();
if (has_cap(ACER_CAP_ACCEL))
acer_wmi_accel_destroy();
remove_sysfs(acer_platform_device);
remove_debugfs();
platform_device_unregister(acer_platform_device);

View File

@ -193,7 +193,10 @@ static int __devinit gmux_probe(struct pnp_dev *pnp,
* backlight control and supports more levels than other options.
* Disable the other backlight choices.
*/
acpi_video_dmi_promote_vendor();
#ifdef CONFIG_ACPI_VIDEO
acpi_video_unregister();
#endif
apple_bl_unregister();
return 0;
@ -213,7 +216,10 @@ static void __devexit gmux_remove(struct pnp_dev *pnp)
release_region(gmux_data->iostart, gmux_data->iolen);
kfree(gmux_data);
acpi_video_dmi_demote_vendor();
#ifdef CONFIG_ACPI_VIDEO
acpi_video_register();
#endif
apple_bl_register();
}

View File

@ -26,6 +26,7 @@
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
#include <linux/fb.h>
#include <linux/dmi.h>
#include "asus-wmi.h"
@ -48,18 +49,115 @@ MODULE_ALIAS("wmi:"ASUS_NB_WMI_EVENT_GUID);
* 1 | Hardware | Software
* 4 | Software | Software
*/
static uint wapf;
static int wapf = -1;
module_param(wapf, uint, 0444);
MODULE_PARM_DESC(wapf, "WAPF value");
static struct quirk_entry *quirks;
static struct quirk_entry quirk_asus_unknown = {
.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,
},
{},
};
static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
{
driver->quirks = &quirk_asus_unknown;
driver->quirks->wapf = wapf;
quirks = &quirk_asus_unknown;
dmi_check_system(asus_quirks);
driver->quirks = quirks;
driver->panel_power = FB_BLANK_UNBLANK;
/* overwrite the wapf setting if the wapf paramater is specified */
if (wapf != -1)
quirks->wapf = wapf;
else
wapf = quirks->wapf;
}
static const struct key_entry asus_nb_wmi_keymap[] = {
@ -94,6 +192,10 @@ static const struct key_entry asus_nb_wmi_keymap[] = {
{ KE_KEY, 0x8A, { KEY_PROG1 } },
{ KE_KEY, 0x95, { KEY_MEDIA } },
{ KE_KEY, 0x99, { KEY_PHONE } },
{ KE_KEY, 0xA0, { KEY_SWITCHVIDEOMODE } }, /* SDSP HDMI only */
{ KE_KEY, 0xA1, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + HDMI */
{ KE_KEY, 0xA2, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + HDMI */
{ KE_KEY, 0xA3, { KEY_SWITCHVIDEOMODE } }, /* SDSP TV + HDMI */
{ KE_KEY, 0xb5, { KEY_CALC } },
{ KE_KEY, 0xc4, { KEY_KBDILLUMUP } },
{ KE_KEY, 0xc5, { KEY_KBDILLUMDOWN } },

View File

@ -47,6 +47,9 @@
#include <linux/thermal.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#ifdef CONFIG_ACPI_VIDEO
#include <acpi/video.h>
#endif
#include "asus-wmi.h"
@ -136,6 +139,9 @@ MODULE_LICENSE("GPL");
/* Power */
#define ASUS_WMI_DEVID_PROCESSOR_STATE 0x00120012
/* Deep S3 / Resume on LID open */
#define ASUS_WMI_DEVID_LID_RESUME 0x00120031
/* DSTS masks */
#define ASUS_WMI_DSTS_STATUS_BIT 0x00000001
#define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002
@ -1365,6 +1371,7 @@ static ssize_t show_sys_wmi(struct asus_wmi *asus, int devid, char *buf)
ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD);
ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA);
ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
ASUS_WMI_CREATE_DEVICE_ATTR(lid_resume, 0644, ASUS_WMI_DEVID_LID_RESUME);
static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
@ -1390,6 +1397,7 @@ static struct attribute *platform_attributes[] = {
&dev_attr_camera.attr,
&dev_attr_cardr.attr,
&dev_attr_touchpad.attr,
&dev_attr_lid_resume.attr,
NULL
};
@ -1408,6 +1416,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
devid = ASUS_WMI_DEVID_CARDREADER;
else if (attr == &dev_attr_touchpad.attr)
devid = ASUS_WMI_DEVID_TOUCHPAD;
else if (attr == &dev_attr_lid_resume.attr)
devid = ASUS_WMI_DEVID_LID_RESUME;
if (devid != -1)
ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
@ -1467,14 +1477,9 @@ static int asus_wmi_platform_init(struct asus_wmi *asus)
*/
if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, 0, 0, NULL))
asus->dsts_id = ASUS_WMI_METHODID_DSTS;
else if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS2, 0, 0, NULL))
else
asus->dsts_id = ASUS_WMI_METHODID_DSTS2;
if (!asus->dsts_id) {
pr_err("Can't find DSTS");
return -ENODEV;
}
/* CWAP allow to define the behavior of the Fn+F2 key,
* this method doesn't seems to be present on Eee PCs */
if (asus->driver->quirks->wapf >= 0)
@ -1681,7 +1686,13 @@ static int asus_wmi_add(struct platform_device *pdev)
if (err)
goto fail_rfkill;
if (asus->driver->quirks->wmi_backlight_power)
acpi_video_dmi_promote_vendor();
if (!acpi_video_backlight_support()) {
#ifdef CONFIG_ACPI_VIDEO
pr_info("Disabling ACPI video driver\n");
acpi_video_unregister();
#endif
err = asus_wmi_backlight_init(asus);
if (err && err != -ENODEV)
goto fail_backlight;

View File

@ -39,6 +39,7 @@ struct quirk_entry {
bool hotplug_wireless;
bool scalar_panel_brightness;
bool store_backlight_power;
bool wmi_backlight_power;
int wapf;
};

View File

@ -31,15 +31,21 @@ MODULE_LICENSE("GPL");
struct cmpc_accel {
int sensitivity;
int g_select;
int inputdev_state;
};
#define CMPC_ACCEL_SENSITIVITY_DEFAULT 5
#define CMPC_ACCEL_DEV_STATE_CLOSED 0
#define CMPC_ACCEL_DEV_STATE_OPEN 1
#define CMPC_ACCEL_SENSITIVITY_DEFAULT 5
#define CMPC_ACCEL_G_SELECT_DEFAULT 0
#define CMPC_ACCEL_HID "ACCE0000"
#define CMPC_ACCEL_HID_V4 "ACCE0001"
#define CMPC_TABLET_HID "TBLT0000"
#define CMPC_IPML_HID "IPML200"
#define CMPC_KEYS_HID "FnBT0000"
#define CMPC_KEYS_HID "FNBT0000"
/*
* Generic input device code.
@ -76,7 +82,391 @@ static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi)
}
/*
* Accelerometer code.
* Accelerometer code for Classmate V4
*/
static acpi_status cmpc_start_accel_v4(acpi_handle handle)
{
union acpi_object param[4];
struct acpi_object_list input;
acpi_status status;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x3;
param[1].type = ACPI_TYPE_INTEGER;
param[1].integer.value = 0;
param[2].type = ACPI_TYPE_INTEGER;
param[2].integer.value = 0;
param[3].type = ACPI_TYPE_INTEGER;
param[3].integer.value = 0;
input.count = 4;
input.pointer = param;
status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
return status;
}
static acpi_status cmpc_stop_accel_v4(acpi_handle handle)
{
union acpi_object param[4];
struct acpi_object_list input;
acpi_status status;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x4;
param[1].type = ACPI_TYPE_INTEGER;
param[1].integer.value = 0;
param[2].type = ACPI_TYPE_INTEGER;
param[2].integer.value = 0;
param[3].type = ACPI_TYPE_INTEGER;
param[3].integer.value = 0;
input.count = 4;
input.pointer = param;
status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
return status;
}
static acpi_status cmpc_accel_set_sensitivity_v4(acpi_handle handle, int val)
{
union acpi_object param[4];
struct acpi_object_list input;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x02;
param[1].type = ACPI_TYPE_INTEGER;
param[1].integer.value = val;
param[2].type = ACPI_TYPE_INTEGER;
param[2].integer.value = 0;
param[3].type = ACPI_TYPE_INTEGER;
param[3].integer.value = 0;
input.count = 4;
input.pointer = param;
return acpi_evaluate_object(handle, "ACMD", &input, NULL);
}
static acpi_status cmpc_accel_set_g_select_v4(acpi_handle handle, int val)
{
union acpi_object param[4];
struct acpi_object_list input;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x05;
param[1].type = ACPI_TYPE_INTEGER;
param[1].integer.value = val;
param[2].type = ACPI_TYPE_INTEGER;
param[2].integer.value = 0;
param[3].type = ACPI_TYPE_INTEGER;
param[3].integer.value = 0;
input.count = 4;
input.pointer = param;
return acpi_evaluate_object(handle, "ACMD", &input, NULL);
}
static acpi_status cmpc_get_accel_v4(acpi_handle handle,
int16_t *x,
int16_t *y,
int16_t *z)
{
union acpi_object param[4];
struct acpi_object_list input;
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
int16_t *locs;
acpi_status status;
param[0].type = ACPI_TYPE_INTEGER;
param[0].integer.value = 0x01;
param[1].type = ACPI_TYPE_INTEGER;
param[1].integer.value = 0;
param[2].type = ACPI_TYPE_INTEGER;
param[2].integer.value = 0;
param[3].type = ACPI_TYPE_INTEGER;
param[3].integer.value = 0;
input.count = 4;
input.pointer = param;
status = acpi_evaluate_object(handle, "ACMD", &input, &output);
if (ACPI_SUCCESS(status)) {
union acpi_object *obj;
obj = output.pointer;
locs = (int16_t *) obj->buffer.pointer;
*x = locs[0];
*y = locs[1];
*z = locs[2];
kfree(output.pointer);
}
return status;
}
static void cmpc_accel_handler_v4(struct acpi_device *dev, u32 event)
{
if (event == 0x81) {
int16_t x, y, z;
acpi_status status;
status = cmpc_get_accel_v4(dev->handle, &x, &y, &z);
if (ACPI_SUCCESS(status)) {
struct input_dev *inputdev = dev_get_drvdata(&dev->dev);
input_report_abs(inputdev, ABS_X, x);
input_report_abs(inputdev, ABS_Y, y);
input_report_abs(inputdev, ABS_Z, z);
input_sync(inputdev);
}
}
}
static ssize_t cmpc_accel_sensitivity_show_v4(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct acpi_device *acpi;
struct input_dev *inputdev;
struct cmpc_accel *accel;
acpi = to_acpi_device(dev);
inputdev = dev_get_drvdata(&acpi->dev);
accel = dev_get_drvdata(&inputdev->dev);
return sprintf(buf, "%d\n", accel->sensitivity);
}
static ssize_t cmpc_accel_sensitivity_store_v4(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct acpi_device *acpi;
struct input_dev *inputdev;
struct cmpc_accel *accel;
unsigned long sensitivity;
int r;
acpi = to_acpi_device(dev);
inputdev = dev_get_drvdata(&acpi->dev);
accel = dev_get_drvdata(&inputdev->dev);
r = kstrtoul(buf, 0, &sensitivity);
if (r)
return r;
/* sensitivity must be between 1 and 127 */
if (sensitivity < 1 || sensitivity > 127)
return -EINVAL;
accel->sensitivity = sensitivity;
cmpc_accel_set_sensitivity_v4(acpi->handle, sensitivity);
return strnlen(buf, count);
}
static struct device_attribute cmpc_accel_sensitivity_attr_v4 = {
.attr = { .name = "sensitivity", .mode = 0660 },
.show = cmpc_accel_sensitivity_show_v4,
.store = cmpc_accel_sensitivity_store_v4
};
static ssize_t cmpc_accel_g_select_show_v4(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct acpi_device *acpi;
struct input_dev *inputdev;
struct cmpc_accel *accel;
acpi = to_acpi_device(dev);
inputdev = dev_get_drvdata(&acpi->dev);
accel = dev_get_drvdata(&inputdev->dev);
return sprintf(buf, "%d\n", accel->g_select);
}
static ssize_t cmpc_accel_g_select_store_v4(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct acpi_device *acpi;
struct input_dev *inputdev;
struct cmpc_accel *accel;
unsigned long g_select;
int r;
acpi = to_acpi_device(dev);
inputdev = dev_get_drvdata(&acpi->dev);
accel = dev_get_drvdata(&inputdev->dev);
r = kstrtoul(buf, 0, &g_select);
if (r)
return r;
/* 0 means 1.5g, 1 means 6g, everything else is wrong */
if (g_select != 0 && g_select != 1)
return -EINVAL;
accel->g_select = g_select;
cmpc_accel_set_g_select_v4(acpi->handle, g_select);
return strnlen(buf, count);
}
static struct device_attribute cmpc_accel_g_select_attr_v4 = {
.attr = { .name = "g_select", .mode = 0660 },
.show = cmpc_accel_g_select_show_v4,
.store = cmpc_accel_g_select_store_v4
};
static int cmpc_accel_open_v4(struct input_dev *input)
{
struct acpi_device *acpi;
struct cmpc_accel *accel;
acpi = to_acpi_device(input->dev.parent);
accel = dev_get_drvdata(&input->dev);
cmpc_accel_set_sensitivity_v4(acpi->handle, accel->sensitivity);
cmpc_accel_set_g_select_v4(acpi->handle, accel->g_select);
if (ACPI_SUCCESS(cmpc_start_accel_v4(acpi->handle))) {
accel->inputdev_state = CMPC_ACCEL_DEV_STATE_OPEN;
return 0;
}
return -EIO;
}
static void cmpc_accel_close_v4(struct input_dev *input)
{
struct acpi_device *acpi;
struct cmpc_accel *accel;
acpi = to_acpi_device(input->dev.parent);
accel = dev_get_drvdata(&input->dev);
cmpc_stop_accel_v4(acpi->handle);
accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
}
static void cmpc_accel_idev_init_v4(struct input_dev *inputdev)
{
set_bit(EV_ABS, inputdev->evbit);
input_set_abs_params(inputdev, ABS_X, -255, 255, 16, 0);
input_set_abs_params(inputdev, ABS_Y, -255, 255, 16, 0);
input_set_abs_params(inputdev, ABS_Z, -255, 255, 16, 0);
inputdev->open = cmpc_accel_open_v4;
inputdev->close = cmpc_accel_close_v4;
}
static int cmpc_accel_suspend_v4(struct device *dev)
{
struct input_dev *inputdev;
struct cmpc_accel *accel;
inputdev = dev_get_drvdata(dev);
accel = dev_get_drvdata(&inputdev->dev);
if (accel->inputdev_state == CMPC_ACCEL_DEV_STATE_OPEN)
return cmpc_stop_accel_v4(to_acpi_device(dev)->handle);
return 0;
}
static int cmpc_accel_resume_v4(struct device *dev)
{
struct input_dev *inputdev;
struct cmpc_accel *accel;
inputdev = dev_get_drvdata(dev);
accel = dev_get_drvdata(&inputdev->dev);
if (accel->inputdev_state == CMPC_ACCEL_DEV_STATE_OPEN) {
cmpc_accel_set_sensitivity_v4(to_acpi_device(dev)->handle,
accel->sensitivity);
cmpc_accel_set_g_select_v4(to_acpi_device(dev)->handle,
accel->g_select);
if (ACPI_FAILURE(cmpc_start_accel_v4(to_acpi_device(dev)->handle)))
return -EIO;
}
return 0;
}
static int cmpc_accel_add_v4(struct acpi_device *acpi)
{
int error;
struct input_dev *inputdev;
struct cmpc_accel *accel;
accel = kmalloc(sizeof(*accel), GFP_KERNEL);
if (!accel)
return -ENOMEM;
accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
accel->sensitivity = CMPC_ACCEL_SENSITIVITY_DEFAULT;
cmpc_accel_set_sensitivity_v4(acpi->handle, accel->sensitivity);
error = device_create_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
if (error)
goto failed_sensitivity;
accel->g_select = CMPC_ACCEL_G_SELECT_DEFAULT;
cmpc_accel_set_g_select_v4(acpi->handle, accel->g_select);
error = device_create_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
if (error)
goto failed_g_select;
error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel_v4",
cmpc_accel_idev_init_v4);
if (error)
goto failed_input;
inputdev = dev_get_drvdata(&acpi->dev);
dev_set_drvdata(&inputdev->dev, accel);
return 0;
failed_input:
device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
failed_g_select:
device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
failed_sensitivity:
kfree(accel);
return error;
}
static int cmpc_accel_remove_v4(struct acpi_device *acpi, int type)
{
struct input_dev *inputdev;
struct cmpc_accel *accel;
inputdev = dev_get_drvdata(&acpi->dev);
accel = dev_get_drvdata(&inputdev->dev);
device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
return cmpc_remove_acpi_notify_device(acpi);
}
static SIMPLE_DEV_PM_OPS(cmpc_accel_pm, cmpc_accel_suspend_v4,
cmpc_accel_resume_v4);
static const struct acpi_device_id cmpc_accel_device_ids_v4[] = {
{CMPC_ACCEL_HID_V4, 0},
{"", 0}
};
static struct acpi_driver cmpc_accel_acpi_driver_v4 = {
.owner = THIS_MODULE,
.name = "cmpc_accel_v4",
.class = "cmpc_accel_v4",
.ids = cmpc_accel_device_ids_v4,
.ops = {
.add = cmpc_accel_add_v4,
.remove = cmpc_accel_remove_v4,
.notify = cmpc_accel_handler_v4,
},
.drv.pm = &cmpc_accel_pm,
};
/*
* Accelerometer code for Classmate versions prior to V4
*/
static acpi_status cmpc_start_accel(acpi_handle handle)
{
@ -726,8 +1116,15 @@ static int cmpc_init(void)
if (r)
goto failed_accel;
r = acpi_bus_register_driver(&cmpc_accel_acpi_driver_v4);
if (r)
goto failed_accel_v4;
return r;
failed_accel_v4:
acpi_bus_unregister_driver(&cmpc_accel_acpi_driver);
failed_accel:
acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
@ -743,6 +1140,7 @@ failed_keys:
static void cmpc_exit(void)
{
acpi_bus_unregister_driver(&cmpc_accel_acpi_driver_v4);
acpi_bus_unregister_driver(&cmpc_accel_acpi_driver);
acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver);
@ -754,6 +1152,7 @@ module_exit(cmpc_exit);
static const struct acpi_device_id cmpc_device_ids[] = {
{CMPC_ACCEL_HID, 0},
{CMPC_ACCEL_HID_V4, 0},
{CMPC_TABLET_HID, 0},
{CMPC_IPML_HID, 0},
{CMPC_KEYS_HID, 0},

View File

@ -206,6 +206,60 @@ static struct dmi_system_id __devinitdata dell_quirks[] = {
},
.driver_data = &quirk_dell_vostro_v130,
},
{
.callback = dmi_matched,
.ident = "Dell Inspiron 5420",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 5420"),
},
.driver_data = &quirk_dell_vostro_v130,
},
{
.callback = dmi_matched,
.ident = "Dell Inspiron 5520",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 5520"),
},
.driver_data = &quirk_dell_vostro_v130,
},
{
.callback = dmi_matched,
.ident = "Dell Inspiron 5720",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 5720"),
},
.driver_data = &quirk_dell_vostro_v130,
},
{
.callback = dmi_matched,
.ident = "Dell Inspiron 7420",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 7420"),
},
.driver_data = &quirk_dell_vostro_v130,
},
{
.callback = dmi_matched,
.ident = "Dell Inspiron 7520",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 7520"),
},
.driver_data = &quirk_dell_vostro_v130,
},
{
.callback = dmi_matched,
.ident = "Dell Inspiron 7720",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 7720"),
},
.driver_data = &quirk_dell_vostro_v130,
},
{ }
};

View File

@ -79,7 +79,7 @@ static const struct key_entry eeepc_wmi_keymap[] = {
{ KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
{ KE_KEY, HOME_PRESS, { KEY_CONFIG } }, /* Home/Express gate key */
{ KE_KEY, 0xe8, { KEY_SCREENLOCK } },
{ KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } },
{ KE_KEY, 0xe9, { KEY_DISPLAYTOGGLE } },
{ KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
{ KE_KEY, 0xec, { KEY_CAMERA_UP } },
{ KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
@ -107,6 +107,11 @@ static struct quirk_entry quirk_asus_et2012_type3 = {
.store_backlight_power = true,
};
static struct quirk_entry quirk_asus_x101ch = {
/* We need this when ACPI function doesn't do this well */
.wmi_backlight_power = true,
};
static struct quirk_entry *quirks;
static void et2012_quirks(void)
@ -157,6 +162,24 @@ static struct dmi_system_id asus_quirks[] = {
},
.driver_data = &quirk_asus_unknown,
},
{
.callback = dmi_matched,
.ident = "ASUSTeK Computer INC. X101CH",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "X101CH"),
},
.driver_data = &quirk_asus_x101ch,
},
{
.callback = dmi_matched,
.ident = "ASUSTeK Computer INC. 1015CX",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"),
},
.driver_data = &quirk_asus_x101ch,
},
{},
};

View File

@ -26,7 +26,7 @@
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <linux/ctype.h>
#if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE)
#ifdef CONFIG_ACPI_VIDEO
#include <acpi/video.h>
#endif
@ -1465,6 +1465,15 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
},
},
/* DMI ids for laptops with bad Chassis Type */
{
.ident = "R40/R41",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "R40/R41"),
DMI_MATCH(DMI_BOARD_NAME, "R40/R41"),
},
},
/* Specific DMI ids for laptop with quirks */
{
.callback = samsung_dmi_matched,
@ -1506,6 +1515,16 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
},
.driver_data = &samsung_broken_acpi_video,
},
{
.callback = samsung_dmi_matched,
.ident = "X360",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
DMI_MATCH(DMI_BOARD_NAME, "X360"),
},
.driver_data = &samsung_broken_acpi_video,
},
{ },
};
MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
@ -1530,15 +1549,18 @@ static int __init samsung_init(void)
samsung->quirks = quirks;
#if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE)
#ifdef CONFIG_ACPI
if (samsung->quirks->broken_acpi_video)
acpi_video_dmi_promote_vendor();
/* Don't handle backlight here if the acpi video already handle it */
if (acpi_video_backlight_support()) {
if (samsung->quirks->broken_acpi_video) {
pr_info("Disabling ACPI video driver\n");
acpi_video_unregister();
} else {
samsung->handle_backlight = false;
}
samsung->handle_backlight = false;
} else if (samsung->quirks->broken_acpi_video) {
pr_info("Disabling ACPI video driver\n");
#ifdef CONFIG_ACPI_VIDEO
acpi_video_unregister();
#endif
}
#endif
@ -1552,8 +1574,7 @@ static int __init samsung_init(void)
#ifdef CONFIG_ACPI
/* Only log that if we are really on a sabi platform */
if (acpi_video_backlight_support() &&
!samsung->quirks->broken_acpi_video)
if (acpi_video_backlight_support())
pr_info("Backlight controlled by ACPI video driver\n");
#endif

View File

@ -3015,8 +3015,6 @@ static void hotkey_exit(void)
if (hotkey_dev_attributes)
delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj);
kfree(hotkey_keycode_map);
dbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_HKEY,
"restoring original HKEY status and mask\n");
/* yes, there is a bitwise or below, we want the
@ -5217,6 +5215,7 @@ static void led_exit(void)
led_classdev_unregister(&tpacpi_leds[i].led_classdev);
}
flush_workqueue(tpacpi_wq);
kfree(tpacpi_leds);
}
@ -8936,6 +8935,7 @@ static void thinkpad_acpi_module_exit(void)
input_unregister_device(tpacpi_inputdev);
else
input_free_device(tpacpi_inputdev);
kfree(hotkey_keycode_map);
}
if (tpacpi_hwmon)
@ -8969,6 +8969,7 @@ static void thinkpad_acpi_module_exit(void)
kfree(thinkpad_id.bios_version_str);
kfree(thinkpad_id.ec_version_str);
kfree(thinkpad_id.model_str);
kfree(thinkpad_id.nummodel_str);
}

View File

@ -190,6 +190,8 @@ extern bool wmi_has_guid(const char *guid);
extern long acpi_video_get_capabilities(acpi_handle graphics_dev_handle);
extern long acpi_is_video_device(struct acpi_device *device);
extern void acpi_video_dmi_promote_vendor(void);
extern void acpi_video_dmi_demote_vendor(void);
extern int acpi_video_backlight_support(void);
extern int acpi_video_display_switch_support(void);
@ -205,6 +207,14 @@ static inline long acpi_is_video_device(struct acpi_device *device)
return 0;
}
static inline void acpi_video_dmi_promote_vendor(void)
{
}
static inline void acpi_video_dmi_demote_vendor(void)
{
}
static inline int acpi_video_backlight_support(void)
{
return 0;