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

Revision 1498, 9.9 kB (checked in by ppalmers, 15 years ago)

Merge all changes from 2.0 branch into trunk (since r1361). This _should_ contain all forward merges done in the mean time. At this moment in time both branches should be in sync.

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Pieter Palmers
4  * Copyright (C) 2008 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_TRIMGAIN  0x01000000
46 #define MOTU_CTRL_INPUT_PAD       0x02000000
47 #define MOTU_CTRL_INPUT_LEVEL     0x04000000
48 #define MOTU_CTRL_INPUT_BOOST     0x08000000
49 #define MOTU_CTRL_PHONES_SRC      0x10000000
50 #define MOTU_CTRL_OPTICAL_MODE    0x20000000
51
52 #define MOTU_CTRL_STD_CHANNEL \
53     (MOTU_CTRL_CHANNEL_FADER|MOTU_CTRL_CHANNEL_PAN|\
54      MOTU_CTRL_CHANNEL_SOLO|MOTU_CTRL_CHANNEL_MUTE)
55
56 #define MOTU_CTRL_STD_MIX \
57     (MOTU_CTRL_MIX_FADER|MOTU_CTRL_MIX_MUTE|\
58      MOTU_CTRL_MIX_DEST)
59
60 #define MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS \
61     (MOTU_CTRL_INPUT_TRIMGAIN|MOTU_CTRL_INPUT_PAD)
62 #define MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS \
63     (MOTU_CTRL_INPUT_LEVEL|MOTU_CTRL_INPUT_BOOST)
64
65 #define MOTU_CTRL_MASK_MUTE_VALUE          0x00010000
66 #define MOTU_CTRL_MASK_MUTE_SETENABLE      0x01000000
67 #define MOTU_CTRL_MASK_SOLO_VALUE          0x00020000
68 #define MOTU_CTRL_MASK_SOLO_SETENABLE      0x02000000
69
70 #define MOTU_CTRL_MASK_ANA5_INPUT_LEVEL    0x00000010
71 #define MOTU_CTRL_MASK_ANA6_INPUT_LEVEL    0x00000020
72 #define MOTU_CTRL_MASK_ANA7_INPUT_LEVEL    0x00000040
73 #define MOTU_CTRL_MASK_ANA8_INPUT_LEVEL    0x00000080
74
75 #define MOTU_CTRL_MODE_PAD                 0x00000000
76 #define MOTU_CTRL_MODE_TRIMGAIN            0x00000001
77
78 #define MOTU_CTRL_METER_PEAKHOLD           0x00000001
79 #define MOTU_CTRL_METER_CLIPHOLD           0x00000002
80 #define MOTU_CTRL_METER_AESEBU_SRC         0x00000004
81 #define MOTU_CTRL_METER_PROG_SRC           0x00000008
82
83 #define MOTU_CTRL_DIR_IN                   0x00000001
84 #define MOTU_CTRL_DIR_OUT                  0x00000002
85 #define MOTU_CTRL_DIR_INOUT                (MOTU_CTRL_DIR_IN | MOTU_CTRL_DIR_OUT)
86
87 #define MOTU_INFO_MODEL                    0x00000001
88 #define MOTU_INFO_IS_STREAMING             0x00000002
89 #define MOTU_INFO_SAMPLE_RATE              0x00000003
90 #define MOTU_INFO_HAS_MIC_INPUTS           0x00000004
91 #define MOTU_INFO_HAS_AESEBU_INPUTS        0x00000005
92 #define MOTU_INFO_HAS_SPDIF_INPUTS         0x00000006
93 #define MOTU_INFO_HAS_OPTICAL_SPDIF        0x00000007
94
95 #define MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL  3
96
97 /* A "register" value used to signify that a particular control in a matrix
98  * mixer is not available on the current interface.
99  */
100 #define MOTU_CTRL_NONE                     0xffffffff
101
102 class MotuDiscreteCtrl
103     : public Control::Discrete
104 {
105 public:
106     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg);
107     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg,
108           std::string name, std::string label, std::string descr);
109
110     virtual bool setValue(int v) = 0;
111     virtual int getValue() = 0;
112
113     // default implementations
114     virtual bool setValue(int idx, int v)
115         {return setValue(v);};
116     virtual int getValue(int idx)
117         {return getValue();};
118
119     virtual int getMinimum() {return 0;};
120     virtual int getMaximum() {return 0;};
121
122 protected:
123     MotuDevice    &m_parent;
124     unsigned int  m_register;
125 };
126
127 class MotuBinarySwitch
128     : public MotuDiscreteCtrl
129 {
130 public:
131     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
132       unsigned int val_mask, unsigned int setenable_mask);
133     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
134         unsigned int val_mask, unsigned int setenable_mask,
135         std::string name, std::string label, std::string descr);
136
137     virtual bool setValue(int v);
138     virtual int getValue();
139
140 protected:
141     unsigned int m_value_mask;
142     unsigned int m_setenable_mask;
143 };
144
145 class ChannelFader
146     : public MotuDiscreteCtrl
147 {
148 public:
149     ChannelFader(MotuDevice &parent, unsigned int dev_reg);
150     ChannelFader(MotuDevice &parent, unsigned int dev_reg,
151           std::string name, std::string label, std::string descr);
152
153     virtual bool setValue(int v);
154     virtual int getValue();
155 };
156
157 class ChannelPan
158     : public MotuDiscreteCtrl
159 {
160 public:
161     ChannelPan(MotuDevice &parent, unsigned int dev_reg);
162     ChannelPan(MotuDevice &parent, unsigned int dev_reg,
163           std::string name, std::string label, std::string descr);
164
165     virtual bool setValue(int v);
166     virtual int getValue();
167 };
168
169 class MotuMatrixMixer : public Control::MatrixMixer
170 {
171 public:
172     MotuMatrixMixer(MotuDevice &parent);
173     MotuMatrixMixer(MotuDevice &parent, std::string name);
174     virtual ~MotuMatrixMixer() {};
175
176     void addRowInfo(std::string name, unsigned int flags, unsigned int address);
177     void addColInfo(std::string name, unsigned int flags, unsigned int address);
178     uint32_t getCellRegister(const unsigned int row, const unsigned int col);
179
180     virtual void show();
181
182     virtual std::string getRowName(const int row);
183     virtual std::string getColName(const int col);
184     virtual int canWrite( const int, const int ) { return true; }
185     virtual int getRowCount();
186     virtual int getColCount();
187
188 protected:
189      struct sSignalInfo {
190          std::string name;
191          unsigned int flags;
192          unsigned int address;
193      };
194
195      std::vector<struct sSignalInfo> m_RowInfo;
196      std::vector<struct sSignalInfo> m_ColInfo;
197
198      MotuDevice& m_parent;
199 };
200
201 class ChannelFaderMatrixMixer : public MotuMatrixMixer
202 {
203 public:
204     ChannelFaderMatrixMixer(MotuDevice &parent);
205     ChannelFaderMatrixMixer(MotuDevice &parent, std::string name);
206     virtual double setValue(const int row, const int col, const double val);
207     virtual double getValue(const int row, const int col);
208 };
209
210 class ChannelPanMatrixMixer : public MotuMatrixMixer
211 {
212 public:
213     ChannelPanMatrixMixer(MotuDevice &parent);
214     ChannelPanMatrixMixer(MotuDevice &parent, std::string name);
215     virtual double setValue(const int row, const int col, const double val);
216     virtual double getValue(const int row, const int col);
217 };
218
219 class ChannelBinSwMatrixMixer : public MotuMatrixMixer
220 {
221 public:
222     ChannelBinSwMatrixMixer(MotuDevice &parent);
223     ChannelBinSwMatrixMixer(MotuDevice &parent, std::string name,
224       unsigned int val_mask, unsigned int setenable_mask);
225     virtual double setValue(const int row, const int col, const double val);
226     virtual double getValue(const int row, const int col);
227
228 protected:
229     unsigned int m_value_mask;
230     unsigned int m_setenable_mask;
231 };
232
233
234
235 class MixFader
236     : public MotuDiscreteCtrl
237 {
238 public:
239     MixFader(MotuDevice &parent, unsigned int dev_reg);
240     MixFader(MotuDevice &parent, unsigned int dev_reg,
241           std::string name, std::string label, std::string descr);
242
243     virtual bool setValue(int v);
244     virtual int getValue();
245 };
246
247 class MixMute
248     : public MotuDiscreteCtrl
249 {
250 public:
251     MixMute(MotuDevice &parent, unsigned int dev_reg);
252     MixMute(MotuDevice &parent, unsigned int dev_reg,
253           std::string name, std::string label, std::string descr);
254
255     virtual bool setValue(int v);
256     virtual int getValue();
257 };
258
259 class MixDest
260     : public MotuDiscreteCtrl
261 {
262 public:
263     MixDest(MotuDevice &parent, unsigned int dev_reg);
264     MixDest(MotuDevice &parent, unsigned int dev_reg,
265           std::string name, std::string label, std::string descr);
266
267     virtual bool setValue(int v);
268     virtual int getValue();
269 };
270
271 class PhonesSrc
272     : public MotuDiscreteCtrl
273 {
274 public:
275     PhonesSrc(MotuDevice &parent);
276     PhonesSrc(MotuDevice &parent,
277           std::string name, std::string label, std::string descr);
278
279     virtual bool setValue(int v);
280     virtual int getValue();
281 };
282
283 class OpticalMode
284     : public MotuDiscreteCtrl
285 {
286 public:
287     OpticalMode(MotuDevice &parent, unsigned int dev_reg);
288     OpticalMode(MotuDevice &parent, unsigned int dev_reg,
289           std::string name, std::string label, std::string descr);
290
291     virtual bool setValue(int v);
292     virtual int getValue();
293 };
294
295 class InputGainPad
296     : public MotuDiscreteCtrl
297 {
298 public:
299     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode);
300     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode,
301           std::string name, std::string label, std::string descr);
302
303     virtual bool setValue(int v);
304     virtual int getValue();
305 protected:
306     void validate();
307     unsigned int dev_register();
308     unsigned int m_mode;
309 };
310
311 class MeterControl
312     : public MotuDiscreteCtrl
313 {
314 public:
315     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift);
316     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift,
317           std::string name, std::string label, std::string descr);
318
319     virtual bool setValue(int v);
320     virtual int getValue();
321 protected:
322     void validate();
323     unsigned int m_shift;
324 };
325
326 class InfoElement
327     : public MotuDiscreteCtrl
328 {
329 public:
330     InfoElement(MotuDevice &parent, unsigned infotype);
331     InfoElement(MotuDevice &parent, unsigned infotype,
332           std::string name, std::string label, std::string descr);
333     virtual bool setValue(int v);
334     virtual int getValue();
335 };
336
337 }
Note: See TracBrowser for help on using the browser.