*
**************************************************************************/
-#if HAVE_LIBSENSORS
+#ifdef HAVE_LIBSENSORS
/* Purpose: Extract lm-sensors data, expose temperature, power, voltage. */
#include "hud/hud_private.h"
#include "util/list.h"
-#include "os/os_time.h"
+#include "util/os_time.h"
#include "os/os_thread.h"
#include "util/u_memory.h"
#include <stdio.h>
*/
static int gsensors_temp_count = 0;
static struct list_head gsensors_temp_list;
-pipe_static_mutex(gsensor_temp_mutex);
+static mtx_t gsensor_temp_mutex = _MTX_INITIALIZER_NP;
struct sensors_temp_info
{
case SENSORS_POWER_CURRENT:
sf = sensors_get_subfeature(sti->chip, sti->feature,
SENSORS_SUBFEATURE_POWER_INPUT);
+ if (!sf)
+ sf = sensors_get_subfeature(sti->chip, sti->feature,
+ SENSORS_SUBFEATURE_POWER_AVERAGE);
if (sf) {
/* Sensors API returns in WATTs, even though driver is reporting mW,
* convert back to mW */
}
static void
-query_sti_load(struct hud_graph *gr)
+query_sti_load(struct hud_graph *gr, struct pipe_context *pipe)
{
struct sensors_temp_info *sti = gr->query_data;
uint64_t now = os_time_get();
switch (sti->mode) {
case SENSORS_TEMP_CURRENT:
- hud_graph_add_value(gr, (uint64_t) sti->current);
+ hud_graph_add_value(gr, sti->current);
break;
case SENSORS_TEMP_CRITICAL:
- hud_graph_add_value(gr, (uint64_t) sti->critical);
+ hud_graph_add_value(gr, sti->critical);
break;
case SENSORS_VOLTAGE_CURRENT:
- hud_graph_add_value(gr, (uint64_t)(sti->current * 1000));
+ hud_graph_add_value(gr, sti->current * 1000);
break;
case SENSORS_CURRENT_CURRENT:
- hud_graph_add_value(gr, (uint64_t) sti->current);
+ hud_graph_add_value(gr, sti->current);
break;
case SENSORS_POWER_CURRENT:
- hud_graph_add_value(gr, (uint64_t) sti->current);
+ hud_graph_add_value(gr, sti->current);
break;
}
hud_get_num_sensors(bool displayhelp)
{
/* Return the number of sensors detected. */
- pipe_mutex_lock(gsensor_temp_mutex);
+ mtx_lock(&gsensor_temp_mutex);
if (gsensors_temp_count) {
- pipe_mutex_unlock(gsensor_temp_mutex);
+ mtx_unlock(&gsensor_temp_mutex);
return gsensors_temp_count;
}
int ret = sensors_init(NULL);
if (ret) {
- pipe_mutex_unlock(gsensor_temp_mutex);
+ mtx_unlock(&gsensor_temp_mutex);
return 0;
}
}
}
- pipe_mutex_unlock(gsensor_temp_mutex);
+ mtx_unlock(&gsensor_temp_mutex);
return gsensors_temp_count;
}