summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_zaurus.cpp
authormickeyl <mickeyl>2005-01-10 15:48:08 (UTC)
committer mickeyl <mickeyl>2005-01-10 15:48:08 (UTC)
commitf7b2f19ecbe3ae9151c1f9dc238bcfd019b3fdbe (patch) (unidiff)
tree218e33596db2dcf280df67d7f07e91f969cd0b91 /libopie2/opiecore/device/odevice_zaurus.cpp
parent6e3873eab783661c1d476106f588f2dab961dd21 (diff)
downloadopie-f7b2f19ecbe3ae9151c1f9dc238bcfd019b3fdbe.zip
opie-f7b2f19ecbe3ae9151c1f9dc238bcfd019b3fdbe.tar.gz
opie-f7b2f19ecbe3ae9151c1f9dc238bcfd019b3fdbe.tar.bz2
first shot at OpenZaurus HAL introduced by 2.6.10
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp78
1 files changed, 54 insertions, 24 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
@@ -210,2 +210,7 @@ void Zaurus::init(const QString& cpu_info)
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}
@@ -222,2 +227,3 @@ void Zaurus::initButtons()
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:
@@ -239,7 +245,4 @@ void Zaurus::initButtons()
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 ),
243 zb->fheldaction ));
244
245 d->m_buttons->append ( b ); 248 d->m_buttons->append ( b );
@@ -416,2 +419,28 @@ bool Zaurus::setSoftSuspend ( bool soft )
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 )
@@ -424,5 +453,7 @@ bool Zaurus::setDisplayBrightness( int bright )
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 );
@@ -430,3 +461,2 @@ bool Zaurus::setDisplayBrightness( int bright )
430 { 461 {
431 int val = ( bright * numberOfSteps ) / 255;
432 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 ); 462 res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
@@ -437,3 +467,10 @@ bool Zaurus::setDisplayBrightness( int bright )
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 }
@@ -457,3 +494,11 @@ bool Zaurus::setDisplayStatus( bool on )
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 }
@@ -560,17 +605,2 @@ ODirection Zaurus::direction() const
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