root/branches/libfreebob-2.0/src/motu/motu_avdevice.h

Revision 302, 4.6 kB (checked in by jwoithe, 16 years ago)

jack driver: call detach() from finish() if detach() hasn't yet been called. This works around the fact that jack doesn't call detach() on close at this stage. Once this is fixed in jack the workaround can be removed.
C streaming API: set sample rate before device initialisation. This permits jackd to set the sample rate to that requested on the command line when starting jackd.
Motu device: start adding details to setSamplingFrequency() beyond that required for basic functionality.

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 #ifndef MOTUDEVICE_H
23 #define MOTUDEVICE_H
24
25 #include "iavdevice.h"
26
27 #include "debugmodule/debugmodule.h"
28 #include "libfreebobavc/avc_definitions.h"
29 #include "libfreebob/xmlparser.h"
30
31 #include "libstreaming/MotuStreamProcessor.h"
32
33 #define MOTUFW_BASE_ADDR                0xfffff0000000ULL
34
35 #define MOTUFW_RATE_BASE_44100          (0<<3)
36 #define MOTUFW_RATE_BASE_48000          (1<<3)
37 #define MOTUFW_RATE_MULTIPLIER_1X       (0<<4)
38 #define MOTUFW_RATE_MULTIPLIER_2X       (1<<4)
39 #define MOTUFW_RATE_MULTIPLIER_4X       (2<<4)
40 #define MOTUFW_RATE_BASE_MASK           (0x00000008)
41 #define MOTUFW_RATE_MULTIPLIER_MASK     (0x00000030)
42
43 #define MOTUFW_OPTICAL_MODE_OFF         (0<<8)
44 #define MOTUFW_OPTICAL_MODE_ADAT        (1<<8)
45 #define MOTUFW_OPTICAL_MODE_TOSLINK     (2<<8)
46 #define MOTUFW_OPTICAL_MODE_MASK        (0x00000300)
47
48 #define MOTUFW_CLKSRC_MASK              0x00000007
49 #define MOTUFW_CLKSRC_INTERNAL          0
50 #define MOTUFW_CLKSRC_ADAT_OPTICAL      1
51 #define MOTUFW_CLKSRC_SPDIF_TOSLINK     2
52 #define MOTUFW_CLKSRC_SMTPE             3
53 #define MOTUFW_CLKSRC_WORDCLOCK         4
54 #define MOTUFW_CLKSRC_ADAT_9PIN         5
55 #define MOTUFW_CLKSRC_AES_EBU           7
56
57 /* Device registers */
58 #define MOTUFW_REG_ISOCTRL              0x0b00
59 #define MOTUFW_REG_RATECTRL             0x0b14
60 #define MOTUFW_REG_ROUTE_PORT_CONF      0x0c04
61 #define MOTUFW_REG_CLKSRC_NAME0         0x0c60
62
63 class ConfigRom;
64 class Ieee1394Service;
65
66 namespace Motu {
67
68 class MotuDevice : public IAvDevice {
69 public:
70     enum EMotuModel {
71       MOTUFW_MODEL_NONE     = 0x0000,
72       MOTUFW_MODEL_828mkII  = 0x0001,
73       MOTUFW_MODEL_TRAVELER = 0x0002,
74     };
75
76     MotuDevice( Ieee1394Service& ieee1394Service,
77                   int nodeId,
78                   int verboseLevel );
79     virtual ~MotuDevice();
80
81     virtual bool discover();
82     virtual ConfigRom& getConfigRom() const;
83
84     // obsolete, will be removed soon, unused
85     virtual bool addXmlDescription( xmlNodePtr deviceNode ) {return true;};
86
87     virtual void showDevice() const;
88
89     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
90     virtual int getSamplingFrequency( );
91
92     virtual bool setId(unsigned int id);
93
94     virtual int getStreamCount();
95     virtual FreebobStreaming::StreamProcessor *getStreamProcessorByIndex(int i);
96
97     virtual bool prepare();
98
99     virtual int startStreamByIndex(int i);
100     virtual int stopStreamByIndex(int i);
101
102     signed int getIsoRecvChannel(void);
103     signed int getIsoSendChannel(void);
104     unsigned int getOpticalMode(void);
105     signed int setOpticalMode(unsigned int mode);
106
107     signed int getEventSize(void);
108  
109 protected:
110     Ieee1394Service* m_1394Service;
111     ConfigRom*       m_configRom;
112     signed int       m_motu_model;
113     int              m_nodeId;
114     int              m_verboseLevel;
115     signed int m_id;
116     signed int m_iso_recv_channel, m_iso_send_channel;
117     signed int m_bandwidth;
118    
119         FreebobStreaming::MotuReceiveStreamProcessor *m_receiveProcessor;
120         FreebobStreaming::MotuTransmitStreamProcessor *m_transmitProcessor;
121
122 private:
123         bool addPort(FreebobStreaming::StreamProcessor *s_processor,
124                 char *name,
125                 enum FreebobStreaming::Port::E_Direction direction,
126                 int position, int size);
127         bool MotuDevice::addDirPorts(
128                 enum FreebobStreaming::Port::E_Direction direction,
129                 unsigned int sample_rate, unsigned int optical_mode);
130        
131         unsigned int ReadRegister(unsigned int reg);
132         signed int WriteRegister(unsigned int reg, quadlet_t data);
133
134         // IEEE1394 Vendor IDs.  One would expect only MOTU, but you never
135         // know if a clone might appear some day.
136         enum EVendorId {
137                 MOTUFW_VENDOR_MOTU = 0x000001f2,
138         };
139        
140         // IEEE1394 Unit directory version IDs for different MOTU hardware
141         enum EUnitVersionId {
142                 MOTUFW_UNITVER_828mkII  = 0x00000003,
143                 MOTUFW_UNITVER_TRAVELER = 0x00000009,
144         };
145
146     // debug support
147     DECLARE_DEBUG_MODULE;
148 };
149
150 }
151
152 #endif
Note: See TracBrowser for help on using the browser.