root/trunk/libffado/src/bebob/bebob_functionblock.h

Revision 1154, 8.6 kB (checked in by ppalmers, 14 years ago)

add expat based parsing of the device cache. add compile-time selection between libxml++ and expat. will allow to get rid of the libxml++ dependency on the long run. scons SERIALIZE_USE_EXPAT=0Only compile testedscons SERIALIZE_USE_EXPAT=0

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
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
24 #ifndef BEBOB_FUNCTION_BLOCK_H
25 #define BEBOB_FUNCTION_BLOCK_H
26
27 #include "bebob/bebob_avplug.h"
28
29 #include "libavc/avc_definitions.h"
30
31 #include "debugmodule/debugmodule.h"
32
33 #include <string>
34
35 namespace AVC {
36     class Subunit;
37 }
38
39 namespace BeBoB {
40
41 class FunctionBlock {
42 public:
43     enum EFunctionBlockType {
44         eFBT_AllFunctionBlockType   = 0xff,
45         eFBT_AudioSubunitSelector   = 0x80,
46         eFBT_AudioSubunitFeature    = 0x81,
47         eFBT_AudioSubunitProcessing = 0x82,
48         eFBT_AudioSubunitCodec      = 0x83,
49     };
50
51     enum ESpecialPurpose {
52         eSP_InputGain,
53         eSP_OutputVolume,
54         eSP_NoSpecialPurpose
55     };
56
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,
64                    int verbose );
65     FunctionBlock( const FunctionBlock& rhs );
66     FunctionBlock();
67     virtual ~FunctionBlock();
68
69     virtual bool discover();
70     virtual bool discoverConnections();
71
72     virtual const char* getName() = 0;
73
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;};
77
78     AVC::no_of_input_plugs_t getNrOfInputPlugs() {return m_nrOfInputPlugs;};
79     AVC::no_of_output_plugs_t getNrOfOutputPlugs() {return m_nrOfOutputPlugs;};
80
81     bool serialize( std::string basePath, Util::IOSerialize& ser ) const;
82
83     static FunctionBlock* deserialize( std::string basePath,
84                                        Util::IODeserialize& deser,
85                                        AVC::Unit& unit,
86                                        AVC::Subunit& subunit );
87     bool deserializeUpdate( std::string basePath,
88                             Util::IODeserialize& deser );
89 protected:
90     bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection,
91                         AVC::plug_id_t plugMaxId );
92
93 protected:
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;
101     int                   m_verbose;
102     AVC::PlugVector          m_plugs;
103
104     DECLARE_DEBUG_MODULE;
105 };
106
107 typedef std::vector<FunctionBlock*> FunctionBlockVector;
108
109 /////////////////////////////////////
110 /////////////////////////////////////
111
112 class FunctionBlockSelector: public FunctionBlock
113 {
114 public:
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,
120                           int verbose);
121     FunctionBlockSelector( const FunctionBlockSelector& rhs );
122     FunctionBlockSelector();
123     virtual ~FunctionBlockSelector();
124
125     virtual const char* getName();
126
127 protected:
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 );
133 };
134
135 /////////////////////////////////////
136
137 class FunctionBlockFeature: public FunctionBlock
138 {
139 public:
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,
145                          int verbose);
146     FunctionBlockFeature( const FunctionBlockFeature& rhs );
147     FunctionBlockFeature();
148     virtual ~FunctionBlockFeature();
149
150     virtual const char* getName();
151
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,
167     };
168
169 protected:
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 );
175 };
176
177 /////////////////////////////////////
178
179 class FunctionBlockEnhancedMixer: public FunctionBlock
180 {
181 public:
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,
187                                 int verbose );
188     FunctionBlockEnhancedMixer();
189     FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer& rhs );
190     virtual ~FunctionBlockEnhancedMixer();
191
192     virtual bool discover();
193
194     virtual const char* getName();
195
196 protected:
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 );
202 };
203
204 /////////////////////////////////////
205
206 class FunctionBlockProcessing: public FunctionBlock
207 {
208 public:
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,
214                              int verbose );
215     FunctionBlockProcessing( const FunctionBlockProcessing& rhs );
216     FunctionBlockProcessing();
217     virtual ~FunctionBlockProcessing();
218
219     virtual const char* getName();
220
221 protected:
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 );
227 };
228
229 /////////////////////////////////////
230
231 class FunctionBlockCodec: public FunctionBlock
232 {
233 public:
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,
239                        int verbose);
240     FunctionBlockCodec( const FunctionBlockCodec& rhs );
241     FunctionBlockCodec();
242     virtual ~FunctionBlockCodec();
243
244     virtual const char* getName();
245
246 protected:
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 );
252 };
253
254 }
255
256 #endif
Note: See TracBrowser for help on using the browser.