author | mickeyl <mickeyl> | 2003-12-30 02:17:25 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-12-30 02:17:25 (UTC) |
commit | b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a (patch) (unidiff) | |
tree | 98db0a0053c53e98ba758773f80ad8e14c9564c9 | |
parent | b636d3d91e8456b22bc450b3d7f3a862b7f615a9 (diff) | |
download | opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.zip opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.tar.gz opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.tar.bz2 |
fix a problem in the c7x0 backlight handling...
Bah! Got confused by the input interval for ODevice::setDisplayBrightness()
(once) again - it has been ridiculous to scale that down from [0-255] to the actual
interval since the day we invented ODevice::displayBrightnessResolution().
I'm going to remove that antique cruft soon.
-rw-r--r-- | libopie/odevice.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index bc09e92..82a0099 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1046,1449 +1046,1451 @@ void Yopy::init ( ) | |||
1046 | 1046 | ||
1047 | QFile f ( "/etc/issue" ); | 1047 | QFile f ( "/etc/issue" ); |
1048 | if ( f. open ( IO_ReadOnly )) { | 1048 | if ( f. open ( IO_ReadOnly )) { |
1049 | QTextStream ts ( &f ); | 1049 | QTextStream ts ( &f ); |
1050 | ts.readLine(); | 1050 | ts.readLine(); |
1051 | d-> m_sysverstr = ts. readLine ( ); | 1051 | d-> m_sysverstr = ts. readLine ( ); |
1052 | f. close ( ); | 1052 | f. close ( ); |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | void Yopy::initButtons ( ) | 1056 | void Yopy::initButtons ( ) |
1057 | { | 1057 | { |
1058 | if ( d-> m_buttons ) | 1058 | if ( d-> m_buttons ) |
1059 | return; | 1059 | return; |
1060 | 1060 | ||
1061 | d-> m_buttons = new QValueList <ODeviceButton>; | 1061 | d-> m_buttons = new QValueList <ODeviceButton>; |
1062 | 1062 | ||
1063 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 1063 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { |
1064 | 1064 | ||
1065 | yopy_button *ib = yopy_buttons + i; | 1065 | yopy_button *ib = yopy_buttons + i; |
1066 | 1066 | ||
1067 | ODeviceButton b; | 1067 | ODeviceButton b; |
1068 | 1068 | ||
1069 | b. setKeycode ( ib-> code ); | 1069 | b. setKeycode ( ib-> code ); |
1070 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1070 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1071 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1071 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1072 | b. setFactoryPresetPressedAction | 1072 | b. setFactoryPresetPressedAction |
1073 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | 1073 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); |
1074 | b. setFactoryPresetHeldAction | 1074 | b. setFactoryPresetHeldAction |
1075 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | 1075 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); |
1076 | 1076 | ||
1077 | d-> m_buttons-> append ( b ); | 1077 | d-> m_buttons-> append ( b ); |
1078 | } | 1078 | } |
1079 | reloadButtonMapping ( ); | 1079 | reloadButtonMapping ( ); |
1080 | 1080 | ||
1081 | QCopChannel *sysch = new QCopChannel("QPE/System", this); | 1081 | QCopChannel *sysch = new QCopChannel("QPE/System", this); |
1082 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), | 1082 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), |
1083 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); | 1083 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | bool Yopy::suspend() | 1086 | bool Yopy::suspend() |
1087 | { | 1087 | { |
1088 | /* Opie for Yopy does not implement its own power management at the | 1088 | /* Opie for Yopy does not implement its own power management at the |
1089 | moment. The public version runs parallel to X, and relies on the | 1089 | moment. The public version runs parallel to X, and relies on the |
1090 | existing power management features. */ | 1090 | existing power management features. */ |
1091 | return false; | 1091 | return false; |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | bool Yopy::setDisplayBrightness(int bright) | 1094 | bool Yopy::setDisplayBrightness(int bright) |
1095 | { | 1095 | { |
1096 | /* The code here works, but is disabled as the current version runs | 1096 | /* The code here works, but is disabled as the current version runs |
1097 | parallel to X, and relies on the existing backlight demon. */ | 1097 | parallel to X, and relies on the existing backlight demon. */ |
1098 | #if 0 | 1098 | #if 0 |
1099 | if ( QFile::exists("/proc/sys/pm/light") ) { | 1099 | if ( QFile::exists("/proc/sys/pm/light") ) { |
1100 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 1100 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); |
1101 | if (fd >= 0 ) { | 1101 | if (fd >= 0 ) { |
1102 | if (bright) | 1102 | if (bright) |
1103 | ::write(fd, "1\n", 2); | 1103 | ::write(fd, "1\n", 2); |
1104 | else | 1104 | else |
1105 | ::write(fd, "0\n", 2); | 1105 | ::write(fd, "0\n", 2); |
1106 | ::close(fd); | 1106 | ::close(fd); |
1107 | return true; | 1107 | return true; |
1108 | } | 1108 | } |
1109 | } | 1109 | } |
1110 | #endif | 1110 | #endif |
1111 | return false; | 1111 | return false; |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | int Yopy::displayBrightnessResolution() const | 1114 | int Yopy::displayBrightnessResolution() const |
1115 | { | 1115 | { |
1116 | return 2; | 1116 | return 2; |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | /************************************************** | 1119 | /************************************************** |
1120 | * | 1120 | * |
1121 | * iPAQ | 1121 | * iPAQ |
1122 | * | 1122 | * |
1123 | **************************************************/ | 1123 | **************************************************/ |
1124 | 1124 | ||
1125 | void iPAQ::init ( ) | 1125 | void iPAQ::init ( ) |
1126 | { | 1126 | { |
1127 | d-> m_vendorstr = "HP"; | 1127 | d-> m_vendorstr = "HP"; |
1128 | d-> m_vendor = Vendor_HP; | 1128 | d-> m_vendor = Vendor_HP; |
1129 | 1129 | ||
1130 | QFile f ( "/proc/hal/model" ); | 1130 | QFile f ( "/proc/hal/model" ); |
1131 | 1131 | ||
1132 | if ( f. open ( IO_ReadOnly )) { | 1132 | if ( f. open ( IO_ReadOnly )) { |
1133 | QTextStream ts ( &f ); | 1133 | QTextStream ts ( &f ); |
1134 | 1134 | ||
1135 | d-> m_modelstr = "H" + ts. readLine ( ); | 1135 | d-> m_modelstr = "H" + ts. readLine ( ); |
1136 | 1136 | ||
1137 | if ( d-> m_modelstr == "H3100" ) | 1137 | if ( d-> m_modelstr == "H3100" ) |
1138 | d-> m_model = Model_iPAQ_H31xx; | 1138 | d-> m_model = Model_iPAQ_H31xx; |
1139 | else if ( d-> m_modelstr == "H3600" ) | 1139 | else if ( d-> m_modelstr == "H3600" ) |
1140 | d-> m_model = Model_iPAQ_H36xx; | 1140 | d-> m_model = Model_iPAQ_H36xx; |
1141 | else if ( d-> m_modelstr == "H3700" ) | 1141 | else if ( d-> m_modelstr == "H3700" ) |
1142 | d-> m_model = Model_iPAQ_H37xx; | 1142 | d-> m_model = Model_iPAQ_H37xx; |
1143 | else if ( d-> m_modelstr == "H3800" ) | 1143 | else if ( d-> m_modelstr == "H3800" ) |
1144 | d-> m_model = Model_iPAQ_H38xx; | 1144 | d-> m_model = Model_iPAQ_H38xx; |
1145 | else if ( d-> m_modelstr == "H3900" ) | 1145 | else if ( d-> m_modelstr == "H3900" ) |
1146 | d-> m_model = Model_iPAQ_H39xx; | 1146 | d-> m_model = Model_iPAQ_H39xx; |
1147 | else if ( d-> m_modelstr == "H5400" ) | 1147 | else if ( d-> m_modelstr == "H5400" ) |
1148 | d-> m_model = Model_iPAQ_H5xxx; | 1148 | d-> m_model = Model_iPAQ_H5xxx; |
1149 | else | 1149 | else |
1150 | d-> m_model = Model_Unknown; | 1150 | d-> m_model = Model_Unknown; |
1151 | 1151 | ||
1152 | f. close ( ); | 1152 | f. close ( ); |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | switch ( d-> m_model ) { | 1155 | switch ( d-> m_model ) { |
1156 | case Model_iPAQ_H31xx: | 1156 | case Model_iPAQ_H31xx: |
1157 | case Model_iPAQ_H38xx: | 1157 | case Model_iPAQ_H38xx: |
1158 | d-> m_rotation = Rot90; | 1158 | d-> m_rotation = Rot90; |
1159 | break; | 1159 | break; |
1160 | case Model_iPAQ_H36xx: | 1160 | case Model_iPAQ_H36xx: |
1161 | case Model_iPAQ_H37xx: | 1161 | case Model_iPAQ_H37xx: |
1162 | case Model_iPAQ_H39xx: | 1162 | case Model_iPAQ_H39xx: |
1163 | 1163 | ||
1164 | default: | 1164 | default: |
1165 | d-> m_rotation = Rot270; | 1165 | d-> m_rotation = Rot270; |
1166 | break; | 1166 | break; |
1167 | case Model_iPAQ_H5xxx: | 1167 | case Model_iPAQ_H5xxx: |
1168 | d-> m_rotation = Rot0; | 1168 | d-> m_rotation = Rot0; |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | f. setName ( "/etc/familiar-version" ); | 1171 | f. setName ( "/etc/familiar-version" ); |
1172 | if ( f. open ( IO_ReadOnly )) { | 1172 | if ( f. open ( IO_ReadOnly )) { |
1173 | d-> m_systemstr = "Familiar"; | 1173 | d-> m_systemstr = "Familiar"; |
1174 | d-> m_system = System_Familiar; | 1174 | d-> m_system = System_Familiar; |
1175 | 1175 | ||
1176 | QTextStream ts ( &f ); | 1176 | QTextStream ts ( &f ); |
1177 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1177 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
1178 | 1178 | ||
1179 | f. close ( ); | 1179 | f. close ( ); |
1180 | } else { | 1180 | } else { |
1181 | f. setName ( "/etc/oz_version" ); | 1181 | f. setName ( "/etc/oz_version" ); |
1182 | 1182 | ||
1183 | if ( f. open ( IO_ReadOnly )) { | 1183 | if ( f. open ( IO_ReadOnly )) { |
1184 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 1184 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
1185 | d-> m_system = System_Familiar; | 1185 | d-> m_system = System_Familiar; |
1186 | 1186 | ||
1187 | QTextStream ts ( &f ); | 1187 | QTextStream ts ( &f ); |
1188 | ts.setDevice ( &f ); | 1188 | ts.setDevice ( &f ); |
1189 | d-> m_sysverstr = ts. readLine ( ); | 1189 | d-> m_sysverstr = ts. readLine ( ); |
1190 | f. close ( ); | 1190 | f. close ( ); |
1191 | } | 1191 | } |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | 1194 | ||
1195 | 1195 | ||
1196 | 1196 | ||
1197 | 1197 | ||
1198 | m_leds [0] = m_leds [1] = Led_Off; | 1198 | m_leds [0] = m_leds [1] = Led_Off; |
1199 | 1199 | ||
1200 | m_power_timer = 0; | 1200 | m_power_timer = 0; |
1201 | 1201 | ||
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | void iPAQ::initButtons ( ) | 1204 | void iPAQ::initButtons ( ) |
1205 | { | 1205 | { |
1206 | if ( d-> m_buttons ) | 1206 | if ( d-> m_buttons ) |
1207 | return; | 1207 | return; |
1208 | 1208 | ||
1209 | if ( isQWS( ) ) | 1209 | if ( isQWS( ) ) |
1210 | QWSServer::setKeyboardFilter ( this ); | 1210 | QWSServer::setKeyboardFilter ( this ); |
1211 | 1211 | ||
1212 | d-> m_buttons = new QValueList <ODeviceButton>; | 1212 | d-> m_buttons = new QValueList <ODeviceButton>; |
1213 | 1213 | ||
1214 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1214 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1215 | i_button *ib = ipaq_buttons + i; | 1215 | i_button *ib = ipaq_buttons + i; |
1216 | ODeviceButton b; | 1216 | ODeviceButton b; |
1217 | 1217 | ||
1218 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1218 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1219 | b. setKeycode ( ib-> code ); | 1219 | b. setKeycode ( ib-> code ); |
1220 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1220 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1221 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1221 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1222 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1222 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1223 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1223 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1224 | 1224 | ||
1225 | d-> m_buttons-> append ( b ); | 1225 | d-> m_buttons-> append ( b ); |
1226 | } | 1226 | } |
1227 | } | 1227 | } |
1228 | reloadButtonMapping ( ); | 1228 | reloadButtonMapping ( ); |
1229 | 1229 | ||
1230 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1230 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1231 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1231 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | 1234 | ||
1235 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1235 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1236 | 1236 | ||
1237 | typedef struct { | 1237 | typedef struct { |
1238 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1238 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1239 | unsigned char TotalTime; /* Units of 5 seconds */ | 1239 | unsigned char TotalTime; /* Units of 5 seconds */ |
1240 | unsigned char OnTime; /* units of 100m/s */ | 1240 | unsigned char OnTime; /* units of 100m/s */ |
1241 | unsigned char OffTime; /* units of 100m/s */ | 1241 | unsigned char OffTime; /* units of 100m/s */ |
1242 | } LED_IN; | 1242 | } LED_IN; |
1243 | 1243 | ||
1244 | typedef struct { | 1244 | typedef struct { |
1245 | unsigned char mode; | 1245 | unsigned char mode; |
1246 | unsigned char pwr; | 1246 | unsigned char pwr; |
1247 | unsigned char brightness; | 1247 | unsigned char brightness; |
1248 | } FLITE_IN; | 1248 | } FLITE_IN; |
1249 | 1249 | ||
1250 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1250 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1251 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1251 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1252 | 1252 | ||
1253 | 1253 | ||
1254 | QValueList <OLed> iPAQ::ledList ( ) const | 1254 | QValueList <OLed> iPAQ::ledList ( ) const |
1255 | { | 1255 | { |
1256 | QValueList <OLed> vl; | 1256 | QValueList <OLed> vl; |
1257 | vl << Led_Power; | 1257 | vl << Led_Power; |
1258 | 1258 | ||
1259 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1259 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1260 | vl << Led_BlueTooth; | 1260 | vl << Led_BlueTooth; |
1261 | return vl; | 1261 | return vl; |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1264 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1265 | { | 1265 | { |
1266 | QValueList <OLedState> vl; | 1266 | QValueList <OLedState> vl; |
1267 | 1267 | ||
1268 | if ( l == Led_Power ) | 1268 | if ( l == Led_Power ) |
1269 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1269 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1270 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1270 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1271 | vl << Led_Off; // << Led_On << ??? | 1271 | vl << Led_Off; // << Led_On << ??? |
1272 | 1272 | ||
1273 | return vl; | 1273 | return vl; |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | OLedState iPAQ::ledState ( OLed l ) const | 1276 | OLedState iPAQ::ledState ( OLed l ) const |
1277 | { | 1277 | { |
1278 | switch ( l ) { | 1278 | switch ( l ) { |
1279 | case Led_Power: | 1279 | case Led_Power: |
1280 | return m_leds [0]; | 1280 | return m_leds [0]; |
1281 | case Led_BlueTooth: | 1281 | case Led_BlueTooth: |
1282 | return m_leds [1]; | 1282 | return m_leds [1]; |
1283 | default: | 1283 | default: |
1284 | return Led_Off; | 1284 | return Led_Off; |
1285 | } | 1285 | } |
1286 | } | 1286 | } |
1287 | 1287 | ||
1288 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1288 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1289 | { | 1289 | { |
1290 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1290 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1291 | 1291 | ||
1292 | if ( l == Led_Power ) { | 1292 | if ( l == Led_Power ) { |
1293 | if ( fd >= 0 ) { | 1293 | if ( fd >= 0 ) { |
1294 | LED_IN leds; | 1294 | LED_IN leds; |
1295 | ::memset ( &leds, 0, sizeof( leds )); | 1295 | ::memset ( &leds, 0, sizeof( leds )); |
1296 | leds. TotalTime = 0; | 1296 | leds. TotalTime = 0; |
1297 | leds. OnTime = 0; | 1297 | leds. OnTime = 0; |
1298 | leds. OffTime = 1; | 1298 | leds. OffTime = 1; |
1299 | leds. OffOnBlink = 2; | 1299 | leds. OffOnBlink = 2; |
1300 | 1300 | ||
1301 | switch ( st ) { | 1301 | switch ( st ) { |
1302 | case Led_Off : leds. OffOnBlink = 0; break; | 1302 | case Led_Off : leds. OffOnBlink = 0; break; |
1303 | case Led_On : leds. OffOnBlink = 1; break; | 1303 | case Led_On : leds. OffOnBlink = 1; break; |
1304 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1304 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1305 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1305 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1308 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1309 | m_leds [0] = st; | 1309 | m_leds [0] = st; |
1310 | return true; | 1310 | return true; |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | return false; | 1314 | return false; |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | 1317 | ||
1318 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1318 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1319 | { | 1319 | { |
1320 | int newkeycode = keycode; | 1320 | int newkeycode = keycode; |
1321 | 1321 | ||
1322 | switch ( keycode ) { | 1322 | switch ( keycode ) { |
1323 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1323 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1324 | case HardKey_Menu: { | 1324 | case HardKey_Menu: { |
1325 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1325 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1326 | ( d-> m_model == Model_iPAQ_H39xx ) || | 1326 | ( d-> m_model == Model_iPAQ_H39xx ) || |
1327 | ( d-> m_model == Model_iPAQ_H5xxx)) { | 1327 | ( d-> m_model == Model_iPAQ_H5xxx)) { |
1328 | newkeycode = HardKey_Mail; | 1328 | newkeycode = HardKey_Mail; |
1329 | } | 1329 | } |
1330 | break; | 1330 | break; |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | // Rotate cursor keys 180° | 1333 | // Rotate cursor keys 180° |
1334 | case Key_Left : | 1334 | case Key_Left : |
1335 | case Key_Right: | 1335 | case Key_Right: |
1336 | case Key_Up : | 1336 | case Key_Up : |
1337 | case Key_Down : { | 1337 | case Key_Down : { |
1338 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1338 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1339 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1339 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1340 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1340 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1341 | } | 1341 | } |
1342 | break; | 1342 | break; |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | // map Power Button short/long press to F34/F35 | 1345 | // map Power Button short/long press to F34/F35 |
1346 | case Key_SysReq: { | 1346 | case Key_SysReq: { |
1347 | if ( isPress ) { | 1347 | if ( isPress ) { |
1348 | if ( m_power_timer ) | 1348 | if ( m_power_timer ) |
1349 | killTimer ( m_power_timer ); | 1349 | killTimer ( m_power_timer ); |
1350 | m_power_timer = startTimer ( 500 ); | 1350 | m_power_timer = startTimer ( 500 ); |
1351 | } | 1351 | } |
1352 | else if ( m_power_timer ) { | 1352 | else if ( m_power_timer ) { |
1353 | killTimer ( m_power_timer ); | 1353 | killTimer ( m_power_timer ); |
1354 | m_power_timer = 0; | 1354 | m_power_timer = 0; |
1355 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 1355 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
1356 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 1356 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
1357 | } | 1357 | } |
1358 | newkeycode = Key_unknown; | 1358 | newkeycode = Key_unknown; |
1359 | break; | 1359 | break; |
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | if ( newkeycode != keycode ) { | 1363 | if ( newkeycode != keycode ) { |
1364 | if ( newkeycode != Key_unknown ) | 1364 | if ( newkeycode != Key_unknown ) |
1365 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 1365 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
1366 | return true; | 1366 | return true; |
1367 | } | 1367 | } |
1368 | else | 1368 | else |
1369 | return false; | 1369 | return false; |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | void iPAQ::timerEvent ( QTimerEvent * ) | 1372 | void iPAQ::timerEvent ( QTimerEvent * ) |
1373 | { | 1373 | { |
1374 | killTimer ( m_power_timer ); | 1374 | killTimer ( m_power_timer ); |
1375 | m_power_timer = 0; | 1375 | m_power_timer = 0; |
1376 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1376 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1377 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1377 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | 1380 | ||
1381 | void iPAQ::alarmSound ( ) | 1381 | void iPAQ::alarmSound ( ) |
1382 | { | 1382 | { |
1383 | #ifndef QT_NO_SOUND | 1383 | #ifndef QT_NO_SOUND |
1384 | static Sound snd ( "alarm" ); | 1384 | static Sound snd ( "alarm" ); |
1385 | int fd; | 1385 | int fd; |
1386 | int vol; | 1386 | int vol; |
1387 | bool vol_reset = false; | 1387 | bool vol_reset = false; |
1388 | 1388 | ||
1389 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1389 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1390 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1390 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1391 | Config cfg ( "qpe" ); | 1391 | Config cfg ( "qpe" ); |
1392 | cfg. setGroup ( "Volume" ); | 1392 | cfg. setGroup ( "Volume" ); |
1393 | 1393 | ||
1394 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1394 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1395 | if ( volalarm < 0 ) | 1395 | if ( volalarm < 0 ) |
1396 | volalarm = 0; | 1396 | volalarm = 0; |
1397 | else if ( volalarm > 100 ) | 1397 | else if ( volalarm > 100 ) |
1398 | volalarm = 100; | 1398 | volalarm = 100; |
1399 | volalarm |= ( volalarm << 8 ); | 1399 | volalarm |= ( volalarm << 8 ); |
1400 | 1400 | ||
1401 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1401 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1402 | vol_reset = true; | 1402 | vol_reset = true; |
1403 | } | 1403 | } |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | snd. play ( ); | 1406 | snd. play ( ); |
1407 | while ( !snd. isFinished ( )) | 1407 | while ( !snd. isFinished ( )) |
1408 | qApp-> processEvents ( ); | 1408 | qApp-> processEvents ( ); |
1409 | 1409 | ||
1410 | if ( fd >= 0 ) { | 1410 | if ( fd >= 0 ) { |
1411 | if ( vol_reset ) | 1411 | if ( vol_reset ) |
1412 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1412 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1413 | ::close ( fd ); | 1413 | ::close ( fd ); |
1414 | } | 1414 | } |
1415 | #endif | 1415 | #endif |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | 1418 | ||
1419 | bool iPAQ::setSoftSuspend ( bool soft ) | 1419 | bool iPAQ::setSoftSuspend ( bool soft ) |
1420 | { | 1420 | { |
1421 | bool res = false; | 1421 | bool res = false; |
1422 | int fd; | 1422 | int fd; |
1423 | 1423 | ||
1424 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1424 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1425 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1425 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1426 | res = true; | 1426 | res = true; |
1427 | else | 1427 | else |
1428 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1428 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1429 | 1429 | ||
1430 | ::close ( fd ); | 1430 | ::close ( fd ); |
1431 | } | 1431 | } |
1432 | else | 1432 | else |
1433 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1433 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1434 | 1434 | ||
1435 | return res; | 1435 | return res; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | 1438 | ||
1439 | bool iPAQ::setDisplayBrightness ( int bright ) | 1439 | bool iPAQ::setDisplayBrightness ( int bright ) |
1440 | { | 1440 | { |
1441 | bool res = false; | 1441 | bool res = false; |
1442 | int fd; | 1442 | int fd; |
1443 | 1443 | ||
1444 | if ( bright > 255 ) | 1444 | if ( bright > 255 ) |
1445 | bright = 255; | 1445 | bright = 255; |
1446 | if ( bright < 0 ) | 1446 | if ( bright < 0 ) |
1447 | bright = 0; | 1447 | bright = 0; |
1448 | 1448 | ||
1449 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1449 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1450 | FLITE_IN bl; | 1450 | FLITE_IN bl; |
1451 | bl. mode = 1; | 1451 | bl. mode = 1; |
1452 | bl. pwr = bright ? 1 : 0; | 1452 | bl. pwr = bright ? 1 : 0; |
1453 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1453 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1454 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1454 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1455 | ::close ( fd ); | 1455 | ::close ( fd ); |
1456 | } | 1456 | } |
1457 | return res; | 1457 | return res; |
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | int iPAQ::displayBrightnessResolution ( ) const | 1460 | int iPAQ::displayBrightnessResolution ( ) const |
1461 | { | 1461 | { |
1462 | switch ( model ( )) { | 1462 | switch ( model ( )) { |
1463 | case Model_iPAQ_H31xx: | 1463 | case Model_iPAQ_H31xx: |
1464 | case Model_iPAQ_H36xx: | 1464 | case Model_iPAQ_H36xx: |
1465 | case Model_iPAQ_H37xx: | 1465 | case Model_iPAQ_H37xx: |
1466 | return 128; // really 256, but >128 could damage the LCD | 1466 | return 128; // really 256, but >128 could damage the LCD |
1467 | 1467 | ||
1468 | case Model_iPAQ_H38xx: | 1468 | case Model_iPAQ_H38xx: |
1469 | case Model_iPAQ_H39xx: | 1469 | case Model_iPAQ_H39xx: |
1470 | return 64; | 1470 | return 64; |
1471 | case Model_iPAQ_H5xxx: | 1471 | case Model_iPAQ_H5xxx: |
1472 | return 255; | 1472 | return 255; |
1473 | 1473 | ||
1474 | default: | 1474 | default: |
1475 | return 2; | 1475 | return 2; |
1476 | } | 1476 | } |
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | 1479 | ||
1480 | bool iPAQ::hasLightSensor ( ) const | 1480 | bool iPAQ::hasLightSensor ( ) const |
1481 | { | 1481 | { |
1482 | return true; | 1482 | return true; |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | int iPAQ::readLightSensor ( ) | 1485 | int iPAQ::readLightSensor ( ) |
1486 | { | 1486 | { |
1487 | int fd; | 1487 | int fd; |
1488 | int val = -1; | 1488 | int val = -1; |
1489 | 1489 | ||
1490 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1490 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1491 | char buffer [8]; | 1491 | char buffer [8]; |
1492 | 1492 | ||
1493 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1493 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1494 | char *endptr; | 1494 | char *endptr; |
1495 | 1495 | ||
1496 | buffer [4] = 0; | 1496 | buffer [4] = 0; |
1497 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1497 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1498 | 1498 | ||
1499 | if ( *endptr != 0 ) | 1499 | if ( *endptr != 0 ) |
1500 | val = -1; | 1500 | val = -1; |
1501 | } | 1501 | } |
1502 | ::close ( fd ); | 1502 | ::close ( fd ); |
1503 | } | 1503 | } |
1504 | 1504 | ||
1505 | return val; | 1505 | return val; |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | int iPAQ::lightSensorResolution ( ) const | 1508 | int iPAQ::lightSensorResolution ( ) const |
1509 | { | 1509 | { |
1510 | return 256; | 1510 | return 256; |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | /************************************************** | 1513 | /************************************************** |
1514 | * | 1514 | * |
1515 | * Zaurus | 1515 | * Zaurus |
1516 | * | 1516 | * |
1517 | **************************************************/ | 1517 | **************************************************/ |
1518 | 1518 | ||
1519 | // Check whether this device is the sharp zaurus.. | 1519 | // Check whether this device is the sharp zaurus.. |
1520 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 1520 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
1521 | // class up into individual classes. We need three classes | 1521 | // class up into individual classes. We need three classes |
1522 | // | 1522 | // |
1523 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 1523 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
1524 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 1524 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
1525 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 1525 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) |
1526 | // | 1526 | // |
1527 | // Only question right now is: Do we really need to do it? Because as soon | 1527 | // Only question right now is: Do we really need to do it? Because as soon |
1528 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 1528 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
1529 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 1529 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
1530 | // | 1530 | // |
1531 | // Comments? - mickeyl. | 1531 | // Comments? - mickeyl. |
1532 | 1532 | ||
1533 | bool Zaurus::isZaurus() | 1533 | bool Zaurus::isZaurus() |
1534 | { | 1534 | { |
1535 | 1535 | ||
1536 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | 1536 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! |
1537 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | 1537 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ |
1538 | return true; | 1538 | return true; |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | // On non-embedix kernels, we have to look closer. | 1541 | // On non-embedix kernels, we have to look closer. |
1542 | bool is_zaurus = false; | 1542 | bool is_zaurus = false; |
1543 | QFile f ( "/proc/cpuinfo" ); | 1543 | QFile f ( "/proc/cpuinfo" ); |
1544 | if ( f. open ( IO_ReadOnly ) ) { | 1544 | if ( f. open ( IO_ReadOnly ) ) { |
1545 | QString model; | 1545 | QString model; |
1546 | QFile f ( "/proc/cpuinfo" ); | 1546 | QFile f ( "/proc/cpuinfo" ); |
1547 | 1547 | ||
1548 | QTextStream ts ( &f ); | 1548 | QTextStream ts ( &f ); |
1549 | QString line; | 1549 | QString line; |
1550 | while( line = ts. readLine ( ) ) { | 1550 | while( line = ts. readLine ( ) ) { |
1551 | if ( line. left ( 8 ) == "Hardware" ) | 1551 | if ( line. left ( 8 ) == "Hardware" ) |
1552 | break; | 1552 | break; |
1553 | } | 1553 | } |
1554 | int loc = line. find ( ":" ); | 1554 | int loc = line. find ( ":" ); |
1555 | if ( loc != -1 ) | 1555 | if ( loc != -1 ) |
1556 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1556 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1557 | 1557 | ||
1558 | if ( model == "Sharp-Collie" | 1558 | if ( model == "Sharp-Collie" |
1559 | || model == "Collie" | 1559 | || model == "Collie" |
1560 | || model == "SHARP Corgi" | 1560 | || model == "SHARP Corgi" |
1561 | || model == "SHARP Shepherd" | 1561 | || model == "SHARP Shepherd" |
1562 | || model == "SHARP Poodle" | 1562 | || model == "SHARP Poodle" |
1563 | || model == "SHARP Husky" | 1563 | || model == "SHARP Husky" |
1564 | ) | 1564 | ) |
1565 | is_zaurus = true; | 1565 | is_zaurus = true; |
1566 | 1566 | ||
1567 | } | 1567 | } |
1568 | return is_zaurus; | 1568 | return is_zaurus; |
1569 | } | 1569 | } |
1570 | 1570 | ||
1571 | 1571 | ||
1572 | void Zaurus::init ( ) | 1572 | void Zaurus::init ( ) |
1573 | { | 1573 | { |
1574 | d-> m_vendorstr = "Sharp"; | 1574 | d-> m_vendorstr = "Sharp"; |
1575 | d-> m_vendor = Vendor_Sharp; | 1575 | d-> m_vendor = Vendor_Sharp; |
1576 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 1576 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! |
1577 | 1577 | ||
1578 | // QFile f ( "/proc/filesystems" ); | 1578 | // QFile f ( "/proc/filesystems" ); |
1579 | QString model; | 1579 | QString model; |
1580 | 1580 | ||
1581 | // It isn't a good idea to check the system configuration to | 1581 | // It isn't a good idea to check the system configuration to |
1582 | // detect the distribution ! | 1582 | // detect the distribution ! |
1583 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 1583 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
1584 | // because it uses a jffs2 filesystem.. | 1584 | // because it uses a jffs2 filesystem.. |
1585 | // (eilers) | 1585 | // (eilers) |
1586 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1586 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1587 | QFile f ("/etc/oz_version"); | 1587 | QFile f ("/etc/oz_version"); |
1588 | if ( f.exists() ){ | 1588 | if ( f.exists() ){ |
1589 | d-> m_vendorstr = "OpenZaurus Team"; | 1589 | d-> m_vendorstr = "OpenZaurus Team"; |
1590 | d-> m_systemstr = "OpenZaurus"; | 1590 | d-> m_systemstr = "OpenZaurus"; |
1591 | d-> m_system = System_OpenZaurus; | 1591 | d-> m_system = System_OpenZaurus; |
1592 | 1592 | ||
1593 | if ( f. open ( IO_ReadOnly )) { | 1593 | if ( f. open ( IO_ReadOnly )) { |
1594 | QTextStream ts ( &f ); | 1594 | QTextStream ts ( &f ); |
1595 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1595 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1596 | f. close ( ); | 1596 | f. close ( ); |
1597 | } | 1597 | } |
1598 | 1598 | ||
1599 | // Openzaurus sometimes uses the embedix kernel! | 1599 | // Openzaurus sometimes uses the embedix kernel! |
1600 | // => Check whether this is an embedix kernel | 1600 | // => Check whether this is an embedix kernel |
1601 | FILE *uname = popen("uname -r", "r"); | 1601 | FILE *uname = popen("uname -r", "r"); |
1602 | QString line; | 1602 | QString line; |
1603 | if ( f.open(IO_ReadOnly, uname) ) { | 1603 | if ( f.open(IO_ReadOnly, uname) ) { |
1604 | QTextStream ts ( &f ); | 1604 | QTextStream ts ( &f ); |
1605 | line = ts. readLine ( ); | 1605 | line = ts. readLine ( ); |
1606 | int loc = line. find ( "embedix" ); | 1606 | int loc = line. find ( "embedix" ); |
1607 | if ( loc != -1 ) | 1607 | if ( loc != -1 ) |
1608 | m_embedix = true; | 1608 | m_embedix = true; |
1609 | else | 1609 | else |
1610 | m_embedix = false; | 1610 | m_embedix = false; |
1611 | f. close ( ); | 1611 | f. close ( ); |
1612 | } | 1612 | } |
1613 | pclose(uname); | 1613 | pclose(uname); |
1614 | } | 1614 | } |
1615 | else { | 1615 | else { |
1616 | d-> m_systemstr = "Zaurus"; | 1616 | d-> m_systemstr = "Zaurus"; |
1617 | d-> m_system = System_Zaurus; | 1617 | d-> m_system = System_Zaurus; |
1618 | } | 1618 | } |
1619 | 1619 | ||
1620 | f. setName ( "/proc/cpuinfo" ); | 1620 | f. setName ( "/proc/cpuinfo" ); |
1621 | if ( f. open ( IO_ReadOnly ) ) { | 1621 | if ( f. open ( IO_ReadOnly ) ) { |
1622 | QTextStream ts ( &f ); | 1622 | QTextStream ts ( &f ); |
1623 | QString line; | 1623 | QString line; |
1624 | while( line = ts. readLine ( ) ) { | 1624 | while( line = ts. readLine ( ) ) { |
1625 | if ( line. left ( 8 ) == "Hardware" ) | 1625 | if ( line. left ( 8 ) == "Hardware" ) |
1626 | break; | 1626 | break; |
1627 | } | 1627 | } |
1628 | int loc = line. find ( ":" ); | 1628 | int loc = line. find ( ":" ); |
1629 | if ( loc != -1 ) | 1629 | if ( loc != -1 ) |
1630 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1630 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | if ( model == "SHARP Corgi" ) { | 1633 | if ( model == "SHARP Corgi" ) { |
1634 | d-> m_model = Model_Zaurus_SLC7x0; | 1634 | d-> m_model = Model_Zaurus_SLC7x0; |
1635 | d-> m_modelstr = "Zaurus SL-C700"; | 1635 | d-> m_modelstr = "Zaurus SL-C700"; |
1636 | } else if ( model == "SHARP Shepherd" ) { | 1636 | } else if ( model == "SHARP Shepherd" ) { |
1637 | d-> m_model = Model_Zaurus_SLC7x0; | 1637 | d-> m_model = Model_Zaurus_SLC7x0; |
1638 | d-> m_modelstr = "Zaurus SL-C750"; | 1638 | d-> m_modelstr = "Zaurus SL-C750"; |
1639 | } else if ( model == "SHARP Husky" ) { | 1639 | } else if ( model == "SHARP Husky" ) { |
1640 | d-> m_model = Model_Zaurus_SLC7x0; | 1640 | d-> m_model = Model_Zaurus_SLC7x0; |
1641 | d-> m_modelstr = "Zaurus SL-C760"; | 1641 | d-> m_modelstr = "Zaurus SL-C760"; |
1642 | } else if ( model == "SHARP Poodle" ) { | 1642 | } else if ( model == "SHARP Poodle" ) { |
1643 | d-> m_model = Model_Zaurus_SLB600; | 1643 | d-> m_model = Model_Zaurus_SLB600; |
1644 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1644 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1645 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 1645 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1646 | d-> m_model = Model_Zaurus_SL5500; | 1646 | d-> m_model = Model_Zaurus_SL5500; |
1647 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1647 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1648 | } else { | 1648 | } else { |
1649 | d-> m_model = Model_Zaurus_SL5500; | 1649 | d-> m_model = Model_Zaurus_SL5500; |
1650 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1650 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | bool flipstate = false; | 1653 | bool flipstate = false; |
1654 | switch ( d-> m_model ) { | 1654 | switch ( d-> m_model ) { |
1655 | case Model_Zaurus_SLA300: | 1655 | case Model_Zaurus_SLA300: |
1656 | d-> m_rotation = Rot0; | 1656 | d-> m_rotation = Rot0; |
1657 | break; | 1657 | break; |
1658 | case Model_Zaurus_SLC7x0: | 1658 | case Model_Zaurus_SLC7x0: |
1659 | d-> m_rotation = rotation(); | 1659 | d-> m_rotation = rotation(); |
1660 | d-> m_direction = direction(); | 1660 | d-> m_direction = direction(); |
1661 | break; | 1661 | break; |
1662 | case Model_Zaurus_SLB600: | 1662 | case Model_Zaurus_SLB600: |
1663 | case Model_Zaurus_SL5500: | 1663 | case Model_Zaurus_SL5500: |
1664 | case Model_Zaurus_SL5000: | 1664 | case Model_Zaurus_SL5000: |
1665 | default: | 1665 | default: |
1666 | d-> m_rotation = Rot270; | 1666 | d-> m_rotation = Rot270; |
1667 | break; | 1667 | break; |
1668 | } | 1668 | } |
1669 | m_leds [0] = Led_Off; | 1669 | m_leds [0] = Led_Off; |
1670 | } | 1670 | } |
1671 | 1671 | ||
1672 | void Zaurus::initButtons ( ) | 1672 | void Zaurus::initButtons ( ) |
1673 | { | 1673 | { |
1674 | if ( d-> m_buttons ) | 1674 | if ( d-> m_buttons ) |
1675 | return; | 1675 | return; |
1676 | 1676 | ||
1677 | d-> m_buttons = new QValueList <ODeviceButton>; | 1677 | d-> m_buttons = new QValueList <ODeviceButton>; |
1678 | 1678 | ||
1679 | struct z_button * pz_buttons; | 1679 | struct z_button * pz_buttons; |
1680 | int buttoncount; | 1680 | int buttoncount; |
1681 | switch ( d-> m_model ) { | 1681 | switch ( d-> m_model ) { |
1682 | case Model_Zaurus_SLC7x0: | 1682 | case Model_Zaurus_SLC7x0: |
1683 | pz_buttons = z_buttons_c700; | 1683 | pz_buttons = z_buttons_c700; |
1684 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1684 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1685 | break; | 1685 | break; |
1686 | default: | 1686 | default: |
1687 | pz_buttons = z_buttons; | 1687 | pz_buttons = z_buttons; |
1688 | buttoncount = ARRAY_SIZE(z_buttons); | 1688 | buttoncount = ARRAY_SIZE(z_buttons); |
1689 | break; | 1689 | break; |
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | for ( int i = 0; i < buttoncount; i++ ) { | 1692 | for ( int i = 0; i < buttoncount; i++ ) { |
1693 | struct z_button *zb = pz_buttons + i; | 1693 | struct z_button *zb = pz_buttons + i; |
1694 | ODeviceButton b; | 1694 | ODeviceButton b; |
1695 | 1695 | ||
1696 | b. setKeycode ( zb-> code ); | 1696 | b. setKeycode ( zb-> code ); |
1697 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1697 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1698 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1698 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1699 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), | 1699 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), |
1700 | zb-> fpressedaction )); | 1700 | zb-> fpressedaction )); |
1701 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), | 1701 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), |
1702 | zb-> fheldaction )); | 1702 | zb-> fheldaction )); |
1703 | 1703 | ||
1704 | d-> m_buttons-> append ( b ); | 1704 | d-> m_buttons-> append ( b ); |
1705 | } | 1705 | } |
1706 | 1706 | ||
1707 | reloadButtonMapping ( ); | 1707 | reloadButtonMapping ( ); |
1708 | 1708 | ||
1709 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1709 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1710 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), | 1710 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), |
1711 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1711 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1712 | } | 1712 | } |
1713 | 1713 | ||
1714 | #include <unistd.h> | 1714 | #include <unistd.h> |
1715 | #include <fcntl.h> | 1715 | #include <fcntl.h> |
1716 | #include <sys/ioctl.h> | 1716 | #include <sys/ioctl.h> |
1717 | 1717 | ||
1718 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1718 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1719 | 1719 | ||
1720 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1720 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1721 | 1721 | ||
1722 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1722 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1723 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1723 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1724 | 1724 | ||
1725 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1725 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1726 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1726 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1727 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1727 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1728 | 1728 | ||
1729 | /* --- for SHARP_BUZZER device --- */ | 1729 | /* --- for SHARP_BUZZER device --- */ |
1730 | 1730 | ||
1731 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1731 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1732 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1732 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1733 | 1733 | ||
1734 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1734 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1735 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1735 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1736 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1736 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1737 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1737 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1738 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1738 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1739 | 1739 | ||
1740 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1740 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1741 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1741 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1742 | 1742 | ||
1743 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1743 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1744 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1744 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1745 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1745 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1746 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1746 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1747 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1747 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1748 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1748 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1749 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1749 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1750 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1750 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1751 | 1751 | ||
1752 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1752 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1753 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1753 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1754 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1754 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1755 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1755 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1756 | // | 1756 | // |
1757 | 1757 | ||
1758 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1758 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1759 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1759 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1760 | 1760 | ||
1761 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 1761 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
1762 | 1762 | ||
1763 | typedef struct sharp_led_status { | 1763 | typedef struct sharp_led_status { |
1764 | int which; /* select which LED status is wanted. */ | 1764 | int which; /* select which LED status is wanted. */ |
1765 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1765 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1766 | } sharp_led_status; | 1766 | } sharp_led_status; |
1767 | 1767 | ||
1768 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1768 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1769 | 1769 | ||
1770 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1770 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1771 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1771 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1772 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1772 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1773 | 1773 | ||
1774 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1774 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1775 | 1775 | ||
1776 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1776 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1777 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1777 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1778 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1778 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1779 | 1779 | ||
1780 | #define FL_IOCTL_STEP_CONTRAST 100 | 1780 | #define FL_IOCTL_STEP_CONTRAST 100 |
1781 | 1781 | ||
1782 | 1782 | ||
1783 | void Zaurus::buzzer ( int sound ) | 1783 | void Zaurus::buzzer ( int sound ) |
1784 | { | 1784 | { |
1785 | #ifndef QT_NO_SOUND | 1785 | #ifndef QT_NO_SOUND |
1786 | QString soundname; | 1786 | QString soundname; |
1787 | 1787 | ||
1788 | // Not all devices have real sound | 1788 | // Not all devices have real sound |
1789 | if ( d->m_model == Model_Zaurus_SLC7x0 | 1789 | if ( d->m_model == Model_Zaurus_SLC7x0 |
1790 | || d->m_model == Model_Zaurus_SLB600 ){ | 1790 | || d->m_model == Model_Zaurus_SLB600 ){ |
1791 | 1791 | ||
1792 | switch ( sound ){ | 1792 | switch ( sound ){ |
1793 | case SHARP_BUZ_SCHEDULE_ALARM: | 1793 | case SHARP_BUZ_SCHEDULE_ALARM: |
1794 | soundname = "alarm"; | 1794 | soundname = "alarm"; |
1795 | break; | 1795 | break; |
1796 | case SHARP_BUZ_TOUCHSOUND: | 1796 | case SHARP_BUZ_TOUCHSOUND: |
1797 | soundname = "touchsound"; | 1797 | soundname = "touchsound"; |
1798 | break; | 1798 | break; |
1799 | case SHARP_BUZ_KEYSOUND: | 1799 | case SHARP_BUZ_KEYSOUND: |
1800 | soundname = "keysound"; | 1800 | soundname = "keysound"; |
1801 | break; | 1801 | break; |
1802 | default: | 1802 | default: |
1803 | soundname = "alarm"; | 1803 | soundname = "alarm"; |
1804 | 1804 | ||
1805 | } | 1805 | } |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | // If a soundname is defined, we expect that this device has | 1808 | // If a soundname is defined, we expect that this device has |
1809 | // sound capabilities.. Otherwise we expect to have the buzzer | 1809 | // sound capabilities.. Otherwise we expect to have the buzzer |
1810 | // device.. | 1810 | // device.. |
1811 | if ( !soundname.isEmpty() ){ | 1811 | if ( !soundname.isEmpty() ){ |
1812 | int fd; | 1812 | int fd; |
1813 | int vol; | 1813 | int vol; |
1814 | bool vol_reset = false; | 1814 | bool vol_reset = false; |
1815 | 1815 | ||
1816 | Sound snd ( soundname ); | 1816 | Sound snd ( soundname ); |
1817 | 1817 | ||
1818 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1818 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1819 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1819 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1820 | Config cfg ( "qpe" ); | 1820 | Config cfg ( "qpe" ); |
1821 | cfg. setGroup ( "Volume" ); | 1821 | cfg. setGroup ( "Volume" ); |
1822 | 1822 | ||
1823 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1823 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1824 | if ( volalarm < 0 ) | 1824 | if ( volalarm < 0 ) |
1825 | volalarm = 0; | 1825 | volalarm = 0; |
1826 | else if ( volalarm > 100 ) | 1826 | else if ( volalarm > 100 ) |
1827 | volalarm = 100; | 1827 | volalarm = 100; |
1828 | volalarm |= ( volalarm << 8 ); | 1828 | volalarm |= ( volalarm << 8 ); |
1829 | 1829 | ||
1830 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1830 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1831 | vol_reset = true; | 1831 | vol_reset = true; |
1832 | } | 1832 | } |
1833 | } | 1833 | } |
1834 | 1834 | ||
1835 | snd. play ( ); | 1835 | snd. play ( ); |
1836 | while ( !snd. isFinished ( )) | 1836 | while ( !snd. isFinished ( )) |
1837 | qApp-> processEvents ( ); | 1837 | qApp-> processEvents ( ); |
1838 | 1838 | ||
1839 | if ( fd >= 0 ) { | 1839 | if ( fd >= 0 ) { |
1840 | if ( vol_reset ) | 1840 | if ( vol_reset ) |
1841 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1841 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1842 | ::close ( fd ); | 1842 | ::close ( fd ); |
1843 | } | 1843 | } |
1844 | } else { | 1844 | } else { |
1845 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1845 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1846 | 1846 | ||
1847 | if ( fd >= 0 ) { | 1847 | if ( fd >= 0 ) { |
1848 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1848 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1849 | ::close ( fd ); | 1849 | ::close ( fd ); |
1850 | } | 1850 | } |
1851 | 1851 | ||
1852 | } | 1852 | } |
1853 | #endif | 1853 | #endif |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | 1856 | ||
1857 | void Zaurus::alarmSound ( ) | 1857 | void Zaurus::alarmSound ( ) |
1858 | { | 1858 | { |
1859 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1859 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1860 | } | 1860 | } |
1861 | 1861 | ||
1862 | void Zaurus::touchSound ( ) | 1862 | void Zaurus::touchSound ( ) |
1863 | { | 1863 | { |
1864 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1864 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1865 | } | 1865 | } |
1866 | 1866 | ||
1867 | void Zaurus::keySound ( ) | 1867 | void Zaurus::keySound ( ) |
1868 | { | 1868 | { |
1869 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1869 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1870 | } | 1870 | } |
1871 | 1871 | ||
1872 | 1872 | ||
1873 | QValueList <OLed> Zaurus::ledList ( ) const | 1873 | QValueList <OLed> Zaurus::ledList ( ) const |
1874 | { | 1874 | { |
1875 | QValueList <OLed> vl; | 1875 | QValueList <OLed> vl; |
1876 | vl << Led_Mail; | 1876 | vl << Led_Mail; |
1877 | return vl; | 1877 | return vl; |
1878 | } | 1878 | } |
1879 | 1879 | ||
1880 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1880 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1881 | { | 1881 | { |
1882 | QValueList <OLedState> vl; | 1882 | QValueList <OLedState> vl; |
1883 | 1883 | ||
1884 | if ( l == Led_Mail ) | 1884 | if ( l == Led_Mail ) |
1885 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1885 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1886 | return vl; | 1886 | return vl; |
1887 | } | 1887 | } |
1888 | 1888 | ||
1889 | OLedState Zaurus::ledState ( OLed which ) const | 1889 | OLedState Zaurus::ledState ( OLed which ) const |
1890 | { | 1890 | { |
1891 | if ( which == Led_Mail ) | 1891 | if ( which == Led_Mail ) |
1892 | return m_leds [0]; | 1892 | return m_leds [0]; |
1893 | else | 1893 | else |
1894 | return Led_Off; | 1894 | return Led_Off; |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1897 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1898 | { | 1898 | { |
1899 | if (!m_embedix) // Currently not supported on non_embedix kernels | 1899 | if (!m_embedix) // Currently not supported on non_embedix kernels |
1900 | return false; | 1900 | return false; |
1901 | 1901 | ||
1902 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1902 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1903 | 1903 | ||
1904 | if ( which == Led_Mail ) { | 1904 | if ( which == Led_Mail ) { |
1905 | if ( fd >= 0 ) { | 1905 | if ( fd >= 0 ) { |
1906 | struct sharp_led_status leds; | 1906 | struct sharp_led_status leds; |
1907 | ::memset ( &leds, 0, sizeof( leds )); | 1907 | ::memset ( &leds, 0, sizeof( leds )); |
1908 | leds. which = SHARP_LED_MAIL_EXISTS; | 1908 | leds. which = SHARP_LED_MAIL_EXISTS; |
1909 | bool ok = true; | 1909 | bool ok = true; |
1910 | 1910 | ||
1911 | switch ( st ) { | 1911 | switch ( st ) { |
1912 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1912 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1913 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1913 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1914 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1914 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1915 | default : ok = false; | 1915 | default : ok = false; |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1918 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1919 | m_leds [0] = st; | 1919 | m_leds [0] = st; |
1920 | return true; | 1920 | return true; |
1921 | } | 1921 | } |
1922 | } | 1922 | } |
1923 | } | 1923 | } |
1924 | return false; | 1924 | return false; |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | bool Zaurus::setSoftSuspend ( bool soft ) | 1927 | bool Zaurus::setSoftSuspend ( bool soft ) |
1928 | { | 1928 | { |
1929 | if (!m_embedix) { | 1929 | if (!m_embedix) { |
1930 | /* non-Embedix kernels dont have kernel autosuspend */ | 1930 | /* non-Embedix kernels dont have kernel autosuspend */ |
1931 | return ODevice::setSoftSuspend( soft ); | 1931 | return ODevice::setSoftSuspend( soft ); |
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | bool res = false; | 1934 | bool res = false; |
1935 | int fd; | 1935 | int fd; |
1936 | 1936 | ||
1937 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1937 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1938 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1938 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1939 | 1939 | ||
1940 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1940 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1941 | 1941 | ||
1942 | if ( sources >= 0 ) { | 1942 | if ( sources >= 0 ) { |
1943 | if ( soft ) | 1943 | if ( soft ) |
1944 | sources &= ~APM_EVT_POWER_BUTTON; | 1944 | sources &= ~APM_EVT_POWER_BUTTON; |
1945 | else | 1945 | else |
1946 | sources |= APM_EVT_POWER_BUTTON; | 1946 | sources |= APM_EVT_POWER_BUTTON; |
1947 | 1947 | ||
1948 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1948 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1949 | res = true; | 1949 | res = true; |
1950 | else | 1950 | else |
1951 | perror ( "APM_IOCGEVTSRC" ); | 1951 | perror ( "APM_IOCGEVTSRC" ); |
1952 | } | 1952 | } |
1953 | else | 1953 | else |
1954 | perror ( "APM_IOCGEVTSRC" ); | 1954 | perror ( "APM_IOCGEVTSRC" ); |
1955 | 1955 | ||
1956 | ::close ( fd ); | 1956 | ::close ( fd ); |
1957 | } | 1957 | } |
1958 | else | 1958 | else |
1959 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1959 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1960 | 1960 | ||
1961 | return res; | 1961 | return res; |
1962 | } | 1962 | } |
1963 | 1963 | ||
1964 | 1964 | ||
1965 | bool Zaurus::setDisplayBrightness ( int bright ) | 1965 | bool Zaurus::setDisplayBrightness ( int bright ) |
1966 | { | 1966 | { |
1967 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | ||
1967 | bool res = false; | 1968 | bool res = false; |
1968 | int fd; | 1969 | int fd; |
1969 | 1970 | ||
1970 | if ( bright > 255 ) bright = 255; | 1971 | if ( bright > 255 ) bright = 255; |
1971 | if ( bright < 0 ) bright = 0; | 1972 | if ( bright < 0 ) bright = 0; |
1972 | 1973 | ||
1973 | if ( m_embedix ) | 1974 | if ( m_embedix ) |
1974 | { | 1975 | { |
1975 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 1976 | if ( d->m_model == Model_Zaurus_SLC7x0 ) |
1976 | { | 1977 | { |
1978 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | ||
1977 | // special treatment for devices with the corgi backlight interface | 1979 | // special treatment for devices with the corgi backlight interface |
1978 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | 1980 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) |
1979 | { | 1981 | { |
1980 | if ( bright > 0x11 ) bright = 0x11; | 1982 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); |
1981 | char writeCommand[100]; | 1983 | char writeCommand[100]; |
1982 | const int count = sprintf( writeCommand, "0x%x\n", bright ); | 1984 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1983 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1985 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1984 | ::close ( fd ); | 1986 | ::close ( fd ); |
1985 | } | 1987 | } |
1986 | return res; | 1988 | return res; |
1987 | } | 1989 | } |
1988 | else | 1990 | else |
1989 | { | 1991 | { |
1990 | // standard treatment for devices with the dumb embedix frontlight interface | 1992 | // standard treatment for devices with the dumb embedix frontlight interface |
1991 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1993 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1992 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1994 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1993 | if ( bright && !bl ) | 1995 | if ( bright && !bl ) |
1994 | bl = 1; | 1996 | bl = 1; |
1995 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1997 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1996 | ::close ( fd ); | 1998 | ::close ( fd ); |
1997 | } | 1999 | } |
1998 | } | 2000 | } |
1999 | } | 2001 | } |
2000 | else | 2002 | else |
2001 | { | 2003 | { |
2002 | // special treatment for the OpenZaurus unified interface | 2004 | // special treatment for the OpenZaurus unified interface |
2003 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 2005 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
2004 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 2006 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
2005 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 2007 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
2006 | ::close ( fd ); | 2008 | ::close ( fd ); |
2007 | } | 2009 | } |
2008 | } | 2010 | } |
2009 | return res; | 2011 | return res; |
2010 | } | 2012 | } |
2011 | 2013 | ||
2012 | bool Zaurus::suspend ( ) | 2014 | bool Zaurus::suspend ( ) |
2013 | { | 2015 | { |
2014 | qDebug("ODevice::suspend"); | 2016 | qDebug("ODevice::suspend"); |
2015 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 2017 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
2016 | return false; | 2018 | return false; |
2017 | 2019 | ||
2018 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 2020 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
2019 | return false; | 2021 | return false; |
2020 | 2022 | ||
2021 | bool res = false; | 2023 | bool res = false; |
2022 | 2024 | ||
2023 | struct timeval tvs, tvn; | 2025 | struct timeval tvs, tvn; |
2024 | ::gettimeofday ( &tvs, 0 ); | 2026 | ::gettimeofday ( &tvs, 0 ); |
2025 | 2027 | ||
2026 | ::sync ( ); // flush fs caches | 2028 | ::sync ( ); // flush fs caches |
2027 | res = ( ::system ( "apm --suspend" ) == 0 ); | 2029 | res = ( ::system ( "apm --suspend" ) == 0 ); |
2028 | 2030 | ||
2029 | // This is needed because the iPAQ apm implementation is asynchronous and we | 2031 | // This is needed because the iPAQ apm implementation is asynchronous and we |
2030 | // can not be sure when exactly the device is really suspended | 2032 | // can not be sure when exactly the device is really suspended |
2031 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 2033 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
2032 | 2034 | ||
2033 | if ( res ) { | 2035 | if ( res ) { |
2034 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 2036 | do { // Yes, wait 15 seconds. This APM bug sucks big time. |
2035 | ::usleep ( 200 * 1000 ); | 2037 | ::usleep ( 200 * 1000 ); |
2036 | ::gettimeofday ( &tvn, 0 ); | 2038 | ::gettimeofday ( &tvn, 0 ); |
2037 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 2039 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
2038 | } | 2040 | } |
2039 | 2041 | ||
2040 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 2042 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
2041 | return res; | 2043 | return res; |
2042 | } | 2044 | } |
2043 | 2045 | ||
2044 | 2046 | ||
2045 | Transformation Zaurus::rotation ( ) const | 2047 | Transformation Zaurus::rotation ( ) const |
2046 | { | 2048 | { |
2047 | Transformation rot; | 2049 | Transformation rot; |
2048 | int handle = 0; | 2050 | int handle = 0; |
2049 | int retval = 0; | 2051 | int retval = 0; |
2050 | 2052 | ||
2051 | switch ( d-> m_model ) { | 2053 | switch ( d-> m_model ) { |
2052 | case Model_Zaurus_SLC7x0: | 2054 | case Model_Zaurus_SLC7x0: |
2053 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2055 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2054 | if (handle == -1) { | 2056 | if (handle == -1) { |
2055 | return Rot270; | 2057 | return Rot270; |
2056 | } else { | 2058 | } else { |
2057 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2059 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2058 | ::close (handle); | 2060 | ::close (handle); |
2059 | 2061 | ||
2060 | if (retval == 2 ) | 2062 | if (retval == 2 ) |
2061 | rot = Rot0; | 2063 | rot = Rot0; |
2062 | else | 2064 | else |
2063 | rot = Rot270; | 2065 | rot = Rot270; |
2064 | } | 2066 | } |
2065 | break; | 2067 | break; |
2066 | case Model_Zaurus_SLA300: | 2068 | case Model_Zaurus_SLA300: |
2067 | case Model_Zaurus_SLB600: | 2069 | case Model_Zaurus_SLB600: |
2068 | case Model_Zaurus_SL5500: | 2070 | case Model_Zaurus_SL5500: |
2069 | case Model_Zaurus_SL5000: | 2071 | case Model_Zaurus_SL5000: |
2070 | default: | 2072 | default: |
2071 | rot = d-> m_rotation; | 2073 | rot = d-> m_rotation; |
2072 | break; | 2074 | break; |
2073 | } | 2075 | } |
2074 | 2076 | ||
2075 | return rot; | 2077 | return rot; |
2076 | } | 2078 | } |
2077 | ODirection Zaurus::direction ( ) const | 2079 | ODirection Zaurus::direction ( ) const |
2078 | { | 2080 | { |
2079 | ODirection dir; | 2081 | ODirection dir; |
2080 | int handle = 0; | 2082 | int handle = 0; |
2081 | int retval = 0; | 2083 | int retval = 0; |
2082 | switch ( d-> m_model ) { | 2084 | switch ( d-> m_model ) { |
2083 | case Model_Zaurus_SLC7x0: | 2085 | case Model_Zaurus_SLC7x0: |
2084 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2086 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2085 | if (handle == -1) { | 2087 | if (handle == -1) { |
2086 | dir = CW; | 2088 | dir = CW; |
2087 | } else { | 2089 | } else { |
2088 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2090 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2089 | ::close (handle); | 2091 | ::close (handle); |
2090 | if (retval == 2 ) | 2092 | if (retval == 2 ) |
2091 | dir = CCW; | 2093 | dir = CCW; |
2092 | else | 2094 | else |
2093 | dir = CW; | 2095 | dir = CW; |
2094 | } | 2096 | } |
2095 | break; | 2097 | break; |
2096 | case Model_Zaurus_SLA300: | 2098 | case Model_Zaurus_SLA300: |
2097 | case Model_Zaurus_SLB600: | 2099 | case Model_Zaurus_SLB600: |
2098 | case Model_Zaurus_SL5500: | 2100 | case Model_Zaurus_SL5500: |
2099 | case Model_Zaurus_SL5000: | 2101 | case Model_Zaurus_SL5000: |
2100 | default: | 2102 | default: |
2101 | dir = d-> m_direction; | 2103 | dir = d-> m_direction; |
2102 | break; | 2104 | break; |
2103 | } | 2105 | } |
2104 | return dir; | 2106 | return dir; |
2105 | 2107 | ||
2106 | } | 2108 | } |
2107 | 2109 | ||
2108 | int Zaurus::displayBrightnessResolution ( ) const | 2110 | int Zaurus::displayBrightnessResolution ( ) const |
2109 | { | 2111 | { |
2110 | if (m_embedix) | 2112 | if (m_embedix) |
2111 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; | 2113 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; |
2112 | else | 2114 | else |
2113 | return 256; | 2115 | return 256; |
2114 | } | 2116 | } |
2115 | 2117 | ||
2116 | bool Zaurus::hasHingeSensor() const | 2118 | bool Zaurus::hasHingeSensor() const |
2117 | { | 2119 | { |
2118 | return d->m_model == Model_Zaurus_SLC7x0; | 2120 | return d->m_model == Model_Zaurus_SLC7x0; |
2119 | } | 2121 | } |
2120 | 2122 | ||
2121 | OHingeStatus Zaurus::readHingeSensor() | 2123 | OHingeStatus Zaurus::readHingeSensor() |
2122 | { | 2124 | { |
2123 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2125 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2124 | if (handle == -1) | 2126 | if (handle == -1) |
2125 | { | 2127 | { |
2126 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 2128 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
2127 | return CASE_UNKNOWN; | 2129 | return CASE_UNKNOWN; |
2128 | } | 2130 | } |
2129 | else | 2131 | else |
2130 | { | 2132 | { |
2131 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2133 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2132 | ::close (handle); | 2134 | ::close (handle); |
2133 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 2135 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
2134 | { | 2136 | { |
2135 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 2137 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
2136 | return static_cast<OHingeStatus>( retval ); | 2138 | return static_cast<OHingeStatus>( retval ); |
2137 | } | 2139 | } |
2138 | else | 2140 | else |
2139 | { | 2141 | { |
2140 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 2142 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
2141 | return CASE_UNKNOWN; | 2143 | return CASE_UNKNOWN; |
2142 | } | 2144 | } |
2143 | } | 2145 | } |
2144 | } | 2146 | } |
2145 | 2147 | ||
2146 | 2148 | ||
2147 | /************************************************** | 2149 | /************************************************** |
2148 | * | 2150 | * |
2149 | * SIMpad | 2151 | * SIMpad |
2150 | * | 2152 | * |
2151 | **************************************************/ | 2153 | **************************************************/ |
2152 | 2154 | ||
2153 | void SIMpad::init ( ) | 2155 | void SIMpad::init ( ) |
2154 | { | 2156 | { |
2155 | d-> m_vendorstr = "SIEMENS"; | 2157 | d-> m_vendorstr = "SIEMENS"; |
2156 | d-> m_vendor = Vendor_SIEMENS; | 2158 | d-> m_vendor = Vendor_SIEMENS; |
2157 | 2159 | ||
2158 | QFile f ( "/proc/hal/model" ); | 2160 | QFile f ( "/proc/hal/model" ); |
2159 | 2161 | ||
2160 | //TODO Implement model checking | 2162 | //TODO Implement model checking |
2161 | //FIXME For now we assume an SL4 | 2163 | //FIXME For now we assume an SL4 |
2162 | 2164 | ||
2163 | d-> m_modelstr = "SL4"; | 2165 | d-> m_modelstr = "SL4"; |
2164 | d-> m_model = Model_SIMpad_SL4; | 2166 | d-> m_model = Model_SIMpad_SL4; |
2165 | 2167 | ||
2166 | switch ( d-> m_model ) { | 2168 | switch ( d-> m_model ) { |
2167 | default: | 2169 | default: |
2168 | d-> m_rotation = Rot0; | 2170 | d-> m_rotation = Rot0; |
2169 | d-> m_direction = CCW; | 2171 | d-> m_direction = CCW; |
2170 | d-> m_holdtime = 1000; // 1000ms | 2172 | d-> m_holdtime = 1000; // 1000ms |
2171 | 2173 | ||
2172 | break; | 2174 | break; |
2173 | } | 2175 | } |
2174 | 2176 | ||
2175 | f. setName ( "/etc/familiar-version" ); | 2177 | f. setName ( "/etc/familiar-version" ); |
2176 | if ( f. open ( IO_ReadOnly )) { | 2178 | if ( f. open ( IO_ReadOnly )) { |
2177 | d-> m_systemstr = "Familiar"; | 2179 | d-> m_systemstr = "Familiar"; |
2178 | d-> m_system = System_Familiar; | 2180 | d-> m_system = System_Familiar; |
2179 | 2181 | ||
2180 | QTextStream ts ( &f ); | 2182 | QTextStream ts ( &f ); |
2181 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2183 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2182 | 2184 | ||
2183 | f. close ( ); | 2185 | f. close ( ); |
2184 | } else { | 2186 | } else { |
2185 | f. setName ( "/etc/oz_version" ); | 2187 | f. setName ( "/etc/oz_version" ); |
2186 | 2188 | ||
2187 | if ( f. open ( IO_ReadOnly )) { | 2189 | if ( f. open ( IO_ReadOnly )) { |
2188 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 2190 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
2189 | d-> m_system = System_OpenZaurus; | 2191 | d-> m_system = System_OpenZaurus; |
2190 | 2192 | ||
2191 | QTextStream ts ( &f ); | 2193 | QTextStream ts ( &f ); |
2192 | ts.setDevice ( &f ); | 2194 | ts.setDevice ( &f ); |
2193 | d-> m_sysverstr = ts. readLine ( ); | 2195 | d-> m_sysverstr = ts. readLine ( ); |
2194 | f. close ( ); | 2196 | f. close ( ); |
2195 | } | 2197 | } |
2196 | } | 2198 | } |
2197 | 2199 | ||
2198 | m_leds [0] = m_leds [1] = Led_Off; | 2200 | m_leds [0] = m_leds [1] = Led_Off; |
2199 | 2201 | ||
2200 | m_power_timer = 0; | 2202 | m_power_timer = 0; |
2201 | 2203 | ||
2202 | } | 2204 | } |
2203 | 2205 | ||
2204 | void SIMpad::initButtons ( ) | 2206 | void SIMpad::initButtons ( ) |
2205 | { | 2207 | { |
2206 | if ( d-> m_buttons ) | 2208 | if ( d-> m_buttons ) |
2207 | return; | 2209 | return; |
2208 | 2210 | ||
2209 | if ( isQWS( ) ) | 2211 | if ( isQWS( ) ) |
2210 | QWSServer::setKeyboardFilter ( this ); | 2212 | QWSServer::setKeyboardFilter ( this ); |
2211 | 2213 | ||
2212 | d-> m_buttons = new QValueList <ODeviceButton>; | 2214 | d-> m_buttons = new QValueList <ODeviceButton>; |
2213 | 2215 | ||
2214 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 2216 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
2215 | s_button *sb = simpad_buttons + i; | 2217 | s_button *sb = simpad_buttons + i; |
2216 | ODeviceButton b; | 2218 | ODeviceButton b; |
2217 | 2219 | ||
2218 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 2220 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
2219 | b. setKeycode ( sb-> code ); | 2221 | b. setKeycode ( sb-> code ); |
2220 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 2222 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
2221 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 2223 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
2222 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 2224 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
2223 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 2225 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
2224 | 2226 | ||
2225 | d-> m_buttons-> append ( b ); | 2227 | d-> m_buttons-> append ( b ); |
2226 | } | 2228 | } |
2227 | } | 2229 | } |
2228 | reloadButtonMapping ( ); | 2230 | reloadButtonMapping ( ); |
2229 | 2231 | ||
2230 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2232 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2231 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2233 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
2232 | } | 2234 | } |
2233 | 2235 | ||
2234 | // SIMpad boardcontrol register CS3 | 2236 | // SIMpad boardcontrol register CS3 |
2235 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 2237 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
2236 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 2238 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
2237 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 2239 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
2238 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 2240 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
2239 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 2241 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
2240 | #define SIMPAD_DISPLAY_ON 0x0010 | 2242 | #define SIMPAD_DISPLAY_ON 0x0010 |
2241 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 2243 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
2242 | #define SIMPAD_MQ_RESET 0x0040 | 2244 | #define SIMPAD_MQ_RESET 0x0040 |
2243 | #define SIMPAD_PCMCIA_RESET 0x0080 | 2245 | #define SIMPAD_PCMCIA_RESET 0x0080 |
2244 | #define SIMPAD_DECT_POWER_ON 0x0100 | 2246 | #define SIMPAD_DECT_POWER_ON 0x0100 |
2245 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 2247 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
2246 | #define SIMPAD_RS232_ON 0x0400 | 2248 | #define SIMPAD_RS232_ON 0x0400 |
2247 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 2249 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
2248 | #define SIMPAD_LED2_ON 0x1000 | 2250 | #define SIMPAD_LED2_ON 0x1000 |
2249 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 2251 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
2250 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 2252 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
2251 | #define SIMPAD_RESET_SIMCARD 0x8000 | 2253 | #define SIMPAD_RESET_SIMCARD 0x8000 |
2252 | 2254 | ||
2253 | //SIMpad touchscreen backlight strength control | 2255 | //SIMpad touchscreen backlight strength control |
2254 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 2256 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
2255 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 2257 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
2256 | 2258 | ||
2257 | QValueList <OLed> SIMpad::ledList ( ) const | 2259 | QValueList <OLed> SIMpad::ledList ( ) const |
2258 | { | 2260 | { |
2259 | QValueList <OLed> vl; | 2261 | QValueList <OLed> vl; |
2260 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 2262 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
2261 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 2263 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
2262 | return vl; | 2264 | return vl; |
2263 | } | 2265 | } |
2264 | 2266 | ||
2265 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 2267 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
2266 | { | 2268 | { |
2267 | QValueList <OLedState> vl; | 2269 | QValueList <OLedState> vl; |
2268 | 2270 | ||
2269 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 2271 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
2270 | vl << Led_Off << Led_On; | 2272 | vl << Led_Off << Led_On; |
2271 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 2273 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
2272 | //vl << Led_Off; | 2274 | //vl << Led_Off; |
2273 | return vl; | 2275 | return vl; |
2274 | } | 2276 | } |
2275 | 2277 | ||
2276 | OLedState SIMpad::ledState ( OLed l ) const | 2278 | OLedState SIMpad::ledState ( OLed l ) const |
2277 | { | 2279 | { |
2278 | switch ( l ) { | 2280 | switch ( l ) { |
2279 | case Led_Power: | 2281 | case Led_Power: |
2280 | return m_leds [0]; | 2282 | return m_leds [0]; |
2281 | //case Led_Mail: | 2283 | //case Led_Mail: |
2282 | //return m_leds [1]; | 2284 | //return m_leds [1]; |
2283 | default: | 2285 | default: |
2284 | return Led_Off; | 2286 | return Led_Off; |
2285 | } | 2287 | } |
2286 | } | 2288 | } |
2287 | 2289 | ||
2288 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 2290 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
2289 | { | 2291 | { |
2290 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 2292 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
2291 | 2293 | ||
2292 | if ( l == Led_Power ) { | 2294 | if ( l == Led_Power ) { |
2293 | if ( fd >= 0 ) { | 2295 | if ( fd >= 0 ) { |
2294 | LED_IN leds; | 2296 | LED_IN leds; |
2295 | ::memset ( &leds, 0, sizeof( leds )); | 2297 | ::memset ( &leds, 0, sizeof( leds )); |
2296 | leds. TotalTime = 0; | 2298 | leds. TotalTime = 0; |
2297 | leds. OnTime = 0; | 2299 | leds. OnTime = 0; |
2298 | leds. OffTime = 1; | 2300 | leds. OffTime = 1; |
2299 | leds. OffOnBlink = 2; | 2301 | leds. OffOnBlink = 2; |
2300 | 2302 | ||
2301 | switch ( st ) { | 2303 | switch ( st ) { |
2302 | case Led_Off : leds. OffOnBlink = 0; break; | 2304 | case Led_Off : leds. OffOnBlink = 0; break; |
2303 | case Led_On : leds. OffOnBlink = 1; break; | 2305 | case Led_On : leds. OffOnBlink = 1; break; |
2304 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 2306 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
2305 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 2307 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
2306 | } | 2308 | } |
2307 | 2309 | ||
2308 | { | 2310 | { |
2309 | /*TODO Implement this like that: | 2311 | /*TODO Implement this like that: |
2310 | read from cs3 | 2312 | read from cs3 |
2311 | && with SIMPAD_LED2_ON | 2313 | && with SIMPAD_LED2_ON |
2312 | write to cs3 */ | 2314 | write to cs3 */ |
2313 | m_leds [0] = st; | 2315 | m_leds [0] = st; |
2314 | return true; | 2316 | return true; |
2315 | } | 2317 | } |
2316 | } | 2318 | } |
2317 | } | 2319 | } |
2318 | return false; | 2320 | return false; |
2319 | } | 2321 | } |
2320 | 2322 | ||
2321 | 2323 | ||
2322 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 2324 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
2323 | { | 2325 | { |
2324 | //TODO | 2326 | //TODO |
2325 | return false; | 2327 | return false; |
2326 | } | 2328 | } |
2327 | 2329 | ||
2328 | void SIMpad::timerEvent ( QTimerEvent * ) | 2330 | void SIMpad::timerEvent ( QTimerEvent * ) |
2329 | { | 2331 | { |
2330 | killTimer ( m_power_timer ); | 2332 | killTimer ( m_power_timer ); |
2331 | m_power_timer = 0; | 2333 | m_power_timer = 0; |
2332 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 2334 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
2333 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 2335 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
2334 | } | 2336 | } |
2335 | 2337 | ||
2336 | 2338 | ||
2337 | void SIMpad::alarmSound ( ) | 2339 | void SIMpad::alarmSound ( ) |
2338 | { | 2340 | { |
2339 | #ifndef QT_NO_SOUND | 2341 | #ifndef QT_NO_SOUND |
2340 | static Sound snd ( "alarm" ); | 2342 | static Sound snd ( "alarm" ); |
2341 | int fd; | 2343 | int fd; |
2342 | int vol; | 2344 | int vol; |
2343 | bool vol_reset = false; | 2345 | bool vol_reset = false; |
2344 | 2346 | ||
2345 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 2347 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
2346 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 2348 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
2347 | Config cfg ( "qpe" ); | 2349 | Config cfg ( "qpe" ); |
2348 | cfg. setGroup ( "Volume" ); | 2350 | cfg. setGroup ( "Volume" ); |
2349 | 2351 | ||
2350 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 2352 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
2351 | if ( volalarm < 0 ) | 2353 | if ( volalarm < 0 ) |
2352 | volalarm = 0; | 2354 | volalarm = 0; |
2353 | else if ( volalarm > 100 ) | 2355 | else if ( volalarm > 100 ) |
2354 | volalarm = 100; | 2356 | volalarm = 100; |
2355 | volalarm |= ( volalarm << 8 ); | 2357 | volalarm |= ( volalarm << 8 ); |
2356 | 2358 | ||
2357 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 2359 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
2358 | vol_reset = true; | 2360 | vol_reset = true; |
2359 | } | 2361 | } |
2360 | } | 2362 | } |
2361 | 2363 | ||
2362 | snd. play ( ); | 2364 | snd. play ( ); |
2363 | while ( !snd. isFinished ( )) | 2365 | while ( !snd. isFinished ( )) |
2364 | qApp-> processEvents ( ); | 2366 | qApp-> processEvents ( ); |
2365 | 2367 | ||
2366 | if ( fd >= 0 ) { | 2368 | if ( fd >= 0 ) { |
2367 | if ( vol_reset ) | 2369 | if ( vol_reset ) |
2368 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 2370 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
2369 | ::close ( fd ); | 2371 | ::close ( fd ); |
2370 | } | 2372 | } |
2371 | #endif | 2373 | #endif |
2372 | } | 2374 | } |
2373 | 2375 | ||
2374 | 2376 | ||
2375 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | 2377 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm |
2376 | { | 2378 | { |
2377 | qDebug( "ODevice for SIMpad: suspend()" ); | 2379 | qDebug( "ODevice for SIMpad: suspend()" ); |
2378 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 2380 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
2379 | return false; | 2381 | return false; |
2380 | 2382 | ||
2381 | bool res = false; | 2383 | bool res = false; |
2382 | 2384 | ||
2383 | struct timeval tvs, tvn; | 2385 | struct timeval tvs, tvn; |
2384 | ::gettimeofday ( &tvs, 0 ); | 2386 | ::gettimeofday ( &tvs, 0 ); |
2385 | 2387 | ||
2386 | ::sync ( ); // flush fs caches | 2388 | ::sync ( ); // flush fs caches |
2387 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 2389 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
2388 | 2390 | ||
2389 | return res; | 2391 | return res; |
2390 | } | 2392 | } |
2391 | 2393 | ||
2392 | 2394 | ||
2393 | bool SIMpad::setSoftSuspend ( bool soft ) | 2395 | bool SIMpad::setSoftSuspend ( bool soft ) |
2394 | { | 2396 | { |
2395 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 2397 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
2396 | return false; | 2398 | return false; |
2397 | } | 2399 | } |
2398 | 2400 | ||
2399 | 2401 | ||
2400 | bool SIMpad::setDisplayStatus ( bool on ) | 2402 | bool SIMpad::setDisplayStatus ( bool on ) |
2401 | { | 2403 | { |
2402 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 2404 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
2403 | 2405 | ||
2404 | bool res = false; | 2406 | bool res = false; |
2405 | int fd; | 2407 | int fd; |
2406 | 2408 | ||
2407 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 2409 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
2408 | 2410 | ||
2409 | res = ( ::system( (const char*) cmdline ) == 0 ); | 2411 | res = ( ::system( (const char*) cmdline ) == 0 ); |
2410 | 2412 | ||
2411 | return res; | 2413 | return res; |
2412 | } | 2414 | } |
2413 | 2415 | ||
2414 | 2416 | ||
2415 | bool SIMpad::setDisplayBrightness ( int bright ) | 2417 | bool SIMpad::setDisplayBrightness ( int bright ) |
2416 | { | 2418 | { |
2417 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 2419 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
2418 | bool res = false; | 2420 | bool res = false; |
2419 | int fd; | 2421 | int fd; |
2420 | 2422 | ||
2421 | if ( bright > 255 ) | 2423 | if ( bright > 255 ) |
2422 | bright = 255; | 2424 | bright = 255; |
2423 | if ( bright < 1 ) | 2425 | if ( bright < 1 ) |
2424 | bright = 0; | 2426 | bright = 0; |
2425 | 2427 | ||
2426 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 2428 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
2427 | int value = 255 - bright; | 2429 | int value = 255 - bright; |
2428 | const int mask = SIMPAD_BACKLIGHT_MASK; | 2430 | const int mask = SIMPAD_BACKLIGHT_MASK; |
2429 | value = value << 8; | 2431 | value = value << 8; |
2430 | value += mask; | 2432 | value += mask; |
2431 | char writeCommand[100]; | 2433 | char writeCommand[100]; |
2432 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 2434 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
2433 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 2435 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
2434 | ::close ( fd ); | 2436 | ::close ( fd ); |
2435 | } | 2437 | } |
2436 | return res; | 2438 | return res; |
2437 | } | 2439 | } |
2438 | 2440 | ||
2439 | 2441 | ||
2440 | int SIMpad::displayBrightnessResolution ( ) const | 2442 | int SIMpad::displayBrightnessResolution ( ) const |
2441 | { | 2443 | { |
2442 | return 255; // All SIMpad models share the same display | 2444 | return 255; // All SIMpad models share the same display |
2443 | } | 2445 | } |
2444 | 2446 | ||
2445 | /************************************************** | 2447 | /************************************************** |
2446 | * | 2448 | * |
2447 | * Ramses | 2449 | * Ramses |
2448 | * | 2450 | * |
2449 | **************************************************/ | 2451 | **************************************************/ |
2450 | 2452 | ||
2451 | void Ramses::init() | 2453 | void Ramses::init() |
2452 | { | 2454 | { |
2453 | d->m_vendorstr = "M und N"; | 2455 | d->m_vendorstr = "M und N"; |
2454 | d->m_vendor = Vendor_MundN; | 2456 | d->m_vendor = Vendor_MundN; |
2455 | 2457 | ||
2456 | QFile f("/proc/sys/board/ramses"); | 2458 | QFile f("/proc/sys/board/ramses"); |
2457 | 2459 | ||
2458 | d->m_modelstr = "Ramses"; | 2460 | d->m_modelstr = "Ramses"; |
2459 | d->m_model = Model_Ramses_MNCI; | 2461 | d->m_model = Model_Ramses_MNCI; |
2460 | 2462 | ||
2461 | d->m_rotation = Rot0; | 2463 | d->m_rotation = Rot0; |
2462 | d->m_holdtime = 1000; | 2464 | d->m_holdtime = 1000; |
2463 | 2465 | ||
2464 | f.setName("/etc/oz_version"); | 2466 | f.setName("/etc/oz_version"); |
2465 | 2467 | ||
2466 | if (f.open(IO_ReadOnly)) { | 2468 | if (f.open(IO_ReadOnly)) { |
2467 | d->m_systemstr = "OpenEmbedded/Ramses"; | 2469 | d->m_systemstr = "OpenEmbedded/Ramses"; |
2468 | d->m_system = System_OpenZaurus; | 2470 | d->m_system = System_OpenZaurus; |
2469 | 2471 | ||
2470 | QTextStream ts(&f); | 2472 | QTextStream ts(&f); |
2471 | ts.setDevice(&f); | 2473 | ts.setDevice(&f); |
2472 | d->m_sysverstr = ts.readLine(); | 2474 | d->m_sysverstr = ts.readLine(); |
2473 | f.close(); | 2475 | f.close(); |
2474 | } | 2476 | } |
2475 | 2477 | ||
2476 | m_power_timer = 0; | 2478 | m_power_timer = 0; |
2477 | 2479 | ||
2478 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 2480 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
2479 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 2481 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
2480 | #define OC(x...) x | 2482 | #define OC(x...) x |
2481 | #else | 2483 | #else |
2482 | #define OC(x...) | 2484 | #define OC(x...) |
2483 | #endif | 2485 | #endif |
2484 | 2486 | ||
2485 | 2487 | ||
2486 | // This table is true for a Intel XScale PXA 255 | 2488 | // This table is true for a Intel XScale PXA 255 |
2487 | 2489 | ||
2488 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 2490 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
2489 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 2491 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
2490 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 2492 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
2491 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 2493 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
2492 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 2494 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
2493 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 2495 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
2494 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 2496 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |