root/branches/ppalmers-streaming/src/dice/dice_avdevice.h

Revision 705, 6.2 kB (checked in by ppalmers, 15 years ago)

restructure the streaming directory

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