]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
drm/nouveau: hook up acpi power supply change tracking
authorBen Skeggs <bskeggs@redhat.com>
Tue, 12 Oct 2010 02:31:32 +0000 (12:31 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 3 Dec 2010 05:05:29 +0000 (15:05 +1000)
Not used at all yet, but lets hook it up now anyway.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_pm.c

index b78663fc334c8e6a83ad052cc68a22920d21d8e9..699d546623bd21ac6cb9e635c2386dbb017e99b3 100644 (file)
@@ -439,6 +439,7 @@ struct nouveau_pm_engine {
        struct nouveau_pm_level *cur;
 
        struct device *hwmon;
+       struct notifier_block acpi_nb;
 
        int (*clock_get)(struct drm_device *, u32 id);
        void *(*clock_pre)(struct drm_device *, struct nouveau_pm_level *,
index 9f7b158f5825c7dfd97b5f112afef7a9858e7b23..d93814160bcffc624cf44ffbe3cc2a0eb27b9b3f 100644 (file)
 #include "nouveau_drv.h"
 #include "nouveau_pm.h"
 
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+#endif
+#include <linux/power_supply.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 
@@ -446,6 +450,25 @@ nouveau_hwmon_fini(struct drm_device *dev)
 #endif
 }
 
+#ifdef CONFIG_ACPI
+static int
+nouveau_pm_acpi_event(struct notifier_block *nb, unsigned long val, void *data)
+{
+       struct drm_nouveau_private *dev_priv =
+               container_of(nb, struct drm_nouveau_private, engine.pm.acpi_nb);
+       struct drm_device *dev = dev_priv->dev;
+       struct acpi_bus_event *entry = (struct acpi_bus_event *)data;
+
+       if (strcmp(entry->device_class, "ac_adapter") == 0) {
+               bool ac = power_supply_is_system_supplied();
+
+               NV_DEBUG(dev, "power supply changed: %s\n", ac ? "AC" : "DC");
+       }
+
+       return NOTIFY_OK;
+}
+#endif
+
 int
 nouveau_pm_init(struct drm_device *dev)
 {
@@ -485,6 +508,10 @@ nouveau_pm_init(struct drm_device *dev)
 
        nouveau_sysfs_init(dev);
        nouveau_hwmon_init(dev);
+#ifdef CONFIG_ACPI
+       pm->acpi_nb.notifier_call = nouveau_pm_acpi_event;
+       register_acpi_notifier(&pm->acpi_nb);
+#endif
 
        return 0;
 }
@@ -503,6 +530,9 @@ nouveau_pm_fini(struct drm_device *dev)
        nouveau_perf_fini(dev);
        nouveau_volt_fini(dev);
 
+#ifdef CONFIG_ACPI
+       unregister_acpi_notifier(&pm->acpi_nb);
+#endif
        nouveau_hwmon_fini(dev);
        nouveau_sysfs_fini(dev);
 }