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

Revision 503, 3.6 kB (checked in by ppalmers, 17 years ago)

- put all libavc stuff into it's own name namespace (AVC)

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