author | mickeyl <mickeyl> | 2005-01-01 17:34:32 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-01 17:34:32 (UTC) |
commit | a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a (patch) (unidiff) | |
tree | ce7f0961815c32782c92009efc197a606b0ab86b | |
parent | 8467a23d6a7f4b52619b60462c8ba80d8a736a9e (diff) | |
download | opie-a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a.zip opie-a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a.tar.gz opie-a62cf9bfb9814a6f5ce5aa8d59fbe5b0cfb8414a.tar.bz2 |
clean up a bit and start w/ introducing SL-6000 support
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 124 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 47 |
2 files changed, 85 insertions, 86 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index ebe1949..1894e15 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -1,650 +1,610 @@ | |||
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 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
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> |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | using namespace Opie::Core; | 56 | using namespace Opie::Core; |
57 | using namespace Opie::Core::Internal; | 57 | using namespace Opie::Core::Internal; |
58 | 58 | ||
59 | struct z_button z_buttons [] = { | 59 | struct z_button z_buttons [] = { |
60 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 60 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
61 | "devicebuttons/z_calendar", | 61 | "devicebuttons/z_calendar", |
62 | "datebook", "nextView()", | 62 | "datebook", "nextView()", |
63 | "today", "raise()" }, | 63 | "today", "raise()" }, |
64 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 64 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
65 | "devicebuttons/z_contact", | 65 | "devicebuttons/z_contact", |
66 | "addressbook", "raise()", | 66 | "addressbook", "raise()", |
67 | "addressbook", "beamBusinessCard()" }, | 67 | "addressbook", "beamBusinessCard()" }, |
68 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 68 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
69 | "devicebuttons/z_home", | 69 | "devicebuttons/z_home", |
70 | "QPE/Launcher", "home()", | 70 | "QPE/Launcher", "home()", |
71 | "buttonsettings", "raise()" }, | 71 | "buttonsettings", "raise()" }, |
72 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 72 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
73 | "devicebuttons/z_menu", | 73 | "devicebuttons/z_menu", |
74 | "QPE/TaskBar", "toggleMenu()", | 74 | "QPE/TaskBar", "toggleMenu()", |
75 | "QPE/TaskBar", "toggleStartMenu()" }, | 75 | "QPE/TaskBar", "toggleStartMenu()" }, |
76 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 76 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
77 | "devicebuttons/z_mail", | 77 | "devicebuttons/z_mail", |
78 | "opiemail", "raise()", | 78 | "opiemail", "raise()", |
79 | "opiemail", "newMail()" }, | 79 | "opiemail", "newMail()" }, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | struct z_button z_buttons_c700 [] = { | 82 | struct z_button z_buttons_c700 [] = { |
83 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 83 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
84 | "devicebuttons/z_calendar", | 84 | "devicebuttons/z_calendar", |
85 | "datebook", "nextView()", | 85 | "datebook", "nextView()", |
86 | "today", "raise()" }, | 86 | "today", "raise()" }, |
87 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 87 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
88 | "devicebuttons/z_contact", | 88 | "devicebuttons/z_contact", |
89 | "addressbook", "raise()", | 89 | "addressbook", "raise()", |
90 | "addressbook", "beamBusinessCard()" }, | 90 | "addressbook", "beamBusinessCard()" }, |
91 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 91 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
92 | "devicebuttons/z_home", | 92 | "devicebuttons/z_home", |
93 | "QPE/Launcher", "home()", | 93 | "QPE/Launcher", "home()", |
94 | "buttonsettings", "raise()" }, | 94 | "buttonsettings", "raise()" }, |
95 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 95 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
96 | "devicebuttons/z_menu", | 96 | "devicebuttons/z_menu", |
97 | "QPE/TaskBar", "toggleMenu()", | 97 | "QPE/TaskBar", "toggleMenu()", |
98 | "QPE/TaskBar", "toggleStartMenu()" }, | 98 | "QPE/TaskBar", "toggleStartMenu()" }, |
99 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 99 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
100 | "devicebuttons/z_hinge", | 100 | "devicebuttons/z_hinge", |
101 | "QPE/Rotation", "rotateDefault()", | 101 | "QPE/Rotation", "rotateDefault()", |
102 | "QPE/Dummy", "doNothing()" }, | 102 | "QPE/Dummy", "doNothing()" }, |
103 | }; | 103 | }; |
104 | 104 | ||
105 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 105 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
106 | // class up into individual classes. We need three classes | 106 | // class up into individual classes. We need three classes |
107 | // | 107 | // |
108 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 108 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
109 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 109 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
110 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 110 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) |
111 | // Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) | ||
111 | // | 112 | // |
112 | // Only question right now is: Do we really need to do it? Because as soon | 113 | // Only question right now is: Do we really need to do it? Because as soon |
113 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 114 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
114 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 115 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
115 | // | 116 | // |
116 | // Comments? - mickeyl. | 117 | // Comments? - mickeyl. |
117 | 118 | ||
118 | void Zaurus::init(const QString& cpu_info) | 119 | void Zaurus::init(const QString& cpu_info) |
119 | { | 120 | { |
120 | // generic distribution code already scanned /etc/issue at that point - | 121 | // generic distribution code already scanned /etc/issue at that point - |
121 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | 122 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" |
122 | if ( d->m_sysverstr.contains( "embedix", false ) ) | 123 | if ( d->m_sysverstr.contains( "embedix", false ) ) |
123 | { | 124 | { |
124 | d->m_vendorstr = "Sharp"; | 125 | d->m_vendorstr = "Sharp"; |
125 | d->m_vendor = Vendor_Sharp; | 126 | d->m_vendor = Vendor_Sharp; |
126 | d->m_systemstr = "Zaurus"; | 127 | d->m_systemstr = "Zaurus"; |
127 | d->m_system = System_Zaurus; | 128 | d->m_system = System_Zaurus; |
128 | m_embedix = true; | 129 | m_embedix = true; |
129 | } | 130 | } |
130 | else | 131 | else |
131 | { | 132 | { |
132 | d->m_vendorstr = "OpenZaurus Team"; | 133 | d->m_vendorstr = "OpenZaurus Team"; |
133 | d->m_systemstr = "OpenZaurus"; | 134 | d->m_systemstr = "OpenZaurus"; |
134 | d->m_system = System_OpenZaurus; | 135 | d->m_system = System_OpenZaurus; |
135 | // sysver already gathered | 136 | // sysver already gathered |
136 | 137 | ||
137 | // Openzaurus sometimes uses the embedix kernel, check if this is one | 138 | // OpenZaurus sometimes uses the embedix kernel, check if this is one |
138 | FILE *uname = popen("uname -r", "r"); | 139 | FILE *uname = popen("uname -r", "r"); |
139 | QFile f; | 140 | QFile f; |
140 | QString line; | 141 | QString line; |
141 | if ( f.open(IO_ReadOnly, uname) ) { | 142 | if ( f.open(IO_ReadOnly, uname) ) { |
142 | QTextStream ts ( &f ); | 143 | QTextStream ts ( &f ); |
143 | line = ts. readLine(); | 144 | line = ts. readLine(); |
144 | int loc = line. find ( "embedix" ); | 145 | int loc = line. find ( "embedix" ); |
145 | if ( loc != -1 ) | 146 | if ( loc != -1 ) |
146 | m_embedix = true; | 147 | m_embedix = true; |
147 | else | 148 | else |
148 | m_embedix = false; | 149 | m_embedix = false; |
149 | f.close(); | 150 | f.close(); |
150 | } | 151 | } |
151 | pclose(uname); | 152 | pclose(uname); |
152 | } | 153 | } |
153 | 154 | ||
154 | // check the Zaurus model | 155 | // check the Zaurus model |
155 | QString model; | 156 | QString model; |
156 | int loc = cpu_info.find( ":" ); | 157 | int loc = cpu_info.find( ":" ); |
157 | if ( loc != -1 ) | 158 | if ( loc != -1 ) |
158 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); | 159 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
159 | else | 160 | else |
160 | model = cpu_info; | 161 | model = cpu_info; |
161 | 162 | ||
162 | if ( model == "SHARP Corgi" ) { | 163 | if ( model == "SHARP Corgi" ) { |
163 | d->m_model = Model_Zaurus_SLC7x0; | 164 | d->m_model = Model_Zaurus_SLC7x0; |
164 | d->m_modelstr = "Zaurus SL-C700"; | 165 | d->m_modelstr = "Zaurus SL-C700"; |
165 | } else if ( model == "SHARP Shepherd" ) { | 166 | } else if ( model == "SHARP Shepherd" ) { |
166 | d->m_model = Model_Zaurus_SLC7x0; | 167 | d->m_model = Model_Zaurus_SLC7x0; |
167 | d->m_modelstr = "Zaurus SL-C750"; | 168 | d->m_modelstr = "Zaurus SL-C750"; |
168 | } else if ( model == "SHARP Husky" ) { | 169 | } else if ( model == "SHARP Husky" ) { |
169 | d->m_model = Model_Zaurus_SLC7x0; | 170 | d->m_model = Model_Zaurus_SLC7x0; |
170 | d->m_modelstr = "Zaurus SL-C760"; | 171 | d->m_modelstr = "Zaurus SL-C760 or SL-C860"; |
171 | } else if ( model == "SHARP Poodle" ) { | 172 | } else if ( model == "SHARP Poodle" ) { |
172 | d->m_model = Model_Zaurus_SLB600; | 173 | d->m_model = Model_Zaurus_SLB600; |
173 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 174 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
174 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 175 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
175 | d->m_model = Model_Zaurus_SL5500; | 176 | d->m_model = Model_Zaurus_SL5500; |
176 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 177 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
177 | } else if ( model == "SHARP Tosa" ) { | 178 | } else if ( model == "SHARP Tosa" ) { |
178 | d->m_model = Model_Zaurus_SL6000; | 179 | d->m_model = Model_Zaurus_SL6000; |
179 | d->m_modelstr = "Zaurus SL-6000"; | 180 | d->m_modelstr = "Zaurus SL-6000"; |
180 | } else { | 181 | } else { |
181 | d->m_model = Model_Zaurus_SL5500; | 182 | d->m_model = Model_Zaurus_SL5500; |
182 | d->m_modelstr = "Unkown Zaurus"; | 183 | d->m_modelstr = "Unkown Zaurus"; |
183 | } | 184 | } |
184 | 185 | ||
185 | // set initial rotation | 186 | // set initial rotation |
186 | switch ( d->m_model ) { | 187 | switch( d->m_model ) { |
187 | case Model_Zaurus_SL6000: | 188 | case Model_Zaurus_SL6000: // fallthrough |
188 | case Model_Zaurus_SLA300: | 189 | case Model_Zaurus_SLA300: |
189 | d->m_rotation = Rot0; | 190 | d->m_rotation = Rot0; |
190 | break; | 191 | break; |
191 | case Model_Zaurus_SLC7x0: | 192 | case Model_Zaurus_SLC7x0: |
192 | d->m_rotation = rotation(); | 193 | d->m_rotation = rotation(); |
193 | d->m_direction = direction(); | 194 | d->m_direction = direction(); |
194 | break; | 195 | break; |
195 | case Model_Zaurus_SLB600: | 196 | case Model_Zaurus_SLB600: // fallthrough |
196 | case Model_Zaurus_SL5500: | 197 | case Model_Zaurus_SL5500: // fallthrough |
197 | case Model_Zaurus_SL5000: | 198 | case Model_Zaurus_SL5000: |
198 | default: | 199 | default: |
199 | d->m_rotation = Rot270; | 200 | d->m_rotation = Rot270; |
200 | break; | 201 | break; |
201 | } | 202 | } |
202 | m_leds [0] = Led_Off; | 203 | m_leds [0] = Led_Off; |
203 | } | 204 | } |
204 | 205 | ||
205 | void Zaurus::initButtons() | 206 | void Zaurus::initButtons() |
206 | { | 207 | { |
207 | if ( d->m_buttons ) | 208 | if ( d->m_buttons ) |
208 | return; | 209 | return; |
209 | 210 | ||
210 | d->m_buttons = new QValueList <ODeviceButton>; | 211 | d->m_buttons = new QValueList <ODeviceButton>; |
211 | 212 | ||
212 | struct z_button * pz_buttons; | 213 | struct z_button * pz_buttons; |
213 | int buttoncount; | 214 | int buttoncount; |
214 | switch ( d->m_model ) { | 215 | switch ( d->m_model ) { |
215 | case Model_Zaurus_SLC7x0: | 216 | case Model_Zaurus_SLC7x0: |
216 | pz_buttons = z_buttons_c700; | 217 | pz_buttons = z_buttons_c700; |
217 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 218 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
218 | break; | 219 | break; |
219 | default: | 220 | default: |
220 | pz_buttons = z_buttons; | 221 | pz_buttons = z_buttons; |
221 | buttoncount = ARRAY_SIZE(z_buttons); | 222 | buttoncount = ARRAY_SIZE(z_buttons); |
222 | break; | 223 | break; |
223 | } | 224 | } |
224 | 225 | ||
225 | for ( int i = 0; i < buttoncount; i++ ) { | 226 | for ( int i = 0; i < buttoncount; i++ ) { |
226 | struct z_button *zb = pz_buttons + i; | 227 | struct z_button *zb = pz_buttons + i; |
227 | ODeviceButton b; | 228 | ODeviceButton b; |
228 | 229 | ||
229 | b. setKeycode ( zb->code ); | 230 | b. setKeycode ( zb->code ); |
230 | b. setUserText ( QObject::tr ( "Button", zb->utext )); | 231 | b. setUserText ( QObject::tr ( "Button", zb->utext )); |
231 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); | 232 | b. setPixmap ( Resource::loadPixmap ( zb->pix )); |
232 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), | 233 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), |
233 | zb->fpressedaction )); | 234 | zb->fpressedaction )); |
234 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), | 235 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb->fheldservice ), |
235 | zb->fheldaction )); | 236 | zb->fheldaction )); |
236 | 237 | ||
237 | d->m_buttons->append ( b ); | 238 | d->m_buttons->append ( b ); |
238 | } | 239 | } |
239 | 240 | ||
240 | reloadButtonMapping(); | 241 | reloadButtonMapping(); |
241 | } | 242 | } |
242 | 243 | ||
243 | #include <unistd.h> | ||
244 | #include <fcntl.h> | ||
245 | #include <sys/ioctl.h> | ||
246 | |||
247 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | ||
248 | |||
249 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | ||
250 | |||
251 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | ||
252 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | ||
253 | |||
254 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | ||
255 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | ||
256 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | ||
257 | 244 | ||
258 | /* --- for SHARP_BUZZER device --- */ | ||
259 | |||
260 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | ||
261 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | ||
262 | |||
263 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | ||
264 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | ||
265 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | ||
266 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | ||
267 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | ||
268 | |||
269 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | ||
270 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | ||
271 | |||
272 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | ||
273 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | ||
274 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | ||
275 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | ||
276 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | ||
277 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | ||
278 | //#define SHARP_PDA_APPSTART 9 /* application start */ | ||
279 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | ||
280 | |||
281 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | ||
282 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | ||
283 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | ||
284 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | ||
285 | // | ||
286 | |||
287 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | ||
288 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | ||
289 | |||
290 | #define SHARP_IOCTL_GET_ROTATION 0x413c | ||
291 | 245 | ||
292 | typedef struct sharp_led_status { | 246 | typedef struct sharp_led_status { |
293 | int which; /* select which LED status is wanted. */ | 247 | int which; /* select which LED status is wanted. */ |
294 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 248 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
295 | } sharp_led_status; | 249 | } sharp_led_status; |
296 | 250 | ||
297 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 251 | void Zaurus::buzzer( int sound ) |
298 | |||
299 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | ||
300 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | ||
301 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | ||
302 | |||
303 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | ||
304 | |||
305 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | ||
306 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | ||
307 | #define APM_EVT_POWER_BUTTON (1 << 0) | ||
308 | |||
309 | #define FL_IOCTL_STEP_CONTRAST 100 | ||
310 | |||
311 | |||
312 | void Zaurus::buzzer ( int sound ) | ||
313 | { | 252 | { |
314 | #ifndef QT_NO_SOUND | 253 | #ifndef QT_NO_SOUND |
315 | Sound *snd = 0; | 254 | Sound *snd = 0; |
316 | 255 | ||
317 | // Not all devices have real sound | 256 | // Not all devices have real sound |
318 | if ( d->m_model == Model_Zaurus_SLC7x0 | 257 | if ( d->m_model == Model_Zaurus_SLC7x0 |
319 | || d->m_model == Model_Zaurus_SLB600 ){ | 258 | || d->m_model == Model_Zaurus_SLB600 |
259 | || d->m_model == Model_Zaurus_SL6000 ) { | ||
320 | 260 | ||
321 | switch ( sound ){ | 261 | switch ( sound ){ |
322 | case SHARP_BUZ_TOUCHSOUND: { | 262 | case SHARP_BUZ_TOUCHSOUND: { |
323 | static Sound touch_sound("touchsound"); | 263 | static Sound touch_sound("touchsound"); |
324 | snd = &touch_sound; | 264 | snd = &touch_sound; |
325 | } | 265 | } |
326 | break; | 266 | break; |
327 | case SHARP_BUZ_KEYSOUND: { | 267 | case SHARP_BUZ_KEYSOUND: { |
328 | static Sound key_sound( "keysound" ); | 268 | static Sound key_sound( "keysound" ); |
329 | snd = &key_sound; | 269 | snd = &key_sound; |
330 | } | 270 | } |
331 | break; | 271 | break; |
332 | case SHARP_BUZ_SCHEDULE_ALARM: | 272 | case SHARP_BUZ_SCHEDULE_ALARM: |
333 | default: { | 273 | default: { |
334 | static Sound alarm_sound("alarm"); | 274 | static Sound alarm_sound("alarm"); |
335 | snd = &alarm_sound; | 275 | snd = &alarm_sound; |
336 | } | 276 | } |
337 | break; | 277 | break; |
338 | } | 278 | } |
339 | } | 279 | } |
340 | 280 | ||
341 | // If a soundname is defined, we expect that this device has | 281 | // If a soundname is defined, we expect that this device has |
342 | // sound capabilities.. Otherwise we expect to have the buzzer | 282 | // sound capabilities.. Otherwise we expect to have the buzzer |
343 | // device.. | 283 | // device.. |
344 | if ( snd && snd->isFinished() ){ | 284 | if ( snd && snd->isFinished() ){ |
345 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 285 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
346 | snd-> play(); | 286 | snd->play(); |
347 | } else if( !snd ) { | 287 | } else if( !snd ) { |
348 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 288 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
349 | 289 | ||
350 | if ( fd >= 0 ) { | 290 | if ( fd >= 0 ) { |
351 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 291 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
352 | ::close ( fd ); | 292 | ::close ( fd ); |
353 | } | 293 | } |
354 | 294 | ||
355 | } | 295 | } |
356 | #endif | 296 | #endif |
357 | } | 297 | } |
358 | 298 | ||
359 | 299 | ||
360 | void Zaurus::playAlarmSound() | 300 | void Zaurus::playAlarmSound() |
361 | { | 301 | { |
362 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 302 | buzzer( SHARP_BUZ_SCHEDULE_ALARM ); |
363 | } | 303 | } |
364 | 304 | ||
365 | void Zaurus::playTouchSound() | 305 | void Zaurus::playTouchSound() |
366 | { | 306 | { |
367 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 307 | buzzer( SHARP_BUZ_TOUCHSOUND ); |
368 | } | 308 | } |
369 | 309 | ||
370 | void Zaurus::playKeySound() | 310 | void Zaurus::playKeySound() |
371 | { | 311 | { |
372 | buzzer ( SHARP_BUZ_KEYSOUND ); | 312 | buzzer( SHARP_BUZ_KEYSOUND ); |
373 | } | 313 | } |
374 | 314 | ||
375 | 315 | ||
376 | QValueList <OLed> Zaurus::ledList() const | 316 | QValueList <OLed> Zaurus::ledList() const |
377 | { | 317 | { |
378 | QValueList <OLed> vl; | 318 | QValueList <OLed> vl; |
379 | vl << Led_Mail; | 319 | vl << Led_Mail; |
380 | return vl; | 320 | return vl; |
381 | } | 321 | } |
382 | 322 | ||
383 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 323 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
384 | { | 324 | { |
385 | QValueList <OLedState> vl; | 325 | QValueList <OLedState> vl; |
386 | 326 | ||
387 | if ( l == Led_Mail ) | 327 | if ( l == Led_Mail ) |
388 | vl << Led_Off << Led_On << Led_BlinkSlow; | 328 | vl << Led_Off << Led_On << Led_BlinkSlow; |
389 | return vl; | 329 | return vl; |
390 | } | 330 | } |
391 | 331 | ||
392 | OLedState Zaurus::ledState ( OLed which ) const | 332 | OLedState Zaurus::ledState ( OLed which ) const |
393 | { | 333 | { |
394 | if ( which == Led_Mail ) | 334 | if ( which == Led_Mail ) |
395 | return m_leds [0]; | 335 | return m_leds [0]; |
396 | else | 336 | else |
397 | return Led_Off; | 337 | return Led_Off; |
398 | } | 338 | } |
399 | 339 | ||
400 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 340 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
401 | { | 341 | { |
402 | if (!m_embedix) // Currently not supported on non_embedix kernels | 342 | if (!m_embedix) // Currently not supported on non_embedix kernels |
403 | return false; | 343 | return false; |
404 | 344 | ||
405 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 345 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
406 | 346 | ||
407 | if ( which == Led_Mail ) { | 347 | if ( which == Led_Mail ) { |
408 | if ( fd >= 0 ) { | 348 | if ( fd >= 0 ) { |
409 | struct sharp_led_status leds; | 349 | struct sharp_led_status leds; |
410 | ::memset ( &leds, 0, sizeof( leds )); | 350 | ::memset ( &leds, 0, sizeof( leds )); |
411 | leds. which = SHARP_LED_MAIL_EXISTS; | 351 | leds. which = SHARP_LED_MAIL_EXISTS; |
412 | bool ok = true; | 352 | bool ok = true; |
413 | 353 | ||
414 | switch ( st ) { | 354 | switch ( st ) { |
415 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 355 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
416 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 356 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
417 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 357 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
418 | default : ok = false; | 358 | default : ok = false; |
419 | } | 359 | } |
420 | 360 | ||
421 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 361 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
422 | m_leds [0] = st; | 362 | m_leds [0] = st; |
423 | return true; | 363 | return true; |
424 | } | 364 | } |
425 | } | 365 | } |
426 | } | 366 | } |
427 | return false; | 367 | return false; |
428 | } | 368 | } |
429 | 369 | ||
430 | bool Zaurus::setSoftSuspend ( bool soft ) | 370 | bool Zaurus::setSoftSuspend ( bool soft ) |
431 | { | 371 | { |
432 | if (!m_embedix) { | 372 | if (!m_embedix) { |
433 | /* non-Embedix kernels dont have kernel autosuspend */ | 373 | /* non-Embedix kernels dont have kernel autosuspend */ |
434 | return ODevice::setSoftSuspend( soft ); | 374 | return ODevice::setSoftSuspend( soft ); |
435 | } | 375 | } |
436 | 376 | ||
437 | bool res = false; | 377 | bool res = false; |
438 | int fd; | 378 | int fd; |
439 | 379 | ||
440 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 380 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
441 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 381 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
442 | 382 | ||
443 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 383 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
444 | 384 | ||
445 | if ( sources >= 0 ) { | 385 | if ( sources >= 0 ) { |
446 | if ( soft ) | 386 | if ( soft ) |
447 | sources &= ~APM_EVT_POWER_BUTTON; | 387 | sources &= ~APM_EVT_POWER_BUTTON; |
448 | else | 388 | else |
449 | sources |= APM_EVT_POWER_BUTTON; | 389 | sources |= APM_EVT_POWER_BUTTON; |
450 | 390 | ||
451 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 391 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
452 | res = true; | 392 | res = true; |
453 | else | 393 | else |
454 | perror ( "APM_IOCGEVTSRC" ); | 394 | perror ( "APM_IOCGEVTSRC" ); |
455 | } | 395 | } |
456 | else | 396 | else |
457 | perror ( "APM_IOCGEVTSRC" ); | 397 | perror ( "APM_IOCGEVTSRC" ); |
458 | 398 | ||
459 | ::close ( fd ); | 399 | ::close ( fd ); |
460 | } | 400 | } |
461 | else | 401 | else |
462 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 402 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
463 | 403 | ||
464 | return res; | 404 | return res; |
465 | } | 405 | } |
466 | 406 | ||
467 | 407 | bool Zaurus::setDisplayBrightness( int bright ) | |
468 | bool Zaurus::setDisplayBrightness ( int bright ) | ||
469 | { | 408 | { |
470 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 409 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
471 | bool res = false; | 410 | bool res = false; |
472 | int fd; | 411 | int fd; |
473 | 412 | ||
474 | if ( bright > 255 ) bright = 255; | 413 | if ( bright > 255 ) bright = 255; |
475 | if ( bright < 0 ) bright = 0; | 414 | if ( bright < 0 ) bright = 0; |
476 | 415 | ||
477 | if ( m_embedix ) | 416 | if ( m_embedix ) |
478 | { | 417 | { |
479 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 418 | if ( d->m_model == Model_Zaurus_SLC7x0 ) |
480 | { | 419 | { |
481 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | 420 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); |
482 | // special treatment for devices with the corgi backlight interface | 421 | // special treatment for devices with the corgi backlight interface |
483 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | 422 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) |
484 | { | 423 | { |
485 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); | 424 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); |
486 | char writeCommand[100]; | 425 | char writeCommand[100]; |
487 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 426 | const int count = sprintf( writeCommand, "%x\n", value ); |
488 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 427 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
489 | ::close ( fd ); | 428 | ::close ( fd ); |
490 | } | 429 | } |
491 | return res; | 430 | return res; |
492 | } | 431 | } |
493 | else | 432 | else |
433 | if ( d->m_model == Model_Zaurus_SL6000 ) | ||
434 | { | ||
435 | //qDebug( "using special treatment for devices with the tosa backlight interface" ); | ||
436 | // special treatment for devices with the tosa backlight interface | ||
437 | if (( fd = ::open ( "/proc/driver/fl/tosa-bl", O_WRONLY )) >= 0 ) | ||
438 | { | ||
439 | int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); | ||
440 | char writeCommand[100]; | ||
441 | const int count = sprintf( writeCommand, "%x\n", value ); | ||
442 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | ||
443 | ::close ( fd ); | ||
444 | } | ||
445 | return res; | ||
446 | } | ||
447 | else | ||
494 | { | 448 | { |
495 | // standard treatment for devices with the dumb embedix frontlight interface | 449 | // standard treatment for devices with the dumb embedix frontlight interface |
496 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 450 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
497 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 451 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
498 | if ( bright && !bl ) | 452 | if ( bright && !bl ) |
499 | bl = 1; | 453 | bl = 1; |
500 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 454 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
501 | ::close ( fd ); | 455 | ::close ( fd ); |
502 | } | 456 | } |
503 | } | 457 | } |
504 | } | 458 | } |
505 | else | 459 | else |
506 | { | 460 | { |
507 | // special treatment for the OpenZaurus unified interface | 461 | // special treatment for the OpenZaurus unified interface |
508 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 462 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
509 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 463 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
510 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 464 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
511 | ::close ( fd ); | 465 | ::close ( fd ); |
512 | } | 466 | } |
513 | } | 467 | } |
514 | return res; | 468 | return res; |
515 | } | 469 | } |
516 | 470 | ||
517 | bool Zaurus::suspend() | 471 | bool Zaurus::suspend() |
518 | { | 472 | { |
519 | qDebug("ODevice::suspend"); | 473 | qDebug("ODevice::suspend"); |
520 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 474 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
521 | return false; | 475 | return false; |
522 | 476 | ||
523 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 477 | if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
524 | return false; | 478 | return false; |
525 | 479 | ||
526 | bool res = false; | 480 | bool res = false; |
527 | ODevice::sendSuspendmsg(); | 481 | ODevice::sendSuspendmsg(); |
528 | 482 | ||
529 | struct timeval tvs, tvn; | 483 | struct timeval tvs, tvn; |
530 | ::gettimeofday ( &tvs, 0 ); | 484 | ::gettimeofday ( &tvs, 0 ); |
531 | 485 | ||
532 | ::sync(); // flush fs caches | 486 | ::sync(); // flush fs caches |
533 | res = ( ::system ( "apm --suspend" ) == 0 ); | 487 | res = ( ::system ( "apm --suspend" ) == 0 ); |
534 | 488 | ||
535 | // This is needed because the iPAQ apm implementation is asynchronous and we | 489 | // This is needed because the iPAQ apm implementation is asynchronous and we |
536 | // can not be sure when exactly the device is really suspended | 490 | // can not be sure when exactly the device is really suspended |
537 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 491 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
538 | 492 | ||
539 | if ( res ) { | 493 | if ( res ) { |
540 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 494 | do { // Yes, wait 15 seconds. This APM bug sucks big time. |
541 | ::usleep ( 200 * 1000 ); | 495 | ::usleep ( 200 * 1000 ); |
542 | ::gettimeofday ( &tvn, 0 ); | 496 | ::gettimeofday ( &tvn, 0 ); |
543 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 497 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
544 | } | 498 | } |
545 | 499 | ||
546 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 500 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
547 | return res; | 501 | return res; |
548 | } | 502 | } |
549 | 503 | ||
550 | 504 | ||
551 | Transformation Zaurus::rotation() const | 505 | Transformation Zaurus::rotation() const |
552 | { | 506 | { |
553 | Transformation rot; | 507 | Transformation rot; |
554 | int handle = 0; | 508 | int handle = 0; |
555 | int retval = 0; | 509 | int retval = 0; |
556 | 510 | ||
557 | switch ( d->m_model ) { | 511 | switch ( d->m_model ) { |
558 | case Model_Zaurus_SLC7x0: | 512 | case Model_Zaurus_SLC7x0: |
559 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 513 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
560 | if (handle == -1) { | 514 | if (handle == -1) { |
561 | return Rot270; | 515 | return Rot270; |
562 | } else { | 516 | } else { |
563 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 517 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
564 | ::close (handle); | 518 | ::close (handle); |
565 | 519 | ||
566 | if (retval == 2 ) | 520 | if (retval == 2 ) |
567 | rot = Rot0; | 521 | rot = Rot0; |
568 | else | 522 | else |
569 | rot = Rot270; | 523 | rot = Rot270; |
570 | } | 524 | } |
571 | break; | 525 | break; |
572 | case Model_Zaurus_SLA300: | 526 | case Model_Zaurus_SLA300: |
573 | case Model_Zaurus_SLB600: | 527 | case Model_Zaurus_SLB600: |
574 | case Model_Zaurus_SL5500: | 528 | case Model_Zaurus_SL5500: |
575 | case Model_Zaurus_SL5000: | 529 | case Model_Zaurus_SL5000: |
576 | default: | 530 | default: |
577 | rot = d->m_rotation; | 531 | rot = d->m_rotation; |
578 | break; | 532 | break; |
579 | } | 533 | } |
580 | 534 | ||
581 | return rot; | 535 | return rot; |
582 | } | 536 | } |
583 | ODirection Zaurus::direction() const | 537 | ODirection Zaurus::direction() const |
584 | { | 538 | { |
585 | ODirection dir; | 539 | ODirection dir; |
586 | int handle = 0; | 540 | int handle = 0; |
587 | int retval = 0; | 541 | int retval = 0; |
588 | switch ( d->m_model ) { | 542 | switch ( d->m_model ) { |
589 | case Model_Zaurus_SLC7x0: | 543 | case Model_Zaurus_SLC7x0: |
590 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 544 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
591 | if (handle == -1) { | 545 | if (handle == -1) { |
592 | dir = CW; | 546 | dir = CW; |
593 | } else { | 547 | } else { |
594 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 548 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
595 | ::close (handle); | 549 | ::close (handle); |
596 | if (retval == 2 ) | 550 | if (retval == 2 ) |
597 | dir = CCW; | 551 | dir = CCW; |
598 | else | 552 | else |
599 | dir = CW; | 553 | dir = CW; |
600 | } | 554 | } |
601 | break; | 555 | break; |
602 | case Model_Zaurus_SLA300: | 556 | case Model_Zaurus_SLA300: |
603 | case Model_Zaurus_SLB600: | 557 | case Model_Zaurus_SLB600: |
604 | case Model_Zaurus_SL5500: | 558 | case Model_Zaurus_SL5500: |
605 | case Model_Zaurus_SL5000: | 559 | case Model_Zaurus_SL5000: |
606 | default: | 560 | default: |
607 | dir = d->m_direction; | 561 | dir = d->m_direction; |
608 | break; | 562 | break; |
609 | } | 563 | } |
610 | return dir; | 564 | return dir; |
611 | 565 | ||
612 | } | 566 | } |
613 | 567 | ||
614 | int Zaurus::displayBrightnessResolution() const | 568 | int Zaurus::displayBrightnessResolution() const |
615 | { | 569 | { |
616 | if (m_embedix) | 570 | if (m_embedix) |
617 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; | 571 | { |
572 | if ( d->m_model == Model_Zaurus_SLC7x0 ) return 18; | ||
573 | if ( d->m_model == Model_Zaurus_SL6000 ) return 18; | ||
574 | return 5; | ||
575 | } | ||
618 | else | 576 | else |
577 | { | ||
619 | return 256; | 578 | return 256; |
579 | } | ||
620 | } | 580 | } |
621 | 581 | ||
622 | bool Zaurus::hasHingeSensor() const | 582 | bool Zaurus::hasHingeSensor() const |
623 | { | 583 | { |
624 | return d->m_model == Model_Zaurus_SLC7x0; | 584 | return d->m_model == Model_Zaurus_SLC7x0; |
625 | } | 585 | } |
626 | 586 | ||
627 | OHingeStatus Zaurus::readHingeSensor() | 587 | OHingeStatus Zaurus::readHingeSensor() |
628 | { | 588 | { |
629 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 589 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
630 | if (handle == -1) | 590 | if (handle == -1) |
631 | { | 591 | { |
632 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 592 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
633 | return CASE_UNKNOWN; | 593 | return CASE_UNKNOWN; |
634 | } | 594 | } |
635 | else | 595 | else |
636 | { | 596 | { |
637 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 597 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
638 | ::close (handle); | 598 | ::close (handle); |
639 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 599 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
640 | { | 600 | { |
641 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 601 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
642 | return static_cast<OHingeStatus>( retval ); | 602 | return static_cast<OHingeStatus>( retval ); |
643 | } | 603 | } |
644 | else | 604 | else |
645 | { | 605 | { |
646 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 606 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
647 | return CASE_UNKNOWN; | 607 | return CASE_UNKNOWN; |
648 | } | 608 | } |
649 | } | 609 | } |
650 | } | 610 | } |
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h index 76a40d6..dc21546 100644 --- a/libopie2/opiecore/device/odevice_zaurus.h +++ b/libopie2/opiecore/device/odevice_zaurus.h | |||
@@ -1,100 +1,139 @@ | |||
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 | =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
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 | #ifndef ODEVICE_ZAURUS | 30 | #ifndef ODEVICE_ZAURUS |
31 | #define ODEVICE_ZAURUS | 31 | #define ODEVICE_ZAURUS |
32 | 32 | ||
33 | #include <opie2/odevice.h> | 33 | #include <opie2/odevice.h> |
34 | 34 | ||
35 | #ifndef ARRAY_SIZE | 35 | #ifndef ARRAY_SIZE |
36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | 36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | // _IO and friends are only defined in kernel headers ... | 39 | // _IO and friends are only defined in kernel headers ... |
40 | |||
41 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 40 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
42 | |||
43 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 41 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
44 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 42 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
45 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 43 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
46 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 44 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
47 | 45 | ||
46 | // Audio | ||
47 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | ||
48 | |||
49 | #define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | ||
50 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | ||
51 | |||
52 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | ||
53 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | ||
54 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | ||
55 | |||
56 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | ||
57 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | ||
58 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | ||
59 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | ||
60 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | ||
61 | |||
62 | // LED | ||
63 | #define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | ||
64 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | ||
65 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | ||
66 | |||
67 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | ||
68 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | ||
69 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | ||
70 | |||
71 | // Rotation and Power Management | ||
72 | #define SHARP_IOCTL_GET_ROTATION 0x413c | ||
73 | |||
74 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | ||
75 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | ||
76 | #define APM_EVT_POWER_BUTTON (1 << 0) | ||
77 | |||
78 | // Brightness | ||
79 | #define FL_IOCTL_STEP_CONTRAST 100 | ||
80 | |||
81 | #define CORGI_TOSA_BL_IOCTL_ON 1 | ||
82 | #define CORGI_TOSA_BL_IOCTL_OFF 2 | ||
83 | #define CORGI_TOSA_BL_IOCTL_STEP_CONTRAST 100 | ||
84 | #define CORGI_TOSA_BL_IOCTL_GET_STEP_CONTRAST 101 | ||
85 | #define CORGI_TOSA_BL_IOCTL_GET_STEP 102 | ||
86 | #define CORGI_BL_PROC_DEVICE corgi-bl | ||
87 | #define TOSA_BL_PROC_DEVICE tosa-bl | ||
48 | 88 | ||
49 | namespace Opie { | 89 | namespace Opie { |
50 | namespace Core { | 90 | namespace Core { |
51 | namespace Internal { | 91 | namespace Internal { |
52 | class Zaurus : public ODevice | 92 | class Zaurus : public ODevice |
53 | { | 93 | { |
54 | |||
55 | protected: | 94 | protected: |
56 | virtual void init(const QString&); | 95 | virtual void init(const QString&); |
57 | virtual void initButtons(); | 96 | virtual void initButtons(); |
58 | 97 | ||
59 | public: | 98 | public: |
60 | virtual bool setSoftSuspend ( bool soft ); | 99 | virtual bool setSoftSuspend ( bool soft ); |
61 | 100 | ||
62 | virtual bool setDisplayBrightness ( int b ); | 101 | virtual bool setDisplayBrightness ( int b ); |
63 | virtual int displayBrightnessResolution() const; | 102 | virtual int displayBrightnessResolution() const; |
64 | 103 | ||
65 | virtual void playAlarmSound(); | 104 | virtual void playAlarmSound(); |
66 | virtual void playKeySound(); | 105 | virtual void playKeySound(); |
67 | virtual void playTouchSound(); | 106 | virtual void playTouchSound(); |
68 | 107 | ||
69 | virtual QValueList <OLed> ledList() const; | 108 | virtual QValueList <OLed> ledList() const; |
70 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 109 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
71 | virtual OLedState ledState( OLed led ) const; | 110 | virtual OLedState ledState( OLed led ) const; |
72 | virtual bool setLedState( OLed led, OLedState st ); | 111 | virtual bool setLedState( OLed led, OLedState st ); |
73 | 112 | ||
74 | virtual bool hasHingeSensor() const; | 113 | virtual bool hasHingeSensor() const; |
75 | virtual OHingeStatus readHingeSensor(); | 114 | virtual OHingeStatus readHingeSensor(); |
76 | 115 | ||
77 | virtual bool suspend(); | 116 | virtual bool suspend(); |
78 | virtual Transformation rotation() const; | 117 | virtual Transformation rotation() const; |
79 | virtual ODirection direction() const; | 118 | virtual ODirection direction() const; |
80 | 119 | ||
81 | protected: | 120 | protected: |
82 | virtual void buzzer ( int snd ); | 121 | virtual void buzzer ( int snd ); |
83 | 122 | ||
84 | OLedState m_leds [1]; | 123 | OLedState m_leds [1]; |
85 | bool m_embedix; | 124 | bool m_embedix; |
86 | }; | 125 | }; |
87 | 126 | ||
88 | struct z_button { | 127 | struct z_button { |
89 | Qt::Key code; | 128 | Qt::Key code; |
90 | char *utext; | 129 | char *utext; |
91 | char *pix; | 130 | char *pix; |
92 | char *fpressedservice; | 131 | char *fpressedservice; |
93 | char *fpressedaction; | 132 | char *fpressedaction; |
94 | char *fheldservice; | 133 | char *fheldservice; |
95 | char *fheldaction; | 134 | char *fheldaction; |
96 | }; | 135 | }; |
97 | } | 136 | } |
98 | } | 137 | } |
99 | } | 138 | } |
100 | #endif | 139 | #endif |