Show
Ignore:
Timestamp:
04/27/08 17:56:21 (16 years ago)
Author:
jwoithe
Message:

* MOTU: Make optical mode control functional. It still needs to have the toslink option disabled for the likes of the 896HD which don't have this capability.
* MOTU: Implement channel pad and trimgain controls.
* MOTU: Minor updates to protocol documentation.

Files:

Legend:

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

    r1006 r1056  
    260260    {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, 
    261261 
    262     /* For line input controls, the "register" is the zero-based channel number */ 
     262    /* For mic/line input controls, the "register" is the zero-based channel number */ 
     263    {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 0}, 
     264    {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 1}, 
     265    {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 2}, 
     266    {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS, 3}, 
    263267    {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 4}, 
    264268    {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 5}, 
     
    416420                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].desc)); 
    417421            type &= ~MOTU_CTRL_MIX_DEST; 
     422        } 
     423 
     424        if (type & MOTU_CTRL_INPUT_TRIMGAIN) { 
     425            snprintf(name, 100, "%s%s", DevicesProperty[m_motu_model-1].mixer_ctrl[i].name, "trimgain"); 
     426            snprintf(label,100, "%s%s", DevicesProperty[m_motu_model-1].mixer_ctrl[i].label,"trimgain"); 
     427            result &= m_MixerContainer->addElement( 
     428                new InputGainPad(*this,  
     429                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].dev_register, MOTU_CTRL_MODE_TRIMGAIN, 
     430                    name, label, 
     431                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].desc)); 
     432            type &= ~MOTU_CTRL_INPUT_TRIMGAIN; 
     433        } 
     434        if (type & MOTU_CTRL_INPUT_PAD) { 
     435            snprintf(name, 100, "%s%s", DevicesProperty[m_motu_model-1].mixer_ctrl[i].name, "pad"); 
     436            snprintf(label,100, "%s%s", DevicesProperty[m_motu_model-1].mixer_ctrl[i].label,"pad"); 
     437            result &= m_MixerContainer->addElement( 
     438                new InputGainPad(*this,  
     439                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].dev_register, MOTU_CTRL_MODE_PAD, 
     440                    name, label, 
     441                    DevicesProperty[m_motu_model-1].mixer_ctrl[i].desc)); 
     442            type &= ~MOTU_CTRL_INPUT_PAD; 
    418443        } 
    419444 
  • trunk/libffado/src/motu/motu_avdevice.h

    r1003 r1056  
    6767 
    6868/* Device registers */ 
    69 #define MOTU_REG_ISOCTRL         0x0b00 
    70 #define MOTU_REG_OPTICAL_CTRL    0x0b10 
    71 #define MOTU_REG_CLK_CTRL        0x0b14 
    72 #define MOTU_REG_ROUTE_PORT_CONF 0x0c04 
    73 #define MOTU_REG_INPUT_LEVEL     0x0c08 
    74 #define MOTU_REG_INPUT_BOOST     0x0c14 
    75 #define MOTU_REG_INPUT_GAIN_PAD  0x0c1c 
    76 #define MOTU_REG_CLKSRC_NAME0    0x0c60 
     69#define MOTU_REG_ISOCTRL           0x0b00 
     70#define MOTU_REG_OPTICAL_CTRL      0x0b10 
     71#define MOTU_REG_CLK_CTRL          0x0b14 
     72#define MOTU_REG_ROUTE_PORT_CONF   0x0c04 
     73#define MOTU_REG_INPUT_LEVEL       0x0c08 
     74#define MOTU_REG_INPUT_BOOST       0x0c14 
     75#define MOTU_REG_INPUT_GAIN_PAD_0  0x0c1c 
     76#define MOTU_REG_CLKSRC_NAME0      0x0c60 
    7777 
    7878/* Port Active Flags (ports declaration) */ 
  • trunk/libffado/src/motu/motu_controls.cpp

    r1006 r1056  
    378378    // Need to get current optical modes so we can preserve the one we're 
    379379    // not setting.  Input mode is in bits 9-8, output is in bits 11-10. 
    380     val = m_parent.ReadRegister(MOTU_REG_ROUTE_PORT_CONF) & 0x000000f0; 
     380    val = m_parent.ReadRegister(MOTU_REG_ROUTE_PORT_CONF) & 0x00000f00; 
    381381 
    382382    // Set mode as requested.  An invalid setting is effectively ignored. 
    383     if (v>=0 && v>=3) { 
     383    if (v>=0 && v<=3) { 
    384384      if (m_register == MOTU_DIR_IN) { 
    385         val = (val & ~0x0030) | ((v & 0x03) << 8); 
     385        val = (val & ~0x0300) | ((v & 0x03) << 8); 
    386386      } else { 
    387         val = (val & ~0x00c0) | ((v & 0x03) << 10); 
     387        val = (val & ~0x0c00) | ((v & 0x03) << 10); 
    388388      } 
    389389    } 
     
    408408    else 
    409409      val = (val >> 10) & 0x03; 
     410    return val; 
     411} 
     412 
     413InputGainPad::InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode) 
     414: MotuDiscreteCtrl(parent, channel) 
     415{ 
     416    m_mode = mode; 
     417    validate(); 
     418} 
     419 
     420InputGainPad::InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode, 
     421             std::string name, std::string label, std::string descr) 
     422: MotuDiscreteCtrl(parent, channel, name, label, descr) 
     423{ 
     424    m_mode = mode; 
     425    validate(); 
     426} 
     427 
     428void InputGainPad::validate(void) { 
     429    if (m_register > MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL) { 
     430        debugOutput(DEBUG_LEVEL_VERBOSE, "Invalid channel %d: max supported is %d, assuming 0\n",  
     431            m_register, MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL); 
     432        m_register = 0; 
     433    } 
     434    if (m_mode!=MOTU_CTRL_MODE_PAD && m_mode!=MOTU_CTRL_MODE_TRIMGAIN) { 
     435        debugOutput(DEBUG_LEVEL_VERBOSE, "Invalid mode %d, assuming %d\n", m_mode, MOTU_CTRL_MODE_PAD); 
     436        m_mode = MOTU_CTRL_MODE_PAD; 
     437    } 
     438} 
     439 
     440unsigned int InputGainPad::dev_register(void) { 
     441    /* Work out the device register to use for the associated channel */ 
     442    if (m_register>=0 && m_register<=3) { 
     443      return MOTU_REG_INPUT_GAIN_PAD_0;       
     444    } else { 
     445      debugOutput(DEBUG_LEVEL_VERBOSE, "unsupported channel %d\n", m_register); 
     446    } 
     447    return 0; 
     448} 
     449              
     450bool 
     451InputGainPad::setValue(int v) 
     452{ 
     453    unsigned int val; 
     454    unsigned int reg, reg_shift; 
     455    debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for mode %d input pad/trim %d to %d\n", m_mode, m_register, v); 
     456 
     457    reg = dev_register(); 
     458    if (reg == 0) 
     459        return false; 
     460    reg_shift = (m_register & 0x03) * 8; 
     461 
     462    // Need to get current gain trim / pad value so we can preserve one 
     463    // while setting the other.  The pad status is in bit 6 of the channel's 
     464    // respective byte with the trim in bits 0-5.  Bit 7 is the write enable 
     465    // bit for the channel. 
     466    val = m_parent.ReadRegister(reg) & (0xff << reg_shift); 
     467 
     468    switch (m_mode) { 
     469        case MOTU_CTRL_MODE_PAD: 
     470            // Set pad bit (bit 6 of relevant channel's byte) 
     471            if (v == 0) { 
     472                val &= ~(0x40 << reg_shift); 
     473            } else { 
     474                val |= (0x40 << reg_shift); 
     475            } 
     476            break; 
     477      case MOTU_CTRL_MODE_TRIMGAIN: 
     478            // Set the gain trim (bits 0-5 of the channel's byte).  Maximum 
     479            // gain is 53 dB. 
     480            if (v > 0x35) 
     481                v = 0x35; 
     482            val = (val & ~(0x3f << reg_shift)) | (v << reg_shift); 
     483            break; 
     484      default: 
     485        debugOutput(DEBUG_LEVEL_VERBOSE, "unsupported mode %d\n", m_mode); 
     486        return false; 
     487    } 
     488 
     489    // Set the channel's write enable bit 
     490    val |= (0x80 << reg_shift); 
     491 
     492    m_parent.WriteRegister(reg, val); 
     493 
     494    return true; 
     495} 
     496 
     497int 
     498InputGainPad::getValue() 
     499{ 
     500    unsigned int val; 
     501    unsigned int reg, reg_shift; 
     502    debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for mode %d input pad/trim %d\n", m_mode, m_register); 
     503 
     504    reg = dev_register(); 
     505    if (reg == 0) 
     506        return false; 
     507    reg_shift = (m_register & 0x03) * 8; 
     508 
     509    // The pad status is in bit 6 of the channel's respective byte with the 
     510    // trim in bits 0-5.  Bit 7 is the write enable bit for the channel. 
     511    val = m_parent.ReadRegister(reg); 
     512 
     513    switch (m_mode) { 
     514        case MOTU_CTRL_MODE_PAD: 
     515            val = ((val >> reg_shift) & 0x40) != 0; 
     516            break; 
     517      case MOTU_CTRL_MODE_TRIMGAIN: 
     518            val = ((val >> reg_shift) & 0x3f); 
     519            break; 
     520      default: 
     521        debugOutput(DEBUG_LEVEL_VERBOSE, "unsupported mode %d\n", m_mode); 
     522        return 0; 
     523    } 
     524 
    410525    return val; 
    411526} 
  • trunk/libffado/src/motu/motu_controls.h

    r1006 r1056  
    4141#define MOTU_CTRL_MIX_DEST        0x00000400 
    4242 
    43 #define MOTU_CTRL_INPUT_LEVEL     0x10000000 
    44 #define MOTU_CTRL_INPUT_BOOST     0x20000000 
    45 #define MOTU_CTRL_PHONES_SRC      0x40000000 
    46 #define MOTU_CTRL_OPTICAL_MODE    0x80000000 
     43#define MOTU_CTRL_INPUT_TRIMGAIN  0x01000000 
     44#define MOTU_CTRL_INPUT_PAD       0x02000000 
     45#define MOTU_CTRL_INPUT_LEVEL     0x04000000 
     46#define MOTU_CTRL_INPUT_BOOST     0x08000000 
     47#define MOTU_CTRL_PHONES_SRC      0x10000000 
     48#define MOTU_CTRL_OPTICAL_MODE    0x20000000 
    4749 
    4850#define MOTU_CTRL_STD_CHANNEL \ 
     
    5456     MOTU_CTRL_MIX_DEST) 
    5557 
     58#define MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS \ 
     59    (MOTU_CTRL_INPUT_TRIMGAIN|MOTU_CTRL_INPUT_PAD) 
    5660#define MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS \ 
    5761    (MOTU_CTRL_INPUT_LEVEL|MOTU_CTRL_INPUT_BOOST) 
     
    6670#define MOTU_CTRL_MASK_ANA7_INPUT_LEVEL    0x00000040 
    6771#define MOTU_CTRL_MASK_ANA8_INPUT_LEVEL    0x00000080 
     72 
     73#define MOTU_CTRL_MODE_PAD                 0x00000000 
     74#define MOTU_CTRL_MODE_TRIMGAIN            0x00000001 
    6875 
    6976#define MOTU_INFO_IS_STREAMING             0x00000001 
     
    7380#define MOTU_INFO_HAS_SPDIF_INPUTS         0x00000005 
    7481 
     82#define MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL  3 
     83 
    7584class MotuDiscreteCtrl 
    7685    : public Control::Discrete 
     
    188197}; 
    189198 
     199class InputGainPad 
     200    : public MotuDiscreteCtrl 
     201{ 
     202public: 
     203    InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode); 
     204    InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode,  
     205          std::string name, std::string label, std::string descr); 
     206 
     207    virtual bool setValue(int v); 
     208    virtual int getValue(); 
     209protected: 
     210    void validate(); 
     211    unsigned int dev_register(); 
     212    unsigned int m_mode; 
     213}; 
     214 
    190215class InfoElement 
    191216    : public MotuDiscreteCtrl