Changeset 1506

Show
Ignore:
Timestamp:
12/07/08 14:30:13 (12 years ago)
Author:
jwoithe
Message:

MOTU: more groundwork to support the channel gains and phase inversion switches on the Ultralite. Please test this on other interfaces to ensure I haven't accidently broken anything for other users.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/src/motu/motu_avdevice.cpp

    r1485 r1506  
    390390 
    391391    /* For mic/line input controls, the "register" is the zero-based channel number */ 
    392     {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 0}, 
    393     {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 1}, 
    394     {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 2}, 
    395     {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 3}, 
    396     {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 4}, 
    397     {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 5}, 
    398     {"Control/Ana7_", "Analog 7 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 6}, 
    399     {"Control/Ana8_", "Analog 8 input ", "", MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS, 7}, 
     392    {"Control/Ana1_", "Analog 1 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 0}, 
     393    {"Control/Ana2_", "Analog 2 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 1}, 
     394    {"Control/Ana3_", "Analog 3 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 2}, 
     395    {"Control/Ana4_", "Analog 4 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 3}, 
     396    {"Control/Ana5_", "Analog 5 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 4}, 
     397    {"Control/Ana6_", "Analog 6 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 5}, 
     398    {"Control/Ana7_", "Analog 7 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 6}, 
     399    {"Control/Ana8_", "Analog 8 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 7}, 
     400    {"Control/Spdif1_", "SPDIF 1 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 6}, 
     401    {"Control/Spdif2_", "SPDIF 2 input ", "", MOTU_CTRL_ULTRALITE_INPUT_CTRLS, 7}, 
    400402 
    401403    /* For phones source control, "register" is currently unused */ 
     
    645647        } 
    646648 
     649        if (type & MOTU_CTRL_INPUT_UL_GAIN) { 
     650            snprintf(name, 100, "%s%s", ctrl->name, "trimgain"); 
     651            snprintf(label,100, "%s%s", ctrl->label,"trimgain"); 
     652            result &= m_MixerContainer->addElement( 
     653                new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_UL_GAIN, 
     654                    name, label, ctrl->desc)); 
     655            type &= ~MOTU_CTRL_INPUT_UL_GAIN; 
     656        } 
     657        if (type & MOTU_CTRL_INPUT_PHASE_INV) { 
     658            snprintf(name, 100, "%s%s", ctrl->name, "phaseinv"); 
     659            snprintf(label,100, "%s%s", ctrl->label,"phaseinv"); 
     660            result &= m_MixerContainer->addElement( 
     661                new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_PHASE_INV, 
     662                    name, label, ctrl->desc)); 
     663            type &= ~MOTU_CTRL_INPUT_PHASE_INV; 
     664        } 
    647665        if (type & MOTU_CTRL_INPUT_TRIMGAIN) { 
    648666            snprintf(name, 100, "%s%s", ctrl->name, "trimgain"); 
    649667            snprintf(label,100, "%s%s", ctrl->label,"trimgain"); 
    650668            result &= m_MixerContainer->addElement( 
    651                 new InputGainPad(*this, ctrl->dev_register, MOTU_CTRL_MODE_TRIMGAIN, 
     669                new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_TRIMGAIN, 
    652670                    name, label, ctrl->desc)); 
    653671            type &= ~MOTU_CTRL_INPUT_TRIMGAIN; 
     
    657675            snprintf(label,100, "%s%s", ctrl->label,"pad"); 
    658676            result &= m_MixerContainer->addElement( 
    659                 new InputGainPad(*this, ctrl->dev_register, MOTU_CTRL_MODE_PAD, 
     677                new InputGainPadInv(*this, ctrl->dev_register, MOTU_CTRL_MODE_PAD, 
    660678                    name, label, ctrl->desc)); 
    661679            type &= ~MOTU_CTRL_INPUT_PAD; 
  • branches/libffado-2.0/src/motu/motu_avdevice.h

    r1423 r1506  
    8585#define MOTU_REG_INPUT_GAIN_PAD_0  0x0c1c 
    8686#define MOTU_REG_CLKSRC_NAME0      0x0c60 
     87#define MOTU_REG_INPUT_GAIN_PHINV0 0x0c70 
     88#define MOTU_REG_INPUT_GAIN_PHINV1 0x0c74 
     89#define MOTU_REG_INPUT_GAIN_PHINV2 0x0c78 
    8790 
    8891/* Port Active Flags (ports declaration) */ 
  • branches/libffado-2.0/src/motu/motu_controls.cpp

    r1478 r1506  
    723723} 
    724724 
    725 InputGainPad::InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode) 
     725InputGainPadInv::InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode) 
    726726: MotuDiscreteCtrl(parent, channel) 
    727727{ 
     
    730730} 
    731731 
    732 InputGainPad::InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode, 
     732InputGainPadInv::InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode, 
    733733             std::string name, std::string label, std::string descr) 
    734734: MotuDiscreteCtrl(parent, channel, name, label, descr) 
     
    738738} 
    739739 
    740 void InputGainPad::validate(void) { 
    741     if (m_register > MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL) { 
     740void InputGainPadInv::validate(void) { 
     741    if ((m_mode==MOTU_CTRL_MODE_PAD || m_mode==MOTU_CTRL_MODE_TRIMGAIN) && 
     742        m_register>MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL) { 
    742743        debugOutput(DEBUG_LEVEL_VERBOSE, "Invalid channel %d: max supported is %d, assuming 0\n",  
    743744            m_register, MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL); 
    744745        m_register = 0; 
    745746    } 
    746     if (m_mode!=MOTU_CTRL_MODE_PAD && m_mode!=MOTU_CTRL_MODE_TRIMGAIN) { 
     747    if ((m_mode==MOTU_CTRL_MODE_UL_GAIN || m_mode==MOTU_CTRL_MODE_PHASE_INV) && 
     748        m_register>MOTU_CTRL_GAINPHASEINV_MAX_CHANNEL) { 
     749        debugOutput(DEBUG_LEVEL_VERBOSE, "Invalid ultralite channel %d: max supported is %d, assuming 0\n",  
     750            m_register, MOTU_CTRL_GAINPHASEINV_MAX_CHANNEL); 
     751        m_register = 0; 
     752    } 
     753    if (m_mode!=MOTU_CTRL_MODE_PAD && m_mode!=MOTU_CTRL_MODE_TRIMGAIN && 
     754        m_mode!=MOTU_CTRL_MODE_UL_GAIN && m_mode!=MOTU_CTRL_MODE_PHASE_INV) { 
    747755        debugOutput(DEBUG_LEVEL_VERBOSE, "Invalid mode %d, assuming %d\n", m_mode, MOTU_CTRL_MODE_PAD); 
    748756        m_mode = MOTU_CTRL_MODE_PAD; 
     
    750758} 
    751759 
    752 unsigned int InputGainPad::dev_register(void) { 
     760unsigned int InputGainPadInv::dev_register(void) { 
    753761    /* Work out the device register to use for the associated channel */ 
    754     if (m_register>=0 && m_register<=3) { 
    755       return MOTU_REG_INPUT_GAIN_PAD_0;       
     762    /* Registers for gain/phase inversion controls on the Ultralite differ from those 
     763     * of other devices. 
     764     */ 
     765    if (m_mode==MOTU_CTRL_MODE_PAD || m_mode==MOTU_CTRL_MODE_TRIMGAIN) { 
     766       if (m_register>=0 && m_register<=3) { 
     767          return MOTU_REG_INPUT_GAIN_PAD_0;       
     768       } else { 
     769          debugOutput(DEBUG_LEVEL_VERBOSE, "unsupported channel %d\n", m_register); 
     770       } 
    756771    } else { 
    757       debugOutput(DEBUG_LEVEL_VERBOSE, "unsupported channel %d\n", m_register); 
     772       if (m_register>=0 && m_register<=3) 
     773          return MOTU_REG_INPUT_GAIN_PHINV0; 
     774       else if (m_register>=4 && m_register<=7) 
     775          return MOTU_REG_INPUT_GAIN_PHINV1; 
     776       else if (m_register>=8 && m_register<=11) 
     777          return MOTU_REG_INPUT_GAIN_PHINV2; 
     778       else { 
     779          debugOutput(DEBUG_LEVEL_VERBOSE, "unsupported ultralite channel %d\n", m_register); 
     780       } 
    758781    } 
    759782    return 0; 
     
    761784              
    762785bool 
    763 InputGainPad::setValue(int v) 
     786InputGainPadInv::setValue(int v) 
    764787{ 
    765788    unsigned int val; 
     
    785808    switch (m_mode) { 
    786809        case MOTU_CTRL_MODE_PAD: 
    787             // Set pad bit (bit 6 of relevant channel's byte) 
     810        case MOTU_CTRL_MODE_PHASE_INV: 
     811            // Set pad/phase inversion bit (bit 6 of relevant channel's byte) 
    788812            if (v == 0) { 
    789813                val &= ~(0x40 << reg_shift); 
     
    793817            break; 
    794818      case MOTU_CTRL_MODE_TRIMGAIN: 
     819      case MOTU_CTRL_MODE_UL_GAIN: 
    795820            // Set the gain trim (bits 0-5 of the channel's byte).  Maximum 
    796             // gain is 53 dB. 
    797             if (v > 0x35) 
    798                 v = 0x35; 
     821            // gain is 53 dB for trimgain on non-ultralite devices.  For 
     822            // ultralites, mic inputs max out at 0x18, line inputs at 0x12 
     823            // and spdif inputs at 0x0c.  We just clip at 0x18 for now. 
     824            if (m_mode==MOTU_CTRL_MODE_TRIMGAIN) { 
     825               if (v > 0x35) 
     826                  v = 0x35; 
     827            } else { 
     828               if (v > 0x18) 
     829                  v = 0x18; 
     830            } 
    799831            val = (val & ~(0x3f << reg_shift)) | (v << reg_shift); 
    800832            break; 
     
    813845 
    814846int 
    815 InputGainPad::getValue() 
     847InputGainPadInv::getValue() 
    816848{ 
    817849    unsigned int val; 
     
    829861    reg_shift = (m_register & 0x03) * 8; 
    830862 
    831     // The pad status is in bit 6 of the channel's respective byte with the 
    832     // trim in bits 0-5.  Bit 7 is the write enable bit for the channel. 
     863    // The pad/phase inversion status is in bit 6 of the channel's 
     864    // respective byte with the trim in bits 0-5.  Bit 7 is the write enable 
     865    // bit for the channel. 
    833866    val = m_parent.ReadRegister(reg); 
    834867 
    835868    switch (m_mode) { 
    836         case MOTU_CTRL_MODE_PAD: 
    837             val = ((val >> reg_shift) & 0x40) != 0; 
    838             break; 
    839       case MOTU_CTRL_MODE_TRIMGAIN: 
    840             val = ((val >> reg_shift) & 0x3f); 
    841             break; 
    842       default: 
    843         debugOutput(DEBUG_LEVEL_VERBOSE, "unsupported mode %d\n", m_mode); 
    844         return 0; 
     869       case MOTU_CTRL_MODE_PAD: 
     870       case MOTU_CTRL_MODE_PHASE_INV: 
     871          val = ((val >> reg_shift) & 0x40) != 0; 
     872          break; 
     873       case MOTU_CTRL_MODE_TRIMGAIN: 
     874       case MOTU_CTRL_MODE_UL_GAIN: 
     875          val = ((val >> reg_shift) & 0x3f); 
     876          break; 
     877       default: 
     878          debugOutput(DEBUG_LEVEL_VERBOSE, "unsupported mode %d\n", m_mode); 
     879          return 0; 
    845880    } 
    846881 
  • branches/libffado-2.0/src/motu/motu_controls.h

    r1418 r1506  
    4343#define MOTU_CTRL_METER           0x00001000 
    4444 
     45#define MOTU_CTRL_INPUT_UL_GAIN   0x00400000  /* Gain on Ultralite channels */ 
     46#define MOTU_CTRL_INPUT_PHASE_INV 0x00800000 
    4547#define MOTU_CTRL_INPUT_TRIMGAIN  0x01000000 
    4648#define MOTU_CTRL_INPUT_PAD       0x02000000 
     
    6365    (MOTU_CTRL_INPUT_LEVEL|MOTU_CTRL_INPUT_BOOST) 
    6466 
     67#define MOTU_CTRL_ULTRALITE_INPUT_CTRLS \ 
     68    (MOTU_CTRL_INPUT_TRIMGAIN|MOTU_CTRL_INPUT_PHASE_INV) 
     69 
    6570#define MOTU_CTRL_MASK_MUTE_VALUE          0x00010000 
    6671#define MOTU_CTRL_MASK_MUTE_SETENABLE      0x01000000 
     
    7580#define MOTU_CTRL_MODE_PAD                 0x00000000 
    7681#define MOTU_CTRL_MODE_TRIMGAIN            0x00000001 
     82#define MOTU_CTRL_MODE_UL_GAIN             0x00000002 
     83#define MOTU_CTRL_MODE_PHASE_INV           0x00000003 
    7784 
    7885#define MOTU_CTRL_METER_PEAKHOLD           0x00000001 
     
    94101 
    95102#define MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL  3 
     103#define MOTU_CTRL_GAINPHASEINV_MAX_CHANNEL 9 
    96104 
    97105/* A "register" value used to signify that a particular control in a matrix 
     
    293301}; 
    294302 
    295 class InputGainPad 
    296     : public MotuDiscreteCtrl 
    297 { 
    298 public: 
    299     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode); 
    300     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode,  
     303class InputGainPadInv 
     304    : public MotuDiscreteCtrl 
     305{ 
     306public: 
     307    InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode); 
     308    InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode,  
    301309          std::string name, std::string label, std::string descr); 
    302310 
  • branches/libffado-2.0/support/mixer-qt4/mixer_motu.py

    r1494 r1506  
    728728            self.disable_hide(self.ana7_pad) 
    729729            self.disable_hide(self.ana8_pad) 
     730        elif (self.model == MOTU_MODEL_ULTRALITE): 
     731            self.disable_hide(self.ana1_level) 
     732            self.disable_hide(self.ana2_level) 
     733            self.disable_hide(self.ana3_level) 
     734            self.disable_hide(self.ana4_level) 
     735            self.disable_hide(self.ana5_level) 
     736            self.disable_hide(self.ana6_level) 
     737            self.disable_hide(self.ana7_level) 
     738            self.disable_hide(self.ana8_level) 
     739            self.disable_hide(self.ana1_boost) 
     740            self.disable_hide(self.ana2_boost) 
     741            self.disable_hide(self.ana3_boost) 
     742            self.disable_hide(self.ana4_boost) 
     743            self.disable_hide(self.ana5_boost) 
     744            self.disable_hide(self.ana6_boost) 
     745            self.disable_hide(self.ana7_boost) 
     746            self.disable_hide(self.ana8_boost) 
     747 
     748            # FIXME: Need to set the label of the pad controls to "Phase Inv" or 
     749            # something similar 
     750 
    730751        else: 
    731752            self.disable_hide(self.ana1_trimgain)