diff options
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_pm.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_pm.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c index 9f7b158f5825..fb846a3fef15 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 | ||
@@ -418,8 +422,7 @@ nouveau_hwmon_init(struct drm_device *dev) | |||
418 | return ret; | 422 | return ret; |
419 | } | 423 | } |
420 | dev_set_drvdata(hwmon_dev, dev); | 424 | dev_set_drvdata(hwmon_dev, dev); |
421 | ret = sysfs_create_group(&hwmon_dev->kobj, | 425 | ret = sysfs_create_group(&dev->pdev->dev.kobj, &hwmon_attrgroup); |
422 | &hwmon_attrgroup); | ||
423 | if (ret) { | 426 | if (ret) { |
424 | NV_ERROR(dev, | 427 | NV_ERROR(dev, |
425 | "Unable to create hwmon sysfs file: %d\n", ret); | 428 | "Unable to create hwmon sysfs file: %d\n", ret); |
@@ -446,6 +449,25 @@ nouveau_hwmon_fini(struct drm_device *dev) | |||
446 | #endif | 449 | #endif |
447 | } | 450 | } |
448 | 451 | ||
452 | #ifdef CONFIG_ACPI | ||
453 | static int | ||
454 | nouveau_pm_acpi_event(struct notifier_block *nb, unsigned long val, void *data) | ||
455 | { | ||
456 | struct drm_nouveau_private *dev_priv = | ||
457 | container_of(nb, struct drm_nouveau_private, engine.pm.acpi_nb); | ||
458 | struct drm_device *dev = dev_priv->dev; | ||
459 | struct acpi_bus_event *entry = (struct acpi_bus_event *)data; | ||
460 | |||
461 | if (strcmp(entry->device_class, "ac_adapter") == 0) { | ||
462 | bool ac = power_supply_is_system_supplied(); | ||
463 | |||
464 | NV_DEBUG(dev, "power supply changed: %s\n", ac ? "AC" : "DC"); | ||
465 | } | ||
466 | |||
467 | return NOTIFY_OK; | ||
468 | } | ||
469 | #endif | ||
470 | |||
449 | int | 471 | int |
450 | nouveau_pm_init(struct drm_device *dev) | 472 | nouveau_pm_init(struct drm_device *dev) |
451 | { | 473 | { |
@@ -485,6 +507,10 @@ nouveau_pm_init(struct drm_device *dev) | |||
485 | 507 | ||
486 | nouveau_sysfs_init(dev); | 508 | nouveau_sysfs_init(dev); |
487 | nouveau_hwmon_init(dev); | 509 | nouveau_hwmon_init(dev); |
510 | #ifdef CONFIG_ACPI | ||
511 | pm->acpi_nb.notifier_call = nouveau_pm_acpi_event; | ||
512 | register_acpi_notifier(&pm->acpi_nb); | ||
513 | #endif | ||
488 | 514 | ||
489 | return 0; | 515 | return 0; |
490 | } | 516 | } |
@@ -503,6 +529,9 @@ nouveau_pm_fini(struct drm_device *dev) | |||
503 | nouveau_perf_fini(dev); | 529 | nouveau_perf_fini(dev); |
504 | nouveau_volt_fini(dev); | 530 | nouveau_volt_fini(dev); |
505 | 531 | ||
532 | #ifdef CONFIG_ACPI | ||
533 | unregister_acpi_notifier(&pm->acpi_nb); | ||
534 | #endif | ||
506 | nouveau_hwmon_fini(dev); | 535 | nouveau_hwmon_fini(dev); |
507 | nouveau_sysfs_fini(dev); | 536 | nouveau_sysfs_fini(dev); |
508 | } | 537 | } |