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

Revision 2442, 9.4 kB (checked in by mocchi, 6 years ago)

[libavc] complement 'Processing function block' command

Current implement of libavc is lack of actual work for 'Processing function block' command defined in 'AV/C Audio Subunit Specification 1.0 (1394TA Document 1999008)'. I guess the reason is there are several types of the command. To implement all of the commands in the specification is too cost.

But here, a driver for BeBoB/MAudio devices needs this command to control device's internal mixer. These devices can be controlled by either 'single' or 'multiple' type of the command.

For these reasons, this commit add 'single type' of 'processing function block command'.

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