mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-29 12:50:43 +00:00
Add support for the standard beep_enable attribute (#2248).
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4766 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
3c53f5fa85
commit
29bea1e843
4 files changed
+37
-4
No files matched your search
@@ -562,6 +562,12 @@ sensors_feature_type sensors_feature_get_type(const char *name, int *nr)
|
||||
int i, count;
|
||||
const struct feature_subtype_match *submatches;
|
||||
|
||||
/* Special case */
|
||||
if (!strcmp(name, "beep_enable")) {
|
||||
*nr = 0;
|
||||
return SENSORS_FEATURE_BEEP_ENABLE;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(matches); i++)
|
||||
if ((count = sscanf(name, matches[i].name, nr, &c)))
|
||||
break;
|
||||
|
||||
@@ -154,6 +154,8 @@ typedef enum sensors_feature_type {
|
||||
|
||||
SENSORS_FEATURE_VID = 0x300,
|
||||
|
||||
SENSORS_FEATURE_BEEP_ENABLE = 0x1100,
|
||||
|
||||
SENSORS_FEATURE_UNKNOWN = INT_MAX,
|
||||
} sensors_feature_type;
|
||||
|
||||
|
||||
+11
-4
@@ -38,9 +38,10 @@ char sensors_sysfs_mount[NAME_MAX];
|
||||
|
||||
#define MAX_SENSORS_PER_TYPE 20
|
||||
#define MAX_SUB_FEATURES 6
|
||||
/* Room for all 3 types (in, fan, temp) with all their subfeatures + VID */
|
||||
/* Room for all 3 types (in, fan, temp) with all their subfeatures + VID
|
||||
+ misc features */
|
||||
#define ALL_POSSIBLE_FEATURES (MAX_SENSORS_PER_TYPE * MAX_SUB_FEATURES * 6 \
|
||||
+ MAX_SENSORS_PER_TYPE)
|
||||
+ MAX_SENSORS_PER_TYPE + 1)
|
||||
|
||||
static
|
||||
int get_type_scaling(int type)
|
||||
@@ -109,9 +110,15 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
|
||||
|
||||
/* "calculate" a place to store the feature in our sparse,
|
||||
sorted table */
|
||||
if (type == SENSORS_FEATURE_VID) {
|
||||
switch (type) {
|
||||
case SENSORS_FEATURE_VID:
|
||||
i = nr + MAX_SENSORS_PER_TYPE * MAX_SUB_FEATURES * 6;
|
||||
} else {
|
||||
break;
|
||||
case SENSORS_FEATURE_BEEP_ENABLE:
|
||||
i = MAX_SENSORS_PER_TYPE * MAX_SUB_FEATURES * 6 +
|
||||
MAX_SENSORS_PER_TYPE;
|
||||
break;
|
||||
default:
|
||||
i = (type >> 8) * MAX_SENSORS_PER_TYPE *
|
||||
MAX_SUB_FEATURES * 2 + nr * MAX_SUB_FEATURES * 2 +
|
||||
((type & 0x10) >> 4) * MAX_SUB_FEATURES +
|
||||
|
||||
@@ -390,6 +390,20 @@ static void print_chip_vid(const sensors_chip_name *name, int f_vid,
|
||||
free(label);
|
||||
}
|
||||
|
||||
static void print_chip_beep_enable(const sensors_chip_name *name, int f_beep,
|
||||
int label_size)
|
||||
{
|
||||
char *label;
|
||||
double beep_enable;
|
||||
|
||||
if ((label = sensors_get_label(name, f_beep))
|
||||
&& !sensors_get_value(name, f_beep, &beep_enable)) {
|
||||
print_label(label, label_size);
|
||||
printf("%s\n", beep_enable ? "enabled" : "disabled");
|
||||
}
|
||||
free(label);
|
||||
}
|
||||
|
||||
void print_chip(const sensors_chip_name *name)
|
||||
{
|
||||
const sensors_feature_data *feature;
|
||||
@@ -415,6 +429,10 @@ void print_chip(const sensors_chip_name *name)
|
||||
case SENSORS_FEATURE_VID:
|
||||
print_chip_vid(name, feature->number, label_size);
|
||||
break;
|
||||
case SENSORS_FEATURE_BEEP_ENABLE:
|
||||
print_chip_beep_enable(name, feature->number,
|
||||
label_size);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user