diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2010-10-11 22:31:32 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2010-12-03 00:05:29 -0500 |
commit | 6032649df9f456f379be8d51f64488cacbfa8317 (patch) | |
tree | a2532cfe347435a47491dc516550dd0eead42595 /drivers/gpu/drm/nouveau/nouveau_pm.c | |
parent | 18a16a768c3d37f5bfdbb414217b530294d5d442 (diff) |
drm/nouveau: hook up acpi power supply change tracking
Not used at all yet, but lets hook it up now anyway.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_pm.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_pm.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c index 9f7b158f5825..d93814160bcf 100644 --- a/drivers/gpu/drm/nouveau/nouveau_pm.c +++ b/drivers/gpu/drm/nouveau/nouveau_pm.c | |||
@@ -27,6 +27,10 @@ | |||
27 | #include "nouveau_drv.h" | 27 | #include "nouveau_drv.h" |
28 | #include "nouveau_pm.h" | 28 | #include "nouveau_pm.h" |
29 | 29 | ||
30 | #ifdef CONFIG_ACPI | ||
31 | #include <linux/acpi.h> | ||
32 | #endif | ||
33 | #include <linux/power_supply.h> | ||
30 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
31 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
32 | 36 | ||
@@ -446,6 +450,25 @@ nouveau_hwmon_fini(struct drm_device *dev) | |||
446 | #endif | 450 | #endif |
447 | } | 451 | } |
448 | 452 | ||
453 | #ifdef CONFIG_ACPI | ||
454 | static int | ||
455 | nouveau_pm_acpi_event(struct notifier_block *nb, unsigned long val, void *data) | ||
456 | { | ||
457 | struct drm_nouveau_private *dev_priv = | ||
458 | container_of(nb, struct drm_nouveau_private, engine.pm.acpi_nb); | ||
459 | struct drm_device *dev = dev_priv->dev; | ||
460 | struct acpi_bus_event *entry = (struct acpi_bus_event *)data; | ||
461 | |||
462 | if (strcmp(entry->device_class, "ac_adapter") == 0) { | ||
463 | bool ac = power_supply_is_system_supplied(); | ||
464 | |||
465 | NV_DEBUG(dev, "power supply changed: %s\n", ac ? "AC" : "DC"); | ||
466 | } | ||
467 | |||
468 | return NOTIFY_OK; | ||
469 | } | ||
470 | #endif | ||
471 | |||
449 | int | 472 | int |
450 | nouveau_pm_init(struct drm_device *dev) | 473 | nouveau_pm_init(struct drm_device *dev) |
451 | { | 474 | { |
@@ -485,6 +508,10 @@ nouveau_pm_init(struct drm_device *dev) | |||
485 | 508 | ||
486 | nouveau_sysfs_init(dev); | 509 | nouveau_sysfs_init(dev); |
487 | nouveau_hwmon_init(dev); | 510 | nouveau_hwmon_init(dev); |
511 | #ifdef CONFIG_ACPI | ||
512 | pm->acpi_nb.notifier_call = nouveau_pm_acpi_event; | ||
513 | register_acpi_notifier(&pm->acpi_nb); | ||
514 | #endif | ||
488 | 515 | ||
489 | return 0; | 516 | return 0; |
490 | } | 517 | } |
@@ -503,6 +530,9 @@ nouveau_pm_fini(struct drm_device *dev) | |||
503 | nouveau_perf_fini(dev); | 530 | nouveau_perf_fini(dev); |
504 | nouveau_volt_fini(dev); | 531 | nouveau_volt_fini(dev); |
505 | 532 | ||
533 | #ifdef CONFIG_ACPI | ||
534 | unregister_acpi_notifier(&pm->acpi_nb); | ||
535 | #endif | ||
506 | nouveau_hwmon_fini(dev); | 536 | nouveau_hwmon_fini(dev); |
507 | nouveau_sysfs_fini(dev); | 537 | nouveau_sysfs_fini(dev); |
508 | } | 538 | } |