Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 99 |
1 files changed, 34 insertions, 65 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 47682bb..127fee9 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,36 +1,36 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice_zaurus.h" | 30 | #include "odevice_zaurus.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
@@ -174,26 +174,24 @@ void Zaurus::init(const QString& cpu_info) | |||
174 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 174 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
175 | d->m_model = Model_Zaurus_SL5500; | 175 | d->m_model = Model_Zaurus_SL5500; |
176 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 176 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
177 | } else if ( model == "SHARP Tosa" ) { | 177 | } else if ( model == "SHARP Tosa" ) { |
178 | d->m_model = Model_Zaurus_SL6000; | 178 | d->m_model = Model_Zaurus_SL6000; |
179 | d->m_modelstr = "Zaurus SL-6000"; | 179 | d->m_modelstr = "Zaurus SL-6000"; |
180 | } else { | 180 | } else { |
181 | d->m_model = Model_Zaurus_SL5500; | 181 | d->m_model = Model_Zaurus_SL5500; |
182 | d->m_modelstr = "Unkown Zaurus"; | 182 | d->m_modelstr = "Unkown Zaurus"; |
183 | } | 183 | } |
184 | 184 | ||
185 | // set initial rotation | 185 | // set initial rotation |
186 | |||
187 | bool flipstate = false; | ||
188 | switch ( d->m_model ) { | 186 | switch ( d->m_model ) { |
189 | case Model_Zaurus_SL6000: | 187 | case Model_Zaurus_SL6000: |
190 | case Model_Zaurus_SLA300: | 188 | case Model_Zaurus_SLA300: |
191 | d->m_rotation = Rot0; | 189 | d->m_rotation = Rot0; |
192 | break; | 190 | break; |
193 | case Model_Zaurus_SLC7x0: | 191 | case Model_Zaurus_SLC7x0: |
194 | d->m_rotation = rotation(); | 192 | d->m_rotation = rotation(); |
195 | d->m_direction = direction(); | 193 | d->m_direction = direction(); |
196 | break; | 194 | break; |
197 | case Model_Zaurus_SLB600: | 195 | case Model_Zaurus_SLB600: |
198 | case Model_Zaurus_SL5500: | 196 | case Model_Zaurus_SL5500: |
199 | case Model_Zaurus_SL5000: | 197 | case Model_Zaurus_SL5000: |
@@ -309,82 +307,53 @@ int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | |||
309 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 307 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
310 | 308 | ||
311 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 309 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
312 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 310 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
313 | #define APM_EVT_POWER_BUTTON (1 << 0) | 311 | #define APM_EVT_POWER_BUTTON (1 << 0) |
314 | 312 | ||
315 | #define FL_IOCTL_STEP_CONTRAST 100 | 313 | #define FL_IOCTL_STEP_CONTRAST 100 |
316 | 314 | ||
317 | 315 | ||
318 | void Zaurus::buzzer ( int sound ) | 316 | void Zaurus::buzzer ( int sound ) |
319 | { | 317 | { |
320 | #ifndef QT_NO_SOUND | 318 | #ifndef QT_NO_SOUND |
321 | QString soundname; | 319 | Sound *snd = 0; |
322 | 320 | ||
323 | // Not all devices have real sound | 321 | // Not all devices have real sound |
324 | if ( d->m_model == Model_Zaurus_SLC7x0 | 322 | if ( d->m_model == Model_Zaurus_SLC7x0 |
325 | || d->m_model == Model_Zaurus_SLB600 ){ | 323 | || d->m_model == Model_Zaurus_SLB600 ){ |
326 | 324 | ||
327 | switch ( sound ){ | 325 | switch ( sound ){ |
328 | case SHARP_BUZ_SCHEDULE_ALARM: | ||
329 | soundname = "alarm"; | ||
330 | break; | ||
331 | case SHARP_BUZ_TOUCHSOUND: | 326 | case SHARP_BUZ_TOUCHSOUND: |
332 | soundname = "touchsound"; | 327 | static Sound touch_sound("touchsound"); |
328 | snd = &touch_sound; | ||
333 | break; | 329 | break; |
334 | case SHARP_BUZ_KEYSOUND: | 330 | case SHARP_BUZ_KEYSOUND: |
335 | soundname = "keysound"; | 331 | static Sound key_sound( "keysound" ); |
332 | snd = &key_sound; | ||
336 | break; | 333 | break; |
334 | case SHARP_BUZ_SCHEDULE_ALARM: | ||
337 | default: | 335 | default: |
338 | soundname = "alarm"; | 336 | static Sound alarm_sound("alarm"); |
339 | 337 | snd = &alarm_sound; | |
338 | break; | ||
340 | } | 339 | } |
341 | } | 340 | } |
342 | 341 | ||
343 | // If a soundname is defined, we expect that this device has | 342 | // If a soundname is defined, we expect that this device has |
344 | // sound capabilities.. Otherwise we expect to have the buzzer | 343 | // sound capabilities.. Otherwise we expect to have the buzzer |
345 | // device.. | 344 | // device.. |
346 | if ( !soundname.isEmpty() ){ | 345 | if ( snd ){ |
347 | int fd; | 346 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
348 | int vol; | 347 | snd-> play(); |
349 | bool vol_reset = false; | ||
350 | |||
351 | Sound snd ( soundname ); | ||
352 | |||
353 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | ||
354 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | ||
355 | Config cfg ( "qpe" ); | ||
356 | cfg. setGroup ( "Volume" ); | ||
357 | |||
358 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | ||
359 | if ( volalarm < 0 ) | ||
360 | volalarm = 0; | ||
361 | else if ( volalarm > 100 ) | ||
362 | volalarm = 100; | ||
363 | volalarm |= ( volalarm << 8 ); | ||
364 | |||
365 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | ||
366 | vol_reset = true; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | snd. play(); | ||
371 | while ( !snd. isFinished()) | ||
372 | qApp->processEvents(); | ||
373 | |||
374 | if ( fd >= 0 ) { | ||
375 | if ( vol_reset ) | ||
376 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | ||
377 | ::close ( fd ); | ||
378 | } | ||
379 | } else { | 348 | } else { |
380 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 349 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
381 | 350 | ||
382 | if ( fd >= 0 ) { | 351 | if ( fd >= 0 ) { |
383 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 352 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
384 | ::close ( fd ); | 353 | ::close ( fd ); |
385 | } | 354 | } |
386 | 355 | ||
387 | } | 356 | } |
388 | #endif | 357 | #endif |
389 | } | 358 | } |
390 | 359 | ||
@@ -505,25 +474,25 @@ bool Zaurus::setDisplayBrightness ( int bright ) | |||
505 | 474 | ||
506 | if ( bright > 255 ) bright = 255; | 475 | if ( bright > 255 ) bright = 255; |
507 | if ( bright < 0 ) bright = 0; | 476 | if ( bright < 0 ) bright = 0; |
508 | 477 | ||
509 | if ( m_embedix ) | 478 | if ( m_embedix ) |
510 | { | 479 | { |
511 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 480 | if ( d->m_model == Model_Zaurus_SLC7x0 ) |
512 | { | 481 | { |
513 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | 482 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); |
514 | // special treatment for devices with the corgi backlight interface | 483 | // special treatment for devices with the corgi backlight interface |
515 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | 484 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) |
516 | { | 485 | { |
517 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); | 486 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); |
518 | char writeCommand[100]; | 487 | char writeCommand[100]; |
519 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 488 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
520 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 489 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
521 | ::close ( fd ); | 490 | ::close ( fd ); |
522 | } | 491 | } |
523 | return res; | 492 | return res; |
524 | } | 493 | } |
525 | else | 494 | else |
526 | { | 495 | { |
527 | // standard treatment for devices with the dumb embedix frontlight interface | 496 | // standard treatment for devices with the dumb embedix frontlight interface |
528 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 497 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
529 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 498 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |