Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

odevice_ramses.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022 :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 #include "odevice_ramses.h"
00032 
00033 /* QT */
00034 #include <qapplication.h>
00035 #include <qfile.h>
00036 #include <qtextstream.h>
00037 #include <qwindowsystem_qws.h>
00038 
00039 /* OPIE */
00040 #include <qpe/config.h>
00041 #include <qpe/sound.h>
00042 #include <qpe/qcopenvelope_qws.h>
00043 
00044 /* STD */
00045 #include <fcntl.h>
00046 #include <math.h>
00047 #include <stdlib.h>
00048 #include <signal.h>
00049 #include <sys/ioctl.h>
00050 #include <sys/time.h>
00051 #include <unistd.h>
00052 #ifndef QT_NO_SOUND
00053 #include <linux/soundcard.h>
00054 #endif
00055 
00056 using namespace Opie::Core;
00057 using namespace Opie::Core::Internal;
00058 
00059 
00060 void Ramses::init(const QString&)
00061 {
00062     d->m_vendorstr = "M und N";
00063     d->m_vendor = Vendor_MundN;
00064 
00065     // with old Prototype-LCD, /proc/sys/board/lcd_type = 1
00066     //d->m_modelstr = "Ramses";
00067     //d->m_model = Model_Ramses_MNCI;
00068     //d->m_rotation = Rot0;
00069 
00070     // all current Hardware, with /proc/sys/board/lcd_type = 2
00071     d->m_modelstr = "MNCIRX";
00072     d->m_model = Model_Ramses_MNCIRX;
00073     d->m_rotation = Rot90;
00074 
00075     d->m_holdtime = 500;
00076 
00077 
00078     // This table is true for a Intel XScale PXA 255
00079 
00080 #ifdef QT_QWS_ALLOW_OVERCLOCK
00081 #define OC(x...) x
00082 #else
00083 #define OC(x...)
00084 #endif
00085 
00086     d->m_cpu_frequencies->append("99000");      // mem= 99, run= 99, turbo= 99, PXbus= 50
00087  OC(d->m_cpu_frequencies->append("118000"); )   // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
00088     d->m_cpu_frequencies->append("199100");     // mem= 99, run=199, turbo=199, PXbus= 99
00089  OC(d->m_cpu_frequencies->append("236000"); )   // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
00090     d->m_cpu_frequencies->append("298600");     // mem= 99, run=199, turbo=298, PXbus= 99
00091  OC(d->m_cpu_frequencies->append("354000"); )   // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
00092     d->m_cpu_frequencies->append("398099");     // mem= 99, run=199, turbo=398, PXbus= 99
00093     d->m_cpu_frequencies->append("398100");     // mem= 99, run=398, turbo=398, PXbus=196
00094  OC(d->m_cpu_frequencies->append("471000"); )   // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
00095 }
00096 
00097 
00098 void Ramses::playAlarmSound()
00099 {
00100 #ifndef QT_NO_SOUND
00101     static Sound snd ( "alarm" );
00102     if(!snd.isFinished())
00103         return;
00104 
00105     changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
00106     snd.play();
00107 #endif
00108 }
00109 
00110 
00111 bool Ramses::suspend()
00112 {
00113     if ( !isQWS( ) ) // only qwsserver is allowed to suspend
00114         return false;
00115 
00116     sendSuspendmsg();
00117     ::sync();
00118 
00119     int fd;
00120     if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) {
00121         char writeCommand[] = "1\n";
00122         ::write(fd, writeCommand, sizeof(writeCommand) );
00123         ::close(fd);
00124     }
00125 
00126     ::usleep ( 200 * 1000 );
00127     return true;
00128 }
00129 
00130 
00131 bool Ramses::setDisplayBrightness(int bright)
00132 {
00133     //qDebug("Ramses::setDisplayBrightness(%d)", bright);
00134     bool res = false;
00135     int fd;
00136 
00137     // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
00138 
00139     if (bright > 255 )
00140         bright = 255;
00141     if (bright < 0)
00142         bright = 0;
00143 
00144     // Turn backlight completely off if brightness=0
00145     if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
00146         char writeCommand[10];
00147         const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
00148         res = (::write(fd, writeCommand, count) != -1);
00149         ::close(fd);
00150     }
00151 
00152     if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) {
00153         char writeCommand[10];
00154         const int count = sprintf(writeCommand, "%d\n", bright);
00155         res = (::write(fd, writeCommand, count) != -1);
00156         ::close(fd);
00157     }
00158     return res;
00159 }
00160 
00161 
00162 int Ramses::displayBrightnessResolution() const
00163 {
00164     return 32;
00165 }
00166 
00167 
00168 // TODO: add displayContrast for old MNCI

Generated on Sat Nov 5 16:16:06 2005 for OPIE by  doxygen 1.4.2