root/branches/echoaudio/src/bebob/bebob_functionblock.h

Revision 507, 8.3 kB (checked in by ppalmers, 16 years ago)

[Temporary commit: compiles but doesn't run]

First pass on AV/C code refactoring. Generic code and data structures
are moved to libavc classes. Implementation/vendor specific stuff remains
in specific classes.

In this case all 'Extended' commands and the discovery procedures remain in
the bebob/ classes, while the remainder goes into the libavc classes.

Line 
1 /*
2  * Copyright (C) 2005-2007 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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
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 // #include "libavc/general/avc_subunit.h"
31
32 #include "debugmodule/debugmodule.h"
33
34 namespace AVC {
35     class Subunit;
36 }
37
38 namespace BeBoB {
39
40 class FunctionBlock {
41 public:
42     enum EFunctionBlockType {
43         eFBT_AllFunctionBlockType   = 0xff,
44         eFBT_AudioSubunitSelector   = 0x80,
45         eFBT_AudioSubunitFeature    = 0x81,
46         eFBT_AudioSubunitProcessing = 0x82,
47         eFBT_AudioSubunitCodec      = 0x83,
48     };
49
50     enum ESpecialPurpose {
51         eSP_InputGain,
52         eSP_OutputVolume,
53         eSP_NoSpecialPurpose
54     };
55
56     FunctionBlock( AVC::Subunit& subunit,
57                    AVC::function_block_type_t type,
58                    AVC::function_block_type_t subtype,
59                    AVC::function_block_id_t id,
60                    ESpecialPurpose purpose,
61                    AVC::no_of_input_plugs_t nrOfInputPlugs,
62                    AVC::no_of_output_plugs_t nrOfOutputPlugs,
63                    int verbose );
64     FunctionBlock( const FunctionBlock& rhs );
65     FunctionBlock();
66     virtual ~FunctionBlock();
67
68     virtual bool discover();
69     virtual bool discoverConnections();
70
71     virtual const char* getName() = 0;
72    
73     AVC::function_block_type_t getType() {return m_type;};
74     AVC::function_block_type_t getSubtype() {return m_subtype;};
75     AVC::function_block_id_t getId() {return m_id;};
76
77     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
78     static FunctionBlock* deserialize( Glib::ustring basePath,
79                        Util::IODeserialize& deser,
80                        AVC::Unit& unit,
81                        AVC::Subunit& subunit);
82 protected:
83     bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection,
84                         AVC::plug_id_t plugMaxId );
85
86 protected:
87     AVC::Subunit*      m_subunit;
88     AVC::function_block_type_t m_type;
89     AVC::function_block_type_t m_subtype;
90     AVC::function_block_id_t   m_id;
91     ESpecialPurpose       m_purpose;
92     AVC::no_of_input_plugs_t   m_nrOfInputPlugs;
93     AVC::no_of_output_plugs_t  m_nrOfOutputPlugs;
94     int                   m_verbose;
95     AVC::PlugVector          m_plugs;
96
97     DECLARE_DEBUG_MODULE;
98 };
99
100 typedef std::vector<FunctionBlock*> FunctionBlockVector;
101
102 /////////////////////////////////////
103 /////////////////////////////////////
104
105 class FunctionBlockSelector: public FunctionBlock
106 {
107 public:
108     FunctionBlockSelector(AVC::Subunit& subunit,
109                           AVC::function_block_id_t id,
110                           ESpecialPurpose purpose,
111                           AVC::no_of_input_plugs_t nrOfInputPlugs,
112                           AVC::no_of_output_plugs_t nrOfOutputPlugs,
113                           int verbose);
114     FunctionBlockSelector( const FunctionBlockSelector& rhs );
115     FunctionBlockSelector();
116     virtual ~FunctionBlockSelector();
117
118     virtual const char* getName();
119
120 protected:
121     virtual bool serializeChild( Glib::ustring basePath,
122                                  Util::IOSerialize& ser ) const;
123     virtual bool deserializeChild( Glib::ustring basePath,
124                                    Util::IODeserialize& deser,
125                                    AvDevice& avDevice );
126 };
127
128 /////////////////////////////////////
129
130 class FunctionBlockFeature: public FunctionBlock
131 {
132 public:
133     FunctionBlockFeature(AVC::Subunit& subunit,
134                          AVC::function_block_id_t id,
135                          ESpecialPurpose purpose,
136                          AVC::no_of_input_plugs_t nrOfInputPlugs,
137                          AVC::no_of_output_plugs_t nrOfOutputPlugs,
138                          int verbose);
139     FunctionBlockFeature( const FunctionBlockFeature& rhs );
140     FunctionBlockFeature();
141     virtual ~FunctionBlockFeature();
142
143     virtual const char* getName();
144    
145     // FIXME: this is not pretty!
146     enum EControlSelectorEncoding {
147         eCSE_Feature_Unknown            = 0x00,
148         eCSE_Feature_Mute               = 0x01,
149         eCSE_Feature_Volume             = 0x02,
150         eCSE_Feature_LRBalance          = 0x03,
151         eCSE_Feature_FRBalance          = 0x04,
152         eCSE_Feature_Bass               = 0x05,
153         eCSE_Feature_Mid                = 0x06,
154         eCSE_Feature_Treble             = 0x07,
155         eCSE_Feature_GEQ                = 0x08,
156         eCSE_Feature_AGC                = 0x09,
157         eCSE_Feature_Delay              = 0x0a,
158         eCSE_Feature_BassBoost          = 0x0b,
159         eCSE_Feature_Loudness           = 0x0c,
160     };
161
162 protected:
163     virtual bool serializeChild( Glib::ustring basePath,
164                                  Util::IOSerialize& ser ) const;
165     virtual bool deserializeChild( Glib::ustring basePath,
166                                    Util::IODeserialize& deser,
167                                    AvDevice& avDevice );
168 };
169
170 /////////////////////////////////////
171
172 class FunctionBlockEnhancedMixer: public FunctionBlock
173 {
174 public:
175     FunctionBlockEnhancedMixer( AVC::Subunit& subunit,
176                                 AVC::function_block_id_t id,
177                                 ESpecialPurpose purpose,
178                                 AVC::no_of_input_plugs_t nrOfInputPlugs,
179                                 AVC::no_of_output_plugs_t nrOfOutputPlugs,
180                                 int verbose );
181     FunctionBlockEnhancedMixer();
182     FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer& rhs );
183     virtual ~FunctionBlockEnhancedMixer();
184
185     virtual const char* getName();
186
187 protected:
188     virtual bool serializeChild( Glib::ustring basePath,
189                                  Util::IOSerialize& ser ) const;
190     virtual bool deserializeChild( Glib::ustring basePath,
191                                    Util::IODeserialize& deser,
192                                    AvDevice& avDevice );
193 };
194
195 /////////////////////////////////////
196
197 class FunctionBlockProcessing: public FunctionBlock
198 {
199 public:
200     FunctionBlockProcessing( AVC::Subunit& subunit,
201                              AVC::function_block_id_t id,
202                              ESpecialPurpose purpose,
203                              AVC::no_of_input_plugs_t nrOfInputPlugs,
204                              AVC::no_of_output_plugs_t nrOfOutputPlugs,
205                              int verbose );
206     FunctionBlockProcessing( const FunctionBlockProcessing& rhs );
207     FunctionBlockProcessing();
208     virtual ~FunctionBlockProcessing();
209
210     virtual const char* getName();
211
212 protected:
213     virtual bool serializeChild( Glib::ustring basePath,
214                                  Util::IOSerialize& ser ) const;
215     virtual bool deserializeChild( Glib::ustring basePath,
216                                    Util::IODeserialize& deser,
217                                    AvDevice& avDevice );
218 };
219
220 /////////////////////////////////////
221
222 class FunctionBlockCodec: public FunctionBlock
223 {
224 public:
225     FunctionBlockCodec(AVC::Subunit& subunit,
226                        AVC::function_block_id_t id,
227                        ESpecialPurpose purpose,
228                        AVC::no_of_input_plugs_t nrOfInputPlugs,
229                        AVC::no_of_output_plugs_t nrOfOutputPlugs,
230                        int verbose);
231     FunctionBlockCodec( const FunctionBlockCodec& rhs );
232     FunctionBlockCodec();
233     virtual ~FunctionBlockCodec();
234
235     virtual const char* getName();
236
237 protected:
238     virtual bool serializeChild( Glib::ustring basePath,
239                                  Util::IOSerialize& ser ) const;
240     virtual bool deserializeChild( Glib::ustring basePath,
241                                    Util::IODeserialize& deser,
242                                    AvDevice& avDevice );
243 };
244
245 }
246
247 #endif
Note: See TracBrowser for help on using the browser.