gallium/hud: fix power sensor readings for amdgpu users
authorAndre Heider <a.heider@gmail.com>
Sat, 27 Oct 2018 07:45:37 +0000 (09:45 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 30 Oct 2018 20:30:32 +0000 (16:30 -0400)
amdgpu doesn't use the INPUT but the AVERAGE subfeature:

$ sensors -u
amdgpu-pci-0100
Adapter: PCI adapter
power1:
  power1_average: 17.233
  power1_cap: 180.000

Signed-off-by: Andre Heider <a.heider@gmail.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/hud/hud_sensors_temp.c

index c26e7b9b2a70d8304090168987e4b458ca34b314..c226e89cc42f607f5e70e12629020524e108bb24 100644 (file)
@@ -122,6 +122,9 @@ get_sensor_values(struct sensors_temp_info *sti)
    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 */