1 |
/* |
---|
2 |
* Copyright (C) 2009 by Pieter Palmers |
---|
3 |
* Copyright (C) 2009 by Arnold Krille |
---|
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 program is free software: you can redistribute it and/or modify |
---|
11 |
* it under the terms of the GNU General Public License as published by |
---|
12 |
* the Free Software Foundation, either version 2 of the License, or |
---|
13 |
* (at your option) version 3 of the License. |
---|
14 |
* |
---|
15 |
* This program is distributed in the hope that it will be useful, |
---|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 |
* GNU General Public License for more details. |
---|
19 |
* |
---|
20 |
* You should have received a copy of the GNU General Public License |
---|
21 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
22 |
* |
---|
23 |
*/ |
---|
24 |
|
---|
25 |
#include "saffire_pro24.h" |
---|
26 |
#include "focusrite_eap.h" |
---|
27 |
|
---|
28 |
#include "libutil/ByteSwap.h" |
---|
29 |
#include <cstdio> |
---|
30 |
|
---|
31 |
namespace Dice { |
---|
32 |
namespace Focusrite { |
---|
33 |
|
---|
34 |
void SaffirePro24::SaffirePro24EAP::setupSources_low() { |
---|
35 |
addSource("SPDIF/In", 6, 2, eRS_AES, 1); |
---|
36 |
addSource("ADAT/In", 0, 8, eRS_ADAT, 1); |
---|
37 |
addSource("Anlg/In", 0, 4, eRS_InS0, 1); |
---|
38 |
addSource("Mixer/Out", 0, 16, eRS_Mixer, 1); |
---|
39 |
addSource("1394/In", 0, 8, eRS_ARX0, 1); |
---|
40 |
addSource("Mute", 0, 1, eRS_Muted); |
---|
41 |
} |
---|
42 |
void SaffirePro24::SaffirePro24EAP::setupDestinations_low() { |
---|
43 |
addDestination("SPDIF/Out", 6, 2, eRD_AES, 1); |
---|
44 |
addDestination("Line/Out", 0, 6, eRD_InS0, 1); |
---|
45 |
addDestination("Mixer/In", 0, 16, eRD_Mixer0, 1); |
---|
46 |
addDestination("Mixer/In", 0, 2, eRD_Mixer1, 17); |
---|
47 |
addDestination("1394/Out", 0, 16, eRD_ATX0, 1); |
---|
48 |
// Is a Mute destination useful ? |
---|
49 |
// addDestination("Mute", 0, 1, eRD_Muted); |
---|
50 |
} |
---|
51 |
|
---|
52 |
void SaffirePro24::SaffirePro24EAP::setupSources_mid() { |
---|
53 |
addSource("SPDIF/In", 6, 2, eRS_AES, 1); |
---|
54 |
addSource("ADAT/In", 0, 4, eRS_ADAT, 1); |
---|
55 |
addSource("Anlg/In", 0, 4, eRS_InS0, 1); |
---|
56 |
addSource("Mixer/Out", 0, 16, eRS_Mixer, 1); |
---|
57 |
addSource("1394/In", 0, 8, eRS_ARX0, 1); |
---|
58 |
addSource("Mute", 0, 1, eRS_Muted); |
---|
59 |
} |
---|
60 |
void SaffirePro24::SaffirePro24EAP::setupDestinations_mid() { |
---|
61 |
addDestination("SPDIF/Out", 6, 2, eRD_AES, 1); |
---|
62 |
addDestination("Line/Out", 0, 6, eRD_InS0, 1); |
---|
63 |
addDestination("Mixer/In", 0, 16, eRD_Mixer0, 1); |
---|
64 |
addDestination("Mixer/In", 0, 2, eRD_Mixer1, 17); |
---|
65 |
addDestination("1394/Out", 0, 12, eRD_ATX0, 1); |
---|
66 |
// Is a Mute destination useful ? |
---|
67 |
// addDestination("Mute", 0, 1, eRD_Muted); |
---|
68 |
} |
---|
69 |
|
---|
70 |
void SaffirePro24::SaffirePro24EAP::setupSources_high() { |
---|
71 |
printMessage("High (192 kHz) sample rate not supported by Saffire Pro 24\n"); |
---|
72 |
} |
---|
73 |
|
---|
74 |
void SaffirePro24::SaffirePro24EAP::setupDestinations_high() { |
---|
75 |
printMessage("High (192 kHz) sample rate not supported by Saffire Pro 24\n"); |
---|
76 |
} |
---|
77 |
|
---|
78 |
/** |
---|
79 |
* The default configurations for the Saffire Pro 24 router. |
---|
80 |
* For coherence with hardware, destinations must follow a specific ordering |
---|
81 |
* There must be 44 destinations at low samplerate |
---|
82 |
* Front LEDs are connected to the first four router entries |
---|
83 |
*/ |
---|
84 |
void |
---|
85 |
SaffirePro24::SaffirePro24EAP::setupDefaultRouterConfig_low() { |
---|
86 |
unsigned int i; |
---|
87 |
// the 1394 stream receivers except the two "loops" one |
---|
88 |
// Looks like analogic inputs are curiously ordered |
---|
89 |
// (required for coherent front LEDs) |
---|
90 |
for (i=0; i<2; i++) { |
---|
91 |
addRoute(eRS_InS0, i+2, eRD_ATX0, i); |
---|
92 |
} |
---|
93 |
for (i=0; i<2; i++) { |
---|
94 |
addRoute(eRS_InS0, i, eRD_ATX0, i+2); |
---|
95 |
} |
---|
96 |
for (i=0; i<2; i++) { |
---|
97 |
addRoute(eRS_AES, i+6, eRD_ATX0, i+4); |
---|
98 |
} |
---|
99 |
for (i=0; i<8; i++) { |
---|
100 |
addRoute(eRS_ADAT, i, eRD_ATX0, i+6); |
---|
101 |
} |
---|
102 |
// The audio ports |
---|
103 |
// Ensure that audio port are not muted |
---|
104 |
for (i=0; i<6; i++) { |
---|
105 |
addRoute(eRS_ARX0, i%2, eRD_InS0, i); |
---|
106 |
} |
---|
107 |
// the SPDIF receiver |
---|
108 |
for (i=0; i<2; i++) { |
---|
109 |
addRoute(eRS_Muted, 0, eRD_AES, i+6); |
---|
110 |
} |
---|
111 |
// the "loops" 1394 stream receivers |
---|
112 |
for (i=0; i<2; i++) { |
---|
113 |
addRoute(eRS_Muted, 0, eRD_ATX0, i+14); |
---|
114 |
} |
---|
115 |
// the Mixer inputs |
---|
116 |
for (i=0; i<4; i++) { |
---|
117 |
addRoute(eRS_InS0, i, eRD_Mixer0, i); |
---|
118 |
} |
---|
119 |
for (i=0; i<2; i++) { |
---|
120 |
addRoute(eRS_AES, i+6, eRD_Mixer0, i+4); |
---|
121 |
} |
---|
122 |
for (i=0; i<8; i++) { |
---|
123 |
addRoute(eRS_ADAT, i, eRD_Mixer0, i+6); |
---|
124 |
} |
---|
125 |
for (i=0; i<2; i++) { |
---|
126 |
addRoute(eRS_ARX0, i, eRD_Mixer0, i+14); |
---|
127 |
} |
---|
128 |
for (i=0; i<2; i++) { |
---|
129 |
addRoute(eRS_Muted, 0, eRD_Mixer1, i); |
---|
130 |
} |
---|
131 |
// The two mute destinations |
---|
132 |
for (i=0; i<2; i++) { |
---|
133 |
addRoute(eRS_Mixer, i, eRD_Muted, 0); |
---|
134 |
} |
---|
135 |
} |
---|
136 |
|
---|
137 |
/** |
---|
138 |
* There must be 40 (?) destinations at mid samplerate |
---|
139 |
* Front LEDs are connected to the first four router entries |
---|
140 |
*/ |
---|
141 |
void |
---|
142 |
SaffirePro24::SaffirePro24EAP::setupDefaultRouterConfig_mid() { |
---|
143 |
unsigned int i; |
---|
144 |
// the 1394 stream receivers except the two "loops" one |
---|
145 |
// Looks like analogic inputs are curiously ordered |
---|
146 |
// (required for coherent front LEDs) |
---|
147 |
for (i=0; i<2; i++) { |
---|
148 |
addRoute(eRS_InS0, i+2, eRD_ATX0, i); |
---|
149 |
} |
---|
150 |
for (i=0; i<2; i++) { |
---|
151 |
addRoute(eRS_InS0, i, eRD_ATX0, i+2); |
---|
152 |
} |
---|
153 |
for (i=0; i<2; i++) { |
---|
154 |
addRoute(eRS_AES, i+6, eRD_ATX0, i+4); |
---|
155 |
} |
---|
156 |
for (i=0; i<4; i++) { |
---|
157 |
addRoute(eRS_ADAT, i, eRD_ATX0, i+6); |
---|
158 |
} |
---|
159 |
// The audio ports |
---|
160 |
// Ensure that audio port are not muted |
---|
161 |
for (i=0; i<6; i++) { |
---|
162 |
addRoute(eRS_ARX0, i%2, eRD_InS0, i); |
---|
163 |
} |
---|
164 |
// the SPDIF receiver |
---|
165 |
for (i=0; i<2; i++) { |
---|
166 |
addRoute(eRS_Muted, 0, eRD_AES, i+6); |
---|
167 |
} |
---|
168 |
// the "loops" 1394 stream receivers |
---|
169 |
for (i=0; i<2; i++) { |
---|
170 |
addRoute(eRS_Muted, 0, eRD_ATX0, i+10); |
---|
171 |
} |
---|
172 |
// the Mixer inputs |
---|
173 |
for (i=0; i<4; i++) { |
---|
174 |
addRoute(eRS_InS0, i, eRD_Mixer0, i); |
---|
175 |
} |
---|
176 |
for (i=0; i<2; i++) { |
---|
177 |
addRoute(eRS_AES, i+6, eRD_Mixer0, i+4); |
---|
178 |
} |
---|
179 |
for (i=0; i<4; i++) { |
---|
180 |
addRoute(eRS_ADAT, i, eRD_Mixer0, i+6); |
---|
181 |
} |
---|
182 |
for (i=0; i<2; i++) { |
---|
183 |
addRoute(eRS_ARX0, i, eRD_Mixer0, i+10); |
---|
184 |
} |
---|
185 |
for (i=0; i<4; i++) { |
---|
186 |
addRoute(eRS_Muted, 0, eRD_Mixer0, i+12); |
---|
187 |
} |
---|
188 |
for (i=0; i<2; i++) { |
---|
189 |
addRoute(eRS_Muted, 0, eRD_Mixer1, i); |
---|
190 |
} |
---|
191 |
// The two mute destinations |
---|
192 |
for (i=0; i<2; i++) { |
---|
193 |
addRoute(eRS_Mixer, i, eRD_Muted, 0); |
---|
194 |
} |
---|
195 |
} |
---|
196 |
|
---|
197 |
/** |
---|
198 |
* High rate not supported |
---|
199 |
*/ |
---|
200 |
void |
---|
201 |
SaffirePro24::SaffirePro24EAP::setupDefaultRouterConfig_high() { |
---|
202 |
printMessage("High (192 kHz) sample rate not supported by Saffire Pro 40\n"); |
---|
203 |
} |
---|
204 |
|
---|
205 |
/** |
---|
206 |
* Pro 24 Monitor section |
---|
207 |
*/ |
---|
208 |
SaffirePro24::SaffirePro24EAP::MonitorSection::MonitorSection(Dice::Focusrite::FocusriteEAP* eap, |
---|
209 |
std::string name) : Control::Container(eap, name) |
---|
210 |
, m_eap(eap) |
---|
211 |
{ |
---|
212 |
// Global Mute control |
---|
213 |
Control::Container* grp_globalmute = new Control::Container(m_eap, "GlobalMute"); |
---|
214 |
addElement(grp_globalmute); |
---|
215 |
FocusriteEAP::Switch* mute = |
---|
216 |
new FocusriteEAP::Switch(m_eap, "State", |
---|
217 |
SAFFIRE_PRO24_REGISTER_APP_GLOBAL_MUTE_SWITCH, |
---|
218 |
FOCUSRITE_EAP_GLOBAL_MUTE_SWITCH_VALUE, |
---|
219 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
220 |
SAFFIRE_PRO24_MESSAGE_SET_GLOBAL_DIM_MUTE_SWITCH); |
---|
221 |
grp_globalmute->addElement(mute); |
---|
222 |
|
---|
223 |
// Global Dim control |
---|
224 |
Control::Container* grp_globaldim = new Control::Container(m_eap, "GlobalDim"); |
---|
225 |
addElement(grp_globaldim); |
---|
226 |
FocusriteEAP::Switch* dim = |
---|
227 |
new FocusriteEAP::Switch(m_eap, "State", |
---|
228 |
SAFFIRE_PRO24_REGISTER_APP_GLOBAL_DIM_SWITCH, |
---|
229 |
FOCUSRITE_EAP_GLOBAL_DIM_SWITCH_VALUE, |
---|
230 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
231 |
SAFFIRE_PRO24_MESSAGE_SET_GLOBAL_DIM_MUTE_SWITCH); |
---|
232 |
grp_globaldim->addElement(dim); |
---|
233 |
FocusriteEAP::Poti* dimlevel = |
---|
234 |
new FocusriteEAP::Poti(m_eap, "Level", |
---|
235 |
SAFFIRE_PRO24_REGISTER_APP_GLOBAL_DIM_VOLUME, |
---|
236 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
237 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_MONITOR_VOLUME); |
---|
238 |
grp_globaldim->addElement(dimlevel); |
---|
239 |
|
---|
240 |
FocusriteEAP::Switch* s; |
---|
241 |
// Mono/stereo switch |
---|
242 |
Control::Container* grp_mono = new Control::Container(m_eap, "Mono"); |
---|
243 |
addElement(grp_mono); |
---|
244 |
for (unsigned int i=0; i<SAFFIRE_PRO24_APP_STEREO_LINEOUT_SIZE; ++i) { |
---|
245 |
std::stringstream stream; |
---|
246 |
stream << "Line" << i*2+1 << "Line" << i*2+2; |
---|
247 |
s = |
---|
248 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
249 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_SWITCH_CONTROL, |
---|
250 |
FOCUSRITE_EAP_SWITCH_CONTROL_VALUE |
---|
251 |
<<(FOCUSRITE_EAP_SWITCH_CONTROL_MONO_SHIFT+i), |
---|
252 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
253 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_SWITCH_CONTROL); |
---|
254 |
grp_mono->addElement(s); |
---|
255 |
} |
---|
256 |
|
---|
257 |
// Independent control of each line/out |
---|
258 |
Control::Container* grp_perchannel = new Control::Container(m_eap, "LineOut"); |
---|
259 |
addElement(grp_perchannel); |
---|
260 |
FocusriteEAP::VolumeControl* vol; |
---|
261 |
|
---|
262 |
// per Line/Out monitoring |
---|
263 |
for (unsigned int i=0; i<SAFFIRE_PRO24_APP_STEREO_LINEOUT_SIZE; ++i) { |
---|
264 |
std::stringstream stream; |
---|
265 |
|
---|
266 |
// Activate/Unactivate per Line/Out volume monitoring |
---|
267 |
stream.str(std::string()); |
---|
268 |
stream << "UnActivate" << i*2+1; |
---|
269 |
s = |
---|
270 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
271 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_MONITOR_SWITCH+i*sizeof(quadlet_t), |
---|
272 |
FOCUSRITE_EAP_SWITCH_BIT_1, |
---|
273 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
274 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_MONITOR_VOLUME); |
---|
275 |
grp_perchannel->addElement(s); |
---|
276 |
stream.str(std::string()); |
---|
277 |
stream << "UnActivate" << i*2+2; |
---|
278 |
s = |
---|
279 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
280 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_MONITOR_SWITCH+i*sizeof(quadlet_t), |
---|
281 |
FOCUSRITE_EAP_SWITCH_BIT_2, |
---|
282 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
283 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_MONITOR_VOLUME); |
---|
284 |
grp_perchannel->addElement(s); |
---|
285 |
|
---|
286 |
// per Line/Out mute/unmute |
---|
287 |
stream.str(std::string()); |
---|
288 |
stream << "Mute" << i*2+1; |
---|
289 |
s = |
---|
290 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
291 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_MONITOR_SWITCH+i*sizeof(quadlet_t), |
---|
292 |
FOCUSRITE_EAP_SWITCH_BIT_3, |
---|
293 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
294 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_MONITOR_VOLUME); |
---|
295 |
grp_perchannel->addElement(s); |
---|
296 |
stream.str(std::string()); |
---|
297 |
stream << "Mute" << i*2+2; |
---|
298 |
s = |
---|
299 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
300 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_MONITOR_SWITCH+i*sizeof(quadlet_t), |
---|
301 |
FOCUSRITE_EAP_SWITCH_BIT_4, |
---|
302 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
303 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_MONITOR_VOLUME); |
---|
304 |
grp_perchannel->addElement(s); |
---|
305 |
|
---|
306 |
// per Line/Out global mute activation/unactivation |
---|
307 |
stream.str(std::string()); |
---|
308 |
stream << "GMute" << 2*i+1; |
---|
309 |
s = |
---|
310 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
311 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_SWITCH_CONTROL, |
---|
312 |
FOCUSRITE_EAP_SWITCH_CONTROL_VALUE |
---|
313 |
<<(FOCUSRITE_EAP_SWITCH_CONTROL_MUTE_SHIFT+2*i), |
---|
314 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
315 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_SWITCH_CONTROL); |
---|
316 |
grp_perchannel->addElement(s); |
---|
317 |
|
---|
318 |
stream.str(std::string()); |
---|
319 |
stream << "GMute" << 2*i+2; |
---|
320 |
s = |
---|
321 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
322 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_SWITCH_CONTROL, |
---|
323 |
FOCUSRITE_EAP_SWITCH_CONTROL_VALUE |
---|
324 |
<<(FOCUSRITE_EAP_SWITCH_CONTROL_MUTE_SHIFT+2*i+1), |
---|
325 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
326 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_SWITCH_CONTROL); |
---|
327 |
grp_perchannel->addElement(s); |
---|
328 |
|
---|
329 |
// per Line/Out global dim activation/unactivation |
---|
330 |
stream.str(std::string()); |
---|
331 |
stream << "GDim" << 2*i+1; |
---|
332 |
s = |
---|
333 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
334 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_SWITCH_CONTROL, |
---|
335 |
FOCUSRITE_EAP_SWITCH_CONTROL_VALUE |
---|
336 |
<<(FOCUSRITE_EAP_SWITCH_CONTROL_DIM_SHIFT+2*i), |
---|
337 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
338 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_SWITCH_CONTROL); |
---|
339 |
grp_perchannel->addElement(s); |
---|
340 |
|
---|
341 |
stream.str(std::string()); |
---|
342 |
stream << "GDim" << 2*i+2; |
---|
343 |
s = |
---|
344 |
new FocusriteEAP::Switch(m_eap, stream.str(), |
---|
345 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_SWITCH_CONTROL, |
---|
346 |
FOCUSRITE_EAP_SWITCH_CONTROL_VALUE |
---|
347 |
<<(FOCUSRITE_EAP_SWITCH_CONTROL_DIM_SHIFT+2*i+1), |
---|
348 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
349 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_SWITCH_CONTROL); |
---|
350 |
grp_perchannel->addElement(s); |
---|
351 |
|
---|
352 |
// per Line/Out volume control |
---|
353 |
stream.str(std::string()); |
---|
354 |
stream << "Volume" << i*2+1; |
---|
355 |
vol = |
---|
356 |
new FocusriteEAP::VolumeControl(m_eap, stream.str(), |
---|
357 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_MONITOR_VOLUME |
---|
358 |
+i*sizeof(quadlet_t), |
---|
359 |
FOCUSRITE_EAP_LINEOUT_VOLUME_SET_1, |
---|
360 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
361 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_MONITOR_VOLUME); |
---|
362 |
grp_perchannel->addElement(vol); |
---|
363 |
stream.str(std::string()); |
---|
364 |
stream << "Volume" << i*2+2; |
---|
365 |
vol = |
---|
366 |
new FocusriteEAP::VolumeControl(m_eap, stream.str(), |
---|
367 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_MONITOR_VOLUME |
---|
368 |
+i*sizeof(quadlet_t), |
---|
369 |
FOCUSRITE_EAP_LINEOUT_VOLUME_SET_2, |
---|
370 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
371 |
SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_MONITOR_VOLUME); |
---|
372 |
grp_perchannel->addElement(vol); |
---|
373 |
} |
---|
374 |
|
---|
375 |
Control::Container* grp_LineInstGain = new Control::Container(m_eap, "LineInstGain"); |
---|
376 |
addElement(grp_LineInstGain); |
---|
377 |
FocusriteEAP::Switch* lineinst = |
---|
378 |
new FocusriteEAP::Switch(m_eap, "LineInst1", |
---|
379 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_INST_SWITCH, |
---|
380 |
SAFFIRE_PRO24_LINEOUT_SWITCH_INST_VALUE, |
---|
381 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
382 |
SAFFIRE_PRO24_MESSAGE_SET_INSTLINE); |
---|
383 |
grp_LineInstGain->addElement(lineinst); |
---|
384 |
lineinst = |
---|
385 |
new FocusriteEAP::Switch(m_eap, "LineInst2", |
---|
386 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_INST_SWITCH, |
---|
387 |
SAFFIRE_PRO24_LINEOUT_SWITCH_INST_VALUE |
---|
388 |
<<FOCUSRITE_EAP_LINEOUT_SWITCH_INST_SHIFT, |
---|
389 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
390 |
SAFFIRE_PRO24_MESSAGE_SET_INSTLINE); |
---|
391 |
grp_LineInstGain->addElement(lineinst); |
---|
392 |
lineinst = |
---|
393 |
new FocusriteEAP::Switch(m_eap, "LineGain3", |
---|
394 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_GAIN_SWITCH, |
---|
395 |
SAFFIRE_PRO24_LINEOUT_SWITCH_GAIN_VALUE, |
---|
396 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
397 |
SAFFIRE_PRO24_MESSAGE_SET_INSTLINE); |
---|
398 |
grp_LineInstGain->addElement(lineinst); |
---|
399 |
lineinst = |
---|
400 |
new FocusriteEAP::Switch(m_eap, "LineGain4", |
---|
401 |
SAFFIRE_PRO24_REGISTER_APP_LINEOUT_GAIN_SWITCH, |
---|
402 |
SAFFIRE_PRO24_LINEOUT_SWITCH_GAIN_VALUE |
---|
403 |
<<FOCUSRITE_EAP_LINEOUT_SWITCH_GAIN_SHIFT, |
---|
404 |
SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET, |
---|
405 |
SAFFIRE_PRO24_MESSAGE_SET_INSTLINE); |
---|
406 |
grp_LineInstGain->addElement(lineinst); |
---|
407 |
} |
---|
408 |
|
---|
409 |
SaffirePro24::SaffirePro24( DeviceManager& d, |
---|
410 |
std::auto_ptr<ConfigRom>( configRom )) |
---|
411 |
: Dice::Device(d , configRom) |
---|
412 |
{ |
---|
413 |
debugOutput(DEBUG_LEVEL_VERBOSE, "Created Dice::Focusrite::SaffirePro24 (NodeID %d)\n", |
---|
414 |
getConfigRom().getNodeId()); |
---|
415 |
} |
---|
416 |
|
---|
417 |
SaffirePro24::~SaffirePro24() |
---|
418 |
{ |
---|
419 |
//debugOutput(DEBUG_LEVEL_VERBOSE, "Deleting the saffirePro24\n"); |
---|
420 |
/// I wonder whether we should really save only on clean exits or also each time a setting is |
---|
421 |
// changed. Or should we provide a function (and thus gui-button) to save the state of the |
---|
422 |
// device? |
---|
423 |
getEAP()->storeFlashConfig(); |
---|
424 |
} |
---|
425 |
|
---|
426 |
bool SaffirePro24::discover() { |
---|
427 |
if (Dice::Device::discover()) { |
---|
428 |
fb_quadlet_t* version = (fb_quadlet_t *)calloc(2, sizeof(fb_quadlet_t)); |
---|
429 |
getEAP()->readRegBlock(Dice::EAP::eRT_Application, SAFFIRE_PRO24_REGISTER_APP_VERSION, version, 1*sizeof(fb_quadlet_t)); |
---|
430 |
// On August 2013, Focusrite released a new firmware. |
---|
431 |
// Version numbering 2.0 (0x00020000) seems common to all Saffire |
---|
432 |
// Dice EAP devices. |
---|
433 |
// Note: 0x00010004 and 0x00010008 stands for a firmware version |
---|
434 |
// not for a device identity. 0x00010004 is a pro24, 0x00010008 |
---|
435 |
// is the pro24dsp. |
---|
436 |
if (version[0] != 0x00010004 && version[0] != 0x00010008 && version[0] != 0x00020000) { |
---|
437 |
fprintf(stderr, "This is a Focusrite Saffire Pro24 but not the right firmware. Better stop here before something goes wrong.\n"); |
---|
438 |
fprintf(stderr, "This device has firmware 0x%x while we only know about versions 0x%x, 0x%x and 0x%x.\n", version[0], 0x10004, 0x10008, 0x00020000); |
---|
439 |
return false; |
---|
440 |
} |
---|
441 |
|
---|
442 |
// FIXME: What is the purpose of the following commented lines at this point ? |
---|
443 |
//getEAP()->readRegBlock(Dice::EAP::eRT_Command, 0x00, tmp, 2*sizeof(fb_quadlet_t)); // DEBUG |
---|
444 |
//hexDumpQuadlets(tmp, 2); // DEBUG |
---|
445 |
|
---|
446 |
FocusriteEAP* eap = dynamic_cast<FocusriteEAP*>(getEAP()); |
---|
447 |
SaffirePro24EAP::MonitorSection* monitor = new SaffirePro24EAP::MonitorSection(eap, "Monitoring"); |
---|
448 |
getEAP()->addElement(monitor); |
---|
449 |
return true; |
---|
450 |
} |
---|
451 |
return false; |
---|
452 |
} |
---|
453 |
|
---|
454 |
void SaffirePro24::showDevice() |
---|
455 |
{ |
---|
456 |
debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Focusrite::SaffirePro24\n"); |
---|
457 |
Dice::Device::showDevice(); |
---|
458 |
} |
---|
459 |
Dice::EAP* SaffirePro24::createEAP() { |
---|
460 |
return new SaffirePro24EAP(*this); |
---|
461 |
} |
---|
462 |
|
---|
463 |
bool SaffirePro24::setNickname( std::string name ) { |
---|
464 |
char nickname[SAFFIRE_PRO24_APP_NICK_NAME_SIZE+1]; |
---|
465 |
|
---|
466 |
// The device has room for SAFFIRE_PRO24_APP_NICK_NAME_SIZE characters. |
---|
467 |
// Erase supplementary characters or fill-in with NULL character if necessary |
---|
468 |
strncpy(nickname, name.c_str(), SAFFIRE_PRO24_APP_NICK_NAME_SIZE); |
---|
469 |
|
---|
470 |
// Strings from the device are always little-endian, |
---|
471 |
// so byteswap for big-endian machines |
---|
472 |
#if __BYTE_ORDER == __BIG_ENDIAN |
---|
473 |
byteSwapBlock((quadlet_t *)nickname, SAFFIRE_PRO24_APP_NICK_NAME_SIZE/4); |
---|
474 |
#endif |
---|
475 |
|
---|
476 |
if (!getEAP()->writeRegBlock(Dice::EAP::eRT_Application, SAFFIRE_PRO24_REGISTER_APP_NICK_NAME, |
---|
477 |
(quadlet_t*)nickname, SAFFIRE_PRO24_APP_NICK_NAME_SIZE)) { |
---|
478 |
debugError("Could not write nickname string \n"); |
---|
479 |
return false; |
---|
480 |
} |
---|
481 |
return true; |
---|
482 |
} |
---|
483 |
|
---|
484 |
std::string SaffirePro24::getNickname() { |
---|
485 |
char nickname[SAFFIRE_PRO24_APP_NICK_NAME_SIZE+1]; |
---|
486 |
if (!getEAP()->readRegBlock(Dice::EAP::eRT_Application, SAFFIRE_PRO24_REGISTER_APP_NICK_NAME, |
---|
487 |
(quadlet_t*)nickname, SAFFIRE_PRO24_APP_NICK_NAME_SIZE)){ |
---|
488 |
debugError("Could not read nickname string \n"); |
---|
489 |
return std::string("(unknown)"); |
---|
490 |
} |
---|
491 |
|
---|
492 |
// Strings from the device are always little-endian, |
---|
493 |
// so byteswap for big-endian machines |
---|
494 |
#if __BYTE_ORDER == __BIG_ENDIAN |
---|
495 |
byteSwapBlock((quadlet_t *)nickname, SAFFIRE_PRO24_APP_NICK_NAME_SIZE/4); |
---|
496 |
#endif |
---|
497 |
|
---|
498 |
// The device supplies at most SAFFIRE_PRO24_APP_NICK_NAME_SIZE characters. Ensure the string is |
---|
499 |
// NULL terminated. |
---|
500 |
nickname[SAFFIRE_PRO24_APP_NICK_NAME_SIZE] = 0; |
---|
501 |
return std::string(nickname); |
---|
502 |
} |
---|
503 |
|
---|
504 |
} |
---|
505 |
} |
---|
506 |
|
---|
507 |
// vim: et |
---|