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 |
#ifndef AVCGENERIC_H |
---|
25 |
#define AVCGENERIC_H |
---|
26 |
|
---|
27 |
#include "../avc_definitions.h" |
---|
28 |
#include "debugmodule/debugmodule.h" |
---|
29 |
|
---|
30 |
#include "fbtypes.h" |
---|
31 |
|
---|
32 |
#include <libavc1394/avc1394.h> |
---|
33 |
|
---|
34 |
class Ieee1394Service; |
---|
35 |
|
---|
36 |
namespace Util { |
---|
37 |
class IOSSerialize; |
---|
38 |
class IISDeserialize; |
---|
39 |
}; |
---|
40 |
|
---|
41 |
namespace AVC { |
---|
42 |
|
---|
43 |
const int fcpFrameMaxLength = 512; |
---|
44 |
typedef unsigned char fcp_frame_t[fcpFrameMaxLength]; |
---|
45 |
|
---|
46 |
enum EAVCDiscoveryMode { |
---|
47 |
eDM_BeBoB = 0x00, |
---|
48 |
eDM_GenericAVC = 0x01, |
---|
49 |
eDM_Invalid = 0xFF, |
---|
50 |
}; |
---|
51 |
|
---|
52 |
class IBusData { |
---|
53 |
public: |
---|
54 |
IBusData() {} |
---|
55 |
virtual ~IBusData() {} |
---|
56 |
|
---|
57 |
virtual bool serialize( Util::IOSSerialize& se ) = 0; |
---|
58 |
virtual bool deserialize( Util::IISDeserialize& de ) = 0; |
---|
59 |
|
---|
60 |
virtual IBusData* clone() const = 0; |
---|
61 |
|
---|
62 |
protected: |
---|
63 |
DECLARE_DEBUG_MODULE; |
---|
64 |
}; |
---|
65 |
|
---|
66 |
class AVCCommand |
---|
67 |
{ |
---|
68 |
public: |
---|
69 |
enum EResponse { |
---|
70 |
eR_Unknown = 0, |
---|
71 |
eR_NotImplemented = AVC1394_RESP_NOT_IMPLEMENTED, |
---|
72 |
eR_Accepted = AVC1394_RESP_ACCEPTED, |
---|
73 |
eR_Rejected = AVC1394_RESP_REJECTED, |
---|
74 |
eR_InTransition = AVC1394_RESP_IN_TRANSITION, |
---|
75 |
eR_Implemented = AVC1394_RESP_IMPLEMENTED, |
---|
76 |
eR_Changed = AVC1394_RESP_CHANGED, |
---|
77 |
eR_Interim = AVC1394_RESP_INTERIM, |
---|
78 |
}; |
---|
79 |
|
---|
80 |
enum ECommandType { |
---|
81 |
eCT_Control = AVC1394_CTYP_CONTROL, |
---|
82 |
eCT_Status = AVC1394_CTYP_STATUS, |
---|
83 |
eCT_SpecificInquiry = AVC1394_CTYP_SPECIFIC_INQUIRY, |
---|
84 |
eCT_Notify = AVC1394_CTYP_NOTIFY, |
---|
85 |
eCT_GeneralInquiry = AVC1394_CTYP_GENERAL_INQUIRY, |
---|
86 |
eCT_Unknown = 0xff, |
---|
87 |
}; |
---|
88 |
|
---|
89 |
virtual bool serialize( Util::IOSSerialize& se ); |
---|
90 |
virtual bool deserialize( Util::IISDeserialize& de ); |
---|
91 |
|
---|
92 |
virtual bool setCommandType( ECommandType commandType ); |
---|
93 |
virtual bool fire(); |
---|
94 |
|
---|
95 |
EResponse getResponse(); |
---|
96 |
|
---|
97 |
bool setNodeId( fb_nodeid_t nodeId ); |
---|
98 |
bool setSubunitType( ESubunitType subunitType ); |
---|
99 |
bool setSubunitId( subunit_id_t subunitId ); |
---|
100 |
|
---|
101 |
ESubunitType getSubunitType(); |
---|
102 |
subunit_id_t getSubunitId(); |
---|
103 |
|
---|
104 |
bool setVerbose( int verboseLevel ); |
---|
105 |
int getVerboseLevel(); |
---|
106 |
|
---|
107 |
virtual const char* getCmdName() const = 0; |
---|
108 |
|
---|
109 |
// workaround |
---|
110 |
static void setSleepAfterAVCCommand( int time ); |
---|
111 |
static int getSleepAfterAVCCommand( ) {return m_time;}; |
---|
112 |
protected: |
---|
113 |
void showFcpFrame( const unsigned char* buf, |
---|
114 |
unsigned short frameSize ) const; |
---|
115 |
|
---|
116 |
protected: |
---|
117 |
AVCCommand( Ieee1394Service& ieee1394service, opcode_t opcode ); |
---|
118 |
virtual ~AVCCommand() {} |
---|
119 |
|
---|
120 |
ECommandType getCommandType(); |
---|
121 |
|
---|
122 |
Ieee1394Service* m_p1394Service; |
---|
123 |
fb_nodeid_t m_nodeId; |
---|
124 |
|
---|
125 |
fcp_frame_t m_fcpFrame; |
---|
126 |
|
---|
127 |
private: |
---|
128 |
ctype_t m_ctype; |
---|
129 |
subunit_t m_subunit; |
---|
130 |
opcode_t m_opcode; |
---|
131 |
EResponse m_eResponse; |
---|
132 |
ECommandType m_commandType; |
---|
133 |
static int m_time; |
---|
134 |
|
---|
135 |
protected: |
---|
136 |
DECLARE_DEBUG_MODULE; |
---|
137 |
}; |
---|
138 |
|
---|
139 |
|
---|
140 |
const char* subunitTypeToString( subunit_type_t subunitType ); |
---|
141 |
const char* responseToString( AVCCommand::EResponse eResponse ); |
---|
142 |
|
---|
143 |
} |
---|
144 |
|
---|
145 |
#endif // AVCGENERIC_H |
---|