root/trunk/libffado/src/dice/focusrite/saffire_pro40.cpp

Revision 2138, 8.6 kB (checked in by jwoithe, 11 years ago)

dice: default router setup patch 5/10 from Philippe Carriere: DICE EAP Saffire Pro 40 Introduce specific default routing functions

Line 
1 /*
2  * Copyright (C) 2009 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program 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
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "saffire_pro40.h"
25
26 #include "focusrite_eap.h"
27
28 namespace Dice {
29 namespace Focusrite {
30
31 int SaffirePro40::SaffirePro40EAP::commandToFix(unsigned offset) {
32     if (offset<0x14) return 2;
33     if (offset<0x3C && offset>=0x14) return 1;
34     if (offset<0x5C && offset>=0x54) return 1;
35     if (offset<0x44 && offset>=0x3C) return 3;
36     if (offset == 0x5C) return 4;
37     return 0;
38 }
39 FocusriteEAP::Poti* SaffirePro40::SaffirePro40EAP::getMonitorPoti(std::string name) {
40     return new FocusriteEAP::Poti(this, name, 0x54);
41 }
42 FocusriteEAP::Poti* SaffirePro40::SaffirePro40EAP::getDimPoti(std::string name) {
43     return new FocusriteEAP::Poti(this, name, 0x58);
44 }
45
46 //
47 // Under 48kHz Saffire pro 40 has
48 //  - 8 analogic inputs (mic/line)
49 //  - 8 ADAT inputs
50 //  - 2 SPDIF inputs
51 //  - 20 ieee1394 inputs
52 //  - 18 mixer inputs
53 //
54 //  - 10 analogic outputs
55 //  - 8 ADAT outputs
56 //  - 2 SPDIF outputs
57 //  - 20 ieee1394 outputs
58 //  - 16 mixer outputs
59 //
60 void SaffirePro40::SaffirePro40EAP::setupSources_low() {
61     addSource("SPDIF",  0,  2, eRS_AES, 1);
62     addSource("ADAT",   0,  8, eRS_ADAT, 1);
63     addSource("Mic/Lin", 16,  8, eRS_InS0, 1);
64     addSource("Mixer",  0, 16, eRS_Mixer, 1);
65     addSource("1394",   0, 12, eRS_ARX0, 1);
66     addSource("1394",   0,  8, eRS_ARX1, 13);
67     addSource("Mute",   0,  1, eRS_Muted);
68 }
69
70 void SaffirePro40::SaffirePro40EAP::setupDestinations_low() {
71     addDestination("SPDIF",  0,  2, eRD_AES, 1);
72     addDestination("ADAT",   0,  8, eRD_ADAT, 1);
73     addDestination("Line", 0,  2, eRD_InS0, 1);
74     addDestination("Line", 0,  8, eRD_InS1, 3);
75     addDestination("Mixer",  0, 16, eRD_Mixer0, 1);
76     addDestination("Mixer",  0,  2, eRD_Mixer1, 17);
77     addDestination("1394",   0, 10, eRD_ATX0, 1);
78     addDestination("1394",   0,  8, eRD_ATX1, 11);
79     addDestination("Loop",   8,  2, eRD_ATX1, 1);
80 // Is a Mute destination useful ?
81 //    addDestination("Mute",   0,  1, eRD_Muted);
82 }
83
84 //
85 // Under 96kHz Saffire pro 40 has
86 //  - 8 analogic inputs (mic/line)
87 //  - 4 ADAT inputs
88 //  - 2 SPDIF inputs
89 //  - 16 ieee1394 inputs
90 //  - 18 mixer inputs
91 //
92 //  - 10 analogic outputs
93 //  - 4 ADAT outputs
94 //  - 2 SPDIF outputs
95 //  - 16 ieee1394 outputs
96 //  - 16 mixer outputs
97 //
98 void SaffirePro40::SaffirePro40EAP::setupSources_mid() {
99     addSource("SPDIF",  0,  2, eRS_AES, 1);
100     addSource("ADAT",   0,  4, eRS_ADAT, 1);
101     addSource("Mic/Lin", 16,  8, eRS_InS0, 1);
102     addSource("Mixer",  0, 16, eRS_Mixer, 1);
103     addSource("1394",   0, 16, eRS_ARX0, 1);
104     addSource("Mute",   0,  1, eRS_Muted);
105 }
106
107 void SaffirePro40::SaffirePro40EAP::setupDestinations_mid() {
108     addDestination("SPDIF",  0,  2, eRD_AES, 1);
109     addDestination("ADAT",   0,  4, eRD_ADAT, 1);
110     addDestination("Line", 0,  2, eRD_InS0, 1);
111     addDestination("Line", 0,  8, eRD_InS1, 3);
112     addDestination("Mixer",  0, 16, eRD_Mixer0, 1);
113     addDestination("Mixer",  0,  2, eRD_Mixer1, 17);
114     addDestination("1394",   0, 14, eRD_ATX0, 1);
115     addDestination("Loop",   14, 2, eRD_ATX0, 1);
116 // Is a Mute destination useful ?
117 //    addDestination("Mute",   0,  1, eRD_Muted);
118 }
119
120 //
121 // 192 kHz is not supported
122 //
123 void SaffirePro40::SaffirePro40EAP::setupSources_high() {
124     printMessage("High (192 kHz) sample rate not supported by Saffire Pro 40\n");
125 }
126
127 void SaffirePro40::SaffirePro40EAP::setupDestinations_high() {
128     printMessage("High (192 kHz) sample rate not supported by Saffire Pro 40\n");
129 }
130
131 SaffirePro40::SaffirePro40( DeviceManager& d,
132                                         std::auto_ptr<ConfigRom>( configRom ))
133     : Dice::Device( d , configRom)
134 {
135     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Dice::Focusrite::SaffirePro40 (NodeID %d)\n",
136                  getConfigRom().getNodeId() );
137 }
138
139 /**
140  * The default configurations for the Saffire Pro 40 router.
141  *  For coherence with hardware, destinations must follow a specific ordering
142  *  There must be 60 destinations at low samplerate
143  *  Front LEDs are connected to the first eight router entries
144  */
145 void
146 SaffirePro40::SaffirePro40EAP::setupDefaultRouterConfig_low() {
147     unsigned int i;
148     // the 1394 stream receivers except the two "loops" one
149     for (i=0; i<8; i++) {
150         addRoute(eRS_InS0, i, eRD_ATX0, i);
151     }
152     for (i=0; i<2; i++) {
153         addRoute(eRS_ADAT, i, eRD_ATX0, i+8);
154     }
155     for (i=0; i<6; i++) {
156         addRoute(eRS_ADAT, i+2, eRD_ATX1, i);
157     }
158     for (i=0; i<2; i++) {
159         addRoute(eRS_AES, i, eRD_ATX1, i+6);
160     }
161     // The audio ports
162     // Ensure that audio port are not muted
163     for (i=0; i<2; i++) {
164         addRoute(eRS_ARX0, i, eRD_InS0, i);
165     }
166     for (i=0; i<8; i++) {
167       addRoute(eRS_ARX0, i%2, eRD_InS1, i);
168     }
169     // the SPDIF receiver
170     for (i=0; i<2; i++) {
171         addRoute(eRS_Muted, 0, eRD_AES, i);
172     }
173     // the ADAT receiver
174     for (i=0; i<8; i++) {
175         addRoute(eRS_Muted, 0, eRD_ADAT, i);
176     }
177     // the "loops" 1394 stream receivers
178     for (i=0; i<2; i++) {
179         addRoute(eRS_Muted, i, eRD_ATX1, i+8);
180     }
181     // the Mixer inputs
182     for (i=0; i<8; i++) {
183         addRoute(eRS_InS0, i, eRD_Mixer0, i);
184     }
185     for (i=0; i<8; i++) {
186         addRoute(eRS_ADAT, i, eRD_Mixer0, i+8);
187     }
188     for (i=0; i<2; i++) {
189         addRoute(eRS_ARX0, i, 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  *  There must be 52 destinations at mid samplerate
199  *  Front LEDs are connected to the first eight router entries
200  */
201 void
202 SaffirePro40::SaffirePro40EAP::setupDefaultRouterConfig_mid() {
203     unsigned int i;
204     // the 1394 stream receivers except the two "loops" one
205     for (i=0; i<8; i++) {
206         addRoute(eRS_InS0, i, eRD_ATX0, i);
207     }
208     for (i=0; i<4; i++) {
209         addRoute(eRS_ADAT, i, eRD_ATX0, i+8);
210     }
211     for (i=0; i<2; i++) {
212         addRoute(eRS_AES, i, eRD_ATX0, i+12);
213     }
214     // The audio ports
215     // Ensure that audio port are not muted
216     for (i=0; i<2; i++) {
217         addRoute(eRS_ARX0, i, eRD_InS0, i);
218     }
219     for (i=0; i<8; i++) {
220       addRoute(eRS_ARX0, i%2, eRD_InS1, i);
221     }
222     // the SPDIF receiver
223     for (i=0; i<2; i++) {
224         addRoute(eRS_Muted, 0, eRD_AES, i);
225     }
226     // the ADAT receiver
227     for (i=0; i<4; i++) {
228         addRoute(eRS_Muted, 0, eRD_ADAT, i);
229     }
230     // the "loops" 1394 stream receivers
231     for (i=0; i<2; i++) {
232         addRoute(eRS_Muted, i, eRD_ATX0, i+14);
233     }
234     // the Mixer inputs
235     for (i=0; i<8; i++) {
236         addRoute(eRS_InS0, i, eRD_Mixer0, i);
237     }
238     for (i=0; i<4; i++) {
239         addRoute(eRS_ADAT, i, eRD_Mixer0, i+8);
240     }
241     for (i=0; i<4; i++) {
242         addRoute(eRS_Muted, 0, eRD_Mixer0, i+12);
243     }
244     for (i=0; i<2; i++) {
245         addRoute(eRS_ARX0, i, eRD_Mixer1, i);
246     }
247     // The two mute destinations
248     for (i=0; i<2; i++) {
249         addRoute(eRS_Mixer, i, eRD_Muted, 0);
250     }
251 }
252
253 /**
254  *  High rate not supported
255  */
256 void
257 SaffirePro40::SaffirePro40EAP::setupDefaultRouterConfig_high() {
258     printMessage("High (192 kHz) sample rate not supported by Saffire Pro 40\n");
259 }
260
261 SaffirePro40::~SaffirePro40()
262 {
263     getEAP()->storeFlashConfig();
264 }
265
266 bool SaffirePro40::discover() {
267     if (Dice::Device::discover()) {
268         m_monitor = new FocusriteEAP::MonitorSection(dynamic_cast<FocusriteEAP*>(getEAP()), "Monitoring");
269         getEAP()->addElement(m_monitor);
270         return true;
271     }
272     return false;
273 }
274
275 void
276 SaffirePro40::showDevice()
277 {
278     debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Focusrite::SaffirePro40\n");
279     Dice::Device::showDevice();
280 }
281
282 Dice::EAP* SaffirePro40::createEAP() {
283     return new SaffirePro40EAP(*this);
284 }
285
286 bool SaffirePro40::setNickname(std::string name) {
287     return getEAP()->writeRegBlock(Dice::EAP::eRT_Application, 0x44, (quadlet_t*)name.c_str(), name.size());
288 }
289 std::string SaffirePro40::getNickname() {
290     char name[16];
291     getEAP()->readRegBlock(Dice::EAP::eRT_Application, 0x44, (quadlet_t*)name, 16);
292     return std::string(name);
293 }
294
295 }
296 }
297 // vim: et
Note: See TracBrowser for help on using the browser.