root/trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.h

Revision 739, 12.1 kB (checked in by ppalmers, 13 years ago)

- Adapt the ffado external API (upgrade to v3)

NEEDS NEW JACK BACKEND

- simplify FFADODevice constructor even more
- implement first framework support for supporting multiple adapters.

currently all firewire adapters are scanned for supported devices unless specified otherwise
however attaching devices to separate adapters is not supported. using multiple adapters at
that are connected together might work.

Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  * Copyright (C) 2005-2007 by Pieter Palmers
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB.
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software Foundation;
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02110-1301 USA
23  */
24
25 #ifndef BEBOB_FOCUSRITE_SAFFIRE_PRO_DEVICE_H
26 #define BEBOB_FOCUSRITE_SAFFIRE_PRO_DEVICE_H
27
28 #include "debugmodule/debugmodule.h"
29 #include "focusrite_generic.h"
30
31 #include "libcontrol/BasicElements.h"
32
33 #include <vector>
34 #include <string>
35
36 // MIXER ID's
37 #define FR_SAFFIREPRO_CMD_ID_AN1_TO_IMIXL        0
38 #define FR_SAFFIREPRO_CMD_ID_AN1_TO_IMIXR        1
39 #define FR_SAFFIREPRO_CMD_ID_AN2_TO_IMIXL        2
40 #define FR_SAFFIREPRO_CMD_ID_AN2_TO_IMIXR        3
41 #define FR_SAFFIREPRO_CMD_ID_AN3_TO_IMIXL        4
42 #define FR_SAFFIREPRO_CMD_ID_AN3_TO_IMIXR        5
43 #define FR_SAFFIREPRO_CMD_ID_AN4_TO_IMIXL        6
44 #define FR_SAFFIREPRO_CMD_ID_AN4_TO_IMIXR        7
45 #define FR_SAFFIREPRO_CMD_ID_AN5_TO_IMIXL        8
46 #define FR_SAFFIREPRO_CMD_ID_AN5_TO_IMIXR        9
47 #define FR_SAFFIREPRO_CMD_ID_AN6_TO_IMIXL       10
48 #define FR_SAFFIREPRO_CMD_ID_AN6_TO_IMIXR       11
49 #define FR_SAFFIREPRO_CMD_ID_AN7_TO_IMIXL       12
50 #define FR_SAFFIREPRO_CMD_ID_AN7_TO_IMIXR       13
51 #define FR_SAFFIREPRO_CMD_ID_AN8_TO_IMIXL       14
52 #define FR_SAFFIREPRO_CMD_ID_AN8_TO_IMIXR       15
53 #define FR_SAFFIREPRO_CMD_ID_SPDIFL_TO_IMIXL    16
54 #define FR_SAFFIREPRO_CMD_ID_SPDIFL_TO_IMIXR    17
55 #define FR_SAFFIREPRO_CMD_ID_SPDIFR_TO_IMIXL    18
56 #define FR_SAFFIREPRO_CMD_ID_SPDIFR_TO_IMIXR    19
57
58 #define FR_SAFFIREPRO_CMD_ID_ADAT11_TO_IMIXL    20
59 #define FR_SAFFIREPRO_CMD_ID_ADAT11_TO_IMIXR    21
60 #define FR_SAFFIREPRO_CMD_ID_ADAT12_TO_IMIXL    22
61 #define FR_SAFFIREPRO_CMD_ID_ADAT12_TO_IMIXR    23
62 #define FR_SAFFIREPRO_CMD_ID_ADAT13_TO_IMIXL    24
63 #define FR_SAFFIREPRO_CMD_ID_ADAT13_TO_IMIXR    25
64 #define FR_SAFFIREPRO_CMD_ID_ADAT14_TO_IMIXL    26
65 #define FR_SAFFIREPRO_CMD_ID_ADAT14_TO_IMIXR    27
66 #define FR_SAFFIREPRO_CMD_ID_ADAT15_TO_IMIXL    28
67 #define FR_SAFFIREPRO_CMD_ID_ADAT15_TO_IMIXR    29
68 #define FR_SAFFIREPRO_CMD_ID_ADAT16_TO_IMIXL    30
69 #define FR_SAFFIREPRO_CMD_ID_ADAT16_TO_IMIXR    31
70 #define FR_SAFFIREPRO_CMD_ID_ADAT17_TO_IMIXL    32
71 #define FR_SAFFIREPRO_CMD_ID_ADAT17_TO_IMIXR    33
72 #define FR_SAFFIREPRO_CMD_ID_ADAT18_TO_IMIXL    34
73 #define FR_SAFFIREPRO_CMD_ID_ADAT18_TO_IMIXR    35
74
75 #define FR_SAFFIREPRO_CMD_ID_ADAT21_TO_IMIXL    36
76 #define FR_SAFFIREPRO_CMD_ID_ADAT21_TO_IMIXR    37
77 #define FR_SAFFIREPRO_CMD_ID_ADAT22_TO_IMIXL    38
78 #define FR_SAFFIREPRO_CMD_ID_ADAT22_TO_IMIXR    39
79 #define FR_SAFFIREPRO_CMD_ID_ADAT23_TO_IMIXL    40
80 #define FR_SAFFIREPRO_CMD_ID_ADAT23_TO_IMIXR    41
81 #define FR_SAFFIREPRO_CMD_ID_ADAT24_TO_IMIXL    42
82 #define FR_SAFFIREPRO_CMD_ID_ADAT24_TO_IMIXR    43
83 #define FR_SAFFIREPRO_CMD_ID_ADAT25_TO_IMIXL    44
84 #define FR_SAFFIREPRO_CMD_ID_ADAT25_TO_IMIXR    45
85 #define FR_SAFFIREPRO_CMD_ID_ADAT26_TO_IMIXL    46
86 #define FR_SAFFIREPRO_CMD_ID_ADAT26_TO_IMIXR    47
87 #define FR_SAFFIREPRO_CMD_ID_ADAT27_TO_IMIXL    48
88 #define FR_SAFFIREPRO_CMD_ID_ADAT27_TO_IMIXR    49
89 #define FR_SAFFIREPRO_CMD_ID_ADAT28_TO_IMIXL    50
90 #define FR_SAFFIREPRO_CMD_ID_ADAT28_TO_IMIXR    51
91
92 #define FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT1    52
93 #define FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT2    54
94 #define FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT1   53
95 #define FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT2   55
96
97 #define FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT3    56
98 #define FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT4    59
99 #define FR_SAFFIREPRO_CMD_ID_PC3_TO_OUT3    57
100 #define FR_SAFFIREPRO_CMD_ID_PC4_TO_OUT4    60
101 #define FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT3   58
102 #define FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT4   61
103
104 #define FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT5    62
105 #define FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT6    65
106 #define FR_SAFFIREPRO_CMD_ID_PC5_TO_OUT5    63
107 #define FR_SAFFIREPRO_CMD_ID_PC6_TO_OUT6    66
108 #define FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT5   64
109 #define FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT6   67
110
111 #define FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT7    68
112 #define FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT8    71
113 #define FR_SAFFIREPRO_CMD_ID_PC7_TO_OUT7    69
114 #define FR_SAFFIREPRO_CMD_ID_PC8_TO_OUT8    72
115 #define FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT7   70
116 #define FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT8   73
117
118 #define FR_SAFFIREPRO_CMD_ID_PC1_TO_OUT9    74
119 #define FR_SAFFIREPRO_CMD_ID_PC2_TO_OUT10   77
120 #define FR_SAFFIREPRO_CMD_ID_PC9_TO_OUT9    75
121 #define FR_SAFFIREPRO_CMD_ID_PC10_TO_OUT10  78
122 #define FR_SAFFIREPRO_CMD_ID_MIX1_TO_OUT9   76
123 #define FR_SAFFIREPRO_CMD_ID_MIX2_TO_OUT10  79
124
125 // SAMPLERATE related ID's
126 #define FR_SAFFIREPRO_CMD_ID_SAMPLERATE            84
127 #define FR_SAFFIREPRO_CMD_ID_SAMPLERATE_NOREBOOT  115
128
129 #define FOCUSRITE_CMD_SAMPLERATE_44K1   1
130 #define FOCUSRITE_CMD_SAMPLERATE_48K    2
131 #define FOCUSRITE_CMD_SAMPLERATE_88K2   3
132 #define FOCUSRITE_CMD_SAMPLERATE_96K    4
133 #define FOCUSRITE_CMD_SAMPLERATE_176K4  5
134 #define FOCUSRITE_CMD_SAMPLERATE_192K   6
135
136 // OTHER CONFIG id's
137 #define FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT12         80
138 #define FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT34         81
139 #define FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT56         82
140 #define FR_SAFFIREPRO_CMD_ID_BITFIELD_OUT78         83
141
142 #define FR_SAFFIREPRO_CMD_BITFIELD_BIT_MUTE         24
143 #define FR_SAFFIREPRO_CMD_BITFIELD_BIT_DAC_IGNORE   25
144 #define FR_SAFFIREPRO_CMD_BITFIELD_BIT_HWCTRL       26
145 #define FR_SAFFIREPRO_CMD_BITFIELD_BIT_PAD          27
146 #define FR_SAFFIREPRO_CMD_BITFIELD_BIT_DIM          28
147
148
149 #define FR_SAFFIREPRO_CMD_ID_SWITCH_CONFIG          85
150 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_DIM12    (1<<0)
151 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_DIM34    (1<<1)
152 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_DIM56    (1<<2)
153 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_DIM78    (1<<3)
154 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_MUTE12   (1<<4)
155 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_MUTE34   (1<<5)
156 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_MUTE56   (1<<6)
157 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_MUTE78   (1<<7)
158 #define FR_SAFFIREPRO_CMD_SWITCH_CONFIG_MUTE910  (1<<8)
159
160 #define FR_SAFFIREPRO_CMD_ID_FRONT_DIAL             86
161 #define FR_SAFFIREPRO_CMD_ID_DIM_INDICATOR          87
162 #define FR_SAFFIREPRO_CMD_ID_MUTE_INDICATOR         88
163
164 #define FR_SAFFIREPRO_CMD_ID_EXT_CLOCK_LOCK         89
165 #define FR_SAFFIREPRO_CMD_ID_AUDIO_ON               90
166
167 #define FR_SAFFIREPRO_CMD_ID_USE_HIGHVOLTAGE_RAIL   91
168 #define FR_SAFFIREPRO_CMD_ID_USING_HIGHVOLTAGE_RAIL 92
169
170 #define FR_SAFFIREPRO_CMD_ID_SYNC_CONFIG            93
171 #define FR_SAFFIREPRO_CMD_SYNC_CONFIG_INTERNAL       0
172 #define FR_SAFFIREPRO_CMD_SYNC_CONFIG_SPDIF          2
173 #define FR_SAFFIREPRO_CMD_SYNC_CONFIG_ADAT1          3
174 #define FR_SAFFIREPRO_CMD_SYNC_CONFIG_ADAT2          4
175 #define FR_SAFFIREPRO_CMD_SYNC_CONFIG_WORDCLOCK      5
176
177 #define FR_SAFFIREPRO_CMD_ID_DEVICE_NAME_1          94
178 #define FR_SAFFIREPRO_CMD_ID_DEVICE_NAME_2          95
179 #define FR_SAFFIREPRO_CMD_ID_DEVICE_NAME_3          96
180 #define FR_SAFFIREPRO_CMD_ID_DEVICE_NAME_4          97
181
182 #define FR_SAFFIREPRO_CMD_ID_PHANTOM14              98
183 #define FR_SAFFIREPRO_CMD_ID_PHANTOM58              99
184 #define FR_SAFFIREPRO_CMD_ID_INSERT1                100
185 #define FR_SAFFIREPRO_CMD_ID_INSERT2                101
186
187 // led flashing
188 #define FR_SAFFIREPRO_CMD_ID_FLASH_LED              102
189 #define FR_SAFFIREPRO_CMD_FLASH_MASK_SECS           0x00FF
190 #define FR_SAFFIREPRO_CMD_FLASH_MASK_FREQ           0xFF00
191 #define FR_SAFFIREPRO_CMD_SET_FLASH_SECS(reg, secs) \
192     (((reg) & ~FR_SAFFIREPRO_CMD_FLASH_MASK_SECS) | \
193     (((secs) & 0xFF)))
194 #define FR_SAFFIREPRO_CMD_GET_FLASH_SECS(reg)       \
195     ((reg) & FR_SAFFIREPRO_CMD_FLASH_MASK_SECS)
196
197 #define FR_SAFFIREPRO_CMD_SET_FLASH_FREQ(reg, freq) \
198     (((reg) & ~FR_SAFFIREPRO_CMD_FLASH_MASK_FREQ) |  \
199     (((freq) & 0xFF) << 8))
200 #define FR_SAFFIREPRO_CMD_GET_FLASH_FREQ(reg)       \
201     ((reg) & FR_SAFFIREPRO_CMD_FLASH_MASK_FREQ)
202
203 #define FR_SAFFIREPRO_CMD_ID_AC3_PASSTHROUGH        103
204 #define FR_SAFFIREPRO_CMD_ID_MIDI_TRU               104
205
206 #define FR_SAFFIREPRO_CMD_ID_ENABLE_SPDIF_INPUT     105
207 #define FR_SAFFIREPRO_CMD_ID_ENABLE_ADAT1_INPUT     106
208 #define FR_SAFFIREPRO_CMD_ID_ENABLE_ADAT2_INPUT     107
209
210 #define FR_SAFFIREPRO_CMD_ID_SAVE_SETTINGS          108
211 #define FR_SAFFIREPRO_CMD_ID_REBOOT                 109
212 #define FR_SAFFIREPRO_CMD_REBOOT_CODE            0xA5A5
213
214 #define FR_SAFFIREPRO_CMD_ID_PLAYBACK_COUNT         110
215 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_REC_OK       0
216 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_PBK_OK       1
217 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_RX_READY     2
218 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_STANDALONE   3
219 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_SPDIFIN_ON   (1<<8)
220 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_SPDIFIN_ERR  (1<<9)
221 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_ADAT1IN_ON   (1<<16)
222 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_ADAT1IN_ERR  (1<<17)
223 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_ADAT2IN_ON   (1<<24)
224 #define FR_SAFFIREPRO_CMD_PLAYBACK_COUNT_ADAT2IN_ERR  (1<<25)
225
226 #define FR_SAFFIREPRO_CMD_ID_STANDALONE_MODE        111
227 #define FR_SAFFIREPRO_CMD_ID_AVC_MODEL              112
228 #define FR_SAFFIREPRO_CMD_AVC_MODEL_LARGE             0
229 #define FR_SAFFIREPRO_CMD_AVC_MODEL_SMALL             1
230
231 #define FR_SAFFIREPRO_CMD_ID_PLL_LOCK_RANGE         113
232
233 #define FR_SAFFIREPRO_CMD_ID_EXIT_STANDALONE        114
234 #define FR_SAFFIREPRO_CMD_EXIT_STANDALONE_CODE   0xA5A5
235
236 #define FR_SAFFIREPRO_CMD_ID_AVC_MODEL_MIDI         116
237 #define FR_SAFFIREPRO_CMD_AVC_MODEL_MIDI_ON           1
238 #define FR_SAFFIREPRO_CMD_AVC_MODEL_MIDI_OFF          0
239
240 #define FR_SAFFIREPRO_CMD_ID_DIM_LEVEL              117
241 #define FR_SAFFIREPRO_CMD_ID_DIRECT_MONITORING      118
242
243
244
245 namespace BeBoB {
246 namespace Focusrite {
247
248 class SaffireProDevice;
249
250 // swiss army knife control class to serve
251 // specific device control commands
252 class SaffireProMultiControl
253     : public Control::Discrete
254 {
255 public:
256     enum eTriggerControlType {
257         eTCT_Reboot,
258         eTCT_FlashLed,
259         eTCT_UseHighVoltageRail,
260     };
261
262 public:
263     SaffireProMultiControl(SaffireProDevice& parent, enum eTriggerControlType);
264     SaffireProMultiControl(SaffireProDevice& parent, enum eTriggerControlType,
265                   std::string name, std::string label, std::string descr);
266
267     virtual bool setValue(int v);
268     virtual int getValue();
269
270 private:
271     SaffireProDevice&          m_Parent;
272     enum eTriggerControlType  m_type;
273 };
274
275
276 class SaffireProMatrixMixer : public FocusriteMatrixMixer
277 {
278 public:
279     enum eMatrixMixerType {
280         eMMT_InputMix,
281         eMMT_OutputMix
282     };
283    
284 public:
285     SaffireProMatrixMixer(SaffireProDevice& parent, enum eMatrixMixerType type);
286     SaffireProMatrixMixer(SaffireProDevice& parent, enum eMatrixMixerType type, std::string n);
287     virtual ~SaffireProMatrixMixer() {};
288
289     virtual void show();
290
291 protected:
292     void init();
293     enum eMatrixMixerType m_type;
294 };
295
296
297 class SaffireProDevice : public FocusriteDevice
298 {
299
300 // we want all outside control to be done by this class
301 friend class SaffireProMultiControl;
302
303 public:
304     SaffireProDevice(std::auto_ptr<ConfigRom>( configRom ));
305     virtual ~SaffireProDevice();
306
307     virtual void showDevice();
308     virtual void setVerboseLevel(int l);
309
310     virtual bool setSamplingFrequency( int );
311     virtual int getSamplingFrequency( );
312
313     virtual bool buildMixer();
314     virtual bool destroyMixer();
315
316 protected:
317     void rebootDevice();
318     void flashLed();
319     bool isAudioOn();
320     bool isExtClockLocked();
321     uint32_t getCount32();
322
323     void useHighVoltageRail(bool useIt);
324     bool usingHighVoltageRail();
325 private:
326     virtual bool setSamplingFrequencyDo( uint32_t );
327     virtual bool setSamplingFrequencyDoNoReboot( uint32_t );
328
329     Control::Container *m_MixerContainer;
330     Control::Container *m_ControlContainer;
331 };
332
333 } // namespace Focusrite
334 } // namespace BeBoB
335
336 #endif
Note: See TracBrowser for help on using the browser.