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

Revision 639, 4.1 kB (checked in by ppalmers, 15 years ago)

- Introduce a generic infrastructure for FFADODevices to present the clock sources they support and their state
- Implement this infrastructure for BeBoB devices
- Implement this infrastructure for ECHO Fireworks devices

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/AmdtpStreamProcessor.h"
33 #include "libstreaming/AmdtpPort.h"
34 #include "libstreaming/AmdtpPortInfo.h"
35
36 #include "libieee1394/ARMHandler.h"
37
38 #include "ffadodevice.h"
39
40 #include <vector>
41
42 #define BOUNCE_REGISTER_BASE 0x0000FFFFE0000000ULL
43 #define BOUNCE_REGISTER_LENGTH (4*256)
44 #define BOUNCE_REGISTER_TX_ISOCHANNEL 0x10
45 #define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14
46 #define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL
47
48 #define BOUNCE_NB_AUDIO_CHANNELS 4
49
50 // don't define more than 8 midi channels!
51 #define BOUNCE_NB_MIDI_CHANNELS  2
52
53 class ConfigRom;
54 class Ieee1394Service;
55
56 namespace Bounce {
57
58 // struct to define the supported devices
59 struct VendorModelEntry {
60     uint32_t vendor_id;
61     uint32_t model_id;
62     uint32_t unit_specifier_id;
63     char *vendor_name;
64     char *model_name;
65 };
66
67 class BounceDevice : public FFADODevice {
68 private:
69     class BounceNotifier;
70 public:
71     BounceDevice( Ieee1394Service& ieee1394Service,
72                   std::auto_ptr<ConfigRom>( configRom ));
73     virtual ~BounceDevice();
74
75     static bool probe( ConfigRom& configRom );
76     static FFADODevice * createDevice( Ieee1394Service& ieee1394Service,
77                                         std::auto_ptr<ConfigRom>( configRom ));
78     static int getConfigurationId( );
79     virtual bool discover();
80
81     virtual bool setSamplingFrequency( int samplingFrequency );
82     virtual int getSamplingFrequency( );
83    
84     virtual ClockSourceVector getSupportedClockSources();
85     virtual bool setActiveClockSource(ClockSource);
86     virtual ClockSource getActiveClockSource();
87
88     virtual bool prepare();
89     virtual bool lock();
90     virtual bool unlock();
91
92     virtual int getStreamCount();
93
94     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
95
96     virtual bool startStreamByIndex(int i);
97     virtual bool stopStreamByIndex(int i);
98
99     virtual void showDevice();
100
101 protected:
102     unsigned int m_samplerate;
103     struct VendorModelEntry* m_model;
104
105     // streaming stuff
106     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
107     StreamProcessorVector m_receiveProcessors;
108     StreamProcessorVector m_transmitProcessors;
109
110     bool addPortsToProcessor(
111        Streaming::StreamProcessor *processor,
112        Streaming::Port::E_Direction direction);
113
114 private: // generic helpers
115     int allocateIsoChannel(unsigned int packet_size);
116     bool deallocateIsoChannel(int channel);
117
118 protected: // I/O helpers
119     // quadlet read/write routines
120     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
121     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
122     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
123     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
124
125 private:
126     BounceNotifier *m_Notifier;
127     /**
128      * this class reacts on the other side writing to the
129      * hosts address space
130      */
131     #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
132     #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4
133     class BounceNotifier : public ARMHandler
134     {
135     public:
136         BounceNotifier(BounceDevice *, nodeaddr_t start);
137         virtual ~BounceNotifier();
138
139     private:
140         BounceDevice *m_bouncedevice;
141     };
142 };
143
144 }
145
146 #endif
Note: See TracBrowser for help on using the browser.