root/trunk/libffado/src/libavc/avc_function_block.h

Revision 455, 8.4 kB (checked in by ppalmers, 15 years ago)

- test-mixer volume control works (tested on phase88 only)
- volume control is exposed to the outside

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