root/trunk/libffado/src/libavc/streamformat/avc_extended_stream_format.h

Revision 864, 13.8 kB (checked in by ppalmers, 15 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
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 AVCEXTENDEDSTREAMFROMAT_H
25 #define AVCEXTENDEDSTREAMFROMAT_H
26
27 #include "../general/avc_generic.h"
28 #include "../general/avc_extended_cmd_generic.h"
29
30 #include <libavc1394/avc1394.h>
31 #include <iostream>
32 #include <vector>
33
34 namespace AVC {
35
36 #define AVC1394_STREAM_FORMAT_SUPPORT            0x2F
37 #define AVC1394_STREAM_FORMAT_SUBFUNCTION_INPUT  0x00
38 #define AVC1394_STREAM_FORMAT_SUBFUNCTION_OUTPUT 0x01
39
40 // BridgeCo extensions
41 #define AVC1394_STREAM_FORMAT_SUBFUNCTION_EXTENDED_STREAM_FORMAT      0xC0
42 #define AVC1394_STREAM_FORMAT_SUBFUNCTION_EXTENDED_STREAM_FORMAT_LIST 0xC1
43
44
45 #define AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_DVCR       0x80
46 #define AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_AUDIOMUSIC 0x90
47 #define AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_INVALID    0xFF
48
49 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SD525_60                     0x00
50 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SDL525_60                    0x04
51 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_HD1125_60                    0x08
52 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SD625_60                     0x80
53 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SDL625_50                    0x84
54 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_HD1250_50                    0x88
55 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_AM824                  0x00
56 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_24_4_AUDIO_PACK        0x01
57 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_32_FLOATING_POINT_DATA 0x02
58 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_AM824_COMPOUND         0x40
59 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_DONT_CARE              0xFF
60
61
62 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC60968_3                            0x00
63 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_3                            0x01
64 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_4                            0x02
65 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_5                            0x03
66 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_6                            0x04
67 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_7                            0x05
68 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MULTI_BIT_LINEAR_AUDIO_RAW            0x06
69 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MULTI_BIT_LINEAR_AUDIO_DVD_AUDIO      0x07
70 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_PLAIN_RAW               0x08
71 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_PLAIN_SACD              0x09
72 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_ENCODED_RAW             0x0A
73 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_ENCODED_SACD            0x0B
74 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_HIGH_PRECISION_MULTIBIT_LINEAR_AUDIO  0x0C
75 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MIDI_CONFORMANT                       0x0D
76 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_SYNC_STREAM                           0x40
77 #define AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_DONT_CARE                             0xFF
78
79 #define AVC1394_STREAM_FORMAT_AM824_IEC60968_3                            0x00
80 #define AVC1394_STREAM_FORMAT_AM824_IEC61937_3                            0x01
81 #define AVC1394_STREAM_FORMAT_AM824_IEC61937_4                            0x02
82 #define AVC1394_STREAM_FORMAT_AM824_IEC61937_5                            0x03
83 #define AVC1394_STREAM_FORMAT_AM824_IEC61937_6                            0x04
84 #define AVC1394_STREAM_FORMAT_AM824_IEC61937_7                            0x05
85 #define AVC1394_STREAM_FORMAT_AM824_MULTI_BIT_LINEAR_AUDIO_RAW            0x06
86 #define AVC1394_STREAM_FORMAT_AM824_MULTI_BIT_LINEAR_AUDIO_DVD_AUDIO      0x07
87 #define AVC1394_STREAM_FORMAT_AM824_HIGH_PRECISION_MULTIBIT_LINEAR_AUDIO  0x0C
88 #define AVC1394_STREAM_FORMAT_AM824_MIDI_CONFORMANT                       0x0D
89 #define AVC1394_STREAM_FORMAT_AM824_DONT_CARE                             0xFF
90
91 /*
92 // As defined in 'AV/C Stream Format Information Specification 1.0 TA Document 2001002'
93 // Not used for extended stream format
94 #define AVC1394_STREAM_FORMAT_SUPPORT_STATUS_SUPPORTED_AND_CONFIGURED              0x00
95 #define AVC1394_STREAM_FORMAT_SUPPORT_STATUS_SUPPORTED_AND_HAS_NOT_BEEN_CONFIGURED 0x01
96 #define AVC1394_STREAM_FORMAT_SUPPORT_STATUS_SUPPORTED_AND_READY_TO_CONFIGURE      0x02
97 #define AVC1394_STREAM_FORMAT_SUPPORT_STATUS_SUPPORTED_AND_NOT_CONFIGURED          0x03
98 #define AVC1394_STREAM_FORMAT_SUPPORT_STATUS_NOT_SUPPORTED                         0x04
99 // 0x05 - 0xFE reserved
100 #define AVC1394_STREAM_FORMAT_SUPPORT_STATUS_NO_INFORMATION                        0xFF
101 */
102
103 #define AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_ACTIVE           0x00
104 #define AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_INACTIVE         0x01
105 #define AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_NO_STREAM_FORMAT 0x02
106 #define AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_NOT_USED         0xff
107
108 class Util::Cmd::IOSSerialize;
109 class Util::Cmd::IISDeserialize;
110
111 enum ERateControl {
112     eRC_Supported = 0x00,
113     eRC_DontCare  = 0x01,
114 };
115
116 ////////////////////////////////////////////////////////////
117
118 class StreamFormatInfo: public IBusData
119 {
120 public:
121     StreamFormatInfo();
122
123     virtual bool serialize( Util::Cmd::IOSSerialize& se );
124     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
125
126     virtual StreamFormatInfo* clone() const;
127
128     number_of_channels_t m_numberOfChannels;
129     stream_format_t      m_streamFormat;
130 };
131 std::ostream& operator<<( std::ostream& stream, StreamFormatInfo info );
132
133 ////////////////////////////////////////////////////////////
134
135 class FormatInformationStreams: public IBusData
136 {
137 public:
138     FormatInformationStreams() {}
139     virtual ~FormatInformationStreams() {}
140 };
141
142 ////////////////////////////////////////////////////////////
143
144 class FormatInformationStreamsSync: public FormatInformationStreams
145 {
146 public:
147     FormatInformationStreamsSync();
148
149     virtual bool serialize( Util::Cmd::IOSSerialize& se );
150     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
151     virtual FormatInformationStreamsSync* clone() const;
152
153     reserved_t           m_reserved0;
154     sampling_frequency_t m_samplingFrequency;
155     rate_control_t       m_rateControl;
156     reserved_t           m_reserved1;
157 };
158
159 ////////////////////////////////////////////////////////////
160
161 class FormatInformationStreamsCompound: public FormatInformationStreams
162 {
163 public:
164     FormatInformationStreamsCompound();
165     virtual ~FormatInformationStreamsCompound();
166
167     virtual bool serialize( Util::Cmd::IOSSerialize& se );
168     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
169     virtual FormatInformationStreamsCompound* clone() const;
170
171     sampling_frequency_t                     m_samplingFrequency;
172     rate_control_t                           m_rateControl;
173     number_of_stream_format_infos_t          m_numberOfStreamFormatInfos;
174
175     typedef std::vector< StreamFormatInfo* > StreamFormatInfoVector;
176     StreamFormatInfoVector                   m_streamFormatInfos;
177 };
178 std::ostream& operator<<( std::ostream& stream, FormatInformationStreamsCompound info );
179
180
181 ////////////////////////////////////////////////////////////
182
183 class FormatInformation: public IBusData
184 {
185 public:
186     enum EFormatHierarchyRoot {
187         eFHR_DVCR            = AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_DVCR,
188         eFHR_AudioMusic      = AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_AUDIOMUSIC,
189         eFHR_Invalid         = AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_INVALID,
190     };
191
192     enum EFomatHierarchyLevel1 {
193         eFHL1_DVCR_SD525_60                     = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SD525_60,
194         eFHL1_DVCR_SDL525_60                    = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SDL525_60,
195         eFHL1_DVCR_HD1125_60                    = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_HD1125_60,
196         eFHL1_DVCR_SD625_60                     = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SD625_60,
197         eFHL1_DVCR_SDL625_50                    = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SDL625_50,
198         eFHL1_DVCR_HD1250_50                    = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_HD1250_50,
199         eFHL1_AUDIOMUSIC_AM824                  = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_AM824,
200         eFHL1_AUDIOMUSIC_24_4_AUDIO_PACK        = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_24_4_AUDIO_PACK,
201         eFHL1_AUDIOMUSIC_32_FLOATING            = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_32_FLOATING_POINT_DATA,
202         eFHL1_AUDIOMUSIC_AM824_COMPOUND         = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_AM824_COMPOUND,
203         eFHL1_AUDIOMUSIC_DONT_CARE              = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_DONT_CARE,
204     };
205
206     enum EFormatHierarchyLevel2 {
207         eFHL2_AM824_IEC60968_3 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC60968_3,
208         eFHL2_AM824_IEC61937_3 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_3,
209         eFHL2_AM824_IEC61937_4 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_4,
210         eFHL2_AM824_IEC61937_5 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_5,
211         eFHL2_AM824_IEC61937_6 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_6,
212         eFHL2_AM824_IEC61937_7 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_7,
213         eFHL2_AM824_MULTI_BIT_LINEAR_AUDIO_RAW = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MULTI_BIT_LINEAR_AUDIO_RAW,
214         eFHL2_AM824_MULTI_BIT_LINEAR_AUDIO_DVD_AUDIO = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MULTI_BIT_LINEAR_AUDIO_DVD_AUDIO,
215         eFHL2_AM824_ONE_BIT_AUDIO_PLAIN_RAW = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_PLAIN_RAW,
216         eFHL2_AM824_ONE_BIT_AUDIO_PLAIN_SACD = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_PLAIN_SACD,
217         eFHL2_AM824_ONE_BIT_AUDIO_ENCODED_RAW = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_ENCODED_RAW,
218         eFHL2_AM824_ONE_BIT_AUDIO_ENCODED_SACD = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_ENCODED_SACD,
219         eFHL2_AM824_HIGH_PRECISION_MULTIBIT_LINEAR_AUDIO = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_HIGH_PRECISION_MULTIBIT_LINEAR_AUDIO,
220         eFHL2_AM824_MIDI_CONFORMANT = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MIDI_CONFORMANT,
221         eFHL2_AM824_SYNC_STREAM = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_SYNC_STREAM,
222         eFHL2_AM824_DONT_CARE = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_DONT_CARE,
223     };
224
225     typedef byte_t format_hierarchy_root_t;
226     typedef byte_t format_hierarchy_level1_t;
227     typedef byte_t format_hierarchy_level2_t;
228
229     FormatInformation();
230     FormatInformation( const FormatInformation& rhs );
231     virtual ~FormatInformation();
232
233     virtual bool serialize( Util::Cmd::IOSSerialize& se );
234     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
235
236     virtual FormatInformation* clone() const;
237
238     format_hierarchy_root_t m_root;
239     format_hierarchy_level1_t m_level1;
240     format_hierarchy_level2_t m_level2;
241     FormatInformationStreams* m_streams;
242 };
243
244 ///////////////////////////////////////////////////////////
245
246 class ExtendedStreamFormatCmd: public AVCCommand
247 {
248 public:
249     enum ESubFunction {
250         eSF_Input                                               = AVC1394_STREAM_FORMAT_SUBFUNCTION_INPUT,
251         eSF_Output                                              = AVC1394_STREAM_FORMAT_SUBFUNCTION_OUTPUT,
252         eSF_ExtendedStreamFormatInformationCommand              = AVC1394_STREAM_FORMAT_SUBFUNCTION_EXTENDED_STREAM_FORMAT,
253         eSF_ExtendedStreamFormatInformationCommandList          = AVC1394_STREAM_FORMAT_SUBFUNCTION_EXTENDED_STREAM_FORMAT_LIST,
254     };
255
256     enum EStatus {
257         eS_Active         = AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_ACTIVE,
258         eS_Inactive       = AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_INACTIVE,
259         eS_NoStreamFormat = AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_NO_STREAM_FORMAT,
260         eS_NotUsed        = AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_NOT_USED,
261     };
262     typedef byte_t status_t;
263     typedef byte_t index_in_stream_format_t;
264
265     ExtendedStreamFormatCmd( Ieee1394Service& ieee1349service, ESubFunction eSubFunction = eSF_ExtendedStreamFormatInformationCommand );
266     ExtendedStreamFormatCmd( const ExtendedStreamFormatCmd& rhs );
267     virtual ~ExtendedStreamFormatCmd();
268
269     bool setPlugAddress( const PlugAddress& plugAddress );
270     bool setIndexInStreamFormat( const int index );
271     bool setSubFunction( ESubFunction subFunction );
272
273     virtual bool serialize( Util::Cmd::IOSSerialize& se );
274     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
275
276     EStatus getStatus();
277     FormatInformation* getFormatInformation();
278     index_in_stream_format_t getIndex();
279
280     virtual const char* getCmdName() const
281     { return "ExtendedStreamFormatCmd"; }
282
283 protected:
284     subfunction_t            m_subFunction;
285     PlugAddress*             m_plugAddress;
286     status_t                 m_status;
287     index_in_stream_format_t m_indexInStreamFormat;
288     FormatInformation*       m_formatInformation;
289 };
290
291 }
292
293 #endif // AVCEXTENDEDSTREAMFROMAT_H
Note: See TracBrowser for help on using the browser.