author | mickeyl <mickeyl> | 2005-01-10 15:48:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-10 15:48:08 (UTC) |
commit | f7b2f19ecbe3ae9151c1f9dc238bcfd019b3fdbe (patch) (unidiff) | |
tree | 218e33596db2dcf280df67d7f07e91f969cd0b91 | |
parent | 6e3873eab783661c1d476106f588f2dab961dd21 (diff) | |
download | opie-f7b2f19ecbe3ae9151c1f9dc238bcfd019b3fdbe.zip opie-f7b2f19ecbe3ae9151c1f9dc238bcfd019b3fdbe.tar.gz opie-f7b2f19ecbe3ae9151c1f9dc238bcfd019b3fdbe.tar.bz2 |
first shot at OpenZaurus HAL introduced by 2.6.10
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 98 | ||||
-rw-r--r-- | libopie2/opiecore/opiecore.pro | 2 |
2 files changed, 65 insertions, 35 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 75a2fdc..269f6c9 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -115,498 +115,528 @@ struct z_button z_buttons_c700 [] = { | |||
115 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 115 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
116 | // | 116 | // |
117 | // Comments? - mickeyl. | 117 | // Comments? - mickeyl. |
118 | 118 | ||
119 | void Zaurus::init(const QString& cpu_info) | 119 | void Zaurus::init(const QString& cpu_info) |
120 | { | 120 | { |
121 | // generic distribution code already scanned /etc/issue at that point - | 121 | // generic distribution code already scanned /etc/issue at that point - |
122 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 122 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
123 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 123 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
124 | { | 124 | { |
125 | d->m_vendorstr = "Sharp"; | 125 | d->m_vendorstr = "Sharp"; |
126 | d->m_vendor = Vendor_Sharp; | 126 | d->m_vendor = Vendor_Sharp; |
127 | d->m_systemstr = "Zaurus"; | 127 | d->m_systemstr = "Zaurus"; |
128 | d->m_system = System_Zaurus; | 128 | d->m_system = System_Zaurus; |
129 | m_embedix = true; | 129 | m_embedix = true; |
130 | } | 130 | } |
131 | else | 131 | else |
132 | { | 132 | { |
133 | d->m_vendorstr = "OpenZaurus Team"; | 133 | d->m_vendorstr = "OpenZaurus Team"; |
134 | d->m_systemstr = "OpenZaurus"; | 134 | d->m_systemstr = "OpenZaurus"; |
135 | d->m_system = System_OpenZaurus; | 135 | d->m_system = System_OpenZaurus; |
136 | // sysver already gathered | 136 | // sysver already gathered |
137 | 137 | ||
138 | // OpenZaurus sometimes uses the embedix kernel, check if this is one | 138 | // OpenZaurus sometimes uses the embedix kernel, check if this is one |
139 | FILE *uname = popen("uname -r", "r"); | 139 | FILE *uname = popen("uname -r", "r"); |
140 | QFile f; | 140 | QFile f; |
141 | QString line; | 141 | QString line; |
142 | if ( f.open(IO_ReadOnly, uname) ) { | 142 | if ( f.open(IO_ReadOnly, uname) ) { |
143 | QTextStream ts ( &f ); | 143 | QTextStream ts ( &f ); |
144 | line = ts. readLine(); | 144 | line = ts. readLine(); |
145 | int loc = line. find ( "embedix" ); | 145 | int loc = line. find ( "embedix" ); |
146 | if ( loc != -1 ) | 146 | if ( loc != -1 ) |
147 | m_embedix = true; | 147 | m_embedix = true; |
148 | else | 148 | else |
149 | m_embedix = false; | 149 | m_embedix = false; |
150 | f.close(); | 150 | f.close(); |
151 | } | 151 | } |
152 | pclose(uname); | 152 | pclose(uname); |
153 | } | 153 | } |
154 | 154 | ||
155 | // check the Zaurus model | 155 | // check the Zaurus model |
156 | QString model; | 156 | QString model; |
157 | int loc = cpu_info.find( ":" ); | 157 | int loc = cpu_info.find( ":" ); |
158 | if ( loc != -1 ) | 158 | if ( loc != -1 ) |
159 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 159 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
160 | else | 160 | else |
161 | model = cpu_info; | 161 | model = cpu_info; |
162 | 162 | ||
163 | if ( model == "SHARP Corgi" ) { | 163 | if ( model == "SHARP Corgi" ) { |
164 | d->m_model = Model_Zaurus_SLC7x0; | 164 | d->m_model = Model_Zaurus_SLC7x0; |
165 | d->m_modelstr = "Zaurus SL-C700"; | 165 | d->m_modelstr = "Zaurus SL-C700"; |
166 | } else if ( model == "SHARP Shepherd" ) { | 166 | } else if ( model == "SHARP Shepherd" ) { |
167 | d->m_model = Model_Zaurus_SLC7x0; | 167 | d->m_model = Model_Zaurus_SLC7x0; |
168 | d->m_modelstr = "Zaurus SL-C750"; | 168 | d->m_modelstr = "Zaurus SL-C750"; |
169 | } else if ( model == "SHARP Husky" ) { | 169 | } else if ( model == "SHARP Husky" ) { |
170 | d->m_model = Model_Zaurus_SLC7x0; | 170 | d->m_model = Model_Zaurus_SLC7x0; |
171 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 171 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
172 | } else if ( model == "SHARP Boxer" ) { | 172 | } else if ( model == "SHARP Boxer" ) { |
173 | d->m_model = Model_Zaurus_SLC7x0; | 173 | d->m_model = Model_Zaurus_SLC7x0; |
174 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; | 174 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
175 | } else if ( model == "SHARP Poodle" ) { | 175 | } else if ( model == "SHARP Poodle" ) { |
176 | d->m_model = Model_Zaurus_SLB600; | 176 | d->m_model = Model_Zaurus_SLB600; |
177 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 177 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
178 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 178 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
179 | d->m_model = Model_Zaurus_SL5500; | 179 | d->m_model = Model_Zaurus_SL5500; |
180 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 180 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
181 | } else if ( model == "SHARP Tosa" ) { | 181 | } else if ( model == "SHARP Tosa" ) { |
182 | d->m_model = Model_Zaurus_SL6000; | 182 | d->m_model = Model_Zaurus_SL6000; |
183 | d->m_modelstr = "Zaurus SL-6000"; | 183 | d->m_modelstr = "Zaurus SL-6000"; |
184 | } else if ( model == "SHARP Spitz" ) { | 184 | } else if ( model == "SHARP Spitz" ) { |
185 | d->m_model = Model_Zaurus_SLC3000; | 185 | d->m_model = Model_Zaurus_SLC3000; |
186 | d->m_modelstr = "Zaurus SL-C3000"; | 186 | d->m_modelstr = "Zaurus SL-C3000"; |
187 | } else { | 187 | } else { |
188 | d->m_model = Model_Zaurus_SL5500; | 188 | d->m_model = Model_Zaurus_SL5500; |
189 | d->m_modelstr = "Unknown Zaurus"; | 189 | d->m_modelstr = "Unknown Zaurus"; |
190 | } | 190 | } |
191 | 191 | ||
192 | // set initial rotation | 192 | // set initial rotation |
193 | switch( d->m_model ) { | 193 | switch( d->m_model ) { |
194 | case Model_Zaurus_SL6000: // fallthrough | 194 | case Model_Zaurus_SL6000: // fallthrough |
195 | case Model_Zaurus_SLA300: | 195 | case Model_Zaurus_SLA300: |
196 | d->m_rotation = Rot0; | 196 | d->m_rotation = Rot0; |
197 | break; | 197 | break; |
198 | case Model_Zaurus_SLC3000: // fallthrough | 198 | case Model_Zaurus_SLC3000: // fallthrough |
199 | case Model_Zaurus_SLC7x0: | 199 | case Model_Zaurus_SLC7x0: |
200 | d->m_rotation = rotation(); | 200 | d->m_rotation = rotation(); |
201 | d->m_direction = direction(); | 201 | d->m_direction = direction(); |
202 | break; | 202 | break; |
203 | case Model_Zaurus_SLB600: // fallthrough | 203 | case Model_Zaurus_SLB600: // fallthrough |
204 | case Model_Zaurus_SL5000: // fallthrough | 204 | case Model_Zaurus_SL5000: // fallthrough |
205 | case Model_Zaurus_SL5500: // fallthrough | 205 | case Model_Zaurus_SL5500: // fallthrough |
206 | default: | 206 | default: |
207 | d->m_rotation = Rot270; | 207 | d->m_rotation = Rot270; |
208 | break; | 208 | break; |
209 | } | 209 | } |
210 | m_leds[0] = Led_Off; | 210 | m_leds[0] = Led_Off; |
211 | |||
212 | if ( m_embedix ) | ||
213 | qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); | ||
214 | else | ||
215 | qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); | ||
211 | } | 216 | } |
212 | 217 | ||
213 | void Zaurus::initButtons() | 218 | void Zaurus::initButtons() |
214 | { | 219 | { |
215 | if ( d->m_buttons ) | 220 | if ( d->m_buttons ) |
216 | return; | 221 | return; |
217 | 222 | ||
218 | d->m_buttons = new QValueList <ODeviceButton>; | 223 | d->m_buttons = new QValueList <ODeviceButton>; |
219 | 224 | ||
220 | struct z_button * pz_buttons; | 225 | struct z_button * pz_buttons; |
221 | int buttoncount; | 226 | int buttoncount; |
222 | switch ( d->m_model ) { | 227 | switch ( d->m_model ) { |
228 | case Model_Zaurus_SLC3000: // fallthrough | ||
223 | case Model_Zaurus_SLC7x0: | 229 | case Model_Zaurus_SLC7x0: |
224 | pz_buttons = z_buttons_c700; | 230 | pz_buttons = z_buttons_c700; |
225 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 231 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
226 | break; | 232 | break; |
227 | default: | 233 | default: |
228 | pz_buttons = z_buttons; | 234 | pz_buttons = z_buttons; |
229 | buttoncount = ARRAY_SIZE(z_buttons); | 235 | buttoncount = ARRAY_SIZE(z_buttons); |
230 | break; | 236 | break; |
231 | } | 237 | } |
232 | 238 | ||
233 | for ( int i = 0; i < buttoncount; i++ ) { | 239 | for ( int i = 0; i < buttoncount; i++ ) { |
234 | struct z_button *zb = pz_buttons + i; | 240 | struct z_button *zb = pz_buttons + i; |
235 | ODeviceButton b; | 241 | ODeviceButton b; |
236 | 242 | ||
237 | b. setKeycode ( zb->code ); | 243 | b.setKeycode( zb->code ); |
238 | b. setUserText ( QObject::tr ( "Button", zb->utext )); | 244 | b.setUserText( QObject::tr( "Button", zb->utext )); |
239 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); | 245 | b.setPixmap( Resource::loadPixmap( zb->pix )); |
240 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), | 246 | b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); |
241 | zb->fpressedaction )); | 247 | b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); |
242 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), | 248 | d->m_buttons->append( b ); |
243 | zb->fheldaction )); | ||
244 | |||
245 | d->m_buttons->append ( b ); | ||
246 | } | 249 | } |
247 | 250 | ||
248 | reloadButtonMapping(); | 251 | reloadButtonMapping(); |
249 | } | 252 | } |
250 | 253 | ||
251 | 254 | ||
252 | 255 | ||
253 | typedef struct sharp_led_status { | 256 | typedef struct sharp_led_status { |
254 | int which; /* select which LED status is wanted. */ | 257 | int which; /* select which LED status is wanted. */ |
255 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 258 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
256 | } sharp_led_status; | 259 | } sharp_led_status; |
257 | 260 | ||
258 | void Zaurus::buzzer( int sound ) | 261 | void Zaurus::buzzer( int sound ) |
259 | { | 262 | { |
260 | #ifndef QT_NO_SOUND | 263 | #ifndef QT_NO_SOUND |
261 | Sound *snd = 0; | 264 | Sound *snd = 0; |
262 | 265 | ||
263 | // All devices except SL5500 have a DSP device | 266 | // All devices except SL5500 have a DSP device |
264 | if ( d->m_model != Model_Zaurus_SL5000 | 267 | if ( d->m_model != Model_Zaurus_SL5000 |
265 | && d->m_model != Model_Zaurus_SL5500 ) { | 268 | && d->m_model != Model_Zaurus_SL5500 ) { |
266 | 269 | ||
267 | switch ( sound ){ | 270 | switch ( sound ){ |
268 | case SHARP_BUZ_TOUCHSOUND: { | 271 | case SHARP_BUZ_TOUCHSOUND: { |
269 | static Sound touch_sound("touchsound"); | 272 | static Sound touch_sound("touchsound"); |
270 | snd = &touch_sound; | 273 | snd = &touch_sound; |
271 | } | 274 | } |
272 | break; | 275 | break; |
273 | case SHARP_BUZ_KEYSOUND: { | 276 | case SHARP_BUZ_KEYSOUND: { |
274 | static Sound key_sound( "keysound" ); | 277 | static Sound key_sound( "keysound" ); |
275 | snd = &key_sound; | 278 | snd = &key_sound; |
276 | } | 279 | } |
277 | break; | 280 | break; |
278 | case SHARP_BUZ_SCHEDULE_ALARM: | 281 | case SHARP_BUZ_SCHEDULE_ALARM: |
279 | default: { | 282 | default: { |
280 | static Sound alarm_sound("alarm"); | 283 | static Sound alarm_sound("alarm"); |
281 | snd = &alarm_sound; | 284 | snd = &alarm_sound; |
282 | } | 285 | } |
283 | break; | 286 | break; |
284 | } | 287 | } |
285 | } | 288 | } |
286 | 289 | ||
287 | // If a soundname is defined, we expect that this device has | 290 | // If a soundname is defined, we expect that this device has |
288 | // sound capabilities.. Otherwise we expect to have the buzzer | 291 | // sound capabilities.. Otherwise we expect to have the buzzer |
289 | // device.. | 292 | // device.. |
290 | if ( snd && snd->isFinished() ){ | 293 | if ( snd && snd->isFinished() ){ |
291 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 294 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
292 | snd->play(); | 295 | snd->play(); |
293 | } else if( !snd ) { | 296 | } else if( !snd ) { |
294 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 297 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
295 | 298 | ||
296 | if ( fd >= 0 ) { | 299 | if ( fd >= 0 ) { |
297 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 300 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
298 | ::close ( fd ); | 301 | ::close ( fd ); |
299 | } | 302 | } |
300 | 303 | ||
301 | } | 304 | } |
302 | #endif | 305 | #endif |
303 | } | 306 | } |
304 | 307 | ||
305 | 308 | ||
306 | void Zaurus::playAlarmSound() | 309 | void Zaurus::playAlarmSound() |
307 | { | 310 | { |
308 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); | 311 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
309 | } | 312 | } |
310 | 313 | ||
311 | void Zaurus::playTouchSound() | 314 | void Zaurus::playTouchSound() |
312 | { | 315 | { |
313 | buzzer( SHARP_BUZ_TOUCHSOUND ); | 316 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
314 | } | 317 | } |
315 | 318 | ||
316 | void Zaurus::playKeySound() | 319 | void Zaurus::playKeySound() |
317 | { | 320 | { |
318 | buzzer( SHARP_BUZ_KEYSOUND ); | 321 | buzzer( SHARP_BUZ_KEYSOUND ); |
319 | } | 322 | } |
320 | 323 | ||
321 | 324 | ||
322 | QValueList <OLed> Zaurus::ledList() const | 325 | QValueList <OLed> Zaurus::ledList() const |
323 | { | 326 | { |
324 | QValueList <OLed> vl; | 327 | QValueList <OLed> vl; |
325 | vl << Led_Mail; | 328 | vl << Led_Mail; |
326 | return vl; | 329 | return vl; |
327 | } | 330 | } |
328 | 331 | ||
329 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const | 332 | QValueList <OLedState> Zaurus::ledStateList( OLed l ) const |
330 | { | 333 | { |
331 | QValueList <OLedState> vl; | 334 | QValueList <OLedState> vl; |
332 | 335 | ||
333 | if ( l == Led_Mail ) | 336 | if ( l == Led_Mail ) |
334 | vl << Led_Off << Led_On << Led_BlinkSlow; | 337 | vl << Led_Off << Led_On << Led_BlinkSlow; |
335 | return vl; | 338 | return vl; |
336 | } | 339 | } |
337 | 340 | ||
338 | OLedState Zaurus::ledState( OLed which ) const | 341 | OLedState Zaurus::ledState( OLed which ) const |
339 | { | 342 | { |
340 | if ( which == Led_Mail ) | 343 | if ( which == Led_Mail ) |
341 | return m_leds [0]; | 344 | return m_leds [0]; |
342 | else | 345 | else |
343 | return Led_Off; | 346 | return Led_Off; |
344 | } | 347 | } |
345 | 348 | ||
346 | bool Zaurus::setLedState( OLed which, OLedState st ) | 349 | bool Zaurus::setLedState( OLed which, OLedState st ) |
347 | { | 350 | { |
348 | // Currently not supported on non_embedix kernels | 351 | // Currently not supported on non_embedix kernels |
349 | if (!m_embedix) | 352 | if (!m_embedix) |
350 | { | 353 | { |
351 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); | 354 | qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); |
352 | return false; | 355 | return false; |
353 | } | 356 | } |
354 | 357 | ||
355 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
356 | 359 | ||
357 | if ( which == Led_Mail ) { | 360 | if ( which == Led_Mail ) { |
358 | if ( fd >= 0 ) { | 361 | if ( fd >= 0 ) { |
359 | struct sharp_led_status leds; | 362 | struct sharp_led_status leds; |
360 | ::memset ( &leds, 0, sizeof( leds )); | 363 | ::memset ( &leds, 0, sizeof( leds )); |
361 | leds. which = SHARP_LED_MAIL_EXISTS; | 364 | leds. which = SHARP_LED_MAIL_EXISTS; |
362 | bool ok = true; | 365 | bool ok = true; |
363 | 366 | ||
364 | switch ( st ) { | 367 | switch ( st ) { |
365 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
366 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
367 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
368 | default : ok = false; | 371 | default : ok = false; |
369 | } | 372 | } |
370 | 373 | ||
371 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
372 | m_leds [0] = st; | 375 | m_leds [0] = st; |
373 | return true; | 376 | return true; |
374 | } | 377 | } |
375 | } | 378 | } |
376 | } | 379 | } |
377 | return false; | 380 | return false; |
378 | } | 381 | } |
379 | 382 | ||
380 | bool Zaurus::setSoftSuspend ( bool soft ) | 383 | bool Zaurus::setSoftSuspend ( bool soft ) |
381 | { | 384 | { |
382 | if (!m_embedix) { | 385 | if (!m_embedix) { |
383 | /* non-Embedix kernels dont have kernel autosuspend */ | 386 | /* non-Embedix kernels dont have kernel autosuspend */ |
384 | return ODevice::setSoftSuspend( soft ); | 387 | return ODevice::setSoftSuspend( soft ); |
385 | } | 388 | } |
386 | 389 | ||
387 | bool res = false; | 390 | bool res = false; |
388 | int fd; | 391 | int fd; |
389 | 392 | ||
390 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 393 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
391 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 394 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
392 | 395 | ||
393 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 396 | int sources = ::ioctl( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
394 | 397 | ||
395 | if ( sources >= 0 ) { | 398 | if ( sources >= 0 ) { |
396 | if ( soft ) | 399 | if ( soft ) |
397 | sources &= ~APM_EVT_POWER_BUTTON; | 400 | sources &= ~APM_EVT_POWER_BUTTON; |
398 | else | 401 | else |
399 | sources |= APM_EVT_POWER_BUTTON; | 402 | sources |= APM_EVT_POWER_BUTTON; |
400 | 403 | ||
401 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 404 | if ( ::ioctl( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
402 | res = true; | 405 | res = true; |
403 | else | 406 | else |
404 | perror ( "APM_IOCGEVTSRC" ); | 407 | perror ( "APM_IOCGEVTSRC" ); |
405 | } | 408 | } |
406 | else | 409 | else |
407 | perror ( "APM_IOCGEVTSRC" ); | 410 | perror ( "APM_IOCGEVTSRC" ); |
408 | 411 | ||
409 | ::close ( fd ); | 412 | ::close( fd ); |
410 | } | 413 | } |
411 | else | 414 | else |
412 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 415 | perror( "/dev/apm_bios or /dev/misc/apm_bios" ); |
413 | 416 | ||
414 | return res; | 417 | return res; |
415 | } | 418 | } |
416 | 419 | ||
420 | int Zaurus::displayBrightnessResolution() const | ||
421 | { | ||
422 | int res = 1; | ||
423 | if (m_embedix) | ||
424 | { | ||
425 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | ||
426 | if ( fd ) | ||
427 | { | ||
428 | int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 ); | ||
429 | ::close( fd ); | ||
430 | return value ? value : res; | ||
431 | } | ||
432 | } | ||
433 | else | ||
434 | { | ||
435 | int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK ); | ||
436 | if ( fd ) | ||
437 | { | ||
438 | char buf[100]; | ||
439 | if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); | ||
440 | ::close( fd ); | ||
441 | } | ||
442 | } | ||
443 | return res; | ||
444 | } | ||
445 | |||
417 | bool Zaurus::setDisplayBrightness( int bright ) | 446 | bool Zaurus::setDisplayBrightness( int bright ) |
418 | { | 447 | { |
419 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 448 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
420 | bool res = false; | 449 | bool res = false; |
421 | 450 | ||
422 | if ( bright > 255 ) bright = 255; | 451 | if ( bright > 255 ) bright = 255; |
423 | if ( bright < 0 ) bright = 0; | 452 | if ( bright < 0 ) bright = 0; |
424 | 453 | ||
454 | int numberOfSteps = displayBrightnessResolution(); | ||
455 | int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; | ||
456 | |||
425 | if ( m_embedix ) | 457 | if ( m_embedix ) |
426 | { | 458 | { |
427 | int numberOfSteps = displayBrightnessResolution(); | ||
428 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 459 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
429 | if ( fd ) | 460 | if ( fd ) |
430 | { | 461 | { |
431 | int val = ( bright * numberOfSteps ) / 255; | 462 | res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
432 | res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); | 463 | ::close( fd ); |
433 | ::close ( fd ); | ||
434 | } | 464 | } |
435 | } | 465 | } |
436 | else | 466 | else |
437 | { | 467 | { |
438 | qDebug( "Zaurus::setDisplayBrightness: ODevice handling for non-embedix kernels not yet implemented" ); | 468 | int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); |
469 | if ( fd ) | ||
470 | { | ||
471 | char buf[100]; | ||
472 | int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); | ||
473 | res = ( ::write( fd, &buf[0], len ) == 0 ); | ||
474 | ::close( fd ); | ||
475 | } | ||
439 | } | 476 | } |
440 | return res; | 477 | return res; |
441 | } | 478 | } |
442 | 479 | ||
443 | bool Zaurus::setDisplayStatus( bool on ) | 480 | bool Zaurus::setDisplayStatus( bool on ) |
444 | { | 481 | { |
445 | bool res = false; | 482 | bool res = false; |
446 | if ( m_embedix ) | 483 | if ( m_embedix ) |
447 | { | 484 | { |
448 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | 485 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
449 | if ( fd ) | 486 | if ( fd ) |
450 | { | 487 | { |
451 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | 488 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; |
452 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | 489 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); |
453 | ::close ( fd ); | 490 | ::close ( fd ); |
454 | } | 491 | } |
455 | } | 492 | } |
456 | else | 493 | else |
457 | { | 494 | { |
458 | qDebug( "Zaurus::setDisplayStatus: ODevice handling for non-embedix kernels not yet implemented" ); | 495 | int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); |
496 | if ( fd ) | ||
497 | { | ||
498 | char buf[10]; | ||
499 | buf[0] = on ? '0' : '1'; | ||
500 | buf[1] = '\0'; | ||
501 | res = ( ::write( fd, &buf[0], 2 ) == 0 ); | ||
502 | ::close( fd ); | ||
503 | } | ||
459 | } | 504 | } |
460 | return res; | 505 | return res; |
461 | } | 506 | } |
462 | 507 | ||
463 | bool Zaurus::suspend() | 508 | bool Zaurus::suspend() |
464 | { | 509 | { |
465 | qDebug("ODevice::suspend"); | 510 | qDebug("ODevice::suspend"); |
466 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 511 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
467 | return false; | 512 | return false; |
468 | 513 | ||
469 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 514 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
470 | return false; | 515 | return false; |
471 | 516 | ||
472 | bool res = false; | 517 | bool res = false; |
473 | ODevice::sendSuspendmsg(); | 518 | ODevice::sendSuspendmsg(); |
474 | 519 | ||
475 | struct timeval tvs, tvn; | 520 | struct timeval tvs, tvn; |
476 | ::gettimeofday ( &tvs, 0 ); | 521 | ::gettimeofday ( &tvs, 0 ); |
477 | 522 | ||
478 | ::sync(); // flush fs caches | 523 | ::sync(); // flush fs caches |
479 | res = ( ::system ( "apm --suspend" ) == 0 ); | 524 | res = ( ::system ( "apm --suspend" ) == 0 ); |
480 | 525 | ||
481 | // This is needed because the apm implementation is asynchronous and we | 526 | // This is needed because the apm implementation is asynchronous and we |
482 | // can not be sure when exactly the device is really suspended | 527 | // can not be sure when exactly the device is really suspended |
483 | if ( res ) { | 528 | if ( res ) { |
484 | do { // Yes, wait 15 seconds. This APM sucks big time. | 529 | do { // Yes, wait 15 seconds. This APM sucks big time. |
485 | ::usleep ( 200 * 1000 ); | 530 | ::usleep ( 200 * 1000 ); |
486 | ::gettimeofday ( &tvn, 0 ); | 531 | ::gettimeofday ( &tvn, 0 ); |
487 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 532 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
488 | } | 533 | } |
489 | 534 | ||
490 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 535 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
491 | return res; | 536 | return res; |
492 | } | 537 | } |
493 | 538 | ||
494 | 539 | ||
495 | Transformation Zaurus::rotation() const | 540 | Transformation Zaurus::rotation() const |
496 | { | 541 | { |
497 | Transformation rot; | 542 | Transformation rot; |
498 | int handle = 0; | 543 | int handle = 0; |
499 | int retval = 0; | 544 | int retval = 0; |
500 | 545 | ||
501 | switch ( d->m_model ) { | 546 | switch ( d->m_model ) { |
502 | case Model_Zaurus_SLC3000: // fallthrough | 547 | case Model_Zaurus_SLC3000: // fallthrough |
503 | case Model_Zaurus_SLC7x0: | 548 | case Model_Zaurus_SLC7x0: |
504 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 549 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
505 | if (handle == -1) { | 550 | if (handle == -1) { |
506 | return Rot270; | 551 | return Rot270; |
507 | } else { | 552 | } else { |
508 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 553 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
509 | ::close (handle); | 554 | ::close (handle); |
510 | 555 | ||
511 | if (retval == 2 ) | 556 | if (retval == 2 ) |
512 | rot = Rot0; | 557 | rot = Rot0; |
513 | else | 558 | else |
514 | rot = Rot270; | 559 | rot = Rot270; |
515 | } | 560 | } |
516 | break; | 561 | break; |
517 | case Model_Zaurus_SL6000: | 562 | case Model_Zaurus_SL6000: |
518 | case Model_Zaurus_SLB600: | 563 | case Model_Zaurus_SLB600: |
519 | case Model_Zaurus_SLA300: | 564 | case Model_Zaurus_SLA300: |
520 | case Model_Zaurus_SL5500: | 565 | case Model_Zaurus_SL5500: |
521 | case Model_Zaurus_SL5000: | 566 | case Model_Zaurus_SL5000: |
522 | default: | 567 | default: |
523 | rot = d->m_rotation; | 568 | rot = d->m_rotation; |
524 | break; | 569 | break; |
525 | } | 570 | } |
526 | 571 | ||
527 | return rot; | 572 | return rot; |
528 | } | 573 | } |
529 | ODirection Zaurus::direction() const | 574 | ODirection Zaurus::direction() const |
530 | { | 575 | { |
531 | ODirection dir; | 576 | ODirection dir; |
532 | int handle = 0; | 577 | int handle = 0; |
533 | int retval = 0; | 578 | int retval = 0; |
534 | switch ( d->m_model ) { | 579 | switch ( d->m_model ) { |
535 | case Model_Zaurus_SLC3000: // fallthrough | 580 | case Model_Zaurus_SLC3000: // fallthrough |
536 | case Model_Zaurus_SLC7x0: | 581 | case Model_Zaurus_SLC7x0: |
537 | handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); | 582 | handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); |
538 | if (handle == -1) { | 583 | if (handle == -1) { |
539 | dir = CW; | 584 | dir = CW; |
540 | } else { | 585 | } else { |
541 | retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); | 586 | retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); |
542 | ::close (handle); | 587 | ::close (handle); |
543 | if (retval == 2 ) | 588 | if (retval == 2 ) |
544 | dir = CCW; | 589 | dir = CCW; |
545 | else | 590 | else |
546 | dir = CW; | 591 | dir = CW; |
547 | } | 592 | } |
548 | break; | 593 | break; |
549 | case Model_Zaurus_SL6000: | 594 | case Model_Zaurus_SL6000: |
550 | case Model_Zaurus_SLA300: | 595 | case Model_Zaurus_SLA300: |
551 | case Model_Zaurus_SLB600: | 596 | case Model_Zaurus_SLB600: |
552 | case Model_Zaurus_SL5500: | 597 | case Model_Zaurus_SL5500: |
553 | case Model_Zaurus_SL5000: | 598 | case Model_Zaurus_SL5000: |
554 | default: dir = d->m_direction; | 599 | default: dir = d->m_direction; |
555 | break; | 600 | break; |
556 | } | 601 | } |
557 | return dir; | 602 | return dir; |
558 | 603 | ||
559 | } | 604 | } |
560 | 605 | ||
561 | int Zaurus::displayBrightnessResolution() const | ||
562 | { | ||
563 | if (m_embedix) | ||
564 | { | ||
565 | int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); | ||
566 | if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 ); | ||
567 | else return 1; | ||
568 | } | ||
569 | else | ||
570 | { | ||
571 | qDebug( "Zaurus::displayBrightnessResolution: ODevice handling for non-embedix kernels not yet implemented" ); | ||
572 | return 1; | ||
573 | } | ||
574 | } | ||
575 | |||
576 | bool Zaurus::hasHingeSensor() const | 606 | bool Zaurus::hasHingeSensor() const |
577 | { | 607 | { |
578 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; | 608 | return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; |
579 | } | 609 | } |
580 | 610 | ||
581 | OHingeStatus Zaurus::readHingeSensor() | 611 | OHingeStatus Zaurus::readHingeSensor() |
582 | { | 612 | { |
583 | if (m_embedix) | 613 | if (m_embedix) |
584 | { | 614 | { |
585 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 615 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
586 | if (handle == -1) | 616 | if (handle == -1) |
587 | { | 617 | { |
588 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 618 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
589 | return CASE_UNKNOWN; | 619 | return CASE_UNKNOWN; |
590 | } | 620 | } |
591 | else | 621 | else |
592 | { | 622 | { |
593 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 623 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
594 | ::close (handle); | 624 | ::close (handle); |
595 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 625 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
596 | { | 626 | { |
597 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 627 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
598 | return static_cast<OHingeStatus>( retval ); | 628 | return static_cast<OHingeStatus>( retval ); |
599 | } | 629 | } |
600 | else | 630 | else |
601 | { | 631 | { |
602 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 632 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
603 | return CASE_UNKNOWN; | 633 | return CASE_UNKNOWN; |
604 | } | 634 | } |
605 | } | 635 | } |
606 | } | 636 | } |
607 | else | 637 | else |
608 | { | 638 | { |
609 | qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); | 639 | qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); |
610 | return CASE_UNKNOWN; | 640 | return CASE_UNKNOWN; |
611 | } | 641 | } |
612 | } | 642 | } |
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro index 1786b08..f133433 100644 --- a/libopie2/opiecore/opiecore.pro +++ b/libopie2/opiecore/opiecore.pro | |||
@@ -1,61 +1,61 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = oapplication.h \ | 4 | HEADERS = oapplication.h \ |
5 | oconfig.h \ | 5 | oconfig.h \ |
6 | odebug.h \ | 6 | odebug.h \ |
7 | oglobal.h \ | 7 | oglobal.h \ |
8 | oglobalsettings.h \ | 8 | oglobalsettings.h \ |
9 | okeyconfigmanager.h \ | 9 | okeyconfigmanager.h \ |
10 | okeyfilter.h \ | 10 | okeyfilter.h \ |
11 | opluginloader.h \ | 11 | opluginloader.h \ |
12 | oprocess.h \ | 12 | oprocess.h \ |
13 | oprocctrl.h \ | 13 | oprocctrl.h \ |
14 | osharedpointer.h \ | 14 | osharedpointer.h \ |
15 | osmartpointer.h \ | 15 | osmartpointer.h \ |
16 | ostorageinfo.h \ | 16 | ostorageinfo.h \ |
17 | xmltree.h | 17 | xmltree.h |
18 | 18 | ||
19 | SOURCES = oapplication.cpp \ | 19 | SOURCES = oapplication.cpp \ |
20 | oconfig.cpp \ | 20 | oconfig.cpp \ |
21 | odebug.cpp \ | 21 | odebug.cpp \ |
22 | oglobal.cpp \ | 22 | oglobal.cpp \ |
23 | oglobalsettings.cpp \ | 23 | oglobalsettings.cpp \ |
24 | okeyconfigmanager.cpp \ | 24 | okeyconfigmanager.cpp \ |
25 | okeyfilter.cpp \ | 25 | okeyfilter.cpp \ |
26 | opluginloader.cpp \ | 26 | opluginloader.cpp \ |
27 | oprocess.cpp \ | 27 | oprocess.cpp \ |
28 | oprocctrl.cpp \ | 28 | oprocctrl.cpp \ |
29 | osmartpointer.cpp \ | 29 | osmartpointer.cpp \ |
30 | ostorageinfo.cpp \ | 30 | ostorageinfo.cpp \ |
31 | xmltree.cpp | 31 | xmltree.cpp |
32 | 32 | ||
33 | 33 | ||
34 | # The following files are currently not compileable on mac ! | 34 | # The following files are currently not compileable on mac ! |
35 | # Therfore I removed them from the build .. (eilers) | 35 | # Therfore I removed them from the build .. (eilers) |
36 | 36 | ||
37 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) | 37 | CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) |
38 | !contains( CONFTEST, y ) { | 38 | !contains( CONFTEST, y ) { |
39 | HEADERS += ofilenotify.h | 39 | HEADERS += ofilenotify.h |
40 | SOURCES += ofilenotify.cpp | 40 | SOURCES += ofilenotify.cpp |
41 | } else { | 41 | } else { |
42 | message( "ofilenotify is not available in a mac build !" ) | 42 | message( "ofilenotify is not available in a mac build !" ) |
43 | } | 43 | } |
44 | 44 | ||
45 | include( device/device.pro ) | 45 | include( device/device.pro ) |
46 | 46 | ||
47 | INTERFACES = | 47 | INTERFACES = |
48 | TARGET = opiecore2 | 48 | TARGET = opiecore2 |
49 | VERSION = 1.9.1 | 49 | VERSION = 1.9.2 |
50 | INCLUDEPATH += $(OPIEDIR)/include | 50 | INCLUDEPATH += $(OPIEDIR)/include |
51 | DEPENDPATH += $(OPIEDIR)/include | 51 | DEPENDPATH += $(OPIEDIR)/include |
52 | 52 | ||
53 | !contains( platform, x11 ) { | 53 | !contains( platform, x11 ) { |
54 | LIBS = -lqpe | 54 | LIBS = -lqpe |
55 | include( $(OPIEDIR)/include.pro ) | 55 | include( $(OPIEDIR)/include.pro ) |
56 | } | 56 | } |
57 | 57 | ||
58 | contains( platform, x11 ) { | 58 | contains( platform, x11 ) { |
59 | LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 59 | LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
60 | } | 60 | } |
61 | 61 | ||