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

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

merge ppalmers-streaming branch

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
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     static FunctionBlock* deserialize( Glib::ustring basePath,
81                        Util::IODeserialize& deser,
82                        AVC::Unit& unit,
83                        AVC::Subunit& subunit);
84 protected:
85     bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection,
86                         AVC::plug_id_t plugMaxId );
87
88 protected:
89     AVC::Subunit*      m_subunit;
90     AVC::function_block_type_t m_type;
91     AVC::function_block_type_t m_subtype;
92     AVC::function_block_id_t   m_id;
93     ESpecialPurpose       m_purpose;
94     AVC::no_of_input_plugs_t   m_nrOfInputPlugs;
95     AVC::no_of_output_plugs_t  m_nrOfOutputPlugs;
96     int                   m_verbose;
97     AVC::PlugVector          m_plugs;
98
99     DECLARE_DEBUG_MODULE;
100 };
101
102 typedef std::vector<FunctionBlock*> FunctionBlockVector;
103
104 /////////////////////////////////////
105 /////////////////////////////////////
106
107 class FunctionBlockSelector: public FunctionBlock
108 {
109 public:
110     FunctionBlockSelector(AVC::Subunit& subunit,
111                           AVC::function_block_id_t id,
112                           ESpecialPurpose purpose,
113                           AVC::no_of_input_plugs_t nrOfInputPlugs,
114                           AVC::no_of_output_plugs_t nrOfOutputPlugs,
115                           int verbose);
116     FunctionBlockSelector( const FunctionBlockSelector& rhs );
117     FunctionBlockSelector();
118     virtual ~FunctionBlockSelector();
119
120     virtual const char* getName();
121
122 protected:
123     virtual bool serializeChild( Glib::ustring basePath,
124                                  Util::IOSerialize& ser ) const;
125     virtual bool deserializeChild( Glib::ustring basePath,
126                                    Util::IODeserialize& deser,
127                                    AvDevice& avDevice );
128 };
129
130 /////////////////////////////////////
131
132 class FunctionBlockFeature: public FunctionBlock
133 {
134 public:
135     FunctionBlockFeature(AVC::Subunit& subunit,
136                          AVC::function_block_id_t id,
137                          ESpecialPurpose purpose,
138                          AVC::no_of_input_plugs_t nrOfInputPlugs,
139                          AVC::no_of_output_plugs_t nrOfOutputPlugs,
140                          int verbose);
141     FunctionBlockFeature( const FunctionBlockFeature& rhs );
142     FunctionBlockFeature();
143     virtual ~FunctionBlockFeature();
144
145     virtual const char* getName();
146    
147     // FIXME: this is not pretty!
148     enum EControlSelectorEncoding {
149         eCSE_Feature_Unknown            = 0x00,
150         eCSE_Feature_Mute               = 0x01,
151         eCSE_Feature_Volume             = 0x02,
152         eCSE_Feature_LRBalance          = 0x03,
153         eCSE_Feature_FRBalance          = 0x04,
154         eCSE_Feature_Bass               = 0x05,
155         eCSE_Feature_Mid                = 0x06,
156         eCSE_Feature_Treble             = 0x07,
157         eCSE_Feature_GEQ                = 0x08,
158         eCSE_Feature_AGC                = 0x09,
159         eCSE_Feature_Delay              = 0x0a,
160         eCSE_Feature_BassBoost          = 0x0b,
161         eCSE_Feature_Loudness           = 0x0c,
162     };
163
164 protected:
165     virtual bool serializeChild( Glib::ustring basePath,
166                                  Util::IOSerialize& ser ) const;
167     virtual bool deserializeChild( Glib::ustring basePath,
168                                    Util::IODeserialize& deser,
169                                    AvDevice& avDevice );
170 };
171
172 /////////////////////////////////////
173
174 class FunctionBlockEnhancedMixer: public FunctionBlock
175 {
176 public:
177     FunctionBlockEnhancedMixer( AVC::Subunit& subunit,
178                                 AVC::function_block_id_t id,
179                                 ESpecialPurpose purpose,
180                                 AVC::no_of_input_plugs_t nrOfInputPlugs,
181                                 AVC::no_of_output_plugs_t nrOfOutputPlugs,
182                                 int verbose );
183     FunctionBlockEnhancedMixer();
184     FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer& rhs );
185     virtual ~FunctionBlockEnhancedMixer();
186
187     virtual const char* getName();
188
189 protected:
190     virtual bool serializeChild( Glib::ustring basePath,
191                                  Util::IOSerialize& ser ) const;
192     virtual bool deserializeChild( Glib::ustring basePath,
193                                    Util::IODeserialize& deser,
194                                    AvDevice& avDevice );
195 };
196
197 /////////////////////////////////////
198
199 class FunctionBlockProcessing: public FunctionBlock
200 {
201 public:
202     FunctionBlockProcessing( AVC::Subunit& subunit,
203                              AVC::function_block_id_t id,
204                              ESpecialPurpose purpose,
205                              AVC::no_of_input_plugs_t nrOfInputPlugs,
206                              AVC::no_of_output_plugs_t nrOfOutputPlugs,
207                              int verbose );
208     FunctionBlockProcessing( const FunctionBlockProcessing& rhs );
209     FunctionBlockProcessing();
210     virtual ~FunctionBlockProcessing();
211
212     virtual const char* getName();
213
214 protected:
215     virtual bool serializeChild( Glib::ustring basePath,
216                                  Util::IOSerialize& ser ) const;
217     virtual bool deserializeChild( Glib::ustring basePath,
218                                    Util::IODeserialize& deser,
219                                    AvDevice& avDevice );
220 };
221
222 /////////////////////////////////////
223
224 class FunctionBlockCodec: public FunctionBlock
225 {
226 public:
227     FunctionBlockCodec(AVC::Subunit& subunit,
228                        AVC::function_block_id_t id,
229                        ESpecialPurpose purpose,
230                        AVC::no_of_input_plugs_t nrOfInputPlugs,
231                        AVC::no_of_output_plugs_t nrOfOutputPlugs,
232                        int verbose);
233     FunctionBlockCodec( const FunctionBlockCodec& rhs );
234     FunctionBlockCodec();
235     virtual ~FunctionBlockCodec();
236
237     virtual const char* getName();
238
239 protected:
240     virtual bool serializeChild( Glib::ustring basePath,
241                                  Util::IOSerialize& ser ) const;
242     virtual bool deserializeChild( Glib::ustring basePath,
243                                    Util::IODeserialize& deser,
244                                    AvDevice& avDevice );
245 };
246
247 }
248
249 #endif
Note: See TracBrowser for help on using the browser.