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

Revision 1361, 6.1 kB (checked in by ppalmers, 14 years ago)

Merge 2.0 branch changes.

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

Line 
1 /*
2  * Copyright (C) 2005-2008 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 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 /**
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 /**
54  * The specifier used to indicate the target descriptor
55  */
56  
57 // NOTE: how are we going to do this? all lengths of the
58 // arguments are dependent on the (sub)unit descriptor
59 class AVCDescriptorSpecifier : public IBusData
60 {
61 public:
62     enum EType {
63         eIndentifier            = 0x00,
64         eListById               = 0x10,
65         eListByType             = 0x11,
66         eEntryByListId          = 0x20,
67         eEntryByObjectIdInList  = 0x21,
68         eEntryByType            = 0x22,
69         eEntryByObjectId        = 0x23,
70         eInfoBlockByType        = 0x30,
71         eInfoBlockByPosition    = 0x31,
72         eSubunit0x80            = 0x80,
73         eInvalid                = 0xFF,
74     };
75    
76 public:
77     AVCDescriptorSpecifier( enum EType type );
78     virtual ~AVCDescriptorSpecifier() {};
79    
80     virtual bool serialize( Util::Cmd::IOSSerialize& se );
81     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
82    
83     virtual AVCDescriptorSpecifier* clone() const;
84    
85 /*    void setType( enum EType type ) {m_type=type;};
86     void setListIdSize( unsigned int l ) {m_listid_size=l;};
87     void setObjectIdSize( unsigned int l ) {m_objectid_size=l;};
88     void setEntryPositionSize( unsigned int l ) {m_entrypos_size=l;};*/
89    
90     enum EType      m_type;
91     uint16_t        m_listid_size;
92     uint16_t        m_objectid_size;
93     uint16_t        m_entrypos_size;
94    
95     uint16_t        m_info_block_type;
96     byte_t          m_info_block_instance;
97     byte_t          m_info_block_position;
98
99 private:
100
101
102 };
103
104 /**
105  * The descriptor class
106  */
107 class AVCDescriptor : public IBusData
108 {
109 public:
110
111     virtual bool serialize( Util::Cmd::IOSSerialize& se );
112     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
113
114     // note: in the end these have to be protected
115     AVCDescriptor( Unit* unit );
116     AVCDescriptor( Unit* unit, Subunit* subunit  );
117     AVCDescriptor( Unit* unit, Subunit* subunit, AVCDescriptorSpecifier s );
118     virtual ~AVCDescriptor();
119    
120     virtual AVCDescriptor* clone() const;
121    
122     void setSpecifier(AVCDescriptorSpecifier s) {m_specifier=s;};
123
124     ESubunitType getSubunitType() const;
125     subunit_id_t getSubunitId() const;
126
127     bool setVerboseLevel( int verboseLevel );
128     int getVerboseLevel();
129
130     virtual const char* getDescriptorName() const
131         {return "AVCDescriptor";};
132
133     bool load();
134     bool reload();
135
136     virtual void show();
137
138 protected:
139     void printBufferBytes(unsigned int level, size_t length, byte_t* buffer) const;
140
141     Unit*            m_unit;
142     Subunit*         m_subunit;
143    
144     AVCDescriptorSpecifier m_specifier;
145    
146     byte_t*          m_data;
147     uint16_t         m_descriptor_length;
148    
149     bool             m_loaded;
150
151 };
152
153 /**
154  * The info block class
155  */
156 class AVCInfoBlock : public IBusData
157 {
158 public:
159
160     virtual bool serialize( Util::Cmd::IOSSerialize& se );
161     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
162     static bool peekBlockType( Util::Cmd::IISDeserialize& de, uint16_t * );
163     static bool peekBlockLength( Util::Cmd::IISDeserialize& de, uint16_t * );
164
165     // note: in the end these have to be protected
166     AVCInfoBlock( );
167     AVCInfoBlock( uint16_t );
168     virtual ~AVCInfoBlock() {};
169    
170     virtual AVCInfoBlock* clone() const;
171    
172 //     EInfoBlockType getType();
173    
174     bool setVerbose( int verboseLevel );
175     int getVerboseLevel();
176    
177     virtual const char* getInfoBlockName() const
178         {return "AVCInfoBlock";};
179    
180     uint16_t    m_compound_length;
181     uint16_t    m_info_block_type;
182     uint16_t    m_primary_field_length;
183    
184     uint16_t    m_supported_info_block_type;
185
186     virtual void show();
187
188 private:
189
190 };
191
192 class AVCRawTextInfoBlock : public AVCInfoBlock
193 {
194 public:
195
196     virtual bool serialize( Util::Cmd::IOSSerialize& se );
197     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
198
199     virtual bool clear();
200    
201     AVCRawTextInfoBlock( );
202     virtual ~AVCRawTextInfoBlock();
203     virtual const char* getInfoBlockName() const
204         {return "AVCRawTextInfoBlock";};
205
206     std::string m_text;
207
208 protected:
209
210 private:
211
212 };
213
214 class AVCNameInfoBlock : public AVCInfoBlock
215 {
216 public:
217
218     virtual bool serialize( Util::Cmd::IOSSerialize& se );
219     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
220
221     virtual bool clear();
222    
223     AVCNameInfoBlock( );
224     virtual ~AVCNameInfoBlock();
225     virtual const char* getInfoBlockName() const
226         {return "AVCNameInfoBlock";};
227
228     std::string m_text;
229
230 protected:
231
232 private:
233
234 };
235 /**
236  *
237  */
238 // class AVCUnitIdentifierDescriptor : public AVCDescriptor
239 // {
240 //
241 // public:
242 //     AVCUnitIdentifierDescriptor(  );
243 //     virtual ~AVCUnitIdentifierDescriptor() {}
244 //
245 // };
246
247 }
248
249 #endif // AVCDESCRIPTOR_H
Note: See TracBrowser for help on using the browser.