root/trunk/libffado/src/motu/motu_avdevice.h

Revision 1003, 6.6 kB (checked in by jwoithe, 16 years ago)

MOTU updates:

  • cleanup of "define" namespace. All MOTU-related defines now start with "MOTU_" rather than a mix of this and "MOTUFW_".
  • Significant cleanup of motu mixer UI definition and python code. Far less glue code is now needed.
  • Use generic binary switch control in mixer dbus interface where possibe.
  • Implement proof-of-concept input level/boost switches.
  • Provide mechanism to feed some device status back to the mixer application. Currently this is done only at startup but in time we'll need a way to poll for some of it as the mixer runs.
  • When streaming is active, disable controls whose operation is incompatible with an active streaming system.
  • Adapt active channels in the mixer to the current device state. The handling of optical input mode is still to be done.
  • Minor updates to MOTU protocol documentation.
  • Whitespace cleanup in mixer_motu.py for consistency with the "tab is 4 spaces" rule used elsewhere in FFADO's source code.
Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
3  * Copyright (C) 2005-2008 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 program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
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/motu/MotuReceiveStreamProcessor.h"
34 #include "libstreaming/motu/MotuTransmitStreamProcessor.h"
35
36 #include "motu_controls.h"
37
38 #define MOTU_BASE_ADDR               0xfffff0000000ULL
39
40 #define MOTU_RATE_BASE_44100         (0<<3)
41 #define MOTU_RATE_BASE_48000         (1<<3)
42 #define MOTU_RATE_MULTIPLIER_1X      (0<<4)
43 #define MOTU_RATE_MULTIPLIER_2X      (1<<4)
44 #define MOTU_RATE_MULTIPLIER_4X      (2<<4)
45 #define MOTU_RATE_BASE_MASK          (0x00000008)
46 #define MOTU_RATE_MULTIPLIER_MASK    (0x00000030)
47
48 #define MOTU_OPTICAL_MODE_OFF        0x00
49 #define MOTU_OPTICAL_MODE_ADAT       0x01
50 #define MOTU_OPTICAL_MODE_TOSLINK    0x02
51 #define MOTU_OPTICAL_IN_MODE_MASK    (0x00000300)
52 #define MOTU_OPTICAL_OUT_MODE_MASK   (0x00000c00)
53 #define MOTU_OPTICAL_MODE_MASK       (MOTU_OPTICAL_IN_MODE_MASK|MOTU_OPTICAL_MODE_MASK)
54
55 #define MOTU_CLKSRC_MASK             0x00000007
56 #define MOTU_CLKSRC_INTERNAL         0
57 #define MOTU_CLKSRC_ADAT_OPTICAL     1
58 #define MOTU_CLKSRC_SPDIF_TOSLINK    2
59 #define MOTU_CLKSRC_SMTPE            3
60 #define MOTU_CLKSRC_WORDCLOCK        4
61 #define MOTU_CLKSRC_ADAT_9PIN        5
62 #define MOTU_CLKSRC_AES_EBU          7
63
64 #define MOTU_DIR_IN          1
65 #define MOTU_DIR_OUT         2
66 #define MOTU_DIR_INOUT       (MOTU_DIR_IN | MOTU_DIR_OUT)
67
68 /* Device registers */
69 #define MOTU_REG_ISOCTRL         0x0b00
70 #define MOTU_REG_OPTICAL_CTRL    0x0b10
71 #define MOTU_REG_CLK_CTRL        0x0b14
72 #define MOTU_REG_ROUTE_PORT_CONF 0x0c04
73 #define MOTU_REG_INPUT_LEVEL     0x0c08
74 #define MOTU_REG_INPUT_BOOST     0x0c14
75 #define MOTU_REG_INPUT_GAIN_PAD  0x0c1c
76 #define MOTU_REG_CLKSRC_NAME0    0x0c60
77
78 /* Port Active Flags (ports declaration) */
79 #define MOTU_PA_RATE_1x          0x0001    /* 44k1 or 48k */
80 #define MOTU_PA_RATE_2x          0x0002    /* 88k2 or 96k */
81 #define MOTU_PA_RATE_4x          0x0004    /* 176k4 or 192k */
82 #define MOTU_PA_RATE_1x2x        (MOTU_PA_RATE_1x|MOTU_PA_RATE_2x)
83 #define MOTU_PA_RATE_ANY         (MOTU_PA_RATE_1x|MOTU_PA_RATE_2x|MOTU_PA_RATE_4x)
84 #define MOTU_PA_RATE_MASK        MOTU_PA_RATE_ANY
85 #define MOTU_PA_OPTICAL_OFF      0x0010    /* Optical port off */
86 #define MOTU_PA_OPTICAL_ADAT     0x0020    /* Optical port in ADAT mode */
87 #define MOTU_PA_OPTICAL_TOSLINK  0x0040    /* Optical port in SPDIF/Toslink mode */
88 #define MOTU_PA_OPTICAL_ON       (MOTU_PA_OPTICAL_ADAT|MOTU_PA_OPTICAL_TOSLINK)
89 #define MOTU_PA_OPTICAL_ANY      (MOTU_PA_OPTICAL_OFF|MOTU_PA_OPTICAL_ON)
90 #define MOTU_PA_OPTICAL_MASK     MOTU_PA_OPTICAL_ANY
91
92 class ConfigRom;
93 class Ieee1394Service;
94
95 namespace Motu {
96
97 enum EMotuModel {
98     MOTU_MODEL_NONE     = 0x0000,
99     MOTU_MODEL_828mkII  = 0x0001,
100     MOTU_MODEL_TRAVELER = 0x0002,
101     MOTU_MODEL_ULTRALITE= 0x0003,
102     MOTU_MODEL_8PRE     = 0x0004,
103     MOTU_MODEL_828MkI   = 0x0005,
104     MOTU_MODEL_896HD    = 0x0006,
105 };
106
107 struct VendorModelEntry {
108     unsigned int vendor_id;
109     unsigned int model_id;
110     unsigned int unit_version;
111     unsigned int unit_specifier_id;
112     enum EMotuModel model;
113     const char *vendor_name;
114     const char *model_name;
115 };
116
117 struct PortEntry {
118     const char *port_name;
119     unsigned int port_dir;
120     unsigned int port_flags;
121     unsigned int port_offset;
122 };
123
124 struct MixerCtrl {
125     const char *name, *label, *desc;
126     unsigned int type;
127     unsigned int dev_register;
128 };
129
130 struct DevicePropertyEntry {
131     const PortEntry* port_entry;
132     unsigned int n_port_entries;
133     signed int MaxSampleRate;
134     const MixerCtrl *mixer_ctrl;
135     unsigned int n_mixer_ctrls;
136     // Others features can be added here like MIDI port presence.
137 };
138
139 /* Macro to calculate the size of an array */
140 #define N_ELEMENTS(_array) (sizeof(_array) / sizeof((_array)[0]))
141
142 class MotuDevice : public FFADODevice {
143 public:
144
145     MotuDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) );
146     virtual ~MotuDevice();
147
148     virtual bool buildMixer();
149     virtual bool destroyMixer();
150
151     static bool probe( ConfigRom& configRom );
152     static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ));
153     static int getConfigurationId( );
154     virtual bool discover();
155
156     virtual void showDevice();
157
158     virtual bool setSamplingFrequency( int samplingFrequency );
159     virtual int getSamplingFrequency( );
160
161     virtual ClockSourceVector getSupportedClockSources();
162     virtual bool setActiveClockSource(ClockSource);
163     virtual ClockSource getActiveClockSource();
164
165     virtual int getStreamCount();
166     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
167
168     virtual bool prepare();
169     virtual bool lock();
170     virtual bool unlock();
171
172     virtual bool startStreamByIndex(int i);
173     virtual bool stopStreamByIndex(int i);
174
175     signed int getIsoRecvChannel(void);
176     signed int getIsoSendChannel(void);
177     unsigned int getOpticalMode(unsigned int dir);
178     signed int setOpticalMode(unsigned int dir, unsigned int mode);
179
180     signed int getEventSize(unsigned int dir);
181
182     signed int       m_motu_model;
183 protected:
184     struct VendorModelEntry * m_model;
185     signed int m_iso_recv_channel, m_iso_send_channel;
186     signed int m_rx_bandwidth, m_tx_bandwidth;
187
188     Streaming::MotuReceiveStreamProcessor *m_receiveProcessor;
189     Streaming::MotuTransmitStreamProcessor *m_transmitProcessor;
190
191 private:
192     bool addPort(Streaming::StreamProcessor *s_processor,
193         char *name,
194         enum Streaming::Port::E_Direction direction,
195         int position, int size);
196     bool addDirPorts(
197         enum Streaming::Port::E_Direction direction,
198         unsigned int sample_rate, unsigned int optical_mode);
199
200 public:
201     unsigned int ReadRegister(unsigned int reg);
202     signed int WriteRegister(unsigned int reg, quadlet_t data);
203
204 private:
205     Control::Container *m_MixerContainer;
206     Control::Container *m_ControlContainer;
207 };
208
209 }
210
211 #endif
Note: See TracBrowser for help on using the browser.