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

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

implement verbose listing of cluster info and music plug info

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 class Util::Cmd::IOSSerialize;
54 class Util::Cmd::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( Util::Cmd::IOSSerialize& se );
83     virtual bool deserialize( Util::Cmd::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( Util::Cmd::IOSSerialize& se );
114     virtual bool deserialize( Util::Cmd::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     virtual void show();
139
140 protected:
141     void printBufferBytes(unsigned int level, size_t length, byte_t* buffer) const;
142
143     Unit*            m_unit;
144     Subunit*         m_subunit;
145    
146     AVCDescriptorSpecifier m_specifier;
147    
148     byte_t*          m_data;
149     uint16_t         m_descriptor_length;
150    
151     bool             m_loaded;
152
153 };
154
155 /**
156  * The info block class
157  */
158 class AVCInfoBlock : public IBusData
159 {
160 public:
161
162     virtual bool serialize( Util::Cmd::IOSSerialize& se );
163     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
164     static bool peekBlockType( Util::Cmd::IISDeserialize& de, uint16_t * );
165     static bool peekBlockLength( Util::Cmd::IISDeserialize& de, uint16_t * );
166
167     // note: in the end these have to be protected
168     AVCInfoBlock( );
169     AVCInfoBlock( uint16_t );
170     virtual ~AVCInfoBlock() {};
171    
172     virtual AVCInfoBlock* clone() const;
173    
174 //     EInfoBlockType getType();
175    
176     bool setVerbose( int verboseLevel );
177     int getVerboseLevel();
178    
179     virtual const char* getInfoBlockName() const
180         {return "AVCInfoBlock";};
181    
182     uint16_t    m_compound_length;
183     uint16_t    m_info_block_type;
184     uint16_t    m_primary_field_length;
185    
186     uint16_t    m_supported_info_block_type;
187
188     virtual void show();
189
190 private:
191
192 };
193
194 class AVCRawTextInfoBlock : public AVCInfoBlock
195 {
196 public:
197
198     virtual bool serialize( Util::Cmd::IOSSerialize& se );
199     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
200
201     virtual bool clear();
202    
203     AVCRawTextInfoBlock( );
204     virtual ~AVCRawTextInfoBlock();
205     virtual const char* getInfoBlockName() const
206         {return "AVCRawTextInfoBlock";};
207
208     std::string m_text;
209
210 protected:
211
212 private:
213
214 };
215
216 class AVCNameInfoBlock : public AVCInfoBlock
217 {
218 public:
219
220     virtual bool serialize( Util::Cmd::IOSSerialize& se );
221     virtual bool deserialize( Util::Cmd::IISDeserialize& de );
222
223     virtual bool clear();
224    
225     AVCNameInfoBlock( );
226     virtual ~AVCNameInfoBlock();
227     virtual const char* getInfoBlockName() const
228         {return "AVCNameInfoBlock";};
229
230     std::string m_text;
231
232 protected:
233
234 private:
235
236 };
237 /**
238  *
239  */
240 // class AVCUnitIdentifierDescriptor : public AVCDescriptor
241 // {
242 //
243 // public:
244 //     AVCUnitIdentifierDescriptor(  );
245 //     virtual ~AVCUnitIdentifierDescriptor() {}
246 //
247 // };
248
249 }
250
251 #endif // AVCDESCRIPTOR_H
Note: See TracBrowser for help on using the browser.