Changeset 2077

Show
Ignore:
Timestamp:
03/09/12 00:14:17 (12 years ago)
Author:
jwoithe
Message:

rme: the streaming system can now be restarted after being stopped without having to exit ffado first. This means that the RME interfaces are now tolerant of jackd coming out of freewheeling mode. It may also improve things in the face of bus resets. We'll see.

Files:

Legend:

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

    r2074 r2077  
    8080        , streaming_has_run ( 0 ) 
    8181        , streaming_has_dryrun ( 0 ) 
     82        , streaming_start_count ( 0 ) 
    8283{ 
    8384  int srate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); 
     
    107108    streaming_has_run = 0; 
    108109    streaming_has_dryrun = 0; 
     110    streaming_start_count = 0; 
    109111    return true; 
    110112} 
     
    351353    uint32_t pkt_ctr ) 
    352354{ 
    353 static signed int cx = 0; 
    354  
    355355    debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, "XMIT EMPTY: CY=%04lu, TSP=%011llu (%04u)\n", 
    356356                CYCLE_TIMER_GET_CYCLES(pkt_ctr), m_last_timestamp,  
     
    381381 
    382382        streaming_has_dryrun = 1; 
    383         if (cx < (1)*n_events) { 
    384             cx += n_events; 
     383        if (streaming_start_count < (1)*n_events) { 
     384            streaming_start_count += n_events; 
    385385            *length = n_events * m_event_size; 
     386//            generateSilentPacketData(data, length); 
    386387        } 
    387388    } 
  • trunk/libffado/src/libstreaming/rme/RmeTransmitStreamProcessor.h

    r2074 r2077  
    132132    unsigned int midi_lock; 
    133133    signed int streaming_has_run, streaming_has_dryrun; 
     134    signed int streaming_start_count; 
    134135    unsigned int midi_tx_period; /* Measured in audio clock periods */ 
    135136}; 
  • trunk/libffado/src/rme/rme_avdevice.cpp

    r2074 r2077  
    625625    signed int err; 
    626626 
    627     // Ensure the transmit processor is ready to start streaming. 
    628     m_transmitProcessor->resetForStreaming(); 
    629  
    630     // FIXME: this may yet move back into prepare(). 
     627signed int iso_rx; 
     628unsigned int stat[4]; 
     629signed int i; 
     630 
     631    // Ensure the transmit processor is ready to start streaming.  When 
     632    // this function is called from prepare() the transmit processor 
     633    // won't be allocated. 
     634    if (m_transmitProcessor != NULL) 
     635        m_transmitProcessor->resetForStreaming(); 
     636 
     637    // Whenever streaming is restarted hardware_init_streaming() needs to be 
     638    // called.  Otherwise the device won't start sending data when data is 
     639    // sent to it and the rx stream will fail to start. 
    631640    err = hardware_init_streaming(dev_config->hardware_freq, iso_tx_channel) != 0; 
    632641    if (err) { 
     
    634643        return false; 
    635644    } 
     645 
     646    i = 0; 
     647    while (i < 100) { 
     648        err = (get_hardware_streaming_status(stat, 4) != 0); 
     649        if (err) { 
     650            debugFatal("error reading status register\n"); 
     651            break; 
     652        } 
     653 
     654// FIXME: this can probably go once the driver matures. 
     655debugOutput(DEBUG_LEVEL_NORMAL, "init stat: %08x %08x %08x %08x\n", 
     656  stat[0], stat[1], stat[2], stat[3]); 
     657 
     658        if (m_rme_model == RME_MODEL_FIREFACE400) { 
     659            break; 
     660        } 
     661 
     662        // The Fireface-800 chooses its tx channel (our rx channel).  Wait 
     663        // for the device busy flag to clear, then confirm that the rx iso 
     664        // channel hasn't changed (it shouldn't across a restart). 
     665        if (stat[2] == 0xffffffff) { 
     666            // Device not ready; wait 5 ms and try again 
     667            usleep(5000); 
     668        } else { 
     669            iso_rx = stat[2] & 63; 
     670            if (iso_rx!=iso_rx_channel && iso_rx_channel!=-1) 
     671                debugOutput(DEBUG_LEVEL_WARNING, "rx iso: now %d, was %d\n", 
     672                    iso_rx, iso_rx_channel); 
     673            iso_rx_channel = iso_rx; 
     674 
     675            // Even if the rx channel has changed, the device takes care of 
     676            // registering the channel itself, so we don't have to (neither 
     677            // do we have to release the old one).  If we try to call 
     678            // raw1394_channel_modify() on the returned channel we'll get an 
     679            // error. 
     680            //   iso_rx_channel = get1394Service().allocateFixedIsoChannelGeneric(iso_rx_channel, bandwidth); 
     681            break; 
     682        } 
     683    } 
     684    if (i==100 || err) 
     685        return false; 
    636686 
    637687    return FFADODevice::resetForStreaming(); 
     
    705755    } 
    706756 
    707 //    err = hardware_init_streaming(dev_config->hardware_freq, iso_tx_channel) != 0; 
    708 //    if (err) { 
    709 //        debugFatal("Could not intialise device streaming system\n"); 
    710 //    } 
    711  
    712     if (err == 0) { 
    713         signed int i; 
    714         for (i=0; i<100; i++) { 
    715             err = (get_hardware_streaming_status(stat, 4) != 0); 
    716             if (err) { 
    717                 debugFatal("error reading status register\n"); 
    718                 break; 
    719             } 
    720  
    721 // FIXME: this can probably go once the driver matures. 
    722 debugOutput(DEBUG_LEVEL_NORMAL, "init stat: %08x %08x %08x %08x\n", 
    723   stat[0], stat[1], stat[2], stat[3]); 
    724  
    725             if (m_rme_model == RME_MODEL_FIREFACE400) { 
    726                 iso_rx_channel = get1394Service().allocateIsoChannelGeneric(bandwidth); 
    727                 break; 
    728             } 
    729             // The Fireface-800 chooses its tx channel (our rx channel). 
    730             if (stat[2] == 0xffffffff) { 
    731                 // Device not ready; wait 5 ms and try again 
    732                 usleep(5000); 
    733             } else { 
    734                 iso_rx_channel = stat[2] & 63; 
    735  
    736                 // The device seems to register this channel itself.  raw1394_channel_modify() 
    737                 // returns an error if used on the returned channel. 
    738                 //   iso_rx_channel = get1394Service().allocateFixedIsoChannelGeneric(iso_rx_channel, bandwidth); 
    739                 break; 
    740             } 
    741         } 
    742         if (iso_rx_channel < 0) { 
    743             debugFatal("Could not allocate/determine iso rx channel\n"); 
    744             err = 1; 
    745         } 
    746     } 
     757    // Call this to initialise the device's streaming system and, in the 
     758    // case of the FF800, obtain the rx iso channel to use.  Having that 
     759    // functionality in resetForStreaming() means it's effectively done 
     760    // twice when FFADO is first started, but this does no harm. 
     761    resetForStreaming(); 
    747762   
    748763    if (err) { 
     
    753768            get1394Service().freeIsoChannel(iso_rx_channel); 
    754769        return false; 
     770    } 
     771 
     772    /* We need to manage the FF400's iso rx channel */ 
     773    if (m_rme_model == RME_MODEL_FIREFACE400) { 
     774        iso_rx_channel = get1394Service().allocateIsoChannelGeneric(bandwidth); 
    755775    } 
    756776