summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp38
1 files changed, 14 insertions, 24 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 2d2f7db..d8415ad 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -178,75 +178,65 @@ void ODevice::init ( )
178 178
179ODevice::~ODevice ( ) 179ODevice::~ODevice ( )
180{ 180{
181 delete d; 181 delete d;
182} 182}
183 183
184bool ODevice::setSoftSuspend ( bool /*soft*/ ) 184bool ODevice::setSoftSuspend ( bool /*soft*/ )
185{ 185{
186 return false; 186 return false;
187} 187}
188 188
189//#include <linux/apm_bios.h> 189//#include <linux/apm_bios.h>
190 190
191#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 191#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
192 192
193 193
194bool ODevice::suspend ( ) 194bool ODevice::suspend ( )
195{ 195{
196 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 196 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
197 return false; 197 return false;
198 198
199 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 199 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
200 return false; 200 return false;
201 201
202 int fd;
203 bool res = false; 202 bool res = false;
204 203
205 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 204 struct timeval tvs, tvn;
206 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 205 ::gettimeofday ( &tvs, 0 );
207 struct timeval tvs, tvn;
208
209 // ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped
210 ::gettimeofday ( &tvs, 0 );
211 206
212 ::sync ( ); // flush fs caches 207 ::sync ( ); // flush fs caches
213 208 res = ( ::system ( "apm --suspend" ) == 0 );
214 res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending 209
215 ::close ( fd ); 210 // This is needed because the iPAQ apm implementation is asynchronous and we
216 211 // can not be sure when exactly the device is really suspended
217 if ( res ) { 212 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
218 // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group 213
219 214 if ( res ) {
220 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 215 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
221 ::usleep ( 200 * 1000 ); 216 ::usleep ( 200 * 1000 );
222 ::gettimeofday ( &tvn, 0 ); 217 ::gettimeofday ( &tvn, 0 );
223 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 218 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
224
225 // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group
226 }
227
228 // ::signal ( SIGTSTP, SIG_DFL );
229 } 219 }
230 220
231 return res; 221 return res;
232} 222}
233 223
234//#include <linux/fb.h> better not rely on kernel headers in userspace ... 224//#include <linux/fb.h> better not rely on kernel headers in userspace ...
235 225
236#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 226#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
237 227
238/* VESA Blanking Levels */ 228/* VESA Blanking Levels */
239#define VESA_NO_BLANKING 0 229#define VESA_NO_BLANKING 0
240#define VESA_VSYNC_SUSPEND 1 230#define VESA_VSYNC_SUSPEND 1
241#define VESA_HSYNC_SUSPEND 2 231#define VESA_HSYNC_SUSPEND 2
242#define VESA_POWERDOWN 3 232#define VESA_POWERDOWN 3
243 233
244 234
245bool ODevice::setDisplayStatus ( bool on ) 235bool ODevice::setDisplayStatus ( bool on )
246{ 236{
247 if ( d-> m_model == Model_Unknown ) 237 if ( d-> m_model == Model_Unknown )
248 return false; 238 return false;
249 239
250 bool res = false; 240 bool res = false;
251 int fd; 241 int fd;
252 242