motu: report the optical control register read from the device when obtaining the...
[ffado.git] / libffado / src / motu / motu_controls.h
blobfe2dc7c2b408b6d72bbd9e3ca708f76c0dc5dceb
1 /*
2 * Copyright (C) 2005-2008 by Daniel Wagner
3 * Copyright (C) 2005-2008 by Pieter Palmers
4 * Copyright (C) 2008-2009 by Jonathan Woithe
6 * This file is part of FFADO
7 * FFADO = Free Firewire (pro-)audio drivers for linux
9 * FFADO is based upon FreeBoB.
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 2 of the License, or
14 * (at your option) version 3 of the License.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 /* DBus controls used with devices which utilise a pre-Mark3 mixer interface */
28 #include "debugmodule/debugmodule.h"
30 #include "libcontrol/BasicElements.h"
31 #include "libcontrol/MatrixMixer.h"
33 namespace Motu {
35 class MotuDevice;
37 #define MOTU_CTRL_CHANNEL_FADER 0x00000001
38 #define MOTU_CTRL_CHANNEL_PAN 0x00000002
39 #define MOTU_CTRL_CHANNEL_SOLO 0x00000004
40 #define MOTU_CTRL_CHANNEL_MUTE 0x00000008
41 #define MOTU_CTRL_MIX_FADER 0x00000100
42 #define MOTU_CTRL_MIX_MUTE 0x00000200
43 #define MOTU_CTRL_MIX_DEST 0x00000400
45 #define MOTU_CTRL_METER 0x00001000
47 #define MOTU_CTRL_INPUT_UL_GAIN 0x00400000 /* Gain on Ultralite channels */
48 #define MOTU_CTRL_INPUT_PHASE_INV 0x00800000
49 #define MOTU_CTRL_INPUT_TRIMGAIN 0x01000000
50 #define MOTU_CTRL_INPUT_PAD 0x02000000
51 #define MOTU_CTRL_INPUT_LEVEL 0x04000000
52 #define MOTU_CTRL_INPUT_BOOST 0x08000000
53 #define MOTU_CTRL_PHONES_SRC 0x10000000
54 #define MOTU_CTRL_OPTICAL_MODE 0x20000000
56 #define MOTU_CTRL_STD_CHANNEL \
57 (MOTU_CTRL_CHANNEL_FADER|MOTU_CTRL_CHANNEL_PAN|\
58 MOTU_CTRL_CHANNEL_SOLO|MOTU_CTRL_CHANNEL_MUTE)
60 #define MOTU_CTRL_STD_MIX \
61 (MOTU_CTRL_MIX_FADER|MOTU_CTRL_MIX_MUTE|\
62 MOTU_CTRL_MIX_DEST)
64 #define MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS \
65 (MOTU_CTRL_INPUT_TRIMGAIN|MOTU_CTRL_INPUT_PAD)
66 #define MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS \
67 (MOTU_CTRL_INPUT_LEVEL|MOTU_CTRL_INPUT_BOOST)
69 #define MOTU_CTRL_ULTRALITE_INPUT_CTRLS \
70 (MOTU_CTRL_INPUT_UL_GAIN|MOTU_CTRL_INPUT_PHASE_INV)
72 #define MOTU_CTRL_MASK_MUTE_VALUE 0x00010000
73 #define MOTU_CTRL_MASK_MUTE_SETENABLE 0x01000000
74 #define MOTU_CTRL_MASK_SOLO_VALUE 0x00020000
75 #define MOTU_CTRL_MASK_SOLO_SETENABLE 0x02000000
77 #define MOTU_CTRL_MASK_ANA5_INPUT_LEVEL 0x00000010
78 #define MOTU_CTRL_MASK_ANA6_INPUT_LEVEL 0x00000020
79 #define MOTU_CTRL_MASK_ANA7_INPUT_LEVEL 0x00000040
80 #define MOTU_CTRL_MASK_ANA8_INPUT_LEVEL 0x00000080
82 #define MOTU_CTRL_MODE_PAD 0x00000000
83 #define MOTU_CTRL_MODE_TRIMGAIN 0x00000001
84 #define MOTU_CTRL_MODE_UL_GAIN 0x00000002
85 #define MOTU_CTRL_MODE_PHASE_INV 0x00000003
87 #define MOTU_CTRL_METER_PEAKHOLD 0x00000001
88 #define MOTU_CTRL_METER_CLIPHOLD 0x00000002
89 #define MOTU_CTRL_METER_AESEBU_SRC 0x00000004
90 #define MOTU_CTRL_METER_PROG_SRC 0x00000008
92 #define MOTU_CTRL_DIR_IN 0x00000001
93 #define MOTU_CTRL_DIR_OUT 0x00000002
94 #define MOTU_CTRL_DIR_INOUT (MOTU_CTRL_DIR_IN | MOTU_CTRL_DIR_OUT)
96 #define MOTU_INFO_MODEL 0x00000001
97 #define MOTU_INFO_IS_STREAMING 0x00000002
98 #define MOTU_INFO_SAMPLE_RATE 0x00000003
100 #define MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL 3
101 #define MOTU_CTRL_GAINPHASEINV_MAX_CHANNEL 9
103 /* A "register" value used to signify that a particular control in a matrix
104 * mixer is not available on the current interface.
106 #define MOTU_CTRL_NONE 0xffffffff
108 class MotuDiscreteCtrl
109 : public Control::Discrete
111 public:
112 MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg);
113 MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg,
114 std::string name, std::string label, std::string descr);
116 virtual bool setValue(int v) = 0;
117 virtual int getValue() = 0;
119 // default implementations
120 virtual bool setValue(int idx, int v)
121 {return setValue(v);};
122 virtual int getValue(int idx)
123 {return getValue();};
125 virtual int getMinimum() {return 0;};
126 virtual int getMaximum() {return 0;};
128 protected:
129 MotuDevice &m_parent;
130 unsigned int m_register;
133 class MotuBinarySwitch
134 : public MotuDiscreteCtrl
136 public:
137 MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
138 unsigned int val_mask, unsigned int setenable_mask);
139 MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
140 unsigned int val_mask, unsigned int setenable_mask,
141 std::string name, std::string label, std::string descr);
143 virtual bool setValue(int v);
144 virtual int getValue();
146 protected:
147 unsigned int m_value_mask;
148 unsigned int m_setenable_mask;
151 class ChannelFader
152 : public MotuDiscreteCtrl
154 public:
155 ChannelFader(MotuDevice &parent, unsigned int dev_reg);
156 ChannelFader(MotuDevice &parent, unsigned int dev_reg,
157 std::string name, std::string label, std::string descr);
159 virtual bool setValue(int v);
160 virtual int getValue();
163 class ChannelPan
164 : public MotuDiscreteCtrl
166 public:
167 ChannelPan(MotuDevice &parent, unsigned int dev_reg);
168 ChannelPan(MotuDevice &parent, unsigned int dev_reg,
169 std::string name, std::string label, std::string descr);
171 virtual bool setValue(int v);
172 virtual int getValue();
175 class MotuMatrixMixer : public Control::MatrixMixer
177 public:
178 MotuMatrixMixer(MotuDevice &parent);
179 MotuMatrixMixer(MotuDevice &parent, std::string name);
180 virtual ~MotuMatrixMixer() {};
182 void addRowInfo(std::string name, unsigned int flags, unsigned int address);
183 void addColInfo(std::string name, unsigned int flags, unsigned int address);
184 uint32_t getCellRegister(const unsigned int row, const unsigned int col);
186 virtual void show();
188 bool hasNames() const { return true; }
189 bool canConnect() const { return false; }
191 virtual std::string getRowName(const int row);
192 virtual std::string getColName(const int col);
193 virtual int canWrite( const int, const int ) { return true; }
194 virtual int getRowCount();
195 virtual int getColCount();
197 // full map updates are unsupported
198 virtual bool getCoefficientMap(int &) {return false;};
199 virtual bool storeCoefficientMap(int &) {return false;};
201 protected:
202 struct sSignalInfo {
203 std::string name;
204 unsigned int flags;
205 unsigned int address;
208 std::vector<struct sSignalInfo> m_RowInfo;
209 std::vector<struct sSignalInfo> m_ColInfo;
211 MotuDevice& m_parent;
214 class ChannelFaderMatrixMixer : public MotuMatrixMixer
216 public:
217 ChannelFaderMatrixMixer(MotuDevice &parent);
218 ChannelFaderMatrixMixer(MotuDevice &parent, std::string name);
219 virtual double setValue(const int row, const int col, const double val);
220 virtual double getValue(const int row, const int col);
223 class ChannelPanMatrixMixer : public MotuMatrixMixer
225 public:
226 ChannelPanMatrixMixer(MotuDevice &parent);
227 ChannelPanMatrixMixer(MotuDevice &parent, std::string name);
228 virtual double setValue(const int row, const int col, const double val);
229 virtual double getValue(const int row, const int col);
232 class ChannelBinSwMatrixMixer : public MotuMatrixMixer
234 public:
235 ChannelBinSwMatrixMixer(MotuDevice &parent);
236 ChannelBinSwMatrixMixer(MotuDevice &parent, std::string name,
237 unsigned int val_mask, unsigned int setenable_mask);
238 virtual double setValue(const int row, const int col, const double val);
239 virtual double getValue(const int row, const int col);
241 protected:
242 unsigned int m_value_mask;
243 unsigned int m_setenable_mask;
248 class MixFader
249 : public MotuDiscreteCtrl
251 public:
252 MixFader(MotuDevice &parent, unsigned int dev_reg);
253 MixFader(MotuDevice &parent, unsigned int dev_reg,
254 std::string name, std::string label, std::string descr);
256 virtual bool setValue(int v);
257 virtual int getValue();
260 class MixMute
261 : public MotuDiscreteCtrl
263 public:
264 MixMute(MotuDevice &parent, unsigned int dev_reg);
265 MixMute(MotuDevice &parent, unsigned int dev_reg,
266 std::string name, std::string label, std::string descr);
268 virtual bool setValue(int v);
269 virtual int getValue();
272 class MixDest
273 : public MotuDiscreteCtrl
275 public:
276 MixDest(MotuDevice &parent, unsigned int dev_reg);
277 MixDest(MotuDevice &parent, unsigned int dev_reg,
278 std::string name, std::string label, std::string descr);
280 virtual bool setValue(int v);
281 virtual int getValue();
284 class PhonesSrc
285 : public MotuDiscreteCtrl
287 public:
288 PhonesSrc(MotuDevice &parent);
289 PhonesSrc(MotuDevice &parent,
290 std::string name, std::string label, std::string descr);
292 virtual bool setValue(int v);
293 virtual int getValue();
296 class OpticalMode
297 : public MotuDiscreteCtrl
299 public:
300 OpticalMode(MotuDevice &parent, unsigned int dev_reg);
301 OpticalMode(MotuDevice &parent, unsigned int dev_reg,
302 std::string name, std::string label, std::string descr);
304 virtual bool setValue(int v);
305 virtual int getValue();
308 class InputGainPadInv
309 : public MotuDiscreteCtrl
311 public:
312 InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode);
313 InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode,
314 std::string name, std::string label, std::string descr);
316 virtual bool setValue(int v);
317 virtual int getValue();
318 protected:
319 void validate();
320 unsigned int dev_register();
321 unsigned int m_mode;
324 class MeterControl
325 : public MotuDiscreteCtrl
327 public:
328 MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift);
329 MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift,
330 std::string name, std::string label, std::string descr);
332 virtual bool setValue(int v);
333 virtual int getValue();
334 protected:
335 void validate();
336 unsigned int m_shift;
339 class InfoElement
340 : public MotuDiscreteCtrl
342 public:
343 InfoElement(MotuDevice &parent, unsigned infotype);
344 InfoElement(MotuDevice &parent, unsigned infotype,
345 std::string name, std::string label, std::string descr);
346 virtual bool setValue(int v);
347 virtual int getValue();