Commit c4917074 authored by Alex Deucher's avatar Alex Deucher

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: default avatarAlex Deucher <alexander.deucher@amd.com>
parent fda4b25c
...@@ -1869,12 +1869,14 @@ extern void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_displ ...@@ -1869,12 +1869,14 @@ extern void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_displ
extern int ni_init_microcode(struct radeon_device *rdev); extern int ni_init_microcode(struct radeon_device *rdev);
extern int ni_mc_load_microcode(struct radeon_device *rdev); extern int ni_mc_load_microcode(struct radeon_device *rdev);
/* radeon_acpi.c */ /* radeon_acpi.c */
#if defined(CONFIG_ACPI) #if defined(CONFIG_ACPI)
extern int radeon_acpi_init(struct radeon_device *rdev); extern int radeon_acpi_init(struct radeon_device *rdev);
#else extern void radeon_acpi_fini(struct radeon_device *rdev);
static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; } #else
#endif static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; }
static inline void radeon_acpi_fini(struct radeon_device *rdev) { }
#endif
#include "radeon_object.h" #include "radeon_object.h"
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/power_supply.h>
#include <acpi/acpi_drivers.h> #include <acpi/acpi_drivers.h>
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
#include <acpi/video.h> #include <acpi/video.h>
...@@ -38,6 +39,10 @@ ...@@ -38,6 +39,10 @@
#include <linux/vga_switcheroo.h> #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 { struct atif_verify_interface {
u16 size; /* structure size in bytes (includes size field) */ u16 size; /* structure size in bytes (includes size field) */
u16 version; /* version */ u16 version; /* version */
...@@ -299,6 +304,26 @@ int radeon_atif_handler(struct radeon_device *rdev, ...@@ -299,6 +304,26 @@ int radeon_atif_handler(struct radeon_device *rdev,
return NOTIFY_OK; 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 */ /* Call all ACPI methods here */
int radeon_acpi_init(struct radeon_device *rdev) int radeon_acpi_init(struct radeon_device *rdev)
{ {
...@@ -367,6 +392,13 @@ int radeon_acpi_init(struct radeon_device *rdev) ...@@ -367,6 +392,13 @@ int radeon_acpi_init(struct radeon_device *rdev)
} }
out: out:
rdev->acpi_nb.notifier_call = radeon_acpi_event;
register_acpi_notifier(&rdev->acpi_nb);
return ret; return ret;
} }
void radeon_acpi_fini(struct radeon_device *rdev)
{
unregister_acpi_notifier(&rdev->acpi_nb);
}
...@@ -51,6 +51,7 @@ int radeon_driver_unload_kms(struct drm_device *dev) ...@@ -51,6 +51,7 @@ int radeon_driver_unload_kms(struct drm_device *dev)
if (rdev == NULL) if (rdev == NULL)
return 0; return 0;
radeon_acpi_fini(rdev);
radeon_modeset_fini(rdev); radeon_modeset_fini(rdev);
radeon_device_fini(rdev); radeon_device_fini(rdev);
kfree(rdev); kfree(rdev);
......
...@@ -22,12 +22,8 @@ ...@@ -22,12 +22,8 @@
*/ */
#include "drmP.h" #include "drmP.h"
#include "radeon.h" #include "radeon.h"
#include "radeon_acpi.h"
#include "avivod.h" #include "avivod.h"
#include "atom.h" #include "atom.h"
#ifdef CONFIG_ACPI
#include <linux/acpi.h>
#endif
#include <linux/power_supply.h> #include <linux/power_supply.h>
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h> #include <linux/hwmon-sysfs.h>
...@@ -51,8 +47,6 @@ static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish ...@@ -51,8 +47,6 @@ static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish
static void radeon_pm_update_profile(struct radeon_device *rdev); static void radeon_pm_update_profile(struct radeon_device *rdev);
static void radeon_pm_set_clocks(struct radeon_device *rdev); static void radeon_pm_set_clocks(struct radeon_device *rdev);
#define ACPI_AC_CLASS "ac_adapter"
int radeon_pm_get_type_index(struct radeon_device *rdev, int radeon_pm_get_type_index(struct radeon_device *rdev,
enum radeon_pm_state_type ps_type, enum radeon_pm_state_type ps_type,
int instance) int instance)
...@@ -71,34 +65,17 @@ int radeon_pm_get_type_index(struct radeon_device *rdev, ...@@ -71,34 +65,17 @@ int radeon_pm_get_type_index(struct radeon_device *rdev,
return rdev->pm.default_power_state_index; return rdev->pm.default_power_state_index;
} }
#ifdef CONFIG_ACPI void radeon_pm_acpi_event_handler(struct radeon_device *rdev)
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); if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
struct acpi_bus_event *entry = (struct acpi_bus_event *)data; if (rdev->pm.profile == PM_PROFILE_AUTO) {
mutex_lock(&rdev->pm.mutex);
if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) { radeon_pm_update_profile(rdev);
if (power_supply_is_system_supplied() > 0) radeon_pm_set_clocks(rdev);
DRM_DEBUG_DRIVER("pm: AC\n"); mutex_unlock(&rdev->pm.mutex);
else
DRM_DEBUG_DRIVER("pm: DC\n");
if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
if (rdev->pm.profile == PM_PROFILE_AUTO) {
mutex_lock(&rdev->pm.mutex);
radeon_pm_update_profile(rdev);
radeon_pm_set_clocks(rdev);
mutex_unlock(&rdev->pm.mutex);
}
} }
} }
/* Check for pending SBIOS requests */
return radeon_atif_handler(rdev, entry);
} }
#endif
static void radeon_pm_update_profile(struct radeon_device *rdev) static void radeon_pm_update_profile(struct radeon_device *rdev)
{ {
...@@ -629,10 +606,6 @@ int radeon_pm_init(struct radeon_device *rdev) ...@@ -629,10 +606,6 @@ int radeon_pm_init(struct radeon_device *rdev)
if (ret) if (ret)
DRM_ERROR("failed to create device file for power method\n"); DRM_ERROR("failed to create device file for power method\n");
#ifdef CONFIG_ACPI
rdev->acpi_nb.notifier_call = radeon_acpi_event;
register_acpi_notifier(&rdev->acpi_nb);
#endif
if (radeon_debugfs_pm_init(rdev)) { if (radeon_debugfs_pm_init(rdev)) {
DRM_ERROR("Failed to register debugfs file for PM!\n"); DRM_ERROR("Failed to register debugfs file for PM!\n");
} }
...@@ -663,9 +636,6 @@ void radeon_pm_fini(struct radeon_device *rdev) ...@@ -663,9 +636,6 @@ void radeon_pm_fini(struct radeon_device *rdev)
device_remove_file(rdev->dev, &dev_attr_power_profile); device_remove_file(rdev->dev, &dev_attr_power_profile);
device_remove_file(rdev->dev, &dev_attr_power_method); device_remove_file(rdev->dev, &dev_attr_power_method);
#ifdef CONFIG_ACPI
unregister_acpi_notifier(&rdev->acpi_nb);
#endif
} }
if (rdev->pm.power_state) if (rdev->pm.power_state)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment