root/branches/libffado-2.0/src/motu/motu_controls.h

Revision 1520, 10.1 kB (checked in by jwoithe, 15 years ago)

MOTU: cleanup of mixer code. In particular, we rely on the model ID to customise all aspects of the GUI, rather than a collection of individual feature flags for some things.

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