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

Revision 2803, 6.1 kB (checked in by jwoithe, 3 years ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

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