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 |
namespace Dice { |
---|
29 |
namespace Focusrite { |
---|
30 |
|
---|
31 |
int SaffirePro24::SaffirePro24EAP::commandToFix(unsigned offset) { |
---|
32 |
if (offset<0x14) return 2; |
---|
33 |
if (offset<0x3C && offset>=0x14) return 1; |
---|
34 |
if (offset<0x58 && offset>=0x50) return 1; |
---|
35 |
if (offset<0x40 && offset>=0x3C) return 3; |
---|
36 |
if (offset<0x60 && offset>=0x58) return 4; |
---|
37 |
return 0; |
---|
38 |
} |
---|
39 |
FocusriteEAP::Poti* SaffirePro24::SaffirePro24EAP::getMonitorPoti(std::string name) { |
---|
40 |
return new FocusriteEAP::Poti(this, name, 0x50); |
---|
41 |
} |
---|
42 |
FocusriteEAP::Poti* SaffirePro24::SaffirePro24EAP::getDimPoti(std::string name) { |
---|
43 |
return new FocusriteEAP::Poti(this, name, 0x54); |
---|
44 |
} |
---|
45 |
|
---|
46 |
/* |
---|
47 |
void SaffirePro24::SaffirePro24EAP::setupSources() { |
---|
48 |
addSource("SPDIF", 6, 2, eRS_AES); |
---|
49 |
addSource("ADAT", 0, 8, eRS_ADAT); |
---|
50 |
addSource("Analog", 0, 4, eRS_InS0); |
---|
51 |
addSource("Mixer", 0, 16, eRS_Mixer); |
---|
52 |
addSource("1394", 0, 8, eRS_ARX0); |
---|
53 |
addSource("Mute", 0, 1, eRS_Muted); |
---|
54 |
} |
---|
55 |
void SaffirePro24::SaffirePro24EAP::setupDestinations() { |
---|
56 |
addDestination("SPDIF", 6, 2, eRD_AES); |
---|
57 |
addDestination("Analog", 0, 6, eRD_InS0); |
---|
58 |
addDestination("Mixer", 0, 16, eRD_Mixer0); |
---|
59 |
addDestination("Mixer", 0, 2, eRD_Mixer1, 16); |
---|
60 |
addDestination("1394", 0, 16, eRD_ATX0); |
---|
61 |
addDestination("Mute", 0, 1, eRD_Muted); |
---|
62 |
} |
---|
63 |
*/ |
---|
64 |
|
---|
65 |
void SaffirePro24::SaffirePro24EAP::setupSources_low() { |
---|
66 |
addSource("SPDIF", 6, 2, eRS_AES); |
---|
67 |
addSource("ADAT", 0, 8, eRS_ADAT); |
---|
68 |
addSource("Analog", 0, 4, eRS_InS0); |
---|
69 |
addSource("Mixer", 0, 8, eRS_Mixer); |
---|
70 |
addSource("1394", 0, 8, eRS_ARX0); |
---|
71 |
addSource("Mute", 0, 1, eRS_Muted); |
---|
72 |
} |
---|
73 |
void SaffirePro24::SaffirePro24EAP::setupDestinations_low() { |
---|
74 |
addDestination("SPDIF", 6, 2, eRD_AES); |
---|
75 |
addDestination("Analog", 0, 6, eRD_InS0); |
---|
76 |
addDestination("Mixer", 0, 16, eRD_Mixer0); |
---|
77 |
addDestination("Mixer", 0, 2, eRD_Mixer1, 16); |
---|
78 |
addDestination("1394", 0, 16, eRD_ATX0); |
---|
79 |
// Is a Mute destination useful ? |
---|
80 |
// addDestination("Mute", 0, 1, eRD_Muted); |
---|
81 |
} |
---|
82 |
|
---|
83 |
void SaffirePro24::SaffirePro24EAP::setupSources_mid() { |
---|
84 |
addSource("SPDIF", 6, 2, eRS_AES); |
---|
85 |
addSource("ADAT", 0, 4, eRS_ADAT); |
---|
86 |
addSource("Analog", 0, 4, eRS_InS0); |
---|
87 |
addSource("Mixer", 0, 16, eRS_Mixer); |
---|
88 |
addSource("1394", 0, 8, eRS_ARX0); |
---|
89 |
addSource("Mute", 0, 1, eRS_Muted); |
---|
90 |
} |
---|
91 |
void SaffirePro24::SaffirePro24EAP::setupDestinations_mid() { |
---|
92 |
addDestination("SPDIF", 6, 2, eRD_AES); |
---|
93 |
addDestination("Analog", 0, 6, eRD_InS0); |
---|
94 |
addDestination("Mixer", 0, 16, eRD_Mixer0); |
---|
95 |
addDestination("Mixer", 0, 2, eRD_Mixer1, 16); |
---|
96 |
addDestination("1394", 0, 12, eRD_ATX0); |
---|
97 |
// Is a Mute destination useful ? |
---|
98 |
// addDestination("Mute", 0, 1, eRD_Muted); |
---|
99 |
} |
---|
100 |
|
---|
101 |
void SaffirePro24::SaffirePro24EAP::setupSources_high() { |
---|
102 |
printMessage("High (192 kHz) sample rate not supported by Saffire Pro 24\n"); |
---|
103 |
} |
---|
104 |
|
---|
105 |
void SaffirePro24::SaffirePro24EAP::setupDestinations_high() { |
---|
106 |
printMessage("High (192 kHz) sample rate not supported by Saffire Pro 24\n"); |
---|
107 |
} |
---|
108 |
|
---|
109 |
class SaffirePro24::LineInstSwitch : public Dice::Focusrite::FocusriteEAP::Switch |
---|
110 |
{ |
---|
111 |
public: |
---|
112 |
LineInstSwitch(Dice::Focusrite::FocusriteEAP* eap, std::string name, size_t offset, int activevalue) |
---|
113 |
: Dice::Focusrite::FocusriteEAP::Switch(eap, name, offset, activevalue) {} |
---|
114 |
std::string getBooleanLabel(bool n) { |
---|
115 |
if ( n ) return "Instrument"; |
---|
116 |
return "Line"; |
---|
117 |
} |
---|
118 |
}; |
---|
119 |
class SaffirePro24::LevelSwitch : public Dice::Focusrite::FocusriteEAP::Switch |
---|
120 |
{ |
---|
121 |
public: |
---|
122 |
LevelSwitch(Dice::Focusrite::FocusriteEAP* eap, std::string name, size_t offset, int activevalue) |
---|
123 |
: Dice::Focusrite::FocusriteEAP::Switch(eap, name, offset, activevalue) {} |
---|
124 |
std::string getBooleanLabel(bool n) { |
---|
125 |
if ( n ) return "High"; |
---|
126 |
return "Low"; |
---|
127 |
} |
---|
128 |
}; |
---|
129 |
|
---|
130 |
SaffirePro24::SaffirePro24( DeviceManager& d, |
---|
131 |
std::auto_ptr<ConfigRom>( configRom )) |
---|
132 |
: Dice::Device(d , configRom) |
---|
133 |
, m_ch1(NULL) |
---|
134 |
, m_ch2(NULL) |
---|
135 |
{ |
---|
136 |
debugOutput(DEBUG_LEVEL_VERBOSE, "Created Dice::Focusrite::SaffirePro24 (NodeID %d)\n", |
---|
137 |
getConfigRom().getNodeId()); |
---|
138 |
} |
---|
139 |
|
---|
140 |
SaffirePro24::~SaffirePro24() |
---|
141 |
{ |
---|
142 |
//debugOutput(DEBUG_LEVEL_VERBOSE, "Deleting the saffirePro24\n"); |
---|
143 |
/// I wonder whether we should really save only on clean exits or also each time a setting is |
---|
144 |
// changed. Or should we provide a function (and thus gui-button) to save the state of the |
---|
145 |
// device? |
---|
146 |
getEAP()->storeFlashConfig(); |
---|
147 |
getEAP()->deleteElement(m_ch1); |
---|
148 |
getEAP()->deleteElement(m_ch2); |
---|
149 |
if (m_ch1) delete m_ch1; |
---|
150 |
if (m_ch2) delete m_ch2; |
---|
151 |
} |
---|
152 |
|
---|
153 |
bool SaffirePro24::discover() { |
---|
154 |
if (Dice::Device::discover()) { |
---|
155 |
fb_quadlet_t* tmp = (fb_quadlet_t *)calloc(2, sizeof(fb_quadlet_t)); |
---|
156 |
getEAP()->readRegBlock(Dice::EAP::eRT_Application, 0x00, tmp, 1*sizeof(fb_quadlet_t)); |
---|
157 |
//hexDumpQuadlets(tmp, 2); // DEBUG |
---|
158 |
if (tmp[0] != 0x00010004 ) { |
---|
159 |
debugError("This is a Focusrite Saffire Pro24 but not the right firmware. Better stop here before something goes wrong.\n"); |
---|
160 |
debugError("This device has firmware 0x%x while we only know about version 0x%x.\n", tmp[0], 0x10004); |
---|
161 |
return false; |
---|
162 |
} |
---|
163 |
//getEAP()->readRegBlock(Dice::EAP::eRT_Command, 0x00, tmp, 2*sizeof(fb_quadlet_t)); // DEBUG |
---|
164 |
//hexDumpQuadlets(tmp, 2); // DEBUG |
---|
165 |
|
---|
166 |
FocusriteEAP* eap = dynamic_cast<FocusriteEAP*>(getEAP()); |
---|
167 |
m_ch1 = new LineInstSwitch(eap, "Ch1LineInst", 0x58, 2); |
---|
168 |
getEAP()->addElement(m_ch1); |
---|
169 |
m_ch2 = new LineInstSwitch(eap, "Ch2LineInst", 0x58, 2<<16); |
---|
170 |
getEAP()->addElement(m_ch2); |
---|
171 |
m_ch3 = new LevelSwitch(eap, "Ch3Level", 0x5C, 1); |
---|
172 |
getEAP()->addElement(m_ch3); |
---|
173 |
m_ch4 = new LevelSwitch(eap, "Ch4Level", 0x5C, 1<<16); |
---|
174 |
getEAP()->addElement(m_ch4); |
---|
175 |
|
---|
176 |
m_monitor = new FocusriteEAP::MonitorSection(eap, "Monitoring"); |
---|
177 |
getEAP()->addElement(m_monitor); |
---|
178 |
return true; |
---|
179 |
} |
---|
180 |
return false; |
---|
181 |
} |
---|
182 |
|
---|
183 |
void SaffirePro24::showDevice() |
---|
184 |
{ |
---|
185 |
debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Focusrite::SaffirePro24\n"); |
---|
186 |
Dice::Device::showDevice(); |
---|
187 |
} |
---|
188 |
Dice::EAP* SaffirePro24::createEAP() { |
---|
189 |
return new SaffirePro24EAP(*this); |
---|
190 |
} |
---|
191 |
|
---|
192 |
bool SaffirePro24::setNickname( std::string name ) { |
---|
193 |
return getEAP()->writeRegBlock( Dice::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name.c_str(), name.size() ); |
---|
194 |
} |
---|
195 |
|
---|
196 |
std::string SaffirePro24::getNickname() { |
---|
197 |
char name[16]; |
---|
198 |
getEAP()->readRegBlock( Dice::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name, 16 ); |
---|
199 |
return std::string( name ); |
---|
200 |
} |
---|
201 |
|
---|
202 |
} |
---|
203 |
} |
---|
204 |
|
---|
205 |
// vim: et |
---|