root/trunk/libffado/src/dice/dice_avdevice.h

Revision 2057, 7.6 kB (checked in by adi, 11 years ago)

DICE-EAP: Get Capture/Playback names when EAP router is present.

When a router is available, Capture/Playback, i.e. inputs/outputs for
jack, are related to the corresponding entries in the router table.
When no router is available (no initialized router or no initialized
EAP) Capture/Playback are receivers/transmitters respectively.

Patch by Philippe Carriere

Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
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 2 of the License, or
12  * (at your option) version 3 of the License.
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 DICEDEVICE_H
25 #define DICEDEVICE_H
26
27 #include "ffadotypes.h"
28 #include "ffadodevice.h"
29
30 #include "debugmodule/debugmodule.h"
31 #include "libavc/avc_definitions.h"
32
33 #include "libstreaming/amdtp/AmdtpReceiveStreamProcessor.h"
34 #include "libstreaming/amdtp/AmdtpTransmitStreamProcessor.h"
35 #include "libstreaming/amdtp/AmdtpPort.h"
36
37 #include "libieee1394/ieee1394service.h"
38
39 #include "libcontrol/Element.h"
40 #include "libcontrol/MatrixMixer.h"
41 #include "libcontrol/CrossbarRouter.h"
42
43 #include <string>
44 #include <vector>
45
46 class ConfigRom;
47 class Ieee1394Service;
48
49 namespace Util {
50     class Configuration;
51 }
52
53 namespace Dice {
54
55 class EAP;
56
57
58 /**
59   @brief Devices based on the DICE-platform
60
61   This class is the basic implementation for devices using the DICE-chip.
62   */
63 class Device : public FFADODevice {
64 private:
65     friend class EAP;
66
67 public:
68     /// constructor
69     Device( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ));
70     /// destructor
71     ~Device();
72
73     static bool probe( Util::Configuration& c, ConfigRom& configRom, bool generic = false );
74     static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ));
75     virtual bool discover();
76
77     static int getConfigurationId( );
78
79     virtual void showDevice();
80
81     virtual bool setSamplingFrequency( int samplingFrequency );
82     virtual int getSamplingFrequency( );
83     virtual std::vector<int> getSupportedSamplingFrequencies();
84
85     virtual ClockSourceVector getSupportedClockSources();
86     virtual bool setActiveClockSource(ClockSource);
87     virtual ClockSource getActiveClockSource();
88
89     virtual int getStreamCount();
90     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
91
92     virtual bool prepare();
93
94     virtual bool lock();
95     virtual bool unlock();
96
97     virtual bool startStreamByIndex(int i);
98     virtual bool stopStreamByIndex(int i);
99
100     virtual bool enableStreaming();
101     virtual bool disableStreaming();
102
103     virtual std::string getNickname();
104     virtual bool setNickname(std::string name);
105
106 protected:
107     // streaming stuff
108     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
109     typedef std::vector< Streaming::StreamProcessor * >::iterator StreamProcessorVectorIterator;
110     StreamProcessorVector m_receiveProcessors;
111     StreamProcessorVector m_transmitProcessors;
112
113 private: // streaming & port helpers
114     enum EPortTypes {
115         ePT_Analog,
116         ePT_MIDI,
117     };
118
119     typedef struct {
120         std::string name;
121         enum EPortTypes portType;
122         unsigned int streamPosition;
123         unsigned int streamLocation;
124     } diceChannelInfo;
125
126     bool addChannelToProcessor( diceChannelInfo *,
127                               Streaming::StreamProcessor *,
128                               Streaming::Port::E_Direction direction);
129
130     int allocateIsoChannel(unsigned int packet_size);
131     bool deallocateIsoChannel(int channel);
132
133 private: // active config
134     enum eDiceConfig {
135         eDC_Unknown,
136         eDC_Low,
137         eDC_Mid,
138         eDC_High,
139     };
140
141     enum eDiceConfig getCurrentConfig();
142
143 private: // helper functions
144     bool enableIsoStreaming();
145     bool disableIsoStreaming();
146     bool isIsoStreamingEnabled();
147
148     bool maskedCheckZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask);
149     bool maskedCheckNotZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask);
150
151     stringlist splitNameString(std::string in);
152     stringlist getTxNameString(unsigned int i);
153     stringlist getRxNameString(unsigned int i);
154     stringlist getCptrNameString(unsigned int);
155     stringlist getPbckNameString(unsigned int);
156     stringlist getClockSourceNameString();
157
158     enum eClockSourceType  clockIdToType(unsigned int id);
159     bool isClockSourceIdLocked(unsigned int id, quadlet_t ext_status_reg);
160     bool isClockSourceIdSlipping(unsigned int id, quadlet_t ext_status_reg);
161
162 // EAP stuff
163 private:
164     EAP*         m_eap;
165 protected:
166     virtual EAP* createEAP();
167 public:
168     EAP* getEAP() {return m_eap;};
169
170 private: // register I/O routines
171     bool initIoFunctions();
172     // functions used for RX/TX abstraction
173     bool startstopStreamByIndex(int i, const bool start);
174     bool prepareSP (unsigned int, const Streaming::Port::E_Direction direction_requested);
175     void setRXTXfuncs (const Streaming::Port::E_Direction direction);
176     // quadlet read/write routines
177     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
178     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
179     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
180     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
181
182     bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *);
183     bool writeGlobalReg(fb_nodeaddr_t, fb_quadlet_t);
184     bool readGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
185     bool writeGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
186     fb_nodeaddr_t globalOffsetGen(fb_nodeaddr_t, size_t);
187
188     bool readTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *);
189     bool writeTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t);
190     bool readTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
191     bool writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
192     fb_nodeaddr_t txOffsetGen(unsigned int, fb_nodeaddr_t, size_t);
193
194     bool readRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *);
195     bool writeRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t);
196     bool readRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
197     bool writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
198     fb_nodeaddr_t rxOffsetGen(unsigned int, fb_nodeaddr_t, size_t);
199
200     fb_quadlet_t m_global_reg_offset;
201     fb_quadlet_t m_global_reg_size;
202     fb_quadlet_t m_tx_reg_offset;
203     fb_quadlet_t m_tx_reg_size;
204     fb_quadlet_t m_rx_reg_offset;
205     fb_quadlet_t m_rx_reg_size;
206     fb_quadlet_t m_unused1_reg_offset;
207     fb_quadlet_t m_unused1_reg_size;
208     fb_quadlet_t m_unused2_reg_offset;
209     fb_quadlet_t m_unused2_reg_size;
210
211     fb_quadlet_t m_nb_tx;
212     fb_quadlet_t m_tx_size;
213     fb_quadlet_t m_nb_rx;
214     fb_quadlet_t m_rx_size;
215
216     fb_quadlet_t audio_base_register;
217     fb_quadlet_t midi_base_register;
218     char dir[3];
219
220     // Function pointers to call readTxReg/readRxReg or writeTxReg/writeRxReg respectively
221     bool (Device::*writeFunc) (unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t data);
222     bool (Device::*readFunc) (unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *result);
223
224 // private:
225 public:
226     /**
227      * this class reacts on the DICE device writing to the
228      * hosts notify address
229      */
230     #define DICE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
231     #define DICE_NOTIFIER_BLOCK_LENGTH 4
232     class Notifier : public Ieee1394Service::ARMHandler
233     {
234     public:
235         Notifier(Device &, nodeaddr_t start);
236         virtual ~Notifier();
237
238     private:
239         Device &m_device;
240     };
241
242     // notification
243     Notifier *m_notifier;
244
245
246
247 };
248
249 }
250 // vim: et
251 #endif
Note: See TracBrowser for help on using the browser.