root/trunk/libffado/src/bounce/bounce_avdevice.h

Revision 734, 4.2 kB (checked in by ppalmers, 13 years ago)

merge ppalmers-streaming branch

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  * Copyright (C) 2005-2007 by Daniel Wagner
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 library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software Foundation;
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02110-1301 USA
23  */
24
25 #ifndef BOUNCEDEVICE_H
26 #define BOUNCEDEVICE_H
27
28 #include "debugmodule/debugmodule.h"
29 #include "libavc/avc_definitions.h"
30 #include "libavc/general/avc_extended_cmd_generic.h"
31
32 #include "libstreaming/amdtp/AmdtpReceiveStreamProcessor.h"
33 #include "libstreaming/amdtp/AmdtpTransmitStreamProcessor.h"
34 #include "libstreaming/amdtp/AmdtpPort.h"
35 #include "libstreaming/amdtp/AmdtpPortInfo.h"
36
37 #include "libieee1394/ARMHandler.h"
38
39 #include "ffadodevice.h"
40
41 #include <vector>
42
43 #define BOUNCE_REGISTER_BASE 0x0000FFFFE0000000ULL
44 #define BOUNCE_REGISTER_LENGTH (4*256)
45 #define BOUNCE_REGISTER_TX_ISOCHANNEL 0x10
46 #define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14
47 #define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL
48
49 #define BOUNCE_NB_AUDIO_CHANNELS 4
50
51 // don't define more than 8 midi channels!
52 #define BOUNCE_NB_MIDI_CHANNELS  2
53
54 class ConfigRom;
55 class Ieee1394Service;
56
57 namespace Bounce {
58
59 // struct to define the supported devices
60 struct VendorModelEntry {
61     uint32_t vendor_id;
62     uint32_t model_id;
63     uint32_t unit_specifier_id;
64     char *vendor_name;
65     char *model_name;
66 };
67
68 class BounceDevice : public FFADODevice {
69 private:
70     class BounceNotifier;
71 public:
72     BounceDevice( Ieee1394Service& ieee1394Service,
73                   std::auto_ptr<ConfigRom>( configRom ));
74     virtual ~BounceDevice();
75
76     static bool probe( ConfigRom& configRom );
77     static FFADODevice * createDevice( Ieee1394Service& ieee1394Service,
78                                         std::auto_ptr<ConfigRom>( configRom ));
79     static int getConfigurationId( );
80     virtual bool discover();
81
82     virtual bool setSamplingFrequency( int samplingFrequency );
83     virtual int getSamplingFrequency( );
84    
85     virtual ClockSourceVector getSupportedClockSources();
86     virtual bool setActiveClockSource(ClockSource);
87     virtual ClockSource getActiveClockSource();
88
89     virtual bool prepare();
90     virtual bool lock();
91     virtual bool unlock();
92
93     virtual int getStreamCount();
94
95     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
96
97     virtual bool startStreamByIndex(int i);
98     virtual bool stopStreamByIndex(int i);
99
100     virtual void showDevice();
101
102 protected:
103     unsigned int m_samplerate;
104     struct VendorModelEntry* m_model;
105
106     // streaming stuff
107     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
108     StreamProcessorVector m_receiveProcessors;
109     StreamProcessorVector m_transmitProcessors;
110
111     bool addPortsToProcessor(
112        Streaming::StreamProcessor *processor,
113        Streaming::Port::E_Direction direction);
114
115 private: // generic helpers
116     int allocateIsoChannel(unsigned int packet_size);
117     bool deallocateIsoChannel(int channel);
118
119 protected: // I/O helpers
120     // quadlet read/write routines
121     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
122     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
123     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
124     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
125
126 private:
127     BounceNotifier *m_Notifier;
128     /**
129      * this class reacts on the other side writing to the
130      * hosts address space
131      */
132     #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
133     #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4
134     class BounceNotifier : public ARMHandler
135     {
136     public:
137         BounceNotifier(BounceDevice *, nodeaddr_t start);
138         virtual ~BounceNotifier();
139
140     private:
141         BounceDevice *m_bouncedevice;
142     };
143 };
144
145 }
146
147 #endif
Note: See TracBrowser for help on using the browser.