summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_zaurus.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp36
1 files changed, 4 insertions, 32 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 82e127e..67dfa41 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -87,96 +87,100 @@ struct z_button z_buttons_c700 [] = {
87 "today", "raise()" }, 87 "today", "raise()" },
88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
89 "devicebuttons/z_contact", 89 "devicebuttons/z_contact",
90 "addressbook", "raise()", 90 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 91 "addressbook", "beamBusinessCard()" },
92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
93 "devicebuttons/z_home", 93 "devicebuttons/z_home",
94 "QPE/Launcher", "home()", 94 "QPE/Launcher", "home()",
95 "buttonsettings", "raise()" }, 95 "buttonsettings", "raise()" },
96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
97 "devicebuttons/z_menu", 97 "devicebuttons/z_menu",
98 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
99 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
101 "devicebuttons/z_mail", 101 "devicebuttons/z_mail",
102 "opiemail", "raise()", 102 "opiemail", "raise()",
103 "opiemail", "newMail()" }, 103 "opiemail", "newMail()" },
104 104
105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), 105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"),
106 "devicebuttons/z_hinge1", 106 "devicebuttons/z_hinge1",
107 "QPE/Rotation", "rotateDefault()", 107 "QPE/Rotation", "rotateDefault()",
108 "QPE/Rotation", "rotateDefault()" }, 108 "QPE/Rotation", "rotateDefault()" },
109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), 109 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"),
110 "devicebuttons/z_hinge2", 110 "devicebuttons/z_hinge2",
111 "QPE/Rotation", "rotateDefault()", 111 "QPE/Rotation", "rotateDefault()",
112 "QPE/Rotation", "rotateDefault()" }, 112 "QPE/Rotation", "rotateDefault()" },
113 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), 113 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
114 "devicebuttons/z_hinge3", 114 "devicebuttons/z_hinge3",
115 "QPE/Rotation", "rotateDefault()", 115 "QPE/Rotation", "rotateDefault()",
116 "QPE/Rotation", "rotateDefault()" }, 116 "QPE/Rotation", "rotateDefault()" },
117}; 117};
118 118
119// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 119// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
120// class up into individual classes. We need three classes 120// class up into individual classes. We need three classes
121// 121//
122// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 122// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
123// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 123// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
124// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) 124// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000)
125// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) 125// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
126// 126//
127// Only question right now is: Do we really need to do it? Because as soon 127// Only question right now is: Do we really need to do it? Because as soon
128// as the OpenZaurus kernel is ready, there will be a unified interface for all 128// as the OpenZaurus kernel is ready, there will be a unified interface for all
129// Zaurus models (concerning apm, backlight, buttons, etc.) 129// Zaurus models (concerning apm, backlight, buttons, etc.)
130// 130//
131// Comments? - mickeyl. 131// Comments? - mickeyl.
132 132
133void Zaurus::init(const QString& cpu_info) 133void Zaurus::init(const QString& cpu_info)
134{ 134{
135 // Set the time to wait until the system is realy suspended
136 // the delta between apm --suspend and sleeping
137 setAPMTimeOut( 15000 );
138
135 // generic distribution code already scanned /etc/issue at that point - 139 // generic distribution code already scanned /etc/issue at that point -
136 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 140 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
137 if ( d->m_sysverstr.contains( "embedix", false ) ) 141 if ( d->m_sysverstr.contains( "embedix", false ) )
138 { 142 {
139 d->m_vendorstr = "Sharp"; 143 d->m_vendorstr = "Sharp";
140 d->m_vendor = Vendor_Sharp; 144 d->m_vendor = Vendor_Sharp;
141 d->m_systemstr = "Zaurus"; 145 d->m_systemstr = "Zaurus";
142 d->m_system = System_Zaurus; 146 d->m_system = System_Zaurus;
143 m_embedix = true; 147 m_embedix = true;
144 } 148 }
145 else 149 else
146 { 150 {
147 d->m_vendorstr = "OpenZaurus Team"; 151 d->m_vendorstr = "OpenZaurus Team";
148 d->m_systemstr = "OpenZaurus"; 152 d->m_systemstr = "OpenZaurus";
149 d->m_system = System_OpenZaurus; 153 d->m_system = System_OpenZaurus;
150 // sysver already gathered 154 // sysver already gathered
151 155
152 // OpenZaurus sometimes uses the embedix kernel, check if this is one 156 // OpenZaurus sometimes uses the embedix kernel, check if this is one
153 FILE *uname = popen("uname -r", "r"); 157 FILE *uname = popen("uname -r", "r");
154 QFile f; 158 QFile f;
155 QString line; 159 QString line;
156 if ( f.open(IO_ReadOnly, uname) ) { 160 if ( f.open(IO_ReadOnly, uname) ) {
157 QTextStream ts ( &f ); 161 QTextStream ts ( &f );
158 line = ts. readLine(); 162 line = ts. readLine();
159 int loc = line. find ( "embedix" ); 163 int loc = line. find ( "embedix" );
160 if ( loc != -1 ) 164 if ( loc != -1 )
161 m_embedix = true; 165 m_embedix = true;
162 else 166 else
163 m_embedix = false; 167 m_embedix = false;
164 f.close(); 168 f.close();
165 } 169 }
166 pclose(uname); 170 pclose(uname);
167 } 171 }
168 172
169 // check the Zaurus model 173 // check the Zaurus model
170 QString model; 174 QString model;
171 int loc = cpu_info.find( ":" ); 175 int loc = cpu_info.find( ":" );
172 if ( loc != -1 ) 176 if ( loc != -1 )
173 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 177 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
174 else 178 else
175 model = cpu_info; 179 model = cpu_info;
176 180
177 if ( model == "SHARP Corgi" ) { 181 if ( model == "SHARP Corgi" ) {
178 d->m_model = Model_Zaurus_SLC7x0; 182 d->m_model = Model_Zaurus_SLC7x0;
179 d->m_modelstr = "Zaurus SL-C700"; 183 d->m_modelstr = "Zaurus SL-C700";
180 } else if ( model == "SHARP Shepherd" ) { 184 } else if ( model == "SHARP Shepherd" ) {
181 d->m_model = Model_Zaurus_SLC7x0; 185 d->m_model = Model_Zaurus_SLC7x0;
182 d->m_modelstr = "Zaurus SL-C750"; 186 d->m_modelstr = "Zaurus SL-C750";
@@ -437,128 +441,96 @@ bool Zaurus::setDisplayBrightness( int bright )
437 if ( fd ) 441 if ( fd )
438 { 442 {
439 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 443 res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
440 ::close( fd ); 444 ::close( fd );
441 } 445 }
442 } 446 }
443 else 447 else
444 { 448 {
445 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK ); 449 int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
446 if ( fd ) 450 if ( fd )
447 { 451 {
448 char buf[100]; 452 char buf[100];
449 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 453 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
450 res = ( ::write( fd, &buf[0], len ) == 0 ); 454 res = ( ::write( fd, &buf[0], len ) == 0 );
451 ::close( fd ); 455 ::close( fd );
452 } 456 }
453 } 457 }
454 return res; 458 return res;
455} 459}
456 460
457bool Zaurus::setDisplayStatus( bool on ) 461bool Zaurus::setDisplayStatus( bool on )
458{ 462{
459 bool res = false; 463 bool res = false;
460 if ( m_embedix ) 464 if ( m_embedix )
461 { 465 {
462 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 466 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
463 if ( fd ) 467 if ( fd )
464 { 468 {
465 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 469 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
466 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 470 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
467 ::close ( fd ); 471 ::close ( fd );
468 } 472 }
469 } 473 }
470 else 474 else
471 { 475 {
472 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); 476 int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
473 if ( fd ) 477 if ( fd )
474 { 478 {
475 char buf[10]; 479 char buf[10];
476 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 480 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
477 buf[1] = '\0'; 481 buf[1] = '\0';
478 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 482 res = ( ::write( fd, &buf[0], 2 ) == 0 );
479 ::close( fd ); 483 ::close( fd );
480 } 484 }
481 } 485 }
482 return res; 486 return res;
483} 487}
484 488
485bool Zaurus::suspend()
486{
487 qDebug("ODevice::suspend");
488 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
489 return false;
490
491 if ( d->m_model == Model_Unknown ) // better don't suspend on unknown devices
492 return false;
493
494 bool res = false;
495 ODevice::sendSuspendmsg();
496
497 struct timeval tvs, tvn;
498 ::gettimeofday ( &tvs, 0 );
499
500 ::sync(); // flush fs caches
501 res = ( ::system ( "apm --suspend" ) == 0 );
502
503 // This is needed because the apm implementation is asynchronous and we
504 // can not be sure when exactly the device is really suspended
505 if ( res ) {
506 do { // Yes, wait 15 seconds. This APM sucks big time.
507 ::usleep ( 200 * 1000 );
508 ::gettimeofday ( &tvn, 0 );
509 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
510 }
511
512 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
513 return res;
514}
515
516
517Transformation Zaurus::rotation() const 489Transformation Zaurus::rotation() const
518{ 490{
519 qDebug( "Zaurus::rotation()" ); 491 qDebug( "Zaurus::rotation()" );
520 Transformation rot; 492 Transformation rot;
521 493
522 switch ( d->m_model ) { 494 switch ( d->m_model ) {
523 case Model_Zaurus_SLC3000: // fallthrough 495 case Model_Zaurus_SLC3000: // fallthrough
524 case Model_Zaurus_SLC7x0: 496 case Model_Zaurus_SLC7x0:
525 { 497 {
526 OHingeStatus hs = readHingeSensor(); 498 OHingeStatus hs = readHingeSensor();
527 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); 499 qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
528 500
529 if ( m_embedix ) 501 if ( m_embedix )
530 { 502 {
531 if ( hs == CASE_PORTRAIT ) rot = Rot0; 503 if ( hs == CASE_PORTRAIT ) rot = Rot0;
532 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 504 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
533 else rot = Rot270; 505 else rot = Rot270;
534 } 506 }
535 else 507 else
536 { 508 {
537 if ( hs == CASE_PORTRAIT ) rot = Rot90; 509 if ( hs == CASE_PORTRAIT ) rot = Rot90;
538 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 510 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
539 else rot = Rot0; 511 else rot = Rot0;
540 } 512 }
541 } 513 }
542 break; 514 break;
543 case Model_Zaurus_SL6000: 515 case Model_Zaurus_SL6000:
544 case Model_Zaurus_SLB600: 516 case Model_Zaurus_SLB600:
545 case Model_Zaurus_SLA300: 517 case Model_Zaurus_SLA300:
546 case Model_Zaurus_SL5500: 518 case Model_Zaurus_SL5500:
547 case Model_Zaurus_SL5000: 519 case Model_Zaurus_SL5000:
548 default: 520 default:
549 rot = d->m_rotation; 521 rot = d->m_rotation;
550 break; 522 break;
551 } 523 }
552 524
553 return rot; 525 return rot;
554} 526}
555ODirection Zaurus::direction() const 527ODirection Zaurus::direction() const
556{ 528{
557 ODirection dir; 529 ODirection dir;
558 530
559 switch ( d->m_model ) { 531 switch ( d->m_model ) {
560 case Model_Zaurus_SLC3000: // fallthrough 532 case Model_Zaurus_SLC3000: // fallthrough
561 case Model_Zaurus_SLC7x0: { 533 case Model_Zaurus_SLC7x0: {
562 OHingeStatus hs = readHingeSensor(); 534 OHingeStatus hs = readHingeSensor();
563 if ( hs == CASE_PORTRAIT ) dir = CCW; 535 if ( hs == CASE_PORTRAIT ) dir = CCW;
564 else if ( hs == CASE_UNKNOWN ) dir = CCW; 536 else if ( hs == CASE_UNKNOWN ) dir = CCW;