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

Revision 1763, 10.4 kB (checked in by ppalmers, 13 years ago)

Merged revisions 1536,1541,1544-1546,1549,1554-1562,1571,1579-1581,1618,1632,1634-1635,1661,1677-1679,1703-1704,1715,1720-1723,1743-1745,1755 via svnmerge from
svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0

Also fix remaining format string warnings.

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 /* DBus controls used with devices which utilise a pre-Mark3 mixer interface */
27
28 #include "debugmodule/debugmodule.h"
29
30 #include "libcontrol/BasicElements.h"
31 #include "libcontrol/MatrixMixer.h"
32
33 namespace Motu {
34
35 class MotuDevice;
36
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
44
45 #define MOTU_CTRL_METER           0x00001000
46
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
55
56 #define MOTU_CTRL_STD_CHANNEL \
57     (MOTU_CTRL_CHANNEL_FADER|MOTU_CTRL_CHANNEL_PAN|\
58      MOTU_CTRL_CHANNEL_SOLO|MOTU_CTRL_CHANNEL_MUTE)
59
60 #define MOTU_CTRL_STD_MIX \
61     (MOTU_CTRL_MIX_FADER|MOTU_CTRL_MIX_MUTE|\
62      MOTU_CTRL_MIX_DEST)
63
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)
68
69 #define MOTU_CTRL_ULTRALITE_INPUT_CTRLS \
70     (MOTU_CTRL_INPUT_UL_GAIN|MOTU_CTRL_INPUT_PHASE_INV)
71
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
76
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
81
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
86
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
91
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)
95
96 #define MOTU_INFO_MODEL                    0x00000001
97 #define MOTU_INFO_IS_STREAMING             0x00000002
98 #define MOTU_INFO_SAMPLE_RATE              0x00000003
99
100 #define MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL  3
101 #define MOTU_CTRL_GAINPHASEINV_MAX_CHANNEL 9
102
103 /* A "register" value used to signify that a particular control in a matrix
104  * mixer is not available on the current interface.
105  */
106 #define MOTU_CTRL_NONE                     0xffffffff
107
108 class MotuDiscreteCtrl
109     : public Control::Discrete
110 {
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);
115
116     virtual bool setValue(int v) = 0;
117     virtual int getValue() = 0;
118
119     // default implementations
120     virtual bool setValue(int idx, int v)
121         {return setValue(v);};
122     virtual int getValue(int idx)
123         {return getValue();};
124
125     virtual int getMinimum() {return 0;};
126     virtual int getMaximum() {return 0;};
127
128 protected:
129     MotuDevice    &m_parent;
130     unsigned int  m_register;
131 };
132
133 class MotuBinarySwitch
134     : public MotuDiscreteCtrl
135 {
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);
142
143     virtual bool setValue(int v);
144     virtual int getValue();
145
146 protected:
147     unsigned int m_value_mask;
148     unsigned int m_setenable_mask;
149 };
150
151 class ChannelFader
152     : public MotuDiscreteCtrl
153 {
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);
158
159     virtual bool setValue(int v);
160     virtual int getValue();
161 };
162
163 class ChannelPan
164     : public MotuDiscreteCtrl
165 {
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);
170
171     virtual bool setValue(int v);
172     virtual int getValue();
173 };
174
175 class MotuMatrixMixer : public Control::MatrixMixer
176 {
177 public:
178     MotuMatrixMixer(MotuDevice &parent);
179     MotuMatrixMixer(MotuDevice &parent, std::string name);
180     virtual ~MotuMatrixMixer() {};
181
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);
185
186     virtual void show();
187
188     bool hasNames() const { return true; }
189     bool canConnect() const { return false; }
190
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();
196
197     // full map updates are unsupported
198     virtual bool getCoefficientMap(int &) {return false;};
199     virtual bool storeCoefficientMap(int &) {return false;};
200
201 protected:
202      struct sSignalInfo {
203          std::string name;
204          unsigned int flags;
205          unsigned int address;
206      };
207
208      std::vector<struct sSignalInfo> m_RowInfo;
209      std::vector<struct sSignalInfo> m_ColInfo;
210
211      MotuDevice& m_parent;
212 };
213
214 class ChannelFaderMatrixMixer : public MotuMatrixMixer
215 {
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);
221 };
222
223 class ChannelPanMatrixMixer : public MotuMatrixMixer
224 {
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);
230 };
231
232 class ChannelBinSwMatrixMixer : public MotuMatrixMixer
233 {
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);
240
241 protected:
242     unsigned int m_value_mask;
243     unsigned int m_setenable_mask;
244 };
245
246
247
248 class MixFader
249     : public MotuDiscreteCtrl
250 {
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);
255
256     virtual bool setValue(int v);
257     virtual int getValue();
258 };
259
260 class MixMute
261     : public MotuDiscreteCtrl
262 {
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);
267
268     virtual bool setValue(int v);
269     virtual int getValue();
270 };
271
272 class MixDest
273     : public MotuDiscreteCtrl
274 {
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);
279
280     virtual bool setValue(int v);
281     virtual int getValue();
282 };
283
284 class PhonesSrc
285     : public MotuDiscreteCtrl
286 {
287 public:
288     PhonesSrc(MotuDevice &parent);
289     PhonesSrc(MotuDevice &parent,
290           std::string name, std::string label, std::string descr);
291
292     virtual bool setValue(int v);
293     virtual int getValue();
294 };
295
296 class OpticalMode
297     : public MotuDiscreteCtrl
298 {
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);
303
304     virtual bool setValue(int v);
305     virtual int getValue();
306 };
307
308 class InputGainPadInv
309     : public MotuDiscreteCtrl
310 {
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);
315
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;
322 };
323
324 class MeterControl
325     : public MotuDiscreteCtrl
326 {
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);
331
332     virtual bool setValue(int v);
333     virtual int getValue();
334 protected:
335     void validate();
336     unsigned int m_shift;
337 };
338
339 class InfoElement
340     : public MotuDiscreteCtrl
341 {
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();
348 };
349
350 }
Note: See TracBrowser for help on using the browser.