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 | |||
@@ -106,52 +106,55 @@ protected: | |||
106 | 106 | ||
107 | OLedState m_leds [2]; | 107 | OLedState m_leds [2]; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | class Zaurus : public ODevice { | 110 | class Zaurus : public ODevice { |
111 | protected: | 111 | protected: |
112 | virtual void init ( ); | 112 | virtual void init ( ); |
113 | virtual void initButtons ( ); | 113 | virtual void initButtons ( ); |
114 | 114 | ||
115 | public: | 115 | public: |
116 | virtual bool setSoftSuspend ( bool soft ); | 116 | virtual bool setSoftSuspend ( bool soft ); |
117 | 117 | ||
118 | virtual bool setDisplayBrightness ( int b ); | 118 | virtual bool setDisplayBrightness ( int b ); |
119 | virtual int displayBrightnessResolution ( ) const; | 119 | virtual int displayBrightnessResolution ( ) const; |
120 | 120 | ||
121 | virtual void alarmSound ( ); | 121 | virtual void alarmSound ( ); |
122 | virtual void keySound ( ); | 122 | virtual void keySound ( ); |
123 | virtual void touchSound ( ); | 123 | virtual void touchSound ( ); |
124 | 124 | ||
125 | virtual QValueList <OLed> ledList ( ) const; | 125 | virtual QValueList <OLed> ledList ( ) const; |
126 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 126 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
127 | virtual OLedState ledState ( OLed led ) const; | 127 | virtual OLedState ledState ( OLed led ) const; |
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 | ||
136 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { | 139 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter { |
137 | protected: | 140 | protected: |
138 | virtual void init ( ); | 141 | virtual void init ( ); |
139 | virtual void initButtons ( ); | 142 | virtual void initButtons ( ); |
140 | 143 | ||
141 | public: | 144 | public: |
142 | virtual bool setSoftSuspend ( bool soft ); | 145 | virtual bool setSoftSuspend ( bool soft ); |
143 | virtual bool suspend(); | 146 | virtual bool suspend(); |
144 | 147 | ||
145 | virtual bool setDisplayStatus( bool on ); | 148 | virtual bool setDisplayStatus( bool on ); |
146 | virtual bool setDisplayBrightness ( int b ); | 149 | virtual bool setDisplayBrightness ( int b ); |
147 | virtual int displayBrightnessResolution ( ) const; | 150 | virtual int displayBrightnessResolution ( ) const; |
148 | 151 | ||
149 | virtual void alarmSound ( ); | 152 | virtual void alarmSound ( ); |
150 | 153 | ||
151 | virtual QValueList <OLed> ledList ( ) const; | 154 | virtual QValueList <OLed> ledList ( ) const; |
152 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 155 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
153 | virtual OLedState ledState ( OLed led ) const; | 156 | virtual OLedState ledState ( OLed led ) const; |
154 | virtual bool setLedState ( OLed led, OLedState st ); | 157 | virtual bool setLedState ( OLed led, OLedState st ); |
155 | 158 | ||
156 | protected: | 159 | protected: |
157 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 160 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
@@ -362,52 +365,52 @@ struct r_button { | |||
362 | { Model_Ramses_MNCI, | 365 | { Model_Ramses_MNCI, |
363 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 366 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
364 | "devicebuttons/ipaq_home", | 367 | "devicebuttons/ipaq_home", |
365 | "QPE/Launcher", "home()", | 368 | "QPE/Launcher", "home()", |
366 | "buttonsettings", "raise()" }, | 369 | "buttonsettings", "raise()" }, |
367 | }; | 370 | }; |
368 | 371 | ||
369 | static QCString makeChannel ( const char *str ) | 372 | static QCString makeChannel ( const char *str ) |
370 | { | 373 | { |
371 | if ( str && !::strchr ( str, '/' )) | 374 | if ( str && !::strchr ( str, '/' )) |
372 | return QCString ( "QPE/Application/" ) + str; | 375 | return QCString ( "QPE/Application/" ) + str; |
373 | else | 376 | else |
374 | return str; | 377 | return str; |
375 | } | 378 | } |
376 | 379 | ||
377 | static inline bool isQWS() | 380 | static inline bool isQWS() |
378 | { | 381 | { |
379 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 382 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
380 | } | 383 | } |
381 | 384 | ||
382 | ODevice *ODevice::inst ( ) | 385 | ODevice *ODevice::inst ( ) |
383 | { | 386 | { |
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" )) |
392 | dev = new SIMpad ( ); | 395 | dev = new SIMpad ( ); |
393 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 396 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
394 | dev = new Ramses ( ); | 397 | dev = new Ramses ( ); |
395 | else | 398 | else |
396 | dev = new ODevice ( ); | 399 | dev = new ODevice ( ); |
397 | 400 | ||
398 | dev-> init ( ); | 401 | dev-> init ( ); |
399 | } | 402 | } |
400 | return dev; | 403 | return dev; |
401 | } | 404 | } |
402 | 405 | ||
403 | 406 | ||
404 | /************************************************** | 407 | /************************************************** |
405 | * | 408 | * |
406 | * common | 409 | * common |
407 | * | 410 | * |
408 | **************************************************/ | 411 | **************************************************/ |
409 | 412 | ||
410 | 413 | ||
411 | ODevice::ODevice ( ) | 414 | ODevice::ODevice ( ) |
412 | { | 415 | { |
413 | d = new ODeviceData; | 416 | d = new ODeviceData; |
@@ -1299,107 +1302,158 @@ int iPAQ::readLightSensor ( ) | |||
1299 | 1302 | ||
1300 | buffer [4] = 0; | 1303 | buffer [4] = 0; |
1301 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1304 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1302 | 1305 | ||
1303 | if ( *endptr != 0 ) | 1306 | if ( *endptr != 0 ) |
1304 | val = -1; | 1307 | val = -1; |
1305 | } | 1308 | } |
1306 | ::close ( fd ); | 1309 | ::close ( fd ); |
1307 | } | 1310 | } |
1308 | 1311 | ||
1309 | return val; | 1312 | return val; |
1310 | } | 1313 | } |
1311 | 1314 | ||
1312 | int iPAQ::lightSensorResolution ( ) const | 1315 | int iPAQ::lightSensorResolution ( ) const |
1313 | { | 1316 | { |
1314 | return 256; | 1317 | return 256; |
1315 | } | 1318 | } |
1316 | 1319 | ||
1317 | /************************************************** | 1320 | /************************************************** |
1318 | * | 1321 | * |
1319 | * Zaurus | 1322 | * Zaurus |
1320 | * | 1323 | * |
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 | ||
1325 | void Zaurus::init ( ) | 1365 | void Zaurus::init ( ) |
1326 | { | 1366 | { |
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" ); |
1331 | QString model; | 1372 | QString model; |
1332 | 1373 | ||
1333 | // It isn't a good idea to check the system configuration to | 1374 | // It isn't a good idea to check the system configuration to |
1334 | // detect the distribution ! | 1375 | // detect the distribution ! |
1335 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 1376 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
1336 | // because it uses a jffs2 filesystem.. | 1377 | // because it uses a jffs2 filesystem.. |
1337 | // (eilers) | 1378 | // (eilers) |
1338 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1379 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1339 | QFile f ("/etc/oz_version"); | 1380 | QFile f ("/etc/oz_version"); |
1340 | if ( f.exists() ){ | 1381 | if ( f.exists() ){ |
1341 | d-> m_vendorstr = "OpenZaurus Team"; | 1382 | d-> m_vendorstr = "OpenZaurus Team"; |
1342 | d-> m_systemstr = "OpenZaurus"; | 1383 | d-> m_systemstr = "OpenZaurus"; |
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 ); |
1350 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1388 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
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 { |
1355 | d-> m_systemstr = "Zaurus"; | 1409 | d-> m_systemstr = "Zaurus"; |
1356 | d-> m_system = System_Zaurus; | 1410 | d-> m_system = System_Zaurus; |
1357 | } | 1411 | } |
1358 | 1412 | ||
1359 | f. setName ( "/proc/cpuinfo" ); | 1413 | f. setName ( "/proc/cpuinfo" ); |
1360 | if ( f. open ( IO_ReadOnly ) ) { | 1414 | if ( f. open ( IO_ReadOnly ) ) { |
1361 | QTextStream ts ( &f ); | 1415 | QTextStream ts ( &f ); |
1362 | QString line; | 1416 | QString line; |
1363 | while( line = ts. readLine ( ) ) { | 1417 | while( line = ts. readLine ( ) ) { |
1364 | if ( line. left ( 8 ) == "Hardware" ) | 1418 | if ( line. left ( 8 ) == "Hardware" ) |
1365 | break; | 1419 | break; |
1366 | } | 1420 | } |
1367 | int loc = line. find ( ":" ); | 1421 | int loc = line. find ( ":" ); |
1368 | if ( loc != -1 ) | 1422 | if ( loc != -1 ) |
1369 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1423 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1370 | } | 1424 | } |
1371 | 1425 | ||
1372 | if ( model == "SHARP Corgi" ) { | 1426 | if ( model == "SHARP Corgi" ) { |
1373 | d-> m_model = Model_Zaurus_SLC700; | 1427 | d-> m_model = Model_Zaurus_SLC700; |
1374 | d-> m_modelstr = "Zaurus SL-C700"; | 1428 | d-> m_modelstr = "Zaurus SL-C700"; |
1375 | } else if ( model == "SHARP Shepherd" ) { | 1429 | } else if ( model == "SHARP Shepherd" ) { |
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"; |
1384 | } else { | 1438 | } else { |
1385 | d-> m_model = Model_Zaurus_SL5500; | 1439 | d-> m_model = Model_Zaurus_SL5500; |
1386 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1440 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1387 | } | 1441 | } |
1388 | 1442 | ||
1389 | bool flipstate = false; | 1443 | bool flipstate = false; |
1390 | switch ( d-> m_model ) { | 1444 | switch ( d-> m_model ) { |
1391 | case Model_Zaurus_SLA300: | 1445 | case Model_Zaurus_SLA300: |
1392 | d-> m_rotation = Rot0; | 1446 | d-> m_rotation = Rot0; |
1393 | break; | 1447 | break; |
1394 | case Model_Zaurus_SLC700: | 1448 | case Model_Zaurus_SLC700: |
1395 | // Note: need to 1) set flipstate based on physical screen orientation | 1449 | // Note: need to 1) set flipstate based on physical screen orientation |
1396 | // and 2) check to see if the user overrode the rotation direction | 1450 | // and 2) check to see if the user overrode the rotation direction |
1397 | // using appearance, and if so, remove that item from the Config to | 1451 | // using appearance, and if so, remove that item from the Config to |
1398 | // ensure the rotate applet flips us back to the previous state. | 1452 | // ensure the rotate applet flips us back to the previous state. |
1399 | if ( flipstate ) { | 1453 | if ( flipstate ) { |
1400 | // 480x640 | 1454 | // 480x640 |
1401 | d-> m_rotation = Rot0; | 1455 | d-> m_rotation = Rot0; |
1402 | d-> m_direction = CW; | 1456 | d-> m_direction = CW; |
1403 | } else { | 1457 | } else { |
1404 | // 640x480 | 1458 | // 640x480 |
1405 | d-> m_rotation = Rot270; | 1459 | d-> m_rotation = Rot270; |
@@ -1422,58 +1476,61 @@ void Zaurus::initButtons ( ) | |||
1422 | return; | 1476 | return; |
1423 | 1477 | ||
1424 | d-> m_buttons = new QValueList <ODeviceButton>; | 1478 | d-> m_buttons = new QValueList <ODeviceButton>; |
1425 | 1479 | ||
1426 | struct z_button * pz_buttons; | 1480 | struct z_button * pz_buttons; |
1427 | int buttoncount; | 1481 | int buttoncount; |
1428 | switch ( d-> m_model ) { | 1482 | switch ( d-> m_model ) { |
1429 | case Model_Zaurus_SLC700: | 1483 | case Model_Zaurus_SLC700: |
1430 | pz_buttons = z_buttons_c700; | 1484 | pz_buttons = z_buttons_c700; |
1431 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1485 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1432 | break; | 1486 | break; |
1433 | default: | 1487 | default: |
1434 | pz_buttons = z_buttons; | 1488 | pz_buttons = z_buttons; |
1435 | buttoncount = ARRAY_SIZE(z_buttons); | 1489 | buttoncount = ARRAY_SIZE(z_buttons); |
1436 | break; | 1490 | break; |
1437 | } | 1491 | } |
1438 | 1492 | ||
1439 | for ( int i = 0; i < buttoncount; i++ ) { | 1493 | for ( int i = 0; i < buttoncount; i++ ) { |
1440 | struct z_button *zb = pz_buttons + i; | 1494 | struct z_button *zb = pz_buttons + i; |
1441 | ODeviceButton b; | 1495 | ODeviceButton b; |
1442 | 1496 | ||
1443 | b. setKeycode ( zb-> code ); | 1497 | b. setKeycode ( zb-> code ); |
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 ); |
1450 | } | 1506 | } |
1451 | 1507 | ||
1452 | reloadButtonMapping ( ); | 1508 | reloadButtonMapping ( ); |
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 | ||
1458 | #include <unistd.h> | 1515 | #include <unistd.h> |
1459 | #include <fcntl.h> | 1516 | #include <fcntl.h> |
1460 | #include <sys/ioctl.h> | 1517 | #include <sys/ioctl.h> |
1461 | 1518 | ||
1462 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1519 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1463 | 1520 | ||
1464 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1521 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1465 | 1522 | ||
1466 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1523 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1467 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1524 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1468 | 1525 | ||
1469 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1526 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1470 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1527 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1471 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1528 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1472 | 1529 | ||
1473 | /* --- for SHARP_BUZZER device --- */ | 1530 | /* --- for SHARP_BUZZER device --- */ |
1474 | 1531 | ||
1475 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1532 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1476 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1533 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1477 | 1534 | ||
1478 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1535 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1479 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1536 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
@@ -1503,240 +1560,265 @@ void Zaurus::initButtons ( ) | |||
1503 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1560 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1504 | 1561 | ||
1505 | typedef struct sharp_led_status { | 1562 | typedef struct sharp_led_status { |
1506 | int which; /* select which LED status is wanted. */ | 1563 | int which; /* select which LED status is wanted. */ |
1507 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1564 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1508 | } sharp_led_status; | 1565 | } sharp_led_status; |
1509 | 1566 | ||
1510 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1567 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1511 | 1568 | ||
1512 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1569 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1513 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1570 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1514 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1571 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1515 | 1572 | ||
1516 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1573 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1517 | 1574 | ||
1518 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1575 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1519 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1576 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1520 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1577 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1521 | 1578 | ||
1522 | #define FL_IOCTL_STEP_CONTRAST 100 | 1579 | #define FL_IOCTL_STEP_CONTRAST 100 |
1523 | 1580 | ||
1524 | 1581 | ||
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: |
1539 | soundname = "alarm"; | 1595 | soundname = "alarm"; |
1540 | break; | 1596 | break; |
1541 | case SHARP_BUZ_TOUCHSOUND: | 1597 | case SHARP_BUZ_TOUCHSOUND: |
1542 | soundname = "touchsound"; | 1598 | soundname = "touchsound"; |
1543 | break; | 1599 | break; |
1544 | case SHARP_BUZ_KEYSOUND: | 1600 | case SHARP_BUZ_KEYSOUND: |
1545 | soundname = "keysound"; | 1601 | soundname = "keysound"; |
1546 | break; | 1602 | break; |
1547 | default: | 1603 | default: |
1548 | soundname = "alarm"; | 1604 | soundname = "alarm"; |
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 ); |
1553 | 1618 | ||
1554 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1619 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1555 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1620 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1556 | Config cfg ( "qpe" ); | 1621 | Config cfg ( "qpe" ); |
1557 | cfg. setGroup ( "Volume" ); | 1622 | cfg. setGroup ( "Volume" ); |
1558 | 1623 | ||
1559 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1624 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1560 | if ( volalarm < 0 ) | 1625 | if ( volalarm < 0 ) |
1561 | volalarm = 0; | 1626 | volalarm = 0; |
1562 | else if ( volalarm > 100 ) | 1627 | else if ( volalarm > 100 ) |
1563 | volalarm = 100; | 1628 | volalarm = 100; |
1564 | volalarm |= ( volalarm << 8 ); | 1629 | volalarm |= ( volalarm << 8 ); |
1565 | 1630 | ||
1566 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1631 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1567 | vol_reset = true; | 1632 | vol_reset = true; |
1568 | } | 1633 | } |
1569 | } | 1634 | } |
1570 | 1635 | ||
1571 | snd. play ( ); | 1636 | snd. play ( ); |
1572 | while ( !snd. isFinished ( )) | 1637 | while ( !snd. isFinished ( )) |
1573 | qApp-> processEvents ( ); | 1638 | qApp-> processEvents ( ); |
1574 | 1639 | ||
1575 | if ( fd >= 0 ) { | 1640 | if ( fd >= 0 ) { |
1576 | if ( vol_reset ) | 1641 | if ( vol_reset ) |
1577 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1642 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
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 | ||
1585 | if ( fd >= 0 ) { | 1648 | if ( fd >= 0 ) { |
1586 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1649 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1587 | ::close ( fd ); | 1650 | ::close ( fd ); |
1588 | } | 1651 | } |
1589 | } | 1652 | |
1590 | } | 1653 | } |
1591 | #endif | 1654 | #endif |
1592 | } | 1655 | } |
1593 | 1656 | ||
1594 | 1657 | ||
1595 | void Zaurus::alarmSound ( ) | 1658 | void Zaurus::alarmSound ( ) |
1596 | { | 1659 | { |
1597 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1660 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1598 | } | 1661 | } |
1599 | 1662 | ||
1600 | void Zaurus::touchSound ( ) | 1663 | void Zaurus::touchSound ( ) |
1601 | { | 1664 | { |
1602 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1665 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1603 | } | 1666 | } |
1604 | 1667 | ||
1605 | void Zaurus::keySound ( ) | 1668 | void Zaurus::keySound ( ) |
1606 | { | 1669 | { |
1607 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1670 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1608 | } | 1671 | } |
1609 | 1672 | ||
1610 | 1673 | ||
1611 | QValueList <OLed> Zaurus::ledList ( ) const | 1674 | QValueList <OLed> Zaurus::ledList ( ) const |
1612 | { | 1675 | { |
1613 | QValueList <OLed> vl; | 1676 | QValueList <OLed> vl; |
1614 | vl << Led_Mail; | 1677 | vl << Led_Mail; |
1615 | return vl; | 1678 | return vl; |
1616 | } | 1679 | } |
1617 | 1680 | ||
1618 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1681 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1619 | { | 1682 | { |
1620 | QValueList <OLedState> vl; | 1683 | QValueList <OLedState> vl; |
1621 | 1684 | ||
1622 | if ( l == Led_Mail ) | 1685 | if ( l == Led_Mail ) |
1623 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1686 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1624 | return vl; | 1687 | return vl; |
1625 | } | 1688 | } |
1626 | 1689 | ||
1627 | OLedState Zaurus::ledState ( OLed which ) const | 1690 | OLedState Zaurus::ledState ( OLed which ) const |
1628 | { | 1691 | { |
1629 | if ( which == Led_Mail ) | 1692 | if ( which == Led_Mail ) |
1630 | return m_leds [0]; | 1693 | return m_leds [0]; |
1631 | else | 1694 | else |
1632 | return Led_Off; | 1695 | return Led_Off; |
1633 | } | 1696 | } |
1634 | 1697 | ||
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 | ||
1639 | if ( which == Led_Mail ) { | 1705 | if ( which == Led_Mail ) { |
1640 | if ( fd >= 0 ) { | 1706 | if ( fd >= 0 ) { |
1641 | struct sharp_led_status leds; | 1707 | struct sharp_led_status leds; |
1642 | ::memset ( &leds, 0, sizeof( leds )); | 1708 | ::memset ( &leds, 0, sizeof( leds )); |
1643 | leds. which = SHARP_LED_MAIL_EXISTS; | 1709 | leds. which = SHARP_LED_MAIL_EXISTS; |
1644 | bool ok = true; | 1710 | bool ok = true; |
1645 | 1711 | ||
1646 | switch ( st ) { | 1712 | switch ( st ) { |
1647 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1713 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1648 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1714 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1649 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1715 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1650 | default : ok = false; | 1716 | default : ok = false; |
1651 | } | 1717 | } |
1652 | 1718 | ||
1653 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1719 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1654 | m_leds [0] = st; | 1720 | m_leds [0] = st; |
1655 | return true; | 1721 | return true; |
1656 | } | 1722 | } |
1657 | } | 1723 | } |
1658 | } | 1724 | } |
1659 | return false; | 1725 | return false; |
1660 | } | 1726 | } |
1661 | 1727 | ||
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; |
1666 | 1737 | ||
1667 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1738 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1668 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1739 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1669 | 1740 | ||
1670 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1741 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1671 | 1742 | ||
1672 | if ( sources >= 0 ) { | 1743 | if ( sources >= 0 ) { |
1673 | if ( soft ) | 1744 | if ( soft ) |
1674 | sources &= ~APM_EVT_POWER_BUTTON; | 1745 | sources &= ~APM_EVT_POWER_BUTTON; |
1675 | else | 1746 | else |
1676 | sources |= APM_EVT_POWER_BUTTON; | 1747 | sources |= APM_EVT_POWER_BUTTON; |
1677 | 1748 | ||
1678 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1749 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1679 | res = true; | 1750 | res = true; |
1680 | else | 1751 | else |
1681 | perror ( "APM_IOCGEVTSRC" ); | 1752 | perror ( "APM_IOCGEVTSRC" ); |
1682 | } | 1753 | } |
1683 | else | 1754 | else |
1684 | perror ( "APM_IOCGEVTSRC" ); | 1755 | perror ( "APM_IOCGEVTSRC" ); |
1685 | 1756 | ||
1686 | ::close ( fd ); | 1757 | ::close ( fd ); |
1687 | } | 1758 | } |
1688 | else | 1759 | else |
1689 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1760 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1690 | 1761 | ||
1691 | return res; | 1762 | return res; |
1692 | } | 1763 | } |
1693 | 1764 | ||
1694 | 1765 | ||
1695 | bool Zaurus::setDisplayBrightness ( int bright ) | 1766 | bool Zaurus::setDisplayBrightness ( int bright ) |
1696 | { | 1767 | { |
1697 | bool res = false; | 1768 | bool res = false; |
1698 | int fd; | 1769 | int fd; |
1699 | 1770 | ||
1700 | if ( bright > 255 ) | 1771 | if ( bright > 255 ) |
1701 | bright = 255; | 1772 | bright = 255; |
1702 | if ( bright < 0 ) | 1773 | if ( bright < 0 ) |
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; |
1713 | } | 1792 | } |
1714 | 1793 | ||
1715 | 1794 | ||
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 | ||
1721 | /************************************************** | 1803 | /************************************************** |
1722 | * | 1804 | * |
1723 | * SIMpad | 1805 | * SIMpad |
1724 | * | 1806 | * |
1725 | **************************************************/ | 1807 | **************************************************/ |
1726 | 1808 | ||
1727 | void SIMpad::init ( ) | 1809 | void SIMpad::init ( ) |
1728 | { | 1810 | { |
1729 | d-> m_vendorstr = "SIEMENS"; | 1811 | d-> m_vendorstr = "SIEMENS"; |
1730 | d-> m_vendor = Vendor_SIEMENS; | 1812 | d-> m_vendor = Vendor_SIEMENS; |
1731 | 1813 | ||
1732 | QFile f ( "/proc/hal/model" ); | 1814 | QFile f ( "/proc/hal/model" ); |
1733 | 1815 | ||
1734 | //TODO Implement model checking | 1816 | //TODO Implement model checking |
1735 | //FIXME For now we assume an SL4 | 1817 | //FIXME For now we assume an SL4 |
1736 | 1818 | ||
1737 | d-> m_modelstr = "SL4"; | 1819 | d-> m_modelstr = "SL4"; |
1738 | d-> m_model = Model_SIMpad_SL4; | 1820 | d-> m_model = Model_SIMpad_SL4; |
1739 | 1821 | ||
1740 | switch ( d-> m_model ) { | 1822 | switch ( d-> m_model ) { |
1741 | default: | 1823 | default: |
1742 | d-> m_rotation = Rot0; | 1824 | d-> m_rotation = Rot0; |