summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp8
1 files changed, 1 insertions, 7 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 6572fb6..1da8862 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -118,51 +118,45 @@ ODevice::ODevice ( )
118 118
119void ODevice::init ( ) 119void ODevice::init ( )
120{ 120{
121} 121}
122 122
123ODevice::~ODevice ( ) 123ODevice::~ODevice ( )
124{ 124{
125 delete d; 125 delete d;
126} 126}
127 127
128//#include <linux/apm_bios.h> 128//#include <linux/apm_bios.h>
129 129
130//#define APM_IOC_SUSPEND _IO('A',2) 130//#define APM_IOC_SUSPEND _IO('A',2)
131 131
132#define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) 132#define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 ))
133 133
134
135void ODevice::tstp_sighandler ( int )
136{
137}
138
139
140bool ODevice::suspend ( ) 134bool ODevice::suspend ( )
141{ 135{
142 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices 136 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices
143 return false; 137 return false;
144 138
145 int fd; 139 int fd;
146 bool res = false; 140 bool res = false;
147 141
148 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 142 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
149 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 143 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
150 struct timeval tvs, tvn; 144 struct timeval tvs, tvn;
151 145
152 ::signal ( SIGTSTP, tstp_sighandler );// we don't want to be stopped 146 ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped
153 ::gettimeofday ( &tvs, 0 ); 147 ::gettimeofday ( &tvs, 0 );
154 148
155 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending 149 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending
156 ::close ( fd ); 150 ::close ( fd );
157 151
158 if ( res ) { 152 if ( res ) {
159 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in out process group 153 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in out process group
160 154
161 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 155 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
162 ::usleep ( 200 * 1000 ); 156 ::usleep ( 200 * 1000 );
163 ::gettimeofday ( &tvn, 0 ); 157 ::gettimeofday ( &tvn, 0 );
164 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 158 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
165 159
166 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group 160 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group
167 } 161 }
168 162