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