Removing old svn keywords.
[monky] / src / nvidia.c
1 /* Conky, a system monitor, based on torsmo
2  *
3  * Any original torsmo code is licensed under the BSD license
4  *
5  * All code written since the fork of torsmo is licensed under the GPL
6  *
7  * Please see COPYING for details
8  *
9  * Copyright (c) 2008 Markus Meissner
10  * Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
11  *      (see AUTHORS)
12  * All rights reserved.
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  *
26  */
27
28 #include "nvidia.h"
29
30 int get_nvidia_value(QUERY_ID qid, Display *dpy){
31         int tmp;
32         if(!XNVCTRLQueryAttribute(dpy, 0, 0, qid, &tmp)){
33                 return -1;
34         }
35         /* FIXME: when are the low 2 bytes of NV_GPU_FREQ needed? */
36         if (qid == NV_GPU_FREQ)
37                 return tmp >> 16;
38         if (qid == NV_MEM_FREQ)
39                 return tmp & 0xFFFF;
40         return tmp;
41 }
42
43 int set_nvidia_type(struct nvidia_s *nvidia, const char *arg)
44 {
45         if (!arg || !arg[0] || !arg[1])
46                 return 1;
47
48         nvidia->print_as_float = 0;
49         switch(arg[0]) {
50                 case 't':                              // temp or threshold
51                         nvidia->print_as_float = 1;
52                         if (arg[1] == 'e')
53                                 nvidia->type = NV_TEMP;
54                         else if (arg[1] == 'h')
55                                 nvidia->type = NV_TEMP_THRESHOLD;
56                         else
57                                 return 1;
58                         break;
59                 case 'g':                              // gpufreq
60                         nvidia->type = NV_GPU_FREQ;
61                         break;
62                 case 'm':                              // memfreq
63                         nvidia->type = NV_MEM_FREQ;
64                         break;
65                 case 'i':                              // imagequality
66                         nvidia->type = NV_IMAGE_QUALITY;
67                         break;
68                 default:
69                         return 1;
70         }
71         return 0;
72 }