Show
Ignore:
Timestamp:
04/25/09 10:14:57 (3 years ago)
Author:
ppalmers
Message:

- Clean up class names
- Change probe code for all devices (except MOTU) to use the config file based approach

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/bounce/bounce_avdevice.cpp

    r1239 r1543  
    2828#include "libieee1394/ieee1394service.h" 
    2929 
    30 #include "libavc/general/avc_plug_info.h" 
    31 #include "libavc/general/avc_extended_plug_info.h" 
    32 #include "libavc/general/avc_subunit_info.h" 
    33 #include "libavc/streamformat/avc_extended_stream_format.h" 
    34 #include "libutil/cmd_serialize.h" 
    35 #include "libavc/avc_definitions.h" 
     30#include "libutil/Configuration.h" 
    3631 
    3732#include "debugmodule/debugmodule.h" 
     33 
     34#include "devicemanager.h" 
    3835 
    3936#include <iostream> 
     
    4643namespace Bounce { 
    4744 
    48 // to define the supported devices 
    49 static VendorModelEntry supportedDeviceList[] = 
    50 
    51     {FW_VENDORID_FFADO, 0x0B0001LU, 0x0B0001LU, "FFADO", "Bounce"}, 
    52 }; 
    53  
    54 BounceDevice::BounceDevice( Ieee1394Service& ieee1394Service, 
    55                             std::auto_ptr<ConfigRom>( configRom )) 
    56     : FFADODevice( ieee1394Service, configRom ) 
     45Device::Device( DeviceManager& d, std::auto_ptr< ConfigRom >( configRom ) ) 
     46    : FFADODevice( d, configRom ) 
    5747    , m_samplerate (44100) 
    58     , m_model( NULL ) 
    5948    , m_Notifier ( NULL ) 
    6049{ 
    61     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Bounce::BounceDevice (NodeID %d)\n", 
     50    debugOutput( DEBUG_LEVEL_VERBOSE, "Created Bounce::Device (NodeID %d)\n", 
    6251                 getConfigRom().getNodeId() ); 
    6352    addOption(Util::OptionContainer::Option("snoopMode",false)); 
    6453} 
    6554 
    66 BounceDevice::~BounceDevice() 
    67 
    68  
    69 
    70  
    71 bool 
    72 BounceDevice::probe( ConfigRom& configRom, bool generic ) 
    73 
    74     if (generic) return false; 
    75  
    76     debugOutput( DEBUG_LEVEL_VERBOSE, "probing BounceDevice\n"); 
    77 //     unsigned int vendorId = configRom.getNodeVendorId(); 
    78     unsigned int modelId = configRom.getModelId(); 
    79     unsigned int unitSpecifierId = configRom.getUnitSpecifierId(); 
    80     debugOutput( DEBUG_LEVEL_VERBOSE, "modelId = 0x%08X, specid = 0x%08X\n", modelId, unitSpecifierId); 
    81  
    82     for ( unsigned int i = 0; 
    83           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 
    84           ++i ) 
    85     { 
    86         if ( 
    87 //             ( supportedDeviceList[i].vendor_id == vendorId ) 
    88              ( supportedDeviceList[i].model_id == modelId ) 
    89              && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 
    90            ) 
    91         { 
    92             return true; 
    93         } 
    94     } 
    95  
     55Device::~Device() 
     56
     57 
     58
     59 
     60bool 
     61Device::probe( Util::Configuration& c, ConfigRom& configRom, bool generic ) 
     62
     63    if(generic) { 
     64        return false; 
     65    } else { 
     66        // check if device is in supported devices list 
     67        unsigned int vendorId = configRom.getNodeVendorId(); 
     68        unsigned int modelId = configRom.getModelId(); 
     69 
     70        Util::Configuration::VendorModelEntry vme = c.findDeviceVME( vendorId, modelId ); 
     71        return c.isValid(vme) && vme.driver == Util::Configuration::eD_Bounce; 
     72    } 
    9673    return false; 
    9774} 
    9875 
    9976FFADODevice * 
    100 BounceDevice::createDevice( Ieee1394Service& ieee1394Service, 
    101                             std::auto_ptr<ConfigRom>( configRom )) 
    102 
    103     return new BounceDevice(ieee1394Service, configRom ); 
    104 
    105  
    106 bool 
    107 BounceDevice::discover() 
    108 
    109     debugOutput( DEBUG_LEVEL_VERBOSE, "discovering BounceDevice (NodeID %d)\n", 
     77Device::createDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 
     78
     79    return new Device(d, configRom ); 
     80
     81 
     82bool 
     83Device::discover() 
     84
     85    debugOutput( DEBUG_LEVEL_VERBOSE, "discovering Device (NodeID %d)\n", 
    11086                 getNodeId() ); 
    11187 
    112 //     unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
    113     unsigned int modelId = m_pConfigRom->getModelId(); 
    114     unsigned int unitSpecifierId = m_pConfigRom->getUnitSpecifierId(); 
    115  
    116     for ( unsigned int i = 0; 
    117           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); 
    118           ++i ) 
    119     { 
    120         if ( //( supportedDeviceList[i].vendor_id == vendorId ) 
    121              ( supportedDeviceList[i].model_id == modelId ) 
    122              && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 
    123            ) 
    124         { 
    125             m_model = &(supportedDeviceList[i]); 
    126         } 
    127     } 
    128  
    129     if (m_model != NULL) { 
     88    unsigned int vendorId = getConfigRom().getNodeVendorId(); 
     89    unsigned int modelId = getConfigRom().getModelId(); 
     90 
     91    Util::Configuration &c = getDeviceManager().getConfiguration(); 
     92    Util::Configuration::VendorModelEntry vme = c.findDeviceVME( vendorId, modelId ); 
     93 
     94    if (c.isValid(vme) && vme.driver == Util::Configuration::eD_Bounce) { 
    13095        debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
    131                 m_model->vendor_name, m_model->model_name); 
    132         return true; 
    133     } 
    134     return false; 
    135 
    136  
    137 int BounceDevice::getSamplingFrequency( ) { 
     96                     vme.vendor_name.c_str(), 
     97                     vme.model_name.c_str()); 
     98    } else { 
     99        debugWarning("Using generic Bounce support for unsupported device '%s %s'\n", 
     100                     getConfigRom().getVendorName().c_str(), getConfigRom().getModelName().c_str()); 
     101    } 
     102    return true; 
     103
     104 
     105int Device::getSamplingFrequency( ) { 
    138106    return m_samplerate; 
    139107} 
    140108 
    141 bool BounceDevice::setSamplingFrequency( int s ) { 
     109bool Device::setSamplingFrequency( int s ) { 
    142110    if (s) { 
    143111        m_samplerate=s; 
     
    147115 
    148116FFADODevice::ClockSourceVector 
    149 BounceDevice::getSupportedClockSources() { 
     117Device::getSupportedClockSources() { 
    150118    FFADODevice::ClockSourceVector r; 
    151119    return r; 
     
    153121 
    154122bool 
    155 BounceDevice::setActiveClockSource(ClockSource s) { 
     123Device::setActiveClockSource(ClockSource s) { 
    156124    return false; 
    157125} 
    158126 
    159127FFADODevice::ClockSource 
    160 BounceDevice::getActiveClockSource() { 
     128Device::getActiveClockSource() { 
    161129    ClockSource s; 
    162130    return s; 
    163131} 
    164132 
    165 int BounceDevice::getConfigurationId( ) { 
    166     return 0; 
    167 
    168  
    169  
    170 bool 
    171 BounceDevice::lock() { 
    172  
    173     return true; 
    174 
    175  
    176  
    177 bool 
    178 BounceDevice::unlock() { 
     133std::vector<int> 
     134Device::getSupportedSamplingFrequencies() 
     135
     136    std::vector<int> frequencies; 
     137    return frequencies; 
     138
     139 
     140 
     141bool 
     142Device::lock() { 
     143 
     144    return true; 
     145
     146 
     147 
     148bool 
     149Device::unlock() { 
    179150 
    180151    return true; 
     
    182153 
    183154void 
    184 BounceDevice::showDevice() 
    185 
     155Device::showDevice() 
     156
     157 
    186158    debugOutput(DEBUG_LEVEL_NORMAL, "\nI am the bouncedevice, the bouncedevice I am...\n" ); 
    187     debugOutput(DEBUG_LEVEL_NORMAL, "Vendor            :  %s\n", m_pConfigRom->getVendorName().c_str()); 
    188     debugOutput(DEBUG_LEVEL_NORMAL, "Model             :  %s\n", m_pConfigRom->getModelName().c_str()); 
    189     debugOutput(DEBUG_LEVEL_NORMAL, "Vendor Name       :  %s\n", m_model->vendor_name); 
    190     debugOutput(DEBUG_LEVEL_NORMAL, "Model Name        :  %s\n", m_model->model_name); 
     159    debugOutput(DEBUG_LEVEL_NORMAL, "Vendor            :  %s\n", getConfigRom().getVendorName().c_str()); 
     160    debugOutput(DEBUG_LEVEL_NORMAL, "Model             :  %s\n", getConfigRom().getModelName().c_str()); 
    191161    debugOutput(DEBUG_LEVEL_NORMAL, "Node              :  %d\n", getNodeId()); 
    192     debugOutput(DEBUG_LEVEL_NORMAL, "GUID              :  0x%016llX\n", m_pConfigRom->getGuid()); 
     162    debugOutput(DEBUG_LEVEL_NORMAL, "GUID              :  0x%016llX\n", getConfigRom().getGuid()); 
    193163    debugOutput(DEBUG_LEVEL_NORMAL, "\n" ); 
    194164} 
    195165 
    196166bool 
    197 BounceDevice::addPortsToProcessor( 
     167Device::addPortsToProcessor( 
    198168    Streaming::StreamProcessor *processor, 
    199169    Streaming::Port::E_Direction direction) { 
     
    257227 
    258228bool 
    259 BounceDevice::prepare() { 
    260     debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceDevice...\n" ); 
     229Device::prepare() { 
     230    debugOutput(DEBUG_LEVEL_NORMAL, "Preparing Device...\n" ); 
    261231 
    262232    bool snoopMode=false; 
     
    268238    Streaming::StreamProcessor *p; 
    269239 
    270     p=new Streaming::AmdtpReceiveStreamProcessor( 
    271                              m_p1394Service->getPort(), 
    272                              m_samplerate, 
     240    p=new Streaming::AmdtpReceiveStreamProcessor(*this, 
    273241                             BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 
    274242 
     
    291259    if (snoopMode) { 
    292260        // we are snooping, so this is receive too. 
    293         p=new Streaming::AmdtpReceiveStreamProcessor( 
    294                                 m_p1394Service->getPort(), 
    295                                 m_samplerate, 
     261        p=new Streaming::AmdtpReceiveStreamProcessor(*this, 
    296262                                BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 
    297263    } else { 
    298         p=new Streaming::AmdtpTransmitStreamProcessor( 
    299                                 m_p1394Service->getPort(), 
    300                                 m_samplerate, 
     264        p=new Streaming::AmdtpTransmitStreamProcessor(*this, 
    301265                                BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 
    302266    } 
     
    331295 
    332296int 
    333 BounceDevice::getStreamCount() { 
     297Device::getStreamCount() { 
    334298    return m_receiveProcessors.size() + m_transmitProcessors.size(); 
    335299} 
    336300 
    337301Streaming::StreamProcessor * 
    338 BounceDevice::getStreamProcessorByIndex(int i) { 
     302Device::getStreamProcessorByIndex(int i) { 
    339303    if (i<(int)m_receiveProcessors.size()) { 
    340304        return m_receiveProcessors.at(i); 
     
    347311 
    348312bool 
    349 BounceDevice::startStreamByIndex(int i) { 
     313Device::startStreamByIndex(int i) { 
    350314    if (i<(int)m_receiveProcessors.size()) { 
    351315        int n=i; 
     
    431395 
    432396bool 
    433 BounceDevice::stopStreamByIndex(int i) { 
     397Device::stopStreamByIndex(int i) { 
    434398    if (i<(int)m_receiveProcessors.size()) { 
    435399        int n=i; 
     
    505469 
    506470// allocate ISO resources for the SP's 
    507 int BounceDevice::allocateIsoChannel(unsigned int packet_size) { 
     471int Device::allocateIsoChannel(unsigned int packet_size) { 
    508472    unsigned int bandwidth=8+packet_size; 
    509473 
    510     int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 
     474    int ch=get1394Service().allocateIsoChannelGeneric(bandwidth); 
    511475 
    512476    debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 
     
    516480} 
    517481// deallocate ISO resources 
    518 bool BounceDevice::deallocateIsoChannel(int channel) { 
     482bool Device::deallocateIsoChannel(int channel) { 
    519483    debugOutput(DEBUG_LEVEL_VERBOSE, "freeing channel %d\n",channel); 
    520     return m_p1394Service->freeIsoChannel(channel); 
     484    return get1394Service().freeIsoChannel(channel); 
    521485} 
    522486 
     
    524488 
    525489bool 
    526 BounceDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 
     490Device::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 
    527491    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 
    528492 
     
    535499    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
    536500 
    537     if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 
     501    if(!get1394Service().read_quadlet( nodeId, addr, result ) ) { 
    538502        debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); 
    539503        return false; 
     
    545509 
    546510bool 
    547 BounceDevice::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 
     511Device::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 
    548512    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 
    549513        offset, data); 
     
    557521    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
    558522 
    559     if(!m_p1394Service->write_quadlet( nodeId, addr, data ) ) { 
     523    if(!get1394Service().write_quadlet( nodeId, addr, data ) ) { 
    560524        debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 
    561525        return false; 
     
    565529 
    566530bool 
    567 BounceDevice::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     531Device::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
    568532    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 
    569533        offset, length); 
     
    577541    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
    578542 
    579     if(!m_p1394Service->read( nodeId, addr, length, data ) ) { 
     543    if(!get1394Service().read( nodeId, addr, length, data ) ) { 
    580544        debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 
    581545        return false; 
     
    585549 
    586550bool 
    587 BounceDevice::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     551Device::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
    588552    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 
    589553        offset, length); 
     
    597561    fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 
    598562 
    599     if(!m_p1394Service->write( nodeId, addr, length, data ) ) { 
     563    if(!get1394Service().write( nodeId, addr, length, data ) ) { 
    600564        debugError("Could not write to node 0x%04X addr 0x%012llX\n", nodeId, addr); 
    601565        return false;