summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -207,8 +207,13 @@ void Zaurus::init(const QString& cpu_info)
d->m_rotation = Rot270;
break;
}
m_leds[0] = Led_Off;
+
+ if ( m_embedix )
+ qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr );
+ else
+ qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
}
void Zaurus::initButtons()
{
@@ -219,8 +224,9 @@ void Zaurus::initButtons()
struct z_button * pz_buttons;
int buttoncount;
switch ( d->m_model ) {
+ case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC7x0:
pz_buttons = z_buttons_c700;
buttoncount = ARRAY_SIZE(z_buttons_c700);
break;
@@ -233,17 +239,14 @@ void Zaurus::initButtons()
for ( int i = 0; i < buttoncount; i++ ) {
struct z_button *zb = pz_buttons + i;
ODeviceButton b;
- b. setKeycode ( zb->code );
- b. setUserText ( QObject::tr ( "Button", zb->utext ));
- b. setPixmap ( Resource::loadPixmap ( zb->pix ));
- b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
- zb->fpressedaction ));
- b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ),
- zb->fheldaction ));
-
- d->m_buttons->append ( b );
+ b.setKeycode( zb->code );
+ b.setUserText( QObject::tr( "Button", zb->utext ));
+ b.setPixmap( Resource::loadPixmap( zb->pix ));
+ b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
+ b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
+ d->m_buttons->append( b );
}
reloadButtonMapping();
}
@@ -389,54 +392,88 @@ bool Zaurus::setSoftSuspend ( bool soft )
if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
(( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
- int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
+ int sources = ::ioctl( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
if ( sources >= 0 ) {
if ( soft )
sources &= ~APM_EVT_POWER_BUTTON;
else
sources |= APM_EVT_POWER_BUTTON;
- if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
+ if ( ::ioctl( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
res = true;
else
perror ( "APM_IOCGEVTSRC" );
}
else
perror ( "APM_IOCGEVTSRC" );
- ::close ( fd );
+ ::close( fd );
}
else
- perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
+ perror( "/dev/apm_bios or /dev/misc/apm_bios" );
return res;
}
+int Zaurus::displayBrightnessResolution() const
+{
+ int res = 1;
+ if (m_embedix)
+ {
+ int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
+ if ( fd )
+ {
+ int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
+ ::close( fd );
+ return value ? value : res;
+ }
+ }
+ else
+ {
+ int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
+ if ( fd )
+ {
+ char buf[100];
+ if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
+ ::close( fd );
+ }
+ }
+ return res;
+}
+
bool Zaurus::setDisplayBrightness( int bright )
{
//qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
bool res = false;
if ( bright > 255 ) bright = 255;
if ( bright < 0 ) bright = 0;
+ int numberOfSteps = displayBrightnessResolution();
+ int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
+
if ( m_embedix )
{
- int numberOfSteps = displayBrightnessResolution();
int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
if ( fd )
{
- int val = ( bright * numberOfSteps ) / 255;
- res = ( ::ioctl ( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
- ::close ( fd );
+ res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
+ ::close( fd );
}
}
else
{
- qDebug( "Zaurus::setDisplayBrightness: ODevice handling for non-embedix kernels not yet implemented" );
+ int fd = ::open( "/sys/class/backlight/corgi-bl/brightness", O_WRONLY|O_NONBLOCK );
+ if ( fd )
+ {
+ char buf[100];
+ int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
+ res = ( ::write( fd, &buf[0], len ) == 0 );
+ ::close( fd );
+ }
}
return res;
}
@@ -454,9 +491,17 @@ bool Zaurus::setDisplayStatus( bool on )
}
}
else
{
- qDebug( "Zaurus::setDisplayStatus: ODevice handling for non-embedix kernels not yet implemented" );
+ int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
+ if ( fd )
+ {
+ char buf[10];
+ buf[0] = on ? '0' : '1';
+ buf[1] = '\0';
+ res = ( ::write( fd, &buf[0], 2 ) == 0 );
+ ::close( fd );
+ }
}
return res;
}
@@ -557,23 +602,8 @@ ODirection Zaurus::direction() const
return dir;
}
-int Zaurus::displayBrightnessResolution() const
-{
- if (m_embedix)
- {
- int handle = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
- if ( handle != -1 ) return ::ioctl( handle, SHARP_FL_IOCTL_GET_STEP, 0 );
- else return 1;
- }
- else
- {
- qDebug( "Zaurus::displayBrightnessResolution: ODevice handling for non-embedix kernels not yet implemented" );
- return 1;
- }
-}
-
bool Zaurus::hasHingeSensor() const
{
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
@@ -45,9 +45,9 @@ SOURCES += ofilenotify.cpp
include( device/device.pro )
INTERFACES =
TARGET = opiecore2
-VERSION = 1.9.1
+VERSION = 1.9.2
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
!contains( platform, x11 ) {