Changeset 1671

Show
Ignore:
Timestamp:
09/19/09 05:02:54 (14 years ago)
Author:
jwoithe
Message:

RME: add some device-level support for stream configuration and control.
RME: make some comments clearer.
RME: remove some useless unreachable code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/rme/fireface_hw.cpp

    r1629 r1671  
    619619 
    620620    return write_tco(tc, 4); 
    621  
    622     return 0; 
    623621} 
    624622 
     
    638636    else 
    639637        ret = writeRegister(RME_FF800_STREAM_SRATE, freq); 
     638 
     639    if (ret == 0) 
     640        dev_config->hardware_freq = freq; 
    640641 
    641642    return ret; 
     
    674675Device::hardware_start_streaming(unsigned int listen_channel) 
    675676{ 
     677    signed int ret = 0; 
    676678    // Listen_channel is the ISO channel the PC will listen on for data sent 
    677679    // by the Fireface. 
     
    679681    quadlet_t data = num_channels; 
    680682 
    681     if (m_rme_model == RME_MODEL_FIREFACE400) { 
    682         addr = RME_FF400_STREAM_START_REG; 
    683         data |= (listen_channel << 5); 
    684     } else { 
    685         addr = RME_FF800_STREAM_START_REG; 
    686         if (speed800) 
    687             data |= RME_FF800_STREAMING_SPEED_800; // Flag 800 Mbps speed 
    688     } 
    689  
    690     return writeRegister(addr, data); 
     683    config_lock(); 
     684    if (not(hardware_is_streaming())) { 
     685        if (m_rme_model == RME_MODEL_FIREFACE400) { 
     686            addr = RME_FF400_STREAM_START_REG; 
     687            data |= (listen_channel << 5); 
     688        } else { 
     689            addr = RME_FF800_STREAM_START_REG; 
     690            if (speed800) 
     691                data |= RME_FF800_STREAMING_SPEED_800; // Flag 800 Mbps speed 
     692        } 
     693 
     694        ret = writeRegister(addr, data); 
     695        if (ret != 0) { 
     696            dev_config->is_streaming = 1; 
     697        } 
     698    } else 
     699        ret = -1; 
     700    config_unlock(); 
     701 
     702    return ret; 
    691703} 
    692704 
     
    696708    fb_nodeaddr_t addr; 
    697709    quadlet_t buf[4] = {0, 0, 0, 1}; 
    698     unsigned int size; 
    699  
    700     if (m_rme_model == RME_MODEL_FIREFACE400) { 
    701       addr = RME_FF400_STREAM_END_REG; 
    702       size = RME_FF400_STREAM_END_SIZE; 
    703     } else { 
    704       addr = RME_FF800_STREAM_END_REG; 
    705       size = RME_FF800_STREAM_END_SIZE; 
    706     } 
    707  
    708     return writeBlock(addr, buf, size); 
     710    unsigned int size, ret = 0; 
     711 
     712    config_lock(); 
     713    if (hardware_is_streaming()) { 
     714        if (m_rme_model == RME_MODEL_FIREFACE400) { 
     715            addr = RME_FF400_STREAM_END_REG; 
     716            size = RME_FF400_STREAM_END_SIZE; 
     717        } else { 
     718            addr = RME_FF800_STREAM_END_REG; 
     719            size = RME_FF800_STREAM_END_SIZE; 
     720        } 
     721 
     722        ret = writeBlock(addr, buf, size); 
     723        if (ret != 0) { 
     724            dev_config->is_streaming = 0; 
     725        } 
     726    } else 
     727        ret = -1; 
     728    config_unlock(); 
     729 
     730    return ret; 
    709731} 
    710732 
  • trunk/libffado/src/rme/rme_avdevice.cpp

    r1660 r1671  
    2525#warning RME support is at an early development stage and is not functional 
    2626 
     27#include "config.h" 
     28 
    2729#include "rme/rme_avdevice.h" 
    2830#include "rme/fireface_def.h" 
     
    516518 
    517519    signed int mult, bandwidth; 
     520    signed int freq; 
     521    signed int err = 0; 
    518522 
    519523    debugOutput(DEBUG_LEVEL_NORMAL, "Preparing Device...\n" ); 
     524 
     525    freq = getSamplingFrequency(); 
     526    if (freq <= 0) { 
     527        debugOutput(DEBUG_LEVEL_ERROR, "Can't continue: sampling frequency not set\n"); 
     528        return false; 
     529    } 
    520530 
    521531    // The number of frames transmitted in a single packet is solely 
     
    553563 
    554564    // 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. 
     565    // rx channel is also allocated for the FF400.  The FF800 chooses 
     566    // the rx channel to be used but does not handle the bus-level 
     567    // channel/bandwidth allocation/ 
    557568    if (iso_tx_channel < 0) { 
    558569        iso_tx_channel = get1394Service().allocateIsoChannelGeneric(bandwidth); 
     
    570581        } 
    571582    } 
    572  
    573     if (iso_tx_channel<0 || iso_rx_channel<0) { 
     583   
     584    if (iso_tx_channel>=0 && iso_rx_channel>=0) { 
     585        err = hardware_init_streaming(dev_config->hardware_freq, iso_tx_channel) != 0; 
     586        if (err) { 
     587            debugFatal("Could not intialise device streaming system\n"); 
     588        } 
     589    } else { 
     590        err = 1; 
     591        debugFatal("Could not allocate iso channels\n"); 
     592    } 
     593 
     594    if (err) { 
    574595        if (iso_tx_channel >= 0)  
    575596            get1394Service().freeIsoChannel(iso_tx_channel); 
    576597        if (iso_rx_channel >= 0) 
    577598            get1394Service().freeIsoChannel(iso_rx_channel); 
    578         debugFatal("Could not allocate iso channels\n"); 
    579         return false; 
    580     } 
    581  
     599        return false; 
     600    } 
     601 
     602    // get the device specific and/or global SP configuration 
     603    Util::Configuration &config = getDeviceManager().getConfiguration(); 
     604    // base value is the config.h value 
     605    float recv_sp_dll_bw = STREAMPROCESSOR_DLL_BW_HZ; 
     606    float xmit_sp_dll_bw = STREAMPROCESSOR_DLL_BW_HZ; 
     607 
     608    // we can override that globally 
     609    config.getValueForSetting("streaming.spm.recv_sp_dll_bw", recv_sp_dll_bw); 
     610    config.getValueForSetting("streaming.spm.xmit_sp_dll_bw", xmit_sp_dll_bw); 
     611 
     612    // or override in the device section 
     613    config.getValueForDeviceSetting(getConfigRom().getNodeVendorId(), getConfigRom().getModelId(), "recv_sp_dll_bw", recv_sp_dll_bw); 
     614    config.getValueForDeviceSetting(getConfigRom().getNodeVendorId(), getConfigRom().getModelId(), "xmit_sp_dll_bw", xmit_sp_dll_bw); 
     615 
     616    // Other things to be done: 
     617    //  * create a receive stream processor, set DLL bandwidth, add ports 
     618    //  * create a transmit stream processor, set DLL bandwidth, add ports 
    582619 
    583620    return true; 
     
    596633bool 
    597634Device::startStreamByIndex(int i) { 
    598     return false; 
     635    // The RME does not allow separate enabling of the transmit and receive 
     636    // streams.  Therefore we start all streaming when index 0 is referenced 
     637    // and silently ignore the start requests for other streams 
     638    // (unconditionally flagging them as being successful). 
     639    if (i == 0) { 
     640        if (hardware_start_streaming(iso_rx_channel) != 0) 
     641            return false; 
     642    } 
     643    return true; 
    599644} 
    600645 
    601646bool 
    602647Device::stopStreamByIndex(int i) { 
    603     return false; 
    604  
     648    // See comments in startStreamByIndex() as to why we act only when stream 
     649    // 0 is requested. 
     650    if (i == 0) { 
     651        if (hardware_stop_streaming() != 0) 
     652            return false; 
     653    } 
     654    return true; 
    605655} 
    606656 
  • trunk/libffado/src/rme/rme_shm.h

    r1629 r1671  
    4040    signed int dds_freq;      // Optionally explicitly set hardware freq 
    4141    signed int software_freq; // Sampling frequency in use by software 
     42    signed int hardware_freq; // Frequency actually programmed into hardware 
    4243 
    4344    signed int is_streaming;