[PATCH] Add a way to list the available voltages through sysfs
Martin Peres
mupuf at mupuf.org
Mon Nov 22 00:59:16 PST 2010
Signed-off-by: Martin Peres <martin.peres at ensi-bourges.fr>
---
drivers/gpu/drm/nouveau/nouveau_pm.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c
index 49d8a17..b0d0691 100644
--- a/drivers/gpu/drm/nouveau/nouveau_pm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_pm.c
@@ -412,6 +412,33 @@ static DEVICE_ATTR(custom_voltage, S_IRUGO | S_IWUSR,
nouveau_pm_get_custom_voltage,
nouveau_pm_set_custom_voltage);
+static ssize_t
+nouveau_pm_get_voltages(struct device *d, struct device_attribute *a, char *buf)
+{
+ struct drm_device *dev = pci_get_drvdata(to_pci_dev(d));
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
+ struct nouveau_pm_voltage *volt = &pm->voltage;
+ int cur_voltage = nouveau_voltage_gpio_get(dev);
+ char *ptr = buf;
+ int len = PAGE_SIZE;
+ int i;
+
+ for (i = 0; i < volt->nr_level; i++) {
+ int size = snprintf(ptr, len, "%c %d [*10mV]\n",
+ cur_voltage == volt->level[i].voltage ? '*' : ' ',
+ volt->level[i].voltage
+ );
+
+ ptr += size;
+ len -= size;
+ }
+
+ return strlen(buf);
+}
+
+static DEVICE_ATTR(voltages, S_IRUGO, nouveau_pm_get_voltages, NULL);
+
static int
nouveau_sysfs_init(struct drm_device *dev)
{
@@ -463,6 +490,10 @@ nouveau_sysfs_init(struct drm_device *dev)
if (ret)
return ret;
+ ret = device_create_file(d, &dev_attr_voltages);
+ if (ret)
+ return ret;
+
return 0;
}
@@ -488,6 +519,7 @@ nouveau_sysfs_fini(struct drm_device *dev)
device_remove_file(d, &dev_attr_custom_shader);
device_remove_file(d, &dev_attr_custom_unk05);
device_remove_file(d, &dev_attr_custom_voltage);
+ device_remove_file(d, &dev_attr_voltages);
}
#ifdef CONFIG_HWMON
--
1.7.3.2
--------------090500090007030301010403--
More information about the Nouveau
mailing list