X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fnvidia.c;h=5feb36f26afdd5b4063e1c26d50d260b762ad8d7;hb=0e52be5c9e4d3bfe732f90abe7ca3cbfa32ad59c;hp=0a85275e0955645650e7ed8375116ae93a875ce2;hpb=e7693e36722f471a39ddca6081a38ff3c9b008d2;p=psensor.git diff --git a/src/lib/nvidia.c b/src/lib/nvidia.c index 0a85275..5feb36f 100644 --- a/src/lib/nvidia.c +++ b/src/lib/nvidia.c @@ -1,22 +1,21 @@ /* - Copyright (C) 2010-2011 jeanfi@gmail.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA -*/ - + * Copyright (C) 2010-2014 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ #include #include #define _(str) gettext(str) @@ -34,9 +33,7 @@ Display *display; -/* - Returns the temperature (Celcius) of a NVidia GPU. -*/ +/* Returns the temperature (Celsius) of a NVidia GPU. */ static int get_temp(struct psensor *sensor) { int temp; @@ -52,7 +49,8 @@ static int get_temp(struct psensor *sensor) if (res == True) return temp; - fprintf(stderr, _("ERROR: failed to retrieve nvidia temperature\n")); + log_debug(_("NVIDIA proprietary driver not used or cannot " + "retrieve NVIDIA GPU temperature.")); return 0; } @@ -61,14 +59,20 @@ static struct psensor *create_sensor(int id, int values_len) char name[200]; char *sid; struct psensor *s; + int t; sprintf(name, "GPU%d", id); sid = malloc(strlen("nvidia") + 1 + strlen(name) + 1); sprintf(sid, "nvidia %s", name); - s = psensor_create(sid, strdup(name), - SENSOR_TYPE_NVIDIA, values_len); + t = SENSOR_TYPE_NVCTRL | SENSOR_TYPE_GPU | SENSOR_TYPE_TEMP; + + s = psensor_create(sid, + strdup(name), + strdup(_("NVidia GPU")), + t, + values_len); s->nvidia_id = id; @@ -88,8 +92,7 @@ static int init() display = XOpenDisplay(NULL); if (!display) { - fprintf(stderr, - _("ERROR: Cannot open connection to X Server\n")); + log_err(_("Cannot open connection to X11 server.")); return 0; } @@ -97,7 +100,7 @@ static int init() XNVCTRLQueryTargetCount(display, NV_CTRL_TARGET_TYPE_GPU, &n)) return n; - fprintf(stderr, _("ERROR: Cannot retrieve NVidia information\n")); + log_err(_("Failed to retrieve NVIDIA information.")); return 0; } @@ -110,7 +113,7 @@ void nvidia_psensor_list_update(struct psensor **sensors) while (*ss) { s = *ss; - if (s->type == SENSOR_TYPE_NVIDIA) + if (s->type & SENSOR_TYPE_NVCTRL) psensor_set_current_value(s, get_temp(s)); ss++;