-rw-r--r-- | libopie/odevice.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 71ed9e4..9373ef9 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -1448,96 +1448,109 @@ int iPAQ::displayBrightnessResolution ( ) const return 255; default: return 2; } } bool iPAQ::hasLightSensor ( ) const { return true; } int iPAQ::readLightSensor ( ) { int fd; int val = -1; if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { char buffer [8]; if ( ::read ( fd, buffer, 5 ) == 5 ) { char *endptr; buffer [4] = 0; val = ::strtol ( buffer + 2, &endptr, 16 ); if ( *endptr != 0 ) val = -1; } ::close ( fd ); } return val; } int iPAQ::lightSensorResolution ( ) const { return 256; } /************************************************** * * Zaurus * **************************************************/ // Check whether this device is the sharp zaurus.. +// 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, and C860) +// +// 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. + bool Zaurus::isZaurus() { // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ return true; } // On non-embedix kernels, we have to look closer. bool is_zaurus = false; QFile f ( "/proc/cpuinfo" ); if ( f. open ( IO_ReadOnly ) ) { QString model; QFile f ( "/proc/cpuinfo" ); QTextStream ts ( &f ); QString line; while( line = ts. readLine ( ) ) { if ( line. left ( 8 ) == "Hardware" ) break; } int loc = line. find ( ":" ); if ( loc != -1 ) model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); if ( model == "Sharp-Collie" || model == "Collie" || model == "SHARP Corgi" || model == "SHARP Shepherd" || model == "SHARP Poodle" || model == "SHARP Husky" ) is_zaurus = true; } return is_zaurus; } void Zaurus::init ( ) { d-> m_vendorstr = "Sharp"; d-> m_vendor = Vendor_Sharp; m_embedix = true; // Not openzaurus means: It has an embedix kernel ! // QFile f ( "/proc/filesystems" ); QString model; @@ -1578,96 +1591,97 @@ void Zaurus::init ( ) else { d-> m_systemstr = "Zaurus"; d-> m_system = System_Zaurus; } f. setName ( "/proc/cpuinfo" ); if ( f. open ( IO_ReadOnly ) ) { QTextStream ts ( &f ); QString line; while( line = ts. readLine ( ) ) { if ( line. left ( 8 ) == "Hardware" ) break; } int loc = line. find ( ":" ); if ( loc != -1 ) model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); } 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"; } 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 { d-> m_model = Model_Zaurus_SL5500; d-> m_modelstr = "Zaurus (Model unknown)"; } bool flipstate = false; switch ( d-> m_model ) { case Model_Zaurus_SLA300: d-> m_rotation = Rot0; break; case Model_Zaurus_SLC7x0: // Note: need to 1) set flipstate based on physical screen orientation // and 2) check to see if the user overrode the rotation direction // using appearance, and if so, remove that item from the Config to // ensure the rotate applet flips us back to the previous state. + // treke said he has patches for detecting the phys. so where are they, treke? -mickeyl. if ( flipstate ) { // 480x640 d-> m_rotation = Rot0; d-> m_direction = CW; } else { // 640x480 d-> m_rotation = Rot270; d-> m_direction = CCW; } break; case Model_Zaurus_SLB600: case Model_Zaurus_SL5500: case Model_Zaurus_SL5000: default: d-> m_rotation = Rot270; break; } 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 ), @@ -1891,96 +1905,99 @@ bool Zaurus::setLedState ( OLed which, OLedState st ) 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 ); } bool res = false; int fd; 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 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 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 ) { +// FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which +// is nice to use. Currently it exposes 16+1 levels. Implement this! +// (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.) bool res = false; int fd; if ( bright > 255 ) bright = 255; if ( bright < 0 ) bright = 0; if (m_embedix) { if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus if ( bright && !bl ) bl = 1; res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); ::close ( fd ); } } else { #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); ::close ( fd ); } } return res; } int Zaurus::displayBrightnessResolution ( ) const { if (m_embedix) return 5; else return 256; } /************************************************** * * SIMpad * **************************************************/ void SIMpad::init ( ) { d-> m_vendorstr = "SIEMENS"; d-> m_vendor = Vendor_SIEMENS; QFile f ( "/proc/hal/model" ); |