root/trunk/libffado/src/motu/motu_controls.h

Revision 1742, 10.3 kB (checked in by arnonym, 11 years ago)

Extend the interface of the MatrixMixer?:

  • Have booleans indicating if names and/or connections are supported. These functions are pure virtual.
  • Allow names and connections to be read and written, the default implementations of these (not anymore pure) virtual functions do nothing and return false or nothing.
Line 
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
5  *
6  * This file is part of FFADO
7  * FFADO = Free Firewire (pro-)audio drivers for linux
8  *
9  * FFADO is based upon FreeBoB.
10  *
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.
15  *
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.
20  *
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/>.
23  *
24  */
25
26 #include "debugmodule/debugmodule.h"
27
28 #include "libcontrol/BasicElements.h"
29 #include "libcontrol/MatrixMixer.h"
30
31 namespace Motu {
32
33 class MotuDevice;
34
35 #define MOTU_CTRL_CHANNEL_FADER   0x00000001
36 #define MOTU_CTRL_CHANNEL_PAN     0x00000002
37 #define MOTU_CTRL_CHANNEL_SOLO    0x00000004
38 #define MOTU_CTRL_CHANNEL_MUTE    0x00000008
39 #define MOTU_CTRL_MIX_FADER       0x00000100
40 #define MOTU_CTRL_MIX_MUTE        0x00000200
41 #define MOTU_CTRL_MIX_DEST        0x00000400
42
43 #define MOTU_CTRL_METER           0x00001000
44
45 #define MOTU_CTRL_INPUT_UL_GAIN   0x00400000  /* Gain on Ultralite channels */
46 #define MOTU_CTRL_INPUT_PHASE_INV 0x00800000
47 #define MOTU_CTRL_INPUT_TRIMGAIN  0x01000000
48 #define MOTU_CTRL_INPUT_PAD       0x02000000
49 #define MOTU_CTRL_INPUT_LEVEL     0x04000000
50 #define MOTU_CTRL_INPUT_BOOST     0x08000000
51 #define MOTU_CTRL_PHONES_SRC      0x10000000
52 #define MOTU_CTRL_OPTICAL_MODE    0x20000000
53
54 #define MOTU_CTRL_STD_CHANNEL \
55     (MOTU_CTRL_CHANNEL_FADER|MOTU_CTRL_CHANNEL_PAN|\
56      MOTU_CTRL_CHANNEL_SOLO|MOTU_CTRL_CHANNEL_MUTE)
57
58 #define MOTU_CTRL_STD_MIX \
59     (MOTU_CTRL_MIX_FADER|MOTU_CTRL_MIX_MUTE|\
60      MOTU_CTRL_MIX_DEST)
61
62 #define MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS \
63     (MOTU_CTRL_INPUT_TRIMGAIN|MOTU_CTRL_INPUT_PAD)
64 #define MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS \
65     (MOTU_CTRL_INPUT_LEVEL|MOTU_CTRL_INPUT_BOOST)
66
67 #define MOTU_CTRL_ULTRALITE_INPUT_CTRLS \
68     (MOTU_CTRL_INPUT_UL_GAIN|MOTU_CTRL_INPUT_PHASE_INV)
69
70 #define MOTU_CTRL_MASK_MUTE_VALUE          0x00010000
71 #define MOTU_CTRL_MASK_MUTE_SETENABLE      0x01000000
72 #define MOTU_CTRL_MASK_SOLO_VALUE          0x00020000
73 #define MOTU_CTRL_MASK_SOLO_SETENABLE      0x02000000
74
75 #define MOTU_CTRL_MASK_ANA5_INPUT_LEVEL    0x00000010
76 #define MOTU_CTRL_MASK_ANA6_INPUT_LEVEL    0x00000020
77 #define MOTU_CTRL_MASK_ANA7_INPUT_LEVEL    0x00000040
78 #define MOTU_CTRL_MASK_ANA8_INPUT_LEVEL    0x00000080
79
80 #define MOTU_CTRL_MODE_PAD                 0x00000000
81 #define MOTU_CTRL_MODE_TRIMGAIN            0x00000001
82 #define MOTU_CTRL_MODE_UL_GAIN             0x00000002
83 #define MOTU_CTRL_MODE_PHASE_INV           0x00000003
84
85 #define MOTU_CTRL_METER_PEAKHOLD           0x00000001
86 #define MOTU_CTRL_METER_CLIPHOLD           0x00000002
87 #define MOTU_CTRL_METER_AESEBU_SRC         0x00000004
88 #define MOTU_CTRL_METER_PROG_SRC           0x00000008
89
90 #define MOTU_CTRL_DIR_IN                   0x00000001
91 #define MOTU_CTRL_DIR_OUT                  0x00000002
92 #define MOTU_CTRL_DIR_INOUT                (MOTU_CTRL_DIR_IN | MOTU_CTRL_DIR_OUT)
93
94 #define MOTU_INFO_MODEL                    0x00000001
95 #define MOTU_INFO_IS_STREAMING             0x00000002
96 #define MOTU_INFO_SAMPLE_RATE              0x00000003
97
98 #define MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL  3
99 #define MOTU_CTRL_GAINPHASEINV_MAX_CHANNEL 9
100
101 /* A "register" value used to signify that a particular control in a matrix
102  * mixer is not available on the current interface.
103  */
104 #define MOTU_CTRL_NONE                     0xffffffff
105
106 class MotuDiscreteCtrl
107     : public Control::Discrete
108 {
109 public:
110     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg);
111     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg,
112           std::string name, std::string label, std::string descr);
113
114     virtual bool setValue(int v) = 0;
115     virtual int getValue() = 0;
116
117     // default implementations
118     virtual bool setValue(int idx, int v)
119         {return setValue(v);};
120     virtual int getValue(int idx)
121         {return getValue();};
122
123     virtual int getMinimum() {return 0;};
124     virtual int getMaximum() {return 0;};
125
126 protected:
127     MotuDevice    &m_parent;
128     unsigned int  m_register;
129 };
130
131 class MotuBinarySwitch
132     : public MotuDiscreteCtrl
133 {
134 public:
135     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
136       unsigned int val_mask, unsigned int setenable_mask);
137     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
138         unsigned int val_mask, unsigned int setenable_mask,
139         std::string name, std::string label, std::string descr);
140
141     virtual bool setValue(int v);
142     virtual int getValue();
143
144 protected:
145     unsigned int m_value_mask;
146     unsigned int m_setenable_mask;
147 };
148
149 class ChannelFader
150     : public MotuDiscreteCtrl
151 {
152 public:
153     ChannelFader(MotuDevice &parent, unsigned int dev_reg);
154     ChannelFader(MotuDevice &parent, unsigned int dev_reg,
155           std::string name, std::string label, std::string descr);
156
157     virtual bool setValue(int v);
158     virtual int getValue();
159 };
160
161 class ChannelPan
162     : public MotuDiscreteCtrl
163 {
164 public:
165     ChannelPan(MotuDevice &parent, unsigned int dev_reg);
166     ChannelPan(MotuDevice &parent, unsigned int dev_reg,
167           std::string name, std::string label, std::string descr);
168
169     virtual bool setValue(int v);
170     virtual int getValue();
171 };
172
173 class MotuMatrixMixer : public Control::MatrixMixer
174 {
175 public:
176     MotuMatrixMixer(MotuDevice &parent);
177     MotuMatrixMixer(MotuDevice &parent, std::string name);
178     virtual ~MotuMatrixMixer() {};
179
180     void addRowInfo(std::string name, unsigned int flags, unsigned int address);
181     void addColInfo(std::string name, unsigned int flags, unsigned int address);
182     uint32_t getCellRegister(const unsigned int row, const unsigned int col);
183
184     virtual void show();
185
186     bool hasNames() const { return true; }
187     bool canConnect() const { return false; }
188
189     virtual std::string getRowName(const int row);
190     virtual std::string getColName(const int col);
191     virtual int canWrite( const int, const int ) { return true; }
192     virtual int getRowCount();
193     virtual int getColCount();
194
195     // full map updates are unsupported
196     virtual bool getCoefficientMap(int &) {return false;};
197     virtual bool storeCoefficientMap(int &) {return false;};
198
199 protected:
200      struct sSignalInfo {
201          std::string name;
202          unsigned int flags;
203          unsigned int address;
204      };
205
206      std::vector<struct sSignalInfo> m_RowInfo;
207      std::vector<struct sSignalInfo> m_ColInfo;
208
209      MotuDevice& m_parent;
210 };
211
212 class ChannelFaderMatrixMixer : public MotuMatrixMixer
213 {
214 public:
215     ChannelFaderMatrixMixer(MotuDevice &parent);
216     ChannelFaderMatrixMixer(MotuDevice &parent, std::string name);
217     virtual double setValue(const int row, const int col, const double val);
218     virtual double getValue(const int row, const int col);
219 };
220
221 class ChannelPanMatrixMixer : public MotuMatrixMixer
222 {
223 public:
224     ChannelPanMatrixMixer(MotuDevice &parent);
225     ChannelPanMatrixMixer(MotuDevice &parent, std::string name);
226     virtual double setValue(const int row, const int col, const double val);
227     virtual double getValue(const int row, const int col);
228 };
229
230 class ChannelBinSwMatrixMixer : public MotuMatrixMixer
231 {
232 public:
233     ChannelBinSwMatrixMixer(MotuDevice &parent);
234     ChannelBinSwMatrixMixer(MotuDevice &parent, std::string name,
235       unsigned int val_mask, unsigned int setenable_mask);
236     virtual double setValue(const int row, const int col, const double val);
237     virtual double getValue(const int row, const int col);
238
239 protected:
240     unsigned int m_value_mask;
241     unsigned int m_setenable_mask;
242 };
243
244
245
246 class MixFader
247     : public MotuDiscreteCtrl
248 {
249 public:
250     MixFader(MotuDevice &parent, unsigned int dev_reg);
251     MixFader(MotuDevice &parent, unsigned int dev_reg,
252           std::string name, std::string label, std::string descr);
253
254     virtual bool setValue(int v);
255     virtual int getValue();
256 };
257
258 class MixMute
259     : public MotuDiscreteCtrl
260 {
261 public:
262     MixMute(MotuDevice &parent, unsigned int dev_reg);
263     MixMute(MotuDevice &parent, unsigned int dev_reg,
264           std::string name, std::string label, std::string descr);
265
266     virtual bool setValue(int v);
267     virtual int getValue();
268 };
269
270 class MixDest
271     : public MotuDiscreteCtrl
272 {
273 public:
274     MixDest(MotuDevice &parent, unsigned int dev_reg);
275     MixDest(MotuDevice &parent, unsigned int dev_reg,
276           std::string name, std::string label, std::string descr);
277
278     virtual bool setValue(int v);
279     virtual int getValue();
280 };
281
282 class PhonesSrc
283     : public MotuDiscreteCtrl
284 {
285 public:
286     PhonesSrc(MotuDevice &parent);
287     PhonesSrc(MotuDevice &parent,
288           std::string name, std::string label, std::string descr);
289
290     virtual bool setValue(int v);
291     virtual int getValue();
292 };
293
294 class OpticalMode
295     : public MotuDiscreteCtrl
296 {
297 public:
298     OpticalMode(MotuDevice &parent, unsigned int dev_reg);
299     OpticalMode(MotuDevice &parent, unsigned int dev_reg,
300           std::string name, std::string label, std::string descr);
301
302     virtual bool setValue(int v);
303     virtual int getValue();
304 };
305
306 class InputGainPadInv
307     : public MotuDiscreteCtrl
308 {
309 public:
310     InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode);
311     InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode,
312           std::string name, std::string label, std::string descr);
313
314     virtual bool setValue(int v);
315     virtual int getValue();
316 protected:
317     void validate();
318     unsigned int dev_register();
319     unsigned int m_mode;
320 };
321
322 class MeterControl
323     : public MotuDiscreteCtrl
324 {
325 public:
326     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift);
327     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift,
328           std::string name, std::string label, std::string descr);
329
330     virtual bool setValue(int v);
331     virtual int getValue();
332 protected:
333     void validate();
334     unsigned int m_shift;
335 };
336
337 class InfoElement
338     : public MotuDiscreteCtrl
339 {
340 public:
341     InfoElement(MotuDevice &parent, unsigned infotype);
342     InfoElement(MotuDevice &parent, unsigned infotype,
343           std::string name, std::string label, std::string descr);
344     virtual bool setValue(int v);
345     virtual int getValue();
346 };
347
348 }
Note: See TracBrowser for help on using the browser.