Skip to content

Commit

Permalink
Merge branch 'linux-next' of git://cavan.codon.org.uk/platform-driver…
Browse files Browse the repository at this point in the history
…s-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.
  • Loading branch information
Linus Torvalds committed Jul 30, 2012
2 parents 287dc4b + 00d3959 commit 7d3d09b
Show file tree
Hide file tree
Showing 13 changed files with 864 additions and 34 deletions.
7 changes: 7 additions & 0 deletions Documentation/ABI/testing/sysfs-platform-asus-wmi
Original file line number Diff line number Diff line change
Expand Up @@ -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.
60 changes: 58 additions & 2 deletions drivers/acpi/video_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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)) {
Expand All @@ -182,15 +211,42 @@ 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
* in. Therefore this must be called after binding PCI and ACPI devices
*/
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)
Expand Down
153 changes: 146 additions & 7 deletions drivers/platform/x86/acer-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)

/*
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)) {
Expand All @@ -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");
Expand Down Expand Up @@ -2133,6 +2267,8 @@ static int __init acer_wmi_init(void)
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;
}
Expand All @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions drivers/platform/x86/apple-gmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}

Expand Down
Loading

0 comments on commit 7d3d09b

Please sign in to comment.