1 |
/* |
---|
2 |
* Copyright (C) 2005-2008 by Pieter Palmers |
---|
3 |
* Copyright (C) 2008-2009 by Jonathan Woithe |
---|
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 |
#include "rme/rme_avdevice.h" |
---|
25 |
#include "rme/fireface_settings_ctrls.h" |
---|
26 |
|
---|
27 |
namespace Rme { |
---|
28 |
|
---|
29 |
RmeSettingsCtrl::RmeSettingsCtrl(Device &parent, unsigned int type, |
---|
30 |
unsigned int info) |
---|
31 |
: Control::Discrete(&parent) |
---|
32 |
, m_parent(parent) |
---|
33 |
, m_type(type) |
---|
34 |
, m_value(0) |
---|
35 |
, m_info(info) |
---|
36 |
{ |
---|
37 |
} |
---|
38 |
|
---|
39 |
RmeSettingsCtrl::RmeSettingsCtrl(Device &parent, unsigned int type, |
---|
40 |
unsigned int info, |
---|
41 |
std::string name, std::string label, std::string descr) |
---|
42 |
: Control::Discrete(&parent) |
---|
43 |
, m_parent(parent) |
---|
44 |
, m_type(type) |
---|
45 |
, m_value(0) |
---|
46 |
, m_info(info) |
---|
47 |
{ |
---|
48 |
setName(name); |
---|
49 |
setLabel(label); |
---|
50 |
setDescription(descr); |
---|
51 |
} |
---|
52 |
|
---|
53 |
bool |
---|
54 |
RmeSettingsCtrl::setValue(int v) { |
---|
55 |
|
---|
56 |
signed int i; |
---|
57 |
signed int err = 0; |
---|
58 |
|
---|
59 |
switch (m_type) { |
---|
60 |
case RME_CTRL_NONE: |
---|
61 |
debugOutput(DEBUG_LEVEL_ERROR, "control has no type set\n"); |
---|
62 |
err = 1; |
---|
63 |
break; |
---|
64 |
case RME_CTRL_PHANTOM_SW: |
---|
65 |
// Lowest 16 bits are phantom status bits (max 16 channels). |
---|
66 |
// High 16 bits are "write enable" bits for the corresponding |
---|
67 |
// channel represented in the low 16 bits. This way changes can |
---|
68 |
// be made to one channel without needing to first read the |
---|
69 |
// existing value. |
---|
70 |
// |
---|
71 |
// At present there are at most 4 phantom-capable channels. |
---|
72 |
// Flag attempts to write to the bits corresponding to channels |
---|
73 |
// beyond this. |
---|
74 |
if (v & 0xfff00000) { |
---|
75 |
debugOutput(DEBUG_LEVEL_WARNING, "Ignored out-of-range phantom set request: mask=0x%04x, value=0x%04x\n", |
---|
76 |
(v >> 16) & 0xfff0, v && 0xfff0); |
---|
77 |
} |
---|
78 |
|
---|
79 |
for (i=0; i<4; i++) { |
---|
80 |
if (v & (0x00010000 << i)) { |
---|
81 |
unsigned int on = (v & (0x00000001 << i)) != 0; |
---|
82 |
err = m_parent.setPhantom(i, on); |
---|
83 |
if (!err) { |
---|
84 |
if (on) { |
---|
85 |
m_value |= (0x01 << i); |
---|
86 |
} else { |
---|
87 |
m_value &= ~(0x01 << i); |
---|
88 |
} |
---|
89 |
} |
---|
90 |
} |
---|
91 |
} |
---|
92 |
break; |
---|
93 |
case RME_CTRL_INPUT_LEVEL: |
---|
94 |
if (m_parent.setInputLevel(v)) { |
---|
95 |
m_value = v; |
---|
96 |
} |
---|
97 |
break; |
---|
98 |
case RME_CTRL_OUTPUT_LEVEL: |
---|
99 |
if (m_parent.setOutputLevel(v)) { |
---|
100 |
m_value = v; |
---|
101 |
} |
---|
102 |
break; |
---|
103 |
case RME_CTRL_FF400_PAD_SW: |
---|
104 |
// Object's "m_info" field is the channel |
---|
105 |
if (m_parent.setInputPadOpt(m_info, v)) { |
---|
106 |
m_value = (v != 0); |
---|
107 |
} |
---|
108 |
break; |
---|
109 |
case RME_CTRL_FF400_INSTR_SW: |
---|
110 |
// Object's "m_info" field is the channel |
---|
111 |
if (m_parent.setInputInstrOpt(m_info, v)) { |
---|
112 |
m_value = (v != 0); |
---|
113 |
} |
---|
114 |
break; |
---|
115 |
case RME_CTRL_PHONES_LEVEL: |
---|
116 |
if (m_parent.setPhonesLevel(v)) { |
---|
117 |
m_value = v; |
---|
118 |
} |
---|
119 |
break; |
---|
120 |
|
---|
121 |
// All RME_CTRL_INFO_* controls are read-only. Warn on attempts to |
---|
122 |
// set these. |
---|
123 |
case RME_CTRL_INFO_MODEL: |
---|
124 |
case RME_CTRL_INFO_TCO_PRESENT: |
---|
125 |
debugOutput(DEBUG_LEVEL_ERROR, "Attempt to set readonly info control 0x%08x\n", m_type); |
---|
126 |
err = 1; |
---|
127 |
break; |
---|
128 |
|
---|
129 |
default: |
---|
130 |
debugOutput(DEBUG_LEVEL_ERROR, "Unknown control type 0x%08x\n", m_type); |
---|
131 |
err = 1; |
---|
132 |
} |
---|
133 |
|
---|
134 |
return err==0?true:false; |
---|
135 |
} |
---|
136 |
|
---|
137 |
int |
---|
138 |
RmeSettingsCtrl::getValue() { |
---|
139 |
|
---|
140 |
signed int i; |
---|
141 |
signed int val = 0; |
---|
142 |
|
---|
143 |
switch (m_type) { |
---|
144 |
case RME_CTRL_NONE: |
---|
145 |
debugOutput(DEBUG_LEVEL_ERROR, "control has no type set\n"); |
---|
146 |
break; |
---|
147 |
|
---|
148 |
case RME_CTRL_PHANTOM_SW: |
---|
149 |
for (i=0; i<3; i++) |
---|
150 |
val |= (m_parent.getPhantom(i) << i); |
---|
151 |
return val; |
---|
152 |
break; |
---|
153 |
case RME_CTRL_INPUT_LEVEL: |
---|
154 |
return m_parent.getInputLevel(); |
---|
155 |
break; |
---|
156 |
case RME_CTRL_OUTPUT_LEVEL: |
---|
157 |
return m_parent.getOutputLevel(); |
---|
158 |
break; |
---|
159 |
case RME_CTRL_FF400_PAD_SW: |
---|
160 |
return m_parent.getInputPadOpt(m_info); |
---|
161 |
break; |
---|
162 |
case RME_CTRL_FF400_INSTR_SW: |
---|
163 |
return m_parent.getInputInstrOpt(m_info); |
---|
164 |
break; |
---|
165 |
case RME_CTRL_PHONES_LEVEL: |
---|
166 |
return m_parent.getPhonesLevel(); |
---|
167 |
break; |
---|
168 |
|
---|
169 |
case RME_CTRL_INFO_MODEL: |
---|
170 |
return m_parent.getRmeModel(); |
---|
171 |
break; |
---|
172 |
|
---|
173 |
case RME_CTRL_INFO_TCO_PRESENT: |
---|
174 |
return m_parent.getTcoPresent(); |
---|
175 |
|
---|
176 |
default: |
---|
177 |
debugOutput(DEBUG_LEVEL_ERROR, "Unknown control type 0x%08x\n", m_type); |
---|
178 |
} |
---|
179 |
|
---|
180 |
return 0; |
---|
181 |
} |
---|
182 |
|
---|
183 |
|
---|
184 |
RmeSettingsMatrixCtrl::RmeSettingsMatrixCtrl(Device &parent, unsigned int type) |
---|
185 |
: Control::MatrixMixer(&parent) |
---|
186 |
, m_parent(parent) |
---|
187 |
, m_type(type) |
---|
188 |
{ |
---|
189 |
} |
---|
190 |
|
---|
191 |
RmeSettingsMatrixCtrl::RmeSettingsMatrixCtrl(Device &parent, unsigned int type, |
---|
192 |
std::string name) |
---|
193 |
: Control::MatrixMixer(&parent) |
---|
194 |
, m_parent(parent) |
---|
195 |
, m_type(type) |
---|
196 |
{ |
---|
197 |
setName(name); |
---|
198 |
} |
---|
199 |
|
---|
200 |
void RmeSettingsMatrixCtrl::show() |
---|
201 |
{ |
---|
202 |
debugOutput(DEBUG_LEVEL_NORMAL, "RME matrix mixer type %d\n", m_type); |
---|
203 |
} |
---|
204 |
|
---|
205 |
std::string RmeSettingsMatrixCtrl::getRowName(const int row) |
---|
206 |
{ |
---|
207 |
char buf[64]; |
---|
208 |
snprintf(buf, sizeof(buf), "RmeSettingsMatrixCtrl type %d, row %d", m_type, row); |
---|
209 |
return buf; |
---|
210 |
} |
---|
211 |
|
---|
212 |
std::string RmeSettingsMatrixCtrl::getColName(const int col) |
---|
213 |
{ |
---|
214 |
char buf[64]; |
---|
215 |
snprintf(buf, sizeof(buf), "RmeSettingsMatrixCtrl type %d, column %d", m_type, col); |
---|
216 |
return buf; |
---|
217 |
} |
---|
218 |
|
---|
219 |
int RmeSettingsMatrixCtrl::getRowCount() |
---|
220 |
{ |
---|
221 |
switch (m_type) { |
---|
222 |
case RME_MATRIXCTRL_GAINS: |
---|
223 |
if (m_parent.getRmeModel() == RME_MODEL_FIREFACE400) |
---|
224 |
return 1; |
---|
225 |
break; |
---|
226 |
} |
---|
227 |
|
---|
228 |
return 0; |
---|
229 |
} |
---|
230 |
|
---|
231 |
int RmeSettingsMatrixCtrl::getColCount() |
---|
232 |
{ |
---|
233 |
switch (m_type) { |
---|
234 |
case RME_MATRIXCTRL_GAINS: |
---|
235 |
if (m_parent.getRmeModel() == RME_MODEL_FIREFACE400) |
---|
236 |
return 22; |
---|
237 |
break; |
---|
238 |
} |
---|
239 |
|
---|
240 |
return 0; |
---|
241 |
} |
---|
242 |
|
---|
243 |
double RmeSettingsMatrixCtrl::setValue(const int row, const int col, const double val) |
---|
244 |
{ |
---|
245 |
signed int ret = true; |
---|
246 |
signed int i; |
---|
247 |
|
---|
248 |
switch (m_type) { |
---|
249 |
case RME_MATRIXCTRL_GAINS: |
---|
250 |
i = val; |
---|
251 |
if (i >= 0) |
---|
252 |
ret = m_parent.setAmpGain(col, val); |
---|
253 |
else |
---|
254 |
ret = -1; |
---|
255 |
break; |
---|
256 |
} |
---|
257 |
|
---|
258 |
return ret; |
---|
259 |
} |
---|
260 |
|
---|
261 |
double RmeSettingsMatrixCtrl::getValue(const int row, const int col) |
---|
262 |
{ |
---|
263 |
double val = 0.0; |
---|
264 |
switch (m_type) { |
---|
265 |
case RME_MATRIXCTRL_GAINS: |
---|
266 |
val = m_parent.getAmpGain(col); |
---|
267 |
break; |
---|
268 |
} |
---|
269 |
|
---|
270 |
return val; |
---|
271 |
} |
---|
272 |
|
---|
273 |
|
---|
274 |
} |
---|