Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 228523
b: refs/heads/master
c: 6032649
h: refs/heads/master
i:
  228521: c00e9a0
  228519: db231fc
v: v3
  • Loading branch information
Ben Skeggs committed Dec 3, 2010
1 parent 2895848 commit 48ae2aa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 18a16a768c3d37f5bfdbb414217b530294d5d442
refs/heads/master: 6032649df9f456f379be8d51f64488cacbfa8317
1 change: 1 addition & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *,
Expand Down
30 changes: 30 additions & 0 deletions trunk/drivers/gpu/drm/nouveau/nouveau_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#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>

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 48ae2aa

Please sign in to comment.