summaryrefslogtreecommitdiff
path: root/libopie2/opiecore
authormickeyl <mickeyl>2005-01-10 14:58:14 (UTC)
committer mickeyl <mickeyl>2005-01-10 14:58:14 (UTC)
commit6e3873eab783661c1d476106f588f2dab961dd21 (patch) (unidiff)
tree14cac38bca6da58545ce4a882f17bc4ad4b98228 /libopie2/opiecore
parent2e897183d1b9373cefaf19dfb272bf1e7bfe50c7 (diff)
downloadopie-6e3873eab783661c1d476106f588f2dab961dd21.zip
opie-6e3873eab783661c1d476106f588f2dab961dd21.tar.gz
opie-6e3873eab783661c1d476106f588f2dab961dd21.tar.bz2
make the SL-C3000 (Sharp Spitz) known to ODevice
Diffstat (limited to 'libopie2/opiecore') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.h3
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp96
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h5
3 files changed, 64 insertions, 40 deletions
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 93d7d22..bbc32fa 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -77,12 +77,13 @@ enum OModel {
77 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 77 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
78 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 78 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
79 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 79 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
80 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 80 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
81 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 81 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
82 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), 82 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ),
83 Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x000007 ),
83 84
84 Model_SIMpad = ( 3 << 24 ), 85 Model_SIMpad = ( 3 << 24 ),
85 86
86 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 87 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
87 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 88 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
88 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 89 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
@@ -358,13 +359,13 @@ class ODeviceData {
358 Transformation m_rotation; 359 Transformation m_rotation;
359 ODirection m_direction; 360 ODirection m_direction;
360 361
361 QValueList <ODeviceButton> *m_buttons; 362 QValueList <ODeviceButton> *m_buttons;
362 uint m_holdtime; 363 uint m_holdtime;
363 QStrList *m_cpu_frequencies; 364 QStrList *m_cpu_frequencies;
364 boolm_initializedButtonQcop : 1; 365 bool m_initializedButtonQcop : 1;
365 366
366 /* values for changeMixerForAlarm */ 367 /* values for changeMixerForAlarm */
367 int m_sound, m_vol, m_mixer; 368 int m_sound, m_vol, m_mixer;
368}; 369};
369 370
370extern bool isQWS(); 371extern bool isQWS();
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index fb23e1d..75a2fdc 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -166,44 +166,51 @@ void Zaurus::init(const QString& cpu_info)
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" ) {
173 d->m_model = Model_Zaurus_SLC7x0;
174 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
172 } else if ( model == "SHARP Poodle" ) { 175 } else if ( model == "SHARP Poodle" ) {
173 d->m_model = Model_Zaurus_SLB600; 176 d->m_model = Model_Zaurus_SLB600;
174 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 177 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
175 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 178 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
176 d->m_model = Model_Zaurus_SL5500; 179 d->m_model = Model_Zaurus_SL5500;
177 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 180 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
178 } else if ( model == "SHARP Tosa" ) { 181 } else if ( model == "SHARP Tosa" ) {
179 d->m_model = Model_Zaurus_SL6000; 182 d->m_model = Model_Zaurus_SL6000;
180 d->m_modelstr = "Zaurus SL-6000"; 183 d->m_modelstr = "Zaurus SL-6000";
184 } else if ( model == "SHARP Spitz" ) {
185 d->m_model = Model_Zaurus_SLC3000;
186 d->m_modelstr = "Zaurus SL-C3000";
181 } else { 187 } else {
182 d->m_model = Model_Zaurus_SL5500; 188 d->m_model = Model_Zaurus_SL5500;
183 d->m_modelstr = "Unkown Zaurus"; 189 d->m_modelstr = "Unknown Zaurus";
184 } 190 }
185 191
186 // set initial rotation 192 // set initial rotation
187 switch( d->m_model ) { 193 switch( d->m_model ) {
188 case Model_Zaurus_SL6000: // fallthrough 194 case Model_Zaurus_SL6000: // fallthrough
189 case Model_Zaurus_SLA300: 195 case Model_Zaurus_SLA300:
190 d->m_rotation = Rot0; 196 d->m_rotation = Rot0;
191 break; 197 break;
198 case Model_Zaurus_SLC3000: // fallthrough
192 case Model_Zaurus_SLC7x0: 199 case Model_Zaurus_SLC7x0:
193 d->m_rotation = rotation(); 200 d->m_rotation = rotation();
194 d->m_direction = direction(); 201 d->m_direction = direction();
195 break; 202 break;
196 case Model_Zaurus_SLB600: // fallthrough 203 case Model_Zaurus_SLB600: // fallthrough
204 case Model_Zaurus_SL5000: // fallthrough
197 case Model_Zaurus_SL5500: // fallthrough 205 case Model_Zaurus_SL5500: // fallthrough
198 case Model_Zaurus_SL5000:
199 default: 206 default:
200 d->m_rotation = Rot270; 207 d->m_rotation = Rot270;
201 break; 208 break;
202 } 209 }
203 m_leds [0] = Led_Off; 210 m_leds[0] = Led_Off;
204} 211}
205 212
206void Zaurus::initButtons() 213void Zaurus::initButtons()
207{ 214{
208 if ( d->m_buttons ) 215 if ( d->m_buttons )
209 return; 216 return;
@@ -250,33 +257,32 @@ typedef struct sharp_led_status {
250 257
251void Zaurus::buzzer( int sound ) 258void Zaurus::buzzer( int sound )
252{ 259{
253#ifndef QT_NO_SOUND 260#ifndef QT_NO_SOUND
254 Sound *snd = 0; 261 Sound *snd = 0;
255 262
256 // Not all devices have real sound 263 // All devices except SL5500 have a DSP device
257 if ( d->m_model == Model_Zaurus_SLC7x0 264 if ( d->m_model != Model_Zaurus_SL5000
258 || d->m_model == Model_Zaurus_SLB600 265 && d->m_model != Model_Zaurus_SL5500 ) {
259 || d->m_model == Model_Zaurus_SL6000 ) {
260 266
261 switch ( sound ){ 267 switch ( sound ){
262 case SHARP_BUZ_TOUCHSOUND: { 268 case SHARP_BUZ_TOUCHSOUND: {
263 static Sound touch_sound("touchsound"); 269 static Sound touch_sound("touchsound");
264 snd = &touch_sound; 270 snd = &touch_sound;
265 } 271 }
266 break; 272 break;
267 case SHARP_BUZ_KEYSOUND: { 273 case SHARP_BUZ_KEYSOUND: {
268 static Sound key_sound( "keysound" ); 274 static Sound key_sound( "keysound" );
269 snd = &key_sound; 275 snd = &key_sound;
270 } 276 }
271 break; 277 break;
272 case SHARP_BUZ_SCHEDULE_ALARM: 278 case SHARP_BUZ_SCHEDULE_ALARM:
273 default: { 279 default: {
274 static Sound alarm_sound("alarm"); 280 static Sound alarm_sound("alarm");
275 snd = &alarm_sound; 281 snd = &alarm_sound;
276 } 282 }
277 break; 283 break;
278 } 284 }
279 } 285 }
280 286
281 // If a soundname is defined, we expect that this device has 287 // If a soundname is defined, we expect that this device has
282 // sound capabilities.. Otherwise we expect to have the buzzer 288 // sound capabilities.. Otherwise we expect to have the buzzer
@@ -317,33 +323,37 @@ QValueList <OLed> Zaurus::ledList() const
317{ 323{
318 QValueList <OLed> vl; 324 QValueList <OLed> vl;
319 vl << Led_Mail; 325 vl << Led_Mail;
320 return vl; 326 return vl;
321} 327}
322 328
323QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 329QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
324{ 330{
325 QValueList <OLedState> vl; 331 QValueList <OLedState> vl;
326 332
327 if ( l == Led_Mail ) 333 if ( l == Led_Mail )
328 vl << Led_Off << Led_On << Led_BlinkSlow; 334 vl << Led_Off << Led_On << Led_BlinkSlow;
329 return vl; 335 return vl;
330} 336}
331 337
332OLedState Zaurus::ledState ( OLed which ) const 338OLedState Zaurus::ledState( OLed which ) const
333{ 339{
334 if ( which == Led_Mail ) 340 if ( which == Led_Mail )
335 return m_leds [0]; 341 return m_leds [0];
336 else 342 else
337 return Led_Off; 343 return Led_Off;
338} 344}
339 345
340bool Zaurus::setLedState ( OLed which, OLedState st ) 346bool Zaurus::setLedState( OLed which, OLedState st )
341{ 347{
342 if (!m_embedix) // Currently not supported on non_embedix kernels 348 // Currently not supported on non_embedix kernels
349 if (!m_embedix)
350 {
351 qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
343 return false; 352 return false;
353 }
344 354
345 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 355 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
346 356
347 if ( which == Led_Mail ) { 357 if ( which == Led_Mail ) {
348 if ( fd >= 0 ) { 358 if ( fd >= 0 ) {
349 struct sharp_led_status leds; 359 struct sharp_led_status leds;
@@ -412,46 +422,46 @@ bool Zaurus::setDisplayBrightness( int bright )
412 if ( bright > 255 ) bright = 255; 422 if ( bright > 255 ) bright = 255;
413 if ( bright < 0 ) bright = 0; 423 if ( bright < 0 ) bright = 0;
414 424
415 if ( m_embedix ) 425 if ( m_embedix )
416 { 426 {
417 int numberOfSteps = displayBrightnessResolution(); 427 int numberOfSteps = displayBrightnessResolution();
418 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 428 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
419 if ( fd ) 429 if ( fd )
420 { 430 {
421 int val = ( bright * numberOfSteps ) / 255; 431 int val = ( bright * numberOfSteps ) / 255;
422 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 432 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
423 ::close ( fd ); 433 ::close ( fd );
424 } 434 }
425 } 435 }
426 else 436 else
427 { 437 {
428 qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); 438 qDebug( "Zaurus::setDisplayBrightness: ODevice handling for non-embedix kernels not yet implemented" );
429 } 439 }
430 return res; 440 return res;
431} 441}
432 442
433bool Zaurus::setDisplayStatus( bool on ) 443bool Zaurus::setDisplayStatus( bool on )
434{ 444{
435 bool res = false; 445 bool res = false;
436 if ( m_embedix ) 446 if ( m_embedix )
437 { 447 {
438 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); 448 int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
439 if ( fd ) 449 if ( fd )
440 { 450 {
441 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; 451 int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF;
442 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); 452 res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 );
443 ::close ( fd ); 453 ::close ( fd );
444 } 454 }
445 } 455 }
446 else 456 else
447 { 457 {
448 qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); 458 qDebug( "Zaurus::setDisplayStatus: ODevice handling for non-embedix kernels not yet implemented" );
449 } 459 }
450 return res; 460 return res;
451} 461}
452 462
453bool Zaurus::suspend() 463bool Zaurus::suspend()
454{ 464{
455 qDebug("ODevice::suspend"); 465 qDebug("ODevice::suspend");
456 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 466 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
457 return false; 467 return false;
@@ -486,12 +496,13 @@ Transformation Zaurus::rotation() const
486{ 496{
487 Transformation rot; 497 Transformation rot;
488 int handle = 0; 498 int handle = 0;
489 int retval = 0; 499 int retval = 0;
490 500
491 switch ( d->m_model ) { 501 switch ( d->m_model ) {
502 case Model_Zaurus_SLC3000: // fallthrough
492 case Model_Zaurus_SLC7x0: 503 case Model_Zaurus_SLC7x0:
493 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 504 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
494 if (handle == -1) { 505 if (handle == -1) {
495 return Rot270; 506 return Rot270;
496 } else { 507 } else {
497 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 508 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
@@ -500,14 +511,15 @@ Transformation Zaurus::rotation() const
500 if (retval == 2 ) 511 if (retval == 2 )
501 rot = Rot0; 512 rot = Rot0;
502 else 513 else
503 rot = Rot270; 514 rot = Rot270;
504 } 515 }
505 break; 516 break;
506 case Model_Zaurus_SLA300: 517 case Model_Zaurus_SL6000:
507 case Model_Zaurus_SLB600: 518 case Model_Zaurus_SLB600:
519 case Model_Zaurus_SLA300:
508 case Model_Zaurus_SL5500: 520 case Model_Zaurus_SL5500:
509 case Model_Zaurus_SL5000: 521 case Model_Zaurus_SL5000:
510 default: 522 default:
511 rot = d->m_rotation; 523 rot = d->m_rotation;
512 break; 524 break;
513 } 525 }
@@ -517,12 +529,13 @@ Transformation Zaurus::rotation() const
517ODirection Zaurus::direction() const 529ODirection Zaurus::direction() const
518{ 530{
519 ODirection dir; 531 ODirection dir;
520 int handle = 0; 532 int handle = 0;
521 int retval = 0; 533 int retval = 0;
522 switch ( d->m_model ) { 534 switch ( d->m_model ) {
535 case Model_Zaurus_SLC3000: // fallthrough
523 case Model_Zaurus_SLC7x0: 536 case Model_Zaurus_SLC7x0:
524 handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); 537 handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK );
525 if (handle == -1) { 538 if (handle == -1) {
526 dir = CW; 539 dir = CW;
527 } else { 540 } else {
528 retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); 541 retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION );
@@ -530,17 +543,18 @@ ODirection Zaurus::direction() const
530 if (retval == 2 ) 543 if (retval == 2 )
531 dir = CCW; 544 dir = CCW;
532 else 545 else
533 dir = CW; 546 dir = CW;
534 } 547 }
535 break; 548 break;
549 case Model_Zaurus_SL6000:
536 case Model_Zaurus_SLA300: 550 case Model_Zaurus_SLA300:
537 case Model_Zaurus_SLB600: 551 case Model_Zaurus_SLB600:
538 case Model_Zaurus_SL5500: 552 case Model_Zaurus_SL5500:
539 case Model_Zaurus_SL5000: 553 case Model_Zaurus_SL5000:
540 default: dir = d->m_direction; 554 default: dir = d->m_direction;
541 break; 555 break;
542 } 556 }
543 return dir; 557 return dir;
544 558
545} 559}
546 560
@@ -551,40 +565,48 @@ int Zaurus::displayBrightnessResolution() const
551 int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK ); 565 int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
552 if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 ); 566 if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 );
553 else return 1; 567 else return 1;
554 } 568 }
555 else 569 else
556 { 570 {
557 qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); 571 qDebug( "Zaurus::displayBrightnessResolution: ODevice handling for non-embedix kernels not yet implemented" );
558 return 1; 572 return 1;
559 } 573 }
560} 574}
561 575
562bool Zaurus::hasHingeSensor() const 576bool Zaurus::hasHingeSensor() const
563{ 577{
564 return d->m_model == Model_Zaurus_SLC7x0; 578 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
565} 579}
566 580
567OHingeStatus Zaurus::readHingeSensor() 581OHingeStatus Zaurus::readHingeSensor()
568{ 582{
569 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 583 if (m_embedix)
570 if (handle == -1)
571 {
572 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
573 return CASE_UNKNOWN;
574 }
575 else
576 { 584 {
577 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 585 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
578 ::close (handle); 586 if (handle == -1)
579 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
580 { 587 {
581 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 588 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
582 return static_cast<OHingeStatus>( retval ); 589 return CASE_UNKNOWN;
583 } 590 }
584 else 591 else
585 { 592 {
586 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 593 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
587 return CASE_UNKNOWN; 594 ::close (handle);
595 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
596 {
597 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
598 return static_cast<OHingeStatus>( retval );
599 }
600 else
601 {
602 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
603 return CASE_UNKNOWN;
604 }
588 } 605 }
589 } 606 }
607 else
608 {
609 qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" );
610 return CASE_UNKNOWN;
611 }
590} 612}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index 37ab876..ed9cf67 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -83,12 +83,13 @@
83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 83#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
84#define SHARP_FL_IOCTL_GET_STEP 102 84#define SHARP_FL_IOCTL_GET_STEP 102
85 85
86namespace Opie { 86namespace Opie {
87namespace Core { 87namespace Core {
88namespace Internal { 88namespace Internal {
89
89class Zaurus : public ODevice 90class Zaurus : public ODevice
90{ 91{
91 protected: 92 protected:
92 virtual void init(const QString&); 93 virtual void init(const QString&);
93 virtual void initButtons(); 94 virtual void initButtons();
94 95
@@ -113,15 +114,15 @@ class Zaurus : public ODevice
113 114
114 virtual bool suspend(); 115 virtual bool suspend();
115 virtual Transformation rotation() const; 116 virtual Transformation rotation() const;
116 virtual ODirection direction() const; 117 virtual ODirection direction() const;
117 118
118 protected: 119 protected:
119 virtual void buzzer ( int snd ); 120 virtual void buzzer( int snd );
120 121
121 OLedState m_leds [1]; 122 OLedState m_leds[1];
122 bool m_embedix; 123 bool m_embedix;
123}; 124};
124 125
125struct z_button { 126struct z_button {
126 Qt::Key code; 127 Qt::Key code;
127 char *utext; 128 char *utext;