root/trunk/libffado/src/bebob/bebob_dl_codes.h

Revision 554, 9.8 kB (checked in by ppalmers, 14 years ago)

Merge echoaudio branch into trunk.

This adds support for the Echo Audiofire devices to FFADO. Possibly also other devices working with the Apple Class Driver will work with this code. It is not fully complete yet, but the main rework is
done.

First of all the IAvDevice class/interface is renamed to FFADODevice, in order to separate the AV/C code from the FFADO API code. A device supported by FFADO implements a FFADODevice.

The BeBoB device has been split up into three groups:
- libavc/* : all code and commands that are specified by AV/C specs. Note that a lot of the code that used to be in BeBoB::AvDevice? now resides in AVC::Unit
- genericavc/* : a FFADODevice that uses AV/C descriptors & commands for discovery and config
- bebob/* : the bebob FFADODevice that inherits from GenericAVC::AvDevice? but that uses BridgeCo? commands for discovery

Everything has been moved as high as possible in the class hierarchy. If necessary, a subclass that uses device specific commands is introduced (e.g. BeBoB::Plug inherits from AVC::Plug and uses the
BridgeCo? extended plug info command to discover it's properties).

There are some other fixes along the way that have been done too.

Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
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 #ifdef ENABLE_BEBOB
25
26 #ifndef BEBOB_DL_CODES_H
27 #define BEBOB_DL_CODES_H
28
29 #include "fbtypes.h"
30
31 #include "libavc/util/avc_serialize.h"
32
33 namespace BeBoB {
34     enum EBootloaderProtocolVersion {
35         eBPV_Unknown = 0,
36         eBPV_V1 = 1,
37         eBPV_V2 = 2,
38         eBPV_V3 = 3,
39     };
40
41     enum EBootloaderCommandCodes {
42         eCmdC_Halt                       = 0x01,
43         eCmdC_Reset                      = 0x02,
44         eCmdC_ReadImageCRC               = 0x03,
45         eCmdC_DownloadStart              = 0x04,
46         eCmdC_DownloadBlock              = 0x05,
47         eCmdC_DownloadEnd                = 0x06,
48         eCmdC_SwitchTo1394Shell          = 0x07,
49         eCmdC_ReadShellChars             = 0x08,
50         eCmdC_WriteShellChars            = 0x09,
51         eCmdC_ProgramGUID                = 0x0a,
52         eCmdC_ProgramMAC                 = 0x0b,
53         eCmdC_InitPersParams             = 0x0c,
54         eCmdC_InitConfigToFactorySetting = 0x0d,
55         eCmdC_SetDebugGUID               = 0x0f,
56         eCmdC_ProgramHWIdVersion         = 0x10,
57         eCmdC_Go                         = 0x11,
58     };
59
60     /////////////////////////
61
62     class CommandCodes {
63     public:
64         CommandCodes( fb_quadlet_t protocolVersion,
65                       fb_byte_t commandCode,
66                       size_t    msgSize,
67                       fb_byte_t operandSizeRequestField,
68                       fb_byte_t operandSizeResponseField );
69     virtual ~CommandCodes();
70
71         virtual bool serialize( AVC::IOSSerialize& se );
72         virtual bool deserialize( AVC::IISDeserialize& de );
73
74         virtual size_t getMaxSize();
75
76         EBootloaderCommandCodes getCommandCode() const
77             { return static_cast<EBootloaderCommandCodes>( m_commandCode ); }
78
79     fb_byte_t getProtocolVersion() const
80         { return m_protocolVersion; }
81         size_t getMsgSize() const
82             { return m_msgSize; }
83         fb_byte_t getOperandSizeRequest() const
84             { return m_operandSizeRequest; }
85         fb_byte_t getOperandSizeResponse() const
86             { return m_operandSizeResponse; }
87         unsigned short getCommandId() const
88             { return m_commandId; }
89
90         fb_quadlet_t getRespProtocolVersion() const
91             { return m_resp_protocolVersion; }
92         unsigned short getRespCommandId() const
93             { return m_resp_commandId; }
94         fb_byte_t getRespCommandCode() const
95             { return m_resp_commandCode; }
96         fb_byte_t getRespOperandSize() const
97             { return m_resp_operandSize; }
98         fb_byte_t getRespSizeInQuadlets() const
99             { return 2 + m_operandSizeResponse; }
100
101     protected:
102         static unsigned short m_gCommandId;
103         unsigned short m_commandId;
104         fb_quadlet_t m_protocolVersion;
105         fb_byte_t m_commandCode;
106         size_t    m_msgSize;
107         fb_byte_t m_operandSizeRequest;
108         fb_byte_t m_operandSizeResponse;
109
110         fb_quadlet_t   m_resp_protocolVersion;
111         unsigned short m_resp_commandId;
112         fb_byte_t      m_resp_commandCode;
113         fb_byte_t      m_resp_operandSize;
114     };
115
116     /////////////////////////
117
118     class CommandCodesReset : public CommandCodes {
119     public:
120         enum EStartMode {
121             eSM_Application = 0,
122             eSM_Bootloader,
123             eSM_Debugger,
124         };
125
126         CommandCodesReset( fb_quadlet_t protocolVersion, EStartMode startMode );
127         virtual ~CommandCodesReset();
128
129         virtual bool serialize( AVC::IOSSerialize& se );
130         virtual bool deserialize( AVC::IISDeserialize& de );
131
132         EStartMode getStartMode() const
133             { return static_cast<EStartMode>( m_startMode ); }
134         bool setStartMode( EStartMode startMode )
135             { m_startMode = startMode; return true; }
136
137     private:
138         fb_byte_t m_startMode;
139     };
140
141     /////////////////////////
142
143     class CommandCodesProgramGUID : public CommandCodes {
144     public:
145         CommandCodesProgramGUID( fb_quadlet_t protocolVersion,
146                            fb_octlet_t guid );
147         virtual ~CommandCodesProgramGUID();
148
149         virtual bool serialize( AVC::IOSSerialize& se );
150         virtual bool deserialize( AVC::IISDeserialize& de );
151
152         fb_octlet_t getGUID() const
153             { return m_guid; }
154         bool setGUID( fb_octlet_t guid )
155             { m_guid = guid; return true; }
156
157     private:
158         fb_octlet_t m_guid;
159     };
160
161
162     /////////////////////////
163
164     class CommandCodesDownloadStart : public CommandCodes {
165     public:
166         enum EObject {
167             eO_Application    = 0,
168         eO_Config         = 1,
169         eO_Debugger       = 2,
170             eO_Bootloader     = 3,
171         eO_WarpImage      = 4,
172         eO_SerialBootCode = 5,
173         };
174
175         CommandCodesDownloadStart( fb_quadlet_t protocolVersion,
176                      EObject object );
177         virtual ~CommandCodesDownloadStart();
178
179         virtual bool serialize( AVC::IOSSerialize& se );
180         virtual bool deserialize( AVC::IISDeserialize& de );
181
182         bool setDate( fb_octlet_t date )
183             { m_date = date; return true; }
184         bool setTime( fb_octlet_t time )
185             { m_time = time; return true; }
186         bool setId( fb_quadlet_t id )
187             { m_id = id; return true; }
188         bool setVersion( fb_quadlet_t version )
189             { m_version = version; return true; }
190         bool setBaseAddress( fb_quadlet_t address )
191             { m_address = address; return true; }
192         bool setLength( fb_quadlet_t length )
193             { m_length = length; return true; }
194         bool setCRC( fb_quadlet_t crc )
195             { m_crc = crc; return true; }
196
197         int getMaxBlockSize() const
198             { return m_resp_max_block_size; }
199
200     private:
201         fb_quadlet_t m_object;
202         fb_octlet_t  m_date;
203         fb_octlet_t  m_time;
204         fb_quadlet_t m_id;
205         fb_quadlet_t m_version;
206         fb_quadlet_t m_address;
207         fb_quadlet_t m_length;
208         fb_quadlet_t m_crc;
209
210         int m_resp_max_block_size;
211     };
212
213     /////////////////////////
214
215     class CommandCodesDownloadBlock : public CommandCodes {
216     public:
217         CommandCodesDownloadBlock( fb_quadlet_t protocolVersion );
218         virtual ~CommandCodesDownloadBlock();
219
220         virtual bool serialize( AVC::IOSSerialize& se );
221         virtual bool deserialize( AVC::IISDeserialize& de );
222
223     bool setSeqNumber( fb_quadlet_t seqNumber )
224         { m_seqNumber = seqNumber; return true; }
225     bool setAddress( fb_quadlet_t address )
226             { m_address = address; return true; }
227         bool setNumberBytes( fb_quadlet_t numByte )
228             { m_numBytes = numByte; return true; }
229         fb_quadlet_t getRespSeqNumber() const
230             { return m_resp_seqNumber; }
231         fb_quadlet_t getRespErrorCode() const
232             { return m_resp_errorCode; }
233     private:
234         fb_quadlet_t m_seqNumber;
235         fb_quadlet_t m_address;
236         fb_quadlet_t m_numBytes;
237
238     fb_quadlet_t m_resp_seqNumber;
239     fb_quadlet_t m_resp_errorCode;
240     };
241
242     /////////////////////////
243
244     class CommandCodesDownloadEnd : public CommandCodes {
245     public:
246         CommandCodesDownloadEnd( fb_quadlet_t protocolVersion );
247         virtual ~CommandCodesDownloadEnd();
248
249         virtual bool serialize( AVC::IOSSerialize& se );
250         virtual bool deserialize( AVC::IISDeserialize& de );
251
252         fb_quadlet_t getRespCrc32() const
253             { return m_resp_crc32; }
254         bool getRespIsValid() const
255             { return m_resp_valid == 0; }
256
257     private:
258         quadlet_t m_resp_crc32;
259         quadlet_t m_resp_valid;
260     };
261
262
263     /////////////////////////
264
265     class CommandCodesInitializePersParam : public CommandCodes {
266     public:
267         CommandCodesInitializePersParam( fb_quadlet_t protocolVersion );
268         virtual ~CommandCodesInitializePersParam();
269
270         virtual bool serialize( AVC::IOSSerialize& se );
271         virtual bool deserialize( AVC::IISDeserialize& de );
272     };
273
274     /////////////////////////
275
276     class CommandCodesInitializeConfigToFactorySetting : public CommandCodes {
277     public:
278         CommandCodesInitializeConfigToFactorySetting(
279             fb_quadlet_t protocolVersion );
280         virtual ~CommandCodesInitializeConfigToFactorySetting();
281
282         virtual bool serialize( AVC::IOSSerialize& se );
283         virtual bool deserialize( AVC::IISDeserialize& de );
284     };
285
286     /////////////////////////
287
288     class CommandCodesGo : public CommandCodes {
289     public:
290         enum EStartMode {
291             eSM_Application = 0,
292         eSM_Debugger = 2,
293         };
294
295         CommandCodesGo( fb_quadlet_t protocolVersion, EStartMode startMode );
296         virtual ~CommandCodesGo();
297
298         virtual bool serialize( AVC::IOSSerialize& se );
299         virtual bool deserialize( AVC::IISDeserialize& de );
300
301         EStartMode getStartMode() const
302             { return static_cast<EStartMode>( m_startMode ); }
303         bool setStartMode( EStartMode startMode )
304             { m_startMode = startMode; return true; }
305
306         fb_quadlet_t getRespIsValidCRC() const
307             { return m_resp_validCRC; }
308
309     private:
310         fb_quadlet_t m_startMode;
311     fb_quadlet_t m_resp_validCRC;
312     };
313
314
315
316 };
317 #endif
318
319 #endif //#ifdef ENABLE_BEBOB
Note: See TracBrowser for help on using the browser.