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

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

Merge 2.0 branch changes.

svn merge -r1349:HEAD svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0

  • 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 enum ERateControl {
109     eRC_Supported = 0x00,
110     eRC_DontCare  = 0x01,
111 };
112
113 ////////////////////////////////////////////////////////////
114
115 class StreamFormatInfo: public IBusData
116 {
117 public:
118     StreamFormatInfo();
119
120     virtual bool serialize( Util::Cmd::IOSSerialize& se );
121     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
122
123     virtual StreamFormatInfo* clone() const;
124
125     number_of_channels_t m_numberOfChannels;
126     stream_format_t      m_streamFormat;
127 };
128 std::ostream& operator<<( std::ostream& stream, StreamFormatInfo info );
129
130 ////////////////////////////////////////////////////////////
131
132 class FormatInformationStreams: public IBusData
133 {
134 public:
135     FormatInformationStreams() {}
136     virtual ~FormatInformationStreams() {}
137 };
138
139 ////////////////////////////////////////////////////////////
140
141 class FormatInformationStreamsSync: public FormatInformationStreams
142 {
143 public:
144     FormatInformationStreamsSync();
145
146     virtual bool serialize( Util::Cmd::IOSSerialize& se );
147     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
148     virtual FormatInformationStreamsSync* clone() const;
149
150     reserved_t           m_reserved0;
151     sampling_frequency_t m_samplingFrequency;
152     rate_control_t       m_rateControl;
153     reserved_t           m_reserved1;
154 };
155
156 ////////////////////////////////////////////////////////////
157
158 class FormatInformationStreamsCompound: public FormatInformationStreams
159 {
160 public:
161     FormatInformationStreamsCompound();
162     virtual ~FormatInformationStreamsCompound();
163
164     virtual bool serialize( Util::Cmd::IOSSerialize& se );
165     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
166     virtual FormatInformationStreamsCompound* clone() const;
167
168     sampling_frequency_t                     m_samplingFrequency;
169     rate_control_t                           m_rateControl;
170     number_of_stream_format_infos_t          m_numberOfStreamFormatInfos;
171
172     typedef std::vector< StreamFormatInfo* > StreamFormatInfoVector;
173     StreamFormatInfoVector                   m_streamFormatInfos;
174 };
175 std::ostream& operator<<( std::ostream& stream, FormatInformationStreamsCompound info );
176
177
178 ////////////////////////////////////////////////////////////
179
180 class FormatInformation: public IBusData
181 {
182 public:
183     enum EFormatHierarchyRoot {
184         eFHR_DVCR            = AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_DVCR,
185         eFHR_AudioMusic      = AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_AUDIOMUSIC,
186         eFHR_Invalid         = AVC1394_STREAM_FORMAT_HIERARCHY_ROOT_INVALID,
187     };
188
189     enum EFomatHierarchyLevel1 {
190         eFHL1_DVCR_SD525_60                     = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SD525_60,
191         eFHL1_DVCR_SDL525_60                    = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SDL525_60,
192         eFHL1_DVCR_HD1125_60                    = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_HD1125_60,
193         eFHL1_DVCR_SD625_60                     = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SD625_60,
194         eFHL1_DVCR_SDL625_50                    = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_SDL625_50,
195         eFHL1_DVCR_HD1250_50                    = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_DVCR_HD1250_50,
196         eFHL1_AUDIOMUSIC_AM824                  = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_AM824,
197         eFHL1_AUDIOMUSIC_24_4_AUDIO_PACK        = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_24_4_AUDIO_PACK,
198         eFHL1_AUDIOMUSIC_32_FLOATING            = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_32_FLOATING_POINT_DATA,
199         eFHL1_AUDIOMUSIC_AM824_COMPOUND         = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_AM824_COMPOUND,
200         eFHL1_AUDIOMUSIC_DONT_CARE              = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_1_AUDIOMUSIC_DONT_CARE,
201     };
202
203     enum EFormatHierarchyLevel2 {
204         eFHL2_AM824_IEC60968_3 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC60968_3,
205         eFHL2_AM824_IEC61937_3 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_3,
206         eFHL2_AM824_IEC61937_4 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_4,
207         eFHL2_AM824_IEC61937_5 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_5,
208         eFHL2_AM824_IEC61937_6 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_6,
209         eFHL2_AM824_IEC61937_7 = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_IEC61937_7,
210         eFHL2_AM824_MULTI_BIT_LINEAR_AUDIO_RAW = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MULTI_BIT_LINEAR_AUDIO_RAW,
211         eFHL2_AM824_MULTI_BIT_LINEAR_AUDIO_DVD_AUDIO = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MULTI_BIT_LINEAR_AUDIO_DVD_AUDIO,
212         eFHL2_AM824_ONE_BIT_AUDIO_PLAIN_RAW = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_PLAIN_RAW,
213         eFHL2_AM824_ONE_BIT_AUDIO_PLAIN_SACD = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_PLAIN_SACD,
214         eFHL2_AM824_ONE_BIT_AUDIO_ENCODED_RAW = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_ENCODED_RAW,
215         eFHL2_AM824_ONE_BIT_AUDIO_ENCODED_SACD = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_ONE_BIT_AUDIO_ENCODED_SACD,
216         eFHL2_AM824_HIGH_PRECISION_MULTIBIT_LINEAR_AUDIO = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_HIGH_PRECISION_MULTIBIT_LINEAR_AUDIO,
217         eFHL2_AM824_MIDI_CONFORMANT = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_MIDI_CONFORMANT,
218         eFHL2_AM824_SYNC_STREAM = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_SYNC_STREAM,
219         eFHL2_AM824_DONT_CARE = AVC1394_STREAM_FORMAT_HIERARCHY_LEVEL_2_AM824_DONT_CARE,
220     };
221
222     typedef byte_t format_hierarchy_root_t;
223     typedef byte_t format_hierarchy_level1_t;
224     typedef byte_t format_hierarchy_level2_t;
225
226     FormatInformation();
227     FormatInformation( const FormatInformation& rhs );
228     virtual ~FormatInformation();
229
230     virtual bool serialize( Util::Cmd::IOSSerialize& se );
231     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
232
233     virtual FormatInformation* clone() const;
234
235     format_hierarchy_root_t m_root;
236     format_hierarchy_level1_t m_level1;
237     format_hierarchy_level2_t m_level2;
238     FormatInformationStreams* m_streams;
239 };
240
241 ///////////////////////////////////////////////////////////
242
243 class ExtendedStreamFormatCmd: public AVCCommand
244 {
245 public:
246     enum ESubFunction {
247         eSF_Input                                               = AVC1394_STREAM_FORMAT_SUBFUNCTION_INPUT,
248         eSF_Output                                              = AVC1394_STREAM_FORMAT_SUBFUNCTION_OUTPUT,
249         eSF_ExtendedStreamFormatInformationCommand              = AVC1394_STREAM_FORMAT_SUBFUNCTION_EXTENDED_STREAM_FORMAT,
250         eSF_ExtendedStreamFormatInformationCommandList          = AVC1394_STREAM_FORMAT_SUBFUNCTION_EXTENDED_STREAM_FORMAT_LIST,
251     };
252
253     enum EStatus {
254         eS_Active         = AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_ACTIVE,
255         eS_Inactive       = AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_INACTIVE,
256         eS_NoStreamFormat = AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_NO_STREAM_FORMAT,
257         eS_NotUsed        = AVC1394_EXTENDED_STREAM_FORMAT_INFO_STATUS_NOT_USED,
258     };
259     typedef byte_t status_t;
260     typedef byte_t index_in_stream_format_t;
261
262     ExtendedStreamFormatCmd( Ieee1394Service& ieee1349service, ESubFunction eSubFunction = eSF_ExtendedStreamFormatInformationCommand );
263     ExtendedStreamFormatCmd( const ExtendedStreamFormatCmd& rhs );
264     virtual ~ExtendedStreamFormatCmd();
265
266     bool setPlugAddress( const PlugAddress& plugAddress );
267     bool setIndexInStreamFormat( const int index );
268     bool setSubFunction( ESubFunction subFunction );
269
270     virtual bool serialize( Util::Cmd::IOSSerialize& se );
271     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
272
273     EStatus getStatus();
274     FormatInformation* getFormatInformation();
275     index_in_stream_format_t getIndex();
276
277     virtual const char* getCmdName() const
278     { return "ExtendedStreamFormatCmd"; }
279
280 protected:
281     subfunction_t            m_subFunction;
282     PlugAddress*             m_plugAddress;
283     status_t                 m_status;
284     index_in_stream_format_t m_indexInStreamFormat;
285     FormatInformation*       m_formatInformation;
286 };
287
288 }
289
290 #endif // AVCEXTENDEDSTREAMFROMAT_H
Note: See TracBrowser for help on using the browser.