- Timestamp:
- 09/07/09 04:41:57 (14 years ago)
- Files:
-
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (1 diff)
- trunk/libffado/src/libieee1394/ieee1394service.h (modified) (1 diff)
- trunk/libffado/src/rme/rme_avdevice.cpp (modified) (4 diffs)
- trunk/libffado/src/rme/rme_avdevice.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libieee1394/ieee1394service.cpp
r1550 r1660 1302 1302 1303 1303 /** 1304 * Allocates a specific fixed iso channel for use by the interface. Returns 1305 * -1 on error (due to the requested channel not being free) or the fixed iso 1306 * channel number. 1307 * 1308 * Does not perform anything other than registering the channel and the 1309 * bandwidth at the IRM 1310 * 1311 * Also allocates the necessary bandwidth (in ISO allocation units). 1312 * 1313 * FIXME: As in libiec61883, channel 63 is not requested; this is either a 1314 * bug or it's omitted since that's the channel preferred by video devices. 1315 * 1316 * @chan the channel number being requested 1317 * @param bandwidth the bandwidth to allocate for this channel 1318 * @return the channel number 1319 */ 1320 signed int Ieee1394Service::allocateFixedIsoChannelGeneric( 1321 unsigned int chan, unsigned int bandwidth 1322 ) { 1323 debugOutput(DEBUG_LEVEL_VERBOSE, "Allocating ISO channel %d using generic method...\n", chan ); 1324 1325 Util::MutexLockHelper lock(*m_handle_lock); 1326 struct ChannelInfo cinfo; 1327 1328 if (raw1394_channel_modify (m_handle, chan, RAW1394_MODIFY_ALLOC) == 0) { 1329 if (raw1394_bandwidth_modify(m_handle, bandwidth, RAW1394_MODIFY_ALLOC) < 0) { 1330 debugFatal("Could not allocate bandwidth of %d\n", bandwidth); 1331 1332 raw1394_channel_modify (m_handle, chan, RAW1394_MODIFY_FREE); 1333 return -1; 1334 } else { 1335 cinfo.channel=chan; 1336 cinfo.bandwidth=bandwidth; 1337 cinfo.alloctype=AllocGeneric; 1338 1339 cinfo.xmit_node=-1; 1340 cinfo.xmit_plug=-1; 1341 cinfo.recv_node=-1; 1342 cinfo.recv_plug=-1; 1343 1344 if (registerIsoChannel(chan, cinfo)) { 1345 return chan; 1346 } else { 1347 raw1394_bandwidth_modify(m_handle, bandwidth, RAW1394_MODIFY_FREE); 1348 raw1394_channel_modify (m_handle, chan, RAW1394_MODIFY_FREE); 1349 return -1; 1350 } 1351 } 1352 } 1353 return -1; 1354 } 1355 1356 /** 1304 1357 * Allocates an iso channel for use by the interface in a similar way to 1305 1358 * libiec61883. Returns -1 on error (due to there being no free channels) trunk/libffado/src/libieee1394/ieee1394service.h
r1568 r1660 360 360 signed int getAvailableBandwidth(); 361 361 signed int allocateIsoChannelGeneric(unsigned int bandwidth); 362 signed int allocateFixedIsoChannelGeneric( 363 unsigned int chan, unsigned int bandwidth); 362 364 signed int allocateIsoChannelCMP(nodeid_t xmit_node, int xmit_plug, 363 365 nodeid_t recv_node, int recv_plug); trunk/libffado/src/rme/rme_avdevice.cpp
r1657 r1660 85 85 , frames_per_packet( 0 ) 86 86 , speed800( 0 ) 87 , iso_tx_channel( -1 ) 88 , iso_rx_channel( -1 ) 87 89 , m_MixerContainer( NULL ) 88 90 , m_ControlContainer( NULL ) … … 94 96 Device::~Device() 95 97 { 98 if (iso_tx_channel>=0 && !get1394Service().freeIsoChannel(iso_tx_channel)) { 99 debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free tx iso channel %d\n", iso_tx_channel); 100 } 101 if (iso_rx_channel>=0 && !get1394Service().freeIsoChannel(iso_rx_channel)) { 102 debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free rx iso channel %d\n", iso_rx_channel); 103 } 104 96 105 destroyMixer(); 97 106 … … 506 515 Device::prepare() { 507 516 508 signed int mult ;517 signed int mult, bandwidth; 509 518 510 519 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing Device...\n" ); … … 537 546 num_channels += (mult==4?0:(mult==2?4:8)); 538 547 539 // TODO: We always must allocate a tx iso channel. An rx iso channel is 540 // also allocated for the FF400. For the FF800, the device itself will 541 // supply the iso channel we should listen on in zero-based byte 2 of 542 // the hardware status return. 548 // Bandwidth is calculated here. For the moment we assume the device 549 // is connected at S400, so 1 allocation unit is 1 transmitted byte. 550 // There is 25 allocation units of protocol overhead per packet. Each 551 // channel of audio data is sent/received as a 32 bit integer. 552 bandwidth = 25 + num_channels*4*frames_per_packet; 553 554 // Both the FF400 and FF800 require we allocate a tx iso channel. The 555 // rx channel is also allocated for the FF400 while the FF800 handles 556 // the rx channel allocation for that device. 557 if (iso_tx_channel < 0) { 558 iso_tx_channel = get1394Service().allocateIsoChannelGeneric(bandwidth); 559 } 560 561 if (iso_rx_channel < 0) { 562 if (m_rme_model == RME_MODEL_FIREFACE800) { 563 unsigned int stat[4]; 564 get_hardware_streaming_status(stat, 4); 565 // CHECKME: does this work before streaming has been initialised? 566 iso_rx_channel = stat[2] & 63; 567 iso_rx_channel = get1394Service().allocateFixedIsoChannelGeneric(iso_rx_channel, bandwidth); 568 } else { 569 iso_rx_channel = get1394Service().allocateIsoChannelGeneric(bandwidth); 570 } 571 } 572 573 if (iso_tx_channel<0 || iso_rx_channel<0) { 574 if (iso_tx_channel >= 0) 575 get1394Service().freeIsoChannel(iso_tx_channel); 576 if (iso_rx_channel >= 0) 577 get1394Service().freeIsoChannel(iso_rx_channel); 578 debugFatal("Could not allocate iso channels\n"); 579 return false; 580 } 581 543 582 544 583 return true; trunk/libffado/src/rme/rme_avdevice.h
r1657 r1660 126 126 signed int speed800; 127 127 128 signed int iso_tx_channel, iso_rx_channel; 129 128 130 private: 129 131 unsigned long long int cmd_buffer_addr();