Changeset 1660 for trunk

Show
Ignore:
Timestamp:
09/07/09 04:41:57 (15 years ago)
Author:
jwoithe
Message:

ieee1394Service: new method allocateFixedIsoChannelGeneric() to allocate a specific channel number instead of scanning for the next available channel number. This functionality is needed for the RME devices.
RME: assign/detect iso channels to use and allocate required bandwidth.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libieee1394/ieee1394service.cpp

    r1550 r1660  
    13021302 
    13031303/** 
     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 */ 
     1320signed 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/** 
    13041357 * Allocates an iso channel for use by the interface in a similar way to 
    13051358 * libiec61883.  Returns -1 on error (due to there being no free channels) 
  • trunk/libffado/src/libieee1394/ieee1394service.h

    r1568 r1660  
    360360    signed int getAvailableBandwidth(); 
    361361    signed int allocateIsoChannelGeneric(unsigned int bandwidth); 
     362    signed int allocateFixedIsoChannelGeneric( 
     363        unsigned int chan, unsigned int bandwidth); 
    362364    signed int allocateIsoChannelCMP(nodeid_t xmit_node, int xmit_plug, 
    363365                                     nodeid_t recv_node, int recv_plug); 
  • trunk/libffado/src/rme/rme_avdevice.cpp

    r1657 r1660  
    8585    , frames_per_packet( 0 ) 
    8686    , speed800( 0 ) 
     87    , iso_tx_channel( -1 ) 
     88    , iso_rx_channel( -1 ) 
    8789    , m_MixerContainer( NULL ) 
    8890    , m_ControlContainer( NULL ) 
     
    9496Device::~Device() 
    9597{ 
     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 
    96105    destroyMixer(); 
    97106 
     
    506515Device::prepare() { 
    507516 
    508     signed int mult
     517    signed int mult, bandwidth
    509518 
    510519    debugOutput(DEBUG_LEVEL_NORMAL, "Preparing Device...\n" ); 
     
    537546        num_channels += (mult==4?0:(mult==2?4:8)); 
    538547 
    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 
    543582 
    544583    return true; 
  • trunk/libffado/src/rme/rme_avdevice.h

    r1657 r1660  
    126126    signed int speed800; 
    127127 
     128    signed int iso_tx_channel, iso_rx_channel; 
     129 
    128130private: 
    129131    unsigned long long int cmd_buffer_addr();