summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-03-31 20:03:31 (UTC)
committer mickeyl <mickeyl>2005-03-31 20:03:31 (UTC)
commit629c1c9a366f56e9d98940f8dcd0778d039f1421 (patch) (unidiff)
treeb54e1da270ada28f0127585d4d9dcf46e36c3de1
parent44bfce59cd3cfb2fa6d75675dee5db5edb36e522 (diff)
downloadopie-629c1c9a366f56e9d98940f8dcd0778d039f1421.zip
opie-629c1c9a366f56e9d98940f8dcd0778d039f1421.tar.gz
opie-629c1c9a366f56e9d98940f8dcd0778d039f1421.tar.bz2
check for '2.4' kernel rather than for an Embedix version, since we will
most likely neither see a unified 2.4 OZ kernel, nor a Embedix 2.6.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp26
2 files changed, 8 insertions, 20 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index cf2061b..af77ed1 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -25,194 +25,192 @@
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_beagle.h" 30#include "odevice_beagle.h"
31#include "odevice_ipaq.h" 31#include "odevice_ipaq.h"
32#include "odevice_jornada.h" 32#include "odevice_jornada.h"
33#include "odevice_ramses.h" 33#include "odevice_ramses.h"
34#include "odevice_simpad.h" 34#include "odevice_simpad.h"
35#include "odevice_yopy.h" 35#include "odevice_yopy.h"
36#include "odevice_zaurus.h" 36#include "odevice_zaurus.h"
37#include "odevice_genuineintel.h" 37#include "odevice_genuineintel.h"
38 38
39/* QT */ 39/* QT */
40#include <qapplication.h> 40#include <qapplication.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qwindowsystem_qws.h> 43#include <qwindowsystem_qws.h>
44 44
45/* OPIE */ 45/* OPIE */
46#include <qpe/config.h> 46#include <qpe/config.h>
47#include <qpe/resource.h> 47#include <qpe/resource.h>
48#include <qpe/sound.h> 48#include <qpe/sound.h>
49#include <qpe/qcopenvelope_qws.h> 49#include <qpe/qcopenvelope_qws.h>
50#include <qpe/sound.h> 50#include <qpe/sound.h>
51#include <opie2/okeyfilter.h> 51#include <opie2/okeyfilter.h>
52 52
53/* STD */ 53/* STD */
54#include <fcntl.h> 54#include <fcntl.h>
55#include <math.h> 55#include <math.h>
56#include <stdlib.h> 56#include <stdlib.h>
57#include <signal.h> 57#include <signal.h>
58#include <sys/ioctl.h> 58#include <sys/ioctl.h>
59#include <sys/time.h> 59#include <sys/time.h>
60#include <unistd.h> 60#include <unistd.h>
61#ifndef QT_NO_SOUND 61#ifndef QT_NO_SOUND
62#include <linux/soundcard.h> 62#include <linux/soundcard.h>
63#endif 63#endif
64 64
65namespace Opie { 65namespace Opie {
66namespace Core { 66namespace Core {
67 67
68static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 68static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
69 69
70 70
71/* STATIC and common implementation */ 71/* STATIC and common implementation */
72/* EXPORT */ ODistribution distributions[] = { 72/* EXPORT */ ODistribution distributions[] = {
73 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 73 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
74 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 74 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
75 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 75 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
76 { System_Unknown, "Linux", "/etc/issue" }, 76 { System_Unknown, "Linux", "/etc/issue" },
77}; 77};
78 78
79 79
80/* EXPORT */ bool isQWS(){ 80/* EXPORT */ bool isQWS(){
81 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 81 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
82} 82}
83 83
84/* EXPORT */ QCString makeChannel ( const char *str ){ 84/* EXPORT */ QCString makeChannel ( const char *str ){
85 if ( str && !::strchr ( str, '/' )) 85 if ( str && !::strchr ( str, '/' ))
86 return QCString ( "QPE/Application/" ) + str; 86 return QCString ( "QPE/Application/" ) + str;
87 else 87 else
88 return str; 88 return str;
89} 89}
90 90
91 91
92 92
93/* Now the default implementation of ODevice */ 93/* Now the default implementation of ODevice */
94 94
95struct default_button default_buttons [] = { 95struct default_button default_buttons [] = {
96 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 96 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
97 "devicebuttons/z_calendar", 97 "devicebuttons/z_calendar",
98 "datebook", "nextView()", 98 "datebook", "nextView()",
99 "today", "raise()" }, 99 "today", "raise()" },
100 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 100 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
101 "devicebuttons/z_contact", 101 "devicebuttons/z_contact",
102 "addressbook", "raise()", 102 "addressbook", "raise()",
103 "addressbook", "beamBusinessCard()" }, 103 "addressbook", "beamBusinessCard()" },
104 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 104 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
105 "devicebuttons/z_home", 105 "devicebuttons/z_home",
106 "QPE/Launcher", "home()", 106 "QPE/Launcher", "home()",
107 "buttonsettings", "raise()" }, 107 "buttonsettings", "raise()" },
108 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 108 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
109 "devicebuttons/z_menu", 109 "devicebuttons/z_menu",
110 "QPE/TaskBar", "toggleMenu()", 110 "QPE/TaskBar", "toggleMenu()",
111 "QPE/TaskBar", "toggleStartMenu()" }, 111 "QPE/TaskBar", "toggleStartMenu()" },
112 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 112 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
113 "devicebuttons/z_mail", 113 "devicebuttons/z_mail",
114 "opiemail", "raise()", 114 "opiemail", "raise()",
115 "opiemail", "newMail()" }, 115 "opiemail", "newMail()" },
116}; 116};
117 117
118ODevice *ODevice::inst() 118ODevice *ODevice::inst()
119{ 119{
120 static ODevice *dev = 0; 120 static ODevice *dev = 0;
121
122 // rewrite this to only use /proc/cpuinfo or so
123 QString cpu_info; 121 QString cpu_info;
124 122
125 if ( !dev ) 123 if ( !dev )
126 { 124 {
127 QFile f( PATH_PROC_CPUINFO ); 125 QFile f( PATH_PROC_CPUINFO );
128 if ( f.open( IO_ReadOnly ) ) 126 if ( f.open( IO_ReadOnly ) )
129 { 127 {
130 QTextStream s( &f ); 128 QTextStream s( &f );
131 while ( !s.atEnd() ) 129 while ( !s.atEnd() )
132 { 130 {
133 QString line; 131 QString line;
134 line = s.readLine(); 132 line = s.readLine();
135 if ( line.startsWith( "Hardware" ) ) 133 if ( line.startsWith( "Hardware" ) )
136 { 134 {
137 qDebug( "ODevice() - found '%s'", (const char*) line ); 135 qDebug( "ODevice() - found '%s'", (const char*) line );
138 cpu_info = line; 136 cpu_info = line;
139 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
140 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
141 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
142 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
143 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
144 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); 142 else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
145 else qWarning( "ODevice() - unknown hardware - using default." ); 143 else qWarning( "ODevice() - unknown hardware - using default." );
146 break; 144 break;
147 } else if ( line.startsWith( "vendor_id" ) ) { 145 } else if ( line.startsWith( "vendor_id" ) ) {
148 qDebug( "ODevice() - found '%s'", (const char*) line ); 146 qDebug( "ODevice() - found '%s'", (const char*) line );
149 cpu_info = line; 147 cpu_info = line;
150 if( line.contains( "genuineintel", false ) ) { 148 if( line.contains( "genuineintel", false ) ) {
151 dev = new Internal::GenuineIntel(); 149 dev = new Internal::GenuineIntel();
152 break; 150 break;
153 } 151 }
154 } 152 }
155 } 153 }
156 } 154 }
157 else 155 else
158 { 156 {
159 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 157 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
160 } 158 }
161 if ( !dev ) dev = new ODevice(); 159 if ( !dev ) dev = new ODevice();
162 dev->init(cpu_info); 160 dev->init(cpu_info);
163 } 161 }
164 return dev; 162 return dev;
165} 163}
166 164
167ODevice::ODevice() 165ODevice::ODevice()
168{ 166{
169 d = new ODeviceData; 167 d = new ODeviceData;
170 168
171 d->m_modelstr = "Unknown"; 169 d->m_modelstr = "Unknown";
172 d->m_model = Model_Unknown; 170 d->m_model = Model_Unknown;
173 d->m_vendorstr = "Unknown"; 171 d->m_vendorstr = "Unknown";
174 d->m_vendor = Vendor_Unknown; 172 d->m_vendor = Vendor_Unknown;
175 d->m_systemstr = "Unknown"; 173 d->m_systemstr = "Unknown";
176 d->m_system = System_Unknown; 174 d->m_system = System_Unknown;
177 d->m_sysverstr = "0.0"; 175 d->m_sysverstr = "0.0";
178 d->m_rotation = Rot0; 176 d->m_rotation = Rot0;
179 d->m_direction = CW; 177 d->m_direction = CW;
180 178
181 d->m_holdtime = 1000; // 1000ms 179 d->m_holdtime = 1000; // 1000ms
182 d->m_buttons = 0; 180 d->m_buttons = 0;
183 d->m_cpu_frequencies = new QStrList; 181 d->m_cpu_frequencies = new QStrList;
184 182
185 183
186 /* mixer */ 184 /* mixer */
187 d->m_sound = d->m_vol = d->m_mixer = -1; 185 d->m_sound = d->m_vol = d->m_mixer = -1;
188 186
189 /* System QCopChannel created */ 187 /* System QCopChannel created */
190 d->m_initializedButtonQcop = false; 188 d->m_initializedButtonQcop = false;
191 189
192 // New distribution detection code first checks for legacy distributions, 190 // New distribution detection code first checks for legacy distributions,
193 // identified by /etc/familiar-version or /etc/oz_version. 191 // identified by /etc/familiar-version or /etc/oz_version.
194 // Then check for OpenEmbedded and lastly, read /etc/issue 192 // Then check for OpenEmbedded and lastly, read /etc/issue
195 193
196 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 194 for ( unsigned int i = 0; i < sizeof distributions; ++i )
197 { 195 {
198 if ( QFile::exists( distributions[i].sysvfile ) ) 196 if ( QFile::exists( distributions[i].sysvfile ) )
199 { 197 {
200 d->m_systemstr = distributions[i].sysstr; 198 d->m_systemstr = distributions[i].sysstr;
201 d->m_system = distributions[i].system; 199 d->m_system = distributions[i].system;
202 d->m_sysverstr = "<Unknown>"; 200 d->m_sysverstr = "<Unknown>";
203 QFile f( distributions[i].sysvfile ); 201 QFile f( distributions[i].sysvfile );
204 if ( f.open( IO_ReadOnly ) ) 202 if ( f.open( IO_ReadOnly ) )
205 { 203 {
206 QTextStream ts( &f ); 204 QTextStream ts( &f );
207 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); 205 d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
208 } 206 }
209 break; 207 break;
210 } 208 }
211 } 209 }
212} 210}
213 211
214void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 212void ODevice::systemMessage( const QCString &msg, const QByteArray & )
215{ 213{
216 if ( msg == "deviceButtonMappingChanged()" ) { 214 if ( msg == "deviceButtonMappingChanged()" ) {
217 reloadButtonMapping(); 215 reloadButtonMapping();
218 } 216 }
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 3bd7f6e..e9b163a 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -21,310 +21,300 @@
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 <opie2/oinputsystem.h> 39#include <opie2/oinputsystem.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42#include <qpe/sound.h> 42#include <qpe/sound.h>
43#include <qpe/qcopenvelope_qws.h> 43#include <qpe/qcopenvelope_qws.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Internal; 58using namespace Opie::Core::Internal;
59 59
60struct z_button z_buttons [] = { 60struct z_button z_buttons [] = {
61 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 61 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
62 "devicebuttons/z_calendar", 62 "devicebuttons/z_calendar",
63 "datebook", "nextView()", 63 "datebook", "nextView()",
64 "today", "raise()" }, 64 "today", "raise()" },
65 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 65 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
66 "devicebuttons/z_contact", 66 "devicebuttons/z_contact",
67 "addressbook", "raise()", 67 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 68 "addressbook", "beamBusinessCard()" },
69 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 69 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
70 "devicebuttons/z_home", 70 "devicebuttons/z_home",
71 "QPE/Launcher", "home()", 71 "QPE/Launcher", "home()",
72 "buttonsettings", "raise()" }, 72 "buttonsettings", "raise()" },
73 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 73 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
74 "devicebuttons/z_menu", 74 "devicebuttons/z_menu",
75 "QPE/TaskBar", "toggleMenu()", 75 "QPE/TaskBar", "toggleMenu()",
76 "QPE/TaskBar", "toggleStartMenu()" }, 76 "QPE/TaskBar", "toggleStartMenu()" },
77 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 77 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
78 "devicebuttons/z_mail", 78 "devicebuttons/z_mail",
79 "opiemail", "raise()", 79 "opiemail", "raise()",
80 "opiemail", "newMail()" }, 80 "opiemail", "newMail()" },
81}; 81};
82 82
83struct z_button z_buttons_c700 [] = { 83struct z_button z_buttons_c700 [] = {
84 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 84 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
85 "devicebuttons/z_calendar", 85 "devicebuttons/z_calendar",
86 "datebook", "nextView()", 86 "datebook", "nextView()",
87 "today", "raise()" }, 87 "today", "raise()" },
88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 88 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
89 "devicebuttons/z_contact", 89 "devicebuttons/z_contact",
90 "addressbook", "raise()", 90 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 91 "addressbook", "beamBusinessCard()" },
92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 92 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
93 "devicebuttons/z_home", 93 "devicebuttons/z_home",
94 "QPE/Launcher", "home()", 94 "QPE/Launcher", "home()",
95 "buttonsettings", "raise()" }, 95 "buttonsettings", "raise()" },
96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
97 "devicebuttons/z_menu", 97 "devicebuttons/z_menu",
98 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
99 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 100 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
101 "devicebuttons/z_mail", 101 "devicebuttons/z_mail",
102 "opiemail", "raise()", 102 "opiemail", "raise()",
103 "opiemail", "newMail()" }, 103 "opiemail", "newMail()" },
104 104
105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"), 105 { Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Hinge1"),
106 "devicebuttons/z_hinge1", 106 "devicebuttons/z_hinge1",
107 "QPE/Rotation", "rotateDefault()",0}, 107 "QPE/Rotation", "rotateDefault()",0},
108 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"), 108 { Qt::Key_F16, QT_TRANSLATE_NOOP("Button", "Hinge2"),
109 "devicebuttons/z_hinge2", 109 "devicebuttons/z_hinge2",
110 "QPE/Rotation", "rotateDefault()",0}, 110 "QPE/Rotation", "rotateDefault()",0},
111 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"), 111 { Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
112 "devicebuttons/z_hinge3", 112 "devicebuttons/z_hinge3",
113 "QPE/Rotation", "rotateDefault()",0}, 113 "QPE/Rotation", "rotateDefault()",0},
114}; 114};
115 115
116// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 116// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
117// class up into individual classes. We need three classes 117// class up into individual classes. We would need three classes
118// 118//
119// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 119// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
120// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 120// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
121// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000) 121// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000)
122// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000) 122// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
123//
124// Only question right now is: Do we really need to do it? Because as soon
125// as the OpenZaurus kernel is ready, there will be a unified interface for all
126// Zaurus models (concerning apm, backlight, buttons, etc.)
127//
128// Comments? - mickeyl.
129 123
130void Zaurus::init(const QString& cpu_info) 124void Zaurus::init(const QString& cpu_info)
131{ 125{
132 // Set the time to wait until the system is realy suspended 126 // Set the time to wait until the system is really suspended
133 // the delta between apm --suspend and sleeping 127 // the delta between apm --suspend and sleeping
134 setAPMTimeOut( 15000 ); 128 setAPMTimeOut( 15000 );
135 129
136 // generic distribution code already scanned /etc/issue at that point - 130 // generic distribution code already scanned /etc/issue at that point -
137 // embedix releases contain "Embedix <version> | Linux for Embedded Devices" 131 // embedix releases contain "Embedix <version> | Linux for Embedded Devices"
138 if ( d->m_sysverstr.contains( "embedix", false ) ) 132 if ( d->m_sysverstr.contains( "embedix", false ) )
139 { 133 {
140 d->m_vendorstr = "Sharp"; 134 d->m_vendorstr = "Sharp";
141 d->m_vendor = Vendor_Sharp; 135 d->m_vendor = Vendor_Sharp;
142 d->m_systemstr = "Zaurus"; 136 d->m_systemstr = "Zaurus";
143 d->m_system = System_Zaurus; 137 d->m_system = System_Zaurus;
144 m_embedix = true; 138 m_embedix = true;
145 } 139 }
146 else 140 else
147 { 141 {
148 d->m_vendorstr = "OpenZaurus Team"; 142 d->m_vendorstr = "OpenZaurus Team";
149 d->m_systemstr = "OpenZaurus"; 143 d->m_systemstr = "OpenZaurus";
150 d->m_system = System_OpenZaurus; 144 d->m_system = System_OpenZaurus;
151 // sysver already gathered 145 // sysver already gathered
152 146
153 // OpenZaurus sometimes uses the embedix kernel, check if this is one 147 // OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one
154 FILE *uname = popen("uname -r", "r"); 148 FILE *uname = popen("uname -r", "r");
155 QFile f; 149 QFile f;
156 QString line; 150 QString line;
157 if ( f.open(IO_ReadOnly, uname) ) { 151 if ( f.open(IO_ReadOnly, uname) ) {
158 QTextStream ts ( &f ); 152 QTextStream ts ( &f );
159 line = ts. readLine(); 153 line = ts.readLine();
160 int loc = line. find ( "embedix" ); 154 m_embedix = line.startsWith( "2.4." );
161 if ( loc != -1 )
162 m_embedix = true;
163 else
164 m_embedix = false;
165 f.close(); 155 f.close();
166 } 156 }
167 pclose(uname); 157 pclose(uname);
168 } 158 }
169 159
170 // check the Zaurus model 160 // check the Zaurus model
171 QString model; 161 QString model;
172 int loc = cpu_info.find( ":" ); 162 int loc = cpu_info.find( ":" );
173 if ( loc != -1 ) 163 if ( loc != -1 )
174 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 164 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
175 else 165 else
176 model = cpu_info; 166 model = cpu_info;
177 167
178 if ( model == "SHARP Corgi" ) { 168 if ( model == "SHARP Corgi" ) {
179 d->m_model = Model_Zaurus_SLC7x0; 169 d->m_model = Model_Zaurus_SLC7x0;
180 d->m_modelstr = "Zaurus SL-C700"; 170 d->m_modelstr = "Zaurus SL-C700";
181 } else if ( model == "SHARP Shepherd" ) { 171 } else if ( model == "SHARP Shepherd" ) {
182 d->m_model = Model_Zaurus_SLC7x0; 172 d->m_model = Model_Zaurus_SLC7x0;
183 d->m_modelstr = "Zaurus SL-C750"; 173 d->m_modelstr = "Zaurus SL-C750";
184 } else if ( model == "SHARP Husky" ) { 174 } else if ( model == "SHARP Husky" ) {
185 d->m_model = Model_Zaurus_SLC7x0; 175 d->m_model = Model_Zaurus_SLC7x0;
186 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 176 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
187 } else if ( model == "SHARP Boxer" ) { 177 } else if ( model == "SHARP Boxer" ) {
188 d->m_model = Model_Zaurus_SLC7x0; 178 d->m_model = Model_Zaurus_SLC7x0;
189 d->m_modelstr = "Zaurus SL-C760 or SL-C860"; 179 d->m_modelstr = "Zaurus SL-C760 or SL-C860";
190 } else if ( model == "SHARP Poodle" ) { 180 } else if ( model == "SHARP Poodle" ) {
191 d->m_model = Model_Zaurus_SLB600; 181 d->m_model = Model_Zaurus_SLB600;
192 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 182 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
193 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 183 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
194 d->m_model = Model_Zaurus_SL5500; 184 d->m_model = Model_Zaurus_SL5500;
195 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 185 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
196 } else if ( model == "SHARP Tosa" ) { 186 } else if ( model == "SHARP Tosa" ) {
197 d->m_model = Model_Zaurus_SL6000; 187 d->m_model = Model_Zaurus_SL6000;
198 d->m_modelstr = "Zaurus SL-6000"; 188 d->m_modelstr = "Zaurus SL-6000";
199 } else if ( model == "SHARP Spitz" ) { 189 } else if ( model == "SHARP Spitz" ) {
200 d->m_model = Model_Zaurus_SLC3000; 190 d->m_model = Model_Zaurus_SLC3000;
201 d->m_modelstr = "Zaurus SL-C3000"; 191 d->m_modelstr = "Zaurus SL-C3000";
202 } else if ( model == "SHARP Akita" ) { 192 } else if ( model == "SHARP Akita" ) {
203 d->m_model = Model_Zaurus_SLC1000; 193 d->m_model = Model_Zaurus_SLC1000;
204 d->m_modelstr = "Zaurus SL-C1000"; 194 d->m_modelstr = "Zaurus SL-C1000";
205 } else { 195 } else {
206 d->m_model = Model_Zaurus_SL5500; 196 d->m_model = Model_Zaurus_SL5500;
207 d->m_modelstr = "Unknown Zaurus"; 197 d->m_modelstr = "Unknown Zaurus";
208 } 198 }
209 199
210 // set initial rotation 200 // set initial rotation
211 switch( d->m_model ) { 201 switch( d->m_model ) {
212 case Model_Zaurus_SL6000: // fallthrough 202 case Model_Zaurus_SL6000: // fallthrough
213 case Model_Zaurus_SLA300: 203 case Model_Zaurus_SLA300:
214 d->m_rotation = Rot0; 204 d->m_rotation = Rot0;
215 break; 205 break;
216 case Model_Zaurus_SLC3000: // fallthrough 206 case Model_Zaurus_SLC3000: // fallthrough
217 case Model_Zaurus_SLC1000: // fallthrough 207 case Model_Zaurus_SLC1000: // fallthrough
218 case Model_Zaurus_SLC7x0: 208 case Model_Zaurus_SLC7x0:
219 d->m_rotation = rotation(); 209 d->m_rotation = rotation();
220 d->m_direction = direction(); 210 d->m_direction = direction();
221 break; 211 break;
222 case Model_Zaurus_SLB600: // fallthrough 212 case Model_Zaurus_SLB600: // fallthrough
223 case Model_Zaurus_SL5000: // fallthrough 213 case Model_Zaurus_SL5000: // fallthrough
224 case Model_Zaurus_SL5500: // fallthrough 214 case Model_Zaurus_SL5500: // fallthrough
225 default: 215 default:
226 d->m_rotation = Rot270; 216 d->m_rotation = Rot270;
227 break; 217 break;
228 } 218 }
229 m_leds[0] = Led_Off; 219 m_leds[0] = Led_Off;
230 220
231 if ( m_embedix ) 221 if ( m_embedix )
232 qDebug( "Zaurus::init() - Using the Embedix HAL on a %s", (const char*) d->m_modelstr ); 222 qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr );
233 else 223 else
234 qDebug( "Zaurus::init() - Using the OpenZaurus HAL on a %s", (const char*) d->m_modelstr ); 224 qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
235} 225}
236 226
237void Zaurus::initButtons() 227void Zaurus::initButtons()
238{ 228{
239 if ( d->m_buttons ) 229 if ( d->m_buttons )
240 return; 230 return;
241 231
242 232
243 d->m_buttons = new QValueList <ODeviceButton>; 233 d->m_buttons = new QValueList <ODeviceButton>;
244 234
245 struct z_button * pz_buttons; 235 struct z_button * pz_buttons;
246 int buttoncount; 236 int buttoncount;
247 switch ( d->m_model ) { 237 switch ( d->m_model ) {
248 case Model_Zaurus_SLC3000: // fallthrough 238 case Model_Zaurus_SLC3000: // fallthrough
249 case Model_Zaurus_SLC1000: // fallthrough 239 case Model_Zaurus_SLC1000: // fallthrough
250 case Model_Zaurus_SLC7x0: 240 case Model_Zaurus_SLC7x0:
251 if ( isQWS( ) ) { 241 if ( isQWS( ) ) {
252 addPreHandler(this); // hinge-sensor-handler 242 addPreHandler(this); // hinge-sensor-handler
253 } 243 }
254 pz_buttons = z_buttons_c700; 244 pz_buttons = z_buttons_c700;
255 buttoncount = ARRAY_SIZE(z_buttons_c700); 245 buttoncount = ARRAY_SIZE(z_buttons_c700);
256 break; 246 break;
257 default: 247 default:
258 pz_buttons = z_buttons; 248 pz_buttons = z_buttons;
259 buttoncount = ARRAY_SIZE(z_buttons); 249 buttoncount = ARRAY_SIZE(z_buttons);
260 break; 250 break;
261 } 251 }
262 252
263 for ( int i = 0; i < buttoncount; i++ ) { 253 for ( int i = 0; i < buttoncount; i++ ) {
264 struct z_button *zb = pz_buttons + i; 254 struct z_button *zb = pz_buttons + i;
265 ODeviceButton b; 255 ODeviceButton b;
266 256
267 b.setKeycode( zb->code ); 257 b.setKeycode( zb->code );
268 b.setUserText( QObject::tr( "Button", zb->utext )); 258 b.setUserText( QObject::tr( "Button", zb->utext ));
269 b.setPixmap( Resource::loadPixmap( zb->pix )); 259 b.setPixmap( Resource::loadPixmap( zb->pix ));
270 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction )); 260 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
271 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction )); 261 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
272 d->m_buttons->append( b ); 262 d->m_buttons->append( b );
273 } 263 }
274 264
275 reloadButtonMapping(); 265 reloadButtonMapping();
276} 266}
277 267
278 268
279 269
280typedef struct sharp_led_status { 270typedef struct sharp_led_status {
281 int which; /* select which LED status is wanted. */ 271 int which; /* select which LED status is wanted. */
282 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 272 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
283} sharp_led_status; 273} sharp_led_status;
284 274
285void Zaurus::buzzer( int sound ) 275void Zaurus::buzzer( int sound )
286{ 276{
287#ifndef QT_NO_SOUND 277#ifndef QT_NO_SOUND
288 Sound *snd = 0; 278 Sound *snd = 0;
289 279
290 // All devices except SL5500 have a DSP device 280 // All devices except SL5500 have a DSP device
291 if ( d->m_model != Model_Zaurus_SL5000 281 if ( d->m_model != Model_Zaurus_SL5000
292 && d->m_model != Model_Zaurus_SL5500 ) { 282 && d->m_model != Model_Zaurus_SL5500 ) {
293 283
294 switch ( sound ){ 284 switch ( sound ){
295 case SHARP_BUZ_TOUCHSOUND: { 285 case SHARP_BUZ_TOUCHSOUND: {
296 static Sound touch_sound("touchsound"); 286 static Sound touch_sound("touchsound");
297 snd = &touch_sound; 287 snd = &touch_sound;
298 } 288 }
299 break; 289 break;
300 case SHARP_BUZ_KEYSOUND: { 290 case SHARP_BUZ_KEYSOUND: {
301 static Sound key_sound( "keysound" ); 291 static Sound key_sound( "keysound" );
302 snd = &key_sound; 292 snd = &key_sound;
303 } 293 }
304 break; 294 break;
305 case SHARP_BUZ_SCHEDULE_ALARM: 295 case SHARP_BUZ_SCHEDULE_ALARM:
306 default: { 296 default: {
307 static Sound alarm_sound("alarm"); 297 static Sound alarm_sound("alarm");
308 snd = &alarm_sound; 298 snd = &alarm_sound;
309 } 299 }
310 break; 300 break;
311 } 301 }
312 } 302 }
313 303
314 // If a soundname is defined, we expect that this device has 304 // If a soundname is defined, we expect that this device has
315 // sound capabilities.. Otherwise we expect to have the buzzer 305 // sound capabilities.. Otherwise we expect to have the buzzer
316 // device.. 306 // device..
317 if ( snd && snd->isFinished() ){ 307 if ( snd && snd->isFinished() ){
318 changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); 308 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
319 snd->play(); 309 snd->play();
320 } else if( !snd ) { 310 } else if( !snd ) {
321 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 311 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
322 312
323 if ( fd >= 0 ) { 313 if ( fd >= 0 ) {
324 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 314 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
325 ::close ( fd ); 315 ::close ( fd );
326 } 316 }
327 317
328 } 318 }
329#endif 319#endif
330} 320}