author | mickeyl <mickeyl> | 2005-02-06 22:53:53 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-02-06 22:53:53 (UTC) |
commit | ab32151cd8e85deb354bab04e25efb1f3f399dee (patch) (side-by-side diff) | |
tree | 66ab72d210bbc50c0e535986c61ca23f68efbfd1 | |
parent | ec33239c6edd9927fe2f82953fa48dec47d19567 (diff) | |
download | opie-ab32151cd8e85deb354bab04e25efb1f3f399dee.zip opie-ab32151cd8e85deb354bab04e25efb1f3f399dee.tar.gz opie-ab32151cd8e85deb354bab04e25efb1f3f399dee.tar.bz2 |
make autorotate also work on kernel 2.6
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 62 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 22 |
2 files changed, 22 insertions, 62 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 3d69614..2c5190c 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp @@ -226,202 +226,163 @@ void ODevice::init(const QString&) * This method initialises the button mapping */ void ODevice::initButtons() { if ( d->m_buttons ) return; qDebug ( "init Buttons" ); d->m_buttons = new QValueList <ODeviceButton>; for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { default_button *db = default_buttons + i; ODeviceButton b; b. setKeycode ( db->code ); b. setUserText ( QObject::tr ( "Button", db->utext )); b. setPixmap ( Resource::loadPixmap ( db->pix )); b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); d->m_buttons->append ( b ); } reloadButtonMapping(); } ODevice::~ODevice() { // we leak m_devicebuttons and m_cpu_frequency // but it's a singleton and it is not so importantant // -zecke delete d; } //#include <linux/apm_bios.h> #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) /** * This method will try to suspend the device * It only works if the user is the QWS Server and the apm application * is installed. * It tries to suspend and then waits some time cause some distributions * do have asynchronus apm implementations. * This method will either fail and return false or it'll suspend the * device and return once the device got woken up * * @return if the device got suspended */ bool 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 iPAQ apm implementation is asynchronous and we - // can not be sure when exactly the device is really suspended - // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. - - if ( res ) { - do { // wait at most 1.5 sec: either suspend didn't work or the device resumed - ::usleep ( 200 * 1000 ); - ::gettimeofday ( &tvn, 0 ); - } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); - } - - return res; + return false; // default implementation == unknown device or qvfb } //#include <linux/fb.h> better not rely on kernel headers in userspace ... #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 /* VESA Blanking Levels */ #define VESA_NO_BLANKING 0 #define VESA_VSYNC_SUSPEND 1 #define VESA_HSYNC_SUSPEND 2 #define VESA_POWERDOWN 3 /** * This sets the display on or off */ bool ODevice::setDisplayStatus ( bool on ) { - qDebug("ODevice::setDisplayStatus(%d)", on); - - if ( d->m_model == Model_Unknown ) - return false; - - bool res = false; - int fd; - -#ifdef QT_QWS_DEVFS - if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { -#else - if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { -#endif - res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); - ::close ( fd ); - } - return res; + qDebug( "ODevice::setDisplayStatus( %d ) - please override me.", on ); + return false; // don't do anything for unknown models } /** * This sets the display brightness * * @param b The brightness to be set on a scale from 0 to 255 * @return success or failure */ bool ODevice::setDisplayBrightness ( int b) { - Q_UNUSED( b ) + qDebug( "ODevice::setDisplayBrightness( %d ) - please override me.", b ); return false; } /** * - * @return Returns the number of steppings on the brightness slider - * in the Light-'n-Power settings. Values smaller zero and bigger + * @returns the number of steppings on the brightness slider + * in the Light-'n-Power settings. Values smaller than zero and bigger * than 255 do not make sense. * * \sa QSlider::setLineStep * \sa QSlider::setPageStep */ int ODevice::displayBrightnessResolution() const { + qDebug( "ODevice::displayBrightnessResolution() - please override me." ); return 16; } /** * This sets the display contrast * @param p The contrast to be set on a scale from 0 to 255 -* @return success or failure +* @returns success or failure */ bool ODevice::setDisplayContrast ( int p) { - Q_UNUSED( p ) + qDebug( "ODevice::setDisplayContrast( %d ) - please override me.", p ); return false; } /** -* @return return the max value for the brightness settings slider +* @returns the maximum value for the contrast settings slider * or 0 if the device doesn't support setting of a contrast */ int ODevice::displayContrastResolution() const { + qDebug( "ODevice::displayBrightnessResolution() - please override me." ); return 0; } /** * This returns the vendor as string * @return Vendor as QString */ QString ODevice::vendorString() const { return d->m_vendorstr; } /** * This returns the vendor as one of the values of OVendor * @return OVendor */ OVendor ODevice::vendor() const { return d->m_vendor; } /** * This returns the model as a string * @return A string representing the model */ QString ODevice::modelString() const { return d->m_modelstr; } /** * This does return the OModel used */ OModel ODevice::model() const { return d->m_model; } /** * This does return the systen name */ QString ODevice::systemString() const { return d->m_systemstr; } /** * Return System as OSystem value @@ -634,97 +595,96 @@ uint ODevice::buttonHoldTime() const * @return The devicebutton or 0l * @see ODeviceButton */ const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) { initButtons(); for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { if ( (*it). keycode() == code ) return &(*it); } return 0; } void ODevice::reloadButtonMapping() { if(!d->m_buttons) initButtons(); if(!d->m_initializedButtonQcop) { QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), this,SLOT(systemMessage(const QCString&,const QByteArray&))); d->m_initializedButtonQcop = true; } Config cfg ( "ButtonSettings" ); for ( uint i = 0; i < d->m_buttons->count(); i++ ) { ODeviceButton &b = ( *d->m_buttons ) [i]; QString group = "Button" + QString::number ( i ); QCString pch, hch; QCString pm, hm; QByteArray pdata, hdata; if ( cfg. hasGroup ( group )) { cfg. setGroup ( group ); pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); } b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); - b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); } } void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) { initButtons(); QString mb_chan; if ( button >= (int) d->m_buttons->count()) return; ODeviceButton &b = ( *d->m_buttons ) [button]; b. setPressedAction ( action ); mb_chan=b. pressedAction(). channel(); Config buttonFile ( "ButtonSettings" ); buttonFile. setGroup ( "Button" + QString::number ( button )); buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) { initButtons(); if ( button >= (int) d->m_buttons->count()) return; ODeviceButton &b = ( *d->m_buttons ) [button]; b. setHeldAction ( action ); Config buttonFile ( "ButtonSettings" ); buttonFile. setGroup ( "Button" + QString::number ( button )); buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 7377965..82e127e 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp @@ -57,108 +57,108 @@ using namespace Opie::Core; using namespace Opie::Core::Internal; struct z_button z_buttons [] = { { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), "devicebuttons/z_calendar", "datebook", "nextView()", "today", "raise()" }, { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), "devicebuttons/z_contact", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), "devicebuttons/z_home", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), "devicebuttons/z_menu", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), "devicebuttons/z_mail", "opiemail", "raise()", "opiemail", "newMail()" }, }; struct z_button z_buttons_c700 [] = { { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), "devicebuttons/z_calendar", "datebook", "nextView()", "today", "raise()" }, { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), "devicebuttons/z_contact", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), "devicebuttons/z_home", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), "devicebuttons/z_menu", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), "devicebuttons/z_mail", "opiemail", "raise()", "opiemail", "newMail()" }, - { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Display Rotate"), - "devicebuttons/z_hinge", + { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), + "devicebuttons/z_hinge1", "QPE/Rotation", "rotateDefault()", - "QPE/Dummy", "doNothing()" }, - { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Display Rotate"), - "devicebuttons/z_hinge", + "QPE/Rotation", "rotateDefault()" }, + { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), + "devicebuttons/z_hinge2", "QPE/Rotation", "rotateDefault()", - "QPE/Dummy", "doNothing()" }, - { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Display Rotate"), - "devicebuttons/z_hinge", + "QPE/Rotation", "rotateDefault()" }, + { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), + "devicebuttons/z_hinge3", "QPE/Rotation", "rotateDefault()", - "QPE/Dummy", "doNothing()" }, + "QPE/Rotation", "rotateDefault()" }, }; // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus // class up into individual classes. We need three classes // // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) // // Only question right now is: Do we really need to do it? Because as soon // as the OpenZaurus kernel is ready, there will be a unified interface for all // Zaurus models (concerning apm, backlight, buttons, etc.) // // Comments? - mickeyl. void Zaurus::init(const QString& cpu_info) { // generic distribution code already scanned /etc/issue at that point - // embedix releases contain "Embedix <version> | Linux for Embedded Devices" if ( d->m_sysverstr.contains( "embedix", false ) ) { d->m_vendorstr = "Sharp"; d->m_vendor = Vendor_Sharp; d->m_systemstr = "Zaurus"; d->m_system = System_Zaurus; m_embedix = true; } else { d->m_vendorstr = "OpenZaurus Team"; d->m_systemstr = "OpenZaurus"; d->m_system = System_OpenZaurus; // sysver already gathered // OpenZaurus sometimes uses the embedix kernel, check if this is one FILE *uname = popen("uname -r", "r"); 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(); @@ -443,143 +443,143 @@ bool Zaurus::setDisplayBrightness( int bright ) else { 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; } bool Zaurus::setDisplayStatus( bool on ) { bool res = false; if ( m_embedix ) { 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 { int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK ); if ( fd ) { char buf[10]; buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; buf[1] = '\0'; res = ( ::write( fd, &buf[0], 2 ) == 0 ); ::close( fd ); } } 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 + if ( d->m_model == Model_Unknown ) // better don't suspend on unknown 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 { qDebug( "Zaurus::rotation()" ); Transformation rot; switch ( d->m_model ) { case Model_Zaurus_SLC3000: // fallthrough case Model_Zaurus_SLC7x0: { OHingeStatus hs = readHingeSensor(); qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs ); if ( m_embedix ) { if ( hs == CASE_PORTRAIT ) rot = Rot0; else if ( hs == CASE_UNKNOWN ) rot = Rot0; else rot = Rot270; } else { - if ( hs == CASE_PORTRAIT ) rot = Rot270; + if ( hs == CASE_PORTRAIT ) rot = Rot90; else if ( hs == CASE_UNKNOWN ) rot = Rot0; else rot = Rot0; } } break; 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; switch ( d->m_model ) { case Model_Zaurus_SLC3000: // fallthrough case Model_Zaurus_SLC7x0: { OHingeStatus hs = readHingeSensor(); if ( hs == CASE_PORTRAIT ) dir = CCW; else if ( hs == CASE_UNKNOWN ) 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; break; } return dir; } bool Zaurus::hasHingeSensor() const { return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; } OHingeStatus Zaurus::readHingeSensor() const |