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

Revision 1315, 9.6 kB (checked in by jwoithe, 12 years ago)

MOTU: first cut at supporting the meter controls of the 896HD. Please test and report what works and what doesn't.

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           0x00000000
79 #define MOTU_CTRL_METER_CLIPHOLD           0x00000001
80 #define MOTU_CTRL_METER_AESEBU_SRC         0x00000002
81 #define MOTU_CTRL_METER_PROG_SRC           0x00000004
82
83 #define MOTU_INFO_MODEL                    0x00000001
84 #define MOTU_INFO_IS_STREAMING             0x00000002
85 #define MOTU_INFO_SAMPLE_RATE              0x00000003
86 #define MOTU_INFO_HAS_MIC_INPUTS           0x00000004
87 #define MOTU_INFO_HAS_AESEBU_INPUTS        0x00000005
88 #define MOTU_INFO_HAS_SPDIF_INPUTS         0x00000006
89 #define MOTU_INFO_HAS_OPTICAL_SPDIF        0x00000007
90
91 #define MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL  3
92
93 class MotuDiscreteCtrl
94     : public Control::Discrete
95 {
96 public:
97     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg);
98     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg,
99           std::string name, std::string label, std::string descr);
100
101     virtual bool setValue(int v) = 0;
102     virtual int getValue() = 0;
103
104     // default implementations
105     virtual bool setValue(int idx, int v)
106         {return setValue(v);};
107     virtual int getValue(int idx)
108         {return getValue();};
109
110     virtual int getMinimum() {return 0;};
111     virtual int getMaximum() {return 0;};
112
113 protected:
114     MotuDevice    &m_parent;
115     unsigned int  m_register;
116 };
117
118 class MotuBinarySwitch
119     : public MotuDiscreteCtrl
120 {
121 public:
122     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
123       unsigned int val_mask, unsigned int setenable_mask);
124     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
125         unsigned int val_mask, unsigned int setenable_mask,
126         std::string name, std::string label, std::string descr);
127
128     virtual bool setValue(int v);
129     virtual int getValue();
130
131 protected:
132     unsigned int m_value_mask;
133     unsigned int m_setenable_mask;
134 };
135
136 class ChannelFader
137     : public MotuDiscreteCtrl
138 {
139 public:
140     ChannelFader(MotuDevice &parent, unsigned int dev_reg);
141     ChannelFader(MotuDevice &parent, unsigned int dev_reg,
142           std::string name, std::string label, std::string descr);
143
144     virtual bool setValue(int v);
145     virtual int getValue();
146 };
147
148 class ChannelPan
149     : public MotuDiscreteCtrl
150 {
151 public:
152     ChannelPan(MotuDevice &parent, unsigned int dev_reg);
153     ChannelPan(MotuDevice &parent, unsigned int dev_reg,
154           std::string name, std::string label, std::string descr);
155
156     virtual bool setValue(int v);
157     virtual int getValue();
158 };
159
160 class MotuMatrixMixer : public Control::MatrixMixer
161 {
162 public:
163     MotuMatrixMixer(MotuDevice &parent);
164     MotuMatrixMixer(MotuDevice &parent, std::string name);
165     virtual ~MotuMatrixMixer() {};
166
167     void addRowInfo(std::string name, unsigned int flags, unsigned int address);
168     void addColInfo(std::string name, unsigned int flags, unsigned int address);
169     uint32_t getCellRegister(const unsigned int row, const unsigned int col);
170
171     virtual void show();
172
173     virtual std::string getRowName(const int row);
174     virtual std::string getColName(const int col);
175     virtual int canWrite( const int, const int ) { return true; }
176     virtual int getRowCount();
177     virtual int getColCount();
178
179 protected:
180      struct sSignalInfo {
181          std::string name;
182          unsigned int flags;
183          unsigned int address;
184      };
185
186      std::vector<struct sSignalInfo> m_RowInfo;
187      std::vector<struct sSignalInfo> m_ColInfo;
188
189      MotuDevice& m_parent;
190 };
191
192 class ChannelFaderMatrixMixer : public MotuMatrixMixer
193 {
194 public:
195     ChannelFaderMatrixMixer(MotuDevice &parent);
196     ChannelFaderMatrixMixer(MotuDevice &parent, std::string name);
197     virtual double setValue(const int row, const int col, const double val);
198     virtual double getValue(const int row, const int col);
199 };
200
201 class ChannelPanMatrixMixer : public MotuMatrixMixer
202 {
203 public:
204     ChannelPanMatrixMixer(MotuDevice &parent);
205     ChannelPanMatrixMixer(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 ChannelBinSwMatrixMixer : public MotuMatrixMixer
211 {
212 public:
213     ChannelBinSwMatrixMixer(MotuDevice &parent);
214     ChannelBinSwMatrixMixer(MotuDevice &parent, std::string name,
215       unsigned int val_mask, unsigned int setenable_mask);
216     virtual double setValue(const int row, const int col, const double val);
217     virtual double getValue(const int row, const int col);
218
219 protected:
220     unsigned int m_value_mask;
221     unsigned int m_setenable_mask;
222 };
223
224
225
226 class MixFader
227     : public MotuDiscreteCtrl
228 {
229 public:
230     MixFader(MotuDevice &parent, unsigned int dev_reg);
231     MixFader(MotuDevice &parent, unsigned int dev_reg,
232           std::string name, std::string label, std::string descr);
233
234     virtual bool setValue(int v);
235     virtual int getValue();
236 };
237
238 class MixMute
239     : public MotuDiscreteCtrl
240 {
241 public:
242     MixMute(MotuDevice &parent, unsigned int dev_reg);
243     MixMute(MotuDevice &parent, unsigned int dev_reg,
244           std::string name, std::string label, std::string descr);
245
246     virtual bool setValue(int v);
247     virtual int getValue();
248 };
249
250 class MixDest
251     : public MotuDiscreteCtrl
252 {
253 public:
254     MixDest(MotuDevice &parent, unsigned int dev_reg);
255     MixDest(MotuDevice &parent, unsigned int dev_reg,
256           std::string name, std::string label, std::string descr);
257
258     virtual bool setValue(int v);
259     virtual int getValue();
260 };
261
262 class PhonesSrc
263     : public MotuDiscreteCtrl
264 {
265 public:
266     PhonesSrc(MotuDevice &parent);
267     PhonesSrc(MotuDevice &parent,
268           std::string name, std::string label, std::string descr);
269
270     virtual bool setValue(int v);
271     virtual int getValue();
272 };
273
274 class OpticalMode
275     : public MotuDiscreteCtrl
276 {
277 public:
278     OpticalMode(MotuDevice &parent, unsigned int dev_reg);
279     OpticalMode(MotuDevice &parent, unsigned int dev_reg,
280           std::string name, std::string label, std::string descr);
281
282     virtual bool setValue(int v);
283     virtual int getValue();
284 };
285
286 class InputGainPad
287     : public MotuDiscreteCtrl
288 {
289 public:
290     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode);
291     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode,
292           std::string name, std::string label, std::string descr);
293
294     virtual bool setValue(int v);
295     virtual int getValue();
296 protected:
297     void validate();
298     unsigned int dev_register();
299     unsigned int m_mode;
300 };
301
302 class MeterControl
303     : public MotuDiscreteCtrl
304 {
305 public:
306     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift);
307     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift,
308           std::string name, std::string label, std::string descr);
309
310     virtual bool setValue(int v);
311     virtual int getValue();
312 protected:
313     void validate();
314     unsigned int m_shift;
315 };
316
317 class InfoElement
318     : public MotuDiscreteCtrl
319 {
320 public:
321     InfoElement(MotuDevice &parent, unsigned infotype);
322     InfoElement(MotuDevice &parent, unsigned infotype,
323           std::string name, std::string label, std::string descr);
324     virtual bool setValue(int v);
325     virtual int getValue();
326 };
327
328 }
Note: See TracBrowser for help on using the browser.