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

Revision 739, 6.2 kB (checked in by ppalmers, 13 years ago)

- Adapt the ffado external API (upgrade to v3)

NEEDS NEW JACK BACKEND

- simplify FFADODevice constructor even more
- implement first framework support for supporting multiple adapters.

currently all firewire adapters are scanned for supported devices unless specified otherwise
however attaching devices to separate adapters is not supported. using multiple adapters at
that are connected together might work.

Line 
1 /*
2  * Copyright (C) 2005-2007 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 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 DICEDEVICE_H
25 #define DICEDEVICE_H
26
27 #include "ffadodevice.h"
28
29 #include "debugmodule/debugmodule.h"
30 #include "libavc/avc_definitions.h"
31
32 #include "libstreaming/amdtp/AmdtpReceiveStreamProcessor.h"
33 #include "libstreaming/amdtp/AmdtpTransmitStreamProcessor.h"
34 #include "libstreaming/amdtp/AmdtpPort.h"
35 #include "libieee1394/ARMHandler.h"
36
37 #include <string>
38 #include <vector>
39
40 class ConfigRom;
41 class Ieee1394Service;
42
43 namespace Dice {
44
45 class DiceNotifier;
46
47 // struct to define the supported devices
48 struct VendorModelEntry {
49     unsigned int vendor_id;
50     unsigned int model_id;
51     char *vendor_name;
52     char *model_name;
53 };
54
55 class DiceAvDevice : public FFADODevice {
56 private:
57     class DiceNotifier;
58 public:
59     DiceAvDevice( std::auto_ptr<ConfigRom>( configRom ));
60     ~DiceAvDevice();
61
62     static bool probe( ConfigRom& configRom );
63     static FFADODevice * createDevice( std::auto_ptr<ConfigRom>( configRom ));
64     virtual bool discover();
65
66     static int getConfigurationId( );
67
68     virtual void showDevice();
69
70     virtual bool setSamplingFrequency( int samplingFrequency );
71     virtual int getSamplingFrequency( );
72
73     virtual ClockSourceVector getSupportedClockSources();
74     virtual bool setActiveClockSource(ClockSource);
75     virtual ClockSource getActiveClockSource();
76
77     virtual int getStreamCount();
78     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
79
80     virtual bool prepare();
81
82     virtual bool lock();
83     virtual bool unlock();
84
85     virtual bool startStreamByIndex(int i);
86     virtual bool stopStreamByIndex(int i);
87
88     virtual bool enableStreaming();
89     virtual bool disableStreaming();
90
91 protected:
92     struct VendorModelEntry *m_model;
93
94     // streaming stuff
95     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
96     StreamProcessorVector m_receiveProcessors;
97     StreamProcessorVector m_transmitProcessors;
98
99 private: // streaming & port helpers
100     enum EPortTypes {
101         ePT_Analog,
102         ePT_MIDI,
103     };
104
105     typedef struct {
106         std::string name;
107         enum EPortTypes portType;
108         unsigned int streamPosition;
109         unsigned int streamLocation;
110     } diceChannelInfo;
111
112     bool addChannelToProcessor( diceChannelInfo *,
113                               Streaming::StreamProcessor *,
114                               Streaming::Port::E_Direction direction);
115
116     int allocateIsoChannel(unsigned int packet_size);
117     bool deallocateIsoChannel(int channel);
118
119 private: // helper functions
120     bool enableIsoStreaming();
121     bool disableIsoStreaming();
122     bool isIsoStreamingEnabled();
123
124     bool maskedCheckZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask);
125     bool maskedCheckNotZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask);
126
127     typedef std::vector< std::string > diceNameVector;
128     typedef std::vector< std::string >::iterator diceNameVectorIterator;
129     diceNameVector splitNameString(std::string in);
130     diceNameVector getTxNameString(unsigned int i);
131     diceNameVector getRxNameString(unsigned int i);
132     diceNameVector getClockSourceNameString();
133     std::string getDeviceNickName();
134
135 private: // register I/O routines
136     bool initIoFunctions();
137     // quadlet read/write routines
138     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
139     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
140     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
141     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
142
143     bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *);
144     bool writeGlobalReg(fb_nodeaddr_t, fb_quadlet_t);
145     bool readGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
146     bool writeGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
147     fb_nodeaddr_t globalOffsetGen(fb_nodeaddr_t, size_t);
148
149     bool readTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *);
150     bool writeTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t);
151     bool readTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
152     bool writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
153     fb_nodeaddr_t txOffsetGen(unsigned int, fb_nodeaddr_t, size_t);
154
155     bool readRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *);
156     bool writeRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t);
157     bool readRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
158     bool writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
159     fb_nodeaddr_t rxOffsetGen(unsigned int, fb_nodeaddr_t, size_t);
160
161     fb_quadlet_t m_global_reg_offset;
162     fb_quadlet_t m_global_reg_size;
163     fb_quadlet_t m_tx_reg_offset;
164     fb_quadlet_t m_tx_reg_size;
165     fb_quadlet_t m_rx_reg_offset;
166     fb_quadlet_t m_rx_reg_size;
167     fb_quadlet_t m_unused1_reg_offset;
168     fb_quadlet_t m_unused1_reg_size;
169     fb_quadlet_t m_unused2_reg_offset;
170     fb_quadlet_t m_unused2_reg_size;
171
172     fb_quadlet_t m_nb_tx;
173     fb_quadlet_t m_tx_size;
174     fb_quadlet_t m_nb_rx;
175     fb_quadlet_t m_rx_size;
176
177 private:
178     // notification
179     DiceNotifier *m_notifier;
180
181     /**
182      * this class reacts on the DICE device writing to the
183      * hosts notify address
184      */
185     #define DICE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
186     #define DICE_NOTIFIER_BLOCK_LENGTH 4
187     class DiceNotifier : public ARMHandler
188     {
189     public:
190         DiceNotifier(DiceAvDevice *, nodeaddr_t start);
191         virtual ~DiceNotifier();
192
193     private:
194         DiceAvDevice *m_dicedevice;
195     };
196 };
197
198 }
199 #endif
Note: See TracBrowser for help on using the browser.