2 * Copyright (C) 2014 by Takashi Sakamoto
3 * Copyright (C) 2005-2008 by Pieter Palmers
5 * This file is part of FFADO
6 * FFADO = Free Firewire (pro-)audio drivers for linux
8 * FFADO is based upon FreeBoB.
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.
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.
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/>.
25 #include "./inspire1394_avdevice.h"
27 #include "libutil/ByteSwap.h"
28 #include "libutil/cmd_serialize.h"
33 Inspire1394Cmd::Inspire1394Cmd(Ieee1394Service
& ieee1394service
)
34 : VendorDependentCmd( ieee1394service
)
39 m_companyId
= 0x000a92;
40 setSubunitType( AVC::eST_Audio
);
43 bool Inspire1394Cmd::serialize( Util::Cmd::IOSSerialize
& se
)
46 result
&= VendorDependentCmd::serialize( se
);
47 result
&= se
.write(m_subfunc
, "Inspire1394Cmd subfunc");
48 result
&= se
.write(m_idx
, "Inspire1394Cmd idx");
49 result
&= se
.write(m_arg
, "Inspire1394Cmd arg");
53 bool Inspire1394Cmd::deserialize( Util::Cmd::IISDeserialize
& de
)
56 result
&= VendorDependentCmd::deserialize( de
);
57 result
&= de
.read( &m_subfunc
);
58 result
&= de
.read( &m_idx
);
59 result
&= de
.read( &m_arg
);
64 BinaryControl::BinaryControl(Inspire1394Device
& parent
,
65 EInspire1394CmdSubfunc subfunc
,
66 std::string name
, std::string label
, std::string desc
)
67 : Control::Discrete(&parent
)
69 , m_subfunc( subfunc
)
75 bool BinaryControl::setValue(int idx
, int v
)
79 debugOutput(DEBUG_LEVEL_VERBOSE
,
80 "setValue for type: %d, idx: %d, val: %d\n",
83 if ( !m_Parent
.setSpecificValue(m_subfunc
, idx
, val
) ) {
84 debugError( "setSpecificValue failed\n" );
90 int BinaryControl::getValue(int idx
)
94 if ( !m_Parent
.getSpecificValue(m_subfunc
, idx
, &val
) ) {
95 debugError( "getSpecificValue failed\n" );
99 debugOutput(DEBUG_LEVEL_VERBOSE
,
100 "getValue for type: %d, idx: %d, val: %d\n",
101 m_subfunc
, idx
, val
);
106 Inspire1394Device::Inspire1394Device(DeviceManager
& d
,
107 std::auto_ptr
<ConfigRom
>(configRom
))
108 : BeBoB::Device( d
, configRom
)
110 addSpecificControls();
112 Inspire1394Device::~Inspire1394Device(void)
115 void Inspire1394Device::showDevice()
117 debugOutput(DEBUG_LEVEL_NORMAL
,
118 "This is a BeBoB::Presonus::Inspire1394Device\n");
119 BeBoB::Device::showDevice();
121 bool Inspire1394Device::addSpecificControls(void)
123 Control::Container
*ctls
;
127 debugOutput(DEBUG_LEVEL_VERBOSE
,
128 "Building a PreSonus Inspire1394 mixer...\n");
130 ctls
= new Control::Container(this, "Preamp");
131 if ( !addElement(ctls
) ) {
132 debugWarning("Could not register specific controls to device\n");
137 // RIAA equalization curve for Analog In 3/4
138 ctl
= new BinaryControl(*this, EInspire1394CmdSubfuncPhono
,
139 "PhonoSwitch", "Phono Switch", "Phono Switch");
140 result
&= ctls
->addElement(ctl
);
142 // 48V for Analog In 1/2
143 ctl
= new BinaryControl(*this, EInspire1394CmdSubfuncPhantom
,
144 "PhantomPower", "Phantom Power", "Phantom Power");
145 result
&= ctls
->addElement(ctl
);
147 // +20dB for Analog In 1/2
148 ctl
= new BinaryControl(*this, EInspire1394CmdSubfuncBoost
,
149 "MicBoost", "Mic Boost", "Mic Boost");
150 result
&= ctls
->addElement(ctl
);
152 // Limitter of preamp for Analog In 1/2
153 ctl
= new BinaryControl(*this, EInspire1394CmdSubfuncLimit
,
154 "MicLimit", "Mic Limit", "Mic Limit");
155 result
&= ctls
->addElement(ctl
);
158 debugWarning("Any controls could not be added\n");
165 bool Inspire1394Device::getSpecificValue(EInspire1394CmdSubfunc subfunc
,
166 int idx
, uint8_t *val
)
168 Inspire1394Cmd
cmd( get1394Service() );
169 cmd
.setCommandType( AVC::AVCCommand::eCT_Status
);
170 cmd
.setNodeId( getConfigRom().getNodeId() );
171 cmd
.setVerbose( getDebugLevel() );
173 cmd
.setSubfunc(subfunc
);
178 debugError( "Inspire1394Cmd failed\n" );
180 } else if (cmd
.getResponse() != AVC::AVCCommand::eR_Implemented
) {
181 debugError("Inspire1394Cmd received error response\n");
189 bool Inspire1394Device::setSpecificValue(EInspire1394CmdSubfunc subfunc
,
190 int idx
, uint8_t val
)
192 Inspire1394Cmd
cmd( get1394Service() );
193 cmd
.setCommandType( AVC::AVCCommand::eCT_Control
);
194 cmd
.setNodeId( getConfigRom().getNodeId() );
195 cmd
.setVerbose( getDebugLevel() );
197 cmd
.setSubfunc(subfunc
);
202 debugError( "Inspire1394Cmd failed\n" );
204 } else if (cmd
.getResponse() != AVC::AVCCommand::eR_Accepted
) {
205 debugError("Inspire1394Cmd received error response\n");
212 } // namespace Presonus