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