root/branches/libffado-2.0-with-panning/src/libavc/audiosubunit/avc_function_block.h

Revision 1338, 9.4 kB (checked in by wagi, 16 years ago)

- Add AV/C command for LRBalance feature function block
- Expose for each found feature function block one level feature

function mixer element and one left right balance feature
function mixer element.

- Add 'Volume' or 'LRBalance' as dbus

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 AVCFUNCTIONBLOCK_H
25 #define AVCFUNCTIONBLOCK_H
26
27 #include "../general/avc_extended_cmd_generic.h"
28 #include "../general/avc_generic.h"
29
30 #include <libavc1394/avc1394.h>
31 #include <vector>
32 using namespace std;
33
34 namespace AVC {
35
36
37 class FunctionBlockFeatureVolume: public IBusData
38 {
39 public:
40     FunctionBlockFeatureVolume();
41     FunctionBlockFeatureVolume( const FunctionBlockFeatureVolume& rhs );
42     virtual ~FunctionBlockFeatureVolume();
43
44     virtual bool serialize( Util::Cmd::IOSSerialize& se );
45     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
46     virtual FunctionBlockFeatureVolume* clone() const;
47
48     control_data_length_t  m_controlDataLength;
49     u_int16_t              m_volume;
50 };
51
52 ///////////////////////////////////////////
53
54 class FunctionBlockFeatureLRBalance: public IBusData
55 {
56 public:
57     FunctionBlockFeatureLRBalance();
58     FunctionBlockFeatureLRBalance( const FunctionBlockFeatureLRBalance& rhs );
59     virtual ~FunctionBlockFeatureLRBalance();
60
61     virtual bool serialize( Util::Cmd::IOSSerialize& se );
62     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
63     virtual FunctionBlockFeatureLRBalance* clone() const;
64
65     control_data_length_t  m_controlDataLength;
66     u_int16_t              m_lrBalance;
67 };
68
69 ///////////////////////////////////////////
70
71 class FunctionBlockProcessingMixer: public IBusData
72 {
73 public:
74     FunctionBlockProcessingMixer();
75     FunctionBlockProcessingMixer( const FunctionBlockProcessingMixer& rhs );
76     virtual ~FunctionBlockProcessingMixer();
77
78     virtual bool serialize( Util::Cmd::IOSSerialize& se );
79     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
80     virtual FunctionBlockProcessingMixer* clone() const;
81
82     control_selector_t m_controlSelector;
83 };
84
85 ///////////////////////////////////////////
86
87 /*
88  * The enhanced mixer feature function block is not
89  * working on all current BeBoB devices.  This code
90  * is there for not really tested or even working.
91  */
92 class FunctionBlockProcessingEnhancedMixer: public IBusData
93 {
94 public:
95     enum EStatusSelector {
96         eSS_ProgramableState = 0x00,
97         eSS_Level            = 0x01,
98     };
99
100     FunctionBlockProcessingEnhancedMixer();
101     FunctionBlockProcessingEnhancedMixer(
102         const FunctionBlockProcessingEnhancedMixer& rhs );
103     virtual ~FunctionBlockProcessingEnhancedMixer();
104
105     virtual bool serialize( Util::Cmd::IOSSerialize& se );
106     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
107     virtual FunctionBlockProcessingEnhancedMixer* clone() const;
108
109     control_selector_t        m_controlSelector;
110     status_selector_t         m_statusSelector;
111     control_data_ext_length_t m_controlDataLength;
112     vector<mixer_programmable_state_t> m_ProgramableStateData;
113     vector<mixer_level_t>              m_LevelData;
114 };
115
116 ///////////////////////////////////////////
117 ///////////////////////////////////////////
118
119 class FunctionBlockSelector: public IBusData
120 {
121 // untested
122 public:
123     // Control selector encoding
124     enum EControlSelectorEncoding {
125         eCSE_Selector_Unknown           = 0x00,
126         eCSE_Selector_Selector          = 0x01,
127     };
128
129     FunctionBlockSelector();
130     FunctionBlockSelector( const FunctionBlockSelector& rhs );
131     virtual ~FunctionBlockSelector();
132
133     virtual bool serialize( Util::Cmd::IOSSerialize& se );
134     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
135     virtual FunctionBlockSelector* clone() const;
136
137     selector_length_t      m_selectorLength;
138     input_fb_plug_number_t m_inputFbPlugNumber;
139     control_selector_t     m_controlSelector;
140 };
141
142 ///////////////////////////////////////////
143
144 class FunctionBlockFeature: public IBusData
145 {
146 // no complete implementation
147 public:
148     // Control selector encoding
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     FunctionBlockFeature();
166     FunctionBlockFeature( const FunctionBlockFeature& rhs );
167     virtual ~FunctionBlockFeature();
168
169     virtual bool serialize( Util::Cmd::IOSSerialize& se );
170     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
171     virtual FunctionBlockFeature* clone() const;
172
173     selector_length_t           m_selectorLength;
174     audio_channel_number_t      m_audioChannelNumber;
175     control_selector_t          m_controlSelector;
176
177     FunctionBlockFeatureVolume*     m_pVolume;
178     FunctionBlockFeatureLRBalance*  m_pLRBalance;
179 };
180
181 ///////////////////////////////////////////
182
183 class FunctionBlockProcessing: public IBusData
184 {
185 // no complete implementation
186 public:
187     // Function block selector
188     enum EProcessingTypeEncoding {
189         ePTE_Mixer                      = 0x01,
190         ePTE_Generic                    = 0x02,
191         ePTE_UpDown                     = 0x03,
192         ePTE_DolbyProLogic              = 0x04,
193         ePTE_3dStereoExtender           = 0x05,
194         ePTE_Reverberation              = 0x06,
195         ePTE_Chorus                     = 0x07,
196         ePTE_DynamicRangeCompression    = 0x08,
197     };
198
199     // Control selector encoding
200     enum EControlSelectorEncoding {
201         eCSE_Processing_Unknown         = 0x00,
202         eCSE_Processing_Enable          = 0x01,
203         eCSE_Processing_Mode            = 0x02,
204         eCSE_Processing_Mixer           = 0x03,
205         eCSE_Processing_EnhancedMixer   = 0xf1,
206
207         // lots of definitions missing
208
209     };
210
211     FunctionBlockProcessing();
212     FunctionBlockProcessing( const FunctionBlockProcessing& rhs );
213     virtual ~FunctionBlockProcessing();
214
215     virtual bool serialize( Util::Cmd::IOSSerialize& se );
216     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
217     virtual FunctionBlockProcessing* clone() const;
218
219     selector_length_t             m_selectorLength;
220     input_fb_plug_number_t        m_fbInputPlugNumber;
221     input_audio_channel_number_t  m_inputAudioChannelNumber;
222     output_audio_channel_number_t m_outputAudioChannelNumber;
223
224     FunctionBlockProcessingMixer*         m_pMixer;
225     FunctionBlockProcessingEnhancedMixer* m_pEnhancedMixer;
226 };
227
228 ///////////////////////////////////////////
229
230 class FunctionBlockCodec: public IBusData
231 {
232 // dummy implementation
233 public:
234     // CODEC type endcoding
235     enum ECodecTypeEncoding {
236         eCTE_Unknown                    = 0x00,
237         eCTE_Ac3Decoder                 = 0x01,
238         eCTE_MpegDecoder                = 0x02,
239         eCTE_DtsDecoder                 = 0x03,
240     };
241
242     FunctionBlockCodec();
243     FunctionBlockCodec( const FunctionBlockCodec& rhs );
244     virtual ~FunctionBlockCodec();
245
246     virtual bool serialize( Util::Cmd::IOSSerialize& se );
247     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
248     virtual FunctionBlockCodec* clone() const;
249 };
250
251 ///////////////////////////////////////////
252 ///////////////////////////////////////////
253
254 #define AVC1394_FUNCTION_BLOCK_CMD 0xB8
255
256 class FunctionBlockCmd: public AVCCommand
257 {
258 public:
259     enum EFunctionBlockType {
260         eFBT_Selector   = 0x80,
261         eFBT_Feature    = 0x81,
262         eFBT_Processing = 0x82,
263         eFBT_Codec      = 0x83,
264     };
265
266     enum EControlAttribute {
267         eCA_Resolution = 0x01,
268         eCA_Minimum    = 0x02,
269         eCA_Maximum    = 0x03,
270         eCA_Default    = 0x04,
271         eCA_Duration   = 0x08,
272         eCA_Current    = 0x10,
273         eCA_Move       = 0x18,
274         eCA_Delta      = 0x19,
275     };
276
277     FunctionBlockCmd( Ieee1394Service& ieee1394service,
278                       EFunctionBlockType eType,
279                       function_block_id_t id,
280                       EControlAttribute eCtrlAttrib );
281     FunctionBlockCmd( const FunctionBlockCmd& rhs );
282     virtual ~FunctionBlockCmd();
283
284     virtual bool serialize( Util::Cmd::IOSSerialize& se );
285     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
286     virtual FunctionBlockCmd* clone() const;
287
288     virtual const char* getCmdName() const
289         { return "FunctionBlockCmd"; }
290
291     function_block_type_t m_functionBlockType;
292     function_block_id_t   m_functionBlockId;
293     control_attribute_t   m_controlAttribute;
294
295     FunctionBlockSelector*      m_pFBSelector;
296     FunctionBlockFeature*       m_pFBFeature;
297     FunctionBlockProcessing*    m_pFBProcessing;
298     FunctionBlockCodec*         m_pFBCodec;
299 };
300
301 }
302
303 #endif
Note: See TracBrowser for help on using the browser.