Changeset 1543 for trunk/libffado/src/bounce/bounce_avdevice.cpp
- Timestamp:
- 04/25/09 10:14:57 (3 years ago)
- Files:
-
- trunk/libffado/src/bounce/bounce_avdevice.cpp (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bounce/bounce_avdevice.cpp
r1239 r1543 28 28 #include "libieee1394/ieee1394service.h" 29 29 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" 36 31 37 32 #include "debugmodule/debugmodule.h" 33 34 #include "devicemanager.h" 38 35 39 36 #include <iostream> … … 46 43 namespace Bounce { 47 44 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 ) 45 Device::Device( DeviceManager& d, std::auto_ptr< ConfigRom >( configRom ) ) 46 : FFADODevice( d, configRom ) 57 47 , m_samplerate (44100) 58 , m_model( NULL )59 48 , m_Notifier ( NULL ) 60 49 { 61 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Bounce:: BounceDevice (NodeID %d)\n",50 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Bounce::Device (NodeID %d)\n", 62 51 getConfigRom().getNodeId() ); 63 52 addOption(Util::OptionContainer::Option("snoopMode",false)); 64 53 } 65 54 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 55 Device::~Device() 56 { 57 58 } 59 60 bool 61 Device::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 } 96 73 return false; 97 74 } 98 75 99 76 FFADODevice * 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", 77 Device::createDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 78 { 79 return new Device(d, configRom ); 80 } 81 82 bool 83 Device::discover() 84 { 85 debugOutput( DEBUG_LEVEL_VERBOSE, "discovering Device (NodeID %d)\n", 110 86 getNodeId() ); 111 87 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) { 130 95 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 105 int Device::getSamplingFrequency( ) { 138 106 return m_samplerate; 139 107 } 140 108 141 bool BounceDevice::setSamplingFrequency( int s ) {109 bool Device::setSamplingFrequency( int s ) { 142 110 if (s) { 143 111 m_samplerate=s; … … 147 115 148 116 FFADODevice::ClockSourceVector 149 BounceDevice::getSupportedClockSources() {117 Device::getSupportedClockSources() { 150 118 FFADODevice::ClockSourceVector r; 151 119 return r; … … 153 121 154 122 bool 155 BounceDevice::setActiveClockSource(ClockSource s) {123 Device::setActiveClockSource(ClockSource s) { 156 124 return false; 157 125 } 158 126 159 127 FFADODevice::ClockSource 160 BounceDevice::getActiveClockSource() {128 Device::getActiveClockSource() { 161 129 ClockSource s; 162 130 return s; 163 131 } 164 132 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() { 133 std::vector<int> 134 Device::getSupportedSamplingFrequencies() 135 { 136 std::vector<int> frequencies; 137 return frequencies; 138 } 139 140 141 bool 142 Device::lock() { 143 144 return true; 145 } 146 147 148 bool 149 Device::unlock() { 179 150 180 151 return true; … … 182 153 183 154 void 184 BounceDevice::showDevice() 185 { 155 Device::showDevice() 156 { 157 186 158 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()); 191 161 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()); 193 163 debugOutput(DEBUG_LEVEL_NORMAL, "\n" ); 194 164 } 195 165 196 166 bool 197 BounceDevice::addPortsToProcessor(167 Device::addPortsToProcessor( 198 168 Streaming::StreamProcessor *processor, 199 169 Streaming::Port::E_Direction direction) { … … 257 227 258 228 bool 259 BounceDevice::prepare() {260 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceDevice...\n" );229 Device::prepare() { 230 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing Device...\n" ); 261 231 262 232 bool snoopMode=false; … … 268 238 Streaming::StreamProcessor *p; 269 239 270 p=new Streaming::AmdtpReceiveStreamProcessor( 271 m_p1394Service->getPort(), 272 m_samplerate, 240 p=new Streaming::AmdtpReceiveStreamProcessor(*this, 273 241 BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 274 242 … … 291 259 if (snoopMode) { 292 260 // 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, 296 262 BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 297 263 } else { 298 p=new Streaming::AmdtpTransmitStreamProcessor( 299 m_p1394Service->getPort(), 300 m_samplerate, 264 p=new Streaming::AmdtpTransmitStreamProcessor(*this, 301 265 BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 302 266 } … … 331 295 332 296 int 333 BounceDevice::getStreamCount() {297 Device::getStreamCount() { 334 298 return m_receiveProcessors.size() + m_transmitProcessors.size(); 335 299 } 336 300 337 301 Streaming::StreamProcessor * 338 BounceDevice::getStreamProcessorByIndex(int i) {302 Device::getStreamProcessorByIndex(int i) { 339 303 if (i<(int)m_receiveProcessors.size()) { 340 304 return m_receiveProcessors.at(i); … … 347 311 348 312 bool 349 BounceDevice::startStreamByIndex(int i) {313 Device::startStreamByIndex(int i) { 350 314 if (i<(int)m_receiveProcessors.size()) { 351 315 int n=i; … … 431 395 432 396 bool 433 BounceDevice::stopStreamByIndex(int i) {397 Device::stopStreamByIndex(int i) { 434 398 if (i<(int)m_receiveProcessors.size()) { 435 399 int n=i; … … 505 469 506 470 // allocate ISO resources for the SP's 507 int BounceDevice::allocateIsoChannel(unsigned int packet_size) {471 int Device::allocateIsoChannel(unsigned int packet_size) { 508 472 unsigned int bandwidth=8+packet_size; 509 473 510 int ch= m_p1394Service->allocateIsoChannelGeneric(bandwidth);474 int ch=get1394Service().allocateIsoChannelGeneric(bandwidth); 511 475 512 476 debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", … … 516 480 } 517 481 // deallocate ISO resources 518 bool BounceDevice::deallocateIsoChannel(int channel) {482 bool Device::deallocateIsoChannel(int channel) { 519 483 debugOutput(DEBUG_LEVEL_VERBOSE, "freeing channel %d\n",channel); 520 return m_p1394Service->freeIsoChannel(channel);484 return get1394Service().freeIsoChannel(channel); 521 485 } 522 486 … … 524 488 525 489 bool 526 BounceDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) {490 Device::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 527 491 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 528 492 … … 535 499 fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 536 500 537 if(! m_p1394Service->read_quadlet( nodeId, addr, result ) ) {501 if(!get1394Service().read_quadlet( nodeId, addr, result ) ) { 538 502 debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); 539 503 return false; … … 545 509 546 510 bool 547 BounceDevice::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) {511 Device::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 548 512 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 549 513 offset, data); … … 557 521 fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 558 522 559 if(! m_p1394Service->write_quadlet( nodeId, addr, data ) ) {523 if(!get1394Service().write_quadlet( nodeId, addr, data ) ) { 560 524 debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 561 525 return false; … … 565 529 566 530 bool 567 BounceDevice::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) {531 Device::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 568 532 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 569 533 offset, length); … … 577 541 fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 578 542 579 if(! m_p1394Service->read( nodeId, addr, length, data ) ) {543 if(!get1394Service().read( nodeId, addr, length, data ) ) { 580 544 debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 581 545 return false; … … 585 549 586 550 bool 587 BounceDevice::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) {551 Device::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 588 552 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 589 553 offset, length); … … 597 561 fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 598 562 599 if(! m_p1394Service->write( nodeId, addr, length, data ) ) {563 if(!get1394Service().write( nodeId, addr, length, data ) ) { 600 564 debugError("Could not write to node 0x%04X addr 0x%012llX\n", nodeId, addr); 601 565 return false;
