author | mickeyl <mickeyl> | 2004-06-12 16:54:50 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-06-12 16:54:50 (UTC) |
commit | b1235df3628d178891eeefed630a22da46b25952 (patch) (unidiff) | |
tree | c88a3cb04adcc9fe214ff08e3c0b96b21e3c4f0a /libopie2/opiecore/device/odevice_zaurus.cpp | |
parent | 7a62e8e3601ee98f5f06261c361fe8132334cd56 (diff) | |
download | opie-b1235df3628d178891eeefed630a22da46b25952.zip opie-b1235df3628d178891eeefed630a22da46b25952.tar.gz opie-b1235df3628d178891eeefed630a22da46b25952.tar.bz2 |
- refactor the distribution detection code
- add detection of OpenEmbedded and generic linux distributions
- simplify the zaurus model detection code
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 61 |
1 files changed, 23 insertions, 38 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index e8b813e..6ac3157 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -112,42 +112,34 @@ struct z_button z_buttons_c700 [] = { | |||
112 | // Only question right now is: Do we really need to do it? Because as soon | 112 | // 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 | 113 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
114 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 114 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
115 | // | 115 | // |
116 | // Comments? - mickeyl. | 116 | // Comments? - mickeyl. |
117 | 117 | ||
118 | void Zaurus::init(const QString&) | 118 | void Zaurus::init(const QString& cpu_info) |
119 | { | ||
120 | // generic distribution code already scanned /etc/issue at that point - | ||
121 | // embedix releases contain "Embedix <version> | Linux for Embedded Devices" | ||
122 | if ( d->m_sysverstr.contains( "embedix", false ) ) | ||
119 | { | 123 | { |
120 | d->m_vendorstr = "Sharp"; | 124 | d->m_vendorstr = "Sharp"; |
121 | d->m_vendor = Vendor_Sharp; | 125 | d->m_vendor = Vendor_Sharp; |
122 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 126 | d->m_systemstr = "Zaurus"; |
123 | 127 | d->m_system = System_Zaurus; | |
124 | // QFile f ( "/proc/filesystems" ); | 128 | m_embedix = true; |
125 | QString model; | 129 | } |
126 | 130 | else | |
127 | // It isn't a good idea to check the system configuration to | 131 | { |
128 | // detect the distribution ! | ||
129 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | ||
130 | // because it uses a jffs2 filesystem.. | ||
131 | // (eilers) | ||
132 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { | ||
133 | QFile f ("/etc/oz_version"); | ||
134 | if ( f.exists() ){ | ||
135 | d->m_vendorstr = "OpenZaurus Team"; | 132 | d->m_vendorstr = "OpenZaurus Team"; |
136 | d->m_systemstr = "OpenZaurus"; | 133 | d->m_systemstr = "OpenZaurus"; |
137 | d->m_system = System_OpenZaurus; | 134 | d->m_system = System_OpenZaurus; |
135 | // sysver already gathered | ||
138 | 136 | ||
139 | if ( f. open ( IO_ReadOnly )) { | 137 | // Openzaurus sometimes uses the embedix kernel, check if this is one |
140 | QTextStream ts ( &f ); | ||
141 | d->m_sysverstr = ts. readLine();//. mid ( 10 ); | ||
142 | f. close(); | ||
143 | } | ||
144 | |||
145 | // Openzaurus sometimes uses the embedix kernel! | ||
146 | // => Check whether this is an embedix kernel | ||
147 | FILE *uname = popen("uname -r", "r"); | 138 | FILE *uname = popen("uname -r", "r"); |
139 | QFile f; | ||
148 | QString line; | 140 | QString line; |
149 | if ( f.open(IO_ReadOnly, uname) ) { | 141 | if ( f.open(IO_ReadOnly, uname) ) { |
150 | QTextStream ts ( &f ); | 142 | QTextStream ts ( &f ); |
151 | line = ts. readLine(); | 143 | line = ts. readLine(); |
152 | int loc = line. find ( "embedix" ); | 144 | int loc = line. find ( "embedix" ); |
153 | if ( loc != -1 ) | 145 | if ( loc != -1 ) |
@@ -155,29 +147,20 @@ void Zaurus::init(const QString&) | |||
155 | else | 147 | else |
156 | m_embedix = false; | 148 | m_embedix = false; |
157 | f. close(); | 149 | f. close(); |
158 | } | 150 | } |
159 | pclose(uname); | 151 | pclose(uname); |
160 | } | 152 | } |
161 | else { | ||
162 | d->m_systemstr = "Zaurus"; | ||
163 | d->m_system = System_Zaurus; | ||
164 | } | ||
165 | 153 | ||
166 | f. setName ( "/proc/cpuinfo" ); | 154 | // check the Zaurus model |
167 | if ( f. open ( IO_ReadOnly ) ) { | 155 | QString model; |
168 | QTextStream ts ( &f ); | 156 | int loc = cpu_info.find( ":" ); |
169 | QString line; | ||
170 | while( line = ts. readLine() ) { | ||
171 | if ( line. left ( 8 ) == "Hardware" ) | ||
172 | break; | ||
173 | } | ||
174 | int loc = line. find ( ":" ); | ||
175 | if ( loc != -1 ) | 157 | if ( loc != -1 ) |
176 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 158 | model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); |
177 | } | 159 | else |
160 | model = cpu_info; | ||
178 | 161 | ||
179 | if ( model == "SHARP Corgi" ) { | 162 | if ( model == "SHARP Corgi" ) { |
180 | d->m_model = Model_Zaurus_SLC7x0; | 163 | d->m_model = Model_Zaurus_SLC7x0; |
181 | d->m_modelstr = "Zaurus SL-C700"; | 164 | d->m_modelstr = "Zaurus SL-C700"; |
182 | } else if ( model == "SHARP Shepherd" ) { | 165 | } else if ( model == "SHARP Shepherd" ) { |
183 | d->m_model = Model_Zaurus_SLC7x0; | 166 | d->m_model = Model_Zaurus_SLC7x0; |
@@ -190,15 +173,17 @@ void Zaurus::init(const QString&) | |||
190 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; | 173 | d->m_modelstr = "Zaurus SL-B500 or SL-5600"; |
191 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 174 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
192 | d->m_model = Model_Zaurus_SL5500; | 175 | d->m_model = Model_Zaurus_SL5500; |
193 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 176 | d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
194 | } else { | 177 | } else { |
195 | d->m_model = Model_Zaurus_SL5500; | 178 | d->m_model = Model_Zaurus_SL5500; |
196 | d->m_modelstr = "Zaurus (Model unknown)"; | 179 | d->m_modelstr = "Unkown Zaurus"; |
197 | } | 180 | } |
198 | 181 | ||
182 | // set initial rotation | ||
183 | |||
199 | bool flipstate = false; | 184 | bool flipstate = false; |
200 | switch ( d->m_model ) { | 185 | switch ( d->m_model ) { |
201 | case Model_Zaurus_SLA300: | 186 | case Model_Zaurus_SLA300: |
202 | d->m_rotation = Rot0; | 187 | d->m_rotation = Rot0; |
203 | break; | 188 | break; |
204 | case Model_Zaurus_SLC7x0: | 189 | case Model_Zaurus_SLC7x0: |