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

Revision 864, 8.5 kB (checked in by ppalmers, 15 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

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 namespace AVC {
34     class Subunit;
35 }
36
37 namespace BeBoB {
38
39 class FunctionBlock {
40 public:
41     enum EFunctionBlockType {
42         eFBT_AllFunctionBlockType   = 0xff,
43         eFBT_AudioSubunitSelector   = 0x80,
44         eFBT_AudioSubunitFeature    = 0x81,
45         eFBT_AudioSubunitProcessing = 0x82,
46         eFBT_AudioSubunitCodec      = 0x83,
47     };
48
49     enum ESpecialPurpose {
50         eSP_InputGain,
51         eSP_OutputVolume,
52         eSP_NoSpecialPurpose
53     };
54
55     FunctionBlock( AVC::Subunit& subunit,
56                    AVC::function_block_type_t type,
57                    AVC::function_block_type_t subtype,
58                    AVC::function_block_id_t id,
59                    ESpecialPurpose purpose,
60                    AVC::no_of_input_plugs_t nrOfInputPlugs,
61                    AVC::no_of_output_plugs_t nrOfOutputPlugs,
62                    int verbose );
63     FunctionBlock( const FunctionBlock& rhs );
64     FunctionBlock();
65     virtual ~FunctionBlock();
66
67     virtual bool discover();
68     virtual bool discoverConnections();
69
70     virtual const char* getName() = 0;
71
72     AVC::function_block_type_t getType() {return m_type;};
73     AVC::function_block_type_t getSubtype() {return m_subtype;};
74     AVC::function_block_id_t getId() {return m_id;};
75
76     AVC::no_of_input_plugs_t getNrOfInputPlugs() {return m_nrOfInputPlugs;};
77     AVC::no_of_output_plugs_t getNrOfOutputPlugs() {return m_nrOfOutputPlugs;};
78
79     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
80
81     static FunctionBlock* deserialize( Glib::ustring basePath,
82                        Util::IODeserialize& deser,
83                        AVC::Unit& unit,
84                        AVC::Subunit& subunit);
85 protected:
86     bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection,
87                         AVC::plug_id_t plugMaxId );
88
89 protected:
90     AVC::Subunit*      m_subunit;
91     AVC::function_block_type_t m_type;
92     AVC::function_block_type_t m_subtype;
93     AVC::function_block_id_t   m_id;
94     ESpecialPurpose       m_purpose;
95     AVC::no_of_input_plugs_t   m_nrOfInputPlugs;
96     AVC::no_of_output_plugs_t  m_nrOfOutputPlugs;
97     int                   m_verbose;
98     AVC::PlugVector          m_plugs;
99
100     DECLARE_DEBUG_MODULE;
101 };
102
103 typedef std::vector<FunctionBlock*> FunctionBlockVector;
104
105 /////////////////////////////////////
106 /////////////////////////////////////
107
108 class FunctionBlockSelector: public FunctionBlock
109 {
110 public:
111     FunctionBlockSelector(AVC::Subunit& subunit,
112                           AVC::function_block_id_t id,
113                           ESpecialPurpose purpose,
114                           AVC::no_of_input_plugs_t nrOfInputPlugs,
115                           AVC::no_of_output_plugs_t nrOfOutputPlugs,
116                           int verbose);
117     FunctionBlockSelector( const FunctionBlockSelector& rhs );
118     FunctionBlockSelector();
119     virtual ~FunctionBlockSelector();
120
121     virtual const char* getName();
122
123 protected:
124     virtual bool serializeChild( Glib::ustring basePath,
125                                  Util::IOSerialize& ser ) const;
126     virtual bool deserializeChild( Glib::ustring basePath,
127                                    Util::IODeserialize& deser,
128                                    AvDevice& avDevice );
129 };
130
131 /////////////////////////////////////
132
133 class FunctionBlockFeature: public FunctionBlock
134 {
135 public:
136     FunctionBlockFeature(AVC::Subunit& subunit,
137                          AVC::function_block_id_t id,
138                          ESpecialPurpose purpose,
139                          AVC::no_of_input_plugs_t nrOfInputPlugs,
140                          AVC::no_of_output_plugs_t nrOfOutputPlugs,
141                          int verbose);
142     FunctionBlockFeature( const FunctionBlockFeature& rhs );
143     FunctionBlockFeature();
144     virtual ~FunctionBlockFeature();
145
146     virtual const char* getName();
147
148     // FIXME: this is not pretty!
149     enum EControlSelectorEncoding {
150         eCSE_Feature_Unknown            = 0x00,
151         eCSE_Feature_Mute               = 0x01,
152         eCSE_Feature_Volume             = 0x02,
153         eCSE_Feature_LRBalance          = 0x03,
154         eCSE_Feature_FRBalance          = 0x04,
155         eCSE_Feature_Bass               = 0x05,
156         eCSE_Feature_Mid                = 0x06,
157         eCSE_Feature_Treble             = 0x07,
158         eCSE_Feature_GEQ                = 0x08,
159         eCSE_Feature_AGC                = 0x09,
160         eCSE_Feature_Delay              = 0x0a,
161         eCSE_Feature_BassBoost          = 0x0b,
162         eCSE_Feature_Loudness           = 0x0c,
163     };
164
165 protected:
166     virtual bool serializeChild( Glib::ustring basePath,
167                                  Util::IOSerialize& ser ) const;
168     virtual bool deserializeChild( Glib::ustring basePath,
169                                    Util::IODeserialize& deser,
170                                    AvDevice& avDevice );
171 };
172
173 /////////////////////////////////////
174
175 class FunctionBlockEnhancedMixer: public FunctionBlock
176 {
177 public:
178     FunctionBlockEnhancedMixer( AVC::Subunit& subunit,
179                                 AVC::function_block_id_t id,
180                                 ESpecialPurpose purpose,
181                                 AVC::no_of_input_plugs_t nrOfInputPlugs,
182                                 AVC::no_of_output_plugs_t nrOfOutputPlugs,
183                                 int verbose );
184     FunctionBlockEnhancedMixer();
185     FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer& rhs );
186     virtual ~FunctionBlockEnhancedMixer();
187
188     virtual bool discover();
189
190     virtual const char* getName();
191
192 protected:
193     virtual bool serializeChild( Glib::ustring basePath,
194                                  Util::IOSerialize& ser ) const;
195     virtual bool deserializeChild( Glib::ustring basePath,
196                                    Util::IODeserialize& deser,
197                                    AvDevice& avDevice );
198 };
199
200 /////////////////////////////////////
201
202 class FunctionBlockProcessing: public FunctionBlock
203 {
204 public:
205     FunctionBlockProcessing( AVC::Subunit& subunit,
206                              AVC::function_block_id_t id,
207                              ESpecialPurpose purpose,
208                              AVC::no_of_input_plugs_t nrOfInputPlugs,
209                              AVC::no_of_output_plugs_t nrOfOutputPlugs,
210                              int verbose );
211     FunctionBlockProcessing( const FunctionBlockProcessing& rhs );
212     FunctionBlockProcessing();
213     virtual ~FunctionBlockProcessing();
214
215     virtual const char* getName();
216
217 protected:
218     virtual bool serializeChild( Glib::ustring basePath,
219                                  Util::IOSerialize& ser ) const;
220     virtual bool deserializeChild( Glib::ustring basePath,
221                                    Util::IODeserialize& deser,
222                                    AvDevice& avDevice );
223 };
224
225 /////////////////////////////////////
226
227 class FunctionBlockCodec: public FunctionBlock
228 {
229 public:
230     FunctionBlockCodec(AVC::Subunit& subunit,
231                        AVC::function_block_id_t id,
232                        ESpecialPurpose purpose,
233                        AVC::no_of_input_plugs_t nrOfInputPlugs,
234                        AVC::no_of_output_plugs_t nrOfOutputPlugs,
235                        int verbose);
236     FunctionBlockCodec( const FunctionBlockCodec& rhs );
237     FunctionBlockCodec();
238     virtual ~FunctionBlockCodec();
239
240     virtual const char* getName();
241
242 protected:
243     virtual bool serializeChild( Glib::ustring basePath,
244                                  Util::IOSerialize& ser ) const;
245     virtual bool deserializeChild( Glib::ustring basePath,
246                                    Util::IODeserialize& deser,
247                                    AvDevice& avDevice );
248 };
249
250 }
251
252 #endif
Note: See TracBrowser for help on using the browser.