diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drv.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_pm.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index b78663fc334..699d546623b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h | |||
@@ -439,6 +439,7 @@ struct nouveau_pm_engine { | |||
439 | struct nouveau_pm_level *cur; | 439 | struct nouveau_pm_level *cur; |
440 | 440 | ||
441 | struct device *hwmon; | 441 | struct device *hwmon; |
442 | struct notifier_block acpi_nb; | ||
442 | 443 | ||
443 | int (*clock_get)(struct drm_device *, u32 id); | 444 | int (*clock_get)(struct drm_device *, u32 id); |
444 | void *(*clock_pre)(struct drm_device *, struct nouveau_pm_level *, | 445 | void *(*clock_pre)(struct drm_device *, struct nouveau_pm_level *, |
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c index 9f7b158f582..d93814160bc 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 | } |