root/trunk/libffado/src/libavc/general/avc_generic.h

Revision 827, 3.9 kB (checked in by wagi, 15 years ago)

untabify

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