From c49170742d6928b16fb3839b47a94cc41630dbe0 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 31 Jul 2012 17:14:35 -0400 Subject: 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 --- drivers/gpu/drm/radeon/radeon_acpi.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'drivers/gpu/drm/radeon/radeon_acpi.c') 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 #include #include +#include #include #include #include @@ -38,6 +39,10 @@ #include +#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); +} -- cgit v1.2.3