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

Revision 742, 6.0 kB (checked in by ppalmers, 13 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

Line 
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 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 3 of the License, or
13  * (at your option) any later version.
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 #define MOTUFW_BASE_ADDR                0xfffff0000000ULL
37
38 #define MOTUFW_RATE_BASE_44100          (0<<3)
39 #define MOTUFW_RATE_BASE_48000          (1<<3)
40 #define MOTUFW_RATE_MULTIPLIER_1X       (0<<4)
41 #define MOTUFW_RATE_MULTIPLIER_2X       (1<<4)
42 #define MOTUFW_RATE_MULTIPLIER_4X       (2<<4)
43 #define MOTUFW_RATE_BASE_MASK           (0x00000008)
44 #define MOTUFW_RATE_MULTIPLIER_MASK     (0x00000030)
45
46 #define MOTUFW_OPTICAL_MODE_OFF        0x00
47 #define MOTUFW_OPTICAL_MODE_ADAT    0x01
48 #define MOTUFW_OPTICAL_MODE_TOSLINK    0x02
49 #define MOTUFW_OPTICAL_IN_MODE_MASK    (0x00000300)
50 #define MOTUFW_OPTICAL_OUT_MODE_MASK    (0x00000c00)
51 #define MOTUFW_OPTICAL_MODE_MASK    (MOTUFW_OPTICAL_IN_MODE_MASK|MOTUFW_OPTICAL_MODE_MASK)
52
53 #define MOTUFW_CLKSRC_MASK        0x00000007
54 #define MOTUFW_CLKSRC_INTERNAL        0
55 #define MOTUFW_CLKSRC_ADAT_OPTICAL    1
56 #define MOTUFW_CLKSRC_SPDIF_TOSLINK    2
57 #define MOTUFW_CLKSRC_SMTPE        3
58 #define MOTUFW_CLKSRC_WORDCLOCK        4
59 #define MOTUFW_CLKSRC_ADAT_9PIN        5
60 #define MOTUFW_CLKSRC_AES_EBU        7
61
62 #define MOTUFW_DIR_IN            1
63 #define MOTUFW_DIR_OUT            2
64 #define MOTUFW_DIR_INOUT        (MOTUFW_DIR_IN | MOTUFW_DIR_OUT)
65
66 /* Device registers */
67 #define MOTUFW_REG_ISOCTRL        0x0b00
68 #define MOTUFW_REG_OPTICAL_CTRL        0x0b10
69 #define MOTUFW_REG_CLK_CTRL        0x0b14
70 #define MOTUFW_REG_ROUTE_PORT_CONF      0x0c04
71 #define MOTUFW_REG_CLKSRC_NAME0        0x0c60
72
73 /* Port Active Flags (ports declaration) */
74 #define MOTUFW_PA_RATE_1x          0x0001    /* 44k1 or 48k */
75 #define MOTUFW_PA_RATE_2x          0x0002    /* 88k2 or 96k */
76 #define MOTUFW_PA_RATE_4x          0x0004    /* 176k4 or 192k */
77 #define MOTUFW_PA_RATE_1x2x        (MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x)
78 #define MOTUFW_PA_RATE_ANY         (MOTUFW_PA_RATE_1x|MOTUFW_PA_RATE_2x|MOTUFW_PA_RATE_4x)
79 #define MOTUFW_PA_RATE_MASK        MOTUFW_PA_RATE_ANY
80 #define MOTUFW_PA_OPTICAL_OFF      0x0010    /* Optical port off */
81 #define MOTUFW_PA_OPTICAL_ADAT     0x0020    /* Optical port in ADAT mode */
82 #define MOTUFW_PA_OPTICAL_TOSLINK  0x0040    /* Optical port in SPDIF/Toslink mode */
83 #define MOTUFW_PA_OPTICAL_ON       (MOTUFW_PA_OPTICAL_ADAT|MOTUFW_PA_OPTICAL_TOSLINK)
84 #define MOTUFW_PA_OPTICAL_ANY      (MOTUFW_PA_OPTICAL_OFF|MOTUFW_PA_OPTICAL_ON)
85 #define MOTUFW_PA_OPTICAL_MASK     MOTUFW_PA_OPTICAL_ANY
86
87 class ConfigRom;
88 class Ieee1394Service;
89
90 namespace Motu {
91
92 enum EMotuModel {
93       MOTUFW_MODEL_NONE     = 0x0000,
94       MOTUFW_MODEL_828mkII  = 0x0001,
95       MOTUFW_MODEL_TRAVELER = 0x0002,
96       MOTUFW_MODEL_ULTRALITE= 0x0003,
97       MOTUFW_MODEL_8PRE     = 0x0004,
98 };
99
100 struct VendorModelEntry {
101     unsigned int vendor_id;
102     unsigned int model_id;
103     unsigned int unit_version;
104     unsigned int unit_specifier_id;
105     enum EMotuModel model;
106     char *vendor_name;
107     char *model_name;
108 };
109
110 struct PortEntry {
111     char *port_name;
112     unsigned int port_dir;
113     unsigned int port_flags;
114     unsigned int port_offset;
115 };
116
117 struct DevicePropertyEntry {
118     const PortEntry* PortsList;
119     int PortsListLength;
120     int MaxSampleRate;
121     // Others features can be added here like MIDI port presence.
122 };
123
124 class MotuDevice : public FFADODevice {
125 public:
126
127     MotuDevice(std::auto_ptr<ConfigRom>( configRom ));
128     virtual ~MotuDevice();
129
130     static bool probe( ConfigRom& configRom );
131     static FFADODevice * createDevice(std::auto_ptr<ConfigRom>( configRom ));
132     static int getConfigurationId( );
133     virtual bool discover();
134
135     virtual void showDevice();
136
137     virtual bool setSamplingFrequency( int samplingFrequency );
138     virtual int getSamplingFrequency( );
139
140     virtual ClockSourceVector getSupportedClockSources();
141     virtual bool setActiveClockSource(ClockSource);
142     virtual ClockSource getActiveClockSource();
143
144     virtual int getStreamCount();
145     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
146
147     virtual bool prepare();
148     virtual bool lock();
149     virtual bool unlock();
150
151     virtual bool startStreamByIndex(int i);
152     virtual bool stopStreamByIndex(int i);
153
154     signed int getIsoRecvChannel(void);
155     signed int getIsoSendChannel(void);
156     unsigned int getOpticalMode(unsigned int dir);
157     signed int setOpticalMode(unsigned int dir, unsigned int mode);
158
159     signed int getEventSize(unsigned int dir);
160
161 protected:
162     signed int       m_motu_model;
163     struct VendorModelEntry * m_model;
164     signed int m_iso_recv_channel, m_iso_send_channel;
165     signed int m_rx_bandwidth, m_tx_bandwidth;
166
167     Streaming::MotuReceiveStreamProcessor *m_receiveProcessor;
168     Streaming::MotuTransmitStreamProcessor *m_transmitProcessor;
169
170 private:
171     bool addPort(Streaming::StreamProcessor *s_processor,
172         char *name,
173         enum Streaming::Port::E_Direction direction,
174         int position, int size);
175     bool addDirPorts(
176         enum Streaming::Port::E_Direction direction,
177         unsigned int sample_rate, unsigned int optical_mode);
178
179     unsigned int ReadRegister(unsigned int reg);
180     signed int WriteRegister(unsigned int reg, quadlet_t data);
181
182 };
183
184 }
185
186 #endif
Note: See TracBrowser for help on using the browser.