BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / drivers / graphics / radeon_hd / sensors.cpp
blob607b1cc76a5f08ca0b198b0466e3b18b2eb809c3
1 /*
2 * Copyright 2011-2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Alexander von Gluck IV, kallisti5@unixzen.com
7 */
10 #include "sensors.h"
13 #define TRACE_DRIVER
14 #ifdef TRACE_DRIVER
15 # define TRACE(x...) dprintf("radeon_hd: " x)
16 #else
17 # define TRACE(x...) ;
18 #endif
21 int32
22 radeon_thermal_query(radeon_info &info)
24 // return GPU temp in millidegrees C
26 uint32 rawTemp = 0;
27 int32 finalTemp = 0;
29 if (info.chipsetID >= RADEON_CAPEVERDE) {
30 rawTemp = (read32(info.registers + SI_CG_MULT_THERMAL_STATUS)
31 & SI_CTF_TEMP_MASK) >> SI_CTF_TEMP_SHIFT;
33 if (rawTemp & 0x200)
34 finalTemp = 255;
35 else
36 finalTemp = rawTemp & 0x1ff;
38 return finalTemp * 1000;
39 } else if (info.chipsetID == RADEON_JUNIPER) {
40 uint32 offset = (read32(info.registers + EVERGREEN_CG_THERMAL_CTRL)
41 & EVERGREEN_TOFFSET_MASK) >> EVERGREEN_TOFFSET_SHIFT;
42 rawTemp = (read32(info.registers + EVERGREEN_CG_TS0_STATUS)
43 & EVERGREEN_TS0_ADC_DOUT_MASK) >> EVERGREEN_TS0_ADC_DOUT_SHIFT;
45 if (offset & 0x100)
46 finalTemp = rawTemp / 2 - (0x200 - offset);
47 else
48 finalTemp = rawTemp / 2 + offset;
50 return finalTemp * 1000;
51 } else if (info.chipsetID == RADEON_SUMO
52 || info.chipsetID == RADEON_SUMO2) {
53 uint32 rawTemp = read32(info.registers + EVERGREEN_CG_THERMAL_STATUS)
54 & 0xff;
55 finalTemp = rawTemp - 49;
57 return finalTemp * 1000;
58 } else if (info.chipsetID >= RADEON_CEDAR) {
59 rawTemp = (read32(info.registers + EVERGREEN_CG_MULT_THERMAL_STATUS)
60 & EVERGREEN_ASIC_T_MASK) >> EVERGREEN_ASIC_T_SHIFT;
62 if (rawTemp & 0x400)
63 finalTemp = -256;
64 else if (rawTemp & 0x200)
65 finalTemp = 255;
66 else if (rawTemp & 0x100) {
67 finalTemp = rawTemp & 0x1ff;
68 finalTemp |= ~0x1ff;
69 } else
70 finalTemp = rawTemp & 0xff;
72 return (finalTemp * 1000) / 2;
73 } else if (info.chipsetID >= RADEON_RV770) {
74 rawTemp = (read32(info.registers + R700_CG_MULT_THERMAL_STATUS)
75 & R700_ASIC_T_MASK) >> R700_ASIC_T_SHIFT;
76 if (rawTemp & 0x400)
77 finalTemp = -256;
78 else if (rawTemp & 0x200)
79 finalTemp = 255;
80 else if (rawTemp & 0x100) {
81 finalTemp = rawTemp & 0x1ff;
82 finalTemp |= ~0x1ff;
83 } else
84 finalTemp = rawTemp & 0xff;
86 return (finalTemp * 1000) / 2;
87 } else if (info.chipsetID >= RADEON_R600) {
88 rawTemp = (read32(info.registers + R600_CG_THERMAL_STATUS)
89 & R600_ASIC_T_MASK) >> R600_ASIC_T_SHIFT;
90 finalTemp = rawTemp & 0xff;
92 if (rawTemp & 0x100)
93 finalTemp -= 256;
95 return finalTemp * 1000;
98 return -1;