diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2012-08-01 01:14:35 +0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2012-09-20 21:10:36 +0400 |
commit | c49170742d6928b16fb3839b47a94cc41630dbe0 (patch) | |
tree | 1496b1d8e4b067d84b28af0f8d5aabb22bf12177 /drivers/gpu/drm/radeon/radeon_acpi.c | |
parent | fda4b25c55a59ba12378e4b9e4553f6ea57d802d (diff) | |
download | linux-c49170742d6928b16fb3839b47a94cc41630dbe0.tar.xz |
drm/radeon: re-organize the acpi notifier callback
Move it out of the radeon_pm.c and into radeon_acpi.c since
we use it for more than just pm now.
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_acpi.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_acpi.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c index b052a556db79..ea22f4416f48 100644 --- a/drivers/gpu/drm/radeon/radeon_acpi.c +++ b/drivers/gpu/drm/radeon/radeon_acpi.c @@ -24,6 +24,7 @@ #include <linux/pci.h> #include <linux/acpi.h> #include <linux/slab.h> +#include <linux/power_supply.h> #include <acpi/acpi_drivers.h> #include <acpi/acpi_bus.h> #include <acpi/video.h> @@ -38,6 +39,10 @@ #include <linux/vga_switcheroo.h> +#define ACPI_AC_CLASS "ac_adapter" + +extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev); + struct atif_verify_interface { u16 size; /* structure size in bytes (includes size field) */ u16 version; /* version */ @@ -299,6 +304,26 @@ int radeon_atif_handler(struct radeon_device *rdev, return NOTIFY_OK; } +static int radeon_acpi_event(struct notifier_block *nb, + unsigned long val, + void *data) +{ + struct radeon_device *rdev = container_of(nb, struct radeon_device, acpi_nb); + struct acpi_bus_event *entry = (struct acpi_bus_event *)data; + + if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) { + if (power_supply_is_system_supplied() > 0) + DRM_DEBUG_DRIVER("pm: AC\n"); + else + DRM_DEBUG_DRIVER("pm: DC\n"); + + radeon_pm_acpi_event_handler(rdev); + } + + /* Check for pending SBIOS requests */ + return radeon_atif_handler(rdev, entry); +} + /* Call all ACPI methods here */ int radeon_acpi_init(struct radeon_device *rdev) { @@ -367,6 +392,13 @@ int radeon_acpi_init(struct radeon_device *rdev) } out: + rdev->acpi_nb.notifier_call = radeon_acpi_event; + register_acpi_notifier(&rdev->acpi_nb); + return ret; } +void radeon_acpi_fini(struct radeon_device *rdev) +{ + unregister_acpi_notifier(&rdev->acpi_nb); +} |