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

Revision 736, 8.5 kB (checked in by ppalmers, 16 years ago)

fix some stuff that was not merged correctly

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
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 const char* getName();
189
190 protected:
191     virtual bool serializeChild( Glib::ustring basePath,
192                                  Util::IOSerialize& ser ) const;
193     virtual bool deserializeChild( Glib::ustring basePath,
194                                    Util::IODeserialize& deser,
195                                    AvDevice& avDevice );
196 };
197
198 /////////////////////////////////////
199
200 class FunctionBlockProcessing: public FunctionBlock
201 {
202 public:
203     FunctionBlockProcessing( AVC::Subunit& subunit,
204                              AVC::function_block_id_t id,
205                              ESpecialPurpose purpose,
206                              AVC::no_of_input_plugs_t nrOfInputPlugs,
207                              AVC::no_of_output_plugs_t nrOfOutputPlugs,
208                              int verbose );
209     FunctionBlockProcessing( const FunctionBlockProcessing& rhs );
210     FunctionBlockProcessing();
211     virtual ~FunctionBlockProcessing();
212
213     virtual const char* getName();
214
215 protected:
216     virtual bool serializeChild( Glib::ustring basePath,
217                                  Util::IOSerialize& ser ) const;
218     virtual bool deserializeChild( Glib::ustring basePath,
219                                    Util::IODeserialize& deser,
220                                    AvDevice& avDevice );
221 };
222
223 /////////////////////////////////////
224
225 class FunctionBlockCodec: public FunctionBlock
226 {
227 public:
228     FunctionBlockCodec(AVC::Subunit& subunit,
229                        AVC::function_block_id_t id,
230                        ESpecialPurpose purpose,
231                        AVC::no_of_input_plugs_t nrOfInputPlugs,
232                        AVC::no_of_output_plugs_t nrOfOutputPlugs,
233                        int verbose);
234     FunctionBlockCodec( const FunctionBlockCodec& rhs );
235     FunctionBlockCodec();
236     virtual ~FunctionBlockCodec();
237
238     virtual const char* getName();
239
240 protected:
241     virtual bool serializeChild( Glib::ustring basePath,
242                                  Util::IOSerialize& ser ) const;
243     virtual bool deserializeChild( Glib::ustring basePath,
244                                    Util::IODeserialize& deser,
245                                    AvDevice& avDevice );
246 };
247
248 }
249
250 #endif
Note: See TracBrowser for help on using the browser.