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

Revision 1274, 8.9 kB (checked in by jwoithe, 15 years ago)

* MOTU: add a model identifer to the dbus interface to assist with per-model mixer customisations.
* MOTU: Begin some model-specific mixer variations. Users of the 828Mk2 should now be able to set the level and boost for analog channels 1-4.
* MOTU: On models without AES/EBU the relevant entry in the mix destination now reads "MainOut?" (since that's what "AES/EBU" did on those interfaces).

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_INPUT_TRIMGAIN  0x01000000
44 #define MOTU_CTRL_INPUT_PAD       0x02000000
45 #define MOTU_CTRL_INPUT_LEVEL     0x04000000
46 #define MOTU_CTRL_INPUT_BOOST     0x08000000
47 #define MOTU_CTRL_PHONES_SRC      0x10000000
48 #define MOTU_CTRL_OPTICAL_MODE    0x20000000
49
50 #define MOTU_CTRL_STD_CHANNEL \
51     (MOTU_CTRL_CHANNEL_FADER|MOTU_CTRL_CHANNEL_PAN|\
52      MOTU_CTRL_CHANNEL_SOLO|MOTU_CTRL_CHANNEL_MUTE)
53
54 #define MOTU_CTRL_STD_MIX \
55     (MOTU_CTRL_MIX_FADER|MOTU_CTRL_MIX_MUTE|\
56      MOTU_CTRL_MIX_DEST)
57
58 #define MOTU_CTRL_TRAVELER_MIC_INPUT_CTRLS \
59     (MOTU_CTRL_INPUT_TRIMGAIN|MOTU_CTRL_INPUT_PAD)
60 #define MOTU_CTRL_TRAVELER_LINE_INPUT_CTRLS \
61     (MOTU_CTRL_INPUT_LEVEL|MOTU_CTRL_INPUT_BOOST)
62
63 #define MOTU_CTRL_MASK_MUTE_VALUE          0x00010000
64 #define MOTU_CTRL_MASK_MUTE_SETENABLE      0x01000000
65 #define MOTU_CTRL_MASK_SOLO_VALUE          0x00020000
66 #define MOTU_CTRL_MASK_SOLO_SETENABLE      0x02000000
67
68 #define MOTU_CTRL_MASK_ANA5_INPUT_LEVEL    0x00000010
69 #define MOTU_CTRL_MASK_ANA6_INPUT_LEVEL    0x00000020
70 #define MOTU_CTRL_MASK_ANA7_INPUT_LEVEL    0x00000040
71 #define MOTU_CTRL_MASK_ANA8_INPUT_LEVEL    0x00000080
72
73 #define MOTU_CTRL_MODE_PAD                 0x00000000
74 #define MOTU_CTRL_MODE_TRIMGAIN            0x00000001
75
76 #define MOTU_INFO_MODEL                    0x00000001
77 #define MOTU_INFO_IS_STREAMING             0x00000002
78 #define MOTU_INFO_SAMPLE_RATE              0x00000003
79 #define MOTU_INFO_HAS_MIC_INPUTS           0x00000004
80 #define MOTU_INFO_HAS_AESEBU_INPUTS        0x00000005
81 #define MOTU_INFO_HAS_SPDIF_INPUTS         0x00000006
82 #define MOTU_INFO_HAS_OPTICAL_SPDIF        0x00000007
83
84 #define MOTU_CTRL_TRIMGAINPAD_MAX_CHANNEL  3
85
86 class MotuDiscreteCtrl
87     : public Control::Discrete
88 {
89 public:
90     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg);
91     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg,
92           std::string name, std::string label, std::string descr);
93
94     virtual bool setValue(int v) = 0;
95     virtual int getValue() = 0;
96
97     // default implementations
98     virtual bool setValue(int idx, int v)
99         {return setValue(v);};
100     virtual int getValue(int idx)
101         {return getValue();};
102
103     virtual int getMinimum() {return 0;};
104     virtual int getMaximum() {return 0;};
105
106 protected:
107     MotuDevice    &m_parent;
108     unsigned int  m_register;
109 };
110
111 class MotuBinarySwitch
112     : public MotuDiscreteCtrl
113 {
114 public:
115     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
116       unsigned int val_mask, unsigned int setenable_mask);
117     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
118         unsigned int val_mask, unsigned int setenable_mask,
119         std::string name, std::string label, std::string descr);
120
121     virtual bool setValue(int v);
122     virtual int getValue();
123
124 protected:
125     unsigned int m_value_mask;
126     unsigned int m_setenable_mask;
127 };
128
129 class ChannelFader
130     : public MotuDiscreteCtrl
131 {
132 public:
133     ChannelFader(MotuDevice &parent, unsigned int dev_reg);
134     ChannelFader(MotuDevice &parent, unsigned int dev_reg,
135           std::string name, std::string label, std::string descr);
136
137     virtual bool setValue(int v);
138     virtual int getValue();
139 };
140
141 class ChannelPan
142     : public MotuDiscreteCtrl
143 {
144 public:
145     ChannelPan(MotuDevice &parent, unsigned int dev_reg);
146     ChannelPan(MotuDevice &parent, unsigned int dev_reg,
147           std::string name, std::string label, std::string descr);
148
149     virtual bool setValue(int v);
150     virtual int getValue();
151 };
152
153 class MotuMatrixMixer : public Control::MatrixMixer
154 {
155 public:
156     MotuMatrixMixer(MotuDevice &parent);
157     MotuMatrixMixer(MotuDevice &parent, std::string name);
158     virtual ~MotuMatrixMixer() {};
159
160     void addRowInfo(std::string name, unsigned int flags, unsigned int address);
161     void addColInfo(std::string name, unsigned int flags, unsigned int address);
162     uint32_t getCellRegister(const unsigned int row, const unsigned int col);
163
164     virtual void show();
165
166     virtual std::string getRowName(const int row);
167     virtual std::string getColName(const int col);
168     virtual int canWrite( const int, const int ) { return true; }
169     virtual int getRowCount();
170     virtual int getColCount();
171
172 protected:
173      struct sSignalInfo {
174          std::string name;
175          unsigned int flags;
176          unsigned int address;
177      };
178
179      std::vector<struct sSignalInfo> m_RowInfo;
180      std::vector<struct sSignalInfo> m_ColInfo;
181
182      MotuDevice& m_parent;
183 };
184
185 class ChannelFaderMatrixMixer : public MotuMatrixMixer
186 {
187 public:
188     ChannelFaderMatrixMixer(MotuDevice &parent);
189     ChannelFaderMatrixMixer(MotuDevice &parent, std::string name);
190     virtual double setValue(const int row, const int col, const double val);
191     virtual double getValue(const int row, const int col);
192 };
193
194 class ChannelPanMatrixMixer : public MotuMatrixMixer
195 {
196 public:
197     ChannelPanMatrixMixer(MotuDevice &parent);
198     ChannelPanMatrixMixer(MotuDevice &parent, std::string name);
199     virtual double setValue(const int row, const int col, const double val);
200     virtual double getValue(const int row, const int col);
201 };
202
203 class ChannelBinSwMatrixMixer : public MotuMatrixMixer
204 {
205 public:
206     ChannelBinSwMatrixMixer(MotuDevice &parent);
207     ChannelBinSwMatrixMixer(MotuDevice &parent, std::string name,
208       unsigned int val_mask, unsigned int setenable_mask);
209     virtual double setValue(const int row, const int col, const double val);
210     virtual double getValue(const int row, const int col);
211
212 protected:
213     unsigned int m_value_mask;
214     unsigned int m_setenable_mask;
215 };
216
217
218
219 class MixFader
220     : public MotuDiscreteCtrl
221 {
222 public:
223     MixFader(MotuDevice &parent, unsigned int dev_reg);
224     MixFader(MotuDevice &parent, unsigned int dev_reg,
225           std::string name, std::string label, std::string descr);
226
227     virtual bool setValue(int v);
228     virtual int getValue();
229 };
230
231 class MixMute
232     : public MotuDiscreteCtrl
233 {
234 public:
235     MixMute(MotuDevice &parent, unsigned int dev_reg);
236     MixMute(MotuDevice &parent, unsigned int dev_reg,
237           std::string name, std::string label, std::string descr);
238
239     virtual bool setValue(int v);
240     virtual int getValue();
241 };
242
243 class MixDest
244     : public MotuDiscreteCtrl
245 {
246 public:
247     MixDest(MotuDevice &parent, unsigned int dev_reg);
248     MixDest(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 PhonesSrc
256     : public MotuDiscreteCtrl
257 {
258 public:
259     PhonesSrc(MotuDevice &parent);
260     PhonesSrc(MotuDevice &parent,
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 OpticalMode
268     : public MotuDiscreteCtrl
269 {
270 public:
271     OpticalMode(MotuDevice &parent, unsigned int dev_reg);
272     OpticalMode(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 InputGainPad
280     : public MotuDiscreteCtrl
281 {
282 public:
283     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode);
284     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode,
285           std::string name, std::string label, std::string descr);
286
287     virtual bool setValue(int v);
288     virtual int getValue();
289 protected:
290     void validate();
291     unsigned int dev_register();
292     unsigned int m_mode;
293 };
294
295 class InfoElement
296     : public MotuDiscreteCtrl
297 {
298 public:
299     InfoElement(MotuDevice &parent, unsigned infotype);
300     InfoElement(MotuDevice &parent, unsigned infotype,
301           std::string name, std::string label, std::string descr);
302     virtual bool setValue(int v);
303     virtual int getValue();
304 };
305
306 }
Note: See TracBrowser for help on using the browser.