2 * Copyright (C) 2005-2008 by Daniel Wagner
4 * This file is part of FFADO
5 * FFADO = Free Firewire (pro-)audio drivers for linux
7 * FFADO is based upon FreeBoB
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.
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.
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/>.
24 #ifndef BEBOB_FUNCTION_BLOCK_H
25 #define BEBOB_FUNCTION_BLOCK_H
27 #include "bebob/bebob_avplug.h"
29 #include "libavc/avc_definitions.h"
31 #include "debugmodule/debugmodule.h"
43 enum EFunctionBlockType
{
44 eFBT_AllFunctionBlockType
= 0xff,
45 eFBT_AudioSubunitSelector
= 0x80,
46 eFBT_AudioSubunitFeature
= 0x81,
47 eFBT_AudioSubunitProcessing
= 0x82,
48 eFBT_AudioSubunitCodec
= 0x83,
51 enum ESpecialPurpose
{
57 FunctionBlock( AVC::Subunit
& subunit
,
58 AVC::function_block_type_t type
,
59 AVC::function_block_type_t subtype
,
60 AVC::function_block_id_t id
,
61 ESpecialPurpose purpose
,
62 AVC::no_of_input_plugs_t nrOfInputPlugs
,
63 AVC::no_of_output_plugs_t nrOfOutputPlugs
,
65 FunctionBlock( const FunctionBlock
& rhs
);
67 virtual ~FunctionBlock();
69 virtual bool discover();
70 virtual bool discoverConnections();
72 virtual const char* getName() = 0;
74 AVC::function_block_type_t
getType() {return m_type
;};
75 AVC::function_block_type_t
getSubtype() {return m_subtype
;};
76 AVC::function_block_id_t
getId() {return m_id
;};
78 AVC::no_of_input_plugs_t
getNrOfInputPlugs() {return m_nrOfInputPlugs
;};
79 AVC::no_of_output_plugs_t
getNrOfOutputPlugs() {return m_nrOfOutputPlugs
;};
81 bool serialize( std::string basePath
, Util::IOSerialize
& ser
) const;
83 static FunctionBlock
* deserialize( std::string basePath
,
84 Util::IODeserialize
& deser
,
86 AVC::Subunit
& subunit
);
87 bool deserializeUpdate( std::string basePath
,
88 Util::IODeserialize
& deser
);
90 bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection
,
91 AVC::plug_id_t plugMaxId
);
94 AVC::Subunit
* m_subunit
;
95 AVC::function_block_type_t m_type
;
96 AVC::function_block_type_t m_subtype
;
97 AVC::function_block_id_t m_id
;
98 ESpecialPurpose m_purpose
;
99 AVC::no_of_input_plugs_t m_nrOfInputPlugs
;
100 AVC::no_of_output_plugs_t m_nrOfOutputPlugs
;
102 AVC::PlugVector m_plugs
;
104 DECLARE_DEBUG_MODULE
;
107 typedef std::vector
<FunctionBlock
*> FunctionBlockVector
;
109 /////////////////////////////////////
110 /////////////////////////////////////
112 class FunctionBlockSelector
: public FunctionBlock
115 FunctionBlockSelector(AVC::Subunit
& subunit
,
116 AVC::function_block_id_t id
,
117 ESpecialPurpose purpose
,
118 AVC::no_of_input_plugs_t nrOfInputPlugs
,
119 AVC::no_of_output_plugs_t nrOfOutputPlugs
,
121 FunctionBlockSelector( const FunctionBlockSelector
& rhs
);
122 FunctionBlockSelector();
123 virtual ~FunctionBlockSelector();
125 virtual const char* getName();
128 virtual bool serializeChild( std::string basePath
,
129 Util::IOSerialize
& ser
) const;
130 virtual bool deserializeChild( std::string basePath
,
131 Util::IODeserialize
& deser
,
132 AvDevice
& avDevice
);
135 /////////////////////////////////////
137 class FunctionBlockFeature
: public FunctionBlock
140 FunctionBlockFeature(AVC::Subunit
& subunit
,
141 AVC::function_block_id_t id
,
142 ESpecialPurpose purpose
,
143 AVC::no_of_input_plugs_t nrOfInputPlugs
,
144 AVC::no_of_output_plugs_t nrOfOutputPlugs
,
146 FunctionBlockFeature( const FunctionBlockFeature
& rhs
);
147 FunctionBlockFeature();
148 virtual ~FunctionBlockFeature();
150 virtual const char* getName();
152 // FIXME: this is not pretty!
153 enum EControlSelectorEncoding
{
154 eCSE_Feature_Unknown
= 0x00,
155 eCSE_Feature_Mute
= 0x01,
156 eCSE_Feature_Volume
= 0x02,
157 eCSE_Feature_LRBalance
= 0x03,
158 eCSE_Feature_FRBalance
= 0x04,
159 eCSE_Feature_Bass
= 0x05,
160 eCSE_Feature_Mid
= 0x06,
161 eCSE_Feature_Treble
= 0x07,
162 eCSE_Feature_GEQ
= 0x08,
163 eCSE_Feature_AGC
= 0x09,
164 eCSE_Feature_Delay
= 0x0a,
165 eCSE_Feature_BassBoost
= 0x0b,
166 eCSE_Feature_Loudness
= 0x0c,
170 virtual bool serializeChild( std::string basePath
,
171 Util::IOSerialize
& ser
) const;
172 virtual bool deserializeChild( std::string basePath
,
173 Util::IODeserialize
& deser
,
174 AvDevice
& avDevice
);
177 /////////////////////////////////////
179 class FunctionBlockEnhancedMixer
: public FunctionBlock
182 FunctionBlockEnhancedMixer( AVC::Subunit
& subunit
,
183 AVC::function_block_id_t id
,
184 ESpecialPurpose purpose
,
185 AVC::no_of_input_plugs_t nrOfInputPlugs
,
186 AVC::no_of_output_plugs_t nrOfOutputPlugs
,
188 FunctionBlockEnhancedMixer();
189 FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer
& rhs
);
190 virtual ~FunctionBlockEnhancedMixer();
192 virtual bool discover();
194 virtual const char* getName();
197 virtual bool serializeChild( std::string basePath
,
198 Util::IOSerialize
& ser
) const;
199 virtual bool deserializeChild( std::string basePath
,
200 Util::IODeserialize
& deser
,
201 AvDevice
& avDevice
);
204 /////////////////////////////////////
206 class FunctionBlockProcessing
: public FunctionBlock
209 FunctionBlockProcessing( AVC::Subunit
& subunit
,
210 AVC::function_block_id_t id
,
211 ESpecialPurpose purpose
,
212 AVC::no_of_input_plugs_t nrOfInputPlugs
,
213 AVC::no_of_output_plugs_t nrOfOutputPlugs
,
215 FunctionBlockProcessing( const FunctionBlockProcessing
& rhs
);
216 FunctionBlockProcessing();
217 virtual ~FunctionBlockProcessing();
219 virtual const char* getName();
222 virtual bool serializeChild( std::string basePath
,
223 Util::IOSerialize
& ser
) const;
224 virtual bool deserializeChild( std::string basePath
,
225 Util::IODeserialize
& deser
,
226 AvDevice
& avDevice
);
229 /////////////////////////////////////
231 class FunctionBlockCodec
: public FunctionBlock
234 FunctionBlockCodec(AVC::Subunit
& subunit
,
235 AVC::function_block_id_t id
,
236 ESpecialPurpose purpose
,
237 AVC::no_of_input_plugs_t nrOfInputPlugs
,
238 AVC::no_of_output_plugs_t nrOfOutputPlugs
,
240 FunctionBlockCodec( const FunctionBlockCodec
& rhs
);
241 FunctionBlockCodec();
242 virtual ~FunctionBlockCodec();
244 virtual const char* getName();
247 virtual bool serializeChild( std::string basePath
,
248 Util::IOSerialize
& ser
) const;
249 virtual bool deserializeChild( std::string basePath
,
250 Util::IODeserialize
& deser
,
251 AvDevice
& avDevice
);