diff options
-rw-r--r-- | rbutil/rbutilqt/autodetection.cpp | 87 | ||||
-rw-r--r-- | rbutil/rbutilqt/autodetection.h | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 14 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutil.ini | 15 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.pro | 3 |
6 files changed, 119 insertions, 6 deletions
diff --git a/rbutil/rbutilqt/autodetection.cpp b/rbutil/rbutilqt/autodetection.cpp index f29df535ab..c16b6976cc 100644 --- a/rbutil/rbutilqt/autodetection.cpp +++ b/rbutil/rbutilqt/autodetection.cpp | |||
@@ -19,9 +19,10 @@ | |||
19 | 19 | ||
20 | #include "autodetection.h" | 20 | #include "autodetection.h" |
21 | 21 | ||
22 | #if defined(Q_OS_LINUX) | 22 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) |
23 | #include <stdio.h> | 23 | #include <stdio.h> |
24 | #include <mntent.h> | 24 | #include <mntent.h> |
25 | #include <usb.h> | ||
25 | #endif | 26 | #endif |
26 | 27 | ||
27 | Autodetection::Autodetection(QObject* parent): QObject(parent) | 28 | Autodetection::Autodetection(QObject* parent): QObject(parent) |
@@ -33,6 +34,9 @@ bool Autodetection::detect() | |||
33 | { | 34 | { |
34 | m_device = ""; | 35 | m_device = ""; |
35 | m_mountpoint = ""; | 36 | m_mountpoint = ""; |
37 | m_errdev = ""; | ||
38 | |||
39 | detectUsb(); | ||
36 | 40 | ||
37 | // Try detection via rockbox.info / rbutil.log | 41 | // Try detection via rockbox.info / rbutil.log |
38 | QStringList mountpoints = getMountpoints(); | 42 | QStringList mountpoints = getMountpoints(); |
@@ -48,7 +52,8 @@ bool Autodetection::detect() | |||
48 | QSettings log(mountpoints.at(i) + "/.rockbox/rbutil.log", | 52 | QSettings log(mountpoints.at(i) + "/.rockbox/rbutil.log", |
49 | QSettings::IniFormat, this); | 53 | QSettings::IniFormat, this); |
50 | if(!log.value("platform").toString().isEmpty()) { | 54 | if(!log.value("platform").toString().isEmpty()) { |
51 | m_device = log.value("platform").toString(); | 55 | if(m_device.isEmpty()) |
56 | m_device = log.value("platform").toString(); | ||
52 | m_mountpoint = mountpoints.at(i); | 57 | m_mountpoint = mountpoints.at(i); |
53 | qDebug() << "rbutil.log detected:" << m_device << m_mountpoint; | 58 | qDebug() << "rbutil.log detected:" << m_device << m_mountpoint; |
54 | return true; | 59 | return true; |
@@ -64,7 +69,8 @@ bool Autodetection::detect() | |||
64 | if(line.startsWith("Target: ")) | 69 | if(line.startsWith("Target: ")) |
65 | { | 70 | { |
66 | line.remove("Target: "); | 71 | line.remove("Target: "); |
67 | m_device = line.trimmed(); // trim whitespaces | 72 | if(m_device.isEmpty()) |
73 | m_device = line.trimmed(); // trim whitespaces | ||
68 | m_mountpoint = mountpoints.at(i); | 74 | m_mountpoint = mountpoints.at(i); |
69 | qDebug() << "rockbox-info.txt detected:" << m_device << m_mountpoint; | 75 | qDebug() << "rockbox-info.txt detected:" << m_device << m_mountpoint; |
70 | return true; | 76 | return true; |
@@ -133,7 +139,9 @@ bool Autodetection::detect() | |||
133 | return true; | 139 | return true; |
134 | } | 140 | } |
135 | 141 | ||
136 | return false; | 142 | if(m_mountpoint.isEmpty() && m_device.isEmpty() && m_errdev.isEmpty()) |
143 | return false; | ||
144 | return true; | ||
137 | } | 145 | } |
138 | 146 | ||
139 | 147 | ||
@@ -192,3 +200,74 @@ QString Autodetection::resolveMountPoint(QString device) | |||
192 | return QString(""); | 200 | return QString(""); |
193 | 201 | ||
194 | } | 202 | } |
203 | |||
204 | |||
205 | /** @brief detect devices based on usb pid / vid. | ||
206 | * @return true upon success, false otherwise. | ||
207 | */ | ||
208 | bool Autodetection::detectUsb() | ||
209 | { | ||
210 | // autodetection only uses the buildin device settings only | ||
211 | QSettings dev(":/ini/rbutil.ini", QSettings::IniFormat, this); | ||
212 | |||
213 | // get a list of ID -> target name | ||
214 | QStringList platforms; | ||
215 | dev.beginGroup("platforms"); | ||
216 | platforms = dev.childKeys(); | ||
217 | dev.endGroup(); | ||
218 | |||
219 | // usbids holds the mapping in the form | ||
220 | // ((VID<<16)|(PID)), targetname | ||
221 | // the ini file needs to hold the IDs as hex values. | ||
222 | QMap<int, QString> usbids; | ||
223 | QMap<int, QString> usberror; | ||
224 | |||
225 | for(int i = 0; i < platforms.size(); i++) { | ||
226 | dev.beginGroup("platforms"); | ||
227 | QString target = dev.value(platforms.at(i)).toString(); | ||
228 | dev.endGroup(); | ||
229 | dev.beginGroup(target); | ||
230 | if(!dev.value("usbid").toString().isEmpty()) | ||
231 | usbids.insert(dev.value("usbid").toString().toInt(0, 16), target); | ||
232 | if(!dev.value("usberror").toString().isEmpty()) | ||
233 | usberror.insert(dev.value("usberror").toString().toInt(0, 16), target); | ||
234 | dev.endGroup(); | ||
235 | } | ||
236 | |||
237 | // usb pid detection | ||
238 | #if defined(Q_OS_LINUX) | defined(Q_OS_MACX) | ||
239 | usb_init(); | ||
240 | usb_find_busses(); | ||
241 | usb_find_devices(); | ||
242 | struct usb_bus *b; | ||
243 | b = usb_get_busses(); | ||
244 | |||
245 | while(b) { | ||
246 | qDebug() << "bus:" << b->dirname << b->devices; | ||
247 | if(b->devices) { | ||
248 | qDebug() << "devices present."; | ||
249 | struct usb_device *u; | ||
250 | u = b->devices; | ||
251 | while(u) { | ||
252 | uint32_t id; | ||
253 | id = u->descriptor.idVendor << 16 | u->descriptor.idProduct; | ||
254 | qDebug("%x", id); | ||
255 | |||
256 | if(usbids.contains(id)) { | ||
257 | m_device = usbids.value(id); | ||
258 | return true; | ||
259 | } | ||
260 | if(usberror.contains(id)) { | ||
261 | m_errdev = usberror.value(id); | ||
262 | // we detected something, so return true | ||
263 | qDebug() << "detected device with problems via usb!"; | ||
264 | return true; | ||
265 | } | ||
266 | u = u->next; | ||
267 | } | ||
268 | } | ||
269 | b = b->next; | ||
270 | } | ||
271 | #endif | ||
272 | return false; | ||
273 | } | ||
diff --git a/rbutil/rbutilqt/autodetection.h b/rbutil/rbutilqt/autodetection.h index 2443b442f4..85b69045ef 100644 --- a/rbutil/rbutilqt/autodetection.h +++ b/rbutil/rbutilqt/autodetection.h | |||
@@ -40,14 +40,16 @@ public: | |||
40 | 40 | ||
41 | QString getDevice() {return m_device;} | 41 | QString getDevice() {return m_device;} |
42 | QString getMountPoint() {return m_mountpoint;} | 42 | QString getMountPoint() {return m_mountpoint;} |
43 | QString errdev(void) { return m_errdev; } | ||
43 | 44 | ||
44 | private: | 45 | private: |
45 | QStringList getMountpoints(void); | 46 | QStringList getMountpoints(void); |
46 | QString resolveMountPoint(QString); | 47 | QString resolveMountPoint(QString); |
48 | bool detectUsb(void); | ||
47 | 49 | ||
48 | QString m_device; | 50 | QString m_device; |
49 | QString m_mountpoint; | 51 | QString m_mountpoint; |
50 | 52 | QString m_errdev; | |
51 | }; | 53 | }; |
52 | 54 | ||
53 | 55 | ||
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index b67d454e82..07947691e5 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -565,6 +565,20 @@ void Config::autodetect() | |||
565 | } | 565 | } |
566 | } | 566 | } |
567 | 567 | ||
568 | if(!detector.errdev().isEmpty()) { | ||
569 | QString text; | ||
570 | if(detector.errdev() == "sansae200") | ||
571 | text = tr("Sansa e200 in MTP mode found!\n" | ||
572 | "You need to change your player to MSC mode for installation. "); | ||
573 | if(detector.errdev() == "h10") | ||
574 | text = tr("H10 20GB in MTP mode found!\n" | ||
575 | "You need to change your player to UMS mode for installation. "); | ||
576 | text += tr("Unless you changed this installation will fail!"); | ||
577 | |||
578 | QMessageBox::critical(this, tr("Fatal error"), text, QMessageBox::Ok); | ||
579 | return; | ||
580 | } | ||
581 | |||
568 | if(detector.getMountPoint() != "" ) | 582 | if(detector.getMountPoint() != "" ) |
569 | { | 583 | { |
570 | ui.mountPoint->setText(detector.getMountPoint()); | 584 | ui.mountPoint->setText(detector.getMountPoint()); |
diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini index 68c371e142..0ece567eba 100644 --- a/rbutil/rbutilqt/rbutil.ini +++ b/rbutil/rbutilqt/rbutil.ini | |||
@@ -142,6 +142,7 @@ bootloadername=bootloader-h100.bin | |||
142 | resolution=160x128x2 | 142 | resolution=160x128x2 |
143 | manualname=rockbox-h100 | 143 | manualname=rockbox-h100 |
144 | brand=Iriver | 144 | brand=Iriver |
145 | usbid=0x10063001 | ||
145 | 146 | ||
146 | [h120] | 147 | [h120] |
147 | name="iHP120 / iHP140 / H120 / H140" | 148 | name="iHP120 / iHP140 / H120 / H140" |
@@ -153,6 +154,7 @@ bootloadername=bootloader-h120.bin | |||
153 | resolution=160x128x2 | 154 | resolution=160x128x2 |
154 | manualname=rockbox-h100 | 155 | manualname=rockbox-h100 |
155 | brand=Iriver | 156 | brand=Iriver |
157 | usbid=0x10063002 | ||
156 | 158 | ||
157 | [h300] | 159 | [h300] |
158 | name="H320 / H340" | 160 | name="H320 / H340" |
@@ -164,6 +166,7 @@ bootloadername=bootloader-h300.bin | |||
164 | resolution=220x176x16 | 166 | resolution=220x176x16 |
165 | manualname=rockbox-h300 | 167 | manualname=rockbox-h300 |
166 | brand=Iriver | 168 | brand=Iriver |
169 | usbid=0x10063003 | ||
167 | 170 | ||
168 | [h10_5gbums] | 171 | [h10_5gbums] |
169 | name="H10 (5 / 6GB) UMS" | 172 | name="H10 (5 / 6GB) UMS" |
@@ -175,6 +178,7 @@ bootloadername=H10.mi4 | |||
175 | resolution=128x128x16 | 178 | resolution=128x128x16 |
176 | manualname= | 179 | manualname= |
177 | brand=Iriver | 180 | brand=Iriver |
181 | usbid=0x41022002 | ||
178 | 182 | ||
179 | [h10_5gbmtp] | 183 | [h10_5gbmtp] |
180 | name="H10 (5 / 6GB) MTP" | 184 | name="H10 (5 / 6GB) MTP" |
@@ -186,6 +190,7 @@ bootloadername=H10_5GB-MTP/H10.mi4 | |||
186 | resolution=128x128x16 | 190 | resolution=128x128x16 |
187 | manualname= | 191 | manualname= |
188 | brand=Iriver | 192 | brand=Iriver |
193 | usbid=0x41022105 | ||
189 | 194 | ||
190 | [h10] | 195 | [h10] |
191 | name="H10 (20GB)" | 196 | name="H10 (20GB)" |
@@ -197,6 +202,8 @@ bootloadername=H10_20GC.mi4 | |||
197 | resolution=160x128x16 | 202 | resolution=160x128x16 |
198 | manualname= | 203 | manualname= |
199 | brand=Iriver | 204 | brand=Iriver |
205 | usbid=0x0b7000ba | ||
206 | usberror=0x41022101 | ||
200 | 207 | ||
201 | [ipod1g2g] | 208 | [ipod1g2g] |
202 | name="Ipod (1st / 2nd gen)" | 209 | name="Ipod (1st / 2nd gen)" |
@@ -230,6 +237,7 @@ bootloadername=ipodnano | |||
230 | resolution=176x132x16 | 237 | resolution=176x132x16 |
231 | manualname= | 238 | manualname= |
232 | brand=Apple | 239 | brand=Apple |
240 | usbid=0x05ac120a | ||
233 | 241 | ||
234 | [ipod4gray] | 242 | [ipod4gray] |
235 | name="Ipod (4th gen, greyscale)" | 243 | name="Ipod (4th gen, greyscale)" |
@@ -274,6 +282,7 @@ bootloadername=ipod3g | |||
274 | resolution=160x128x2 | 282 | resolution=160x128x2 |
275 | manualname= | 283 | manualname= |
276 | brand=Apple | 284 | brand=Apple |
285 | usbid=0x05ac1201 | ||
277 | 286 | ||
278 | [ipodmini1g] | 287 | [ipodmini1g] |
279 | name="Ipod Mini (1st gen)" | 288 | name="Ipod Mini (1st gen)" |
@@ -307,6 +316,8 @@ bootloadername=x5_fw.bin | |||
307 | resolution=160x128x16 | 316 | resolution=160x128x16 |
308 | manualname= | 317 | manualname= |
309 | brand=Cowon | 318 | brand=Cowon |
319 | usbid=0x0e210510 | ||
320 | usbid=0x0e210513 | ||
310 | 321 | ||
311 | [iaudiox5v] | 322 | [iaudiox5v] |
312 | name="iAudio X5V" | 323 | name="iAudio X5V" |
@@ -329,6 +340,7 @@ bootloadername=m5_fw.bin | |||
329 | resolution=160x128x16 | 340 | resolution=160x128x16 |
330 | manualname= | 341 | manualname= |
331 | brand=Cowon | 342 | brand=Cowon |
343 | usbid=0x0e210520 | ||
332 | 344 | ||
333 | [gigabeatf] | 345 | [gigabeatf] |
334 | name="Gigabeat F / X" | 346 | name="Gigabeat F / X" |
@@ -339,6 +351,7 @@ bootloadername=FWIMG01.DAT | |||
339 | resolution=240x320x16 | 351 | resolution=240x320x16 |
340 | manualname= | 352 | manualname= |
341 | brand=Toshiba | 353 | brand=Toshiba |
354 | usbid=0x09300009 | ||
342 | 355 | ||
343 | [sansae200] | 356 | [sansae200] |
344 | name="Sansa E200" | 357 | name="Sansa E200" |
@@ -350,6 +363,8 @@ bootloadername=PP5022.mi4 | |||
350 | resolution=176x220x16 | 363 | resolution=176x220x16 |
351 | manualname= | 364 | manualname= |
352 | brand=Sandisk | 365 | brand=Sandisk |
366 | usbid=0x07817421 | ||
367 | usberror=0x07810720 | ||
353 | 368 | ||
354 | [encoders] | 369 | [encoders] |
355 | encpreset01 = "Lame (default)" | 370 | encpreset01 = "Lame (default)" |
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index f5376b5185..6a561e1b85 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -66,7 +66,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) | |||
66 | QSettings::UserScope, "rockbox.org", "RockboxUtility"); | 66 | QSettings::UserScope, "rockbox.org", "RockboxUtility"); |
67 | qDebug() << "config: system"; | 67 | qDebug() << "config: system"; |
68 | } | 68 | } |
69 | 69 | ||
70 | // manual tab | 70 | // manual tab |
71 | updateManual(); | 71 | updateManual(); |
72 | updateDevice(); | 72 | updateDevice(); |
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index e45560c124..2d0bd7633b 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro | |||
@@ -124,6 +124,9 @@ macx { | |||
124 | QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk | 124 | QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk |
125 | CONFIG+=x86 ppc | 125 | CONFIG+=x86 ppc |
126 | } | 126 | } |
127 | unix { | ||
128 | LIBS += -lusb | ||
129 | } | ||
127 | 130 | ||
128 | static { | 131 | static { |
129 | QTPLUGIN += qtaccessiblewidgets | 132 | QTPLUGIN += qtaccessiblewidgets |