root/trunk/libffado/src/bebob/presonus/inspire1394_avdevice.cpp

Revision 2803, 5.8 kB (checked in by jwoithe, 3 years ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

Line 
1 /*
2  * Copyright (C) 2014      by Takashi Sakamoto
3  * Copyright (C) 2005-2008 by Pieter Palmers
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 "./inspire1394_avdevice.h"
26
27 #include "libutil/ByteSwap.h"
28 #include "libutil/cmd_serialize.h"
29
30 namespace BeBoB {
31 namespace Presonus {
32 namespace Inspire1394 {
33
34 Command::Command(Ieee1394Service& ieee1394service)
35     : VendorDependentCmd( ieee1394service )
36     , m_subfunc( 0x00 )
37     , m_idx( 0x00 )
38     , m_arg( 0x00 )
39 {
40     m_companyId = 0x000a92;
41     setSubunitType( AVC::eST_Audio );
42     setSubunitId( 0x00 );
43 }
44 bool Command::serialize( Util::Cmd::IOSSerialize& se )
45 {
46     bool result = true;
47     result &= VendorDependentCmd::serialize( se );
48     result &= se.write(m_subfunc, "Cmd subfunc");
49     result &= se.write(m_idx, "Cmd idx");
50     result &= se.write(m_arg, "Cmd arg");
51
52     return result;
53 }
54 bool Command::deserialize( Util::Cmd::IISDeserialize& de )
55 {
56     bool result = true;
57     result &= VendorDependentCmd::deserialize( de );
58     result &= de.read( &m_subfunc);
59     result &= de.read( &m_idx );
60     result &= de.read( &m_arg );
61
62     return result;
63 }
64
65 BinaryControl::BinaryControl(Device& parent,
66                 ECmdSubfunc subfunc,
67                 std::string name, std::string label, std::string desc)
68     : Control::Discrete(&parent)
69     , m_Parent(parent)
70     , m_subfunc( subfunc )
71 {
72     setName(name);
73     setLabel(label);
74     setDescription(desc);
75 }
76 bool BinaryControl::setValue(int idx, int v)
77 {
78     uint8_t val = v;
79
80     debugOutput(DEBUG_LEVEL_VERBOSE,
81                 "setValue for type: %d, idx: %d, val: %d\n",
82                 m_subfunc, idx, val);
83
84     if ( !m_Parent.setSpecificValue(m_subfunc, idx, val) ) {
85         debugError( "setSpecificValue failed\n" );
86         return false;
87     }
88
89     return true;
90 }
91 int BinaryControl::getValue(int idx)
92 {
93     uint8_t val;
94
95     if ( !m_Parent.getSpecificValue(m_subfunc, idx, &val) ) {
96         debugError( "getSpecificValue failed\n" );
97         return 0;
98     }
99
100     debugOutput(DEBUG_LEVEL_VERBOSE,
101                 "getValue for type: %d, idx: %d, val: %d\n",
102                 m_subfunc, idx, val);
103
104     return val;
105 }
106
107 Device::Device(DeviceManager& d, ffado_smartptr<ConfigRom>(configRom))
108     : BeBoB::Device( d, configRom )
109 {
110     addSpecificControls();
111 }
112 Device::~Device(void)
113 {
114 }
115 void Device::showDevice()
116 {
117     debugOutput(DEBUG_LEVEL_NORMAL,
118                 "This is a BeBoB::Presonus::Inspire1394::Device\n");
119     BeBoB::Device::showDevice();
120 }
121 bool Device::addSpecificControls(void)
122 {
123     Control::Container *ctls;
124     BinaryControl *ctl;
125     bool result = true;
126
127     debugOutput(DEBUG_LEVEL_VERBOSE,
128                 "Building a PreSonus Inspire1394 mixer...\n");
129
130     ctls = new Control::Container(this, "Preamp");
131     if ( !addElement(ctls) ) {
132         debugWarning("Could not register specific controls to device\n");
133         delete ctls;
134         return false;
135     }
136
137     // RIAA equalization curve for Analog In 3/4
138     ctl = new BinaryControl(*this, ECmdSubfuncPhono,
139                         "PhonoSwitch", "Phono Switch", "Phono Switch");
140     result &= ctls->addElement(ctl);
141
142     // 48V for Analog In 1/2
143     ctl = new BinaryControl(*this, ECmdSubfuncPhantom,
144                         "PhantomPower", "Phantom Power", "Phantom Power");
145     result &= ctls->addElement(ctl);
146
147     // +20dB for Analog In 1/2
148     ctl = new BinaryControl(*this, ECmdSubfuncBoost,
149                         "MicBoost", "Mic Boost", "Mic Boost");
150     result &= ctls->addElement(ctl);
151
152     // Limitter of preamp for Analog In 1/2
153     ctl = new BinaryControl(*this, ECmdSubfuncLimit,
154                         "MicLimit", "Mic Limit", "Mic Limit");
155     result &= ctls->addElement(ctl);
156
157     if ( !result ) {
158         debugWarning("Any controls could not be added\n");
159         destroyMixer();
160         return false;
161     }
162
163     return true;
164 }
165 bool Device::getSpecificValue(ECmdSubfunc subfunc,
166                                          int idx, uint8_t *val)
167 {
168     Command cmd( get1394Service() );
169     cmd.setCommandType( AVC::AVCCommand::eCT_Status );
170     cmd.setNodeId( getConfigRom().getNodeId() );
171     cmd.setVerbose( getDebugLevel() );
172
173     cmd.setSubfunc(subfunc);
174     cmd.setIdx(idx);
175     cmd.setArg(0xff);
176
177     if ( !cmd.fire() ) {
178         debugError( "Cmd failed\n" );
179         return false;
180     } else if (cmd.getResponse() != AVC::AVCCommand::eR_Implemented ) {
181         debugError("Cmd received error response\n");
182         return false;
183     }
184
185     *val = cmd.getArg();
186
187     return true;
188 }
189 bool Device::setSpecificValue(ECmdSubfunc subfunc,
190                                          int idx, uint8_t val)
191 {
192     Command cmd( get1394Service() );
193     cmd.setCommandType( AVC::AVCCommand::eCT_Control );
194     cmd.setNodeId( getConfigRom().getNodeId() );
195     cmd.setVerbose( getDebugLevel() );
196
197     cmd.setSubfunc(subfunc);
198     cmd.setIdx(idx);
199     cmd.setArg(val);
200
201     if ( !cmd.fire() ) {
202         debugError( "Cmd failed\n" );
203         return false;
204     } else if (cmd.getResponse() != AVC::AVCCommand::eR_Accepted) {
205         debugError("Cmd received error response\n");
206         return false;
207     }
208
209     return true;
210 }
211
212 } // namespace Inspire1394
213 } // namespace Presonus
214 } // namespace BeBoB
Note: See TracBrowser for help on using the browser.