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

Revision 435, 4.3 kB (checked in by pieterpalmers, 15 years ago)

src/devicemanager:
- start OSC server for the device manager

src/devicemanager,
src/iavdevice,
src/libieee1394/configrom:
- inherit from OscNode? to become Osc'able

src/bounce,
src/libstreaming/AmdtpStreamProcessor,
src/libstreaming/AmdtpSlaveStreamProcessor:
- fixed bounce device implementation, now working

src/bebob:
- fixed midi bug

General:
- removed 'intermediate XML'
- removed obsolete tests
- removed obsolete files
- removed obsolete API calls

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 "libavc/avc_definitions.h"
29
30 #include "libstreaming/MotuStreamProcessor.h"
31
32 #define MOTUFW_BASE_ADDR                0xfffff0000000ULL
33
34 #define MOTUFW_RATE_BASE_44100          (0<<3)
35 #define MOTUFW_RATE_BASE_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_RATE_BASE_MASK           (0x00000008)
40 #define MOTUFW_RATE_MULTIPLIER_MASK     (0x00000030)
41
42 #define MOTUFW_OPTICAL_MODE_OFF         0x00
43 #define MOTUFW_OPTICAL_MODE_ADAT        0x01
44 #define MOTUFW_OPTICAL_MODE_TOSLINK     0x02
45 #define MOTUFW_OPTICAL_IN_MODE_MASK     (0x00000300)
46 #define MOTUFW_OPTICAL_OUT_MODE_MASK    (0x00000c00)
47 #define MOTUFW_OPTICAL_MODE_MASK        (MOTUFW_OPTICAL_IN_MODE_MASK|MOTUFW_OPTICAL_MODE_MASK)
48
49 #define MOTUFW_CLKSRC_MASK              0x00000007
50 #define MOTUFW_CLKSRC_INTERNAL          0
51 #define MOTUFW_CLKSRC_ADAT_OPTICAL      1
52 #define MOTUFW_CLKSRC_SPDIF_TOSLINK     2
53 #define MOTUFW_CLKSRC_SMTPE             3
54 #define MOTUFW_CLKSRC_WORDCLOCK         4
55 #define MOTUFW_CLKSRC_ADAT_9PIN         5
56 #define MOTUFW_CLKSRC_AES_EBU           7
57
58 #define MOTUFW_DIR_IN                   1
59 #define MOTUFW_DIR_OUT                  2
60 #define MOTUFW_DIR_INOUT                (MOTUFW_DIR_IN | MOTUFW_DIR_OUT)
61
62 /* Device registers */
63 #define MOTUFW_REG_ISOCTRL              0x0b00
64 #define MOTUFW_REG_OPTICAL_CTRL         0x0b10
65 #define MOTUFW_REG_CLK_CTRL             0x0b14
66 #define MOTUFW_REG_ROUTE_PORT_CONF      0x0c04
67 #define MOTUFW_REG_CLKSRC_NAME0         0x0c60
68
69 class ConfigRom;
70 class Ieee1394Service;
71
72 namespace Motu {
73
74 enum EMotuModel {
75       MOTUFW_MODEL_NONE     = 0x0000,
76       MOTUFW_MODEL_828mkII  = 0x0001,
77       MOTUFW_MODEL_TRAVELER = 0x0002,
78 };
79
80 struct VendorModelEntry {
81     unsigned int vendor_id;
82     unsigned int model_id;
83     unsigned int unit_version;
84     unsigned int unit_specifier_id;
85     enum EMotuModel model;
86     char *vendor_name;
87     char *model_name;
88 };
89
90 class MotuDevice : public IAvDevice {
91 public:
92
93     MotuDevice( std::auto_ptr<ConfigRom>( configRom ),
94           Ieee1394Service& ieee1394Service,
95                   int nodeId );
96     virtual ~MotuDevice();
97
98     static bool probe( ConfigRom& configRom );
99     virtual bool discover();
100
101     virtual void showDevice() const;
102
103     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
104     virtual int getSamplingFrequency( );
105
106     virtual int getStreamCount();
107     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
108
109     virtual bool prepare();
110     bool lock();
111     bool unlock();
112    
113     bool startStreamByIndex(int i);
114     bool stopStreamByIndex(int i);
115
116     signed int getIsoRecvChannel(void);
117     signed int getIsoSendChannel(void);
118     unsigned int getOpticalMode(unsigned int dir);
119     signed int setOpticalMode(unsigned int dir, unsigned int mode);
120
121     signed int getEventSize(unsigned int dir);
122  
123 protected:
124     signed int       m_motu_model;
125     struct VendorModelEntry * m_model;
126     signed int m_iso_recv_channel, m_iso_send_channel;
127     signed int m_bandwidth;
128    
129         Streaming::MotuReceiveStreamProcessor *m_receiveProcessor;
130         Streaming::MotuTransmitStreamProcessor *m_transmitProcessor;
131
132 private:
133         bool addPort(Streaming::StreamProcessor *s_processor,
134                 char *name,
135                 enum Streaming::Port::E_Direction direction,
136                 int position, int size);
137         bool addDirPorts(
138                 enum Streaming::Port::E_Direction direction,
139                 unsigned int sample_rate, unsigned int optical_mode);
140        
141         unsigned int ReadRegister(unsigned int reg);
142         signed int WriteRegister(unsigned int reg, quadlet_t data);
143
144 };
145
146 }
147
148 #endif
Note: See TracBrowser for help on using the browser.