From: <tr...@ff...> - 2008-08-18 23:22:54
|
Author: jwoithe Date: 2008-08-18 16:23:16 -0700 (Mon, 18 Aug 2008) New Revision: 1315 Modified: branches/libffado-2.0/src/motu/motu_avdevice.cpp branches/libffado-2.0/src/motu/motu_avdevice.h branches/libffado-2.0/src/motu/motu_controls.cpp branches/libffado-2.0/src/motu/motu_controls.h branches/libffado-2.0/support/mixer/mixer_motu.py branches/libffado-2.0/support/mixer/mixer_motu.ui Log: MOTU: first cut at supporting the meter controls of the 896HD. Please test and report what works and what doesn't. Modified: branches/libffado-2.0/src/motu/motu_avdevice.cpp =================================================================== --- branches/libffado-2.0/src/motu/motu_avdevice.cpp 2008-08-18 23:21:21 UTC (rev 1314) +++ branches/libffado-2.0/src/motu/motu_avdevice.cpp 2008-08-18 23:23:16 UTC (rev 1315) @@ -301,6 +301,25 @@ {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_DIR_OUT}, }; +const MixerCtrl MixerCtrls_896HD[] = { + {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, + {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, + {"Mix3/Mix_", "Mix 3 ", "", MOTU_CTRL_STD_MIX, 0x0c28, }, + {"Mix4/Mix_", "Mix 4 ", "", MOTU_CTRL_STD_MIX, 0x0c2c, }, + + /* For phones source control, "register" is currently unused */ + {"Control/Phones_", "Phones source", "", MOTU_CTRL_PHONES_SRC, 0}, + + /* For optical mode controls, the "register" is used to indicate direction */ + {"Control/OpticalIn_mode", "Optical input mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_DIR_IN}, + {"Control/OpticalOut_mode", "Optical output mode ", "", MOTU_CTRL_OPTICAL_MODE, MOTU_DIR_OUT}, + + /* For meter controls the "register" indicates which meter controls are available */ + {"Control/Meter_", "Meter ", "", MOTU_CTRL_METER, + MOTU_CTRL_METER_PEAKHOLD | MOTU_CTRL_METER_CLIPHOLD | MOTU_CTRL_METER_AESEBU_SRC | + MOTU_CTRL_METER_PROG_SRC}, +}; + const MixerCtrl MixerCtrls_828Mk2[] = { {"Mix1/Mix_", "Mix 1 ", "", MOTU_CTRL_STD_MIX, 0x0c20, }, {"Mix2/Mix_", "Mix 2 ", "", MOTU_CTRL_STD_MIX, 0x0c24, }, @@ -331,11 +350,8 @@ const MotuMixer Mixer_828Mk2 = MOTUMIXER( MixerCtrls_828Mk2, MixerBuses_Traveler, MixerChannels_Traveler); -// For convenience during initial testing, just make the 896HD use the -// Traveler's mixer definition. Separate definitions for these models will -// come once the final mixer structure is in place. For now it's in a state -// of flux and subject to significant change. -#define Mixer_896HD Mixer_Traveler +const MotuMixer Mixer_896HD = MOTUMIXER( + MixerCtrls_896HD, MixerBuses_Traveler, MixerChannels_Traveler); /* The order of DevicesProperty entries must match the numeric order of the * MOTU model enumeration (EMotuModel). @@ -548,6 +564,37 @@ ctrl->name, ctrl->label, ctrl->desc)); type &= ~MOTU_CTRL_OPTICAL_MODE; } + if (type & MOTU_CTRL_METER) { + if (ctrl->dev_register & MOTU_CTRL_METER_PEAKHOLD) { + snprintf(name, 100, "%s%s", ctrl->name, "peakhold_time"); + snprintf(label,100, "%s%s", ctrl->label,"peakhold time"); + result &= m_MixerContainer->addElement( + new MeterControl(*this, MOTU_METER_PEAKHOLD_MASK, + MOTU_METER_PEAKHOLD_SHIFT, name, label, ctrl->desc)); + } + if (ctrl->dev_register & MOTU_CTRL_METER_CLIPHOLD) { + snprintf(name, 100, "%s%s", ctrl->name, "cliphold_time"); + snprintf(label,100, "%s%s", ctrl->label,"cliphold time"); + result &= m_MixerContainer->addElement( + new MeterControl(*this, MOTU_METER_CLIPHOLD_MASK, + MOTU_METER_CLIPHOLD_SHIFT, name, label, ctrl->desc)); + } + if (ctrl->dev_register & MOTU_CTRL_METER_AESEBU_SRC) { + snprintf(name, 100, "%s%s", ctrl->name, "aesebu_src"); + snprintf(label,100, "%s%s", ctrl->label,"AESEBU source"); + result &= m_MixerContainer->addElement( + new MeterControl(*this, MOTU_METER_AESEBU_SRC_MASK, + MOTU_METER_AESEBU_SRC_SHIFT, name, label, ctrl->desc)); + } + if (ctrl->dev_register & MOTU_CTRL_METER_PROG_SRC) { + snprintf(name, 100, "%s%s", ctrl->name, "src"); + snprintf(label,100, "%s%s", ctrl->label,"source"); + result &= m_MixerContainer->addElement( + new MeterControl(*this, MOTU_METER_PROG_SRC_MASK, + MOTU_METER_PROG_SRC_SHIFT, name, label, ctrl->desc)); + } + type &= ~MOTU_CTRL_METER; + } if (type) { debugOutput(DEBUG_LEVEL_VERBOSE, "Unknown mixer control type flag bits 0x%08x\n", ctrl->type); Modified: branches/libffado-2.0/src/motu/motu_avdevice.h =================================================================== --- branches/libffado-2.0/src/motu/motu_avdevice.h 2008-08-18 23:21:21 UTC (rev 1314) +++ branches/libffado-2.0/src/motu/motu_avdevice.h 2008-08-18 23:23:16 UTC (rev 1315) @@ -67,10 +67,21 @@ #define MOTU_DIR_OUT 2 #define MOTU_DIR_INOUT (MOTU_DIR_IN | MOTU_DIR_OUT) +#define MOTU_METER_PEAKHOLD_MASK 0x3800 +#define MOTU_METER_PEAKHOLD_SHIFT 11 +#define MOTU_METER_CLIPHOLD_MASK 0x0700 +#define MOTU_METER_CLIPHOLD_SHIFT 8 +#define MOTU_METER_AESEBU_SRC_MASK 0x0004 +#define MOTU_METER_AESEBU_SRC_SHIFT 2 +#define MOTU_METER_PROG_SRC_MASK 0x0003 +#define MOTU_METER_PROG_SRC_SHIFT 0 + /* Device registers */ #define MOTU_REG_ISOCTRL 0x0b00 #define MOTU_REG_OPTICAL_CTRL 0x0b10 #define MOTU_REG_CLK_CTRL 0x0b14 +#define MOTU_REG_896HD_METER_REG 0x0b1c +#define MOTU_REG_896HD_METER_CONF 0x0b24 #define MOTU_REG_ROUTE_PORT_CONF 0x0c04 #define MOTU_REG_INPUT_LEVEL 0x0c08 #define MOTU_REG_INPUT_BOOST 0x0c14 Modified: branches/libffado-2.0/src/motu/motu_controls.cpp =================================================================== --- branches/libffado-2.0/src/motu/motu_controls.cpp 2008-08-18 23:21:21 UTC (rev 1314) +++ branches/libffado-2.0/src/motu/motu_controls.cpp 2008-08-18 23:23:16 UTC (rev 1315) @@ -726,6 +726,64 @@ return val; } +MeterControl::MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift) +: MotuDiscreteCtrl(parent, ctrl_mask) +{ + m_shift = ctrl_shift; + validate(); +} + +MeterControl::MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift, + std::string name, std::string label, std::string descr) +: MotuDiscreteCtrl(parent, ctrl_mask, name, label, descr) +{ + m_shift = ctrl_shift; + validate(); +} + +void MeterControl::validate(void) { + if (m_register & (1<< m_shift) == 0) { + debugOutput(DEBUG_LEVEL_VERBOSE, "Inconsistent mask/shift: 0x%08x/%d\n", m_register, m_shift); + } +} + +bool +MeterControl::setValue(int v) +{ + unsigned int val; + debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for meter control 0x%08x/%d: %d\n", + m_register, m_shift, v); + + // Need to get current register setting so we can preserve the parts not + // being controlled by this object. m_register holds the mask for the + // parts we're changing. + val = m_parent.ReadRegister(MOTU_REG_896HD_METER_CONF) & ~m_register; + val |= (v << m_shift) & m_register; + + m_parent.WriteRegister(MOTU_REG_896HD_METER_CONF, val); + + // Drivers under other OSes set MOTU_REG_896HD_METER_REG (0x0b1c) to + // 0x0400 whenever MOTU_REG_896HD_METER_CONF (0x0b24) is changed. + // There's no obvious reason why they do this, but since it's no hassle + // we might as well do the same. + m_parent.WriteRegister(MOTU_REG_896HD_METER_REG, 0x0400); + + return true; +} + +int +MeterControl::getValue() +{ + unsigned int val; + debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for meter control 0x%08x/%d\n", + m_register, m_shift); + + // m_register holds the mask of the part of interest + val = (m_parent.ReadRegister(MOTU_REG_896HD_METER_CONF) & m_register) >> m_shift; + + return val; +} + InfoElement::InfoElement(MotuDevice &parent, unsigned infotype) : MotuDiscreteCtrl(parent, infotype) { Modified: branches/libffado-2.0/src/motu/motu_controls.h =================================================================== --- branches/libffado-2.0/src/motu/motu_controls.h 2008-08-18 23:21:21 UTC (rev 1314) +++ branches/libffado-2.0/src/motu/motu_controls.h 2008-08-18 23:23:16 UTC (rev 1315) @@ -40,6 +40,8 @@ #define MOTU_CTRL_MIX_MUTE 0x00000200 #define MOTU_CTRL_MIX_DEST 0x00000400 +#define MOTU_CTRL_METER 0x00001000 + #define MOTU_CTRL_INPUT_TRIMGAIN 0x01000000 #define MOTU_CTRL_INPUT_PAD 0x02000000 #define MOTU_CTRL_INPUT_LEVEL 0x04000000 @@ -73,6 +75,11 @@ #define MOTU_CTRL_MODE_PAD 0x00000000 #define MOTU_CTRL_MODE_TRIMGAIN 0x00000001 +#define MOTU_CTRL_METER_PEAKHOLD 0x00000000 +#define MOTU_CTRL_METER_CLIPHOLD 0x00000001 +#define MOTU_CTRL_METER_AESEBU_SRC 0x00000002 +#define MOTU_CTRL_METER_PROG_SRC 0x00000004 + #define MOTU_INFO_MODEL 0x00000001 #define MOTU_INFO_IS_STREAMING 0x00000002 #define MOTU_INFO_SAMPLE_RATE 0x00000003 @@ -292,6 +299,21 @@ unsigned int m_mode; }; +class MeterControl + : public MotuDiscreteCtrl +{ +public: + MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift); + MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift, + std::string name, std::string label, std::string descr); + + virtual bool setValue(int v); + virtual int getValue(); +protected: + void validate(); + unsigned int m_shift; +}; + class InfoElement : public MotuDiscreteCtrl { Modified: branches/libffado-2.0/support/mixer/mixer_motu.py =================================================================== --- branches/libffado-2.0/support/mixer/mixer_motu.py 2008-08-18 23:21:21 UTC (rev 1314) +++ branches/libffado-2.0/support/mixer/mixer_motu.py 2008-08-18 23:23:16 UTC (rev 1315) @@ -559,6 +559,11 @@ self.optical_in_mode: ['/Mixer/Control/OpticalIn_mode'], self.optical_out_mode: ['/Mixer/Control/OpticalOut_mode'], + + self.meter_src_ctrl: ['/Mixer/Control/Meter_src'], + self.aesebu_meter_ctrl: ['/Mixer/Control/Meter_aesebu_src'], + self.peakhold_time_ctrl:['/Mixer/Control/Meter_peakhold_time'], + self.cliphold_time_ctrl:['/Mixer/Control/Meter_cliphold_time'], } self.SelectorControls={ @@ -636,6 +641,13 @@ self.optical_in_mode.removeItem(2) self.optical_out_mode.removeItem(2) + # Only the 896HD has meter controls + if (self.model != MOTU_MODEL_896HD): + self.disable_hide(self.meter_src) + self.disable_hide(self.aesebu_meter) + self.disable_hide(self.peakhold_time) + self.disable_hide(self.cliphold_time) + # Some controls must be disabled if the device is streaming if (self.is_streaming): print "Disabling controls which require inactive streaming" Modified: branches/libffado-2.0/support/mixer/mixer_motu.ui =================================================================== --- branches/libffado-2.0/support/mixer/mixer_motu.ui 2008-08-18 23:21:21 UTC (rev 1314) +++ branches/libffado-2.0/support/mixer/mixer_motu.ui 2008-08-18 23:23:16 UTC (rev 1315) @@ -26,7 +26,7 @@ <rect> <x>0</x> <y>0</y> - <width>958</width> + <width>992</width> <height>693</height> </rect> </property> @@ -251,6 +251,249 @@ </widget> </vbox> </widget> + <widget class="Line"> + <property name="name"> + <cstring>line2_2</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>meter_src</cstring> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="title"> + <string>Meter source</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QComboBox"> + <item> + <property name="text"> + <string>Analog out</string> + </property> + </item> + <item> + <property name="text"> + <string>ADAT in</string> + </property> + </item> + <item> + <property name="text"> + <string>ADAT out</string> + </property> + </item> + <property name="name"> + <cstring>meter_src_ctrl</cstring> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>aesebu_meter</cstring> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="title"> + <string>AES/EBU Meter</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QComboBox"> + <item> + <property name="text"> + <string>AES/EBU out</string> + </property> + </item> + <item> + <property name="text"> + <string>AES/EBU in</string> + </property> + </item> + <property name="name"> + <cstring>aesebu_meter_ctrl</cstring> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>peakhold_time</cstring> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="title"> + <string>Peakhold time</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QComboBox"> + <item> + <property name="text"> + <string>Off</string> + </property> + </item> + <item> + <property name="text"> + <string>2 sec</string> + </property> + </item> + <item> + <property name="text"> + <string>4 sec</string> + </property> + </item> + <item> + <property name="text"> + <string>10 sec</string> + </property> + </item> + <item> + <property name="text"> + <string>1 min</string> + </property> + </item> + <item> + <property name="text"> + <string>5 min</string> + </property> + </item> + <item> + <property name="text"> + <string>8 min</string> + </property> + </item> + <item> + <property name="text"> + <string>infinite</string> + </property> + </item> + <property name="name"> + <cstring>peakhold_time_ctrl</cstring> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>cliphold_time</cstring> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="title"> + <string>Cliphold time</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QComboBox"> + <item> + <property name="text"> + <string>Off</string> + </property> + </item> + <item> + <property name="text"> + <string>2 sec</string> + </property> + </item> + <item> + <property name="text"> + <string>4 sec</string> + </property> + </item> + <item> + <property name="text"> + <string>10 sec</string> + </property> + </item> + <item> + <property name="text"> + <string>1 min</string> + </property> + </item> + <item> + <property name="text"> + <string>5 min</string> + </property> + </item> + <item> + <property name="text"> + <string>8 min</string> + </property> + </item> + <item> + <property name="text"> + <string>infinite</string> + </property> + </item> + <property name="name"> + <cstring>cliphold_time_ctrl</cstring> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + </widget> + </vbox> + </widget> <spacer> <property name="name"> <cstring>spacer183</cstring> @@ -264,7 +507,7 @@ <property name="sizeHint"> <size> <width>20</width> - <height>321</height> + <height>220</height> </size> </property> </spacer> |