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

Revision 644, 3.8 kB (checked in by ppalmers, 13 years ago)

- Adapt the phase 88 mixer control application to the new DBUS control interface

  • 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 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     bool setVerboseLevel( int verboseLevel )
106         { return setVerbose(verboseLevel);};
107
108     int getVerboseLevel();
109
110     virtual const char* getCmdName() const = 0;
111
112     // workaround
113     static void setSleepAfterAVCCommand( int time );
114     static int getSleepAfterAVCCommand( ) {return m_time;};
115 protected:
116     void showFcpFrame( const unsigned char* buf,
117                unsigned short frameSize ) const;
118
119 protected:
120     AVCCommand( Ieee1394Service& ieee1394service, opcode_t opcode );
121     virtual ~AVCCommand() {}
122
123     ECommandType getCommandType();
124
125     Ieee1394Service* m_p1394Service;
126     fb_nodeid_t      m_nodeId;
127
128     fcp_frame_t      m_fcpFrame;
129
130 private:
131     ctype_t      m_ctype;
132     subunit_t    m_subunit;
133     opcode_t     m_opcode;
134     EResponse    m_eResponse;
135     ECommandType m_commandType;
136     static int   m_time;
137    
138 protected:
139     DECLARE_DEBUG_MODULE;
140 };
141
142
143 const char* subunitTypeToString( subunit_type_t subunitType );
144 const char* responseToString( AVCCommand::EResponse eResponse );
145
146 }
147
148 #endif // AVCGENERIC_H
Note: See TracBrowser for help on using the browser.