root/trunk/libffado/src/rme/rme_avdevice_settings.cpp

Revision 1622, 4.9 kB (checked in by jwoithe, 14 years ago)

RME: input, output and phones mixer/control elements now control respective device parameters

Line 
1 /*
2  * Copyright (C) 2005-2009 by Jonathan Woithe
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 #include "rme/rme_avdevice.h"
24 #include "rme/fireface_def.h"
25
26 #include "debugmodule/debugmodule.h"
27
28 namespace Rme {
29
30 signed int
31 Device::getPhantom(unsigned int channel) {
32
33     if (channel > 3) {
34         debugOutput(DEBUG_LEVEL_WARNING, "Channel %d phantom power not supported\n", channel);
35         return -1;
36     }
37
38     return settings.mic_phantom[channel] != 0;
39 }
40
41 signed int
42 Device::setPhantom(unsigned int channel, unsigned int status) {
43
44     if (channel > 3) {
45         debugOutput(DEBUG_LEVEL_WARNING, "Channel %d phantom power not supported\n", channel);
46         return -1;
47     }
48
49     settings.mic_phantom[channel] = (status != 0);
50     set_hardware_params();
51
52     return 0;
53 }
54
55 signed int
56 Device::getInputLevel(void) {
57     return settings.input_level;
58 }
59
60 signed int
61 Device::setInputLevel(unsigned int level) {
62
63     if (level<FF_SWPARAM_ILEVEL_LOGAIN || level>FF_SWPARAM_ILEVEL_m10dBV) {
64         debugOutput(DEBUG_LEVEL_WARNING, "Invalid input level ID %d\n", level);
65         return -1;
66     }
67     settings.input_level = level;
68     set_hardware_params();
69
70     return 0;
71 }
72
73 signed int
74 Device::getOutputLevel(void) {
75     return settings.output_level;
76 }
77
78 signed int
79 Device::setOutputLevel(unsigned int level) {
80
81     if (level<FF_SWPARAM_OLEVEL_HIGAIN || level>FF_SWPARAM_OLEVEL_m10dBV) {
82         debugOutput(DEBUG_LEVEL_WARNING, "Invalid output level ID %d\n", level);
83         return -1;
84     }
85     settings.output_level = level;
86     set_hardware_params();
87
88     return 0;
89 }
90
91 signed int
92 Device::getPhonesLevel(void) {
93     return settings.phones_level;
94 }
95
96 signed int
97 Device::setPhonesLevel(unsigned int level) {
98
99     if (level<FF_SWPARAM_PHONESLEVEL_HIGAIN || level>FF_SWPARAM_PHONESLEVEL_m10dBV) {
100         debugOutput(DEBUG_LEVEL_WARNING, "Invalid phones level ID %d\n", level);
101         return -1;
102     }
103     settings.phones_level = level;
104     set_hardware_params();
105
106     return 0;
107 }
108
109 signed int
110 Device::getInputPadOpt(unsigned int channel) {
111     if (m_rme_model!=RME_MODEL_FIREFACE400 || channel<3 || channel>4) {
112         debugOutput(DEBUG_LEVEL_WARNING, "Channel %d input pad option not supported for model %d\n", channel, m_rme_model);
113         return -1;
114     }
115     return settings.ff400_input_pad[channel-3] != 0;
116 }
117
118 signed int
119 Device::setInputPadOpt(unsigned int channel, unsigned int status) {
120     if (m_rme_model!=RME_MODEL_FIREFACE400 || channel<3 || channel>4) {
121         debugOutput(DEBUG_LEVEL_WARNING, "Channel %d input pad option not supported for model %d\n", channel, m_rme_model);
122         return -1;
123     }
124     settings.ff400_input_pad[channel-3] = (status != 0);
125     set_hardware_params();
126     return 0;
127 }
128
129 signed int
130 Device::getInputInstrOpt(unsigned int channel) {
131     if (m_rme_model!=RME_MODEL_FIREFACE400 || channel<3 || channel>4) {
132         debugOutput(DEBUG_LEVEL_WARNING, "Channel %d input instrument option not supported for model %d\n", channel, m_rme_model);
133         return -1;
134     }
135     return settings.ff400_instr_input[channel-3] != 0;
136 }
137
138 signed int
139 Device::setInputInstrOpt(unsigned int channel, unsigned int status) {
140     if (m_rme_model!=RME_MODEL_FIREFACE400 || channel<3 || channel>4) {
141         debugOutput(DEBUG_LEVEL_WARNING, "Channel %d input instrument option not supported for model %d\n", channel, m_rme_model);
142         return -1;
143     }
144     settings.ff400_instr_input[channel-3] = (status != 0);
145     set_hardware_params();
146     return 0;
147 }
148
149 signed int
150 Device::getAmpGain(unsigned int index) {
151     if (m_rme_model != RME_MODEL_FIREFACE400) {
152         debugOutput(DEBUG_LEVEL_WARNING, "Amp gains only supported on FF400\n");
153         return -1;
154     }
155     if (index > 21) {
156         debugOutput(DEBUG_LEVEL_WARNING, "Amp gain index %d invalid\n", index);
157          return -1;
158     }
159     return settings.amp_gains[index];
160 }
161
162 signed int
163 Device::setAmpGain(unsigned int index, signed int val) {
164
165     if (m_rme_model != RME_MODEL_FIREFACE400) {
166         debugOutput(DEBUG_LEVEL_WARNING, "Amp gains only supported on FF400\n");
167         return -1;
168     }
169     if (index > 21) {
170         debugOutput(DEBUG_LEVEL_WARNING, "Amp gain index %d invalid\n", index);
171          return -1;
172     }
173     settings.amp_gains[index] = val & 0xff;
174     return set_hardware_ampgain(index, val);
175 }
176
177 }
Note: See TracBrowser for help on using the browser.