root/branches/streaming-rework/src/motu/motu_avdevice.h

Revision 384, 5.0 kB (checked in by pieterpalmers, 16 years ago)

- temporary commit as backup measure
- rewrote synchronisation code
- receive streaming based on SYT works
- transmit streaming synced to received stream sort of works, still

have to iron out some issues.

NOTE: all devices but the bebob's are disabled in this code,

because they still have to be ported to the new sync
mechanism.

Line 
1 /* motu_avdevice.h
2  * Copyright (C) 2006 by Pieter Palmers
3  * Copyright (C) 2006 Jonathan Woithe
4  *
5  * This file is part of FreeBob.
6  *
7  * FreeBob is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  * FreeBob is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with FreeBob; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19  * MA 02111-1307 USA.
20  */
21
22 #ifdef ENABLE_MOTU
23
24 #ifndef MOTUDEVICE_H
25 #define MOTUDEVICE_H
26
27 #include "iavdevice.h"
28
29 #include "debugmodule/debugmodule.h"
30 #include "libfreebobavc/avc_definitions.h"
31 #include "libfreebob/xmlparser.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 class ConfigRom;
73 class Ieee1394Service;
74
75 namespace Motu {
76
77 class MotuDevice : public IAvDevice {
78 public:
79     enum EMotuModel {
80       MOTUFW_MODEL_NONE     = 0x0000,
81       MOTUFW_MODEL_828mkII  = 0x0001,
82       MOTUFW_MODEL_TRAVELER = 0x0002,
83     };
84
85     MotuDevice( std::auto_ptr<ConfigRom>( configRom ),
86           Ieee1394Service& ieee1394Service,
87                   int nodeId,
88                   int verboseLevel );
89     virtual ~MotuDevice();
90
91     static bool probe( ConfigRom& configRom );
92     virtual bool discover();
93     virtual ConfigRom& getConfigRom() const;
94
95     // obsolete, will be removed soon, unused
96     virtual bool addXmlDescription( xmlNodePtr deviceNode ) {return true;};
97
98     virtual void showDevice() const;
99
100     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
101     virtual int getSamplingFrequency( );
102
103     virtual bool setId(unsigned int id);
104
105     virtual int getStreamCount();
106     virtual FreebobStreaming::StreamProcessor *getStreamProcessorByIndex(int i);
107
108     virtual bool prepare();
109
110     virtual int startStreamByIndex(int i);
111     virtual int stopStreamByIndex(int i);
112
113     signed int getIsoRecvChannel(void);
114     signed int getIsoSendChannel(void);
115     unsigned int getOpticalMode(unsigned int dir);
116     signed int setOpticalMode(unsigned int dir, unsigned int mode);
117
118     signed int getEventSize(unsigned int dir);
119  
120 protected:
121     std::auto_ptr<ConfigRom>( m_configRom );
122     Ieee1394Service* m_1394Service;
123    
124     signed int       m_motu_model;
125     int              m_nodeId;
126     int              m_verboseLevel;
127     signed int m_id;
128     signed int m_iso_recv_channel, m_iso_send_channel;
129     signed int m_bandwidth;
130    
131         FreebobStreaming::MotuReceiveStreamProcessor *m_receiveProcessor;
132         FreebobStreaming::MotuTransmitStreamProcessor *m_transmitProcessor;
133
134 private:
135         bool addPort(FreebobStreaming::StreamProcessor *s_processor,
136                 char *name,
137                 enum FreebobStreaming::Port::E_Direction direction,
138                 int position, int size);
139         bool addDirPorts(
140                 enum FreebobStreaming::Port::E_Direction direction,
141                 unsigned int sample_rate, unsigned int optical_mode);
142        
143         unsigned int ReadRegister(unsigned int reg);
144         signed int WriteRegister(unsigned int reg, quadlet_t data);
145
146         // IEEE1394 Vendor IDs.  One would expect only MOTU, but you never
147         // know if a clone might appear some day.
148         enum EVendorId {
149                 MOTUFW_VENDOR_MOTU = 0x000001f2,
150         };
151        
152         // IEEE1394 Unit directory version IDs for different MOTU hardware
153         enum EUnitVersionId {
154                 MOTUFW_UNITVER_828mkII  = 0x00000003,
155                 MOTUFW_UNITVER_TRAVELER = 0x00000009,
156         };
157
158     // debug support
159     DECLARE_DEBUG_MODULE;
160 };
161
162 }
163
164 #endif
165
166 #endif // ENABLE_MOTU
Note: See TracBrowser for help on using the browser.