Merge branch 'thomab/freq' of ~/gitea/data/gitea-repositories/hramrach/lm-sensors

This commit is contained in:
Michal Suchanek committed 2023-12-24 12:28:52 +01:00
commit c91425c121
3 files changed
+40

No files matched your search

+2
View File
@@ -150,6 +150,7 @@ typedef enum sensors_feature_type {
SENSORS_FEATURE_INTRUSION = 0x11,
SENSORS_FEATURE_MAX_OTHER,
SENSORS_FEATURE_BEEP_ENABLE = 0x18,
SENSORS_FEATURE_FREQ,
SENSORS_FEATURE_MAX,
SENSORS_FEATURE_UNKNOWN = INT_MAX,
} sensors_feature_type;
@@ -264,6 +265,7 @@ typedef enum sensors_subfeature_type {
SENSORS_SUBFEATURE_BEEP_ENABLE = SENSORS_FEATURE_BEEP_ENABLE << 8,
SENSORS_SUBFEATURE_FREQ_INPUT = SENSORS_FEATURE_FREQ << 8,
SENSORS_SUBFEATURE_UNKNOWN = INT_MAX,
} sensors_subfeature_type;
+8
View File
@@ -153,6 +153,7 @@ int get_type_scaling(sensors_subfeature_type type)
return 1;
case SENSORS_SUBFEATURE_POWER_AVERAGE:
case SENSORS_SUBFEATURE_ENERGY_INPUT:
case SENSORS_SUBFEATURE_FREQ_INPUT:
return 1000000;
}
@@ -182,6 +183,7 @@ char *get_feature_name(sensors_feature_type ftype, char *sfname)
case SENSORS_FEATURE_CURR:
case SENSORS_FEATURE_HUMIDITY:
case SENSORS_FEATURE_INTRUSION:
case SENSORS_FEATURE_FREQ:
underscore = strchr(sfname, '_');
name = strndup(sfname, underscore - sfname);
if (!name)
@@ -350,6 +352,11 @@ static const struct subfeature_type_match intrusion_matches[] = {
{ "beep", SENSORS_SUBFEATURE_INTRUSION_BEEP },
{ NULL, 0 }
};
static const struct subfeature_type_match freq_matches[] = {
{ "input", SENSORS_SUBFEATURE_FREQ_INPUT },
{ NULL, 0 }
};
static struct feature_type_match matches[] = {
{ "temp%d%c", temp_matches },
{ "in%d%c", in_matches },
@@ -360,6 +367,7 @@ static struct feature_type_match matches[] = {
{ "energy%d%c", energy_matches },
{ "intrusion%d%c", intrusion_matches },
{ "humidity%d%c", humidity_matches },
{ "freq%d%c", freq_matches },
{ "pwm%d%c", pwm_matches },
};
+30
View File
@@ -898,6 +898,33 @@ static void print_chip_curr(const sensors_chip_name *name,
printf("\n");
}
static void print_chip_freq(const sensors_chip_name *name,
const sensors_feature *feature,
int label_size)
{
const sensors_subfeature *sf;
double val;
char *label;
if (!(label = sensors_get_label(name, feature))) {
fprintf(stderr, "ERROR: Can't get label of feature %s!\n",
feature->name);
return;
}
print_label(label, label_size);
free(label);
sf = sensors_get_subfeature(name, feature,
SENSORS_SUBFEATURE_FREQ_INPUT);
if (sf && get_input_value(name, sf, &val) == 0) {
printf("%4.0f %s", val, "MHz");
} else {
printf(" N/A ");
}
printf("\n");
}
static void print_chip_intrusion(const sensors_chip_name *name,
const sensors_feature *feature,
int label_size)
@@ -959,6 +986,9 @@ void print_chip(const sensors_chip_name *name)
case SENSORS_FEATURE_HUMIDITY:
print_chip_humidity(name, feature, label_size);
break;
case SENSORS_FEATURE_FREQ:
print_chip_freq(name, feature, label_size);
break;
case SENSORS_FEATURE_PWM:
print_chip_pwm(name, feature, label_size);
break;