1 |
/* |
---|
2 |
* Copyright (C) 2005-2007 by Pieter Palmers |
---|
3 |
* Copyright (C) 2005-2007 by Jonathan Woithe |
---|
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 library is free software; you can redistribute it and/or |
---|
11 |
* modify it under the terms of the GNU Lesser General Public |
---|
12 |
* License version 2.1, as published by the Free Software Foundation; |
---|
13 |
* |
---|
14 |
* This library 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 GNU |
---|
17 |
* Lesser General Public License for more details. |
---|
18 |
* |
---|
19 |
* You should have received a copy of the GNU Lesser General Public |
---|
20 |
* License along with this library; if not, write to the Free Software |
---|
21 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
---|
22 |
* MA 02110-1301 USA |
---|
23 |
*/ |
---|
24 |
|
---|
25 |
#ifndef MOTUDEVICE_H |
---|
26 |
#define MOTUDEVICE_H |
---|
27 |
|
---|
28 |
#include "ffadodevice.h" |
---|
29 |
|
---|
30 |
#include "debugmodule/debugmodule.h" |
---|
31 |
#include "libavc/avc_definitions.h" |
---|
32 |
|
---|
33 |
#include "libstreaming/MotuStreamProcessor.h" |
---|
34 |
|
---|
35 |
#define MOTUFW_BASE_ADDR 0xfffff0000000ULL |
---|
36 |
|
---|
37 |
#define MOTUFW_RATE_BASE_44100 (0<<3) |
---|
38 |
#define MOTUFW_RATE_BASE_48000 (1<<3) |
---|
39 |
#define MOTUFW_RATE_MULTIPLIER_1X (0<<4) |
---|
40 |
#define MOTUFW_RATE_MULTIPLIER_2X (1<<4) |
---|
41 |
#define MOTUFW_RATE_MULTIPLIER_4X (2<<4) |
---|
42 |
#define MOTUFW_RATE_BASE_MASK (0x00000008) |
---|
43 |
#define MOTUFW_RATE_MULTIPLIER_MASK (0x00000030) |
---|
44 |
|
---|
45 |
#define MOTUFW_OPTICAL_MODE_OFF 0x00 |
---|
46 |
#define MOTUFW_OPTICAL_MODE_ADAT 0x01 |
---|
47 |
#define MOTUFW_OPTICAL_MODE_TOSLINK 0x02 |
---|
48 |
#define MOTUFW_OPTICAL_IN_MODE_MASK (0x00000300) |
---|
49 |
#define MOTUFW_OPTICAL_OUT_MODE_MASK (0x00000c00) |
---|
50 |
#define MOTUFW_OPTICAL_MODE_MASK (MOTUFW_OPTICAL_IN_MODE_MASK|MOTUFW_OPTICAL_MODE_MASK) |
---|
51 |
|
---|
52 |
#define MOTUFW_CLKSRC_MASK 0x00000007 |
---|
53 |
#define MOTUFW_CLKSRC_INTERNAL 0 |
---|
54 |
#define MOTUFW_CLKSRC_ADAT_OPTICAL 1 |
---|
55 |
#define MOTUFW_CLKSRC_SPDIF_TOSLINK 2 |
---|
56 |
#define MOTUFW_CLKSRC_SMTPE 3 |
---|
57 |
#define MOTUFW_CLKSRC_WORDCLOCK 4 |
---|
58 |
#define MOTUFW_CLKSRC_ADAT_9PIN 5 |
---|
59 |
#define MOTUFW_CLKSRC_AES_EBU 7 |
---|
60 |
|
---|
61 |
#define MOTUFW_DIR_IN 1 |
---|
62 |
#define MOTUFW_DIR_OUT 2 |
---|
63 |
#define MOTUFW_DIR_INOUT (MOTUFW_DIR_IN | MOTUFW_DIR_OUT) |
---|
64 |
|
---|
65 |
/* Device registers */ |
---|
66 |
#define MOTUFW_REG_ISOCTRL 0x0b00 |
---|
67 |
#define MOTUFW_REG_OPTICAL_CTRL 0x0b10 |
---|
68 |
#define MOTUFW_REG_CLK_CTRL 0x0b14 |
---|
69 |
#define MOTUFW_REG_ROUTE_PORT_CONF 0x0c04 |
---|
70 |
#define MOTUFW_REG_CLKSRC_NAME0 0x0c60 |
---|
71 |
|
---|
72 |
/* Port Active Flags (ports declaration) */ |
---|
73 |
#define MOTUFW_PA_RATE_1x 0x0001 /* 44k1 or 48k */ |
---|
74 |
#define MOTUFW_PA_RATE_2x 0x0002 /* 88k2 or 96k */ |
---|
75 |
#define MOTUFW_PA_RATE_4x 0x0004 /* 176k4 or 192k */ |
---|
76 |
#define MOTUFW_PA_RATE_1x2x (MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x) |
---|
77 |
#define MOTUFW_PA_RATE_ANY (MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x|MOTUFW_PA_RATE_4x) |
---|
78 |
#define MOTUFW_PA_RATE_MASK MOTUFW_PA_RATE_ANY |
---|
79 |
#define MOTUFW_PA_OPTICAL_OFF 0x0010 /* Optical port off */ |
---|
80 |
#define MOTUFW_PA_OPTICAL_ADAT 0x0020 /* Optical port in ADAT mode */ |
---|
81 |
#define MOTUFW_PA_OPTICAL_TOSLINK 0x0040 /* Optical port in SPDIF/Toslink mode */ |
---|
82 |
#define MOTUFW_PA_OPTICAL_ON (MOTUFW_PA_OPTICAL_ADAT|MOTUFW_PA_OPTICAL_TOSLINK) |
---|
83 |
#define MOTUFW_PA_OPTICAL_ANY (MOTUFW_PA_OPTICAL_OFF|MOTUFW_PA_OPTICAL_ON) |
---|
84 |
#define MOTUFW_PA_OPTICAL_MASK MOTUFW_PA_OPTICAL_ANY |
---|
85 |
|
---|
86 |
class ConfigRom; |
---|
87 |
class Ieee1394Service; |
---|
88 |
|
---|
89 |
namespace Motu { |
---|
90 |
|
---|
91 |
enum EMotuModel { |
---|
92 |
MOTUFW_MODEL_NONE = 0x0000, |
---|
93 |
MOTUFW_MODEL_828mkII = 0x0001, |
---|
94 |
MOTUFW_MODEL_TRAVELER = 0x0002, |
---|
95 |
}; |
---|
96 |
|
---|
97 |
struct VendorModelEntry { |
---|
98 |
unsigned int vendor_id; |
---|
99 |
unsigned int model_id; |
---|
100 |
unsigned int unit_version; |
---|
101 |
unsigned int unit_specifier_id; |
---|
102 |
enum EMotuModel model; |
---|
103 |
char *vendor_name; |
---|
104 |
char *model_name; |
---|
105 |
}; |
---|
106 |
|
---|
107 |
struct PortEntry { |
---|
108 |
char *port_name; |
---|
109 |
unsigned int port_dir; |
---|
110 |
unsigned int port_flags; |
---|
111 |
unsigned int port_offset; |
---|
112 |
}; |
---|
113 |
|
---|
114 |
struct DevicePortsEntry { |
---|
115 |
const PortEntry* PortsList; |
---|
116 |
int PortsListLength; |
---|
117 |
// Others features can be added here like MIDI port presence. |
---|
118 |
}; |
---|
119 |
|
---|
120 |
class MotuDevice : public FFADODevice { |
---|
121 |
public: |
---|
122 |
|
---|
123 |
MotuDevice( Ieee1394Service& ieee1394Service, |
---|
124 |
std::auto_ptr<ConfigRom>( configRom )); |
---|
125 |
virtual ~MotuDevice(); |
---|
126 |
|
---|
127 |
static bool probe( ConfigRom& configRom ); |
---|
128 |
static FFADODevice * createDevice( Ieee1394Service& ieee1394Service, |
---|
129 |
std::auto_ptr<ConfigRom>( configRom )); |
---|
130 |
static int getConfigurationId( ); |
---|
131 |
virtual bool discover(); |
---|
132 |
|
---|
133 |
virtual void showDevice(); |
---|
134 |
|
---|
135 |
virtual bool setSamplingFrequency( int samplingFrequency ); |
---|
136 |
virtual int getSamplingFrequency( ); |
---|
137 |
|
---|
138 |
virtual ClockSourceVector getSupportedClockSources(); |
---|
139 |
virtual bool setActiveClockSource(ClockSource); |
---|
140 |
virtual ClockSource getActiveClockSource(); |
---|
141 |
|
---|
142 |
virtual int getStreamCount(); |
---|
143 |
virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i); |
---|
144 |
|
---|
145 |
virtual bool prepare(); |
---|
146 |
virtual bool lock(); |
---|
147 |
virtual bool unlock(); |
---|
148 |
|
---|
149 |
virtual bool startStreamByIndex(int i); |
---|
150 |
virtual bool stopStreamByIndex(int i); |
---|
151 |
|
---|
152 |
signed int getIsoRecvChannel(void); |
---|
153 |
signed int getIsoSendChannel(void); |
---|
154 |
unsigned int getOpticalMode(unsigned int dir); |
---|
155 |
signed int setOpticalMode(unsigned int dir, unsigned int mode); |
---|
156 |
|
---|
157 |
signed int getEventSize(unsigned int dir); |
---|
158 |
|
---|
159 |
protected: |
---|
160 |
signed int m_motu_model; |
---|
161 |
struct VendorModelEntry * m_model; |
---|
162 |
signed int m_iso_recv_channel, m_iso_send_channel; |
---|
163 |
signed int m_bandwidth; |
---|
164 |
|
---|
165 |
Streaming::MotuReceiveStreamProcessor *m_receiveProcessor; |
---|
166 |
Streaming::MotuTransmitStreamProcessor *m_transmitProcessor; |
---|
167 |
|
---|
168 |
private: |
---|
169 |
bool addPort(Streaming::StreamProcessor *s_processor, |
---|
170 |
char *name, |
---|
171 |
enum Streaming::Port::E_Direction direction, |
---|
172 |
int position, int size); |
---|
173 |
bool addDirPorts( |
---|
174 |
enum Streaming::Port::E_Direction direction, |
---|
175 |
unsigned int sample_rate, unsigned int optical_mode); |
---|
176 |
|
---|
177 |
unsigned int ReadRegister(unsigned int reg); |
---|
178 |
signed int WriteRegister(unsigned int reg, quadlet_t data); |
---|
179 |
|
---|
180 |
}; |
---|
181 |
|
---|
182 |
} |
---|
183 |
|
---|
184 |
#endif |
---|