-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 92 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 20 |
2 files changed, 45 insertions, 67 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 1894e15..e75e777 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -315,296 +315,276 @@ void Zaurus::playKeySound() | |||
315 | 315 | ||
316 | QValueList <OLed> Zaurus::ledList() const | 316 | QValueList <OLed> Zaurus::ledList() const |
317 | { | 317 | { |
318 | QValueList <OLed> vl; | 318 | QValueList <OLed> vl; |
319 | vl << Led_Mail; | 319 | vl << Led_Mail; |
320 | return vl; | 320 | return vl; |
321 | } | 321 | } |
322 | 322 | ||
323 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 323 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
324 | { | 324 | { |
325 | QValueList <OLedState> vl; | 325 | QValueList <OLedState> vl; |
326 | 326 | ||
327 | if ( l == Led_Mail ) | 327 | if ( l == Led_Mail ) |
328 | vl << Led_Off << Led_On << Led_BlinkSlow; | 328 | vl << Led_Off << Led_On << Led_BlinkSlow; |
329 | return vl; | 329 | return vl; |
330 | } | 330 | } |
331 | 331 | ||
332 | OLedState Zaurus::ledState ( OLed which ) const | 332 | OLedState Zaurus::ledState ( OLed which ) const |
333 | { | 333 | { |
334 | if ( which == Led_Mail ) | 334 | if ( which == Led_Mail ) |
335 | return m_leds [0]; | 335 | return m_leds [0]; |
336 | else | 336 | else |
337 | return Led_Off; | 337 | return Led_Off; |
338 | } | 338 | } |
339 | 339 | ||
340 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 340 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
341 | { | 341 | { |
342 | if (!m_embedix) // Currently not supported on non_embedix kernels | 342 | if (!m_embedix) // Currently not supported on non_embedix kernels |
343 | return false; | 343 | return false; |
344 | 344 | ||
345 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 345 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
346 | 346 | ||
347 | if ( which == Led_Mail ) { | 347 | if ( which == Led_Mail ) { |
348 | if ( fd >= 0 ) { | 348 | if ( fd >= 0 ) { |
349 | struct sharp_led_status leds; | 349 | struct sharp_led_status leds; |
350 | ::memset ( &leds, 0, sizeof( leds )); | 350 | ::memset ( &leds, 0, sizeof( leds )); |
351 | leds. which = SHARP_LED_MAIL_EXISTS; | 351 | leds. which = SHARP_LED_MAIL_EXISTS; |
352 | bool ok = true; | 352 | bool ok = true; |
353 | 353 | ||
354 | switch ( st ) { | 354 | switch ( st ) { |
355 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 355 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
356 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 356 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
357 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 357 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
358 | default : ok = false; | 358 | default : ok = false; |
359 | } | 359 | } |
360 | 360 | ||
361 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 361 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
362 | m_leds [0] = st; | 362 | m_leds [0] = st; |
363 | return true; | 363 | return true; |
364 | } | 364 | } |
365 | } | 365 | } |
366 | } | 366 | } |
367 | return false; | 367 | return false; |
368 | } | 368 | } |
369 | 369 | ||
370 | bool Zaurus::setSoftSuspend ( bool soft ) | 370 | bool Zaurus::setSoftSuspend ( bool soft ) |
371 | { | 371 | { |
372 | if (!m_embedix) { | 372 | if (!m_embedix) { |
373 | /* non-Embedix kernels dont have kernel autosuspend */ | 373 | /* non-Embedix kernels dont have kernel autosuspend */ |
374 | return ODevice::setSoftSuspend( soft ); | 374 | return ODevice::setSoftSuspend( soft ); |
375 | } | 375 | } |
376 | 376 | ||
377 | bool res = false; | 377 | bool res = false; |
378 | int fd; | 378 | int fd; |
379 | 379 | ||
380 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 380 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
381 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 381 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
382 | 382 | ||
383 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 383 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
384 | 384 | ||
385 | if ( sources >= 0 ) { | 385 | if ( sources >= 0 ) { |
386 | if ( soft ) | 386 | if ( soft ) |
387 | sources &= ~APM_EVT_POWER_BUTTON; | 387 | sources &= ~APM_EVT_POWER_BUTTON; |
388 | else | 388 | else |
389 | sources |= APM_EVT_POWER_BUTTON; | 389 | sources |= APM_EVT_POWER_BUTTON; |
390 | 390 | ||
391 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 391 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
392 | res = true; | 392 | res = true; |
393 | else | 393 | else |
394 | perror ( "APM_IOCGEVTSRC" ); | 394 | perror ( "APM_IOCGEVTSRC" ); |
395 | } | 395 | } |
396 | else | 396 | else |
397 | perror ( "APM_IOCGEVTSRC" ); | 397 | perror ( "APM_IOCGEVTSRC" ); |
398 | 398 | ||
399 | ::close ( fd ); | 399 | ::close ( fd ); |
400 | } | 400 | } |
401 | else | 401 | else |
402 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 402 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
403 | 403 | ||
404 | return res; | 404 | return res; |
405 | } | 405 | } |
406 | 406 | ||
407 | bool Zaurus::setDisplayBrightness( int bright ) | 407 | bool Zaurus::setDisplayBrightness( int bright ) |
408 | { | 408 | { |
409 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 409 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
410 | bool res = false; | 410 | bool res = false; |
411 | int fd; | ||
412 | 411 | ||
413 | if ( bright > 255 ) bright = 255; | 412 | if ( bright > 255 ) bright = 255; |
414 | if ( bright < 0 ) bright = 0; | 413 | if ( bright < 0 ) bright = 0; |
415 | 414 | ||
416 | if ( m_embedix ) | 415 | if ( m_embedix ) |
417 | { | 416 | { |
418 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 417 | int numberOfSteps = displayBrightnessResolution(); |
419 | { | 418 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); |
420 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | 419 | if ( fd ) |
421 | // special treatment for devices with the corgi backlight interface | ||
422 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | ||
423 | { | ||
424 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); | ||
425 | char writeCommand[100]; | ||
426 | const int count = sprintf( writeCommand, "%x\n", value ); | ||
427 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | ||
428 | ::close ( fd ); | ||
429 | } | ||
430 | return res; | ||
431 | } | ||
432 | else | ||
433 | if ( d->m_model == Model_Zaurus_SL6000 ) | ||
434 | { | ||
435 | //qDebug( "using special treatment for devices with the tosa backlight interface" ); | ||
436 | // special treatment for devices with the tosa backlight interface | ||
437 | if (( fd = ::open ( "/proc/driver/fl/tosa-bl", O_WRONLY )) >= 0 ) | ||
438 | { | ||
439 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); | ||
440 | char writeCommand[100]; | ||
441 | const int count = sprintf( writeCommand, "%x\n", value ); | ||
442 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | ||
443 | ::close ( fd ); | ||
444 | } | ||
445 | return res; | ||
446 | } | ||
447 | else | ||
448 | { | 420 | { |
449 | // standard treatment for devices with the dumb embedix frontlight interface | 421 | int val = ( numberOfSteps * 255 ) / 255; |
450 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 422 | res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); |
451 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 423 | ::close ( fd ); |
452 | if ( bright && !bl ) | ||
453 | bl = 1; | ||
454 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | ||
455 | ::close ( fd ); | ||
456 | } | ||
457 | } | 424 | } |
458 | } | 425 | } |
459 | else | 426 | else |
460 | { | 427 | { |
461 | // special treatment for the OpenZaurus unified interface | 428 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); |
462 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 429 | } |
463 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 430 | return res; |
464 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 431 | } |
432 | |||
433 | bool Zaurus::setDisplayStatus( bool on ) | ||
434 | { | ||
435 | bool res = false; | ||
436 | if ( m_embedix ) | ||
437 | { | ||
438 | int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); | ||
439 | if ( fd ) | ||
440 | { | ||
441 | int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; | ||
442 | res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); | ||
465 | ::close ( fd ); | 443 | ::close ( fd ); |
466 | } | 444 | } |
467 | } | 445 | } |
446 | else | ||
447 | { | ||
448 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); | ||
449 | } | ||
468 | return res; | 450 | return res; |
469 | } | 451 | } |
470 | 452 | ||
471 | bool Zaurus::suspend() | 453 | bool Zaurus::suspend() |
472 | { | 454 | { |
473 | qDebug("ODevice::suspend"); | 455 | qDebug("ODevice::suspend"); |
474 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 456 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
475 | return false; | 457 | return false; |
476 | 458 | ||
477 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 459 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
478 | return false; | 460 | return false; |
479 | 461 | ||
480 | bool res = false; | 462 | bool res = false; |
481 | ODevice::sendSuspendmsg(); | 463 | ODevice::sendSuspendmsg(); |
482 | 464 | ||
483 | struct timeval tvs, tvn; | 465 | struct timeval tvs, tvn; |
484 | ::gettimeofday ( &tvs, 0 ); | 466 | ::gettimeofday ( &tvs, 0 ); |
485 | 467 | ||
486 | ::sync(); // flush fs caches | 468 | ::sync(); // flush fs caches |
487 | res = ( ::system ( "apm --suspend" ) == 0 ); | 469 | res = ( ::system ( "apm --suspend" ) == 0 ); |
488 | 470 | ||
489 | // This is needed because the iPAQ apm implementation is asynchronous and we | 471 | // This is needed because the apm implementation is asynchronous and we |
490 | // can not be sure when exactly the device is really suspended | 472 | // can not be sure when exactly the device is really suspended |
491 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | ||
492 | |||
493 | if ( res ) { | 473 | if ( res ) { |
494 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 474 | do { // Yes, wait 15 seconds. This APM sucks big time. |
495 | ::usleep ( 200 * 1000 ); | 475 | ::usleep ( 200 * 1000 ); |
496 | ::gettimeofday ( &tvn, 0 ); | 476 | ::gettimeofday ( &tvn, 0 ); |
497 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 477 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
498 | } | 478 | } |
499 | 479 | ||
500 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 480 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
501 | return res; | 481 | return res; |
502 | } | 482 | } |
503 | 483 | ||
504 | 484 | ||
505 | Transformation Zaurus::rotation() const | 485 | Transformation Zaurus::rotation() const |
506 | { | 486 | { |
507 | Transformation rot; | 487 | Transformation rot; |
508 | int handle = 0; | 488 | int handle = 0; |
509 | int retval = 0; | 489 | int retval = 0; |
510 | 490 | ||
511 | switch ( d->m_model ) { | 491 | switch ( d->m_model ) { |
512 | case Model_Zaurus_SLC7x0: | 492 | case Model_Zaurus_SLC7x0: |
513 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 493 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
514 | if (handle == -1) { | 494 | if (handle == -1) { |
515 | return Rot270; | 495 | return Rot270; |
516 | } else { | 496 | } else { |
517 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 497 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
518 | ::close (handle); | 498 | ::close (handle); |
519 | 499 | ||
520 | if (retval == 2 ) | 500 | if (retval == 2 ) |
521 | rot = Rot0; | 501 | rot = Rot0; |
522 | else | 502 | else |
523 | rot = Rot270; | 503 | rot = Rot270; |
524 | } | 504 | } |
525 | break; | 505 | break; |
526 | case Model_Zaurus_SLA300: | 506 | case Model_Zaurus_SLA300: |
527 | case Model_Zaurus_SLB600: | 507 | case Model_Zaurus_SLB600: |
528 | case Model_Zaurus_SL5500: | 508 | case Model_Zaurus_SL5500: |
529 | case Model_Zaurus_SL5000: | 509 | case Model_Zaurus_SL5000: |
530 | default: | 510 | default: |
531 | rot = d->m_rotation; | 511 | rot = d->m_rotation; |
532 | break; | 512 | break; |
533 | } | 513 | } |
534 | 514 | ||
535 | return rot; | 515 | return rot; |
536 | } | 516 | } |
537 | ODirection Zaurus::direction() const | 517 | ODirection Zaurus::direction() const |
538 | { | 518 | { |
539 | ODirection dir; | 519 | ODirection dir; |
540 | int handle = 0; | 520 | int handle = 0; |
541 | int retval = 0; | 521 | int retval = 0; |
542 | switch ( d->m_model ) { | 522 | switch ( d->m_model ) { |
543 | case Model_Zaurus_SLC7x0: | 523 | case Model_Zaurus_SLC7x0: |
544 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 524 | handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); |
545 | if (handle == -1) { | 525 | if (handle == -1) { |
546 | dir = CW; | 526 | dir = CW; |
547 | } else { | 527 | } else { |
548 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 528 | retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); |
549 | ::close (handle); | 529 | ::close (handle); |
550 | if (retval == 2 ) | 530 | if (retval == 2 ) |
551 | dir = CCW; | 531 | dir = CCW; |
552 | else | 532 | else |
553 | dir = CW; | 533 | dir = CW; |
554 | } | 534 | } |
555 | break; | 535 | break; |
556 | case Model_Zaurus_SLA300: | 536 | case Model_Zaurus_SLA300: |
557 | case Model_Zaurus_SLB600: | 537 | case Model_Zaurus_SLB600: |
558 | case Model_Zaurus_SL5500: | 538 | case Model_Zaurus_SL5500: |
559 | case Model_Zaurus_SL5000: | 539 | case Model_Zaurus_SL5000: |
560 | default: | 540 | default: dir = d->m_direction; |
561 | dir = d->m_direction; | ||
562 | break; | 541 | break; |
563 | } | 542 | } |
564 | return dir; | 543 | return dir; |
565 | 544 | ||
566 | } | 545 | } |
567 | 546 | ||
568 | int Zaurus::displayBrightnessResolution() const | 547 | int Zaurus::displayBrightnessResolution() const |
569 | { | 548 | { |
570 | if (m_embedix) | 549 | if (m_embedix) |
571 | { | 550 | { |
572 | if ( d->m_model == Model_Zaurus_SLC7x0 ) return 18; | 551 | int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); |
573 | if ( d->m_model == Model_Zaurus_SL6000 ) return 18; | 552 | if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 ); |
574 | return 5; | 553 | else return 1; |
575 | } | 554 | } |
576 | else | 555 | else |
577 | { | 556 | { |
578 | return 256; | 557 | qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); |
558 | return 1; | ||
579 | } | 559 | } |
580 | } | 560 | } |
581 | 561 | ||
582 | bool Zaurus::hasHingeSensor() const | 562 | bool Zaurus::hasHingeSensor() const |
583 | { | 563 | { |
584 | return d->m_model == Model_Zaurus_SLC7x0; | 564 | return d->m_model == Model_Zaurus_SLC7x0; |
585 | } | 565 | } |
586 | 566 | ||
587 | OHingeStatus Zaurus::readHingeSensor() | 567 | OHingeStatus Zaurus::readHingeSensor() |
588 | { | 568 | { |
589 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 569 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
590 | if (handle == -1) | 570 | if (handle == -1) |
591 | { | 571 | { |
592 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 572 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
593 | return CASE_UNKNOWN; | 573 | return CASE_UNKNOWN; |
594 | } | 574 | } |
595 | else | 575 | else |
596 | { | 576 | { |
597 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 577 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
598 | ::close (handle); | 578 | ::close (handle); |
599 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 579 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
600 | { | 580 | { |
601 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 581 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
602 | return static_cast<OHingeStatus>( retval ); | 582 | return static_cast<OHingeStatus>( retval ); |
603 | } | 583 | } |
604 | else | 584 | else |
605 | { | 585 | { |
606 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 586 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
607 | return CASE_UNKNOWN; | 587 | return CASE_UNKNOWN; |
608 | } | 588 | } |
609 | } | 589 | } |
610 | } | 590 | } |
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h index dc21546..37ab876 100644 --- a/libopie2/opiecore/device/odevice_zaurus.h +++ b/libopie2/opiecore/device/odevice_zaurus.h | |||
@@ -1,139 +1,137 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 4 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ODEVICE_ZAURUS | 30 | #ifndef ODEVICE_ZAURUS |
31 | #define ODEVICE_ZAURUS | 31 | #define ODEVICE_ZAURUS |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include <opie2/odevice.h> |
34 | 34 | ||
35 | #ifndef ARRAY_SIZE | 35 | #ifndef ARRAY_SIZE |
36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | // _IO and friends are only defined in kernel headers ... | 39 | // _IO and friends are only defined in kernel headers ... |
40 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 40 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
45 | 45 | ||
46 | // Audio | 46 | // Audio |
47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
48 | 48 | ||
49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
51 | 51 | ||
52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
55 | 55 | ||
56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
61 | 61 | ||
62 | // LED | 62 | // LED |
63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
66 | 66 | ||
67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
70 | 70 | ||
71 | // Rotation and Power Management | 71 | // Rotation and Power Management |
72 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 72 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
73 | 73 | ||
74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
76 | #define APM_EVT_POWER_BUTTON (1 << 0) | 76 | #define APM_EVT_POWER_BUTTON (1 << 0) |
77 | 77 | ||
78 | // Brightness | 78 | // Brightness |
79 | #define FL_IOCTL_STEP_CONTRAST 100 | 79 | #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" |
80 | 80 | #define SHARP_FL_IOCTL_ON 1 | |
81 | #define CORGI_TOSA_BL_IOCTL_ON 1 | 81 | #define SHARP_FL_IOCTL_OFF 2 |
82 | #define CORGI_TOSA_BL_IOCTL_OFF 2 | 82 | #define SHARP_FL_IOCTL_STEP_CONTRAST 100 |
83 | #define CORGI_TOSA_BL_IOCTL_STEP_CONTRAST 100 | 83 | #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 |
84 | #define CORGI_TOSA_BL_IOCTL_GET_STEP_CONTRAST 101 | 84 | #define SHARP_FL_IOCTL_GET_STEP 102 |
85 | #define CORGI_TOSA_BL_IOCTL_GET_STEP 102 | ||
86 | #define CORGI_BL_PROC_DEVICE corgi-bl | ||
87 | #define TOSA_BL_PROC_DEVICE tosa-bl | ||
88 | 85 | ||
89 | namespace Opie { | 86 | namespace Opie { |
90 | namespace Core { | 87 | namespace Core { |
91 | namespace Internal { | 88 | namespace Internal { |
92 | class Zaurus : public ODevice | 89 | class Zaurus : public ODevice |
93 | { | 90 | { |
94 | protected: | 91 | protected: |
95 | virtual void init(const QString&); | 92 | virtual void init(const QString&); |
96 | virtual void initButtons(); | 93 | virtual void initButtons(); |
97 | 94 | ||
98 | public: | 95 | public: |
99 | virtual bool setSoftSuspend ( bool soft ); | 96 | virtual bool setSoftSuspend( bool soft ); |
100 | 97 | ||
101 | virtual bool setDisplayBrightness ( int b ); | 98 | virtual bool setDisplayBrightness( int b ); |
99 | virtual bool setDisplayStatus( bool on ); | ||
102 | virtual int displayBrightnessResolution() const; | 100 | virtual int displayBrightnessResolution() const; |
103 | 101 | ||
104 | virtual void playAlarmSound(); | 102 | virtual void playAlarmSound(); |
105 | virtual void playKeySound(); | 103 | virtual void playKeySound(); |
106 | virtual void playTouchSound(); | 104 | virtual void playTouchSound(); |
107 | 105 | ||
108 | virtual QValueList <OLed> ledList() const; | 106 | virtual QValueList <OLed> ledList() const; |
109 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 107 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
110 | virtual OLedState ledState( OLed led ) const; | 108 | virtual OLedState ledState( OLed led ) const; |
111 | virtual bool setLedState( OLed led, OLedState st ); | 109 | virtual bool setLedState( OLed led, OLedState st ); |
112 | 110 | ||
113 | virtual bool hasHingeSensor() const; | 111 | virtual bool hasHingeSensor() const; |
114 | virtual OHingeStatus readHingeSensor(); | 112 | virtual OHingeStatus readHingeSensor(); |
115 | 113 | ||
116 | virtual bool suspend(); | 114 | virtual bool suspend(); |
117 | virtual Transformation rotation() const; | 115 | virtual Transformation rotation() const; |
118 | virtual ODirection direction() const; | 116 | virtual ODirection direction() const; |
119 | 117 | ||
120 | protected: | 118 | protected: |
121 | virtual void buzzer ( int snd ); | 119 | virtual void buzzer ( int snd ); |
122 | 120 | ||
123 | OLedState m_leds [1]; | 121 | OLedState m_leds [1]; |
124 | bool m_embedix; | 122 | bool m_embedix; |
125 | }; | 123 | }; |
126 | 124 | ||
127 | struct z_button { | 125 | struct z_button { |
128 | Qt::Key code; | 126 | Qt::Key code; |
129 | char *utext; | 127 | char *utext; |
130 | char *pix; | 128 | char *pix; |
131 | char *fpressedservice; | 129 | char *fpressedservice; |
132 | char *fpressedaction; | 130 | char *fpressedaction; |
133 | char *fheldservice; | 131 | char *fheldservice; |
134 | char *fheldaction; | 132 | char *fheldaction; |
135 | }; | 133 | }; |
136 | } | 134 | } |
137 | } | 135 | } |
138 | } | 136 | } |
139 | #endif | 137 | #endif |