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

Revision 1630, 10.3 kB (checked in by ppalmers, 12 years ago)

add base level support for the DICE EAP based mixers (incomplete)

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     virtual std::string getRowName(const int row);
187     virtual std::string getColName(const int col);
188     virtual int canWrite( const int, const int ) { return true; }
189     virtual int getRowCount();
190     virtual int getColCount();
191
192     // full map updates are unsupported
193     virtual bool getCoefficientMap(int &) {return false;};
194     virtual bool storeCoefficientMap(int &) {return false;};
195
196 protected:
197      struct sSignalInfo {
198          std::string name;
199          unsigned int flags;
200          unsigned int address;
201      };
202
203      std::vector<struct sSignalInfo> m_RowInfo;
204      std::vector<struct sSignalInfo> m_ColInfo;
205
206      MotuDevice& m_parent;
207 };
208
209 class ChannelFaderMatrixMixer : public MotuMatrixMixer
210 {
211 public:
212     ChannelFaderMatrixMixer(MotuDevice &parent);
213     ChannelFaderMatrixMixer(MotuDevice &parent, std::string name);
214     virtual double setValue(const int row, const int col, const double val);
215     virtual double getValue(const int row, const int col);
216 };
217
218 class ChannelPanMatrixMixer : public MotuMatrixMixer
219 {
220 public:
221     ChannelPanMatrixMixer(MotuDevice &parent);
222     ChannelPanMatrixMixer(MotuDevice &parent, std::string name);
223     virtual double setValue(const int row, const int col, const double val);
224     virtual double getValue(const int row, const int col);
225 };
226
227 class ChannelBinSwMatrixMixer : public MotuMatrixMixer
228 {
229 public:
230     ChannelBinSwMatrixMixer(MotuDevice &parent);
231     ChannelBinSwMatrixMixer(MotuDevice &parent, std::string name,
232       unsigned int val_mask, unsigned int setenable_mask);
233     virtual double setValue(const int row, const int col, const double val);
234     virtual double getValue(const int row, const int col);
235
236 protected:
237     unsigned int m_value_mask;
238     unsigned int m_setenable_mask;
239 };
240
241
242
243 class MixFader
244     : public MotuDiscreteCtrl
245 {
246 public:
247     MixFader(MotuDevice &parent, unsigned int dev_reg);
248     MixFader(MotuDevice &parent, unsigned int dev_reg,
249           std::string name, std::string label, std::string descr);
250
251     virtual bool setValue(int v);
252     virtual int getValue();
253 };
254
255 class MixMute
256     : public MotuDiscreteCtrl
257 {
258 public:
259     MixMute(MotuDevice &parent, unsigned int dev_reg);
260     MixMute(MotuDevice &parent, unsigned int dev_reg,
261           std::string name, std::string label, std::string descr);
262
263     virtual bool setValue(int v);
264     virtual int getValue();
265 };
266
267 class MixDest
268     : public MotuDiscreteCtrl
269 {
270 public:
271     MixDest(MotuDevice &parent, unsigned int dev_reg);
272     MixDest(MotuDevice &parent, unsigned int dev_reg,
273           std::string name, std::string label, std::string descr);
274
275     virtual bool setValue(int v);
276     virtual int getValue();
277 };
278
279 class PhonesSrc
280     : public MotuDiscreteCtrl
281 {
282 public:
283     PhonesSrc(MotuDevice &parent);
284     PhonesSrc(MotuDevice &parent,
285           std::string name, std::string label, std::string descr);
286
287     virtual bool setValue(int v);
288     virtual int getValue();
289 };
290
291 class OpticalMode
292     : public MotuDiscreteCtrl
293 {
294 public:
295     OpticalMode(MotuDevice &parent, unsigned int dev_reg);
296     OpticalMode(MotuDevice &parent, unsigned int dev_reg,
297           std::string name, std::string label, std::string descr);
298
299     virtual bool setValue(int v);
300     virtual int getValue();
301 };
302
303 class InputGainPadInv
304     : public MotuDiscreteCtrl
305 {
306 public:
307     InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode);
308     InputGainPadInv(MotuDevice &parent, unsigned int channel, unsigned int mode,
309           std::string name, std::string label, std::string descr);
310
311     virtual bool setValue(int v);
312     virtual int getValue();
313 protected:
314     void validate();
315     unsigned int dev_register();
316     unsigned int m_mode;
317 };
318
319 class MeterControl
320     : public MotuDiscreteCtrl
321 {
322 public:
323     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift);
324     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift,
325           std::string name, std::string label, std::string descr);
326
327     virtual bool setValue(int v);
328     virtual int getValue();
329 protected:
330     void validate();
331     unsigned int m_shift;
332 };
333
334 class InfoElement
335     : public MotuDiscreteCtrl
336 {
337 public:
338     InfoElement(MotuDevice &parent, unsigned infotype);
339     InfoElement(MotuDevice &parent, unsigned infotype,
340           std::string name, std::string label, std::string descr);
341     virtual bool setValue(int v);
342     virtual int getValue();
343 };
344
345 }
Note: See TracBrowser for help on using the browser.