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

Revision 1382, 9.7 kB (checked in by jwoithe, 15 years ago)

MOTU: Allow dbus matrix elements to be flagged as non-existent "pad" controls so other controls remain at their respective places within the matrix.
MOTU: Use pad controls in Ultralite mixer so SPDIF controls remain at their usual index within the dbus matrix mixer elements.

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_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 /* A "register" value used to signify that a particular control in a matrix
94  * mixer is not available on the current interface.
95  */
96 #define MOTU_CTRL_NONE                     0xffffffff
97
98 class MotuDiscreteCtrl
99     : public Control::Discrete
100 {
101 public:
102     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg);
103     MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg,
104           std::string name, std::string label, std::string descr);
105
106     virtual bool setValue(int v) = 0;
107     virtual int getValue() = 0;
108
109     // default implementations
110     virtual bool setValue(int idx, int v)
111         {return setValue(v);};
112     virtual int getValue(int idx)
113         {return getValue();};
114
115     virtual int getMinimum() {return 0;};
116     virtual int getMaximum() {return 0;};
117
118 protected:
119     MotuDevice    &m_parent;
120     unsigned int  m_register;
121 };
122
123 class MotuBinarySwitch
124     : public MotuDiscreteCtrl
125 {
126 public:
127     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
128       unsigned int val_mask, unsigned int setenable_mask);
129     MotuBinarySwitch(MotuDevice &parent, unsigned int dev_reg,
130         unsigned int val_mask, unsigned int setenable_mask,
131         std::string name, std::string label, std::string descr);
132
133     virtual bool setValue(int v);
134     virtual int getValue();
135
136 protected:
137     unsigned int m_value_mask;
138     unsigned int m_setenable_mask;
139 };
140
141 class ChannelFader
142     : public MotuDiscreteCtrl
143 {
144 public:
145     ChannelFader(MotuDevice &parent, unsigned int dev_reg);
146     ChannelFader(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 ChannelPan
154     : public MotuDiscreteCtrl
155 {
156 public:
157     ChannelPan(MotuDevice &parent, unsigned int dev_reg);
158     ChannelPan(MotuDevice &parent, unsigned int dev_reg,
159           std::string name, std::string label, std::string descr);
160
161     virtual bool setValue(int v);
162     virtual int getValue();
163 };
164
165 class MotuMatrixMixer : public Control::MatrixMixer
166 {
167 public:
168     MotuMatrixMixer(MotuDevice &parent);
169     MotuMatrixMixer(MotuDevice &parent, std::string name);
170     virtual ~MotuMatrixMixer() {};
171
172     void addRowInfo(std::string name, unsigned int flags, unsigned int address);
173     void addColInfo(std::string name, unsigned int flags, unsigned int address);
174     uint32_t getCellRegister(const unsigned int row, const unsigned int col);
175
176     virtual void show();
177
178     virtual std::string getRowName(const int row);
179     virtual std::string getColName(const int col);
180     virtual int canWrite( const int, const int ) { return true; }
181     virtual int getRowCount();
182     virtual int getColCount();
183
184 protected:
185      struct sSignalInfo {
186          std::string name;
187          unsigned int flags;
188          unsigned int address;
189      };
190
191      std::vector<struct sSignalInfo> m_RowInfo;
192      std::vector<struct sSignalInfo> m_ColInfo;
193
194      MotuDevice& m_parent;
195 };
196
197 class ChannelFaderMatrixMixer : public MotuMatrixMixer
198 {
199 public:
200     ChannelFaderMatrixMixer(MotuDevice &parent);
201     ChannelFaderMatrixMixer(MotuDevice &parent, std::string name);
202     virtual double setValue(const int row, const int col, const double val);
203     virtual double getValue(const int row, const int col);
204 };
205
206 class ChannelPanMatrixMixer : public MotuMatrixMixer
207 {
208 public:
209     ChannelPanMatrixMixer(MotuDevice &parent);
210     ChannelPanMatrixMixer(MotuDevice &parent, std::string name);
211     virtual double setValue(const int row, const int col, const double val);
212     virtual double getValue(const int row, const int col);
213 };
214
215 class ChannelBinSwMatrixMixer : public MotuMatrixMixer
216 {
217 public:
218     ChannelBinSwMatrixMixer(MotuDevice &parent);
219     ChannelBinSwMatrixMixer(MotuDevice &parent, std::string name,
220       unsigned int val_mask, unsigned int setenable_mask);
221     virtual double setValue(const int row, const int col, const double val);
222     virtual double getValue(const int row, const int col);
223
224 protected:
225     unsigned int m_value_mask;
226     unsigned int m_setenable_mask;
227 };
228
229
230
231 class MixFader
232     : public MotuDiscreteCtrl
233 {
234 public:
235     MixFader(MotuDevice &parent, unsigned int dev_reg);
236     MixFader(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 MixMute
244     : public MotuDiscreteCtrl
245 {
246 public:
247     MixMute(MotuDevice &parent, unsigned int dev_reg);
248     MixMute(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 MixDest
256     : public MotuDiscreteCtrl
257 {
258 public:
259     MixDest(MotuDevice &parent, unsigned int dev_reg);
260     MixDest(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 PhonesSrc
268     : public MotuDiscreteCtrl
269 {
270 public:
271     PhonesSrc(MotuDevice &parent);
272     PhonesSrc(MotuDevice &parent,
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 OpticalMode
280     : public MotuDiscreteCtrl
281 {
282 public:
283     OpticalMode(MotuDevice &parent, unsigned int dev_reg);
284     OpticalMode(MotuDevice &parent, unsigned int dev_reg,
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 InputGainPad
292     : public MotuDiscreteCtrl
293 {
294 public:
295     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode);
296     InputGainPad(MotuDevice &parent, unsigned int channel, unsigned int mode,
297           std::string name, std::string label, std::string descr);
298
299     virtual bool setValue(int v);
300     virtual int getValue();
301 protected:
302     void validate();
303     unsigned int dev_register();
304     unsigned int m_mode;
305 };
306
307 class MeterControl
308     : public MotuDiscreteCtrl
309 {
310 public:
311     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift);
312     MeterControl(MotuDevice &parent, unsigned int ctrl_mask, unsigned int ctrl_shift,
313           std::string name, std::string label, std::string descr);
314
315     virtual bool setValue(int v);
316     virtual int getValue();
317 protected:
318     void validate();
319     unsigned int m_shift;
320 };
321
322 class InfoElement
323     : public MotuDiscreteCtrl
324 {
325 public:
326     InfoElement(MotuDevice &parent, unsigned infotype);
327     InfoElement(MotuDevice &parent, unsigned infotype,
328           std::string name, std::string label, std::string descr);
329     virtual bool setValue(int v);
330     virtual int getValue();
331 };
332
333 }
Note: See TracBrowser for help on using the browser.