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

Revision 1498, 6.1 kB (checked in by ppalmers, 15 years ago)

Merge all changes from 2.0 branch into trunk (since r1361). This _should_ contain all forward merges done in the mean time. At this moment in time both branches should be in sync.

Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
3  * Copyright (C) 2005-2008 by Daniel Wagner
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef AVC_UNIT_H
26 #define AVC_UNIT_H
27
28 #include <stdint.h>
29
30 #include "debugmodule/debugmodule.h"
31
32 #include "../avc_definitions.h"
33 #include "../general/avc_extended_cmd_generic.h"
34 #include "../general/avc_subunit.h"
35 #include "../general/avc_plug.h"
36 #include "../musicsubunit/avc_musicsubunit.h"
37 #include "../audiosubunit/avc_audiosubunit.h"
38
39 #include "libutil/serialize.h"
40
41 #include <sstream>
42 #include <vector>
43
44 class ConfigRom;
45 class Ieee1394Service;
46
47 namespace AVC {
48
49 class Unit {
50 public:
51     Unit( );
52     virtual ~Unit();
53
54     virtual void setVerboseLevel(int l);
55     virtual void show();
56
57     // these have to be implemented by the parent class
58     /// Returns the 1394 service
59     virtual Ieee1394Service& get1394Service() = 0;
60     /// Returns the ConfigRom
61     virtual ConfigRom& getConfigRom() const = 0;
62
63     /// Discovers the unit's internals
64     virtual bool discover();
65
66     PlugManager& getPlugManager()
67         { return *m_pPlugManager; }
68
69     struct SyncInfo {
70         SyncInfo( Plug& source,
71                   Plug& destination,
72                   std::string description )
73             : m_source( &source )
74             , m_destination( &destination )
75             , m_description( description )
76             {}
77         SyncInfo()
78             : m_source( 0 )
79             , m_destination( 0 )
80             , m_description( "" )
81             {}
82         Plug*     m_source;
83         Plug*     m_destination;
84         std::string m_description;
85     };
86
87     typedef std::vector<SyncInfo> SyncInfoVector;
88     virtual const SyncInfoVector& getSyncInfos() const
89         { return m_syncInfos; }
90     virtual const SyncInfo* getActiveSyncInfo();
91
92     virtual bool setActiveSync( const SyncInfo& syncInfo );
93
94     virtual bool serialize( std::string basePath, Util::IOSerialize& ser ) const;
95     virtual bool deserialize( std::string basePath, Util::IODeserialize& deser );
96
97     SubunitAudio* getAudioSubunit( subunit_id_t subunitId )
98         { return dynamic_cast<SubunitAudio*>(
99                    getSubunit( eST_Audio , subunitId ));};
100     SubunitMusic* getMusicSubunit( subunit_id_t subunitId )
101         { return dynamic_cast<SubunitMusic*>(
102                    getSubunit( eST_Music , subunitId ));};
103     Subunit* getSubunit( subunit_type_t subunitType,
104                          subunit_id_t subunitId ) const;
105
106     virtual AVC::Subunit* createSubunit(Unit& unit,
107                                         ESubunitType type,
108                                         subunit_t id );
109     virtual AVC::Plug* createPlug( AVC::Unit* unit,
110                                    AVC::Subunit* subunit,
111                                    AVC::function_block_type_t functionBlockType,
112                                    AVC::function_block_type_t functionBlockId,
113                                    AVC::Plug::EPlugAddressType plugAddressType,
114                                    AVC::Plug::EPlugDirection plugDirection,
115                                    AVC::plug_id_t plugId,
116                                    int globalId = -1 );
117
118 protected:
119     /// cleans the internal data structures that are created by discovery
120     virtual bool clean();
121
122     virtual bool enumerateSubUnits();
123     virtual bool rediscoverConnections();
124     virtual bool discoverPlugConnections();
125     virtual bool discoverSubUnitsPlugConnections();
126     virtual bool discoverPlugs();
127     virtual bool discoverPlugsPCR( AVC::Plug::EPlugDirection plugDirection,
128                            AVC::plug_id_t plugMaxId );
129     virtual bool discoverPlugsExternal( AVC::Plug::EPlugDirection plugDirection,
130                                 AVC::plug_id_t plugMaxId );
131     virtual bool propagatePlugInfo();
132     virtual bool discoverSyncModes();
133     virtual bool checkSyncConnectionsAndAddToList( AVC::PlugVector& plhs,
134                                            AVC::PlugVector& prhs,
135                                            std::string syncDescription );
136     virtual Plug* getSyncPlug( int maxPlugId, Plug::EPlugDirection );
137
138     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const;
139     PlugConnection* getPlugConnection( Plug& srcPlug ) const;
140
141     Plug* getPlugById( PlugVector& plugs,
142                          Plug::EPlugDirection plugDireciton,
143                          int id );
144     PlugVector getPlugsByType( PlugVector& plugs,
145                  Plug::EPlugDirection plugDirection,
146                  Plug::EPlugType type);
147
148 //     bool setSamplingFrequencyPlug( Plug& plug,
149 //                                    Plug::EPlugDirection direction,
150 //                                    ESamplingFrequency samplingFrequency );
151
152     void showPlugs( PlugVector& plugs ) const;
153
154
155     bool serializeSyncInfoVector( std::string basePath,
156                                   Util::IOSerialize& ser,
157                                   const SyncInfoVector& vec ) const;
158     bool deserializeSyncInfoVector( std::string basePath,
159                                     Util::IODeserialize& deser,
160                                     SyncInfoVector& vec );
161 protected:
162     SubunitVector             m_subunits;
163     PlugVector                m_pcrPlugs;
164     PlugVector                m_externalPlugs;
165     PlugConnectionVector      m_plugConnections;
166     PlugManager*              m_pPlugManager;
167     SyncInfoVector            m_syncInfos;
168
169 private:
170     DECLARE_DEBUG_MODULE;
171
172 };
173
174 }
175
176 #endif
Note: See TracBrowser for help on using the browser.