Index: trunk/libffado/config.h.in =================================================================== --- trunk/libffado/config.h.in (revision 598) +++ trunk/libffado/config.h.in (revision 599) @@ -27,2 +27,3 @@ #define CACHEDIR "$cachedir" +#define SHAREDIR "$sharedir" Index: trunk/libffado/src/SConscript =================================================================== --- trunk/libffado/src/SConscript (revision 594) +++ trunk/libffado/src/SConscript (revision 599) @@ -91,4 +91,5 @@ maudio/fw410.xml \ maudio/fwap.xml \ + bebob/ffado_driver_bebob.txt \ ' ) @@ -98,7 +99,15 @@ ' ) +genericavc_pkgdata = env.Split( '\ + genericavc/ffado_driver_genericavc.txt \ +' ) + fireworks_source = env.Split( '\ fireworks/fireworks_device.cpp \ fireworks/audiofire/audiofire_device.cpp \ +' ) + +fireworks_pkgdata = env.Split( '\ + fireworks/ffado_driver_fireworks.txt \ ' ) @@ -210,4 +219,10 @@ libenv.Alias( "install", libenv.Install( "$sharedir", data ) ) +for data in genericavc_pkgdata: + libenv.Alias( "install", libenv.Install( "$sharedir", data ) ) + +for data in fireworks_pkgdata: + libenv.Alias( "install", libenv.Install( "$sharedir", data ) ) + # # For the debugging apps Index: trunk/libffado/src/genericavc/avc_avdevice.cpp =================================================================== --- trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 589) +++ trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 599) @@ -35,4 +35,6 @@ #include "debugmodule/debugmodule.h" +#include "config.h" + #include #include @@ -50,9 +52,4 @@ IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_VERBOSE ); -// to define the supported devices -static VendorModelEntry supportedDeviceList[] = -{ - -}; AvDevice::AvDevice( Ieee1394Service& ieee1394Service, @@ -78,14 +75,8 @@ unsigned int modelId = configRom.getModelId(); - for ( unsigned int i = 0; - i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); - ++i ) - { - if ( ( supportedDeviceList[i].vendor_id == vendorId ) - && ( supportedDeviceList[i].model_id == modelId ) - ) - { - return true; - } + GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" ); + if ( vendorModel.parse() ) { + vendorModel.printTable(); + return vendorModel.find( vendorId, modelId ); } @@ -239,7 +230,7 @@ { FFADODevice::showDevice(); - + debugOutput(DEBUG_LEVEL_NORMAL, - "%s %s\n", m_model->vendor_name, m_model->model_name); + "%s %s\n", m_model->vendor_name.c_str(), m_model->model_name.c_str()); AVC::Unit::show(); @@ -418,5 +409,5 @@ ); break; - + case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType: default: Index: trunk/libffado/src/genericavc/avc_vendormodel.cpp =================================================================== --- trunk/libffado/src/genericavc/avc_vendormodel.cpp (revision 558) +++ trunk/libffado/src/genericavc/avc_vendormodel.cpp (revision 599) @@ -28,4 +28,7 @@ #include #include +#include +#include +#include using namespace std; @@ -52,18 +55,63 @@ } +//------------------------------------------------- + +GenericAVC::VendorModelEntry::VendorModelEntry() + : vendor_id( 0 ) + , model_id( 0 ) +{ +} + +GenericAVC::VendorModelEntry::VendorModelEntry( const VendorModelEntry& rhs ) + : vendor_id( rhs.vendor_id ) + , model_id( rhs.model_id ) + , vendor_name( rhs.vendor_name ) + , model_name( rhs.model_name ) +{ +} + +GenericAVC::VendorModelEntry& +GenericAVC::VendorModelEntry::operator = ( const VendorModelEntry& rhs ) +{ + // check for assignment to self + if ( this == &rhs ) return *this; + + vendor_id = rhs.vendor_id; + model_id = rhs.model_id; + vendor_name = rhs.vendor_name; + model_name = rhs.model_name; + + return *this; +} + +GenericAVC::VendorModelEntry::~VendorModelEntry() +{ +} + GenericAVC::VendorModel::VendorModel( const char* filename ) -{ - ifstream in ( filename ); + : m_filename( filename ) +{ +} + +GenericAVC::VendorModel::~VendorModel() +{ +} + + +bool +GenericAVC::VendorModel::parse() +{ + ifstream in ( m_filename.c_str() ); if ( !in ) { - perror( filename ); - return; - } - - cout << "vendorId\t\tmodelId\t\tvendorName\t\tmodelName" << endl; + perror( m_filename.c_str() ); + return false; + } + string line; while ( !getline( in, line ).eof() ) { string::size_type i = line.find_first_not_of( " \t\n\v" ); if ( i != string::npos && line[i] == '#' ) + // this line starts with a '#' -> comment continue; @@ -71,29 +119,90 @@ tokenize( line, tokens, "," ); - for ( vector::iterator it = tokens.begin(); - it != tokens.end(); - ++it ) - { - string vendorId = *it++; - string modelId = *it++; - string vendorName = *it++; - string modelName= *it; - cout << vendorId << "\t" << modelId << "\t" <::const_iterator it = tokens.begin(); + char* tail; + + errno = 0; + vme.vendor_id = strtol( it++->c_str(), &tail, 0 ); + vme.model_id = strtol( it++->c_str(), &tail, 0 ); + vme.vendor_name = *it++; + vme.model_name = *it++; + + if ( errno ) + // string -> int conversion failed + continue; + + vector::const_iterator end = tokens.end(); + if ( it != end ) + handleAdditionalEntries( vme, tokens, it, end ); + + m_vendorModelEntries.push_back( vme ); } if ( !in.eof() ) { - cout << "GenericAVC::VendorModel::VendorModel: error in parsing" << endl; - } -} - -GenericAVC::VendorModel::~VendorModel() -{ - for ( VendorModelEntryVector::iterator it = m_vendorModelEntries.begin(); + cerr << "GenericAVC::VendorModel::VendorModel: error in parsing" << endl; + return false; + } + + return true; +} + +bool +GenericAVC::VendorModel::printTable() const +{ + // Some debug output + cout << "vendorId\t\tmodelId\t\tvendorName\t\t\t\tmodelName" << endl; + for ( VendorModelEntryVector::const_iterator it = m_vendorModelEntries.begin(); it != m_vendorModelEntries.end(); ++it ) { - delete *it; - } + cout << it->vendor_id << "\t\t\t" + << it->model_id << "\t" + << it->vendor_name << "\t" + << it->model_name << endl; + } + return true; +} + +bool +GenericAVC::VendorModel::handleAdditionalEntries(VendorModelEntry& vme, + vector& v, + vector::const_iterator& b, + vector::const_iterator& e ) +{ + return true; +} + +class is_same : public unary_function { +public: + is_same( unsigned int vendor_id, unsigned model_id ) + : m_vendor_id( vendor_id ) + , m_model_id( model_id ) + {} + + bool operator () ( const GenericAVC::VendorModelEntry& vme ) const { + return vme.vendor_id == m_vendor_id && vme.model_id == m_model_id; + } + +private: + unsigned int m_vendor_id; + unsigned int m_model_id; +}; + +GenericAVC::VendorModelEntry* +GenericAVC::VendorModel::find( unsigned int vendor_id, unsigned model_id ) +{ + VendorModelEntryVector::iterator it = + find_if ( m_vendorModelEntries.begin(), + m_vendorModelEntries.end(), + is_same( vendor_id, model_id ) ); + if ( it != m_vendorModelEntries.end() ) + return &*it; + + return 0; } Index: trunk/libffado/src/genericavc/avc_vendormodel.h =================================================================== --- trunk/libffado/src/genericavc/avc_vendormodel.h (revision 557) +++ trunk/libffado/src/genericavc/avc_vendormodel.h (revision 599) @@ -25,4 +25,5 @@ #define GENERICAVC_VENDORMODEL_H +#include #include @@ -31,19 +32,33 @@ // struct to define the supported devices struct VendorModelEntry { + VendorModelEntry(); + VendorModelEntry(const VendorModelEntry& rhs); + VendorModelEntry& operator = (const VendorModelEntry& rhs); + virtual ~VendorModelEntry(); + unsigned int vendor_id; unsigned int model_id; - char *vendor_name; - char *model_name; + std::string vendor_name; + std::string model_name; }; -typedef std::vector VendorModelEntryVector; +typedef std::vector VendorModelEntryVector; class VendorModel { public: VendorModel( const char* filename ); - ~VendorModel(); + virtual ~VendorModel(); + + virtual bool parse(); + virtual bool printTable() const; + virtual bool handleAdditionalEntries(VendorModelEntry& vme, + std::vector& v, + std::vector::const_iterator& b, + std::vector::const_iterator& e ); + VendorModelEntry* find( unsigned int vendor_id, unsigned model_id ); const VendorModelEntryVector& getVendorModelEntries() const; private: + std::string m_filename; VendorModelEntryVector m_vendorModelEntries; }; Index: trunk/libffado/src/bebob/bebob_avdevice.cpp =================================================================== --- trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 587) +++ trunk/libffado/src/bebob/bebob_avdevice.cpp (revision 599) @@ -54,32 +54,4 @@ namespace BeBoB { -static GenericAVC::VendorModelEntry supportedDeviceList[] = -{ - {FW_VENDORID_MACKIE, 0x00010065, "Mackie", "Onyx Firewire"}, - - {FW_VENDORID_APOGEE, 0x00010048, "Apogee Electronics", "Rosetta 200"}, - - {FW_VENDORID_BRIDGECO, 0x00010048, "BridgeCo", "RD Audio1"}, - - {FW_VENDORID_PRESONUS, 0x00010000, "PreSonus", "FIREBOX"}, - {FW_VENDORID_PRESONUS, 0x00010066, "PreSonus", "FirePOD"}, - - {FW_VENDORID_TERRATEC, 0x00000003, "TerraTec Electronic GmbH", "Phase 88 FW"}, - {FW_VENDORID_TERRATEC, 0x00000004, "TerraTec Electronic GmbH", "Phase X24 FW (model version 4)"}, - {FW_VENDORID_TERRATEC, 0x00000007, "TerraTec Electronic GmbH", "Phase X24 FW (model version 7)"}, - - {FW_VENDORID_ESI, 0x00010064, "ESI", "Quatafire 610"}, - - {FW_VENDORID_FOCUSRITE, 0x00000000, "Focusrite", "Saffire (LE)"}, - {FW_VENDORID_FOCUSRITE, 0x00000003, "Focusrite", "Saffire Pro26IO"}, - {FW_VENDORID_FOCUSRITE, 0x00000006, "Focusrite", "Saffire Pro10IO"}, - - {FW_VENDORID_EDIROL, 0x00010048, "EDIROL", "FA-101"}, - {FW_VENDORID_EDIROL, 0x00010049, "EDIROL", "FA-66"}, - - {FW_VENDORID_MAUDIO, 0x00010062, "M-Audio", "FW Solo"}, - {FW_VENDORID_MAUDIO, 0x00010081, "M-Audio", "NRV10"}, -}; - AvDevice::AvDevice( Ieee1394Service& ieee1394service, std::auto_ptr< ConfigRom >( configRom ) ) @@ -104,16 +76,10 @@ unsigned int modelId = configRom.getModelId(); - //GenericAVC::VendorModel vendorModel( "/home/wagi/src/libffado/src/bebob/ffado_driver_bebob.txt" ); - - for ( unsigned int i = 0; - i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); - ++i ) - { - if ( ( supportedDeviceList[i].vendor_id == vendorId ) - && ( supportedDeviceList[i].model_id == modelId ) ) - { - return true; - } - } + GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); + if ( vendorModel.parse() ) { + vendorModel.printTable(); + return vendorModel.find( vendorId, modelId ); + } + return false; } @@ -126,5 +92,5 @@ unsigned int modelId = configRom->getModelId(); return new Focusrite::SaffireProDevice(ieee1394Service, configRom); - + switch (vendorId) { case FW_VENDORID_TERRATEC: @@ -150,20 +116,13 @@ unsigned int modelId = m_pConfigRom->getModelId(); - for ( unsigned int i = 0; - i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); - ++i ) - { - if ( ( supportedDeviceList[i].vendor_id == vendorId ) - && ( supportedDeviceList[i].model_id == modelId ) - ) - { - m_model = &(supportedDeviceList[i]); - break; - } + GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); + if ( vendorModel.parse() ) { + m_model = vendorModel.find( vendorId, modelId ); } if (m_model != NULL) { debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", - m_model->vendor_name, m_model->model_name); + m_model->vendor_name.c_str(), + m_model->model_name.c_str()); } else return false; Index: trunk/libffado/src/bebob/ffado_driver_bebob.txt =================================================================== --- trunk/libffado/src/bebob/ffado_driver_bebob.txt (revision 599) +++ trunk/libffado/src/bebob/ffado_driver_bebob.txt (revision 599) @@ -0,0 +1,17 @@ +# Vendor ID Model ID Vendor Name Model Name +0x00000f, 0x00010065, "Mackie" ,"Onyx Firewire" +0x0003db, 0x00010048, "Apogee Electronics" ,"Rosetta 200" +0x0007f5, 0x00010048, "BridgeCo" ,"RD Audio1" +0x0007f5, 0x00010049, "BridgeCo" ,"Audio 5" +0x000a92, 0x00010000, "PreSonus" ,"FIREBOX" +0x000a92, 0x00010066, "PreSonus" ,"FirePOD" +0x000aac, 0x00000003, "TerraTec Electronic GmbH" ,"Phase 88 FW" +0x000aac, 0x00000004, "TerraTec Electronic GmbH" ,"Phase X24 FW (model version 4)" +0x000aac, 0x00000007, "TerraTec Electronic GmbH" ,"Phase X24 FW (model version 7)" +0x000f1b, 0x00010064, "ESI" ,"Quatafire 610" +0x00130e, 0x00000003, "Focusrite" ,"Saffire Pro26IO" +0x00130e, 0x00000006, "Focusrite" ,"Saffire Pro10IO" +0x0040ab, 0x00010048, "EDIROL" ,"FA-101" +0x0040ab, 0x00010049, "EDIROL" ,"FA-66" +0x000d6c, 0x00010062, "M-Audio" ,"FW Solo" +0x000d6c, 0x00010081, "M-Audio" ,"NRV10" Index: trunk/libffado/src/fireworks/ffado_driver_fireworks.txt =================================================================== --- trunk/libffado/src/fireworks/ffado_driver_fireworks.txt (revision 599) +++ trunk/libffado/src/fireworks/ffado_driver_fireworks.txt (revision 599) @@ -0,0 +1,1 @@ +0x001486, 0x00000af2, "Echo", "AudioFire2" Index: trunk/libffado/src/fireworks/fireworks_device.cpp =================================================================== --- trunk/libffado/src/fireworks/fireworks_device.cpp (revision 589) +++ trunk/libffado/src/fireworks/fireworks_device.cpp (revision 599) @@ -29,12 +29,8 @@ #include "libieee1394/ieee1394service.h" +#include "config.h" + // FireWorks is the platform used and developed by ECHO AUDIO namespace FireWorks { - -// to define the supported devices -static GenericAVC::VendorModelEntry supportedDeviceList[] = -{ - {FW_VENDORID_ECHO, 0x00000af2, "Echo", "AudioFire2"}, -}; Device::Device( Ieee1394Service& ieee1394Service, @@ -64,14 +60,8 @@ unsigned int modelId = configRom.getModelId(); - for ( unsigned int i = 0; - i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); - ++i ) - { - if ( ( supportedDeviceList[i].vendor_id == vendorId ) - && ( supportedDeviceList[i].model_id == modelId ) - ) - { - return true; - } + GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" ); + if ( vendorModel.parse() ) { + vendorModel.printTable(); + return vendorModel.find( vendorId, modelId ); } @@ -85,14 +75,7 @@ unsigned int modelId = m_pConfigRom->getModelId(); - for ( unsigned int i = 0; - i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); - ++i ) - { - if ( ( supportedDeviceList[i].vendor_id == vendorId ) - && ( supportedDeviceList[i].model_id == modelId ) - ) - { - m_model = &(supportedDeviceList[i]); - } + GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); + if ( vendorModel.parse() ) { + m_model = vendorModel.find( vendorId, modelId ); } @@ -101,5 +84,5 @@ } debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", - m_model->vendor_name, m_model->model_name); + m_model->vendor_name.c_str(), m_model->model_name.c_str()); if ( !GenericAVC::AvDevice::discover() ) { @@ -117,5 +100,5 @@ unsigned int vendorId = configRom->getNodeVendorId(); unsigned int modelId = configRom->getModelId(); - + switch(vendorId) { case FW_VENDORID_ECHO: return new ECHO::AudioFire(ieee1394Service, configRom );