summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp98
-rw-r--r--libopie2/opiecore/opiecore.pro2
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
@@ -208,6 +208,11 @@ void Zaurus::init(const QString& cpu_info)
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
213void Zaurus::initButtons() 218void Zaurus::initButtons()
@@ -220,6 +225,7 @@ void Zaurus::initButtons()
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);
@@ -234,15 +240,12 @@ void Zaurus::initButtons()
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();
@@ -390,7 +393,7 @@ bool Zaurus::setSoftSuspend ( bool soft )
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 )
@@ -398,7 +401,7 @@ bool Zaurus::setSoftSuspend ( bool soft )
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" );
@@ -406,14 +409,40 @@ bool Zaurus::setSoftSuspend ( bool soft )
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
420int 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
417bool Zaurus::setDisplayBrightness( int bright ) 446bool Zaurus::setDisplayBrightness( int bright )
418{ 447{
419 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 448 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
@@ -422,20 +451,28 @@ bool Zaurus::setDisplayBrightness( int bright )
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}
@@ -455,7 +492,15 @@ bool Zaurus::setDisplayStatus( bool on )
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}
@@ -558,21 +603,6 @@ ODirection Zaurus::direction() const
558 603
559} 604}
560 605
561int 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
576bool Zaurus::hasHingeSensor() const 606bool 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;
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
@@ -46,7 +46,7 @@ include( device/device.pro )
46 46
47INTERFACES = 47INTERFACES =
48TARGET = opiecore2 48TARGET = opiecore2
49VERSION = 1.9.1 49VERSION = 1.9.2
50INCLUDEPATH += $(OPIEDIR)/include 50INCLUDEPATH += $(OPIEDIR)/include
51DEPENDPATH += $(OPIEDIR)/include 51DEPENDPATH += $(OPIEDIR)/include
52 52