[haiku-commits] haiku: hrev43345 - in src/add-ons: kernel/drivers/graphics/radeon_hd accelerants/radeon_hd

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 27 Nov 2011 21:42:19 +0100 (CET)

hrev43345 adds 1 changeset to branch 'master'
old head: 8e844f63e9c2baad1459b9dfb3103420caf9cb1a
new head: 30207c6c8c18cafcc5451a7d5e4cb9c6b7c2c4e2

----------------------------------------------------------------------------

7 files changed, 115 insertions(+), 76 deletions(-)
src/add-ons/accelerants/radeon_hd/accelerant.cpp   |    3 -
src/add-ons/accelerants/radeon_hd/gpu.cpp          |   72 -------------
src/add-ons/accelerants/radeon_hd/gpu.h            |    1 -
.../kernel/drivers/graphics/radeon_hd/Jamfile      |    1 +
.../drivers/graphics/radeon_hd/radeon_hd.cpp       |    5 +
.../kernel/drivers/graphics/radeon_hd/sensors.cpp  |   89 ++++++++++++++++
.../kernel/drivers/graphics/radeon_hd/sensors.h    |   20 ++++

############################################################################

Revision:    hrev43345
Commit:      30207c6c8c18cafcc5451a7d5e4cb9c6b7c2c4e2
URL:         http://cgit.haiku-os.org/haiku/commit/?id=30207c6
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Sun Nov 27 20:40:40 2011 UTC

Move thermal query into new driver sensor source file

* thermal query still works pre-atombios init

----------------------------------------------------------------------------

diff --git a/src/add-ons/accelerants/radeon_hd/accelerant.cpp 
b/src/add-ons/accelerants/radeon_hd/accelerant.cpp
index 0c75b3c..94d50f3 100644
--- a/src/add-ons/accelerants/radeon_hd/accelerant.cpp
+++ b/src/add-ons/accelerants/radeon_hd/accelerant.cpp
@@ -287,9 +287,6 @@ radeon_init_accelerant(int device)
 
        radeon_gpu_mc_setup();
 
-       TRACE("%s: Current GPU temperature: %" B_PRId32 " mC\n",
-               __func__, radeon_get_temp());
-
        TRACE("%s done\n", __func__);
        return B_OK;
 }
diff --git a/src/add-ons/accelerants/radeon_hd/gpu.cpp 
b/src/add-ons/accelerants/radeon_hd/gpu.cpp
index 9b98a2f..12e80aa 100644
--- a/src/add-ons/accelerants/radeon_hd/gpu.cpp
+++ b/src/add-ons/accelerants/radeon_hd/gpu.cpp
@@ -851,75 +851,3 @@ radeon_gpu_gpio_setup()
 
        return B_OK;
 }
-
-
-int32
-radeon_get_temp()
-{
-       // return GPU temp in millidegrees C
-
-       radeon_shared_info &info = *gInfo->shared_info;
-
-       uint32 rawTemp = 0;
-       int32 finalTemp = 0;
-
-       if (info.chipsetID == RADEON_JUNIPER) {
-               uint32 offset = (Read32(OUT, EVERGREEN_CG_THERMAL_CTRL)
-                       & EVERGREEN_TOFFSET_MASK) >> EVERGREEN_TOFFSET_SHIFT;
-               rawTemp = (Read32(OUT, EVERGREEN_CG_TS0_STATUS)
-                       & EVERGREEN_TS0_ADC_DOUT_MASK) >> 
EVERGREEN_TS0_ADC_DOUT_SHIFT;
-
-               if (offset & 0x100)
-                       finalTemp = rawTemp / 2 - (0x200 - offset);
-               else
-                       finalTemp = rawTemp / 2 + offset;
-
-               return finalTemp * 1000;
-       } else if (info.chipsetID == RADEON_SUMO
-               || info.chipsetID == RADEON_SUMO2) {
-               uint32 rawTemp = Read32(OUT, EVERGREEN_CG_THERMAL_STATUS) & 
0xff;
-               finalTemp = rawTemp - 49;
-
-               return finalTemp * 1000;
-       } else if (info.chipsetID >= RADEON_CEDAR) {
-               rawTemp = (Read32(OUT, EVERGREEN_CG_MULT_THERMAL_STATUS)
-                       & EVERGREEN_ASIC_T_MASK) >> EVERGREEN_ASIC_T_SHIFT;
-
-               if (rawTemp & 0x400)
-                       finalTemp = -256;
-               else if (rawTemp & 0x200)
-                       finalTemp = 255;
-               else if (rawTemp & 0x100) {
-                       finalTemp = rawTemp & 0x1ff;
-                       finalTemp |= ~0x1ff;
-               } else
-                       finalTemp = rawTemp & 0xff;
-
-               return (finalTemp * 1000) / 2;
-       } else if (info.chipsetID >= RADEON_RV770) {
-               rawTemp = (Read32(OUT, R700_CG_MULT_THERMAL_STATUS) & 
R700_ASIC_T_MASK)
-                       >> R700_ASIC_T_SHIFT;
-               if (rawTemp & 0x400)
-                       finalTemp = -256;
-               else if (rawTemp & 0x200)
-                       finalTemp = 255;
-               else if (rawTemp & 0x100) {
-                       finalTemp = rawTemp & 0x1ff;
-                       finalTemp |= ~0x1ff;
-               } else
-                       finalTemp = rawTemp & 0xff;
-
-               return (finalTemp * 1000) / 2;
-       } else if (info.chipsetID >= RADEON_R600) {
-               rawTemp = (Read32(OUT, R600_CG_THERMAL_STATUS) & 
R600_ASIC_T_MASK)
-                       >> R600_ASIC_T_SHIFT;
-               finalTemp = rawTemp & 0xff;
-
-               if (rawTemp & 0x100)
-                       finalTemp -= 256;
-
-               return finalTemp * 1000;
-       }
-
-       return -1;
-}
diff --git a/src/add-ons/accelerants/radeon_hd/gpu.h 
b/src/add-ons/accelerants/radeon_hd/gpu.h
index ac42211..66940b3 100644
--- a/src/add-ons/accelerants/radeon_hd/gpu.h
+++ b/src/add-ons/accelerants/radeon_hd/gpu.h
@@ -179,7 +179,6 @@ status_t radeon_gpu_irq_setup();
 status_t radeon_gpu_gpio_setup();
 status_t radeon_gpu_i2c_attach(uint32 id, uint8 hw_line);
 bool radeon_gpu_read_edid(uint32 connector, edid1_info *edid);
-int32 radeon_get_temp();
 
 
 #endif
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/Jamfile 
b/src/add-ons/kernel/drivers/graphics/radeon_hd/Jamfile
index d2a9068..ff5cf5f 100644
--- a/src/add-ons/kernel/drivers/graphics/radeon_hd/Jamfile
+++ b/src/add-ons/kernel/drivers/graphics/radeon_hd/Jamfile
@@ -12,6 +12,7 @@ KernelAddon radeon_hd :
        driver.cpp
        device.cpp
        radeon_hd.cpp
+       sensors.cpp
        : libgraphicscommon.a
 ;
 
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp 
b/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp
index 3565813..08d5821 100644
--- a/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp
+++ b/src/add-ons/kernel/drivers/graphics/radeon_hd/radeon_hd.cpp
@@ -11,6 +11,7 @@
 
 
 #include "radeon_hd.h"
+#include "sensors.h"
 
 #include "AreaKeeper.h"
 #include "driver.h"
@@ -764,6 +765,10 @@ radeon_hd_init(radeon_info &info)
        }
 
        TRACE("card(%ld): %s completed successfully!\n", info.id, __func__);
+
+       TRACE("card(%ld): GPU thermal status: %" B_PRId32 "C\n", info.id,
+               radeon_thermal_query(info) / 1000);
+
        return B_OK;
 }
 
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.cpp 
b/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.cpp
new file mode 100644
index 0000000..467c527
--- /dev/null
+++ b/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011-2012 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Alexander von Gluck IV, kallisti5@xxxxxxxxxxx
+ */
+
+
+#include "sensors.h"
+
+
+#define TRACE_DRIVER
+#ifdef TRACE_DRIVER
+#      define TRACE(x...) dprintf("radeon_hd: " x)
+#else
+#      define TRACE(x...) ;
+#endif
+
+
+int32
+radeon_thermal_query(radeon_info &info)
+{
+       // return GPU temp in millidegrees C
+
+       uint32 rawTemp = 0;
+       int32 finalTemp = 0;
+
+       if (info.chipsetID == RADEON_JUNIPER) {
+               uint32 offset = (read32(info.registers + 
EVERGREEN_CG_THERMAL_CTRL)
+                       & EVERGREEN_TOFFSET_MASK) >> EVERGREEN_TOFFSET_SHIFT;
+               rawTemp = (read32(info.registers + EVERGREEN_CG_TS0_STATUS)
+                       & EVERGREEN_TS0_ADC_DOUT_MASK) >> 
EVERGREEN_TS0_ADC_DOUT_SHIFT;
+
+               if (offset & 0x100)
+                       finalTemp = rawTemp / 2 - (0x200 - offset);
+               else
+                       finalTemp = rawTemp / 2 + offset;
+
+               return finalTemp * 1000;
+       } else if (info.chipsetID == RADEON_SUMO
+               || info.chipsetID == RADEON_SUMO2) {
+               uint32 rawTemp = read32(info.registers + 
EVERGREEN_CG_THERMAL_STATUS)
+                       & 0xff;
+               finalTemp = rawTemp - 49;
+
+               return finalTemp * 1000;
+       } else if (info.chipsetID >= RADEON_CEDAR) {
+               rawTemp = (read32(info.registers + 
EVERGREEN_CG_MULT_THERMAL_STATUS)
+                       & EVERGREEN_ASIC_T_MASK) >> EVERGREEN_ASIC_T_SHIFT;
+
+               if (rawTemp & 0x400)
+                       finalTemp = -256;
+               else if (rawTemp & 0x200)
+                       finalTemp = 255;
+               else if (rawTemp & 0x100) {
+                       finalTemp = rawTemp & 0x1ff;
+                       finalTemp |= ~0x1ff;
+               } else
+                       finalTemp = rawTemp & 0xff;
+
+               return (finalTemp * 1000) / 2;
+       } else if (info.chipsetID >= RADEON_RV770) {
+               rawTemp = (read32(info.registers + R700_CG_MULT_THERMAL_STATUS)
+                       & R700_ASIC_T_MASK) >> R700_ASIC_T_SHIFT;
+               if (rawTemp & 0x400)
+                       finalTemp = -256;
+               else if (rawTemp & 0x200)
+                       finalTemp = 255;
+               else if (rawTemp & 0x100) {
+                       finalTemp = rawTemp & 0x1ff;
+                       finalTemp |= ~0x1ff;
+               } else
+                       finalTemp = rawTemp & 0xff;
+
+               return (finalTemp * 1000) / 2;
+       } else if (info.chipsetID >= RADEON_R600) {
+               rawTemp = (read32(info.registers + R600_CG_THERMAL_STATUS)
+                       & R600_ASIC_T_MASK) >> R600_ASIC_T_SHIFT;
+               finalTemp = rawTemp & 0xff;
+
+               if (rawTemp & 0x100)
+                       finalTemp -= 256;
+
+               return finalTemp * 1000;
+       }
+
+       return -1;
+}
diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.h 
b/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.h
new file mode 100644
index 0000000..6013f49
--- /dev/null
+++ b/src/add-ons/kernel/drivers/graphics/radeon_hd/sensors.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2011-2012 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Alexander von Gluck IV, kallisti5@xxxxxxxxxxx
+ */
+#ifndef SENSORS_H
+#define SENSORS_H
+
+
+#include "driver.h"
+#include "device.h"
+#include "radeon_hd.h"
+
+
+int32 radeon_thermal_query(radeon_info &info);
+
+
+#endif /* SENSORS_H */


Other related posts:

  • » [haiku-commits] haiku: hrev43345 - in src/add-ons: kernel/drivers/graphics/radeon_hd accelerants/radeon_hd - kallisti5