diff --git a/gkrellm/src/sysdeps/linux.c b/gkrellm/src/sysdeps/linux.c index 5a15250..ebe2905 100644 --- a/gkrellm/src/sysdeps/linux.c +++ b/gkrellm/src/sysdeps/linux.c @@ -2292,6 +2292,7 @@ gkrellm_sys_uptime_init(void) #define IBM_ACPI_INTERFACE 6 #define UNINORTH_INTERFACE 7 #define WINDFARM_INTERFACE 8 +#define ATICONFIG_INTERFACE 9 #define IBM_ACPI_FAN_FILE "/proc/acpi/ibm/fan" #define IBM_ACPI_THERMAL "/proc/acpi/ibm/thermal" @@ -3092,6 +3093,36 @@ gkrellm_sys_sensors_get_temperature(gchar *sensor_path, gint id, return FALSE; } + if (interface == ATICONFIG_INTERFACE) + { +#if GLIB_CHECK_VERSION(2,0,0) + gchar *args[] = { "aticonfig", "--odgt", "--adapter", sensor_path, NULL }; + gchar *output = NULL; + gchar *s = NULL; + + result = g_spawn_sync(NULL, args, NULL, + G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, + NULL, NULL, &output, NULL, NULL, NULL); + + if(result && output) + { + gfloat dummy; + + if(!temp) + temp = &dummy; + s = strstr(output, "Sensor"); + if (s) + result = (sscanf(s,"Sensor %*s Temperature - %f", temp) == 1); + else + result = FALSE; + } + + g_free(output); + return result; +#else + return FALSE; +#endif + } #ifdef HAVE_LIBSENSORS if (interface == LIBSENSORS_INTERFACE) return libsensors_get_value(sensor_path, id, iodev, temp); @@ -3525,6 +3556,28 @@ sensors_nvclock_ngpus(void) return n; } +static gint +sensors_aticonfig_ngpus(void) + { + gint n = 0, s = 0; +#if GLIB_CHECK_VERSION(2,0,0) + gchar *args[] = { "aticonfig", "--list-adapters", NULL }; + gchar *output = NULL; + gboolean result; + + result = g_spawn_sync(NULL, args, NULL, + G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, + NULL, NULL, &output, NULL, NULL, NULL); + + if(result && output) + n = sscanf(output, "* %d.", &s); + g_free(output); +#endif + if (_GK.debug_level & DEBUG_SENSORS) + printf("aticonfig gpus = %d\n", n); + return n; + } + static void sensors_nvclock_init(gboolean enable) { @@ -3698,7 +3751,7 @@ gkrellm_sys_sensors_init(void) fclose(f); } - /* nvidia-settings GPU core & ambient temperatues + /* nvidia-settings/aticonfig GPU core & ambient temperatures */ cnt = sensors_nvidia_settings_ngpus(); ngpus_added = 0; @@ -3744,7 +3797,6 @@ gkrellm_sys_sensors_init(void) gkrellm_sensors_sysdep_option("use_nvclock", _("Use nvclock for NVIDIA GPU temperatures"), sensors_nvclock_init); - id = 0; /* Try for ambient only for gpu:0 for now */ if (gkrellm_sys_sensors_get_temperature("GPUAmbientTemp", id, 0, @@ -3756,6 +3808,43 @@ gkrellm_sys_sensors_init(void) 1.0, 0.0, NULL, "GPU A"); } + /* aticonfig temperature display - + | it's very simular to nvidia case + */ + cnt = sensors_aticonfig_ngpus(); + ngpus_added = 0; + if (cnt < 2) + { + if (gkrellm_sys_sensors_get_temperature("0", id, 0, + ATICONFIG_INTERFACE, NULL)) + { + gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE, + "0", "ATI/AMD GPU Core", + id, 0, ATICONFIG_INTERFACE, + 1.0, 0.0, NULL, "GPU C"); + ++ngpus_added; + } + } + else + { + for (id = 0; id < cnt; ++id) + { + sensor_path = g_strdup_printf("%d", id); + if (gkrellm_sys_sensors_get_temperature(sensor_path, id, 0, + ATICONFIG_INTERFACE, NULL)) + { + snprintf(id_name, sizeof(id_name), "ATI/AMD GPU:%d Core", id); + default_label = g_strdup_printf("GPU:%d", id); + gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE, + sensor_path, id_name, + id, 0, ATICONFIG_INTERFACE, + 1.0, 0.0, NULL, default_label); + g_free(default_label); + ++ngpus_added; + } + g_free(sensor_path); + } + } /* UNINORTH sensors */