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

Revision 300, 4.2 kB (checked in by jwoithe, 16 years ago)

Major cleanup of MOTU streaming code.
Fine-tuned the DLL used for iso transmission timestamping.
Tweaked MOTU shutdown to avoid long delays if streaming isn't operational; this means that xrun recovery nearly always works now.

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