summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_motorola_ezx.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_motorola_ezx.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_motorola_ezx.cpp45
1 files changed, 2 insertions, 43 deletions
diff --git a/libopie2/opiecore/device/odevice_motorola_ezx.cpp b/libopie2/opiecore/device/odevice_motorola_ezx.cpp
index eed81ac..67a2b9b 100644
--- a/libopie2/opiecore/device/odevice_motorola_ezx.cpp
+++ b/libopie2/opiecore/device/odevice_motorola_ezx.cpp
@@ -82,211 +82,170 @@ struct ezx_button ezx_buttons [] = {
82 "opiemail", "raise()", 82 "opiemail", "raise()",
83 "opiemail", "newMail()" }, 83 "opiemail", "newMail()" },
84}; 84};
85 85
86void Motorola_EZX::init(const QString& cpu_info) 86void Motorola_EZX::init(const QString& cpu_info)
87{ 87{
88 qDebug( "Motorola_EZX::init()" ); 88 qDebug( "Motorola_EZX::init()" );
89 // Set the time to wait until the system is really suspended 89 // Set the time to wait until the system is really suspended
90 // the delta between apm --suspend and sleeping 90 // the delta between apm --suspend and sleeping
91 setAPMTimeOut( 15000 ); 91 setAPMTimeOut( 15000 );
92 92
93 d->m_vendorstr = "OpenEZX Team"; 93 d->m_vendorstr = "OpenEZX Team";
94 d->m_systemstr = "OpenEZX"; 94 d->m_systemstr = "OpenEZX";
95 d->m_system = System_OpenEZX; 95 d->m_system = System_OpenEZX;
96 // sysver already gathered 96 // sysver already gathered
97 97
98 // check the Motorola_EZX model 98 // check the Motorola_EZX model
99 QString model; 99 QString model;
100 int loc = cpu_info.find( ":" ); 100 int loc = cpu_info.find( ":" );
101 if ( loc != -1 ) 101 if ( loc != -1 )
102 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 102 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
103 else 103 else
104 model = cpu_info; 104 model = cpu_info;
105 105
106 if ( model == "Motorola Ezx Platform" ) { 106 if ( model == "Motorola Ezx Platform" ) {
107 d->m_model = Model_Motorola_EZX; 107 d->m_model = Model_Motorola_EZX;
108 d->m_modelstr = "Motorola_EZX"; 108 d->m_modelstr = "Motorola_EZX";
109 } else assert( 0 ); 109 } else assert( 0 );
110 110
111 // set path to backlight device in kernel 2.6 111 // set path to backlight device in kernel 2.6
112 m_backlightdev = "/sys/class/backlight/ezx-bl/"; 112 m_backlightdev = "/sys/class/backlight/ezx-bl/";
113 d->m_rotation = Rot0; 113 d->m_rotation = Rot0;
114 //initHingeSensor(); 114 //initHingeSensor();
115 115
116 // set default qte driver and led state 116 // set default qte driver and led state
117 d->m_qteDriver = "Transformed"; 117 d->m_qteDriver = "Transformed";
118 m_leds[0] = Led_Off; 118 m_leds[0] = Led_Off;
119 119
120 qDebug( "Motorola_EZX::init() - Using the 2.6 OpenEZX HAL on a %s", (const char*) d->m_modelstr ); 120 qDebug( "Motorola_EZX::init() - Using the 2.6 OpenEZX HAL on a %s", (const char*) d->m_modelstr );
121} 121}
122 122
123void Motorola_EZX::initButtons() 123void Motorola_EZX::initButtons()
124{ 124{
125 qDebug( "Motorola_EZX::initButtons()" ); 125 qDebug( "Motorola_EZX::initButtons()" );
126 if ( d->m_buttons ) 126 if ( d->m_buttons )
127 return; 127 return;
128 128
129 d->m_buttons = new QValueList <ODeviceButton>; 129 d->m_buttons = new QValueList <ODeviceButton>;
130
131 struct ezx_button * ezx_buttons;
132 int buttoncount;
133
134/*
135
136 switch ( d->m_model )
137 {
138 case Model_Motorola_EZX_SL6000:
139 pezx_buttons = ezx_buttons_6000;
140 buttoncount = ARRAY_SIZE(ezx_buttons_6000);
141 break;
142 case Model_Motorola_EZX_SLC3100: // fallthrough
143 case Model_Motorola_EZX_SLC3000: // fallthrough
144 case Model_Motorola_EZX_SLC1000: // fallthrough
145 case Model_Motorola_EZX_SLC7x0:
146 if ( isQWS( ) )
147 {
148 addPreHandler(this);
149 }
150 pezx_buttons = ezx_buttons_c700;
151 buttoncount = ARRAY_SIZE(ezx_buttons_c700);
152 break;
153 default:
154 pezx_buttons = ezx_buttons;
155 buttoncount = ARRAY_SIZE(ezx_buttons);
156 break;
157 }
158
159 for ( int i = 0; i < buttoncount; i++ ) {
160 struct ezx_button *zb = pezx_buttons + i;
161 ODeviceButton b;
162
163 b.setKeycode( zb->code );
164 b.setUserText( QObject::tr( "Button", zb->utext ));
165 b.setPixmap( OResource::loadPixmap( zb->pix ));
166 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
167 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
168 d->m_buttons->append( b );
169 }
170*/
171 reloadButtonMapping(); 130 reloadButtonMapping();
172} 131}
173 132
174void Motorola_EZX::playAlarmSound() 133void Motorola_EZX::playAlarmSound()
175{ 134{
176#ifndef QT_NO_SOUND 135#ifndef QT_NO_SOUND
177 static Sound snd ( "alarm" ); 136 static Sound snd ( "alarm" );
178 if(!snd.isFinished()) 137 if(!snd.isFinished())
179 return; 138 return;
180 139
181 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 140 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
182 snd. play(); 141 snd. play();
183#endif 142#endif
184} 143}
185 144
186QValueList <OLed> Motorola_EZX::ledList() const 145QValueList <OLed> Motorola_EZX::ledList() const
187{ 146{
188 QValueList <OLed> vl; 147 QValueList <OLed> vl;
189 vl << Led_Mail; 148 vl << Led_Mail;
190 return vl; 149 return vl;
191} 150}
192 151
193QValueList <OLedState> Motorola_EZX::ledStateList( OLed l ) const 152QValueList <OLedState> Motorola_EZX::ledStateList( OLed l ) const
194{ 153{
195 QValueList <OLedState> vl; 154 QValueList <OLedState> vl;
196 155
197 if ( l == Led_Mail ) 156 if ( l == Led_Mail )
198 vl << Led_Off << Led_On << Led_BlinkSlow; 157 vl << Led_Off << Led_On << Led_BlinkSlow;
199 return vl; 158 return vl;
200} 159}
201 160
202OLedState Motorola_EZX::ledState( OLed which ) const 161OLedState Motorola_EZX::ledState( OLed which ) const
203{ 162{
204 if ( which == Led_Mail ) 163 if ( which == Led_Mail )
205 return m_leds [0]; 164 return m_leds [0];
206 else 165 else
207 return Led_Off; 166 return Led_Off;
208} 167}
209 168
210bool Motorola_EZX::setLedState( OLed which, OLedState st ) 169bool Motorola_EZX::setLedState( OLed, OLedState )
211{ 170{
212 // Currently not supported 171 // Currently not supported
213 qDebug( "Motorola_EZX::setLedState: ODevice handling not yet implemented" ); 172 qDebug( "Motorola_EZX::setLedState: ODevice handling not yet implemented" );
214 return false; 173 return false;
215} 174}
216 175
217int Motorola_EZX::displayBrightnessResolution() const 176int Motorola_EZX::displayBrightnessResolution() const
218{ 177{
219 int res = 1; 178 int res = 1;
220 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK ); 179 int fd = ::open( m_backlightdev + "max_brightness", O_RDONLY|O_NONBLOCK );
221 if ( fd ) 180 if ( fd )
222 { 181 {
223 char buf[100]; 182 char buf[100];
224 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res ); 183 if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
225 ::close( fd ); 184 ::close( fd );
226 } 185 }
227 return res; 186 return res;
228} 187}
229 188
230bool Motorola_EZX::setDisplayBrightness( int bright ) 189bool Motorola_EZX::setDisplayBrightness( int bright )
231{ 190{
232 qDebug( "Motorola_EZX::setDisplayBrightness( %d )", bright ); 191 qDebug( "Motorola_EZX::setDisplayBrightness( %d )", bright );
233 return false; 192 return false;
234 193
235 bool res = false; 194 bool res = false;
236 195
237 if ( bright > 255 ) bright = 255; 196 if ( bright > 255 ) bright = 255;
238 if ( bright < 0 ) bright = 0; 197 if ( bright < 0 ) bright = 0;
239 198
240 int numberOfSteps = displayBrightnessResolution(); 199 int numberOfSteps = displayBrightnessResolution();
241 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255; 200 int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
242 201
243 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); 202 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
244 if ( fd ) 203 if ( fd )
245 { 204 {
246 char buf[100]; 205 char buf[100];
247 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 206 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
248 res = ( ::write( fd, &buf[0], len ) == 0 ); 207 res = ( ::write( fd, &buf[0], len ) == 0 );
249 ::close( fd ); 208 ::close( fd );
250 } 209 }
251 return res; 210 return res;
252} 211}
253 212
254bool Motorola_EZX::setDisplayStatus( bool on ) 213bool Motorola_EZX::setDisplayStatus( bool on )
255{ 214{
256 bool res = false; 215 bool res = false;
257 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); 216 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
258 if ( fd ) 217 if ( fd )
259 { 218 {
260 char buf[10]; 219 char buf[10];
261 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 220 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
262 buf[1] = '\0'; 221 buf[1] = '\0';
263 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 222 res = ( ::write( fd, &buf[0], 2 ) == 0 );
264 ::close( fd ); 223 ::close( fd );
265 } 224 }
266 return res; 225 return res;
267} 226}
268 227
269void Motorola_EZX::systemMessage( const QCString &msg, const QByteArray & ) 228void Motorola_EZX::systemMessage( const QCString &msg, const QByteArray & )
270{ 229{
271 if ( msg == "deviceButtonMappingChanged()" ) { 230 if ( msg == "deviceButtonMappingChanged()" ) {
272 reloadButtonMapping(); 231 reloadButtonMapping();
273 } 232 }
274} 233}
275 234
276bool Motorola_EZX::suspend() { 235bool Motorola_EZX::suspend() {
277 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 236 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
278 return false; 237 return false;
279 238
280 bool res = false; 239 bool res = false;
281 QCopChannel::send( "QPE/System", "aboutToSuspend()" ); 240 QCopChannel::send( "QPE/System", "aboutToSuspend()" );
282 241
283 struct timeval tvs, tvn; 242 struct timeval tvs;
284 ::gettimeofday ( &tvs, 0 ); 243 ::gettimeofday ( &tvs, 0 );
285 244
286 ::sync(); // flush fs caches 245 ::sync(); // flush fs caches
287 res = ( ::system ( "apm --suspend" ) == 0 ); 246 res = ( ::system ( "apm --suspend" ) == 0 );
288 247
289 QCopChannel::send( "QPE/System", "returnFromSuspend()" ); 248 QCopChannel::send( "QPE/System", "returnFromSuspend()" );
290 249
291 return res; 250 return res;
292} 251}