Changeset 599 for trunk/libffado

Show
Ignore:
Timestamp:
08/29/07 14:17:58 (16 years ago)
Author:
wagi
Message:

Instead of static compiled in vendor/model table use configuration files.

Maybe needs some more cleanup but I wanted to check in this baby before
someone else screws me up with some majors changes in the repos :)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/config.h.in

    r598 r599  
    2727#define CACHEDIR "$cachedir" 
    2828 
     29#define SHAREDIR "$sharedir" 
  • trunk/libffado/src/bebob/bebob_avdevice.cpp

    r587 r599  
    5454namespace BeBoB { 
    5555 
    56 static GenericAVC::VendorModelEntry supportedDeviceList[] = 
    57 { 
    58     {FW_VENDORID_MACKIE, 0x00010065, "Mackie", "Onyx Firewire"}, 
    59  
    60     {FW_VENDORID_APOGEE, 0x00010048, "Apogee Electronics", "Rosetta 200"}, 
    61  
    62     {FW_VENDORID_BRIDGECO, 0x00010048, "BridgeCo", "RD Audio1"}, 
    63  
    64     {FW_VENDORID_PRESONUS, 0x00010000, "PreSonus", "FIREBOX"}, 
    65     {FW_VENDORID_PRESONUS, 0x00010066, "PreSonus", "FirePOD"}, 
    66  
    67     {FW_VENDORID_TERRATEC, 0x00000003, "TerraTec Electronic GmbH", "Phase 88 FW"}, 
    68     {FW_VENDORID_TERRATEC, 0x00000004, "TerraTec Electronic GmbH", "Phase X24 FW (model version 4)"}, 
    69     {FW_VENDORID_TERRATEC, 0x00000007, "TerraTec Electronic GmbH", "Phase X24 FW (model version 7)"}, 
    70  
    71     {FW_VENDORID_ESI, 0x00010064, "ESI", "Quatafire 610"}, 
    72  
    73     {FW_VENDORID_FOCUSRITE, 0x00000000, "Focusrite", "Saffire (LE)"}, 
    74     {FW_VENDORID_FOCUSRITE, 0x00000003, "Focusrite", "Saffire Pro26IO"}, 
    75     {FW_VENDORID_FOCUSRITE, 0x00000006, "Focusrite", "Saffire Pro10IO"}, 
    76  
    77     {FW_VENDORID_EDIROL, 0x00010048, "EDIROL", "FA-101"}, 
    78     {FW_VENDORID_EDIROL, 0x00010049, "EDIROL", "FA-66"}, 
    79  
    80     {FW_VENDORID_MAUDIO, 0x00010062, "M-Audio", "FW Solo"}, 
    81     {FW_VENDORID_MAUDIO, 0x00010081, "M-Audio", "NRV10"}, 
    82 }; 
    83  
    8456AvDevice::AvDevice( Ieee1394Service& ieee1394service, 
    8557                    std::auto_ptr< ConfigRom >( configRom ) ) 
     
    10476    unsigned int modelId = configRom.getModelId(); 
    10577 
    106     //GenericAVC::VendorModel vendorModel( "/home/wagi/src/libffado/src/bebob/ffado_driver_bebob.txt" ); 
    107  
    108     for ( unsigned int i = 0; 
    109           i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 
    110           ++i ) 
    111     { 
    112         if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    113              && ( supportedDeviceList[i].model_id == modelId ) ) 
    114         { 
    115             return true; 
    116         } 
    117     } 
     78    GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); 
     79    if ( vendorModel.parse() ) { 
     80        vendorModel.printTable(); 
     81        return vendorModel.find( vendorId, modelId ); 
     82    } 
     83 
    11884    return false; 
    11985} 
     
    12692    unsigned int modelId = configRom->getModelId(); 
    12793                    return new Focusrite::SaffireProDevice(ieee1394Service, configRom); 
    128      
     94 
    12995    switch (vendorId) { 
    13096        case FW_VENDORID_TERRATEC: 
     
    150116    unsigned int modelId = m_pConfigRom->getModelId(); 
    151117 
    152     for ( unsigned int i = 0; 
    153           i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 
    154           ++i ) 
    155     { 
    156         if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    157              && ( supportedDeviceList[i].model_id == modelId ) 
    158            ) 
    159         { 
    160             m_model = &(supportedDeviceList[i]); 
    161             break; 
    162         } 
     118    GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); 
     119    if ( vendorModel.parse() ) { 
     120        m_model = vendorModel.find( vendorId, modelId ); 
    163121    } 
    164122 
    165123    if (m_model != NULL) { 
    166124        debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
    167                 m_model->vendor_name, m_model->model_name); 
     125                     m_model->vendor_name.c_str(), 
     126                     m_model->model_name.c_str()); 
    168127    } else return false; 
    169128 
  • trunk/libffado/src/fireworks/fireworks_device.cpp

    r589 r599  
    2929#include "libieee1394/ieee1394service.h" 
    3030 
     31#include "config.h" 
     32 
    3133// FireWorks is the platform used and developed by ECHO AUDIO 
    3234namespace FireWorks { 
    33  
    34 // to define the supported devices 
    35 static GenericAVC::VendorModelEntry supportedDeviceList[] = 
    36 { 
    37     {FW_VENDORID_ECHO, 0x00000af2, "Echo", "AudioFire2"}, 
    38 }; 
    3935 
    4036Device::Device( Ieee1394Service& ieee1394Service, 
     
    6460    unsigned int modelId = configRom.getModelId(); 
    6561 
    66     for ( unsigned int i = 0; 
    67           i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 
    68           ++i ) 
    69     { 
    70         if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    71              && ( supportedDeviceList[i].model_id == modelId ) 
    72            ) 
    73         { 
    74             return true; 
    75         } 
     62    GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" ); 
     63    if ( vendorModel.parse() ) { 
     64        vendorModel.printTable(); 
     65        return vendorModel.find( vendorId, modelId ); 
    7666    } 
    7767 
     
    8575    unsigned int modelId = m_pConfigRom->getModelId(); 
    8676 
    87     for ( unsigned int i = 0; 
    88           i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); 
    89           ++i ) 
    90     { 
    91         if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    92              && ( supportedDeviceList[i].model_id == modelId ) 
    93            ) 
    94         { 
    95             m_model = &(supportedDeviceList[i]); 
    96         } 
     77    GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_bebob.txt" ); 
     78    if ( vendorModel.parse() ) { 
     79        m_model = vendorModel.find( vendorId, modelId ); 
    9780    } 
    9881 
     
    10184    } 
    10285    debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
    103             m_model->vendor_name, m_model->model_name); 
     86            m_model->vendor_name.c_str(), m_model->model_name.c_str()); 
    10487 
    10588    if ( !GenericAVC::AvDevice::discover() ) { 
     
    117100    unsigned int vendorId = configRom->getNodeVendorId(); 
    118101    unsigned int modelId = configRom->getModelId(); 
    119      
     102 
    120103    switch(vendorId) { 
    121104        case FW_VENDORID_ECHO: return new ECHO::AudioFire(ieee1394Service, configRom ); 
  • trunk/libffado/src/genericavc/avc_avdevice.cpp

    r589 r599  
    3535#include "debugmodule/debugmodule.h" 
    3636 
     37#include "config.h" 
     38 
    3739#include <string> 
    3840#include <stdint.h> 
     
    5052IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_VERBOSE ); 
    5153 
    52 // to define the supported devices 
    53 static VendorModelEntry supportedDeviceList[] = 
    54 { 
    55  
    56 }; 
    5754 
    5855AvDevice::AvDevice( Ieee1394Service& ieee1394Service, 
     
    7875    unsigned int modelId = configRom.getModelId(); 
    7976 
    80     for ( unsigned int i = 0; 
    81           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 
    82           ++i ) 
    83     { 
    84         if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    85              && ( supportedDeviceList[i].model_id == modelId ) 
    86            ) 
    87         { 
    88             return true; 
    89         } 
     77    GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" ); 
     78    if ( vendorModel.parse() ) { 
     79        vendorModel.printTable(); 
     80        return vendorModel.find( vendorId, modelId ); 
    9081    } 
    9182 
     
    239230{ 
    240231    FFADODevice::showDevice(); 
    241      
     232 
    242233    debugOutput(DEBUG_LEVEL_NORMAL, 
    243         "%s %s\n", m_model->vendor_name, m_model->model_name); 
     234        "%s %s\n", m_model->vendor_name.c_str(), m_model->model_name.c_str()); 
    244235 
    245236    AVC::Unit::show(); 
     
    418409                ); 
    419410                break; 
    420                  
     411 
    421412            case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType: 
    422413            default: 
  • trunk/libffado/src/genericavc/avc_vendormodel.cpp

    r558 r599  
    2828#include <iostream> 
    2929#include <iterator> 
     30#include <cerrno> 
     31#include <functional> 
     32#include <algorithm> 
    3033 
    3134using namespace std; 
     
    5255} 
    5356 
     57//------------------------------------------------- 
     58 
     59GenericAVC::VendorModelEntry::VendorModelEntry() 
     60    : vendor_id( 0 ) 
     61    , model_id( 0 ) 
     62{ 
     63} 
     64 
     65GenericAVC::VendorModelEntry::VendorModelEntry( const VendorModelEntry& rhs ) 
     66    : vendor_id( rhs.vendor_id ) 
     67    , model_id( rhs.model_id ) 
     68    , vendor_name( rhs.vendor_name ) 
     69    , model_name( rhs.model_name ) 
     70{ 
     71} 
     72 
     73GenericAVC::VendorModelEntry& 
     74GenericAVC::VendorModelEntry::operator = ( const VendorModelEntry& rhs ) 
     75{ 
     76    // check for assignment to self 
     77    if ( this == &rhs ) return *this; 
     78 
     79    vendor_id   = rhs.vendor_id; 
     80    model_id    = rhs.model_id; 
     81    vendor_name = rhs.vendor_name; 
     82    model_name  = rhs.model_name; 
     83 
     84    return *this; 
     85} 
     86 
     87GenericAVC::VendorModelEntry::~VendorModelEntry() 
     88{ 
     89} 
     90 
    5491GenericAVC::VendorModel::VendorModel( const char* filename ) 
    55 
    56     ifstream in ( filename ); 
     92    : m_filename( filename ) 
     93
     94
     95 
     96GenericAVC::VendorModel::~VendorModel() 
     97
     98
     99 
     100 
     101bool 
     102GenericAVC::VendorModel::parse() 
     103
     104    ifstream in ( m_filename.c_str() ); 
    57105 
    58106    if ( !in ) { 
    59         perror( filename ); 
    60         return; 
    61     } 
    62  
    63     cout << "vendorId\t\tmodelId\t\tvendorName\t\tmodelName" << endl; 
     107        perror( m_filename.c_str() ); 
     108        return false; 
     109    } 
     110 
    64111    string line; 
    65112    while ( !getline( in,  line ).eof() ) { 
    66113        string::size_type i = line.find_first_not_of( " \t\n\v" ); 
    67114        if ( i != string::npos && line[i] == '#' ) 
     115            // this line starts with a '#' -> comment 
    68116            continue; 
    69117 
     
    71119        tokenize( line, tokens, "," ); 
    72120 
    73         for ( vector<string>::iterator it = tokens.begin(); 
    74               it != tokens.end(); 
    75               ++it ) 
    76         { 
    77             string vendorId = *it++; 
    78             string modelId = *it++; 
    79             string vendorName = *it++; 
    80             string modelName= *it; 
    81             cout << vendorId << "\t" << modelId << "\t" <<vendorName << "\t" << modelName << endl; 
    82         } 
     121        if ( tokens.size() < 4 ) 
     122            // ignore this line, it has not all needed mandatory entries 
     123            continue; 
     124 
     125        VendorModelEntry vme; 
     126        vector<string>::const_iterator it = tokens.begin(); 
     127        char* tail; 
     128 
     129        errno = 0; 
     130        vme.vendor_id   = strtol( it++->c_str(), &tail, 0 ); 
     131        vme.model_id    = strtol( it++->c_str(), &tail, 0 ); 
     132        vme.vendor_name = *it++; 
     133        vme.model_name  = *it++; 
     134 
     135        if ( errno ) 
     136            // string -> int conversion failed 
     137            continue; 
     138 
     139        vector<string>::const_iterator end = tokens.end(); 
     140        if ( it != end ) 
     141            handleAdditionalEntries( vme, tokens, it, end ); 
     142 
     143        m_vendorModelEntries.push_back( vme ); 
    83144    } 
    84145 
    85146    if ( !in.eof() ) { 
    86         cout << "GenericAVC::VendorModel::VendorModel: error in parsing" << endl; 
    87     } 
    88 
    89  
    90 GenericAVC::VendorModel::~VendorModel() 
    91 
    92     for ( VendorModelEntryVector::iterator it = m_vendorModelEntries.begin(); 
     147        cerr << "GenericAVC::VendorModel::VendorModel: error in parsing" << endl; 
     148        return false; 
     149    } 
     150 
     151    return true; 
     152
     153 
     154bool 
     155GenericAVC::VendorModel::printTable() const 
     156
     157    // Some debug output 
     158    cout << "vendorId\t\tmodelId\t\tvendorName\t\t\t\tmodelName" << endl; 
     159    for ( VendorModelEntryVector::const_iterator it = m_vendorModelEntries.begin(); 
    93160          it != m_vendorModelEntries.end(); 
    94161          ++it ) 
    95162    { 
    96         delete *it; 
    97     } 
     163        cout << it->vendor_id << "\t\t\t" 
     164             << it->model_id << "\t" 
     165             << it->vendor_name << "\t" 
     166             << it->model_name << endl; 
     167    } 
     168    return true; 
     169
     170 
     171bool 
     172GenericAVC::VendorModel::handleAdditionalEntries(VendorModelEntry& vme, 
     173                                                 vector<string>& v, 
     174                                                 vector<string>::const_iterator& b, 
     175                                                 vector<string>::const_iterator& e ) 
     176
     177    return true; 
     178
     179 
     180class is_same : public unary_function<GenericAVC::VendorModelEntry, bool> { 
     181public: 
     182    is_same( unsigned int vendor_id, unsigned model_id ) 
     183        : m_vendor_id( vendor_id ) 
     184        , m_model_id( model_id ) 
     185    {} 
     186 
     187    bool operator () ( const GenericAVC::VendorModelEntry& vme ) const { 
     188        return vme.vendor_id == m_vendor_id && vme.model_id == m_model_id; 
     189    } 
     190 
     191private: 
     192    unsigned int m_vendor_id; 
     193    unsigned int m_model_id; 
     194}; 
     195 
     196GenericAVC::VendorModelEntry* 
     197GenericAVC::VendorModel::find( unsigned int vendor_id, unsigned model_id ) 
     198
     199    VendorModelEntryVector::iterator it = 
     200        find_if ( m_vendorModelEntries.begin(), 
     201                  m_vendorModelEntries.end(), 
     202                  is_same( vendor_id, model_id ) ); 
     203    if ( it != m_vendorModelEntries.end() ) 
     204        return &*it; 
     205 
     206    return 0; 
    98207} 
    99208 
  • trunk/libffado/src/genericavc/avc_vendormodel.h

    r557 r599  
    2525#define GENERICAVC_VENDORMODEL_H 
    2626 
     27#include <string> 
    2728#include <vector> 
    2829 
     
    3132// struct to define the supported devices 
    3233struct VendorModelEntry { 
     34    VendorModelEntry(); 
     35    VendorModelEntry(const VendorModelEntry& rhs); 
     36    VendorModelEntry& operator = (const VendorModelEntry& rhs); 
     37    virtual ~VendorModelEntry(); 
     38 
    3339    unsigned int vendor_id; 
    3440    unsigned int model_id; 
    35     char *vendor_name; 
    36     char *model_name; 
     41    std::string vendor_name; 
     42    std::string model_name; 
    3743}; 
    3844 
    39 typedef std::vector<VendorModelEntry*> VendorModelEntryVector; 
     45typedef std::vector<VendorModelEntry> VendorModelEntryVector; 
    4046 
    4147class VendorModel { 
    4248public: 
    4349    VendorModel( const char* filename ); 
    44     ~VendorModel(); 
     50    virtual ~VendorModel(); 
     51 
     52    virtual bool parse(); 
     53    virtual bool printTable() const; 
     54    virtual bool handleAdditionalEntries(VendorModelEntry& vme, 
     55                                         std::vector<std::string>& v, 
     56                                         std::vector<std::string>::const_iterator& b, 
     57                                         std::vector<std::string>::const_iterator& e ); 
     58    VendorModelEntry* find( unsigned int vendor_id,  unsigned model_id ); 
    4559 
    4660    const VendorModelEntryVector& getVendorModelEntries() const; 
    4761private: 
     62    std::string m_filename; 
    4863    VendorModelEntryVector m_vendorModelEntries; 
    4964}; 
  • trunk/libffado/src/SConscript

    r594 r599  
    9191        maudio/fw410.xml \ 
    9292        maudio/fwap.xml \ 
     93        bebob/ffado_driver_bebob.txt \ 
    9394' ) 
    9495 
     
    9899' ) 
    99100 
     101genericavc_pkgdata = env.Split( '\ 
     102        genericavc/ffado_driver_genericavc.txt \ 
     103' )      
     104 
    100105fireworks_source =  env.Split( '\ 
    101106        fireworks/fireworks_device.cpp \ 
    102107        fireworks/audiofire/audiofire_device.cpp \ 
     108' ) 
     109 
     110fireworks_pkgdata =  env.Split( '\ 
     111        fireworks/ffado_driver_fireworks.txt \ 
    103112' ) 
    104113 
     
    210219        libenv.Alias( "install", libenv.Install( "$sharedir", data ) ) 
    211220 
     221for data in genericavc_pkgdata: 
     222        libenv.Alias( "install", libenv.Install( "$sharedir", data ) ) 
     223 
     224for data in fireworks_pkgdata: 
     225        libenv.Alias( "install", libenv.Install( "$sharedir", data ) ) 
     226 
    212227# 
    213228# For the debugging apps