Changeset 1524

Show
Ignore:
Timestamp:
03/24/09 15:12:35 (15 years ago)
Author:
ppalmers
Message:

- Fix handling of MIDI 2x and 3x mode
- Introduce support for driver parameters in the config file
- add command rate control for the saffire devices to reduce

the issues with mixer actions messing up audio.


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/configuration

    r1497 r1524  
    106106    driver      = 1; # BeBoB 
    107107    mixer       = "SaffireMixer"; 
     108    cmd_interval_time = 10000; 
    108109}, 
    109110{ 
     
    231232    modelname = "Onyx 1200F"; 
    232233    driver = 2; 
     234  }, 
     235  { 
     236    vendorid = 0x00001260; 
     237    modelid = 0x00001000; 
     238    vendorname = "Stanton DJ"; 
     239    modelname = "SCS.1m"; 
     240    driver = 3; 
    233241  }, 
    234242  { # added by arnonym from ffado-mixers list 
  • branches/libffado-2.0/SConstruct

    r1513 r1524  
    5353        BoolOption( "DEBUG", """\ 
    5454Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use 
    55   \"-O2\" to optimise.""", True ), 
     55  \"-O2\" to optimize.""", True ), 
    5656        BoolOption( "PROFILE", "Build with symbols and other profiling info", False ), 
    5757        PathOption( "PREFIX", "The prefix where ffado will be installed to.", "/usr/local", PathOption.PathAccept ), 
  • branches/libffado-2.0/src/bebob/focusrite/focusrite_generic.cpp

    r1371 r1524  
    2626 
    2727#include "libutil/ByteSwap.h" 
    28 #include "libutil/SystemTimeSource.h" 
    2928 
    3029namespace BeBoB { 
     
    3332FocusriteDevice::FocusriteDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom )) 
    3433    : BeBoB::AvDevice( d, configRom) 
     34    , m_cmd_time_interval( 0 ) 
     35    , m_earliest_next_cmd_time( 0 ) 
    3536{ 
    3637    debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Focusrite::FocusriteDevice (NodeID %d)\n", 
     
    6162    bool use_avc = false; 
    6263    if(!getOption("useAvcForParameters", use_avc)) { 
    63         debugWarning("Could not retrieve useAvcForParameters parameter, defauling to false\n"); 
    64     } 
     64        debugWarning("Could not retrieve useAvcForParameters parameter, defaulting to false\n"); 
     65    } 
     66 
     67    // rate control 
     68    ffado_microsecs_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
     69    if(m_cmd_time_interval && (m_earliest_next_cmd_time > now)) { 
     70        ffado_microsecs_t wait = m_earliest_next_cmd_time - now; 
     71        debugOutput( DEBUG_LEVEL_VERBOSE, "Rate control... %llu\n", wait ); 
     72        Util::SystemTimeSource::SleepUsecRelative(wait); 
     73    } 
     74    m_earliest_next_cmd_time = now + m_cmd_time_interval; 
     75 
    6576    if (use_avc) { 
    6677        return setSpecificValueAvc(id, v); 
     
    7687    bool use_avc = false; 
    7788    if(!getOption("useAvcForParameters", use_avc)) { 
    78         debugWarning("Could not retrieve useAvcForParameters parameter, defauling to false\n"); 
    79     } 
     89        debugWarning("Could not retrieve useAvcForParameters parameter, defaulting to false\n"); 
     90    } 
     91 
     92    // rate control 
     93    ffado_microsecs_t now = Util::SystemTimeSource::getCurrentTimeAsUsecs(); 
     94    if(m_cmd_time_interval && (m_earliest_next_cmd_time > now)) { 
     95        ffado_microsecs_t wait = m_earliest_next_cmd_time - now; 
     96        debugOutput( DEBUG_LEVEL_VERBOSE, "Rate control... %llu\n", wait ); 
     97        Util::SystemTimeSource::SleepUsecRelative(wait); 
     98    } 
     99    m_earliest_next_cmd_time = now + m_cmd_time_interval; 
     100 
     101    // execute 
    80102    if (use_avc) { 
    81103        retval = getSpecificValueAvc(id, v); 
  • branches/libffado-2.0/src/bebob/focusrite/focusrite_generic.h

    r1370 r1524  
    3131#include "libcontrol/BasicElements.h" 
    3232#include "libcontrol/MatrixMixer.h" 
     33 
     34#include "libutil/SystemTimeSource.h" 
    3335 
    3436#define FR_PARAM_SPACE_START 0x000100000000LL 
     
    236238    bool setSpecificValueARM(uint32_t id, uint32_t v); 
    237239    bool getSpecificValueARM(uint32_t id, uint32_t *v); 
     240 
     241protected: 
     242    ffado_microsecs_t m_cmd_time_interval; 
     243    ffado_microsecs_t m_earliest_next_cmd_time; 
    238244}; 
    239245 
  • branches/libffado-2.0/src/bebob/focusrite/focusrite_saffire.cpp

    r1413 r1524  
    2525#include "focusrite_cmd.h" 
    2626 
     27#include "devicemanager.h" 
     28 
    2729namespace BeBoB { 
    2830namespace Focusrite { 
     
    3941    } else { 
    4042        m_isSaffireLE = true; 
     43    } 
     44 
     45    // find the configured delay time for this device 
     46    Util::Configuration &config = d.getConfiguration(); 
     47    int delaytime = 0; 
     48    if(config.getValueForDeviceSetting(getConfigRom().getNodeVendorId(), getConfigRom().getModelId(), "cmd_interval_time", delaytime)) { 
     49        m_cmd_time_interval = delaytime; 
     50        debugOutput( DEBUG_LEVEL_VERBOSE, "Setting command interval time to %llu\n", 
     51                     m_cmd_time_interval ); 
     52    } else { 
     53        m_cmd_time_interval = 10000; 
     54        debugOutput( DEBUG_LEVEL_VERBOSE, "No command interval time setting found, defaulting to %llu\n", 
     55                     m_cmd_time_interval ); 
    4156    } 
    4257} 
  • branches/libffado-2.0/src/devicemanager.cpp

    r1452 r1524  
    948948    if(dev) { 
    949949        debugOutput( DEBUG_LEVEL_VERBOSE, " found supported device...\n" ); 
     950        dev->setVerboseLevel(getDebugLevel()); 
    950951        return dev; 
    951952    } 
     
    955956    if(dev) { 
    956957        debugOutput( DEBUG_LEVEL_VERBOSE, " found generic support for device...\n" ); 
     958        dev->setVerboseLevel(getDebugLevel()); 
    957959        return dev; 
    958960    } 
    959961    debugOutput( DEBUG_LEVEL_VERBOSE, " device not supported...\n" ); 
    960     return 0
     962    return NULL
    961963} 
    962964 
     
    964966DeviceManager::getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) ) 
    965967{ 
    966     return 0
     968    return NULL
    967969} 
    968970 
  • branches/libffado-2.0/src/libieee1394/CycleTimerHelper.cpp

    r1466 r1524  
    455455        // i.e. DLL error signal 
    456456        int64_t diff_ticks_corr; 
    457         if (ticks_late > 0) { 
     457        if (ticks_late >= 0) { 
    458458            diff_ticks_corr = diff_ticks - ticks_late; 
    459459            debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 
  • branches/libffado-2.0/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp

    r1448 r1524  
    181181    debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE,  
    182182                        "(%p)->processReadBlock(%u, %u)\n", 
    183                         this,nevents,offset); 
     183                        this, nevents, offset); 
    184184 
    185185    // update the variable parts of the cache 
     
    366366    for (i = 0; i < m_nb_midi_ports; i++) { 
    367367        struct _MIDI_port_cache &p = m_midi_ports.at(i); 
    368         if (p.buffer && p.enabled) { 
     368        if (p.buffer && p.enabled) {  
    369369            uint32_t *buffer = (quadlet_t *)(p.buffer); 
    370370            buffer += offset; 
    371  
    372371            for (j = p.location;j < nevents; j += 8) { 
    373372                target_event = (quadlet_t *) (data + ((j * m_dimension) + p.position)); 
    374                 sample_int=CondSwapFromBus32(*target_event); 
     373                sample_int = CondSwapFromBus32(*target_event); 
     374 
    375375                // FIXME: this assumes that 2X and 3X speed isn't used, 
    376376                // because only the 1X slot is put into the ringbuffer 
    377                 if(IEC61883_AM824_GET_LABEL(sample_int) != IEC61883_AM824_LABEL_MIDI_NO_DATA) { 
     377                if(IEC61883_AM824_HAS_LABEL(sample_int, IEC61883_AM824_LABEL_MIDI_1X)) { 
    378378                    sample_int=(sample_int >> 16) & 0x000000FF; 
    379379                    sample_int |= 0x01000000; // flag that there is a midi event present 
    380380                    *buffer = sample_int; 
    381                     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Received midi byte %08X on port %p index %d\n", sample_int, p, j-p.location); 
     381                } else if(IEC61883_AM824_HAS_LABEL(sample_int, IEC61883_AM824_LABEL_MIDI_2X) 
     382                       || IEC61883_AM824_HAS_LABEL(sample_int, IEC61883_AM824_LABEL_MIDI_3X) ) { 
     383                    debugOutput(DEBUG_LEVEL_VERBOSE, "Midi mode %X not supported.\n", IEC61883_AM824_GET_LABEL(sample_int)); 
    382384                } else { 
    383385                    // make sure no event is received 
  • branches/libffado-2.0/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h

    r1419 r1524  
    5151#define IEC61883_AM824_LABEL_MIDI_2X          0x82 
    5252#define IEC61883_AM824_LABEL_MIDI_3X          0x83 
     53 
     54#define IEC61883_AM824_HAS_LABEL(x, lbl)         (((x) & 0xFF000000) == (((quadlet_t)(lbl))<<24)) 
    5355 
    5456namespace Streaming { 
  • branches/libffado-2.0/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h

    r1419 r1524  
    5151#define IEC61883_AM824_LABEL_MIDI_2X          0x82 
    5252#define IEC61883_AM824_LABEL_MIDI_3X          0x83 
     53 
     54#define IEC61883_AM824_HAS_LABEL(x, lbl)         (((x) & 0xFF000000) == (((quadlet_t)(lbl))<<24)) 
    5355 
    5456namespace Streaming { 
  • branches/libffado-2.0/src/libutil/Configuration.cpp

    r1405 r1524  
    289289} 
    290290 
    291  
    292 Configuration::VendorModelEntry 
    293 Configuration::findDeviceVME( unsigned int vendor_id, unsigned model_id ) 
     291bool 
     292Configuration::getValueForDeviceSetting(unsigned int vendor_id, unsigned model_id, std::string setting, int32_t &ref) 
     293
     294    libconfig::Setting *s = getDeviceSetting( vendor_id, model_id ); 
     295    if(s) { 
     296        try { 
     297            return s->lookupValue(setting, ref); 
     298        } catch (...) { 
     299            debugOutput(DEBUG_LEVEL_VERBOSE, "Setting %s not found\n", setting.c_str()); 
     300            return false; 
     301        } 
     302    } else { 
     303        debugOutput(DEBUG_LEVEL_VERBOSE, "device %X/%X not found\n", vendor_id, model_id); 
     304        return false; 
     305    } 
     306
     307 
     308bool 
     309Configuration::getValueForDeviceSetting(unsigned int vendor_id, unsigned model_id, std::string setting, int64_t &ref) 
     310
     311    libconfig::Setting *s = getDeviceSetting( vendor_id, model_id ); 
     312    if(s) { 
     313        try { 
     314            return s->lookupValue(setting, ref); 
     315        } catch (...) { 
     316            debugOutput(DEBUG_LEVEL_VERBOSE, "Setting %s not found\n", setting.c_str()); 
     317            return false; 
     318        } 
     319    } else { 
     320        debugOutput(DEBUG_LEVEL_VERBOSE, "device %X/%X not found\n", vendor_id, model_id); 
     321        return false; 
     322    } 
     323
     324 
     325libconfig::Setting * 
     326Configuration::getDeviceSetting( unsigned int vendor_id, unsigned model_id ) 
    294327{ 
    295328    for ( std::vector<ConfigFile *>::iterator it = m_ConfigFiles.begin(); 
     
    309342                    uint32_t mid = modelid; 
    310343                    if (vendor_id == vid && model_id == mid) { 
    311                         struct VendorModelEntry vme; 
    312                         vme.vendor_id = vendorid; 
    313                         vme.model_id = modelid; 
    314  
    315                         const char *tmp = s["vendorname"]; 
    316                         vme.vendor_name = tmp; 
    317                         tmp = s["modelname"]; 
    318                         vme.model_name = tmp; 
    319                         vme.driver = s["driver"]; 
    320344                        debugOutput(DEBUG_LEVEL_VERBOSE, 
    321345                                    "  device VME for %X:%x found in %s\n", 
    322346                                    vendor_id, model_id, c->getName().c_str()); 
    323347                        c->showSetting(s); 
    324                         return vme
     348                        return &s
    325349                    } 
    326350                } catch (...) { 
     
    330354        } catch (...) { 
    331355            debugOutput(DEBUG_LEVEL_VERBOSE, "  %s has no device definitions\n", c->getName().c_str()); 
     356        } 
     357    } 
     358    return NULL; 
     359} 
     360 
     361 
     362 
     363Configuration::VendorModelEntry 
     364Configuration::findDeviceVME( unsigned int vendor_id, unsigned model_id ) 
     365{ 
     366 
     367    // FIXME: clean this pointer/reference mess please 
     368    Setting *ps = getDeviceSetting(vendor_id, model_id); 
     369 
     370    if(ps) { 
     371        Setting &s = *ps; 
     372        try { 
     373            Setting &vendorid = s["vendorid"]; 
     374            Setting &modelid = s["modelid"]; 
     375            uint32_t vid = vendorid; 
     376            uint32_t mid = modelid; 
     377            if (vendor_id == vid && model_id == mid) { 
     378                struct VendorModelEntry vme; 
     379                vme.vendor_id = vendorid; 
     380                vme.model_id = modelid; 
     381 
     382                const char *tmp = s["vendorname"]; 
     383                vme.vendor_name = tmp; 
     384                tmp = s["modelname"]; 
     385                vme.model_name = tmp; 
     386                vme.driver = s["driver"]; 
     387                return vme; 
     388            } else { 
     389                debugError("BUG: vendor/model found but not found?\n"); 
     390            } 
     391        } catch (...) { 
     392            debugWarning("Bogus format\n"); 
    332393        } 
    333394    } 
  • branches/libffado-2.0/src/libutil/Configuration.h

    r1373 r1524  
    127127    bool getValueForSetting(std::string path, int64_t &ref); 
    128128 
     129    /** 
     130     * @brief retrieves a setting for a given device 
     131     *  
     132     * the value in the ref parameter is not changed if 
     133     * the function returns false. 
     134     *  
     135     * @param vendor_id vendor id for the device 
     136     * @param model_id  model id for the device 
     137     * @param setting name of the setting 
     138     * @param ref reference to the integer that will hold the value. 
     139     * @return true if successful, false if not 
     140     */ 
     141    bool getValueForDeviceSetting(unsigned int vendor_id, unsigned model_id, std::string setting, int32_t &ref); 
     142    bool getValueForDeviceSetting(unsigned int vendor_id, unsigned model_id, std::string setting, int64_t &ref); 
     143 
    129144    virtual void setVerboseLevel(int l) {setDebugLevel(l);}; 
    130145    virtual void show(); 
     
    132147private: 
    133148    libconfig::Setting *getSetting( std::string path ); 
     149    libconfig::Setting *getDeviceSetting( unsigned int vendor_id, unsigned model_id ); 
    134150 
    135151    int findFileName(std::string s);