author | zecke <zecke> | 2004-09-21 16:04:01 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-21 16:04:01 (UTC) |
commit | 2e877b93064d149ccafbbd86da55fbd244c3af4a (patch) (unidiff) | |
tree | 5b1d3618ea1690a6d810c21f2a73e7e8ae51b257 | |
parent | 56f3bcad1a0abd199a458a62c8bde0ebdff035d5 (diff) | |
download | opie-2e877b93064d149ccafbbd86da55fbd244c3af4a.zip opie-2e877b93064d149ccafbbd86da55fbd244c3af4a.tar.gz opie-2e877b93064d149ccafbbd86da55fbd244c3af4a.tar.bz2 |
Simpad:
-We're not a KeyFilter remove the inheritance and installing of it
-Use /proc/mq200/driver/backlight instead of PWM_CONTROL
-Soft Suspend is dead long time do not reimplement it..
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 32 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.h | 6 |
2 files changed, 5 insertions, 33 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 34876da..335e0db 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -125,97 +125,91 @@ void SIMpad::init(const QString&) | |||
125 | d->m_modelstr = "SL4"; | 125 | d->m_modelstr = "SL4"; |
126 | d->m_model = Model_SIMpad_SL4; | 126 | d->m_model = Model_SIMpad_SL4; |
127 | 127 | ||
128 | switch ( d->m_model ) { | 128 | switch ( d->m_model ) { |
129 | default: | 129 | default: |
130 | d->m_rotation = Rot0; | 130 | d->m_rotation = Rot0; |
131 | d->m_direction = CCW; | 131 | d->m_direction = CCW; |
132 | d->m_holdtime = 1000; // 1000ms | 132 | d->m_holdtime = 1000; // 1000ms |
133 | 133 | ||
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | 136 | ||
137 | //Distribution detecting code is now in base class | 137 | //Distribution detecting code is now in base class |
138 | m_leds [0] = m_leds [1] = Led_Off; | 138 | m_leds [0] = m_leds [1] = Led_Off; |
139 | 139 | ||
140 | m_power_timer = 0; | 140 | m_power_timer = 0; |
141 | 141 | ||
142 | } | 142 | } |
143 | 143 | ||
144 | void SIMpad::initButtons() | 144 | void SIMpad::initButtons() |
145 | { | 145 | { |
146 | if ( d->m_buttons ) | 146 | if ( d->m_buttons ) |
147 | return; | 147 | return; |
148 | 148 | ||
149 | if ( isQWS( ) ) { | ||
150 | addPreHandler(this); | ||
151 | } | ||
152 | |||
153 | |||
154 | d->m_buttons = new QValueList <ODeviceButton>; | 149 | d->m_buttons = new QValueList <ODeviceButton>; |
155 | 150 | ||
156 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 151 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
157 | s_button *sb = simpad_buttons + i; | 152 | s_button *sb = simpad_buttons + i; |
158 | ODeviceButton b; | 153 | ODeviceButton b; |
159 | 154 | ||
160 | if (( sb->model & d->m_model ) == d->m_model ) { | 155 | if (( sb->model & d->m_model ) == d->m_model ) { |
161 | b. setKeycode ( sb->code ); | 156 | b. setKeycode ( sb->code ); |
162 | b. setUserText ( QObject::tr ( "Button", sb->utext )); | 157 | b. setUserText ( QObject::tr ( "Button", sb->utext )); |
163 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); | 158 | b. setPixmap ( Resource::loadPixmap ( sb->pix )); |
164 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); | 159 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); |
165 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); | 160 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); |
166 | 161 | ||
167 | d->m_buttons->append ( b ); | 162 | d->m_buttons->append ( b ); |
168 | } | 163 | } |
169 | } | 164 | } |
170 | reloadButtonMapping(); | 165 | reloadButtonMapping(); |
171 | 166 | ||
172 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 167 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
173 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 168 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
174 | } | 169 | } |
175 | 170 | ||
176 | // SIMpad boardcontrol register CS3 | 171 | // SIMpad boardcontrol register CS3 |
177 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 172 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
178 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 173 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
179 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 174 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
180 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 175 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
181 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 176 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
182 | #define SIMPAD_DISPLAY_ON 0x0010 | 177 | #define SIMPAD_DISPLAY_ON 0x0010 |
183 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 178 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
184 | #define SIMPAD_MQ_RESET 0x0040 | 179 | #define SIMPAD_MQ_RESET 0x0040 |
185 | #define SIMPAD_PCMCIA_RESET 0x0080 | 180 | #define SIMPAD_PCMCIA_RESET 0x0080 |
186 | #define SIMPAD_DECT_POWER_ON 0x0100 | 181 | #define SIMPAD_DECT_POWER_ON 0x0100 |
187 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 182 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
188 | #define SIMPAD_RS232_ON 0x0400 | 183 | #define SIMPAD_RS232_ON 0x0400 |
189 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 184 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
190 | #define SIMPAD_LED2_ON 0x1000 | 185 | #define SIMPAD_LED2_ON 0x1000 |
191 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 186 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
192 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 187 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
193 | #define SIMPAD_RESET_SIMCARD 0x8000 | 188 | #define SIMPAD_RESET_SIMCARD 0x8000 |
194 | 189 | ||
195 | //SIMpad touchscreen backlight strength control | 190 | //SIMpad touchscreen backlight strength control |
196 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 191 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/backlight" |
197 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | ||
198 | 192 | ||
199 | 193 | ||
200 | /* | 194 | /* |
201 | * The SIMpad exposes ChipSelect3 to userspace | 195 | * The SIMpad exposes ChipSelect3 to userspace |
202 | * via a proc filesystem file. Using this register | 196 | * via a proc filesystem file. Using this register |
203 | * one can toggle power of serial, irda, dect circuits | 197 | * one can toggle power of serial, irda, dect circuits |
204 | * change the video driver and display status and | 198 | * change the video driver and display status and |
205 | * many more things. | 199 | * many more things. |
206 | * To not lose the current setting we read the current | 200 | * To not lose the current setting we read the current |
207 | * cs3 setting and toggle the necessary bits and then | 201 | * cs3 setting and toggle the necessary bits and then |
208 | * write it. | 202 | * write it. |
209 | */ | 203 | */ |
210 | static bool setCS3Bit( bool bitset, int bit ) { | 204 | static bool setCS3Bit( bool bitset, int bit ) { |
211 | int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_RDONLY ); | 205 | int cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_RDONLY ); |
212 | 206 | ||
213 | if ( cs3_fd < 0 ) | 207 | if ( cs3_fd < 0 ) |
214 | return false; | 208 | return false; |
215 | 209 | ||
216 | static char line[32]; | 210 | static char line[32]; |
217 | int val = 0; | 211 | int val = 0; |
218 | bool ok = false; | 212 | bool ok = false; |
219 | 213 | ||
220 | /* | 214 | /* |
221 | * try to read and parse the Chipselect3 status | 215 | * try to read and parse the Chipselect3 status |
@@ -278,123 +272,103 @@ QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | |||
278 | 272 | ||
279 | OLedState SIMpad::ledState ( OLed l ) const | 273 | OLedState SIMpad::ledState ( OLed l ) const |
280 | { | 274 | { |
281 | switch ( l ) { | 275 | switch ( l ) { |
282 | case Led_Power: | 276 | case Led_Power: |
283 | return m_leds [0]; | 277 | return m_leds [0]; |
284 | //case Led_Mail: | 278 | //case Led_Mail: |
285 | // return m_leds [1]; | 279 | // return m_leds [1]; |
286 | default: | 280 | default: |
287 | return Led_Off; | 281 | return Led_Off; |
288 | } | 282 | } |
289 | } | 283 | } |
290 | 284 | ||
291 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 285 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
292 | { | 286 | { |
293 | if ( l == Led_Power ) { | 287 | if ( l == Led_Power ) { |
294 | m_leds [0] = st; | 288 | m_leds [0] = st; |
295 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); | 289 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); |
296 | return true; | 290 | return true; |
297 | } | 291 | } |
298 | 292 | ||
299 | return false; | 293 | return false; |
300 | } | 294 | } |
301 | 295 | ||
302 | |||
303 | bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ ) | ||
304 | { | ||
305 | //TODO | ||
306 | return false; | ||
307 | } | ||
308 | |||
309 | void SIMpad::timerEvent ( QTimerEvent * ) | 296 | void SIMpad::timerEvent ( QTimerEvent * ) |
310 | { | 297 | { |
311 | killTimer ( m_power_timer ); | 298 | killTimer ( m_power_timer ); |
312 | m_power_timer = 0; | 299 | m_power_timer = 0; |
313 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 300 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
314 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 301 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
315 | } | 302 | } |
316 | 303 | ||
317 | 304 | ||
318 | void SIMpad::playAlarmSound() | 305 | void SIMpad::playAlarmSound() |
319 | { | 306 | { |
320 | #ifndef QT_NO_SOUND | 307 | #ifndef QT_NO_SOUND |
321 | static Sound snd ( "alarm" ); | 308 | static Sound snd ( "alarm" ); |
322 | if(!snd.isFinished()) | 309 | if(!snd.isFinished()) |
323 | return; | 310 | return; |
324 | 311 | ||
325 | /* save as the Sound is static! */ | 312 | /* save as the Sound is static! */ |
326 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 313 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
327 | snd. play(); | 314 | snd. play(); |
328 | #endif | 315 | #endif |
329 | } | 316 | } |
330 | 317 | ||
331 | 318 | ||
332 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 319 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
333 | { | 320 | { |
334 | qDebug( "ODevice for SIMpad: suspend()" ); | 321 | qDebug( "ODevice for SIMpad: suspend()" ); |
335 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 322 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
336 | return false; | 323 | return false; |
337 | 324 | ||
338 | /* | 325 | /* |
339 | * we need to save the screen content | 326 | * we need to save the screen content |
340 | * then go to suspend using ODevice::suspend | 327 | * then go to suspend using ODevice::suspend |
341 | * and finally restore the screen content | 328 | * and finally restore the screen content |
342 | */ | 329 | */ |
343 | (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); | 330 | (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); |
344 | bool res = ODevice::suspend(); | 331 | bool res = ODevice::suspend(); |
345 | 332 | ||
346 | /* | 333 | /* |
347 | * restore | 334 | * restore |
348 | */ | 335 | */ |
349 | if ( res ) | 336 | if ( res ) |
350 | ::system( "cat /tmp/.buffer > /dev/fb/0" ); | 337 | ::system( "cat /tmp/.buffer > /dev/fb/0" ); |
351 | 338 | ||
352 | return res; | 339 | return res; |
353 | } | 340 | } |
354 | 341 | ||
355 | |||
356 | bool SIMpad::setSoftSuspend ( bool soft ) | ||
357 | { | ||
358 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | ||
359 | return false; | ||
360 | } | ||
361 | |||
362 | |||
363 | bool SIMpad::setDisplayStatus ( bool on ) | 342 | bool SIMpad::setDisplayStatus ( bool on ) |
364 | { | 343 | { |
365 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 344 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
366 | 345 | ||
367 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); | 346 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); |
368 | } | 347 | } |
369 | 348 | ||
370 | 349 | ||
371 | bool SIMpad::setDisplayBrightness ( int bright ) | 350 | bool SIMpad::setDisplayBrightness ( int bright ) |
372 | { | 351 | { |
373 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 352 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
374 | bool res = false; | 353 | bool res = false; |
375 | int fd; | 354 | int fd; |
376 | 355 | ||
377 | if ( bright > 255 ) | 356 | if ( bright > 255 ) |
378 | bright = 255; | 357 | bright = 255; |
379 | if ( bright < 1 ) | 358 | if ( bright < 1 ) |
380 | bright = 0; | 359 | bright = 0; |
381 | 360 | ||
382 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 361 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
383 | int value = 255 - bright; | 362 | QCString str = QFile::encodeName( QString::number(bright)); |
384 | const int mask = SIMPAD_BACKLIGHT_MASK; | 363 | res = ( ::write(fd, str, str.length()) != -1 ); |
385 | value = value << 8; | ||
386 | value += mask; | ||
387 | char writeCommand[100]; | ||
388 | const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); | ||
389 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | ||
390 | ::close ( fd ); | 364 | ::close ( fd ); |
391 | } | 365 | } |
392 | return res; | 366 | return res; |
393 | } | 367 | } |
394 | 368 | ||
395 | 369 | ||
396 | int SIMpad::displayBrightnessResolution() const | 370 | int SIMpad::displayBrightnessResolution() const |
397 | { | 371 | { |
398 | return 255; // All SIMpad models share the same display | 372 | return 255; // All SIMpad models share the same display |
399 | } | 373 | } |
400 | 374 | ||
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h index 6c42be7..dbcbbb4 100644 --- a/libopie2/opiecore/device/odevice_simpad.h +++ b/libopie2/opiecore/device/odevice_simpad.h | |||
@@ -18,70 +18,68 @@ | |||
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 | #ifndef ODEVICE_SIMPAD | 30 | #ifndef ODEVICE_SIMPAD |
31 | #define ODEVICE_SIMPAD | 31 | #define ODEVICE_SIMPAD |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include <opie2/odevice.h> |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | namespace Opie { | 38 | namespace Opie { |
39 | namespace Core { | 39 | namespace Core { |
40 | namespace Internal { | 40 | namespace Internal { |
41 | 41 | ||
42 | class SIMpad : public ODevice, public QWSServer::KeyboardFilter | 42 | class SIMpad : public ODevice |
43 | { | 43 | { |
44 | protected: | 44 | protected: |
45 | virtual void init(const QString&); | 45 | virtual void init(const QString&); |
46 | virtual void initButtons(); | 46 | virtual void initButtons(); |
47 | 47 | ||
48 | public: | 48 | public: |
49 | virtual bool setSoftSuspend( bool soft ); | ||
50 | virtual bool suspend(); | 49 | virtual bool suspend(); |
51 | 50 | ||
52 | virtual bool setDisplayStatus( bool on ); | 51 | virtual bool setDisplayStatus( bool on ); |
53 | virtual bool setDisplayBrightness( int b ); | 52 | virtual bool setDisplayBrightness( int b ); |
54 | virtual int displayBrightnessResolution() const; | 53 | virtual int displayBrightnessResolution() const; |
55 | 54 | ||
56 | virtual void playAlarmSound(); | 55 | virtual void playAlarmSound(); |
57 | 56 | ||
58 | virtual QValueList <OLed> ledList() const; | 57 | virtual QValueList <OLed> ledList() const; |
59 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | 58 | virtual QValueList <OLedState> ledStateList( OLed led ) const; |
60 | virtual OLedState ledState( OLed led ) const; | 59 | virtual OLedState ledState( OLed led ) const; |
61 | virtual bool setLedState( OLed led, OLedState st ); | 60 | virtual bool setLedState( OLed led, OLedState st ); |
62 | 61 | ||
63 | protected: | 62 | protected: |
64 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
65 | virtual void timerEvent( QTimerEvent *te ); | 63 | virtual void timerEvent( QTimerEvent *te ); |
66 | 64 | ||
67 | int m_power_timer; | 65 | int m_power_timer; |
68 | 66 | ||
69 | OLedState m_leds [2]; | 67 | OLedState m_leds [2]; |
70 | }; | 68 | }; |
71 | 69 | ||
72 | struct s_button { | 70 | struct s_button { |
73 | uint model; | 71 | uint model; |
74 | Qt::Key code; | 72 | Qt::Key code; |
75 | char *utext; | 73 | char *utext; |
76 | char *pix; | 74 | char *pix; |
77 | char *fpressedservice; | 75 | char *fpressedservice; |
78 | char *fpressedaction; | 76 | char *fpressedaction; |
79 | char *fheldservice; | 77 | char *fheldservice; |
80 | char *fheldaction; | 78 | char *fheldaction; |
81 | }; | 79 | }; |
82 | 80 | ||
83 | } | 81 | } |
84 | } | 82 | } |
85 | } | 83 | } |
86 | 84 | ||
87 | #endif | 85 | #endif |