-rw-r--r-- | libopie2/opiecore/device/odevice.h | 3 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 96 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 5 |
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 @@ -51,64 +51,65 @@ namespace Core{ class ODeviceData; /** * The available devices */ enum OModel { Model_Unknown, // = 0 Model_Series_Mask = 0xff000000, Model_iPAQ = ( 1 << 24 ), Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), Model_Jornada = ( 6 << 24 ), Model_Jornada_56x = ( Model_Jornada | 0x000001 ), Model_Zaurus = ( 2 << 24 ), Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), + Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x000007 ), Model_SIMpad = ( 3 << 24 ), Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), Model_Ramses = ( 4 << 24 ), Model_Ramses_All = ( Model_Ramses | 0xffffff ), Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), Model_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), Model_Yopy = ( 5 << 24 ), Model_Yopy_All = ( Model_Yopy | 0xffffff ), Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), Model_Beagle = ( 6 << 24 ), Model_Beagle_All = ( Model_Beagle | 0xffffff ), Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), Model_GenuineIntel = ( 7 << 24 ) }; /** @@ -332,48 +333,48 @@ private slots: void playingStopped(); protected: void addPreHandler(QWSServer::KeyboardFilter*aFilter); void remPreHandler(QWSServer::KeyboardFilter*aFilter); void reloadButtonMapping(); void changeMixerForAlarm( int mixer, const char* file, Sound *snd); /* ugly virtual hook */ virtual void virtual_hook( int id, void* data ); }; class ODeviceData { public: QString m_vendorstr; OVendor m_vendor; QString m_modelstr; OModel m_model; QString m_systemstr; OSystem m_system; QString m_sysverstr; Transformation m_rotation; ODirection m_direction; QValueList <ODeviceButton> *m_buttons; uint m_holdtime; QStrList *m_cpu_frequencies; - bool m_initializedButtonQcop : 1; + bool m_initializedButtonQcop : 1; /* values for changeMixerForAlarm */ int m_sound, m_vol, m_mixer; }; extern bool isQWS(); extern QCString makeChannel ( const char *str ); } } #endif 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 @@ -140,236 +140,246 @@ void Zaurus::init(const QString& cpu_info) QFile f; QString line; if ( f.open(IO_ReadOnly, uname) ) { QTextStream ts ( &f ); line = ts. readLine(); int loc = line. find ( "embedix" ); if ( loc != -1 ) m_embedix = true; else m_embedix = false; f.close(); } pclose(uname); } // check the Zaurus model QString model; int loc = cpu_info.find( ":" ); if ( loc != -1 ) model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); else model = cpu_info; if ( model == "SHARP Corgi" ) { d->m_model = Model_Zaurus_SLC7x0; d->m_modelstr = "Zaurus SL-C700"; } else if ( model == "SHARP Shepherd" ) { d->m_model = Model_Zaurus_SLC7x0; d->m_modelstr = "Zaurus SL-C750"; } else if ( model == "SHARP Husky" ) { d->m_model = Model_Zaurus_SLC7x0; d->m_modelstr = "Zaurus SL-C760 or SL-C860"; + } else if ( model == "SHARP Boxer" ) { + d->m_model = Model_Zaurus_SLC7x0; + d->m_modelstr = "Zaurus SL-C760 or SL-C860"; } else if ( model == "SHARP Poodle" ) { d->m_model = Model_Zaurus_SLB600; d->m_modelstr = "Zaurus SL-B500 or SL-5600"; } else if ( model == "Sharp-Collie" || model == "Collie" ) { d->m_model = Model_Zaurus_SL5500; d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; } else if ( model == "SHARP Tosa" ) { d->m_model = Model_Zaurus_SL6000; d->m_modelstr = "Zaurus SL-6000"; + } else if ( model == "SHARP Spitz" ) { + d->m_model = Model_Zaurus_SLC3000; + d->m_modelstr = "Zaurus SL-C3000"; } else { d->m_model = Model_Zaurus_SL5500; - d->m_modelstr = "Unkown Zaurus"; + d->m_modelstr = "Unknown Zaurus"; } // set initial rotation switch( d->m_model ) { case Model_Zaurus_SL6000: // fallthrough case Model_Zaurus_SLA300: d->m_rotation = Rot0; break; + case Model_Zaurus_SLC3000: // fallthrough case Model_Zaurus_SLC7x0: d->m_rotation = rotation(); d->m_direction = direction(); break; case Model_Zaurus_SLB600: // fallthrough + case Model_Zaurus_SL5000: // fallthrough case Model_Zaurus_SL5500: // fallthrough - case Model_Zaurus_SL5000: default: d->m_rotation = Rot270; break; } - m_leds [0] = Led_Off; + m_leds[0] = Led_Off; } void Zaurus::initButtons() { if ( d->m_buttons ) return; d->m_buttons = new QValueList <ODeviceButton>; struct z_button * pz_buttons; int buttoncount; switch ( d->m_model ) { case Model_Zaurus_SLC7x0: pz_buttons = z_buttons_c700; buttoncount = ARRAY_SIZE(z_buttons_c700); break; default: pz_buttons = z_buttons; buttoncount = ARRAY_SIZE(z_buttons); break; } 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 ); } reloadButtonMapping(); } typedef struct sharp_led_status { int which; /* select which LED status is wanted. */ int status; /* set new led status if you call SHARP_LED_SETSTATUS */ } sharp_led_status; void Zaurus::buzzer( int sound ) { #ifndef QT_NO_SOUND Sound *snd = 0; - // Not all devices have real sound - if ( d->m_model == Model_Zaurus_SLC7x0 - || d->m_model == Model_Zaurus_SLB600 - || d->m_model == Model_Zaurus_SL6000 ) { + // All devices except SL5500 have a DSP device + if ( d->m_model != Model_Zaurus_SL5000 + && d->m_model != Model_Zaurus_SL5500 ) { switch ( sound ){ case SHARP_BUZ_TOUCHSOUND: { static Sound touch_sound("touchsound"); snd = &touch_sound; - } + } break; case SHARP_BUZ_KEYSOUND: { static Sound key_sound( "keysound" ); snd = &key_sound; - } + } break; case SHARP_BUZ_SCHEDULE_ALARM: default: { static Sound alarm_sound("alarm"); snd = &alarm_sound; - } + } break; } } // If a soundname is defined, we expect that this device has // sound capabilities.. Otherwise we expect to have the buzzer // device.. if ( snd && snd->isFinished() ){ changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); snd->play(); } else if( !snd ) { int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); if ( fd >= 0 ) { ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); ::close ( fd ); } } #endif } void Zaurus::playAlarmSound() { buzzer( SHARP_BUZ_SCHEDULE_ALARM ); } void Zaurus::playTouchSound() { buzzer( SHARP_BUZ_TOUCHSOUND ); } void Zaurus::playKeySound() { buzzer( SHARP_BUZ_KEYSOUND ); } QValueList <OLed> Zaurus::ledList() const { QValueList <OLed> vl; vl << Led_Mail; return vl; } -QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const +QValueList <OLedState> Zaurus::ledStateList( OLed l ) const { QValueList <OLedState> vl; if ( l == Led_Mail ) vl << Led_Off << Led_On << Led_BlinkSlow; return vl; } -OLedState Zaurus::ledState ( OLed which ) const +OLedState Zaurus::ledState( OLed which ) const { if ( which == Led_Mail ) return m_leds [0]; else return Led_Off; } -bool Zaurus::setLedState ( OLed which, OLedState st ) +bool Zaurus::setLedState( OLed which, OLedState st ) { - if (!m_embedix) // Currently not supported on non_embedix kernels + // Currently not supported on non_embedix kernels + if (!m_embedix) + { + qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" ); return false; + } static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); if ( which == Led_Mail ) { if ( fd >= 0 ) { struct sharp_led_status leds; ::memset ( &leds, 0, sizeof( leds )); leds. which = SHARP_LED_MAIL_EXISTS; bool ok = true; switch ( st ) { case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; default : ok = false; } if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { m_leds [0] = st; return true; } } } return false; } bool Zaurus::setSoftSuspend ( bool soft ) { if (!m_embedix) { /* non-Embedix kernels dont have kernel autosuspend */ return ODevice::setSoftSuspend( soft ); } @@ -386,205 +396,217 @@ bool Zaurus::setSoftSuspend ( bool soft ) if ( soft ) sources &= ~APM_EVT_POWER_BUTTON; else sources |= APM_EVT_POWER_BUTTON; if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources res = true; else perror ( "APM_IOCGEVTSRC" ); } else perror ( "APM_IOCGEVTSRC" ); ::close ( fd ); } else perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 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; if ( m_embedix ) { int numberOfSteps = displayBrightnessResolution(); - int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); + 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 ); } } else { - qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); + qDebug( "Zaurus::setDisplayBrightness: ODevice handling for non-embedix kernels not yet implemented" ); } return res; } bool Zaurus::setDisplayStatus( bool on ) { bool res = false; if ( m_embedix ) { - int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); + int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK ); if ( fd ) { int ioctlnum = on ? SHARP_FL_IOCTL_ON : SHARP_FL_IOCTL_OFF; res = ( ::ioctl ( fd, ioctlnum, 0 ) == 0 ); ::close ( fd ); } } else { - qDebug( "ODevice handling for non-embedix kernels not yet implemented" ); + qDebug( "Zaurus::setDisplayStatus: ODevice handling for non-embedix kernels not yet implemented" ); } return res; -} +} bool Zaurus::suspend() { qDebug("ODevice::suspend"); if ( !isQWS( ) ) // only qwsserver is allowed to suspend return false; if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices return false; bool res = false; ODevice::sendSuspendmsg(); struct timeval tvs, tvn; ::gettimeofday ( &tvs, 0 ); ::sync(); // flush fs caches res = ( ::system ( "apm --suspend" ) == 0 ); // This is needed because the apm implementation is asynchronous and we // can not be sure when exactly the device is really suspended if ( res ) { do { // Yes, wait 15 seconds. This APM sucks big time. ::usleep ( 200 * 1000 ); ::gettimeofday ( &tvn, 0 ); } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); } QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); return res; } Transformation Zaurus::rotation() const { Transformation rot; int handle = 0; int retval = 0; switch ( d->m_model ) { + case Model_Zaurus_SLC3000: // fallthrough case Model_Zaurus_SLC7x0: handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); if (handle == -1) { return Rot270; } else { retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); ::close (handle); if (retval == 2 ) rot = Rot0; else rot = Rot270; } break; - case Model_Zaurus_SLA300: + case Model_Zaurus_SL6000: case Model_Zaurus_SLB600: + case Model_Zaurus_SLA300: case Model_Zaurus_SL5500: case Model_Zaurus_SL5000: default: rot = d->m_rotation; break; } return rot; } ODirection Zaurus::direction() const { ODirection dir; int handle = 0; int retval = 0; switch ( d->m_model ) { + case Model_Zaurus_SLC3000: // fallthrough case Model_Zaurus_SLC7x0: handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); if (handle == -1) { dir = CW; } else { retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION ); ::close (handle); if (retval == 2 ) dir = CCW; else dir = CW; } break; + case Model_Zaurus_SL6000: case Model_Zaurus_SLA300: case Model_Zaurus_SLB600: case Model_Zaurus_SL5500: case Model_Zaurus_SL5000: - default: dir = d->m_direction; + default: dir = d->m_direction; break; } 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( "ODevice handling for non-embedix kernels not yet implemented" ); + 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; + return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; } OHingeStatus Zaurus::readHingeSensor() { - int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); - if (handle == -1) - { - qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror - return CASE_UNKNOWN; - } - else + if (m_embedix) { - int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); - ::close (handle); - if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) + int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); + if (handle == -1) { - qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); - return static_cast<OHingeStatus>( retval ); + qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror + return CASE_UNKNOWN; } else { - qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); - return CASE_UNKNOWN; + int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); + ::close (handle); + if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) + { + qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); + return static_cast<OHingeStatus>( retval ); + } + else + { + qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); + return CASE_UNKNOWN; + } } } + else + { + qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); + return CASE_UNKNOWN; + } } 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 @@ -57,81 +57,82 @@ #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) // LED #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ // Rotation and Power Management #define SHARP_IOCTL_GET_ROTATION 0x413c #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) #define APM_EVT_POWER_BUTTON (1 << 0) // Brightness #define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl" #define SHARP_FL_IOCTL_ON 1 #define SHARP_FL_IOCTL_OFF 2 #define SHARP_FL_IOCTL_STEP_CONTRAST 100 #define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101 #define SHARP_FL_IOCTL_GET_STEP 102 namespace Opie { namespace Core { namespace Internal { + class Zaurus : public ODevice { protected: virtual void init(const QString&); virtual void initButtons(); public: virtual bool setSoftSuspend( bool soft ); virtual bool setDisplayBrightness( int b ); virtual bool setDisplayStatus( bool on ); virtual int displayBrightnessResolution() const; virtual void playAlarmSound(); virtual void playKeySound(); virtual void playTouchSound(); virtual QValueList <OLed> ledList() const; virtual QValueList <OLedState> ledStateList ( OLed led ) const; virtual OLedState ledState( OLed led ) const; virtual bool setLedState( OLed led, OLedState st ); virtual bool hasHingeSensor() const; virtual OHingeStatus readHingeSensor(); virtual bool suspend(); virtual Transformation rotation() const; virtual ODirection direction() const; protected: - virtual void buzzer ( int snd ); + virtual void buzzer( int snd ); - OLedState m_leds [1]; + OLedState m_leds[1]; bool m_embedix; }; struct z_button { Qt::Key code; char *utext; char *pix; char *fpressedservice; char *fpressedaction; char *fheldservice; char *fheldaction; }; } } } #endif |