1 |
/* |
---|
2 |
* Copyright (C) 2005-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 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 3 of the License, or |
---|
12 |
* (at your option) any later version. |
---|
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 |
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 |
private: |
---|
186 |
|
---|
187 |
}; |
---|
188 |
|
---|
189 |
class AVCRawTextInfoBlock : public AVCInfoBlock |
---|
190 |
{ |
---|
191 |
public: |
---|
192 |
|
---|
193 |
virtual bool serialize( Util::Cmd::IOSSerialize& se ); |
---|
194 |
virtual bool deserialize( Util::Cmd::IISDeserialize& de ); |
---|
195 |
|
---|
196 |
virtual bool clear(); |
---|
197 |
|
---|
198 |
AVCRawTextInfoBlock( ); |
---|
199 |
virtual ~AVCRawTextInfoBlock(); |
---|
200 |
virtual const char* getInfoBlockName() const |
---|
201 |
{return "AVCRawTextInfoBlock";}; |
---|
202 |
|
---|
203 |
std::string m_text; |
---|
204 |
|
---|
205 |
protected: |
---|
206 |
|
---|
207 |
private: |
---|
208 |
|
---|
209 |
}; |
---|
210 |
|
---|
211 |
class AVCNameInfoBlock : public AVCInfoBlock |
---|
212 |
{ |
---|
213 |
public: |
---|
214 |
|
---|
215 |
virtual bool serialize( Util::Cmd::IOSSerialize& se ); |
---|
216 |
virtual bool deserialize( Util::Cmd::IISDeserialize& de ); |
---|
217 |
|
---|
218 |
virtual bool clear(); |
---|
219 |
|
---|
220 |
AVCNameInfoBlock( ); |
---|
221 |
virtual ~AVCNameInfoBlock(); |
---|
222 |
virtual const char* getInfoBlockName() const |
---|
223 |
{return "AVCNameInfoBlock";}; |
---|
224 |
|
---|
225 |
std::string m_text; |
---|
226 |
|
---|
227 |
protected: |
---|
228 |
|
---|
229 |
private: |
---|
230 |
|
---|
231 |
}; |
---|
232 |
/** |
---|
233 |
* |
---|
234 |
*/ |
---|
235 |
// class AVCUnitIdentifierDescriptor : public AVCDescriptor |
---|
236 |
// { |
---|
237 |
// |
---|
238 |
// public: |
---|
239 |
// AVCUnitIdentifierDescriptor( ); |
---|
240 |
// virtual ~AVCUnitIdentifierDescriptor() {} |
---|
241 |
// |
---|
242 |
// }; |
---|
243 |
|
---|
244 |
} |
---|
245 |
|
---|
246 |
#endif // AVCDESCRIPTOR_H |
---|