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