mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 20:55:17 -05:00
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
This commit is contained in:
parent
750f0acee3
commit
ddbb751425
2 changed files with 66 additions and 5 deletions
|
|
@ -56,6 +56,7 @@ bool Autodetection::detect()
|
||||||
QDir dir(mountpoints.at(i));
|
QDir dir(mountpoints.at(i));
|
||||||
if(dir.exists())
|
if(dir.exists())
|
||||||
{
|
{
|
||||||
|
qDebug() << "file checking:" << mountpoints.at(i);
|
||||||
// check logfile first.
|
// check logfile first.
|
||||||
if(QFile(mountpoints.at(i) + "/.rockbox/rbutil.log").exists()) {
|
if(QFile(mountpoints.at(i) + "/.rockbox/rbutil.log").exists()) {
|
||||||
QSettings log(mountpoints.at(i) + "/.rockbox/rbutil.log",
|
QSettings log(mountpoints.at(i) + "/.rockbox/rbutil.log",
|
||||||
|
|
@ -95,23 +96,28 @@ bool Autodetection::detect()
|
||||||
m_mountpoint = mountpoints.at(i);
|
m_mountpoint = mountpoints.at(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(rootentries.contains("ONDIOST.BIN"), Qt::CaseInsensitive)
|
if(rootentries.contains("ONDIOST.BIN", Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
// ONDIOST.BIN in root -> Ondio FM
|
// ONDIOST.BIN in root -> Ondio FM
|
||||||
m_device = "ondiofm";
|
m_device = "ondiofm";
|
||||||
m_mountpoint = mountpoints.at(i);
|
m_mountpoint = mountpoints.at(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(rootentries.contains("ONDIOSP.BIN"), Qt::CaseInsensitive)
|
if(rootentries.contains("ONDIOSP.BIN", Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
// ONDIOSP.BIN in root -> Ondio SP
|
// ONDIOSP.BIN in root -> Ondio SP
|
||||||
m_device = "ondiosp";
|
m_device = "ondiosp";
|
||||||
m_mountpoint = mountpoints.at(i);
|
m_mountpoint = mountpoints.at(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(rootentries.contains("ajbrec.ajz"), Qt::CaseInsensitive)
|
if(rootentries.contains("ajbrec.ajz", Qt::CaseInsensitive))
|
||||||
{
|
{
|
||||||
qDebug() << "it's an archos. further detection needed";
|
qDebug() << "ajbrec.ajz found. Trying detectAjbrec()";
|
||||||
|
if(detectAjbrec(mountpoints.at(i))) {
|
||||||
|
m_mountpoint = mountpoints.at(i);
|
||||||
|
qDebug() << m_device;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// detection based on player specific folders
|
// detection based on player specific folders
|
||||||
QStringList rootfolders = root.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
QStringList rootfolders = root.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
|
@ -122,7 +128,6 @@ bool Autodetection::detect()
|
||||||
m_mountpoint = mountpoints.at(i);
|
m_mountpoint = mountpoints.at(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
qDebug() << rootfolders;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -260,6 +265,7 @@ bool Autodetection::detectUsb()
|
||||||
while(u) {
|
while(u) {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
id = u->descriptor.idVendor << 16 | u->descriptor.idProduct;
|
id = u->descriptor.idVendor << 16 | u->descriptor.idProduct;
|
||||||
|
m_usbconid.append(id);
|
||||||
qDebug("%x", id);
|
qDebug("%x", id);
|
||||||
|
|
||||||
if(usbids.contains(id)) {
|
if(usbids.contains(id)) {
|
||||||
|
|
@ -332,6 +338,7 @@ bool Autodetection::detectUsb()
|
||||||
else {
|
else {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
id = vid << 16 | pid;
|
id = vid << 16 | pid;
|
||||||
|
m_usbconid.append(id);
|
||||||
qDebug("VID: %04x PID: %04x", vid, pid);
|
qDebug("VID: %04x PID: %04x", vid, pid);
|
||||||
if(usbids.contains(id)) {
|
if(usbids.contains(id)) {
|
||||||
m_device = usbids.value(id);
|
m_device = usbids.value(id);
|
||||||
|
|
@ -357,3 +364,55 @@ bool Autodetection::detectUsb()
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Autodetection::detectAjbrec(QString root)
|
||||||
|
{
|
||||||
|
QFile f(root + "/ajbrec.ajz");
|
||||||
|
char header[24];
|
||||||
|
f.open(QIODevice::ReadOnly);
|
||||||
|
if(!f.read(header, 24)) return false;
|
||||||
|
|
||||||
|
// check the header of the file.
|
||||||
|
// recorder v1 had a 6 bytes sized header
|
||||||
|
// recorder v2, FM, Ondio SP and FM have a 24 bytes header.
|
||||||
|
|
||||||
|
// recorder v1 has the binary length in the first 4 bytes, so check
|
||||||
|
// for them first.
|
||||||
|
int len = (header[0]<<24) | (header[1]<<16) | (header[2]<<8) | header[3];
|
||||||
|
qDebug() << "possible bin length:" << len;
|
||||||
|
qDebug() << "file len:" << f.size();
|
||||||
|
if((f.size() - 6) == len)
|
||||||
|
m_device = "recorder";
|
||||||
|
|
||||||
|
// size didn't match, now we need to assume we have a headerlength of 24.
|
||||||
|
switch(header[11]) {
|
||||||
|
case 2:
|
||||||
|
m_device = "recorderv2";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
m_device = "fmrecorder";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
// newer recorder firmwares also use the version id 8
|
||||||
|
// so check usb id too.
|
||||||
|
if(m_usbconid.contains(0x058f9330))
|
||||||
|
m_device = "ondiofm";
|
||||||
|
else
|
||||||
|
m_device = "recorderv2";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
m_device = "ondiosp";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
if(m_device.isEmpty()) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,12 @@ private:
|
||||||
QStringList getMountpoints(void);
|
QStringList getMountpoints(void);
|
||||||
QString resolveMountPoint(QString);
|
QString resolveMountPoint(QString);
|
||||||
bool detectUsb(void);
|
bool detectUsb(void);
|
||||||
|
bool detectAjbrec(QString);
|
||||||
|
|
||||||
QString m_device;
|
QString m_device;
|
||||||
QString m_mountpoint;
|
QString m_mountpoint;
|
||||||
QString m_errdev;
|
QString m_errdev;
|
||||||
|
QList<int> m_usbconid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue