diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2012-07-31 17:14:35 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2012-09-20 13:10:36 -0400 |
commit | c49170742d6928b16fb3839b47a94cc41630dbe0 (patch) | |
tree | 1496b1d8e4b067d84b28af0f8d5aabb22bf12177 | |
parent | fda4b25c55a59ba12378e4b9e4553f6ea57d802d (diff) |
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>
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_acpi.c | 32 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_kms.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_pm.c | 44 |
4 files changed, 48 insertions, 43 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index dea5f08bd23b..b5b16878f0cf 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -1869,12 +1869,14 @@ extern void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_displ | |||
1869 | extern int ni_init_microcode(struct radeon_device *rdev); | 1869 | extern int ni_init_microcode(struct radeon_device *rdev); |
1870 | extern int ni_mc_load_microcode(struct radeon_device *rdev); | 1870 | extern int ni_mc_load_microcode(struct radeon_device *rdev); |
1871 | 1871 | ||
1872 | /* radeon_acpi.c */ | 1872 | /* radeon_acpi.c */ |
1873 | #if defined(CONFIG_ACPI) | 1873 | #if defined(CONFIG_ACPI) |
1874 | extern int radeon_acpi_init(struct radeon_device *rdev); | 1874 | extern int radeon_acpi_init(struct radeon_device *rdev); |
1875 | #else | 1875 | extern void radeon_acpi_fini(struct radeon_device *rdev); |
1876 | static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; } | 1876 | #else |
1877 | #endif | 1877 | static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; } |
1878 | static inline void radeon_acpi_fini(struct radeon_device *rdev) { } | ||
1879 | #endif | ||
1878 | 1880 | ||
1879 | #include "radeon_object.h" | 1881 | #include "radeon_object.h" |
1880 | 1882 | ||
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 @@ | |||
24 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
25 | #include <linux/acpi.h> | 25 | #include <linux/acpi.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/power_supply.h> | ||
27 | #include <acpi/acpi_drivers.h> | 28 | #include <acpi/acpi_drivers.h> |
28 | #include <acpi/acpi_bus.h> | 29 | #include <acpi/acpi_bus.h> |
29 | #include <acpi/video.h> | 30 | #include <acpi/video.h> |
@@ -38,6 +39,10 @@ | |||
38 | 39 | ||
39 | #include <linux/vga_switcheroo.h> | 40 | #include <linux/vga_switcheroo.h> |
40 | 41 | ||
42 | #define ACPI_AC_CLASS "ac_adapter" | ||
43 | |||
44 | extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev); | ||
45 | |||
41 | struct atif_verify_interface { | 46 | struct atif_verify_interface { |
42 | u16 size; /* structure size in bytes (includes size field) */ | 47 | u16 size; /* structure size in bytes (includes size field) */ |
43 | u16 version; /* version */ | 48 | u16 version; /* version */ |
@@ -299,6 +304,26 @@ int radeon_atif_handler(struct radeon_device *rdev, | |||
299 | return NOTIFY_OK; | 304 | return NOTIFY_OK; |
300 | } | 305 | } |
301 | 306 | ||
307 | static int radeon_acpi_event(struct notifier_block *nb, | ||
308 | unsigned long val, | ||
309 | void *data) | ||
310 | { | ||
311 | struct radeon_device *rdev = container_of(nb, struct radeon_device, acpi_nb); | ||
312 | struct acpi_bus_event *entry = (struct acpi_bus_event *)data; | ||
313 | |||
314 | if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) { | ||
315 | if (power_supply_is_system_supplied() > 0) | ||
316 | DRM_DEBUG_DRIVER("pm: AC\n"); | ||
317 | else | ||
318 | DRM_DEBUG_DRIVER("pm: DC\n"); | ||
319 | |||
320 | radeon_pm_acpi_event_handler(rdev); | ||
321 | } | ||
322 | |||
323 | /* Check for pending SBIOS requests */ | ||
324 | return radeon_atif_handler(rdev, entry); | ||
325 | } | ||
326 | |||
302 | /* Call all ACPI methods here */ | 327 | /* Call all ACPI methods here */ |
303 | int radeon_acpi_init(struct radeon_device *rdev) | 328 | int radeon_acpi_init(struct radeon_device *rdev) |
304 | { | 329 | { |
@@ -367,6 +392,13 @@ int radeon_acpi_init(struct radeon_device *rdev) | |||
367 | } | 392 | } |
368 | 393 | ||
369 | out: | 394 | out: |
395 | rdev->acpi_nb.notifier_call = radeon_acpi_event; | ||
396 | register_acpi_notifier(&rdev->acpi_nb); | ||
397 | |||
370 | return ret; | 398 | return ret; |
371 | } | 399 | } |
372 | 400 | ||
401 | void radeon_acpi_fini(struct radeon_device *rdev) | ||
402 | { | ||
403 | unregister_acpi_notifier(&rdev->acpi_nb); | ||
404 | } | ||
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index 8c2471854cd7..cb8e94d1a2b2 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -51,6 +51,7 @@ int radeon_driver_unload_kms(struct drm_device *dev) | |||
51 | 51 | ||
52 | if (rdev == NULL) | 52 | if (rdev == NULL) |
53 | return 0; | 53 | return 0; |
54 | radeon_acpi_fini(rdev); | ||
54 | radeon_modeset_fini(rdev); | 55 | radeon_modeset_fini(rdev); |
55 | radeon_device_fini(rdev); | 56 | radeon_device_fini(rdev); |
56 | kfree(rdev); | 57 | kfree(rdev); |
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index 14e544e0eb31..c15e505a15bc 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
@@ -22,12 +22,8 @@ | |||
22 | */ | 22 | */ |
23 | #include "drmP.h" | 23 | #include "drmP.h" |
24 | #include "radeon.h" | 24 | #include "radeon.h" |
25 | #include "radeon_acpi.h" | ||
26 | #include "avivod.h" | 25 | #include "avivod.h" |
27 | #include "atom.h" | 26 | #include "atom.h" |
28 | #ifdef CONFIG_ACPI | ||
29 | #include <linux/acpi.h> | ||
30 | #endif | ||
31 | #include <linux/power_supply.h> | 27 | #include <linux/power_supply.h> |
32 | #include <linux/hwmon.h> | 28 | #include <linux/hwmon.h> |
33 | #include <linux/hwmon-sysfs.h> | 29 | #include <linux/hwmon-sysfs.h> |
@@ -51,8 +47,6 @@ static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish | |||
51 | static void radeon_pm_update_profile(struct radeon_device *rdev); | 47 | static void radeon_pm_update_profile(struct radeon_device *rdev); |
52 | static void radeon_pm_set_clocks(struct radeon_device *rdev); | 48 | static void radeon_pm_set_clocks(struct radeon_device *rdev); |
53 | 49 | ||
54 | #define ACPI_AC_CLASS "ac_adapter" | ||
55 | |||
56 | int radeon_pm_get_type_index(struct radeon_device *rdev, | 50 | int radeon_pm_get_type_index(struct radeon_device *rdev, |
57 | enum radeon_pm_state_type ps_type, | 51 | enum radeon_pm_state_type ps_type, |
58 | int instance) | 52 | int instance) |
@@ -71,34 +65,17 @@ int radeon_pm_get_type_index(struct radeon_device *rdev, | |||
71 | return rdev->pm.default_power_state_index; | 65 | return rdev->pm.default_power_state_index; |
72 | } | 66 | } |
73 | 67 | ||
74 | #ifdef CONFIG_ACPI | 68 | void radeon_pm_acpi_event_handler(struct radeon_device *rdev) |
75 | static int radeon_acpi_event(struct notifier_block *nb, | ||
76 | unsigned long val, | ||
77 | void *data) | ||
78 | { | 69 | { |
79 | struct radeon_device *rdev = container_of(nb, struct radeon_device, acpi_nb); | 70 | if (rdev->pm.pm_method == PM_METHOD_PROFILE) { |
80 | struct acpi_bus_event *entry = (struct acpi_bus_event *)data; | 71 | if (rdev->pm.profile == PM_PROFILE_AUTO) { |
81 | 72 | mutex_lock(&rdev->pm.mutex); | |
82 | if (strcmp(entry->device_class, ACPI_AC_CLASS) == 0) { | 73 | radeon_pm_update_profile(rdev); |
83 | if (power_supply_is_system_supplied() > 0) | 74 | radeon_pm_set_clocks(rdev); |
84 | DRM_DEBUG_DRIVER("pm: AC\n"); | 75 | mutex_unlock(&rdev->pm.mutex); |
85 | else | ||
86 | DRM_DEBUG_DRIVER("pm: DC\n"); | ||
87 | |||
88 | if (rdev->pm.pm_method == PM_METHOD_PROFILE) { | ||
89 | if (rdev->pm.profile == PM_PROFILE_AUTO) { | ||
90 | mutex_lock(&rdev->pm.mutex); | ||
91 | radeon_pm_update_profile(rdev); | ||
92 | radeon_pm_set_clocks(rdev); | ||
93 | mutex_unlock(&rdev->pm.mutex); | ||
94 | } | ||
95 | } | 76 | } |
96 | } | 77 | } |
97 | |||
98 | /* Check for pending SBIOS requests */ | ||
99 | return radeon_atif_handler(rdev, entry); | ||
100 | } | 78 | } |
101 | #endif | ||
102 | 79 | ||
103 | static void radeon_pm_update_profile(struct radeon_device *rdev) | 80 | static void radeon_pm_update_profile(struct radeon_device *rdev) |
104 | { | 81 | { |
@@ -629,10 +606,6 @@ int radeon_pm_init(struct radeon_device *rdev) | |||
629 | if (ret) | 606 | if (ret) |
630 | DRM_ERROR("failed to create device file for power method\n"); | 607 | DRM_ERROR("failed to create device file for power method\n"); |
631 | 608 | ||
632 | #ifdef CONFIG_ACPI | ||
633 | rdev->acpi_nb.notifier_call = radeon_acpi_event; | ||
634 | register_acpi_notifier(&rdev->acpi_nb); | ||
635 | #endif | ||
636 | if (radeon_debugfs_pm_init(rdev)) { | 609 | if (radeon_debugfs_pm_init(rdev)) { |
637 | DRM_ERROR("Failed to register debugfs file for PM!\n"); | 610 | DRM_ERROR("Failed to register debugfs file for PM!\n"); |
638 | } | 611 | } |
@@ -663,9 +636,6 @@ void radeon_pm_fini(struct radeon_device *rdev) | |||
663 | 636 | ||
664 | device_remove_file(rdev->dev, &dev_attr_power_profile); | 637 | device_remove_file(rdev->dev, &dev_attr_power_profile); |
665 | device_remove_file(rdev->dev, &dev_attr_power_method); | 638 | device_remove_file(rdev->dev, &dev_attr_power_method); |
666 | #ifdef CONFIG_ACPI | ||
667 | unregister_acpi_notifier(&rdev->acpi_nb); | ||
668 | #endif | ||
669 | } | 639 | } |
670 | 640 | ||
671 | if (rdev->pm.power_state) | 641 | if (rdev->pm.power_state) |