root/trunk/libffado/src/libavc/descriptors/avc_descriptor.h

Revision 524, 5.9 kB (checked in by ppalmers, 17 years ago)

echo discovery works, audio I/O works, still some issues with midi and channel naming

Line 
1 /*
2  * Copyright (C) 2007 by Pieter Palmers
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 /**
25  * Partially implements AV/C Descriptors/InfoBlocks as in TA2001021
26  *
27  * The idea is to treat a descriptor as an object that can fetch and store
28  * it's state from/to a device. It will call the necessary AV/C commands to
29  * achieve this. This (hopefully) simplifies handling the fact that there are
30  * so many different descriptor types. It also handles the fact that descriptors
31  * are not state-less.
32  *
33  */
34
35 #ifndef AVCDESCRIPTOR_H
36 #define AVCDESCRIPTOR_H
37
38 #include "../avc_definitions.h"
39
40 #include "../general/avc_generic.h"
41 #include "debugmodule/debugmodule.h"
42
43 #include <libavc1394/avc1394.h>
44 #include <string>
45
46 class Ieee1394Service;
47
48 namespace AVC {
49
50 class Unit;
51 class Subunit;
52
53 class IOSSerialize;
54 class IISDeserialize;
55 /**
56  * The specifier used to indicate the target descriptor
57  */
58  
59 // NOTE: how are we going to do this? all lengths of the
60 // arguments are dependent on the (sub)unit descriptor
61 class AVCDescriptorSpecifier : public IBusData
62 {
63 public:
64     enum EType {
65         eIndentifier            = 0x00,
66         eListById               = 0x10,
67         eListByType             = 0x11,
68         eEntryByListId          = 0x20,
69         eEntryByObjectIdInList  = 0x21,
70         eEntryByType            = 0x22,
71         eEntryByObjectId        = 0x23,
72         eInfoBlockByType        = 0x30,
73         eInfoBlockByPosition    = 0x31,
74         eSubunit0x80            = 0x80,
75         eInvalid                = 0xFF,
76     };
77    
78 public:
79     AVCDescriptorSpecifier( enum EType type );
80     virtual ~AVCDescriptorSpecifier() {};
81    
82     virtual bool serialize( IOSSerialize& se );
83     virtual bool deserialize( IISDeserialize& de );
84    
85     virtual AVCDescriptorSpecifier* clone() const;
86    
87 /*    void setType( enum EType type ) {m_type=type;};
88     void setListIdSize( unsigned int l ) {m_listid_size=l;};
89     void setObjectIdSize( unsigned int l ) {m_objectid_size=l;};
90     void setEntryPositionSize( unsigned int l ) {m_entrypos_size=l;};*/
91    
92     enum EType      m_type;
93     uint16_t        m_listid_size;
94     uint16_t        m_objectid_size;
95     uint16_t        m_entrypos_size;
96    
97     uint16_t        m_info_block_type;
98     byte_t          m_info_block_instance;
99     byte_t          m_info_block_position;
100
101 private:
102
103
104 };
105
106 /**
107  * The descriptor class
108  */
109 class AVCDescriptor : public IBusData
110 {
111 public:
112
113     virtual bool serialize( IOSSerialize& se );
114     virtual bool deserialize( IISDeserialize& de );
115
116     // note: in the end these have to be protected
117     AVCDescriptor( Unit* unit );
118     AVCDescriptor( Unit* unit, Subunit* subunit  );
119     AVCDescriptor( Unit* unit, Subunit* subunit, AVCDescriptorSpecifier s );
120     virtual ~AVCDescriptor();
121    
122     virtual AVCDescriptor* clone() const;
123    
124     void setSpecifier(AVCDescriptorSpecifier s) {m_specifier=s;};
125
126     ESubunitType getSubunitType() const;
127     subunit_id_t getSubunitId() const;
128
129     bool setVerboseLevel( int verboseLevel );
130     int getVerboseLevel();
131
132     virtual const char* getDescriptorName() const
133         {return "AVCDescriptor";};
134    
135     bool load();
136     bool reload();
137    
138 protected:
139
140     Unit*            m_unit;
141     Subunit*         m_subunit;
142    
143     AVCDescriptorSpecifier m_specifier;
144    
145     byte_t*          m_data;
146     uint16_t         m_descriptor_length;
147    
148     bool             m_loaded;
149
150 };
151
152 /**
153  * The info block class
154  */
155 class AVCInfoBlock : public IBusData
156 {
157 public:
158
159     virtual bool serialize( IOSSerialize& se );
160     virtual bool deserialize( IISDeserialize& de );
161     static bool peekBlockType( IISDeserialize& de, uint16_t * );
162     static bool peekBlockLength( IISDeserialize& de, uint16_t * );
163
164     // note: in the end these have to be protected
165     AVCInfoBlock( );
166     AVCInfoBlock( uint16_t );
167     virtual ~AVCInfoBlock() {};
168    
169     virtual AVCInfoBlock* clone() const;
170    
171 //     EInfoBlockType getType();
172    
173     bool setVerbose( int verboseLevel );
174     int getVerboseLevel();
175    
176     virtual const char* getInfoBlockName() const
177         {return "AVCInfoBlock";};
178    
179     uint16_t    m_compound_length;
180     uint16_t    m_info_block_type;
181     uint16_t    m_primary_field_length;
182    
183     uint16_t    m_supported_info_block_type;
184 private:
185
186 };
187
188 class AVCRawTextInfoBlock : public AVCInfoBlock
189 {
190 public:
191
192     virtual bool serialize( IOSSerialize& se );
193     virtual bool deserialize( IISDeserialize& de );
194
195     virtual bool clear();
196    
197     AVCRawTextInfoBlock( );
198     virtual ~AVCRawTextInfoBlock();
199     virtual const char* getInfoBlockName() const
200         {return "AVCRawTextInfoBlock";};
201
202     std::string m_text;
203
204 protected:
205
206 private:
207
208 };
209
210 class AVCNameInfoBlock : public AVCInfoBlock
211 {
212 public:
213
214     virtual bool serialize( IOSSerialize& se );
215     virtual bool deserialize( IISDeserialize& de );
216
217     virtual bool clear();
218    
219     AVCNameInfoBlock( );
220     virtual ~AVCNameInfoBlock();
221     virtual const char* getInfoBlockName() const
222         {return "AVCNameInfoBlock";};
223
224     std::string m_text;
225
226 protected:
227
228 private:
229
230 };
231 /**
232  *
233  */
234 // class AVCUnitIdentifierDescriptor : public AVCDescriptor
235 // {
236 //
237 // public:
238 //     AVCUnitIdentifierDescriptor(  );
239 //     virtual ~AVCUnitIdentifierDescriptor() {}
240 //
241 // };
242
243 }
244
245 #endif // AVCDESCRIPTOR_H
Note: See TracBrowser for help on using the browser.