Add a way to list the available voltages
Subsystems (3)
PATCH 1/1 Add a way to list the available voltages
Hi,
This patch makes it easy for people to set their custom_voltage file. Previously, they had to guess what was the available voltages.
This patch depends on my previous patch to add a custom perflvl.
Martin
From e9c880e0882bb609a9ce4ec0bf28ef99ea78714a Mon Sep 17 00:00:00 2001
From: Martin Peres <[email protected]>
Date: Mon, 22 Nov 2010 09:59:16 +0100
Subject: [PATCH] Add a way to list the available voltages through sysfs
Signed-off-by Martin Peres <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_pm.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
drivers/gpu/drm/nouveau/nouveau_pm.c +32 -0
@@ -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
Signature · 1 line
1.7.3.2
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau