root/lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h @ 4366

Revision 4366, 6.9 KB (checked in by jwrdegoede, 8 years ago)

Generic chip support / get featuretype fixes just received from Bob Schlarmann, as the version I committed wasn't the latest version

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2    sensors.h - Part of libsensors, a Linux library for reading sensor data.
3    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/
19
20#ifndef LIB_SENSORS_SENSORS_H
21#define LIB_SENSORS_SENSORS_H
22
23#include <stdio.h>
24#include <limits.h>
25
26/* Publicly accessible library functions */
27
28#define SENSORS_CHIP_NAME_PREFIX_ANY NULL
29#define SENSORS_CHIP_NAME_BUS_ISA -1
30#define SENSORS_CHIP_NAME_BUS_ANY -2
31#define SENSORS_CHIP_NAME_BUS_ANY_I2C -3
32#define SENSORS_CHIP_NAME_BUS_DUMMY -4
33#define SENSORS_CHIP_NAME_BUS_PCI -5
34#define SENSORS_CHIP_NAME_ADDR_ANY -1
35
36#ifdef __cplusplus
37extern "C" {
38#endif /* __cplusplus */
39
40/* A chip name is encoded is in this structure */
41typedef struct sensors_chip_name {
42  char *prefix;
43  int bus;
44  int addr;
45  char *busname;        /* if dummy */
46} sensors_chip_name;
47
48/* (Re)load the configuration file and the detected chips list. If this
49    returns a value unequal to zero, you are in trouble; you can not
50    assume anything will be initialized properly. */
51extern int sensors_init(FILE *input);
52
53/* Clean-up function: You can't access anything after
54   this, until the next sensors_init() call! */
55extern void sensors_cleanup(void);
56
57/* Parse a chip name to the internal representation. Return 0 on succes, <0
58   on error. */
59extern int sensors_parse_chip_name(const char *orig_name,
60                                   sensors_chip_name *res);
61
62/* Compare two chips name descriptions, to see whether they could match.
63   Return 0 if it does not match, return 1 if it does match. */
64extern int sensors_match_chip(sensors_chip_name chip1, 
65                              sensors_chip_name chip2);
66
67/* Check whether the chip name is an 'absolute' name, which can only match
68   one chip, or whether it has wildcards. Returns 0 if it is absolute, 1
69   if there are wildcards. */
70extern int sensors_chip_name_has_wildcards(sensors_chip_name chip);
71
72/* This function returns the adapter name of a bus number,
73   as used within the sensors_chip_name structure. If it could not be found,
74   it returns NULL */
75extern const char *sensors_get_adapter_name(int bus_nr);
76
77/* This function is deprecated and will be dropped soon. */
78extern const char *sensors_get_algorithm_name(int bus_nr);
79
80/* Look up the label which belongs to this chip. Note that chip should not
81   contain wildcard values! *result is newly allocated (free it yourself).
82   This function will return 0 on success, and <0 on failure.  This
83   function takes logical mappings into account. */
84extern int sensors_get_label(sensors_chip_name name, int feature, 
85                             char **result);
86
87/* Looks up whether a feature should be ignored. Returns <0 on failure,
88   0 if it should be ignored, 1 if it is valid. This function takes
89   logical mappings into account. */
90extern int sensors_get_ignored(sensors_chip_name name, int fature);
91
92/* Read the value of a feature of a certain chip. Note that chip should not
93   contain wildcard values! This function will return 0 on success, and <0
94   on failure.  */
95extern int sensors_get_feature(sensors_chip_name name, int feature,
96                               double *result);
97
98/* Set the value of a feature of a certain chip. Note that chip should not
99   contain wildcard values! This function will return 0 on success, and <0
100   on failure. */
101extern int sensors_set_feature(sensors_chip_name name, int feature,
102                               double value);
103
104/* Execute all set statements for this particular chip. The chip may contain
105   wildcards!  This function will return 0 on success, and <0 on failure. */
106extern int sensors_do_chip_sets(sensors_chip_name name);
107
108/* Execute all set statements for all detected chips. This is the same as
109   calling sensors_do_chip_sets with an all wildcards chip name */
110extern int sensors_do_all_sets(void);
111
112/* This function returns all detected chips, one by one. To start at the
113   beginning of the list, use 0 for nr; NULL is returned if we are
114   at the end of the list. Do not try to change these chip names, as
115   they point to internal structures! Do not use nr for anything else. */
116extern const sensors_chip_name *sensors_get_detected_chips(int *nr);
117
118
119/* These defines are used in the mode field of sensors_feature_data */
120#define SENSORS_MODE_NO_RW 0
121#define SENSORS_MODE_R 1
122#define SENSORS_MODE_W 2
123#define SENSORS_MODE_RW 3
124
125/* This define is used in the mapping field of sensors_feature_data if no
126   mapping is available */
127#define SENSORS_NO_MAPPING -1
128
129/* This structure is used when you want to get all features of a specific
130   chip. */
131typedef struct sensors_feature_data {
132  int number;
133  const char *name;
134  int mapping;
135  int compute_mapping;
136  int mode;
137} sensors_feature_data;
138
139/* This returns all features of a specific chip. They are returned in
140   bunches: everything with the same mapping is returned just after each
141   other, with the master feature in front (that feature does not map to
142   itself, but has SENSORS_NO_MAPPING as mapping field). nr1 and nr2 are
143   two internally used variables. Set both to zero to start again at the
144   begin of the list. If no more features are found NULL is returned.
145   Do not try to change the returned structure; you will corrupt internal
146   data structures. */
147extern const sensors_feature_data *sensors_get_all_features
148             (sensors_chip_name name, int *nr1,int *nr2);
149
150typedef enum sensors_feature_type {
151  SENSORS_FEATURE_TEMP = 0x0,
152  SENSORS_FEATURE_TEMP_ALARM,
153  SENSORS_FEATURE_TEMP_FAULT,
154  SENSORS_FEATURE_TEMP_SENS,
155  SENSORS_FEATURE_TEMP_HYST,
156  SENSORS_FEATURE_TEMP_OVER,
157  SENSORS_FEATURE_TEMP_MAX,
158  SENSORS_FEATURE_TEMP_MIN,
159  SENSORS_FEATURE_TEMP_HIGH,
160  SENSORS_FEATURE_TEMP_LOW,
161  SENSORS_FEATURE_TEMP_LIM,
162  SENSORS_FEATURE_TEMP_CRIT,
163 
164  SENSORS_FEATURE_IN = 0x100,
165  SENSORS_FEATURE_IN_ALARM,
166  SENSORS_FEATURE_IN_MIN,
167  SENSORS_FEATURE_IN_MAX,
168  SENSORS_FEATURE_IN_MIN_ALARM,
169  SENSORS_FEATURE_IN_MAX_ALARM,
170 
171  SENSORS_FEATURE_FAN = 0x200,
172  SENSORS_FEATURE_FAN_ALARM,
173  SENSORS_FEATURE_FAN_FAULT,
174  SENSORS_FEATURE_FAN_MIN,
175  SENSORS_FEATURE_FAN_DIV,
176 
177  SENSORS_FEATURE_VID = 0x300,
178  SENSORS_FEATURE_VRM,
179 
180  SENSORS_FEATURE_UNKNOWN = INT_MAX
181} sensors_feature_type;
182
183sensors_feature_type sensors_feature_get_type
184             (const sensors_feature_data *feature);
185
186#ifdef __cplusplus
187}
188#endif /* __cplusplus */
189
190#endif /* def LIB_SENSORS_ERROR_H */
Note: See TracBrowser for help on using the browser.