summaryrefslogtreecommitdiff
authoreilers <eilers>2003-08-10 17:19:47 (UTC)
committer eilers <eilers>2003-08-10 17:19:47 (UTC)
commit538f7adcd133861f795a133a23ca184a47f81139 (patch) (side-by-side diff)
tree9c4614f3bfa0e0430a41a79bcbe931ae0b9573c6
parent0024cf8df3d576ac4fa5921b041d0fdbd17079e1 (diff)
downloadopie-538f7adcd133861f795a133a23ca184a47f81139.zip
opie-538f7adcd133861f795a133a23ca184a47f81139.tar.gz
opie-538f7adcd133861f795a133a23ca184a47f81139.tar.bz2
Experimental odevice:
This enables real sound support for all openzaurus kernels and devices.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp142
1 files changed, 112 insertions, 30 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index a134810..3ff029e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -129,2 +129,4 @@ public:
+ static bool isZaurus();
+
protected:
@@ -133,2 +135,3 @@ protected:
OLedState m_leds [1];
+ bool m_embedix;
};
@@ -385,6 +388,6 @@ ODevice *ODevice::inst ( )
- if ( !dev ) {
+ if ( !dev ) {
if ( QFile::exists ( "/proc/hal/model" ))
dev = new iPAQ ( );
- else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
+ else if ( Zaurus::isZaurus() )
dev = new Zaurus ( );
@@ -1322,2 +1325,39 @@ int iPAQ::lightSensorResolution ( ) const
+// Check whether this device is the sharp zaurus..
+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 kenrnels, we have too 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"
+ )
+ is_zaurus = true;
+
+ }
+ return is_zaurus;
+}
@@ -1328,2 +1368,3 @@ void Zaurus::init ( )
d-> m_vendor = Vendor_Sharp;
+ m_embedix = true; // Not openzaurus means: It has an embedix kernel !
@@ -1344,5 +1385,2 @@ void Zaurus::init ( )
- // f. close ( );
-
- // f. setName ( "/etc/oz_version" );
if ( f. open ( IO_ReadOnly )) {
@@ -1352,2 +1390,18 @@ void Zaurus::init ( )
}
+
+ // Openzaurus sometimes uses the embedix kernel!
+ // => Check whether this is an embedix kernel
+ FILE *uname = popen("uname -r", "r");
+ 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);
}
@@ -1377,6 +1431,6 @@ void Zaurus::init ( )
d-> m_modelstr = "Zaurus SL-C750";
- }else if ( model == "SHARP Poodle" ) {
+ } 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" ) {
+ } else if ( model == "Sharp-Collie" || model == "Collie" ) {
d-> m_model = Model_Zaurus_SL5500;
@@ -1445,4 +1499,6 @@ void Zaurus::initButtons ( )
b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
- b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
- b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
+ b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ),
+ zb-> fpressedaction ));
+ b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ),
+ zb-> fheldaction ));
@@ -1454,3 +1510,4 @@ void Zaurus::initButtons ( )
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
- connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
+ connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )),
+ this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
}
@@ -1526,12 +1583,11 @@ void Zaurus::buzzer ( int sound )
{
- // Not all devices have real sound.
#ifndef QT_NO_SOUND
- switch ( d-> m_model ) {
- case Model_Zaurus_SLC700:{
- int fd;
- int vol;
- bool vol_reset = false;
+ QString soundname;
+
+ // Not all devices have real sound. But I expect
+ // that Openzaurus now has a sound driver which
+ // I will use instead the buzzer...
+ if ( ( d->m_model == Model_Zaurus_SLC700 )
+ || d->m_system == System_OpenZaurus ){
- QString soundname;
-
switch ( sound ){
@@ -1550,2 +1606,11 @@ void Zaurus::buzzer ( int sound )
}
+ }
+
+ // If a soundname is defined, we expect that this device has
+ // sound capabilities.. Otherwise we expect to have the buzzer
+ // device..
+ if ( !soundname.isEmpty() ){
+ int fd;
+ int vol;
+ bool vol_reset = false;
@@ -1579,5 +1644,3 @@ void Zaurus::buzzer ( int sound )
}
- break;
- }
- default:{ // Devices with buzzer
+ } else {
int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
@@ -1588,4 +1651,4 @@ void Zaurus::buzzer ( int sound )
}
- }
- }
+
+ }
#endif
@@ -1636,2 +1699,5 @@ bool Zaurus::setLedState ( OLed which, OLedState st )
{
+ if (!m_embedix) // Currently not supported on non_embedix kernels
+ return false;
+
static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
@@ -1663,2 +1729,7 @@ bool Zaurus::setSoftSuspend ( bool soft )
{
+ if (!m_embedix) {
+ /* non-Embedix kernels dont have kernel autosuspend */
+ return ODevice::setSoftSuspend( soft );
+ }
+
bool res = false;
@@ -1704,8 +1775,16 @@ bool Zaurus::setDisplayBrightness ( int bright )
- 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 );
+ 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 );
+ }
}
@@ -1717,3 +1796,6 @@ int Zaurus::displayBrightnessResolution ( ) const
{
- return 5;
+ if (m_embedix)
+ return 5;
+ else
+ return 256;
}