author | eilers <eilers> | 2003-08-10 17:19:47 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-10 17:19:47 (UTC) |
commit | 538f7adcd133861f795a133a23ca184a47f81139 (patch) (unidiff) | |
tree | 9c4614f3bfa0e0430a41a79bcbe931ae0b9573c6 | |
parent | 0024cf8df3d576ac4fa5921b041d0fdbd17079e1 (diff) | |
download | opie-538f7adcd133861f795a133a23ca184a47f81139.zip opie-538f7adcd133861f795a133a23ca184a47f81139.tar.gz opie-538f7adcd133861f795a133a23ca184a47f81139.tar.bz2 |
Experimental odevice:
This enables real sound support for all openzaurus kernels and devices.
-rw-r--r-- | libopie/odevice.cpp | 142 |
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 | |||
@@ -128,8 +128,11 @@ public: | |||
128 | virtual bool setLedState ( OLed led, OLedState st ); | 128 | virtual bool setLedState ( OLed led, OLedState st ); |
129 | 129 | ||
130 | static bool isZaurus(); | ||
131 | |||
130 | protected: | 132 | protected: |
131 | virtual void buzzer ( int snd ); | 133 | virtual void buzzer ( int snd ); |
132 | 134 | ||
133 | OLedState m_leds [1]; | 135 | OLedState m_leds [1]; |
136 | bool m_embedix; | ||
134 | }; | 137 | }; |
135 | 138 | ||
@@ -384,8 +387,8 @@ ODevice *ODevice::inst ( ) | |||
384 | static ODevice *dev = 0; | 387 | static ODevice *dev = 0; |
385 | 388 | ||
386 | if ( !dev ) { | 389 | if ( !dev ) { |
387 | if ( QFile::exists ( "/proc/hal/model" )) | 390 | if ( QFile::exists ( "/proc/hal/model" )) |
388 | dev = new iPAQ ( ); | 391 | dev = new iPAQ ( ); |
389 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 392 | else if ( Zaurus::isZaurus() ) |
390 | dev = new Zaurus ( ); | 393 | dev = new Zaurus ( ); |
391 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 394 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
@@ -1321,4 +1324,41 @@ int iPAQ::lightSensorResolution ( ) const | |||
1321 | **************************************************/ | 1324 | **************************************************/ |
1322 | 1325 | ||
1326 | // Check whether this device is the sharp zaurus.. | ||
1327 | bool Zaurus::isZaurus() | ||
1328 | { | ||
1329 | |||
1330 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | ||
1331 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | ||
1332 | return true; | ||
1333 | } | ||
1334 | |||
1335 | // On non-embedix kenrnels, we have too look closer. | ||
1336 | bool is_zaurus = false; | ||
1337 | QFile f ( "/proc/cpuinfo" ); | ||
1338 | if ( f. open ( IO_ReadOnly ) ) { | ||
1339 | QString model; | ||
1340 | QFile f ( "/proc/cpuinfo" ); | ||
1341 | |||
1342 | QTextStream ts ( &f ); | ||
1343 | QString line; | ||
1344 | while( line = ts. readLine ( ) ) { | ||
1345 | if ( line. left ( 8 ) == "Hardware" ) | ||
1346 | break; | ||
1347 | } | ||
1348 | int loc = line. find ( ":" ); | ||
1349 | if ( loc != -1 ) | ||
1350 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | ||
1351 | |||
1352 | if ( model == "Sharp-Collie" | ||
1353 | || model == "Collie" | ||
1354 | || model == "SHARP Corgi" | ||
1355 | || model == "SHARP Shepherd" | ||
1356 | || model == "SHARP Poodle" | ||
1357 | ) | ||
1358 | is_zaurus = true; | ||
1359 | |||
1360 | } | ||
1361 | return is_zaurus; | ||
1362 | } | ||
1323 | 1363 | ||
1324 | 1364 | ||
@@ -1327,4 +1367,5 @@ void Zaurus::init ( ) | |||
1327 | d-> m_vendorstr = "Sharp"; | 1367 | d-> m_vendorstr = "Sharp"; |
1328 | d-> m_vendor = Vendor_Sharp; | 1368 | d-> m_vendor = Vendor_Sharp; |
1369 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | ||
1329 | 1370 | ||
1330 | // QFile f ( "/proc/filesystems" ); | 1371 | // QFile f ( "/proc/filesystems" ); |
@@ -1343,7 +1384,4 @@ void Zaurus::init ( ) | |||
1343 | d-> m_system = System_OpenZaurus; | 1384 | d-> m_system = System_OpenZaurus; |
1344 | 1385 | ||
1345 | // f. close ( ); | ||
1346 | |||
1347 | // f. setName ( "/etc/oz_version" ); | ||
1348 | if ( f. open ( IO_ReadOnly )) { | 1386 | if ( f. open ( IO_ReadOnly )) { |
1349 | QTextStream ts ( &f ); | 1387 | QTextStream ts ( &f ); |
@@ -1351,4 +1389,20 @@ void Zaurus::init ( ) | |||
1351 | f. close ( ); | 1389 | f. close ( ); |
1352 | } | 1390 | } |
1391 | |||
1392 | // Openzaurus sometimes uses the embedix kernel! | ||
1393 | // => Check whether this is an embedix kernel | ||
1394 | FILE *uname = popen("uname -r", "r"); | ||
1395 | QString line; | ||
1396 | if ( f.open(IO_ReadOnly, uname) ) { | ||
1397 | QTextStream ts ( &f ); | ||
1398 | line = ts. readLine ( ); | ||
1399 | int loc = line. find ( "embedix" ); | ||
1400 | if ( loc != -1 ) | ||
1401 | m_embedix = true; | ||
1402 | else | ||
1403 | m_embedix = false; | ||
1404 | f. close ( ); | ||
1405 | } | ||
1406 | pclose(uname); | ||
1353 | } | 1407 | } |
1354 | else { | 1408 | else { |
@@ -1376,8 +1430,8 @@ void Zaurus::init ( ) | |||
1376 | d-> m_model = Model_Zaurus_SLC700; // Do we need a special type for the C750 ? (eilers) | 1430 | d-> m_model = Model_Zaurus_SLC700; // Do we need a special type for the C750 ? (eilers) |
1377 | d-> m_modelstr = "Zaurus SL-C750"; | 1431 | d-> m_modelstr = "Zaurus SL-C750"; |
1378 | }else if ( model == "SHARP Poodle" ) { | 1432 | } else if ( model == "SHARP Poodle" ) { |
1379 | d-> m_model = Model_Zaurus_SLB600; | 1433 | d-> m_model = Model_Zaurus_SLB600; |
1380 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1434 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1381 | } else if ( model = "Sharp-Collie" ) { | 1435 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1382 | d-> m_model = Model_Zaurus_SL5500; | 1436 | d-> m_model = Model_Zaurus_SL5500; |
1383 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1437 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
@@ -1444,6 +1498,8 @@ void Zaurus::initButtons ( ) | |||
1444 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1498 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1445 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1499 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1446 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1500 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), |
1447 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1501 | zb-> fpressedaction )); |
1502 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), | ||
1503 | zb-> fheldaction )); | ||
1448 | 1504 | ||
1449 | d-> m_buttons-> append ( b ); | 1505 | d-> m_buttons-> append ( b ); |
@@ -1453,5 +1509,6 @@ void Zaurus::initButtons ( ) | |||
1453 | 1509 | ||
1454 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1510 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1455 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1511 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), |
1512 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | ||
1456 | } | 1513 | } |
1457 | 1514 | ||
@@ -1525,14 +1582,13 @@ typedef struct sharp_led_status { | |||
1525 | void Zaurus::buzzer ( int sound ) | 1582 | void Zaurus::buzzer ( int sound ) |
1526 | { | 1583 | { |
1527 | // Not all devices have real sound. | ||
1528 | #ifndef QT_NO_SOUND | 1584 | #ifndef QT_NO_SOUND |
1529 | switch ( d-> m_model ) { | 1585 | QString soundname; |
1530 | case Model_Zaurus_SLC700:{ | 1586 | |
1531 | int fd; | 1587 | // Not all devices have real sound. But I expect |
1532 | int vol; | 1588 | // that Openzaurus now has a sound driver which |
1533 | bool vol_reset = false; | 1589 | // I will use instead the buzzer... |
1590 | if ( ( d->m_model == Model_Zaurus_SLC700 ) | ||
1591 | || d->m_system == System_OpenZaurus ){ | ||
1534 | 1592 | ||
1535 | QString soundname; | ||
1536 | |||
1537 | switch ( sound ){ | 1593 | switch ( sound ){ |
1538 | case SHARP_BUZ_SCHEDULE_ALARM: | 1594 | case SHARP_BUZ_SCHEDULE_ALARM: |
@@ -1549,4 +1605,13 @@ void Zaurus::buzzer ( int sound ) | |||
1549 | 1605 | ||
1550 | } | 1606 | } |
1607 | } | ||
1608 | |||
1609 | // If a soundname is defined, we expect that this device has | ||
1610 | // sound capabilities.. Otherwise we expect to have the buzzer | ||
1611 | // device.. | ||
1612 | if ( !soundname.isEmpty() ){ | ||
1613 | int fd; | ||
1614 | int vol; | ||
1615 | bool vol_reset = false; | ||
1551 | 1616 | ||
1552 | Sound snd ( soundname ); | 1617 | Sound snd ( soundname ); |
@@ -1578,7 +1643,5 @@ void Zaurus::buzzer ( int sound ) | |||
1578 | ::close ( fd ); | 1643 | ::close ( fd ); |
1579 | } | 1644 | } |
1580 | break; | 1645 | } else { |
1581 | } | ||
1582 | default:{ // Devices with buzzer | ||
1583 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1646 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1584 | 1647 | ||
@@ -1587,6 +1650,6 @@ void Zaurus::buzzer ( int sound ) | |||
1587 | ::close ( fd ); | 1650 | ::close ( fd ); |
1588 | } | 1651 | } |
1589 | } | 1652 | |
1590 | } | 1653 | } |
1591 | #endif | 1654 | #endif |
1592 | } | 1655 | } |
@@ -1635,4 +1698,7 @@ OLedState Zaurus::ledState ( OLed which ) const | |||
1635 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1698 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1636 | { | 1699 | { |
1700 | if (!m_embedix) // Currently not supported on non_embedix kernels | ||
1701 | return false; | ||
1702 | |||
1637 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1703 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1638 | 1704 | ||
@@ -1662,4 +1728,9 @@ bool Zaurus::setLedState ( OLed which, OLedState st ) | |||
1662 | bool Zaurus::setSoftSuspend ( bool soft ) | 1728 | bool Zaurus::setSoftSuspend ( bool soft ) |
1663 | { | 1729 | { |
1730 | if (!m_embedix) { | ||
1731 | /* non-Embedix kernels dont have kernel autosuspend */ | ||
1732 | return ODevice::setSoftSuspend( soft ); | ||
1733 | } | ||
1734 | |||
1664 | bool res = false; | 1735 | bool res = false; |
1665 | int fd; | 1736 | int fd; |
@@ -1703,10 +1774,18 @@ bool Zaurus::setDisplayBrightness ( int bright ) | |||
1703 | bright = 0; | 1774 | bright = 0; |
1704 | 1775 | ||
1705 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1776 | if (m_embedix) { |
1706 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1777 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1707 | if ( bright && !bl ) | 1778 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1708 | bl = 1; | 1779 | if ( bright && !bl ) |
1709 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1780 | bl = 1; |
1710 | ::close ( fd ); | 1781 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1782 | ::close ( fd ); | ||
1783 | } | ||
1784 | } else { | ||
1785 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | ||
1786 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | ||
1787 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | ||
1788 | ::close ( fd ); | ||
1789 | } | ||
1711 | } | 1790 | } |
1712 | return res; | 1791 | return res; |
@@ -1716,5 +1795,8 @@ bool Zaurus::setDisplayBrightness ( int bright ) | |||
1716 | int Zaurus::displayBrightnessResolution ( ) const | 1795 | int Zaurus::displayBrightnessResolution ( ) const |
1717 | { | 1796 | { |
1718 | return 5; | 1797 | if (m_embedix) |
1798 | return 5; | ||
1799 | else | ||
1800 | return 256; | ||
1719 | } | 1801 | } |
1720 | 1802 | ||