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() const |
---|
91 |
{ return m_activeSyncInfo; } |
---|
92 |
|
---|
93 |
virtual bool setActiveSync( const SyncInfo& syncInfo ); |
---|
94 |
|
---|
95 |
virtual bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; |
---|
96 |
virtual bool deserialize( Glib::ustring basePath, Util::IODeserialize& deser ); |
---|
97 |
|
---|
98 |
SubunitAudio* getAudioSubunit( subunit_id_t subunitId ) |
---|
99 |
{ return dynamic_cast<SubunitAudio*>( |
---|
100 |
getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));}; |
---|
101 |
SubunitMusic* getMusicSubunit( subunit_id_t subunitId ) |
---|
102 |
{ return dynamic_cast<SubunitMusic*>( |
---|
103 |
getSubunit( AVC1394_SUBUNIT_MUSIC , subunitId ));}; |
---|
104 |
Subunit* getSubunit( subunit_type_t subunitType, |
---|
105 |
subunit_id_t subunitId ) const; |
---|
106 |
|
---|
107 |
virtual AVC::Subunit* createSubunit(Unit& unit, |
---|
108 |
ESubunitType type, |
---|
109 |
subunit_t id ); |
---|
110 |
virtual AVC::Plug* createPlug( AVC::Unit* unit, |
---|
111 |
AVC::Subunit* subunit, |
---|
112 |
AVC::function_block_type_t functionBlockType, |
---|
113 |
AVC::function_block_type_t functionBlockId, |
---|
114 |
AVC::Plug::EPlugAddressType plugAddressType, |
---|
115 |
AVC::Plug::EPlugDirection plugDirection, |
---|
116 |
AVC::plug_id_t plugId ); |
---|
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 discoverPlugConnections(); |
---|
124 |
virtual bool discoverSubUnitsPlugConnections(); |
---|
125 |
virtual bool discoverPlugs(); |
---|
126 |
virtual bool discoverPlugsPCR( AVC::Plug::EPlugDirection plugDirection, |
---|
127 |
AVC::plug_id_t plugMaxId ); |
---|
128 |
virtual bool discoverPlugsExternal( AVC::Plug::EPlugDirection plugDirection, |
---|
129 |
AVC::plug_id_t plugMaxId ); |
---|
130 |
virtual bool propagatePlugInfo(); |
---|
131 |
virtual bool discoverSyncModes(); |
---|
132 |
virtual bool checkSyncConnectionsAndAddToList( AVC::PlugVector& plhs, |
---|
133 |
AVC::PlugVector& prhs, |
---|
134 |
std::string syncDescription ); |
---|
135 |
virtual Plug* getSyncPlug( int maxPlugId, Plug::EPlugDirection ); |
---|
136 |
|
---|
137 |
unsigned int getNrOfSubunits( subunit_type_t subunitType ) const; |
---|
138 |
PlugConnection* getPlugConnection( Plug& srcPlug ) const; |
---|
139 |
|
---|
140 |
Plug* getPlugById( PlugVector& plugs, |
---|
141 |
Plug::EPlugDirection plugDireciton, |
---|
142 |
int id ); |
---|
143 |
PlugVector getPlugsByType( PlugVector& plugs, |
---|
144 |
Plug::EPlugDirection plugDirection, |
---|
145 |
Plug::EPlugType type); |
---|
146 |
|
---|
147 |
// bool setSamplingFrequencyPlug( Plug& plug, |
---|
148 |
// Plug::EPlugDirection direction, |
---|
149 |
// ESamplingFrequency samplingFrequency ); |
---|
150 |
|
---|
151 |
void showPlugs( PlugVector& plugs ) const; |
---|
152 |
|
---|
153 |
|
---|
154 |
bool serializeSyncInfoVector( Glib::ustring basePath, |
---|
155 |
Util::IOSerialize& ser, |
---|
156 |
const SyncInfoVector& vec ) const; |
---|
157 |
bool deserializeSyncInfoVector( Glib::ustring basePath, |
---|
158 |
Util::IODeserialize& deser, |
---|
159 |
SyncInfoVector& vec ); |
---|
160 |
protected: |
---|
161 |
SubunitVector m_subunits; |
---|
162 |
PlugVector m_pcrPlugs; |
---|
163 |
PlugVector m_externalPlugs; |
---|
164 |
PlugConnectionVector m_plugConnections; |
---|
165 |
PlugManager* m_pPlugManager; |
---|
166 |
SyncInfoVector m_syncInfos; |
---|
167 |
SyncInfo* m_activeSyncInfo; |
---|
168 |
|
---|
169 |
private: |
---|
170 |
DECLARE_DEBUG_MODULE; |
---|
171 |
|
---|
172 |
}; |
---|
173 |
|
---|
174 |
} |
---|
175 |
|
---|
176 |
#endif |
---|