Changeset 992

Show
Ignore:
Timestamp:
04/06/08 16:19:31 (13 years ago)
Author:
jwoithe
Message:

Added support for getting firewire unit version via Dbus (needed by ffadomixer to differentiate MOTU models down the track).
Created a motu mixer in ffadomixer and commenced implementation of controls. The precise nature of the implementation is still being fine-tuned and is subject to change.
Minor whitespace cleanups and spelling corrections.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/motu/motu_avdevice.cpp

    r984 r992  
    3838#include "libutil/DelayLockedLoop.h" 
    3939#include "libutil/Time.h" 
     40 
     41#include "libcontrol/BasicElements.h" 
    4042 
    4143#include <string> 
     
    245247}; 
    246248 
     249// Mixer registers 
     250const MixerCtrl MixerCtrls_Traveler[] = { 
     251    {"Mix1/Ana1_", "Mix 1 analog 1 ", "", MOTU_CTRL_STD_CHANNEL, 0x4000, }, 
     252    {"Mix1/Ana2_", "Mix 1 analog 2 ", "", MOTU_CTRL_STD_CHANNEL, 0x4004, }, 
     253    {"Mix1/Ana3_", "Mix 1 analog 3 ", "", MOTU_CTRL_STD_CHANNEL, 0x4008, }, 
     254    {"Mix1/Ana4_", "Mix 1 analog 4 ", "", MOTU_CTRL_STD_CHANNEL, 0x400c, }, 
     255    {"Mix1/Ana5_", "Mix 1 analog 5 ", "", MOTU_CTRL_STD_CHANNEL, 0x4010, }, 
     256    {"Mix1/Ana6_", "Mix 1 analog 6 ", "", MOTU_CTRL_STD_CHANNEL, 0x4014, }, 
     257    {"Mix1/Ana7_", "Mix 1 analog 7 ", "", MOTU_CTRL_STD_CHANNEL, 0x4018, }, 
     258    {"Mix1/Ana8_", "Mix 1 analog 8 ", "", MOTU_CTRL_STD_CHANNEL, 0x401c, }, 
     259}; 
     260 
     261// For convenience during initial testing, just make the 828MkII and 896HD 
     262// use the Traveler's mixer definition.  Separate definitions for these  
     263// models will come once the final mixer structure is in place.  For now 
     264// it's in a state of flux and subject to significant change. 
     265#define MixerCtrls_828MkII MixerCtrls_Traveler 
     266#define MixerCtrls_896HD   MixerCtrls_Traveler 
     267 
    247268/* The order of DevicesProperty entries must match the numeric order of the 
    248269 * MOTU model enumeration (EMotuModel). 
    249270 */ 
    250271const DevicePropertyEntry DevicesProperty[] = { 
    251 //  { Ports_map,       sizeof( Ports_map ),        MaxSR }, 
    252     { Ports_828MKII,   sizeof( Ports_828MKII ),    96000 }, 
    253     { Ports_TRAVELER,  sizeof( Ports_TRAVELER ),  192000 }, 
    254     { Ports_ULTRALITE, sizeof( Ports_ULTRALITE ),  96000 }, 
    255     { Ports_8PRE,      sizeof( Ports_8PRE ),       96000 }, 
    256     { Ports_828MKI,    sizeof( Ports_828MKI ),     48000 }, 
    257     { Ports_896HD,     sizeof( Ports_896HD ),     192000 }, 
     272//  { Ports_map,       N_ELEMENTS( Ports_map ),        MaxSR }, 
     273    { Ports_828MKII,   N_ELEMENTS( Ports_828MKII ),    96000, MixerCtrls_828MkII, N_ELEMENTS(MixerCtrls_828MkII), }, 
     274    { Ports_TRAVELER,  N_ELEMENTS( Ports_TRAVELER ),  192000, MixerCtrls_Traveler, N_ELEMENTS(MixerCtrls_Traveler), }, 
     275    { Ports_ULTRALITE, N_ELEMENTS( Ports_ULTRALITE ),  96000 }, 
     276    { Ports_8PRE,      N_ELEMENTS( Ports_8PRE ),       96000 }, 
     277    { Ports_828MKI,    N_ELEMENTS( Ports_828MKI ),     48000 }, 
     278    { Ports_896HD,     N_ELEMENTS( Ports_896HD ),     192000, MixerCtrls_896HD, N_ELEMENTS(MixerCtrls_896HD), }, 
    258279}; 
    259280 
     
    267288    , m_receiveProcessor ( 0 ) 
    268289    , m_transmitProcessor ( 0 ) 
    269  
     290    , m_MixerContainer ( NULL ) 
     291    , m_ControlContainer ( NULL ) 
    270292{ 
    271293    debugOutput( DEBUG_LEVEL_VERBOSE, "Created Motu::MotuDevice (NodeID %d)\n", 
     
    285307        debugOutput(DEBUG_LEVEL_VERBOSE, "Could not free send iso channel %d\n", m_iso_send_channel); 
    286308    } 
     309 
     310    destroyMixer(); 
     311} 
     312 
     313bool 
     314MotuDevice::buildMixer() { 
     315    unsigned int i; 
     316    bool result = true; 
     317    debugOutput(DEBUG_LEVEL_VERBOSE, "Building a MOTU mixer...\n"); 
     318 
     319    destroyMixer(); 
     320         
     321    // create the mixer object container 
     322    m_MixerContainer = new Control::Container("Mixer"); 
     323    if (!m_MixerContainer) { 
     324        debugError("Could not create mixer container...\n"); 
     325        return false; 
     326    } 
     327 
     328    // Mixer controls get added here 
     329    for (i=0; i<DevicesProperty[m_motu_model-1].n_mixer_ctrls; i++) { 
     330        unsigned int type = DevicesProperty[m_motu_model-1].mixer_ctrl[i].type; 
     331        char name[100]; 
     332        char label[100]; 
     333        if (type & MOTU_CTRL_CHANNEL_FADER) { 
     334            snprintf(name, 100, "%s%s", DevicesProperty[m_motu_model-1].mixer_ctrl[i].name, "fader"); 
     335            snprintf(label,100, "%s%s", DevicesProperty[m_motu_model-1].mixer_ctrl[i].label,"fader"); 
     336            result &= m_MixerContainer->addElement( 
     337                new ChannelFader(*this,  
     338                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].dev_register, 
     339                    name, label,  
     340                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].desc)); 
     341            type &= ~MOTU_CTRL_CHANNEL_FADER; 
     342        } 
     343        if (type & MOTU_CTRL_CHANNEL_PAN) { 
     344            snprintf(name, 100, "%s%s", DevicesProperty[m_motu_model-1].mixer_ctrl[i].name, "pan"); 
     345            snprintf(label,100, "%s%s", DevicesProperty[m_motu_model-1].mixer_ctrl[i].label,"pan"); 
     346            result &= m_MixerContainer->addElement( 
     347                new ChannelPan(*this,  
     348                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].dev_register, 
     349                    name, label, 
     350                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].desc)); 
     351            type &= ~MOTU_CTRL_CHANNEL_PAN; 
     352        } 
     353        if (type) { 
     354            debugOutput(DEBUG_LEVEL_VERBOSE, "Unknown mixer control type flag bits 0x%08x\n", DevicesProperty[m_motu_model-1].mixer_ctrl[i].type); 
     355        } 
     356    } 
     357 
     358    if (!addElement(m_MixerContainer)) { 
     359        debugWarning("Could not register mixer to device\n"); 
     360        // clean up 
     361        destroyMixer(); 
     362        return false; 
     363    } 
     364 
     365    // Special controls 
     366    m_ControlContainer = new Control::Container("Control"); 
     367    if (!m_ControlContainer) { 
     368        debugError("Could not create control container...\n"); 
     369        return false; 
     370    } 
     371 
     372    // Special controls get added here 
     373 
     374    if (!result) { 
     375        debugWarning("One or more device control elements could not be created."); 
     376        // clean up those that couldn't be created 
     377        destroyMixer(); 
     378        return false; 
     379    } 
     380    if (!addElement(m_ControlContainer)) { 
     381        debugWarning("Could not register controls to device\n"); 
     382        // clean up 
     383        destroyMixer(); 
     384        return false; 
     385    } 
     386 
     387    return true; 
     388} 
     389 
     390 
     391bool 
     392MotuDevice::destroyMixer() { 
     393    debugOutput(DEBUG_LEVEL_VERBOSE, "destroy mixer...\n"); 
     394 
     395    if (m_MixerContainer == NULL) { 
     396        debugOutput(DEBUG_LEVEL_VERBOSE, "no mixer to destroy...\n"); 
     397        return true; 
     398    } 
     399     
     400    if (!deleteElement(m_MixerContainer)) { 
     401        debugError("Mixer present but not registered to the avdevice\n"); 
     402        return false; 
     403    } 
     404 
     405    // remove and delete (as in free) child control elements 
     406    m_MixerContainer->clearElements(true); 
     407    delete m_MixerContainer; 
     408    m_MixerContainer = NULL; 
     409 
     410    // remove control container 
     411    if (m_ControlContainer == NULL) { 
     412        debugOutput(DEBUG_LEVEL_VERBOSE, "no controls to destroy...\n"); 
     413        return true; 
     414    } 
     415     
     416    if (!deleteElement(m_ControlContainer)) { 
     417        debugError("Controls present but not registered to the avdevice\n"); 
     418        return false; 
     419    } 
     420     
     421    // remove and delete (as in free) child control elements 
     422    m_ControlContainer->clearElements(true); 
     423    delete m_ControlContainer; 
     424    m_ControlContainer = NULL; 
     425 
     426    return true; 
    287427} 
    288428 
     
    337477    } 
    338478 
    339     if (m_model != NULL) { 
    340         debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
    341                 m_model->vendor_name, m_model->model_name); 
    342         return true; 
    343     } 
    344  
    345     return false; 
     479    if (m_model == NULL) { 
     480        return false; 
     481    } 
     482 
     483    debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", 
     484        m_model->vendor_name, m_model->model_name); 
     485 
     486    if (!buildMixer()) { 
     487        debugWarning("Could not build mixer\n"); 
     488    } 
     489 
     490    return true; 
    346491} 
    347492 
     
    8941039        flags |= MOTUFW_PA_RATE_1x; 
    8951040 
    896     for (i=0; i < ( DevicesProperty[m_motu_model-1].PortsListLength /sizeof( PortEntry ) ); i++) { 
    897         if (( DevicesProperty[m_motu_model-1].PortsList[i].port_dir & dir ) && 
    898            ( DevicesProperty[m_motu_model-1].PortsList[i].port_flags & MOTUFW_PA_RATE_MASK & flags ) && 
    899            ( DevicesProperty[m_motu_model-1].PortsList[i].port_flags & MOTUFW_PA_OPTICAL_MASK & flags )) { 
     1041    for (i=0; i < DevicesProperty[m_motu_model-1].n_port_entries; i++) { 
     1042        if (( DevicesProperty[m_motu_model-1].port_entry[i].port_dir & dir ) && 
     1043           ( DevicesProperty[m_motu_model-1].port_entry[i].port_flags & MOTUFW_PA_RATE_MASK & flags ) && 
     1044           ( DevicesProperty[m_motu_model-1].port_entry[i].port_flags & MOTUFW_PA_OPTICAL_MASK & flags )) { 
    9001045            size += 3; 
    9011046        } 
     
    9561101    std::string id=std::string("dev?"); 
    9571102    if(!getOption("id", id)) { 
    958         debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
     1103        debugWarning("Could not retrieve id parameter, defaulting to 'dev?'\n"); 
    9591104    } 
    9601105 
     
    9651110    } 
    9661111 
    967     for (i=0; i < ( DevicesProperty[m_motu_model-1].PortsListLength /sizeof( PortEntry ) ); i++) { 
    968         if (( DevicesProperty[m_motu_model-1].PortsList[i].port_dir & dir ) && 
    969            ( DevicesProperty[m_motu_model-1].PortsList[i].port_flags & MOTUFW_PA_RATE_MASK & flags ) && 
    970            ( DevicesProperty[m_motu_model-1].PortsList[i].port_flags & MOTUFW_PA_OPTICAL_MASK & flags )) { 
     1112    for (i=0; i < DevicesProperty[m_motu_model-1].n_port_entries; i++) { 
     1113        if (( DevicesProperty[m_motu_model-1].port_entry[i].port_dir & dir ) && 
     1114           ( DevicesProperty[m_motu_model-1].port_entry[i].port_flags & MOTUFW_PA_RATE_MASK & flags ) && 
     1115           ( DevicesProperty[m_motu_model-1].port_entry[i].port_flags & MOTUFW_PA_OPTICAL_MASK & flags )) { 
    9711116            asprintf(&buff,"%s_%s_%s" , id.c_str(), mode_str, 
    972               DevicesProperty[m_motu_model-1].PortsList[i].port_name); 
    973             if (!addPort(s_processor, buff, direction, DevicesProperty[m_motu_model-1].PortsList[i].port_offset, 0)) 
     1117              DevicesProperty[m_motu_model-1].port_entry[i].port_name); 
     1118            if (!addPort(s_processor, buff, direction, DevicesProperty[m_motu_model-1].port_entry[i].port_offset, 0)) 
    9741119                return false; 
    9751120        } 
  • trunk/libffado/src/motu/motu_avdevice.h

    r981 r992  
    3434#include "libstreaming/motu/MotuTransmitStreamProcessor.h" 
    3535 
    36 #define MOTUFW_BASE_ADDR                0xfffff0000000ULL 
    37  
    38 #define MOTUFW_RATE_BASE_44100          (0<<3) 
    39 #define MOTUFW_RATE_BASE_48000          (1<<3) 
    40 #define MOTUFW_RATE_MULTIPLIER_1X       (0<<4) 
    41 #define MOTUFW_RATE_MULTIPLIER_2X       (1<<4) 
    42 #define MOTUFW_RATE_MULTIPLIER_4X       (2<<4) 
    43 #define MOTUFW_RATE_BASE_MASK           (0x00000008) 
    44 #define MOTUFW_RATE_MULTIPLIER_MASK     (0x00000030) 
     36#include "motu_controls.h" 
     37 
     38#define MOTUFW_BASE_ADDR               0xfffff0000000ULL 
     39 
     40#define MOTUFW_RATE_BASE_44100         (0<<3) 
     41#define MOTUFW_RATE_BASE_48000         (1<<3) 
     42#define MOTUFW_RATE_MULTIPLIER_1X      (0<<4) 
     43#define MOTUFW_RATE_MULTIPLIER_2X      (1<<4) 
     44#define MOTUFW_RATE_MULTIPLIER_4X      (2<<4) 
     45#define MOTUFW_RATE_BASE_MASK          (0x00000008) 
     46#define MOTUFW_RATE_MULTIPLIER_MASK    (0x00000030) 
    4547 
    4648#define MOTUFW_OPTICAL_MODE_OFF        0x00 
    47 #define MOTUFW_OPTICAL_MODE_ADAT    0x01 
     49#define MOTUFW_OPTICAL_MODE_ADAT       0x01 
    4850#define MOTUFW_OPTICAL_MODE_TOSLINK    0x02 
    4951#define MOTUFW_OPTICAL_IN_MODE_MASK    (0x00000300) 
    50 #define MOTUFW_OPTICAL_OUT_MODE_MASK    (0x00000c00) 
    51 #define MOTUFW_OPTICAL_MODE_MASK    (MOTUFW_OPTICAL_IN_MODE_MASK|MOTUFW_OPTICAL_MODE_MASK) 
    52  
    53 #define MOTUFW_CLKSRC_MASK        0x00000007 
    54 #define MOTUFW_CLKSRC_INTERNAL       
    55 #define MOTUFW_CLKSRC_ADAT_OPTICAL   
     52#define MOTUFW_OPTICAL_OUT_MODE_MASK   (0x00000c00) 
     53#define MOTUFW_OPTICAL_MODE_MASK       (MOTUFW_OPTICAL_IN_MODE_MASK|MOTUFW_OPTICAL_MODE_MASK) 
     54 
     55#define MOTUFW_CLKSRC_MASK             0x00000007 
     56#define MOTUFW_CLKSRC_INTERNAL       
     57#define MOTUFW_CLKSRC_ADAT_OPTICAL   
    5658#define MOTUFW_CLKSRC_SPDIF_TOSLINK    2 
    57 #define MOTUFW_CLKSRC_SMTPE       
     59#define MOTUFW_CLKSRC_SMTPE           
    5860#define MOTUFW_CLKSRC_WORDCLOCK        4 
    5961#define MOTUFW_CLKSRC_ADAT_9PIN        5 
    60 #define MOTUFW_CLKSRC_AES_EBU       
    61  
    62 #define MOTUFW_DIR_IN           
    63 #define MOTUFW_DIR_OUT            
    64 #define MOTUFW_DIR_INOUT        (MOTUFW_DIR_IN | MOTUFW_DIR_OUT) 
     62#define MOTUFW_CLKSRC_AES_EBU         
     63 
     64#define MOTUFW_DIR_IN         
     65#define MOTUFW_DIR_OUT         
     66#define MOTUFW_DIR_INOUT       (MOTUFW_DIR_IN | MOTUFW_DIR_OUT) 
    6567 
    6668/* Device registers */ 
    67 #define MOTUFW_REG_ISOCTRL        0x0b00 
    68 #define MOTUFW_REG_OPTICAL_CTRL        0x0b10 
     69#define MOTUFW_REG_ISOCTRL        0x0b00 
     70#define MOTUFW_REG_OPTICAL_CTRL    0x0b10 
    6971#define MOTUFW_REG_CLK_CTRL        0x0b14 
    70 #define MOTUFW_REG_ROUTE_PORT_CONF      0x0c04 
    71 #define MOTUFW_REG_CLKSRC_NAME0        0x0c60 
     72#define MOTUFW_REG_ROUTE_PORT_CONF 0x0c04 
     73#define MOTUFW_REG_CLKSRC_NAME0    0x0c60 
    7274 
    7375/* Port Active Flags (ports declaration) */ 
     
    117119}; 
    118120 
     121struct MixerCtrl { 
     122    const char *name, *label, *desc; 
     123    unsigned int type; 
     124    unsigned int dev_register; 
     125}; 
     126 
    119127struct DevicePropertyEntry { 
    120     const PortEntry* PortsList; 
    121     int PortsListLength; 
    122     int MaxSampleRate; 
     128    const PortEntry* port_entry; 
     129    unsigned int n_port_entries; 
     130    signed int MaxSampleRate; 
     131    const MixerCtrl *mixer_ctrl; 
     132    unsigned int n_mixer_ctrls; 
    123133    // Others features can be added here like MIDI port presence. 
    124134}; 
    125135 
     136/* Macro to calculate the size of an array */ 
     137#define N_ELEMENTS(_array) (sizeof(_array) / sizeof((_array)[0])) 
     138 
    126139class MotuDevice : public FFADODevice { 
     140// Declare mixer controls as friends so they can access the register  
     141// transaction functions. 
     142friend class ChannelFader; 
     143friend class ChannelPan; 
    127144public: 
    128145 
    129146    MotuDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) ); 
    130147    virtual ~MotuDevice(); 
     148 
     149    virtual bool buildMixer(); 
     150    virtual bool destroyMixer(); 
    131151 
    132152    static bool probe( ConfigRom& configRom ); 
     
    182202    signed int WriteRegister(unsigned int reg, quadlet_t data); 
    183203 
     204    Control::Container *m_MixerContainer; 
     205    Control::Container *m_ControlContainer; 
    184206}; 
    185207 
  • trunk/libffado/src/SConscript

    r967 r992  
    144144motu_source = env.Split( '\ 
    145145        motu/motu_avdevice.cpp \ 
     146        motu/motu_controls.cpp \ 
    146147        libstreaming/motu/MotuPort.cpp \ 
    147148        libstreaming/motu/MotuPortInfo.cpp \ 
  • trunk/libffado/support/dbus/control-interface.xml

    r973 r992  
    4242      <method name="getModelId"> 
    4343          <arg type="i" name="modelid" direction="out"/> 
     44      </method> 
     45      <method name="getUnitVersion"> 
     46          <arg type="i" name="unitversion" direction="out"/> 
    4447      </method> 
    4548  </interface> 
  • trunk/libffado/support/dbus/controlserver.cpp

    r973 r992  
    495495} 
    496496 
     497DBus::Int32 
     498ConfigRomX::getUnitVersion( ) 
     499{ 
     500    return m_Slave.getUnitVersion(); 
     501} 
     502 
    497503// --- MatrixMixer 
    498504 
  • trunk/libffado/support/dbus/controlserver.h

    r973 r992  
    211211    DBus::Int32 getVendorId( ); 
    212212    DBus::Int32 getModelId( ); 
     213    DBus::Int32 getUnitVersion( ); 
    213214 
    214215private: 
  • trunk/libffado/support/mixer/ffadomixer.in

    r973 r992  
    4242from mixer_mackie_generic import * 
    4343from mixer_quatafire import * 
     44from mixer_motu import * 
    4445 
    4546SupportedDevices=[ 
     
    5556    [(0x00000f, 0x00010067),'MackieGenericControl'], 
    5657    [(0x000f1b, 0x00010064),'QuataFireMixer'], 
     58    [(0x0001f2, 0x00000000),'MotuMixer'], 
    5759    ] 
    5860 
     
    175177    def getModelId(self): 
    176178        return self.iface.getModelId() 
     179    def getUnitVersion(self): 
     180        return self.iface.getUnitVersion() 
    177181 
    178182class ClockSelectInterface: 
     
    243247        vendorId = cfgrom.getVendorId() 
    244248        modelId = cfgrom.getModelId() 
     249        unitVersion = cfgrom.getUnitVersion() 
    245250        GUID = cfgrom.getGUID() 
    246251        print " Found (%s, %X, %X) %s %s" % (str(GUID), vendorId, modelId, cfgrom.getVendorName(), cfgrom.getModelName()) 
    247252         
    248253        thisdev=(vendorId, modelId); 
     254        # The MOTU devices use unitVersion to differentiate models.  For the 
     255        # moment thought we don't need to know precisely which model we're 
     256        # using. 
     257        if vendorId == 0x1f2: 
     258            thisdev=(vendorId, 0x00000000) 
    249259         
    250260        for dev in SupportedDevices: 
     
    260270                    else: 
    261271                        mixerapp = "SaffireLEMixer" 
    262  
    263272                print mixerapp 
    264273                exec('forms.append('+mixerapp+'())') 
  • trunk/libffado/support/mixer/SConscript

    r971 r992  
    3232        e['MIXERAPPS'] = [ 'phase24', 'phase88', 'saffirepro', 'saffire', 
    3333                           'saffirele', 'af2', 'bcoaudio5', 'edirolfa66', 
    34                            'mackie_generic', 'quatafire'
     34                           'mackie_generic', 'quatafire', 'motu'
    3535        # 
    3636        # For the ffadomixer.in