summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-09-27 08:50:47 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-09-27 08:50:47 +0000
commitddbb75142571e05b6f046594840151d8b4b379b1 (patch)
tree455097c97dedd16e8c82d1204cfcda516fa1800f
parent750f0acee30b5b89fb1547cc8bbe1b9f165044bf (diff)
downloadrockbox-ddbb75142571e05b6f046594840151d8b4b379b1.tar.gz
rockbox-ddbb75142571e05b6f046594840151d8b4b379b1.zip
Add parsing of ajbrec.ajz file header for autodetection. All archos targets should now be detectable. Fix a stupid bug in file-based detection.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14865 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/autodetection.cpp69
-rw-r--r--rbutil/rbutilqt/autodetection.h2
2 files changed, 66 insertions, 5 deletions
diff --git a/rbutil/rbutilqt/autodetection.cpp b/rbutil/rbutilqt/autodetection.cpp
index def1d12ef7..7be8cca707 100644
--- a/rbutil/rbutilqt/autodetection.cpp
+++ b/rbutil/rbutilqt/autodetection.cpp
@@ -56,6 +56,7 @@ bool Autodetection::detect()
56 QDir dir(mountpoints.at(i)); 56 QDir dir(mountpoints.at(i));
57 if(dir.exists()) 57 if(dir.exists())
58 { 58 {
59 qDebug() << "file checking:" << mountpoints.at(i);
59 // check logfile first. 60 // check logfile first.
60 if(QFile(mountpoints.at(i) + "/.rockbox/rbutil.log").exists()) { 61 if(QFile(mountpoints.at(i) + "/.rockbox/rbutil.log").exists()) {
61 QSettings log(mountpoints.at(i) + "/.rockbox/rbutil.log", 62 QSettings log(mountpoints.at(i) + "/.rockbox/rbutil.log",
@@ -95,23 +96,28 @@ bool Autodetection::detect()
95 m_mountpoint = mountpoints.at(i); 96 m_mountpoint = mountpoints.at(i);
96 return true; 97 return true;
97 } 98 }
98 if(rootentries.contains("ONDIOST.BIN"), Qt::CaseInsensitive) 99 if(rootentries.contains("ONDIOST.BIN", Qt::CaseInsensitive))
99 { 100 {
100 // ONDIOST.BIN in root -> Ondio FM 101 // ONDIOST.BIN in root -> Ondio FM
101 m_device = "ondiofm"; 102 m_device = "ondiofm";
102 m_mountpoint = mountpoints.at(i); 103 m_mountpoint = mountpoints.at(i);
103 return true; 104 return true;
104 } 105 }
105 if(rootentries.contains("ONDIOSP.BIN"), Qt::CaseInsensitive) 106 if(rootentries.contains("ONDIOSP.BIN", Qt::CaseInsensitive))
106 { 107 {
107 // ONDIOSP.BIN in root -> Ondio SP 108 // ONDIOSP.BIN in root -> Ondio SP
108 m_device = "ondiosp"; 109 m_device = "ondiosp";
109 m_mountpoint = mountpoints.at(i); 110 m_mountpoint = mountpoints.at(i);
110 return true; 111 return true;
111 } 112 }
112 if(rootentries.contains("ajbrec.ajz"), Qt::CaseInsensitive) 113 if(rootentries.contains("ajbrec.ajz", Qt::CaseInsensitive))
113 { 114 {
114 qDebug() << "it's an archos. further detection needed"; 115 qDebug() << "ajbrec.ajz found. Trying detectAjbrec()";
116 if(detectAjbrec(mountpoints.at(i))) {
117 m_mountpoint = mountpoints.at(i);
118 qDebug() << m_device;
119 return true;
120 }
115 } 121 }
116 // detection based on player specific folders 122 // detection based on player specific folders
117 QStringList rootfolders = root.entryList(QDir::Dirs | QDir::NoDotAndDotDot); 123 QStringList rootfolders = root.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
@@ -122,7 +128,6 @@ bool Autodetection::detect()
122 m_mountpoint = mountpoints.at(i); 128 m_mountpoint = mountpoints.at(i);
123 return true; 129 return true;
124 } 130 }
125 qDebug() << rootfolders;
126 } 131 }
127 132
128 } 133 }
@@ -260,6 +265,7 @@ bool Autodetection::detectUsb()
260 while(u) { 265 while(u) {
261 uint32_t id; 266 uint32_t id;
262 id = u->descriptor.idVendor << 16 | u->descriptor.idProduct; 267 id = u->descriptor.idVendor << 16 | u->descriptor.idProduct;
268 m_usbconid.append(id);
263 qDebug("%x", id); 269 qDebug("%x", id);
264 270
265 if(usbids.contains(id)) { 271 if(usbids.contains(id)) {
@@ -332,6 +338,7 @@ bool Autodetection::detectUsb()
332 else { 338 else {
333 uint32_t id; 339 uint32_t id;
334 id = vid << 16 | pid; 340 id = vid << 16 | pid;
341 m_usbconid.append(id);
335 qDebug("VID: %04x PID: %04x", vid, pid); 342 qDebug("VID: %04x PID: %04x", vid, pid);
336 if(usbids.contains(id)) { 343 if(usbids.contains(id)) {
337 m_device = usbids.value(id); 344 m_device = usbids.value(id);
@@ -357,3 +364,55 @@ bool Autodetection::detectUsb()
357#endif 364#endif
358 return false; 365 return false;
359} 366}
367
368
369bool Autodetection::detectAjbrec(QString root)
370{
371 QFile f(root + "/ajbrec.ajz");
372 char header[24];
373 f.open(QIODevice::ReadOnly);
374 if(!f.read(header, 24)) return false;
375
376 // check the header of the file.
377 // recorder v1 had a 6 bytes sized header
378 // recorder v2, FM, Ondio SP and FM have a 24 bytes header.
379
380 // recorder v1 has the binary length in the first 4 bytes, so check
381 // for them first.
382 int len = (header[0]<<24) | (header[1]<<16) | (header[2]<<8) | header[3];
383 qDebug() << "possible bin length:" << len;
384 qDebug() << "file len:" << f.size();
385 if((f.size() - 6) == len)
386 m_device = "recorder";
387
388 // size didn't match, now we need to assume we have a headerlength of 24.
389 switch(header[11]) {
390 case 2:
391 m_device = "recorderv2";
392 break;
393
394 case 4:
395 m_device = "fmrecorder";
396 break;
397
398 case 8:
399 // newer recorder firmwares also use the version id 8
400 // so check usb id too.
401 if(m_usbconid.contains(0x058f9330))
402 m_device = "ondiofm";
403 else
404 m_device = "recorderv2";
405 break;
406
407 case 16:
408 m_device = "ondiosp";
409 break;
410
411 default:
412 break;
413 }
414 f.close();
415
416 if(m_device.isEmpty()) return false;
417 return true;
418}
diff --git a/rbutil/rbutilqt/autodetection.h b/rbutil/rbutilqt/autodetection.h
index 83eb3979fe..a620b69566 100644
--- a/rbutil/rbutilqt/autodetection.h
+++ b/rbutil/rbutilqt/autodetection.h
@@ -46,10 +46,12 @@ private:
46 QStringList getMountpoints(void); 46 QStringList getMountpoints(void);
47 QString resolveMountPoint(QString); 47 QString resolveMountPoint(QString);
48 bool detectUsb(void); 48 bool detectUsb(void);
49 bool detectAjbrec(QString);
49 50
50 QString m_device; 51 QString m_device;
51 QString m_mountpoint; 52 QString m_mountpoint;
52 QString m_errdev; 53 QString m_errdev;
54 QList<int> m_usbconid;
53}; 55};
54 56
55 57