summaryrefslogtreecommitdiff
blob: 79e2f16767eb94e7a9ca4a01f87d2c444bcef711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
--- ksensors-0.7.3.orig/src/i8ksensorslist.cpp	2003-10-27 06:44:40.000000000 +0800
+++ ksensors-0.7.3/src/i8ksensorslist.cpp	2005-12-25 11:48:51.000000000 +0800
@@ -65,7 +65,70 @@
 	rightFan->readConfig();
   }
 
-  if ( (acpiAvail=(AcpiAvailable()==0)) )
+  if (ibmAcpiAvail=(IbmAcpiAvailable()==0))
+  {
+	cpuTempAcpiIbm= new Sensor(this);
+	cpuTempAcpiIbm->setType(Sensor::lmTemp);
+	cpuTempAcpiIbm->setName("cputemp");
+	cpuTempAcpiIbm->setDescription("CPU Temp");
+	cpuTempAcpiIbm->setValueMax  (80 , Sensor::dgCelsius);
+	cpuTempAcpiIbm->setValueMin  ( 0 , Sensor::dgCelsius);
+	cpuTempAcpiIbm->setValueIdeal(30 , Sensor::dgCelsius);
+	cpuTempAcpiIbm->setValue     ( 0 , Sensor::dgCelsius);
+	cpuTempAcpiIbm->readConfig();
+
+	pciTempAcpiIbm= new Sensor(this);
+	pciTempAcpiIbm->setType(Sensor::lmTemp);
+	pciTempAcpiIbm->setName("pictmp");
+	pciTempAcpiIbm->setDescription("Mini PCI Temp");
+	pciTempAcpiIbm->setValueMax  (55 , Sensor::dgCelsius);
+	pciTempAcpiIbm->setValueMin  ( 0 , Sensor::dgCelsius);
+	pciTempAcpiIbm->setValueIdeal(25 , Sensor::dgCelsius);
+	pciTempAcpiIbm->setValue     ( 0 , Sensor::dgCelsius);
+	pciTempAcpiIbm->readConfig();
+
+	hddTempAcpiIbm= new Sensor(this);
+	hddTempAcpiIbm->setType(Sensor::lmTemp);
+	hddTempAcpiIbm->setName("hddtmp");
+	hddTempAcpiIbm->setDescription("HDD Temp");
+	hddTempAcpiIbm->setValueMax  (40 , Sensor::dgCelsius);
+	hddTempAcpiIbm->setValueMin  ( 0 , Sensor::dgCelsius);
+	hddTempAcpiIbm->setValueIdeal(20 , Sensor::dgCelsius);
+	hddTempAcpiIbm->setValue     ( 0 , Sensor::dgCelsius);
+	hddTempAcpiIbm->readConfig();
+
+	gpuTempAcpiIbm= new Sensor(this);
+	gpuTempAcpiIbm->setType(Sensor::lmTemp);
+	gpuTempAcpiIbm->setName("gputmp");
+	gpuTempAcpiIbm->setDescription("GPU Temp");
+	gpuTempAcpiIbm->setValueMax  (60 , Sensor::dgCelsius);
+	gpuTempAcpiIbm->setValueMin  ( 0 , Sensor::dgCelsius);
+	gpuTempAcpiIbm->setValueIdeal(25 , Sensor::dgCelsius);
+	gpuTempAcpiIbm->setValue     ( 0 , Sensor::dgCelsius);
+	gpuTempAcpiIbm->readConfig();
+
+	bat0TempAcpiIbm= new Sensor(this);
+	bat0TempAcpiIbm->setType(Sensor::lmTemp);
+	bat0TempAcpiIbm->setName("bat0tmp");
+	bat0TempAcpiIbm->setDescription("BAT0 Temp");
+	bat0TempAcpiIbm->setValueMax  (40 , Sensor::dgCelsius);
+	bat0TempAcpiIbm->setValueMin  ( 0 , Sensor::dgCelsius);
+	bat0TempAcpiIbm->setValueIdeal(30 , Sensor::dgCelsius);
+	bat0TempAcpiIbm->setValue     ( 0 , Sensor::dgCelsius);
+	bat0TempAcpiIbm->readConfig();
+
+	bat1TempAcpiIbm= new Sensor(this);
+	bat1TempAcpiIbm->setType(Sensor::lmTemp);
+	bat1TempAcpiIbm->setName("bat1tmp");
+	bat1TempAcpiIbm->setDescription("BAT1 Temp");
+	bat1TempAcpiIbm->setValueMax  (40 , Sensor::dgCelsius);
+	bat1TempAcpiIbm->setValueMin  ( 0 , Sensor::dgCelsius);
+	bat1TempAcpiIbm->setValueIdeal(30 , Sensor::dgCelsius);
+	bat1TempAcpiIbm->setValue     ( 0 , Sensor::dgCelsius);
+	bat1TempAcpiIbm->readConfig();
+  }
+
+  if ( (!ibmAcpiAvail) && (acpiAvail=(AcpiAvailable()==0)) )
   {
 	cpuTempAcpi= new Sensor(this);
 	cpuTempAcpi->setType(Sensor::lmTemp);
@@ -77,35 +140,51 @@
 	cpuTempAcpi->setValue     (30 , Sensor::dgCelsius);
 	cpuTempAcpi->readConfig();
   }
-
   updateSensors();
 }
 
 I8KSensorsList::~I8KSensorsList(){
 }
 
-
 void I8KSensorsList::updateSensors()
 {
-double t,f1,f2;
+double t,f1,f2, ct,pt,ht,gt,bt0,na0,bt1,na1;
 
   if(i8kAvail && !getI8KInfo(&t,&f1,&f2)) {
     cpuTemp->setValue(t,Sensor::dgCelsius);
     leftFan->setValue(f1);
     rightFan->setValue(f2);
   }
-  if(acpiAvail && !getAcpiTemperature(&t)) {
+
+  if(ibmAcpiAvail && !getIbmAcpiTemperature(&ct,&pt,&ht,&gt,&bt0,&na0,&bt1,&na1)) {
+    cpuTempAcpiIbm->setValue(ct,Sensor::dgCelsius);
+    pciTempAcpiIbm->setValue(pt,Sensor::dgCelsius);
+    hddTempAcpiIbm->setValue(ht,Sensor::dgCelsius);
+    gpuTempAcpiIbm->setValue(gt,Sensor::dgCelsius);
+    bat0TempAcpiIbm->setValue(bt0,Sensor::dgCelsius);
+    bat1TempAcpiIbm->setValue(bt1,Sensor::dgCelsius);
+  }
+
+  if(!ibmAcpiAvail && acpiAvail && !getAcpiTemperature(&t)) {
     cpuTempAcpi->setValue(t,Sensor::dgCelsius);
   }
-}
 
+}
 
 int I8KSensorsList::AcpiAvailable()
 {
  double t;
+
  return  getAcpiTemperature(&t);
 }
 
+int I8KSensorsList::IbmAcpiAvailable()
+{
+ double t0,t1,t2,t3,t4,t5,t6,t7;
+
+ return  getIbmAcpiTemperature(&t0,&t1,&t2,&t3,&t4,&t5,&t6,&t7);
+}
+
 int I8KSensorsList::I8KOnlyAvailable()
 {
 double d1,d2,d3;
@@ -122,7 +201,7 @@
   case -3: qWarning("I18K Warning: Only format version 1.0 is supported. Inform the author.");         break;
  }
 
- return (result==0 ||  AcpiAvailable()==0);
+ return (result==0 ||  AcpiAvailable()==0 ||  IbmAcpiAvailable()==0);
 }
 
 
--- ksensors-0.7.3.orig/src/i8ksensorslist.h	2003-10-27 06:29:33.000000000 +0800
+++ ksensors-0.7.3/src/i8ksensorslist.h	2005-12-25 10:30:14.000000000 +0800
@@ -42,13 +42,25 @@
 
   bool i8kAvail;
   bool acpiAvail;
+  bool ibmAcpiAvail;
 
   Sensor *cpuTempAcpi;
+
+  Sensor *cpuTempAcpiIbm;
+  Sensor *pciTempAcpiIbm;
+  Sensor *hddTempAcpiIbm;
+  Sensor *gpuTempAcpiIbm;
+  Sensor *bat0TempAcpiIbm;
+  Sensor *na0TempAcpiIbm;
+  Sensor *bat1TempAcpiIbm;
+  Sensor *na1TempAcpiIbm;
+
   Sensor *cpuTemp;
   Sensor *leftFan;
   Sensor *rightFan;
 
   static int AcpiAvailable();
+  static int IbmAcpiAvailable();
   static int I8KOnlyAvailable();
 };

--- ksensors-0.7.3.orig/src/procinfo.cpp	2003-10-27 06:45:41.000000000 +0800
+++ ksensors-0.7.3/src/procinfo.cpp	2005-12-25 12:31:12.000000000 +0800
@@ -84,7 +84,8 @@
 {
 char buf[128];
 
-    if(read_file("/proc/acpi/thermal_zone/THRM/temperature", buf, sizeof(buf))<= 0)  return -1;
+    if((read_file("/proc/acpi/thermal_zone/THRM/temperature", buf, sizeof(buf))<= 0) &&
+     (read_file("/proc/acpi/thermal_zone/THM0/temperature", buf, sizeof(buf))<= 0)) return -1;
 
     sscanf(buf, "temperature: %lf C", cpuTemp);
 
@@ -92,6 +93,23 @@
 }
 
 
+// ********* IBM Acpi *************************************
+// cat /proc/acpi/ibm/thermal (ibm_acpi module) if available
+// temperatures:   46 45 34 48 32 -128 29 -128
+
+int getIbmAcpiTemperature(double *cpuTemp, double *pciTemp, double *hddTemp, double *gpuTemp,
+  double *bat0Temp, double *na0Temp, double *bat1Temp, double *na1Temp)
+{
+char buf[128];
+
+    if(read_file("/proc/acpi/ibm/thermal", buf, sizeof(buf))<= 0) return -1;
+
+    sscanf(buf, "temperatures: %lf %lf %lf %lf %lf %lf %lf %lf", cpuTemp, pciTemp, hddTemp, gpuTemp,
+      bat0Temp, na0Temp, bat1Temp, na1Temp);
+
+    return 0;
+}
+
 int getMemInfo(int *RamTotal,int *RamUsed,int *SwapTotal, int *SwapUsed)
 {
 char buf[4096];
@@ -138,7 +156,7 @@
 
  if(read_file("/proc/stat", buf, sizeof(buf)) <= 0) return false;
 
- sscanf(buf, "cpu %u %u %u %u",user,nice,system,idle);
+ sscanf(buf, "cpu %d %d %d %d",user,nice,system,idle);
 
  return true;
 }

--- ksensors-0.7.3.orig/src/procinfo.h	2003-10-27 06:28:46.000000000 +0800
+++ ksensors-0.7.3/src/procinfo.h	2005-12-25 10:24:11.000000000 +0800
@@ -21,3 +21,5 @@
 int  getUpTime();
 int getI8KInfo(double *cpuTemp,  double *leftFan, double *rightFan);
 int getAcpiTemperature(double *cpuTemp);
+int getIbmAcpiTemperature(double *cpuTemp, double *pciTemp, double *hddTemp, double *gpuTemp,
+  double *bat0Temp, double *na0Temp, double *bat1Temp, double *na1Temp);