summaryrefslogtreecommitdiff
authorschurig <schurig>2004-09-09 10:19:13 (UTC)
committer schurig <schurig>2004-09-09 10:19:13 (UTC)
commitb3259d2dcf3599828a4eaa0d8de8148ca1839aef (patch) (unidiff)
tree5a5395da0f2476e6fec73abd1d4a953517d4e1d9
parent57549dc20fdaf0c5d7784d2adbbbdc8dfebb70fa (diff)
downloadopie-b3259d2dcf3599828a4eaa0d8de8148ca1839aef.zip
opie-b3259d2dcf3599828a4eaa0d8de8148ca1839aef.tar.gz
opie-b3259d2dcf3599828a4eaa0d8de8148ca1839aef.tar.bz2
updates to MNCI
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ramses.cpp170
-rw-r--r--libopie2/opiecore/device/odevice_ramses.h34
2 files changed, 50 insertions, 154 deletions
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp
index 7db2af1..0cddf85 100644
--- a/libopie2/opiecore/device/odevice_ramses.cpp
+++ b/libopie2/opiecore/device/odevice_ramses.cpp
@@ -56,145 +56,81 @@
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct r_button ramses_buttons [] = {
60 { Model_Ramses_MNCI,
61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
62 "devicebuttons/z_menu",
63 "QPE/TaskBar", "toggleMenu()",
64 "QPE/TaskBar", "toggleStartMenu()" },
65 { Model_Ramses_MNCI,
66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
67 "devicebuttons/ipaq_home",
68 "QPE/Launcher", "home()",
69 "buttonsettings", "raise()" },
70};
71 59
72void Ramses::init(const QString&) 60void Ramses::init(const QString&)
73{ 61{
74 d->m_vendorstr = "M und N"; 62 d->m_vendorstr = "M und N";
75 d->m_vendor = Vendor_MundN; 63 d->m_vendor = Vendor_MundN;
76 64
77 QFile f("/proc/sys/board/ramses"); 65 // with old Prototype-LCD, /proc/sys/board/lcd_type = 1
66 //d->m_modelstr = "Ramses";
67 //d->m_model = Model_Ramses_MNCI;
68 //d->m_rotation = Rot0;
78 69
79 d->m_modelstr = "Ramses"; 70 // all current Hardware, with /proc/sys/board/lcd_type = 2
80 d->m_model = Model_Ramses_MNCI; 71 d->m_modelstr = "MNCIRX";
72 d->m_model = Model_Ramses_MNCIRX;
73 d->m_rotation = Rot90;
81 74
82 d->m_rotation = Rot0; 75 d->m_holdtime = 500;
83 d->m_holdtime = 1000;
84 76
85 // Distribution detection code now in the base class
86 77
87 m_power_timer = 0; 78 // This table is true for a Intel XScale PXA 255
88 79
89#ifdef QT_QWS_ALLOW_OVERCLOCK 80#ifdef QT_QWS_ALLOW_OVERCLOCK
90#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 81#define OC(x...) x
91#define OC(x...) x
92#else 82#else
93#define OC(x...) 83#define OC(x...)
94#endif 84#endif
95 85
96 // This table is true for a Intel XScale PXA 255
97
98 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 86 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
99OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 87 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
100 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 88 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
101OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 89 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
102 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 90 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
103OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 91 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
104 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 92 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
105 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 93 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
106OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 94 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
107
108} 95}
109 96
110bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
111{
112 Q_UNUSED( keycode );
113 Q_UNUSED( modifiers );
114 Q_UNUSED( isPress );
115 Q_UNUSED( autoRepeat );
116 return false;
117}
118 97
119void Ramses::timerEvent(QTimerEvent *) 98void Ramses::playAlarmSound()
120{ 99{
121 killTimer(m_power_timer); 100#ifndef QT_NO_SOUND
122 m_power_timer = 0; 101 static Sound snd ( "alarm" );
123 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
124 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
125}
126
127
128bool Ramses::setSoftSuspend(bool soft)
129{
130 qDebug("Ramses::setSoftSuspend(%d)", soft);
131#if 0
132 bool res = false;
133 int fd;
134
135 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
136 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
137
138 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
139
140 if (sources >= 0) {
141 if (soft)
142 sources &= ~APM_EVT_POWER_BUTTON;
143 else
144 sources |= APM_EVT_POWER_BUTTON;
145
146 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
147 res = true;
148 else
149 perror("APM_IOCGEVTSRC");
150 }
151 else
152 perror("APM_IOCGEVTSRC");
153
154 ::close(fd);
155 }
156 else
157 perror("/dev/apm_bios or /dev/misc/apm_bios");
158 102
159 return res; 103 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
104 snd.play();
160#else 105#else
161 return true; 106#error QT_NO_SOUND defined
162#endif 107#endif
163} 108}
164 109
110
165bool Ramses::suspend() 111bool Ramses::suspend()
166{ 112{
167 qDebug("Ramses::suspend"); 113 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
168 return false; 114 return false;
169}
170 115
171/** 116 sendSuspendmsg();
172* This sets the display on or off 117 ::sync();
173*/
174bool Ramses::setDisplayStatus(bool on)
175{
176 qDebug("Ramses::setDisplayStatus(%d)", on);
177#if 0
178 bool res = false;
179 int fd;
180 118
181 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 119 int fd;
182 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 120 if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) {
121 char writeCommand[] = "1\n";
122 ::write(fd, writeCommand, sizeof(writeCommand) );
183 ::close(fd); 123 ::close(fd);
184 } 124 }
185 return res; 125
186#else 126 ::usleep ( 200 * 1000 );
187 return true; 127 return true;
188#endif
189} 128}
190 129
191 130
192/*
193* We get something between 0..255 into us
194*/
195bool Ramses::setDisplayBrightness(int bright) 131bool Ramses::setDisplayBrightness(int bright)
196{ 132{
197 qDebug("Ramses::setDisplayBrightness(%d)", bright); 133 //qDebug("Ramses::setDisplayBrightness(%d)", bright);
198 bool res = false; 134 bool res = false;
199 int fd; 135 int fd;
200 136
@@ -205,7 +141,7 @@ bool Ramses::setDisplayBrightness(int bright)
205 if (bright < 0) 141 if (bright < 0)
206 bright = 0; 142 bright = 0;
207 143
208 // Turn backlight completely off 144 // Turn backlight completely off if brightness=0
209 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 145 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
210 char writeCommand[10]; 146 char writeCommand[10];
211 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 147 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
@@ -213,11 +149,8 @@ bool Ramses::setDisplayBrightness(int bright)
213 ::close(fd); 149 ::close(fd);
214 } 150 }
215 151
216 // scale backlight brightness to hardware 152 if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) {
217 bright = 500-(bright * 500 / 255); 153 char writeCommand[10];
218 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
219 qDebug(" %d ->pwm1", bright);
220 char writeCommand[100];
221 const int count = sprintf(writeCommand, "%d\n", bright); 154 const int count = sprintf(writeCommand, "%d\n", bright);
222 res = (::write(fd, writeCommand, count) != -1); 155 res = (::write(fd, writeCommand, count) != -1);
223 ::close(fd); 156 ::close(fd);
@@ -231,34 +164,5 @@ int Ramses::displayBrightnessResolution() const
231 return 32; 164 return 32;
232} 165}
233 166
234bool Ramses::setDisplayContrast(int contr)
235{
236 qDebug("Ramses::setDisplayContrast(%d)", contr);
237 bool res = false;
238 int fd;
239
240 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
241
242 if (contr > 255 )
243 contr = 255;
244 if (contr < 0)
245 contr = 0;
246 contr = 90 - (contr * 20 / 255);
247
248 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
249 qDebug(" %d ->pwm0", contr);
250 char writeCommand[100];
251 const int count = sprintf(writeCommand, "%d\n", contr);
252 res = (::write(fd, writeCommand, count) != -1);
253 res = true;
254 ::close(fd);
255 }
256 return res;
257}
258
259
260int Ramses::displayContrastResolution() const
261{
262 return 20;
263}
264 167
168// TODO: add displayContrast for old MNCI
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h
index 3cf5e92..bbd3862 100644
--- a/libopie2/opiecore/device/odevice_ramses.h
+++ b/libopie2/opiecore/device/odevice_ramses.h
@@ -34,42 +34,34 @@
34/* QT */ 34/* QT */
35#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
36 36
37
38#ifndef OD_IOC
39#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
40#define OD_IO(type,number) OD_IOC(0,type,number,0)
41#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
42#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
43#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
44#endif
45
46
47
37namespace Opie { 48namespace Opie {
38namespace Core { 49namespace Core {
39namespace Internal { 50namespace Internal {
40 51
41class Ramses : public ODevice, public QWSServer::KeyboardFilter 52class Ramses : public ODevice
42{ 53{
43 protected: 54 protected:
44 virtual void init(const QString&); 55 virtual void init(const QString&);
45 56
46 public: 57 public:
47 virtual bool setSoftSuspend( bool soft );
48 virtual bool suspend(); 58 virtual bool suspend();
49 59
50 virtual bool setDisplayStatus( bool on );
51 virtual bool setDisplayBrightness( int b ); 60 virtual bool setDisplayBrightness( int b );
52 virtual int displayBrightnessResolution() const; 61 virtual int displayBrightnessResolution() const;
53 virtual bool setDisplayContrast( int b ); 62 virtual void playAlarmSound();
54 virtual int displayContrastResolution() const;
55
56 protected:
57 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
58 virtual void timerEvent ( QTimerEvent *te );
59
60 int m_power_timer;
61}; 63};
62 64
63struct r_button {
64 uint model;
65 Qt::Key code;
66 char *utext;
67 char *pix;
68 char *fpressedservice;
69 char *fpressedaction;
70 char *fheldservice;
71 char *fheldaction;
72};
73} 65}
74} 66}
75} 67}